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 INCLUDED_SD_SOURCE_UI_INC_OUTLINERITERATORIMPL_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_OUTLINERITERATORIMPL_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();
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() = 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();
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. Additionally 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();
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
;
123 /** Iterator all objects that belong to the current mark list
124 a.k.a. selection. It is assumed that all marked objects belong to the
125 same page. It is further assumed that the mark list does not change
126 while an iterator is alive. It is therefore the responsibility of an
127 iterator's owner to handle the case of a changed mark list.
129 <p>For documentation of the methods please refere to the base class
130 <type>IteratorImplBase</type>.</p>
132 class SelectionIteratorImpl
133 : public IteratorImplBase
136 SelectionIteratorImpl (
137 const ::std::vector
< SdrObjectWeakRef
>& rObjectList
,
138 sal_Int32 nObjectIndex
,
139 SdDrawDocument
* pDocument
,
140 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
141 bool bDirectionIsForward
);
142 SelectionIteratorImpl (const SelectionIteratorImpl
& rObject
);
143 virtual ~SelectionIteratorImpl();
145 virtual void GotoNextText() SAL_OVERRIDE
;
146 virtual const IteratorPosition
& GetPosition() SAL_OVERRIDE
;
147 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
) const SAL_OVERRIDE
;
148 virtual bool operator== (const IteratorImplBase
& rIterator
) const SAL_OVERRIDE
;
151 const ::std::vector
<SdrObjectWeakRef
>& mrObjectList
;
152 sal_Int32 mnObjectIndex
;
154 /** Compare the given iterator with this object. This method handles
155 only the case that the given iterator is an instance of this class.
157 The iterator to compare to.
159 The type of the iterator.
161 Returns <TRUE/> when both iterators point to the same object.
163 virtual bool IsEqual (const IteratorImplBase
& rIterator
, IteratorType aType
) const SAL_OVERRIDE
;
165 IteratorImplBase
& operator= (const IteratorImplBase
& rIterator
);
168 /** Iterator for iteration over all objects in a single view. On reaching
169 the last object on the last page (or the first object on the first page)
170 the view is *not* switched. Further calls to the
171 <member>GotoNextObject()</member> method will be ignored.
173 <p>For documentation of the methods please refere to the base class
174 <type>IteratorImplBase</type>.</p>
176 class ViewIteratorImpl
: public IteratorImplBase
180 sal_Int32 nPageIndex
,
181 SdDrawDocument
* pDocument
,
182 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
183 bool bDirectionIsForward
);
185 sal_Int32 nPageIndex
,
186 SdDrawDocument
* pDocument
,
187 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
188 bool bDirectionIsForward
,
191 virtual ~ViewIteratorImpl();
193 virtual void GotoNextText() SAL_OVERRIDE
;
194 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
) const SAL_OVERRIDE
;
195 virtual void Reverse() SAL_OVERRIDE
;
198 /** Initialize this iterator with respect to the given location. After
199 this call the object looks like newly constructed.
201 void Init (IteratorLocation aLocation
);
203 /** Set up page pointer and object list iterator for the specified
206 Index of the new page. It may lie outside the valid range for
209 void SetPage (sal_Int32 nPageIndex
);
212 /// Indicates whether a page changed occurred on switching to current page.
213 bool mbPageChangeOccurred
;
214 /// Pointer to the page associated with the current page index. May be NULL.
216 /// Iterator of all objects on the current page.
217 SdrObjListIter
* mpObjectIterator
;
219 // Don't use this operator.
220 ViewIteratorImpl
& operator= (const ViewIteratorImpl
&){return *this;};
223 /** Iterator for iteration over all objects in all views. It automatically
224 switches views when reaching the end/beginning of a view.
226 <p>For documentation of the methods please refere to the base class
227 <type>IteratorImplBase</type>.</p>
229 class DocumentIteratorImpl
: public ViewIteratorImpl
232 DocumentIteratorImpl (
233 sal_Int32 nPageIndex
,
236 SdDrawDocument
* pDocument
,
237 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
238 bool bDirectionIsForward
);
239 virtual ~DocumentIteratorImpl();
241 virtual void GotoNextText() SAL_OVERRIDE
;
242 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
) const SAL_OVERRIDE
;
245 /// Number of pages in the view that is specified by <member>maPosition</member>.
246 sal_Int32 mnPageCount
;
248 // Don't use this operator.
249 DocumentIteratorImpl
& operator= (const DocumentIteratorImpl
& ){return *this;};
252 } } // end of namespace ::sd::outliner
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */