1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SD_OUTLINER_ITERATOR_IMPL_HXX
21 #define SD_OUTLINER_ITERATOR_IMPL_HXX
23 #include <svx/svdobj.hxx>
24 #include "OutlinerIterator.hxx"
25 #include <boost/weak_ptr.hpp>
37 class IteratorImplBase
;
39 /** Base class for the polymorphic implementation class of the
40 <type>Iterator</type> class. The iterators based on this class are
41 basically uni directional iterators. Their direction can, however, be
42 reversed at any point of their life time.
44 class IteratorImplBase
47 /** The constructor stores the given arguments to be used by the derived
50 The document provides the information to be iterated on.
52 Some information has to be taken from the view shell.
53 @param bDirectionIsForward
54 This flag defines the iteration direction. When <TRUE/> then
55 the direction is forwards otherwise it is backwards.
57 IteratorImplBase (SdDrawDocument
* pDocument
,
58 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
59 bool bDirectionIsForward
);
60 IteratorImplBase (SdDrawDocument
* pDocument
,
61 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
62 bool bDirectionIsForward
, PageKind ePageKind
, EditMode eEditMode
);
63 virtual ~IteratorImplBase (void);
65 /** Advance to the next text of the current object or to the next object.
66 This takes the iteration direction into
67 account. The new object pointed to can be retrieved (among other
68 information) by calling the <member>GetPosition</member> method.
70 virtual void GotoNextText (void) = 0;
71 /** Return an object that describes the current object.
73 The returned object describes the current object pointed to by
74 the iterator. See the description of
75 <type>IteratorPosition</type> for details on the available
78 virtual const IteratorPosition
& GetPosition (void);
79 /** Create an exact copy of this object. No argument should be
80 specified when called from the outside. It then creates an object
81 first and passes that to the inherited <member>Clone()</member>
82 methods to fill in class specific information.
84 Returns a copy of this object. When this method is called with
85 an argument then this value will be returned.
87 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
=NULL
) const;
88 /** Test the equality of the this object and the given iterator. Two
89 iterators are taken to be equal when they point to the same object.
90 Iteration direction is not taken into account.
92 The iterator to compare to.
94 When both iterators ar equal <TRUE/> is returned, <FALSE/> otherwise.
96 virtual bool operator== (const IteratorImplBase
& rIterator
) const;
97 /** This method is used by the equality operator. Additionaly to the
98 iterator it takes a type information which is taken into account on
99 comparison. It is part of a "multimethod" pattern.
101 The iterator to compare to.
103 The type of the iterator.
105 Returns <TRUE/> when both iterators point to the same object.
107 virtual bool IsEqual (const IteratorImplBase
& rIterator
, IteratorType aType
) const;
108 /** Reverse the direction of iteration. The current object stays the same.
110 virtual void Reverse (void);
113 /// The current position as returned by <member>GetPosition()</member>.
114 IteratorPosition maPosition
;
115 /// The document on whose data the iterator operates.
116 SdDrawDocument
* mpDocument
;
117 /// Necessary secondary source of information.
118 ::boost::weak_ptr
<ViewShell
> mpViewShellWeak
;
119 /// Specifies the search direction.
120 bool mbDirectionIsForward
;
126 /** Iterator all objects that belong to the current mark list
127 a.k.a. selection. It is assumed that all marked objects belong to the
128 same page. It is further assumed that the mark list does not change
129 while an iterator is alive. It is therefore the responsibility of an
130 iterator's owner to handle the case of a changed mark list.
132 <p>For documentation of the methods please refere to the base class
133 <type>IteratorImplBase</type>.</p>
135 class SelectionIteratorImpl
136 : public IteratorImplBase
139 SelectionIteratorImpl (
140 const ::std::vector
< SdrObjectWeakRef
>& rObjectList
,
141 sal_Int32 nObjectIndex
,
142 SdDrawDocument
* pDocument
,
143 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
144 bool bDirectionIsForward
);
145 SelectionIteratorImpl (const SelectionIteratorImpl
& rObject
);
146 virtual ~SelectionIteratorImpl (void);
148 virtual void GotoNextText (void);
149 virtual const IteratorPosition
& GetPosition (void);
150 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
) const;
151 virtual bool operator== (const IteratorImplBase
& rIterator
) const;
154 const ::std::vector
<SdrObjectWeakRef
>& mrObjectList
;
155 sal_Int32 mnObjectIndex
;
157 /** Compare the given iterator with this object. This method handles
158 only the case that the given iterator is an instance of this class.
160 The iterator to compare to.
162 The type of the iterator.
164 Returns <TRUE/> when both iterators point to the same object.
166 virtual bool IsEqual (const IteratorImplBase
& rIterator
, IteratorType aType
) const;
168 IteratorImplBase
& operator= (const IteratorImplBase
& rIterator
);
172 /** Iterator for iteration over all objects in a single view. On reaching
173 the last object on the last page (or the first object on the first page)
174 the view is *not* switched. Further calls to the
175 <member>GotoNextObject()</member> method will be ignored.
177 <p>For documentation of the methods please refere to the base class
178 <type>IteratorImplBase</type>.</p>
180 class ViewIteratorImpl
: public IteratorImplBase
184 sal_Int32 nPageIndex
,
185 SdDrawDocument
* pDocument
,
186 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
187 bool bDirectionIsForward
);
189 sal_Int32 nPageIndex
,
190 SdDrawDocument
* pDocument
,
191 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
192 bool bDirectionIsForward
,
195 virtual ~ViewIteratorImpl (void);
197 virtual void GotoNextText (void);
198 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
) const;
199 virtual void Reverse (void);
202 /// Number of pages in the view that is specified by <member>maPosition</member>.
203 sal_Int32 mnPageCount
;
205 /** Initialize this iterator with respect to the given location. After
206 this call the object looks like newly constructed.
208 void Init (IteratorLocation aLocation
);
210 /** Set up page pointer and object list iterator for the specified
213 Index of the new page. It may lie outside the valid range for
216 void SetPage (sal_Int32 nPageIndex
);
219 /// Indicates whether a page changed occurred on switching to current page.
220 bool mbPageChangeOccurred
;
221 /// Pointer to the page associated with the current page index. May be NULL.
223 /// Iterator of all objects on the current page.
224 SdrObjListIter
* mpObjectIterator
;
226 // Don't use this operator.
227 ViewIteratorImpl
& operator= (const ViewIteratorImpl
&){return *this;};
233 /** Iterator for iteration over all objects in all views. It automatically
234 switches views when reaching the end/beginning of a view.
236 <p>For documentation of the methods please refere to the base class
237 <type>IteratorImplBase</type>.</p>
239 class DocumentIteratorImpl
: public ViewIteratorImpl
242 DocumentIteratorImpl (
243 sal_Int32 nPageIndex
,
246 SdDrawDocument
* pDocument
,
247 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
248 bool bDirectionIsForward
);
249 virtual ~DocumentIteratorImpl (void);
251 virtual void GotoNextText (void);
252 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
) const;
255 sal_Int32 mnPageCount
;
257 // Don't use this operator.
258 DocumentIteratorImpl
& operator= (const DocumentIteratorImpl
& ){return *this;};
262 } } // end of namespace ::sd::outliner
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */