xref: /aoo41x/main/svx/source/svdraw/svditer.cxx (revision f6e50924)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include "svx/svditer.hxx"
27 #include <svx/svdpage.hxx>
28 #include <svx/svdogrp.hxx>
29 #include <svx/svdobj.hxx>
30 #include <svx/svdmark.hxx>
31 
32 // #99190#
33 #include <svx/scene3d.hxx>
34 
SdrObjListIter(const SdrObjList & rObjList,SdrIterMode eMode,sal_Bool bReverse)35 SdrObjListIter::SdrObjListIter(const SdrObjList& rObjList, SdrIterMode eMode, sal_Bool bReverse)
36 :	maObjList(1024, 64, 64),
37 	mnIndex(0L),
38 	mbReverse(bReverse)
39 {
40 	ImpProcessObjectList(rObjList, eMode, sal_True);
41 	Reset();
42 }
43 
SdrObjListIter(const SdrObjList & rObjList,sal_Bool bUseZOrder,SdrIterMode eMode,sal_Bool bReverse)44 SdrObjListIter::SdrObjListIter(const SdrObjList& rObjList, sal_Bool bUseZOrder, SdrIterMode eMode, sal_Bool bReverse)
45 :	maObjList(1024, 64, 64),
46 	mnIndex(0L),
47 	mbReverse(bReverse)
48 {
49 	ImpProcessObjectList(rObjList, eMode, bUseZOrder);
50 	Reset();
51 }
52 
SdrObjListIter(const SdrObject & rObj,SdrIterMode eMode,sal_Bool bReverse)53 SdrObjListIter::SdrObjListIter( const SdrObject& rObj, SdrIterMode eMode, sal_Bool bReverse )
54 :	maObjList(1024, 64, 64),
55 	mnIndex(0L),
56 	mbReverse(bReverse)
57 {
58 	if ( rObj.ISA( SdrObjGroup ) )
59 		ImpProcessObjectList(*rObj.GetSubList(), eMode, sal_True);
60 	else
61 		maObjList.Insert( (void*)&rObj, LIST_APPEND );
62 	Reset();
63 }
64 
SdrObjListIter(const SdrMarkList & rMarkList,SdrIterMode eMode,sal_Bool bReverse)65 SdrObjListIter::SdrObjListIter( const SdrMarkList& rMarkList, SdrIterMode eMode, sal_Bool bReverse )
66 :	maObjList(1024, 64, 64),
67 	mnIndex(0L),
68 	mbReverse(bReverse)
69 {
70 	ImpProcessMarkList(rMarkList, eMode);
71 	Reset();
72 }
73 
ImpProcessObjectList(const SdrObjList & rObjList,SdrIterMode eMode,sal_Bool bUseZOrder)74 void SdrObjListIter::ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode, sal_Bool bUseZOrder)
75 {
76 	for( sal_uIntPtr nIdx = 0, nCount = rObjList.GetObjCount(); nIdx < nCount; ++nIdx )
77 	{
78 		SdrObject* pObj = bUseZOrder ?
79             rObjList.GetObj( nIdx ) : rObjList.GetObjectForNavigationPosition( nIdx );
80         OSL_ASSERT( pObj != 0 );
81         if( pObj )
82             ImpProcessObj( pObj, eMode, bUseZOrder );
83 	}
84 }
85 
ImpProcessMarkList(const SdrMarkList & rMarkList,SdrIterMode eMode)86 void SdrObjListIter::ImpProcessMarkList( const SdrMarkList& rMarkList, SdrIterMode eMode )
87 {
88     for( sal_uIntPtr nIdx = 0, nCount = rMarkList.GetMarkCount(); nIdx < nCount; ++nIdx )
89         if( SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj() )
90             ImpProcessObj( pObj, eMode, sal_False );
91 }
92 
ImpProcessObj(SdrObject * pObj,SdrIterMode eMode,sal_Bool bUseZOrder)93 void SdrObjListIter::ImpProcessObj(SdrObject* pObj, SdrIterMode eMode, sal_Bool bUseZOrder)
94 {
95     bool bIsGroup = pObj->IsGroupObject();
96     // #99190# 3D objects are no group objects, IsGroupObject()
97     // only tests if pSub is not null ptr :-(
98     if( bIsGroup && pObj->ISA( E3dObject ) && !pObj->ISA( E3dScene ) )
99         bIsGroup = false;
100 
101     if( !bIsGroup || (eMode != IM_DEEPNOGROUPS) )
102         maObjList.Insert( pObj, LIST_APPEND );
103 
104     if( bIsGroup && (eMode != IM_FLAT) )
105         ImpProcessObjectList( *pObj->GetSubList(), eMode, bUseZOrder );
106 }
107