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 .
22 #include <svx/svditer.hxx>
23 #include <OutlinerIterator.hxx>
35 /** Base class for the polymorphic implementation class of the
36 <type>Iterator</type> class. The iterators based on this class are
37 basically uni directional iterators. Their direction can, however, be
38 reversed at any point of their life time.
40 class IteratorImplBase
43 /** The constructor stores the given arguments to be used by the derived
46 The document provides the information to be iterated on.
48 Some information has to be taken from the view shell.
49 @param bDirectionIsForward
50 This flag defines the iteration direction. When <TRUE/> then
51 the direction is forwards otherwise it is backwards.
53 IteratorImplBase (SdDrawDocument
* pDocument
,
54 const std::weak_ptr
<ViewShell
>& rpViewShellWeak
,
55 bool bDirectionIsForward
);
56 IteratorImplBase (SdDrawDocument
* pDocument
,
57 std::weak_ptr
<ViewShell
> pViewShellWeak
,
58 bool bDirectionIsForward
, PageKind ePageKind
, EditMode eEditMode
);
59 virtual ~IteratorImplBase();
61 /** Advance to the next text of the current object or to the next object.
62 This takes the iteration direction into
63 account. The new object pointed to can be retrieved (among other
64 information) by calling the <member>GetPosition</member> method.
66 virtual void GotoNextText() = 0;
67 /** Return an object that describes the current object.
69 The returned object describes the current object pointed to by
70 the iterator. See the description of
71 <type>IteratorPosition</type> for details on the available
74 virtual const IteratorPosition
& GetPosition();
75 /** Create an exact copy of this object. No argument should be
76 specified when called from the outside. It then creates an object
77 first and passes that to the inherited <member>Clone()</member>
78 methods to fill in class specific information.
80 Returns a copy of this object. When this method is called with
81 an argument then this value will be returned.
83 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
=nullptr) const;
84 /** Test the equality of the this object and the given iterator. Two
85 iterators are taken to be equal when they point to the same object.
86 Iteration direction is not taken into account.
88 The iterator to compare to.
90 When both iterators are equal <TRUE/> is returned, <FALSE/> otherwise.
92 virtual bool operator== (const IteratorImplBase
& rIterator
) const;
93 /** This method is used by the equality operator. It is part of a "multimethod" pattern.
95 The iterator to compare to.
97 Returns <TRUE/> when both iterators point to the same object.
99 virtual bool IsEqualSelection(const IteratorImplBase
& rIterator
) const;
100 /** Reverse the direction of iteration. The current object stays the same.
102 virtual void Reverse();
105 /// The current position as returned by <member>GetPosition()</member>.
106 IteratorPosition maPosition
;
107 /// The document on whose data the iterator operates.
108 SdDrawDocument
* mpDocument
;
109 /// Necessary secondary source of information.
110 std::weak_ptr
<ViewShell
> mpViewShellWeak
;
111 /// Specifies the search direction.
112 bool mbDirectionIsForward
;
115 /** Iterator all objects that belong to the current mark list
116 a.k.a. selection. It is assumed that all marked objects belong to the
117 same page. It is further assumed that the mark list does not change
118 while an iterator is alive. It is therefore the responsibility of an
119 iterator's owner to handle the case of a changed mark list.
121 <p>For documentation of the methods please refer to the base class
122 <type>IteratorImplBase</type>.</p>
124 class SelectionIteratorImpl final
125 : public IteratorImplBase
128 SelectionIteratorImpl (
129 const ::std::vector
< ::unotools::WeakReference
<SdrObject
> >& rObjectList
,
130 sal_Int32 nObjectIndex
,
131 SdDrawDocument
* pDocument
,
132 const std::weak_ptr
<ViewShell
>& rpViewShellWeak
,
133 bool bDirectionIsForward
);
134 SelectionIteratorImpl (const SelectionIteratorImpl
& rObject
);
135 virtual ~SelectionIteratorImpl() override
;
137 virtual void GotoNextText() override
;
138 virtual const IteratorPosition
& GetPosition() override
;
139 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
= nullptr) const override
;
140 virtual bool operator== (const IteratorImplBase
& rIterator
) const override
;
143 const ::std::vector
<::unotools::WeakReference
<SdrObject
>>& mrObjectList
;
144 sal_Int32 mnObjectIndex
;
146 /** Compare the given iterator with this object. This method handles
147 only the case that the given iterator is an instance of this class.
149 The iterator to compare to.
151 Returns <TRUE/> when both iterators point to the same object.
153 virtual bool IsEqualSelection(const IteratorImplBase
& rIterator
) const override
;
155 IteratorImplBase
& operator= (const IteratorImplBase
& rIterator
);
158 /** Iterator for iteration over all objects in all views. It switches views when
161 Iterates in the following pattern
162 1-) Alternating Normal View and Notes View for each page
165 4-) The Handout Master
167 <p>For documentation of the methods please refer to the base class
168 <type>IteratorImplBase</type>.</p>
170 class DocumentIteratorImpl final
: public IteratorImplBase
173 DocumentIteratorImpl (
174 sal_Int32 nPageIndex
,
177 SdDrawDocument
* pDocument
,
178 const std::weak_ptr
<ViewShell
>& rpViewShellWeak
,
179 bool bDirectionIsForward
);
180 virtual ~DocumentIteratorImpl() override
;
182 virtual void GotoNextText() override
;
183 virtual IteratorImplBase
* Clone (IteratorImplBase
* pObject
= nullptr) const override
;
184 virtual void Reverse() override
;
187 /** Set up page pointer and object list iterator for the specified
190 Index of the new page. It may lie outside the valid range for
193 void SetPage (sal_Int32 nPageIndex
);
195 /// Iterator of all objects on the current page.
196 std::optional
<SdrObjListIter
> moObjectIterator
;
198 /// Pointer to the page associated with the current page index. May be NULL.
201 /// Number of pages in the view that is specified by <member>maPosition</member>.
202 sal_Int32 mnPageCount
;
204 // Don't use this operator.
205 DocumentIteratorImpl
& operator= (const DocumentIteratorImpl
& ) = delete;
208 } } // end of namespace ::sd::outliner
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */