Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / svdraw / svditer.cxx
blobd572a4009d61256bf7a80cb54d298704eb0fd2e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/svdogrp.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/svdmark.hxx>
25 #include <svx/scene3d.hxx>
27 SdrObjListIter::SdrObjListIter(const SdrObjList& rObjList, SdrIterMode eMode, bool bReverse)
28 : mnIndex(0L),
29 mbReverse(bReverse)
31 ImpProcessObjectList(rObjList, eMode, true);
32 Reset();
35 SdrObjListIter::SdrObjListIter(const SdrObjList& rObjList, bool bUseZOrder, SdrIterMode eMode, bool bReverse)
36 : mnIndex(0L),
37 mbReverse(bReverse)
39 ImpProcessObjectList(rObjList, eMode, bUseZOrder);
40 Reset();
43 SdrObjListIter::SdrObjListIter( const SdrObject& rObj, SdrIterMode eMode, bool bReverse )
44 : mnIndex(0L),
45 mbReverse(bReverse)
47 if ( rObj.ISA( SdrObjGroup ) )
48 ImpProcessObjectList(*rObj.GetSubList(), eMode, true);
49 else
50 maObjList.push_back(const_cast<SdrObject*>(&rObj));
51 Reset();
54 SdrObjListIter::SdrObjListIter( const SdrMarkList& rMarkList, SdrIterMode eMode, bool bReverse )
55 : mnIndex(0L),
56 mbReverse(bReverse)
58 ImpProcessMarkList(rMarkList, eMode);
59 Reset();
62 void SdrObjListIter::ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode, bool bUseZOrder)
64 for( sal_uIntPtr nIdx = 0, nCount = rObjList.GetObjCount(); nIdx < nCount; ++nIdx )
66 SdrObject* pObj = bUseZOrder ?
67 rObjList.GetObj( nIdx ) : rObjList.GetObjectForNavigationPosition( nIdx );
68 OSL_ASSERT( pObj != 0 );
69 if( pObj )
70 ImpProcessObj( pObj, eMode, bUseZOrder );
74 void SdrObjListIter::ImpProcessMarkList( const SdrMarkList& rMarkList, SdrIterMode eMode )
76 for( sal_uIntPtr nIdx = 0, nCount = rMarkList.GetMarkCount(); nIdx < nCount; ++nIdx )
77 if( SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj() )
78 ImpProcessObj( pObj, eMode, false );
81 void SdrObjListIter::ImpProcessObj(SdrObject* pObj, SdrIterMode eMode, bool bUseZOrder)
83 bool bIsGroup = pObj->IsGroupObject();
84 // 3D objects are not group objects, IsGroupObject()
85 // only tests if pSub is not null ptr :-(
86 if( bIsGroup && pObj->ISA( E3dObject ) && !pObj->ISA( E3dScene ) )
87 bIsGroup = false;
89 if( !bIsGroup || (eMode != IM_DEEPNOGROUPS) )
90 maObjList.push_back(pObj);
92 if( bIsGroup && (eMode != IM_FLAT) )
93 ImpProcessObjectList( *pObj->GetSubList(), eMode, bUseZOrder );
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */