merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / inc / OutlinerIteratorImpl.hxx
blob482af32f1353760d8fdae71f09672b7a50f4d36e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OutlinerIteratorImpl.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_OUTLINER_ITERATOR_IMPL_HXX
32 #define SD_OUTLINER_ITERATOR_IMPL_HXX
34 #include <svx/svdobj.hxx>
35 #include "OutlinerIterator.hxx"
36 #include <boost/weak_ptr.hpp>
38 class SdDrawDocument;
39 class SdPage;
40 class SdrObjListIter;
42 namespace sd {
44 class ViewShell;
46 namespace outliner {
48 class IteratorImplBase;
50 /** Base class for the polymorphic implementation class of the
51 <type>Iterator</type> class. The iterators based on this class are
52 basically uni directional iterators. Their direction can, however, be
53 reversed at any point of their life time.
55 class IteratorImplBase
57 public:
58 /** The constructor stores the given arguments to be used by the derived
59 classes.
60 @param pDocument
61 The document provides the information to be iterated on.
62 @param pViewShellWeak
63 Some information has to be taken from the view shell.
64 @param bDirectionIsForward
65 This flag defines the iteration direction. When <TRUE/> then
66 the direction is forwards otherwise it is backwards.
68 IteratorImplBase (SdDrawDocument* pDocument,
69 const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
70 bool bDirectionIsForward);
71 IteratorImplBase (SdDrawDocument* pDocument,
72 const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
73 bool bDirectionIsForward, PageKind ePageKind, EditMode eEditMode);
74 virtual ~IteratorImplBase (void);
76 /** Advance to the next text of the current object or to the next object.
77 This takes the iteration direction into
78 account. The new object pointed to can be retrieved (among other
79 information) by calling the <member>GetPosition</member> method.
81 virtual void GotoNextText (void) = 0;
82 /** Return an object that describes the current object.
83 @return
84 The returned object describes the current object pointed to by
85 the iterator. See the description of
86 <type>IteratorPosition</type> for details on the available
87 information.
89 virtual const IteratorPosition& GetPosition (void);
90 /** Create an exact copy of this object. No argument should be
91 specified when called from the outside. It then creates an object
92 first and passes that to the inherited <member>Clone()</member>
93 methods to fill in class specific information.
94 @return
95 Returns a copy of this object. When this method is called with
96 an argument then this value will be returned.
98 virtual IteratorImplBase* Clone (IteratorImplBase* pObject=NULL) const;
99 /** Test the equality of the this object and the given iterator. Two
100 iterators are taken to be equal when they point to the same object.
101 Iteration direction is not taken into account.
102 @param rIterator
103 The iterator to compare to.
104 @return
105 When both iterators ar equal <TRUE/> is returned, <FALSE/> otherwise.
107 virtual bool operator== (const IteratorImplBase& rIterator) const;
108 /** This method is used by the equality operator. Additionaly to the
109 iterator it takes a type information which is taken into account on
110 comparison. It is part of a "multimethod" pattern.
111 @param rIterator
112 The iterator to compare to.
113 @param aType
114 The type of the iterator.
115 @return
116 Returns <TRUE/> when both iterators point to the same object.
118 virtual bool IsEqual (const IteratorImplBase& rIterator, IteratorType aType) const;
119 /** Reverse the direction of iteration. The current object stays the same.
121 virtual void Reverse (void);
123 protected:
124 /// The current position as returned by <member>GetPosition()</member>.
125 IteratorPosition maPosition;
126 /// The document on whose data the iterator operates.
127 SdDrawDocument* mpDocument;
128 /// Necessary secondary source of information.
129 ::boost::weak_ptr<ViewShell> mpViewShellWeak;
130 /// Specifies the search direction.
131 bool mbDirectionIsForward;
137 /** Iterator all objects that belong to the current mark list
138 a.k.a. selection. It is assumed that all marked objects belong to the
139 same page. It is further assumed that the mark list does not change
140 while an iterator is alive. It is therefore the responsibility of an
141 iterator's owner to handle the case of a changed mark list.
143 <p>For documentation of the methods please refere to the base class
144 <type>IteratorImplBase</type>.</p>
146 class SelectionIteratorImpl
147 : public IteratorImplBase
149 public:
150 SelectionIteratorImpl (
151 const ::std::vector< SdrObjectWeakRef >& rObjectList,
152 sal_Int32 nObjectIndex,
153 SdDrawDocument* pDocument,
154 const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
155 bool bDirectionIsForward);
156 SelectionIteratorImpl (const SelectionIteratorImpl& rObject);
157 virtual ~SelectionIteratorImpl (void);
159 virtual void GotoNextText (void);
160 virtual const IteratorPosition& GetPosition (void);
161 virtual IteratorImplBase* Clone (IteratorImplBase* pObject) const;
162 virtual bool operator== (const IteratorImplBase& rIterator) const;
164 private:
165 const ::std::vector<SdrObjectWeakRef>& mrObjectList;
166 sal_Int32 mnObjectIndex;
168 /** Compare the given iterator with this object. This method handles
169 only the case that the given iterator is an instance of this class.
170 @param rIterator
171 The iterator to compare to.
172 @param aType
173 The type of the iterator.
174 @return
175 Returns <TRUE/> when both iterators point to the same object.
177 virtual bool IsEqual (const IteratorImplBase& rIterator, IteratorType aType) const;
179 IteratorImplBase& operator= (const IteratorImplBase& rIterator);
183 /** Iterator for iteration over all objects in a single view. On reaching
184 the last object on the last page (or the first object on the first page)
185 the view is *not* switched. Further calls to the
186 <member>GotoNextObject()</member> method will be ignored.
188 <p>For documentation of the methods please refere to the base class
189 <type>IteratorImplBase</type>.</p>
191 class ViewIteratorImpl : public IteratorImplBase
193 public:
194 ViewIteratorImpl (
195 sal_Int32 nPageIndex,
196 SdDrawDocument* pDocument,
197 const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
198 bool bDirectionIsForward);
199 ViewIteratorImpl (
200 sal_Int32 nPageIndex,
201 SdDrawDocument* pDocument,
202 const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
203 bool bDirectionIsForward,
204 PageKind ePageKind,
205 EditMode eEditMode);
206 virtual ~ViewIteratorImpl (void);
208 virtual void GotoNextText (void);
209 virtual IteratorImplBase* Clone (IteratorImplBase* pObject) const;
210 virtual void Reverse (void);
212 protected:
213 /// Number of pages in the view that is specified by <member>maPosition</member>.
214 sal_Int32 mnPageCount;
216 /** Initialize this iterator with respect to the given location. After
217 this call the object looks like newly constructed.
219 void Init (IteratorLocation aLocation);
221 /** Set up page pointer and object list iterator for the specified
222 page.
223 @param nPageIndex
224 Index of the new page. It may lie outside the valid range for
225 page indices.
227 void SetPage (sal_Int32 nPageIndex);
229 private:
230 /// Indicates whether a page changed occured on switching to current page.
231 bool mbPageChangeOccured;
232 /// Pointer to the page associated with the current page index. May be NULL.
233 SdPage* mpPage;
234 /// Iterator of all objects on the current page.
235 SdrObjListIter* mpObjectIterator;
237 // Don't use this operator.
238 ViewIteratorImpl& operator= (const ViewIteratorImpl&){return *this;};
244 /** Iterator for iteration over all objects in all views. It automatically
245 switches views when reaching the end/beginning of a view.
247 <p>For documentation of the methods please refere to the base class
248 <type>IteratorImplBase</type>.</p>
250 class DocumentIteratorImpl : public ViewIteratorImpl
252 public:
253 DocumentIteratorImpl (
254 sal_Int32 nPageIndex,
255 PageKind ePageKind,
256 EditMode eEditMode,
257 SdDrawDocument* pDocument,
258 const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
259 bool bDirectionIsForward);
260 virtual ~DocumentIteratorImpl (void);
262 virtual void GotoNextText (void);
263 virtual IteratorImplBase* Clone (IteratorImplBase* pObject) const;
265 private:
266 sal_Int32 mnPageCount;
268 // Don't use this operator.
269 DocumentIteratorImpl& operator= (const DocumentIteratorImpl& ){return *this;};
273 } } // end of namespace ::sd::outliner
275 #endif