InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AttributeBossList.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Eric_Menninga
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 __AttributeBossList__
25 #define __AttributeBossList__
26 
27 #include "K2Vector.h"
28 #include "KeyValuePair.h"
29 #include "K2SmartPtr.h"
30 
31 class IPMUnknown;
32 class IObjectModel;
33 class IPMStream;
34 class IClassInfo;
35 class IAttrBossReferencing;
36 
37  // sorted list by ClassID
38  // each value has a pointer to the boss, and whether the boss can be
39  // copied to other AttributeBossLists (is it "missing").
42 
43 
44 
58 {
59  public:
60  typedef object_type data_type;
64 
65  AttributeBossList& operator=(const AttributeBossList& other);
66 
67  enum ReadWriteStatus { kSuccess, kListChangedOnRead };
68  ReadWriteStatus ReadWrite(IPMStream* stream);
69 
70  AttributeBossList(AttributeBossList&& copy) noexcept
71 #ifdef DEBUG
72  :fMirror(nil)
73 #endif
74  {
75  swap(*this, copy);
76  }
77 
78  AttributeBossList &operator =(AttributeBossList&& copy) noexcept
79  {
80  swap(*this, copy);
81 
82  return *this;
83  }
84 
85  friend inline void swap(AttributeBossList &a, AttributeBossList &b) noexcept
86  {
87  using std::swap;
88  swap(a.fBosses, b.fBosses);
89 #ifdef DEBUG
90  swap(a.fMirror, b.fMirror);
91 #endif
92 #ifdef INTERFACEPROXIES_SUPPORTED
93  swap(a.fTokens, b.fTokens);
94 #endif
95  }
96 
99  int32 CountBosses() const;
100 
104  ClassID GetClassN(int32 n) const;
105 
111  const IPMUnknown* QueryBossN(int32 n, PMIID id) const;
112 
118  const IPMUnknown* QueryByClassID(ClassID c, PMIID id) const;
119 
125  void ApplyAttribute(const IPMUnknown *newone, const ClassID attrClass = kInvalidClass);
126 
130  void ApplyAttributes(const AttributeBossList *list);
131 
135  void ClearOverride(ClassID id);
136 
141  void ClearOverrides(const AttributeBossList *list);
142 
145  void ClearNonStyleOverrides();
146 
149  void ClearAllOverrides();
150 
155  AttributeBossList* Duplicate() const;
156 
163 
167  bool16 ContainsAttribute(ClassID klas) const;
168 
175  bool16 ContainsExact(IDataBase *db, const IPMUnknown *check, ClassID klas = kInvalidClass) const;
176 
180  bool16 IsEqual(IDataBase *db, const AttributeBossList* other) const;
181 
185  bool16 Intersects(const AttributeBossList* other) const;
186 
193  bool16 IntersectionContainsDifferences(IDataBase * db, const AttributeBossList * other) const;
194 
201  static uint32 ConvertAttributeList(IPMStream *inStream, IPMStream *outStream, ImplementationID context);
202 
209  static uint32 CopyAttributeList(IPMStream *inStream, IPMStream *outStream);
210 
214 #ifdef DEBUG
215  static bool16 ts_DebugAttributeBossList;
216 
217  bool16 CheckAttributeBossList() const;
218  inline bool16 IsChecking() const { return fMirror != nil; }
219 
220  private:
221  AttributeBossList *fMirror;
222 #endif
223 
224  protected:
225  ReadWriteStatus DoWrite(IPMStream* stream);
226  ReadWriteStatus DoRead(IPMStream* stream);
227 
228  void CopyInto(AttributeBossList *) const;
229 
230  bool16 AllowCopy(ClassID attrClass, IPMUnknown *boss) const;
231 
232 #ifdef DEBUG
233  void _ReferenceAttribute(ClassID cls, IPMUnknown *attr);
234  void _DereferenceAttribute(ClassID cls, IPMUnknown *attr);
235 #endif
236 
237  private:
238  BossLookup fBosses;
239 #ifdef INTERFACEPROXIES_SUPPORTED
240  BossLookup fTokens;
241 #endif
242 
243 private:
247  void StripMissingAttributes();
248 
249  bool16 operator==(const AttributeBossList& other) const;
250  bool16 operator!=(const AttributeBossList& other) const;
251 
252 public:
256  static boost::shared_ptr<AttributeBossList> kNil_shared_ptr;
257 };
258 
259 /* IDAttributeList class is used to also associate a data base with attribute boss list */
261 public:
262  typedef object_type data_type;
263 
264  IDAttributeList() : fAttributeList(nil), fDB(nil) {}
265 
266  IDAttributeList(const AttributeBossList * attrList, IDataBase * db) : fAttributeList(attrList), fDB(db) {}
267 
268  const AttributeBossList * GetAttributeList() const { return fAttributeList; }
269  IDataBase * GetDataBase() const { return fDB; }
270 
271 private:
272  IDataBase * fDB;
273  const AttributeBossList * fAttributeList;
274 };
275 
276 
277 #endif
278  // __AttributeBossList__