Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / svditer.hxx
blobf4d935989eaddf0e61df92c9ccf3e9c9347dd45e
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 #ifndef INCLUDED_SVX_SVDITER_HXX
21 #define INCLUDED_SVX_SVDITER_HXX
23 #include <vector>
25 #include <sal/types.h>
26 #include <svx/svxdllapi.h>
28 class SdrObjList;
29 class SdrObject;
30 class SdrMarkList;
32 // SdrObjListIter methods:
33 // SdrIterMode::Flat : Flat over the list
34 // SdrIterMode::DeepWithGroups : With recursive descent parser, Next() also returns group objects
35 // SdrIterMode::DeepNoGroups : With recursive descent parser, Next() returns no group objects
36 enum class SdrIterMode { Flat, DeepWithGroups, DeepNoGroups };
38 class SVX_DLLPUBLIC SdrObjListIter
40 std::vector<SdrObject*> maObjList;
41 sal_uInt32 mnIndex;
42 bool mbReverse;
44 void ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode, bool bUseZOrder);
45 void ImpProcessMarkList(const SdrMarkList& rMarkList, SdrIterMode eMode);
46 void ImpProcessObj(SdrObject* pObj, SdrIterMode eMode, bool bUseZOrder);
48 public:
49 explicit SdrObjListIter(const SdrObjList& rObjList, SdrIterMode eMode = SdrIterMode::DeepNoGroups, bool bReverse = false);
50 /** This variant lets the user choose the order in which to travel over
51 the objects.
52 @param bUseZOrder
53 When <TRUE/> then the z-order defines the order of iteration.
54 Otherwise the navigation position as returned by
55 SdrObject::GetNavigationPosition() is used.
57 SdrObjListIter(const SdrObjList& rObjList, bool bUseZOrder, SdrIterMode eMode = SdrIterMode::DeepNoGroups);
59 /* SJ: the following function can now be used with every
60 SdrObject and is no longer limited to group objects */
61 explicit SdrObjListIter(const SdrObject& rObj, SdrIterMode eMode = SdrIterMode::DeepNoGroups);
63 /** Iterates over a list of marked objects received from the SdrMarkView. */
64 explicit SdrObjListIter(const SdrMarkList& rMarkList, SdrIterMode eMode = SdrIterMode::DeepNoGroups);
66 void Reset() { mnIndex = (mbReverse ? maObjList.size() : 0L); }
67 bool IsMore() const { return (mbReverse ? mnIndex != 0 : ( mnIndex < maObjList.size())); }
68 SdrObject* Next()
70 sal_uInt32 idx = (mbReverse ? --mnIndex : mnIndex++);
71 return idx < maObjList.size() ? maObjList[idx] : nullptr;
74 sal_uInt32 Count() { return maObjList.size(); }
77 #endif // INCLUDED_SVX_SVDITER_HXX
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */