xref: /AOO41X/main/svx/inc/svx/svditer.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
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 #ifndef _SVDITER_HXX
25 #define _SVDITER_HXX
26 
27 #include <sal/types.h>
28 #include <tools/list.hxx>
29 #include "svx/svxdllapi.h"
30 
31 class SdrObjList;
32 class SdrObject;
33 class SdrMarkList;
34 
35 // SdrObjListIter methods:
36 // IM_FLAT              : Flach ueber die Liste
37 // IM_DEEPWITHGROUPS    : Mit rekursivem Abstieg, Next() liefert auch Gruppenobjekte
38 // IM_DEEPNOGROUPS      : Mit rekursivem Abstieg, Next() liefert keine Gruppenobjekte
39 enum SdrIterMode { IM_FLAT, IM_DEEPWITHGROUPS, IM_DEEPNOGROUPS};
40 
41 class SVX_DLLPUBLIC SdrObjListIter
42 {
43     List                        maObjList;
44     sal_uInt32                  mnIndex;
45     sal_Bool                        mbReverse;
46 
47     void ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode, sal_Bool bUseZOrder);
48     void ImpProcessMarkList(const SdrMarkList& rMarkList, SdrIterMode eMode);
49     void ImpProcessObj(SdrObject* pObj, SdrIterMode eMode, sal_Bool bUseZOrder);
50 
51 public:
52     SdrObjListIter(const SdrObjList& rObjList, SdrIterMode eMode = IM_DEEPNOGROUPS, sal_Bool bReverse = sal_False);
53     /** This variant lets the user choose the order in which to travel over
54         the objects.
55         @param bUseZOrder
56             When <TRUE/> then the z-order defines the order of iteration.
57             Otherwise the navigation position as returned by
58             SdrObject::GetNavigationPosition() is used.
59     */
60     SdrObjListIter(const SdrObjList& rObjList, sal_Bool bUseZOrder, SdrIterMode eMode = IM_DEEPNOGROUPS, sal_Bool bReverse = sal_False);
61 
62     /* SJ: the following function can now be used with every
63        SdrObject and is no longer limited to group objects */
64     SdrObjListIter(const SdrObject& rObj, SdrIterMode eMode = IM_DEEPNOGROUPS, sal_Bool bReverse = sal_False);
65 
66     /** Iterates over a list of marked objects received from the SdrMarkView. */
67     SdrObjListIter(const SdrMarkList& rMarkList, SdrIterMode eMode = IM_DEEPNOGROUPS, sal_Bool bReverse = sal_False);
68 
Reset()69     void Reset() { mnIndex = (mbReverse ? maObjList.Count() : 0L); }
IsMore() const70     sal_Bool IsMore() const { return (mbReverse ? mnIndex != 0 : ( mnIndex < maObjList.Count())); }
Next()71     SdrObject* Next() { return (SdrObject*)maObjList.GetObject(mbReverse ? --mnIndex : mnIndex++); }
72 
Count()73     sal_uInt32 Count() { return maObjList.Count(); }
74 };
75 
76 #endif //_SVDITER_HXX
77 
78