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>
24 #include <osl/diagnose.h>
26 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
)
42 mbUseZOrder(bUseZOrder
)
44 if(nullptr != pObjList
)
46 // correct when we have no ObjectNavigationOrder
47 if(!mbUseZOrder
&& !pObjList
->HasObjectNavigationOrder())
52 ImpProcessObjectList(*pObjList
, eMode
);
58 SdrObjListIter::SdrObjListIter(const SdrObject
& rSdrObject
, SdrIterMode eMode
, bool bReverse
)
63 ImpProcessObj(rSdrObject
, eMode
);
67 SdrObjListIter::SdrObjListIter(const SdrPage
* pSdrPage
, SdrIterMode eMode
, bool bReverse
)
73 ImpProcessObjectList(*pSdrPage
, eMode
);
77 SdrObjListIter::SdrObjListIter( const SdrMarkList
& rMarkList
, SdrIterMode eMode
)
82 ImpProcessMarkList(rMarkList
, eMode
);
86 void SdrObjListIter::ImpProcessObjectList(const SdrObjList
& rObjList
, SdrIterMode eMode
)
88 for(size_t nIdx(0), nCount(rObjList
.GetObjCount()); nIdx
< nCount
; ++nIdx
)
90 const SdrObject
* pSdrObject(mbUseZOrder
91 ? rObjList
.GetObj(nIdx
)
92 : rObjList
.GetObjectForNavigationPosition(nIdx
));
94 if(nullptr == pSdrObject
)
96 OSL_ENSURE(false, "SdrObjListIter: corrupted SdrObjList (!)");
100 ImpProcessObj(*pSdrObject
, eMode
);
105 void SdrObjListIter::ImpProcessMarkList(const SdrMarkList
& rMarkList
, SdrIterMode eMode
)
107 for( size_t nIdx
= 0, nCount
= rMarkList
.GetMarkCount(); nIdx
< nCount
; ++nIdx
)
109 if( SdrObject
* pObj
= rMarkList
.GetMark( nIdx
)->GetMarkedSdrObj() )
111 ImpProcessObj(*pObj
, eMode
);
116 void SdrObjListIter::ImpProcessObj(const SdrObject
& rSdrObject
, SdrIterMode eMode
)
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
126 const SdrObjList
* pChildren(rSdrObject
.getChildrenOfSdrObject());
127 const bool bIsGroup(nullptr != pChildren
);
129 if(!bIsGroup
|| (SdrIterMode::DeepNoGroups
!= eMode
))
131 maObjList
.push_back(&rSdrObject
);
134 if(bIsGroup
&& (SdrIterMode::Flat
!= eMode
))
136 ImpProcessObjectList(*pChildren
, eMode
);
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */