InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IContentDropperAppData.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: vaggarwa
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 __IContentDropperAppData__
25 #define __IContentDropperAppData__
26 
27 // ----- Interfaces -----
28 #include "IContentDropperDocData.h"
29 #include "IDataBase.h"
30 
31 // ----- Includes -----
32 #include "CCollection.h"
33 #include "UIDRef.h"
34 
35 // ----- ID.h files -----
36 #include "ContentDropperID.h"
37 
38 
39 
40 //========================================================================================
41 // class IContentDropperAppData
42 //========================================================================================
43 
45 {
46 
47 public:
48  enum { kDefaultIID = IID_ICONTENTDROPPERAPPDATA };
49 
50 
51  //Iterator to traverse through the collections
52  class iterator
53  {
54  friend class IContentDropperAppData;
55  public:
57  bool16 operator==(const iterator& rhs) const
58  {
59  return (fIndex == rhs.fIndex && fIsExpanded == rhs.fIsExpanded);
60  }
61  bool16 operator!=(const iterator& rhs) const
62  {
63  return (fIndex != rhs.fIndex || fIsExpanded != rhs.fIsExpanded);
64  }
65 
66  iterator& operator++() { ++fIndex; return *this;}
67  //friend CCollection* operator*(iterator iter);
68  CCollection* operator*() const
69  {
70 
71  if(fIsExpanded)
72  {
73  int32 parentIndex = fAppData->GetIndexOfRootAtHead();
74  const CCollection* coll = fAppData->GetNthCollection(parentIndex);
75  int32 size = coll->GetNumberOfElements();
76  return coll->GetNthElement(fIndex % size);
77  }
78  else
79  {
80  int32 size = fAppData->Size();
81  return fAppData->GetNthCollection(fIndex % size);
82  }
83  }
84  private:
85  IContentDropperAppData* fAppData;
86  int32 fIndex;
87  bool16 fIsExpanded;
88  iterator();
89  iterator(IContentDropperAppData* appDataPtr, int32 index, bool16 expanded) : fAppData(appDataPtr),fIndex(index), fIsExpanded(expanded) {}
90  };
91 
92  friend class iterator;
93 
94 
95  iterator begin(){ return iterator(this,this->GetHeadIndex(), this->IsHeadExpanded()); }
96 
97  iterator end()
98  {
99  int32 endIndex = this->GetHeadIndex();
100  if(IsHeadExpanded())
101  {
102  int32 parentIndex = this->GetIndexOfRootAtHead();
103  const CCollection* coll = this->GetNthCollection(parentIndex);
104  endIndex+=coll->GetNumberOfElements();
105  }
106  else
107  {
108  endIndex+=this->Size();
109  }
110  return iterator(this,endIndex,IsHeadExpanded());
111  }
112 
113  iterator LastGrabbed()
114  {
115  int32 lastIndex;
116 
117  if(IsHeadExpanded())
118  {
119  int32 parentIndex = this->GetIndexOfRootAtHead();
120  const CCollection* coll = this->GetNthCollection(parentIndex);
121  lastIndex = coll->GetNumberOfElements() - 1;
122  }
123  else
124  {
125  lastIndex = this->Size() - 1;
126  }
127  return iterator(this,lastIndex, IsHeadExpanded());
128  }
129 
130  virtual void Create() = 0;
131 
135  virtual void Clear() = 0;
136 
137  virtual void GrabCollection(IDataBase* db, CCollection* collection) = 0;
138 
142  virtual bool16 Find(const UIDRef& uidRef) const = 0;
143 
144  virtual void RemoveAt(int32 at) = 0;
145 
146  virtual int32 GetNextCaptureID() = 0;
147 
148  //iterator methods
149  virtual int32 Size() const = 0;
150  virtual CCollection* GetFirstCollection() const = 0;
151  virtual CCollection* GetNthCollection(int32 nth) const = 0;
152  virtual CCollection* GetNthCollectionAndDB(int32 nth, IDataBase*& dbPtr ) const = 0;
153 
154 
155  virtual const CCollection* GetHeadCollection() = 0;
156  virtual IDataBase* GetHeadCollectionDB() const = 0;
157  virtual int32 MoveHead(int32 moveAhead) = 0;
158  virtual int32 MoveHeadToFirstCollection() = 0;
159  virtual int32 MoveHeadToLastCollection() = 0;
160  virtual void ExpandHead() = 0;
161  virtual void CollapseHead() = 0;
162  virtual bool16 IsHeadExpanded() const = 0;
163  virtual void RemoveAtHead() = 0;
164  virtual bool16 CanExpandHead() = 0;
165  virtual bool16 CanCollapseHead() = 0;
166  virtual PMString GetDescriptionString() const = 0;
167  virtual int32 GetNumOfItemsInLevel() const = 0;
168 protected:
169  virtual int32 GetHeadIndex() = 0;
170  virtual int32 GetIndexOfRootAtHead() const = 0;
171 
172 
173 };
174 
175 
176 
177 
178 #endif