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#include <osl/diagnose.h>
25
26SdrObjListIter::SdrObjListIter(const SdrObjList* pObjList, SdrIterMode eMode, bool bReverse)
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
39SdrObjListIter::SdrObjListIter(const SdrObjList* pObjList, bool bUseZOrder, SdrIterMode eMode, bool bReverse)
40: mnIndex(0),
41 mbReverse(bReverse),
42 mbUseZOrder(bUseZOrder)
43{
44 if(nullptr != pObjList)
45 {
46 // correct when we have no ObjectNavigationOrder
47 if(!mbUseZOrder && !pObjList->HasObjectNavigationOrder())
48 {
49 mbUseZOrder = false;
50 }
51
52 ImpProcessObjectList(*pObjList, eMode);
53 }
54
55 Reset();
56}
57
58SdrObjListIter::SdrObjListIter(const SdrObject& rSdrObject, SdrIterMode eMode, bool bReverse)
59: mnIndex(0),
60 mbReverse(bReverse),
61 mbUseZOrder(true)
62{
63 ImpProcessObj(rSdrObject, eMode);
64 Reset();
65}
66
67SdrObjListIter::SdrObjListIter(const SdrPage* pSdrPage, SdrIterMode eMode, bool bReverse)
68: mnIndex(0),
69 mbReverse(bReverse),
70 mbUseZOrder(true)
71{
72 if (pSdrPage)
73 ImpProcessObjectList(*pSdrPage, eMode);
74 Reset();
75}
76
78: mnIndex(0),
79 mbReverse(false),
80 mbUseZOrder(true)
81{
82 ImpProcessMarkList(rMarkList, eMode);
83 Reset();
84}
85
87{
88 for(size_t nIdx(0), nCount(rObjList.GetObjCount()); nIdx < nCount; ++nIdx)
89 {
90 const SdrObject* pSdrObject(mbUseZOrder
91 ? rObjList.GetObj(nIdx)
92 : rObjList.GetObjectForNavigationPosition(nIdx));
93
94 if(nullptr == pSdrObject)
95 {
96 OSL_ENSURE(false, "SdrObjListIter: corrupted SdrObjList (!)");
97 }
98 else
99 {
100 ImpProcessObj(*pSdrObject, eMode);
101 }
102 }
103}
104
106{
107 for( size_t nIdx = 0, nCount = rMarkList.GetMarkCount(); nIdx < nCount; ++nIdx )
108 {
109 if( SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj() )
110 {
111 ImpProcessObj(*pObj, eMode);
112 }
113 }
114}
115
117{
118 // TTTT: Note: The behaviour has changed here, it will now deep-iterate
119 // for SdrObjGroup and E3dScene. Old version only deep-dived for SdrObjGroup,
120 // E3dScene was just added flat. This is now more correct, but potentially
121 // there will exist code in the 3D area that *self-iterates* with local
122 // functions/methods due to this iterator was not doing the expected thing.
123 // These will be difficult to find, but in most cases should do no harm,
124 // but cost runtime. Will need to have an eye on this aspect on continued
125 // changes...
126 const SdrObjList* pChildren(rSdrObject.getChildrenOfSdrObject());
127 const bool bIsGroup(nullptr != pChildren);
128
129 if(!bIsGroup || (SdrIterMode::DeepNoGroups != eMode))
130 {
131 maObjList.push_back(&rSdrObject);
132 }
133
134 if(bIsGroup && (SdrIterMode::Flat != eMode))
135 {
136 ImpProcessObjectList(*pChildren, eMode);
137 }
138}
139
140/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t GetMarkCount() const
Definition: svdmark.hxx:178
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:230
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
void ImpProcessObj(const SdrObject &rSdrObject, SdrIterMode eMode)
Definition: svditer.cxx:116
SdrObjListIter(const SdrObjList *pObjList, SdrIterMode eMode=SdrIterMode::DeepNoGroups, bool bReverse=false)
Definition: svditer.cxx:26
void Reset()
Definition: svditer.hxx:61
void ImpProcessMarkList(const SdrMarkList &rMarkList, SdrIterMode eMode)
Definition: svditer.cxx:105
std::vector< const SdrObject * > maObjList
Definition: svditer.hxx:40
void ImpProcessObjectList(const SdrObjList &rSdrObjList, SdrIterMode eMode)
Definition: svditer.cxx:86
bool mbUseZOrder
Definition: svditer.hxx:43
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:785
size_t GetObjCount() const
Definition: svdpage.cxx:779
bool HasObjectNavigationOrder() const
Return whether there is an explicit, user defined, object navigation order.
Definition: svdpage.cxx:865
SdrObject * GetObjectForNavigationPosition(const sal_uInt32 nNavigationPosition) const
Return the object for the given navigation position.
Definition: svdpage.cxx:916
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual SdrObjList * getChildrenOfSdrObject() const
Definition: svdobj.cxx:323
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
int nCount
Mode eMode
SdrIterMode
Definition: svditer.hxx:36
sal_uInt32 mnIndex