1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svx/svditer.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdmark.hxx>
SdrObjListIter::SdrObjListIter(const SdrObjList* pObjList, SdrIterMode eMode, bool bReverse)
: maObjList(),
mnIndex(0),
mbReverse(bReverse),
mbUseZOrder(true)
{
if(nullptr != pObjList)
{
ImpProcessObjectList(*pObjList, eMode);
}
Reset();
}
SdrObjListIter::SdrObjListIter(const SdrObjList* pObjList, bool bUseZOrder, SdrIterMode eMode, bool bReverse)
: maObjList(),
mnIndex(0),
mbReverse(bReverse),
mbUseZOrder(bUseZOrder)
{
if(nullptr != pObjList)
{
// correct when we have no ObjectNavigationOrder
if(!mbUseZOrder && !pObjList->HasObjectNavigationOrder())
{
mbUseZOrder = false;
}
ImpProcessObjectList(*pObjList, eMode);
}
Reset();
}
SdrObjListIter::SdrObjListIter(const SdrObject& rSdrObject, SdrIterMode eMode, bool bReverse)
: maObjList(),
mnIndex(0),
mbReverse(bReverse),
mbUseZOrder(true)
{
ImpProcessObj(rSdrObject, eMode);
Reset();
}
SdrObjListIter::SdrObjListIter(const SdrPage* pSdrPage, SdrIterMode eMode, bool bReverse)
: maObjList(),
mnIndex(0),
mbReverse(bReverse),
mbUseZOrder(true)
{
if (const SdrObjList* pList = dynamic_cast<const SdrObjList*>(pSdrPage))
ImpProcessObjectList(*pList, eMode);
Reset();
}
SdrObjListIter::SdrObjListIter( const SdrMarkList& rMarkList, SdrIterMode eMode )
: maObjList(),
mnIndex(0),
mbReverse(false),
mbUseZOrder(true)
{
ImpProcessMarkList(rMarkList, eMode);
Reset();
}
void SdrObjListIter::ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode)
{ for(size_t nIdx(0), nCount(rObjList.GetObjCount()); nIdx < nCount; ++nIdx)
{
const SdrObject* pSdrObject(mbUseZOrder
? rObjList.GetObj(nIdx)
: rObjList.GetObjectForNavigationPosition(nIdx));
if(nullptr == pSdrObject)
{
OSL_ENSURE(false, "SdrObjListIter: corrupted SdrObjList (!)");
}
else
{
ImpProcessObj(*pSdrObject, eMode);
}
}
}
void SdrObjListIter::ImpProcessMarkList(const SdrMarkList& rMarkList, SdrIterMode eMode)
{
for( size_t nIdx = 0, nCount = rMarkList.GetMarkCount(); nIdx < nCount; ++nIdx )
{
if( SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj() )
{
ImpProcessObj(*pObj, eMode);
}
}
}
void SdrObjListIter::ImpProcessObj(const SdrObject& rSdrObject, SdrIterMode eMode)
{
// TTTT: Note: The behaviour has changed here, it will now deep-iterate
// for SdrObjGroup and E3dScene. Old version only deep-dived for SdrObjGroup,
// E3dScene was just added flat. This is now more correct, but potentially
// there will exist code in the 3D area that *self-iterates* with local
// functions/methods due to this iterator was not doing the expected thing.
// These will be difficult to find, but in most cases should do no harm,
// but cost runtime. Will need to have an eye on this aspect on continued
// changes...
const SdrObjList* pChildren(rSdrObject.getChildrenOfSdrObject());
const bool bIsGroup(nullptr != pChildren);
if(!bIsGroup || (SdrIterMode::DeepNoGroups != eMode))
{
maObjList.push_back(&rSdrObject);
}
if(bIsGroup && (SdrIterMode::Flat != eMode))
{
ImpProcessObjectList(*pChildren, eMode);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|