InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IParcelList.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: dwaterfa
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 __IParcelList__
25 #define __IParcelList__
26 
27 #include "IPMUnknown.h"
28 #include "UIDRef.h"
29 #include "ParcelKey.h"
30 #include "IParcel.h"
31 
32 class ITextFrameColumn;
33 
34 
35 class IParcelList : public IPMUnknown
36 {
37  public:
38  enum { kDefaultIID = IID_IPARCELLIST };
39 
40  //
41  // ParcelLists are associated with a single FrameList because each
42  // Parcel is associated with a single TextFrame.
43  //
44  virtual UIDRef GetFrameListRef() const = 0;
45 
46  //
47  // Returns the number of Parcels in this ParcelList.
48  //
49  virtual int32 GetParcelCount() const = 0;
50 
51  //
52  // GetParcelIndex() Returns the index of the specified Parcel in
53  // the ParcelList or -1 if the Parcel is not part
54  // of the ParcelList.
55  //
56  // QueryParcel() Returns the specified Parcel or nil if the
57  //
58  virtual int32 GetParcelIndex(ParcelKey key) const = 0;
59  virtual IParcel* QueryParcel(ParcelKey key) const = 0;
60 
61  //
62  // The GetNext...() methods return the Parcel which is the FIRST Parcel
63  // at the desired location relative to the specified Parcel. If the
64  // specified Parcel is already at the specified location then it will
65  // be returned.
66  //
67  // Note: A Multi-Column Frame is a type of "Box".
68  //
69  virtual ParcelKey GetNthParcelKey(int32 index) const = 0;
70  virtual ParcelKey GetFirstParcelKey() const = 0;
71  virtual ParcelKey GetLastParcelKey() const = 0;
72  virtual ParcelKey GetPreviousParcelKey(ParcelKey key) const = 0;
73  virtual ParcelKey GetNextParcelKey(ParcelKey key) const = 0;
74  virtual ParcelKey GetNextBoxParcelKey(ParcelKey key) const = 0;
75  virtual ParcelKey GetNextPageParcelKey(ParcelKey key) const = 0;
76  virtual ParcelKey GetNextEvenPageParcelKey(ParcelKey key) const = 0;
77  virtual ParcelKey GetNextOddPageParcelKey(ParcelKey key) const = 0;
78 
79  //
80  // Bounds are expressed in an unspecified coordinate system. To place
81  // the Parcel in Text Frame coordinates use the matrix returned in
82  // GetParcelToFrameMatrix().
83  //
84  // The actual shape within the Parcel is not available through this
85  // interface.
86  //
87  virtual PMRect GetParcelBounds(ParcelKey key) const = 0;
88 
89  //
90  // The UID of the page item boss through which the Parcel is flowing.
91  //
92  virtual UID GetParcelFrameUID(ParcelKey key) const = 0;
93  virtual ITextFrameColumn* QueryParcelFrame(ParcelKey key) const = 0;
94 
95  //
96  // Returns the innerToFrame Matrix.
97  //
98  virtual PMMatrix GetParcelToFrameMatrix(ParcelKey key) const = 0;
99 
100  //
101  // Although invalidation is handled by the IPendingInvals interface
102  // on the TextFrame, the Parcel may have information that allows the
103  // client to avoid doing the invalidation in the first place. For
104  // example:
105  //
106  // ParcelKey key;
107  // PMRect invalRect;
108  // if (pl->GetParcelAcceptingInvals(key))
109  // {
110  // InterfacePtr<ITextFrameColumn> tfc(pl->QueryParcelFrame(key));
111  // InterfacePtr<IPendingInvals> pi(tfc, UseDefaultIID());
112  // pl->GetParcelToFrameMatrix(key).Transform(&invalRect);
113  // pi->RecordPendingInval(invalRect);
114  // }
115  //
116  virtual bool16 GetParcelAcceptingPendingInvals(ParcelKey key) const = 0;
117 
118  //
119  // Iterators
120  //
121  // It is acceptable to pass in an invalid ParcelKey to begin()/end()/
122  // rbegin()/rend(). The resulting iterator will be the same as if the
123  // caller had called the end()/rend() methods with no key argument.
124  //
125  // Iterators do NOT obtain a reference to the underlying ParcelList.
126  // It is the responsibility of the caller to maintain that reference
127  // over the life of the iterator.
128  //
129  class const_iterator_helper;
131  {
132  public:
133  typedef ParcelKey value_type;
134  typedef std::ptrdiff_t difference_type;
135  typedef const ParcelKey* pointer;
136  typedef const ParcelKey& reference;
137  typedef std::bidirectional_iterator_tag iterator_category;
138 
140  fHelper(helper)
141  { fKey = fHelper->dereference(); }
142 
143  const_iterator(const const_iterator& copy)
144  {
145  fHelper = copy.fHelper->copy();
146  fKey = copy.fKey;
147  }
148 
149  ~const_iterator()
150  { delete fHelper; }
151 
152  const ParcelKey& operator*() const
153  { return fKey; }
154 
155  const ParcelKey* operator->() const
156  { return &fKey; }
157 
158  const_iterator& operator=(const const_iterator& rhs)
159  {
160  if (this != &rhs)
161  {
162  delete fHelper;
163  fHelper = rhs.fHelper->copy();
164  fKey = rhs.fKey;
165  }
166  return *this;
167  }
168 
169  const_iterator& operator++()
170  {
171  fHelper->increment();
172  fKey = fHelper->dereference();
173  return *this;
174  }
175 
176  const_iterator operator++(int)
177  {
178  const_iterator tmp = *this;
179  fHelper->increment();
180  fKey = fHelper->dereference();
181  return tmp;
182  }
183 
184  const_iterator& operator--()
185  {
186  fHelper->decrement();
187  fKey = fHelper->dereference();
188  return *this;
189  }
190 
191  const_iterator operator--(int)
192  {
193  const_iterator tmp = *this;
194  fHelper->decrement();
195  fKey = fHelper->dereference();
196  return tmp;
197  }
198 
199  bool16 operator==(const const_iterator& rhs) const
200  { return fHelper->equal(rhs.fHelper); }
201 
202  bool16 operator!=(const const_iterator& rhs) const
203  { return !(*this == rhs); }
204 
205  protected:
206  const_iterator_helper* fHelper;
207  ParcelKey fKey;
208  };
209 
211  {
212  public:
213  typedef ParcelKey value_type;
214  typedef std::ptrdiff_t difference_type;
215  typedef const ParcelKey* pointer;
216  typedef const ParcelKey& reference;
217  typedef std::bidirectional_iterator_tag iterator_category;
218 
220  fIter(helper)
221  { }
222 
224  fIter(copy.fIter)
225  { }
226 
227  const ParcelKey& operator*() const
228  { return fIter.operator*(); }
229 
230  const ParcelKey* operator->() const
231  { return fIter.operator->(); }
232 
233  const_reverse_iterator& operator=(const const_reverse_iterator& rhs)
234  { this->fIter = rhs.fIter; return *this; }
235 
236  const_reverse_iterator& operator++()
237  { --fIter; return *this; }
238 
239  const_reverse_iterator operator++(int)
240  {
241  const_reverse_iterator tmp = *this;
242  ++fIter;
243  return tmp;
244  }
245 
246  const_reverse_iterator& operator--()
247  { ++fIter; return *this; }
248 
249  const_reverse_iterator operator--(int)
250  {
251  const_reverse_iterator tmp = *this;
252  --fIter;
253  return tmp;
254  }
255 
256  bool16 operator==(const const_reverse_iterator& rhs) const
257  { return (this->fIter == rhs.fIter); }
258 
259  bool16 operator!=(const const_reverse_iterator& rhs)
260  { return !(*this == rhs); }
261 
262  private:
263  const_iterator fIter;
264  };
265 
266  virtual const_iterator begin() const;
267  virtual const_iterator begin(ParcelKey key) const;
268  virtual const_iterator end() const;
269  virtual const_iterator end(ParcelKey key) const;
270  virtual const_reverse_iterator rbegin() const;
271  virtual const_reverse_iterator rbegin(ParcelKey key) const;
272  virtual const_reverse_iterator rend() const;
273  virtual const_reverse_iterator rend(ParcelKey key) const;
274 
275  //
276  // Implementation must supply a helper to assist the common iterator
277  // code above. Note that this method returns a class from the heap
278  // that must be deleted by the caller.
279  //
281  {
282  public:
283  virtual ~const_iterator_helper() { }
284  virtual ParcelKey dereference() const = 0;
285  virtual bool16 equal(const const_iterator_helper* rhs) const = 0;
286  virtual void increment() = 0;
287  virtual void decrement() = 0;
288  virtual const_iterator_helper* copy() const = 0;
289 
290  protected:
293  };
294 
295  virtual const_iterator_helper* NewIterHelper(int32 parcelIndex) const = 0;
296 
297 };
298 
299 #endif