LibreOffice Module svx (master)  1
svditer.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <svx/svditer.hxx>
21 #include <svx/svdpage.hxx>
22 #include <svx/svdobj.hxx>
23 #include <svx/svdmark.hxx>
24 
25 SdrObjListIter::SdrObjListIter(const SdrObjList* pObjList, SdrIterMode eMode, bool bReverse)
26 : maObjList(),
27  mnIndex(0),
28  mbReverse(bReverse),
29  mbUseZOrder(true)
30 {
31  if(nullptr != pObjList)
32  {
33  ImpProcessObjectList(*pObjList, eMode);
34  }
35 
36  Reset();
37 }
38 
39 SdrObjListIter::SdrObjListIter(const SdrObjList* pObjList, bool bUseZOrder, SdrIterMode eMode, bool bReverse)
40 : maObjList(),
41  mnIndex(0),
42  mbReverse(bReverse),
43  mbUseZOrder(bUseZOrder)
44 {
45  if(nullptr != pObjList)
46  {
47  // correct when we have no ObjectNavigationOrder
48  if(!mbUseZOrder && !pObjList->HasObjectNavigationOrder())
49  {
50  mbUseZOrder = false;
51  }
52 
53  ImpProcessObjectList(*pObjList, eMode);
54  }
55 
56  Reset();
57 }
58 
59 SdrObjListIter::SdrObjListIter(const SdrObject& rSdrObject, SdrIterMode eMode, bool bReverse)
60 : maObjList(),
61  mnIndex(0),
62  mbReverse(bReverse),
63  mbUseZOrder(true)
64 {
65  ImpProcessObj(rSdrObject, eMode);
66  Reset();
67 }
68 
69 SdrObjListIter::SdrObjListIter(const SdrPage* pSdrPage, SdrIterMode eMode, bool bReverse)
70 : maObjList(),
71  mnIndex(0),
72  mbReverse(bReverse),
73  mbUseZOrder(true)
74 {
75  if (const SdrObjList* pList = dynamic_cast<const SdrObjList*>(pSdrPage))
76  ImpProcessObjectList(*pList, eMode);
77  Reset();
78 }
79 
81 : maObjList(),
82  mnIndex(0),
83  mbReverse(false),
84  mbUseZOrder(true)
85 {
86  ImpProcessMarkList(rMarkList, eMode);
87  Reset();
88 }
89 
91 { for(size_t nIdx(0), nCount(rObjList.GetObjCount()); nIdx < nCount; ++nIdx)
92  {
93  const SdrObject* pSdrObject(mbUseZOrder
94  ? rObjList.GetObj(nIdx)
95  : rObjList.GetObjectForNavigationPosition(nIdx));
96 
97  if(nullptr == pSdrObject)
98  {
99  OSL_ENSURE(false, "SdrObjListIter: corrupted SdrObjList (!)");
100  }
101  else
102  {
103  ImpProcessObj(*pSdrObject, eMode);
104  }
105  }
106 }
107 
109 {
110  for( size_t nIdx = 0, nCount = rMarkList.GetMarkCount(); nIdx < nCount; ++nIdx )
111  {
112  if( SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj() )
113  {
114  ImpProcessObj(*pObj, eMode);
115  }
116  }
117 }
118 
120 {
121  // TTTT: Note: The behaviour has changed here, it will now deep-iterate
122  // for SdrObjGroup and E3dScene. Old version only deep-dived for SdrObjGroup,
123  // E3dScene was just added flat. This is now more correct, but potentially
124  // there will exist code in the 3D area that *self-iterates* with local
125  // functions/methods due to this iterator was not doing the expected thing.
126  // These will be difficult to find, but in most cases should do no harm,
127  // but cost runtime. Will need to have an eye on this aspect on continued
128  // changes...
129  const SdrObjList* pChildren(rSdrObject.getChildrenOfSdrObject());
130  const bool bIsGroup(nullptr != pChildren);
131 
132  if(!bIsGroup || (SdrIterMode::DeepNoGroups != eMode))
133  {
134  maObjList.push_back(&rSdrObject);
135  }
136 
137  if(bIsGroup && (SdrIterMode::Flat != eMode))
138  {
139  ImpProcessObjectList(*pChildren, eMode);
140  }
141 }
142 
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t GetMarkCount() const
Definition: svdmark.hxx:180
virtual SdrObjList * getChildrenOfSdrObject() const
Definition: svdobj.cxx:304
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:758
size_t GetObjCount() const
Definition: svdpage.cxx:752
SdrObject * GetObjectForNavigationPosition(const sal_uInt32 nNavigationPosition) const
Return the object for the given navigation position.
Definition: svdpage.cxx:877
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:229
int nCount
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
SdrObjListIter(const SdrObjList *pObjList, SdrIterMode eMode=SdrIterMode::DeepNoGroups, bool bReverse=false)
Definition: svditer.cxx:25
void ImpProcessObjectList(const SdrObjList &rSdrObjList, SdrIterMode eMode)
Definition: svditer.cxx:90
bool HasObjectNavigationOrder() const
Return whether there is an explicit, user defined, object navigation order.
Definition: svdpage.cxx:825
Abstract DrawObject.
Definition: svdobj.hxx:312
SdrIterMode
Definition: svditer.hxx:36
bool mbUseZOrder
Definition: svditer.hxx:43
void ImpProcessMarkList(const SdrMarkList &rMarkList, SdrIterMode eMode)
Definition: svditer.cxx:108
void ImpProcessObj(const SdrObject &rSdrObject, SdrIterMode eMode)
Definition: svditer.cxx:119
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
bool mbReverse
void Reset()
Definition: svditer.hxx:61
int mnIndex
std::vector< const SdrObject * > maObjList
Definition: svditer.hxx:40