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 #include <svx/svditer.hxx>
21 #include <svx/svdpage.hxx>
22 #include <svx/svdobj.hxx>
23 #include <svx/svdmark.hxx>
25 SdrObjListIter::SdrObjListIter(const SdrObjList
* pObjList
, SdrIterMode eMode
, bool bReverse
)
31 if(nullptr != pObjList
)
33 ImpProcessObjectList(*pObjList
, eMode
);
39 SdrObjListIter::SdrObjListIter(const SdrObjList
* pObjList
, bool bUseZOrder
, SdrIterMode eMode
, bool bReverse
)
43 mbUseZOrder(bUseZOrder
)
45 if(nullptr != pObjList
)
47 // correct when we have no ObjectNavigationOrder
48 if(!mbUseZOrder
&& !pObjList
->HasObjectNavigationOrder())
53 ImpProcessObjectList(*pObjList
, eMode
);
59 SdrObjListIter::SdrObjListIter(const SdrObject
& rSdrObject
, SdrIterMode eMode
, bool bReverse
)
65 ImpProcessObj(rSdrObject
, eMode
);
69 SdrObjListIter::SdrObjListIter(const SdrPage
* pSdrPage
, SdrIterMode eMode
, bool bReverse
)
75 if (const SdrObjList
* pList
= dynamic_cast<const SdrObjList
*>(pSdrPage
))
76 ImpProcessObjectList(*pList
, eMode
);
80 SdrObjListIter::SdrObjListIter( const SdrMarkList
& rMarkList
, SdrIterMode eMode
)
86 ImpProcessMarkList(rMarkList
, eMode
);
90 void SdrObjListIter::ImpProcessObjectList(const SdrObjList
& rObjList
, SdrIterMode eMode
)
91 { for(size_t nIdx(0), nCount(rObjList
.GetObjCount()); nIdx
< nCount
; ++nIdx
)
93 const SdrObject
* pSdrObject(mbUseZOrder
94 ? rObjList
.GetObj(nIdx
)
95 : rObjList
.GetObjectForNavigationPosition(nIdx
));
97 if(nullptr == pSdrObject
)
99 OSL_ENSURE(false, "SdrObjListIter: corrupted SdrObjList (!)");
103 ImpProcessObj(*pSdrObject
, eMode
);
108 void SdrObjListIter::ImpProcessMarkList(const SdrMarkList
& rMarkList
, SdrIterMode eMode
)
110 for( size_t nIdx
= 0, nCount
= rMarkList
.GetMarkCount(); nIdx
< nCount
; ++nIdx
)
112 if( SdrObject
* pObj
= rMarkList
.GetMark( nIdx
)->GetMarkedSdrObj() )
114 ImpProcessObj(*pObj
, eMode
);
119 void SdrObjListIter::ImpProcessObj(const SdrObject
& rSdrObject
, SdrIterMode eMode
)
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
129 const SdrObjList
* pChildren(rSdrObject
.getChildrenOfSdrObject());
130 const bool bIsGroup(nullptr != pChildren
);
132 if(!bIsGroup
|| (SdrIterMode::DeepNoGroups
!= eMode
))
134 maObjList
.push_back(&rSdrObject
);
137 if(bIsGroup
&& (SdrIterMode::Flat
!= eMode
))
139 ImpProcessObjectList(*pChildren
, eMode
);
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */