InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IFontGroupId.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: mvogel
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __IFontGroupId__
25 #define __IFontGroupId__
26 
27 #include "GRRefCountedObj.h"
28 #include "InterfacePtr.h"
29 #include "IFontGroup.h"
30 #include "BravoForwardDecl.h"
31 
32 #include "IPMFont.h"
33 
34 class PMString;
35 
36 #define ALLOWDUPFONTS 1
37 
43 {
44 public:
45  IFontGroupId (IFontGroup *group, PMString const &fontGroupName, PMString const &fontGroupNameNative) :
46  fGroup (group),
47  fFontGroupName (fontGroupName),
48  fFontGroupNameNative (fontGroupNameNative),
49  fFontType (IPMFont::kUnknownFontType)
50  {
51  if (fGroup)
52  fGroup->AddRef();
53  }
54 
55  IFontGroupId (IFontGroup *group, PMString const &fontGroupName, PMString const &fontGroupNameNative, IPMFont::FontType fontType) :
56  fGroup(group),
57  fFontGroupName (fontGroupName),
58  fFontGroupNameNative (fontGroupNameNative),
59  fFontType (fontType)
60  {
61  if (fGroup)
62  fGroup->AddRef();
63  }
64 
65  ~IFontGroupId()
66  {
67  if (fGroup)
68  {
69  fGroup->Release();
70  fGroup = nil;
71  }
72  }
73 
74  const PMString &GetName() const
75  {
76  return fFontGroupName;
77  }
78  IFontGroup *GetGroup() const
79  {
80  return fGroup;
81  }
82  IPMFont::FontType GetFontType() const
83  {
84  return fFontType;
85  }
86  bool16 operator == (const IFontGroupId &value) const
87  { // There are ill-formed fonts whose native family names differ within the group but whose non-native family names
88  // are identical across the group. In the English locale, for example, these would be considered a single group
89  // if we relied only on the non-native name. But we must treat them separately in order to avoid problems
90  // elsewhere. Hence we compare against both native and non-native.
91  // On the other hand, if native is empty, it signals "unknown", effectively, and we'll allow a match there
92  // because in any normal circumstance that should be true.
93  if (value.fFontGroupName == fFontGroupName && (
94  fFontGroupNameNative.empty() || value.fFontGroupNameNative.empty() ||
95  value.fFontGroupNameNative == fFontGroupNameNative))
96  return fFontType == value.GetFontType() ||
97  fFontType == IPMFont::kUnknownFontType || value.GetFontType() == IPMFont::kUnknownFontType;
98 
99  return kFalse;
100  }
101 
102 
103 private:
104  IFontGroupId() :
105  fGroup(nil),
106  fFontGroupName(),
107  fFontGroupNameNative(),
108  fFontType(IPMFont::kUnknownFontType)
109  {}
110  // Copy constructor
111  IFontGroupId( const IFontGroupId& orig ) :
112  fGroup(orig.fGroup),
113  fFontGroupName(orig.fFontGroupName),
114  fFontGroupNameNative (orig.fFontGroupNameNative),
115  fFontType(orig.fFontType)
116  {
117  ASSERT_FAIL("DOES THIS HAPPEN??");
118  //if (fGroup) fGroup->AddRef();
119  }
120 
121  IFontGroupId& operator=(const IFontGroupId& fontGroupIdentifierPtr);
122 
123  IFontGroup *fGroup;
124  PMString fFontGroupName;
125  PMString fFontGroupNameNative;
126  IPMFont::FontType fFontType;
127 };
128 
129 DECLARE_OBJECT_TYPE(IFontGroupId);
130 
131 template <>
133 {
134 public:
135  InterfacePtr(IFontGroupId * pFace)
136  // Note: Constructing an InterfacePtr from an existing,
137  // "real" interface pointer implies the InterfacePtr
138  // now owns the reference that was held by the real pointer.
139  : fFace(pFace) {}
140 
141  ~InterfacePtr()
142  {
143  if (fFace != nil){
144  //const_cast<IFontGroupId *>(unknown)->Release();
145  fFace->Release();
146  }
147  }
148 
149  operator IFontGroupId*() const
150  { return fFace; }
151  // We allow the cast operator to return a nil pointer
152  // since it is valid to test against nil and may be valid
153  // to pass a nil pointer to some methods.
154 
155 
156  IFontGroupId * operator ->() const
157  {
158  #ifdef DEBUG
159  ASSERT_MSG(fFace != nil,"About to use nil interface ptr!");
160  #endif
161  return fFace;
162  }
163 
164 private:
165  IFontGroupId * fFace;
166 
167  // If you feel you need one of these, let me know. Thx. - Zak
168  // For the sake of clarity and simplicity, they're currently not supported.
169 
170  InterfacePtr(void);
171  InterfacePtr(const InterfacePtr<IFontGroupId>& fontGroupIdentifierPtr);
172  InterfacePtr<IFontGroupId>& operator=(const InterfacePtr<IFontGroupId>& fontGroupIdentifierPtr);
173  InterfacePtr<IFontGroupId>& operator=(IFontGroupId * pFace);
174 
175 };
176 
177 #endif
178  //__IFontGroupId__
179