Bump version to 6.4-15
[LibreOffice.git] / include / svx / svdlayer.hxx
blob2289efb32975e747f1d1006c7005c44c2d713835
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_SVDLAYER_HXX
21 #define INCLUDED_SVX_SVDLAYER_HXX
23 #include <svx/svdsob.hxx>
24 #include <svx/svdtypes.hxx>
25 #include <svx/svxdllapi.h>
26 #include <memory>
27 #include <vector>
29 /**
30 * Note on the layer mix with symbolic/ID-based interface:
31 * You create a new layer with
32 * pLayerAdmin->NewLayer("A new layer");
33 * This layer is automatically appended to the end of the list.
35 * The same holds true for layer sets.
37 * The interface for SdrLayerSet is based on LayerIDs. The app must get
38 * an ID for it at the SdrLayerAdmin, like so:
39 * SdrLayerID nLayerID=pLayerAdmin->GetLayerID("A new layer");
41 * If the layer cannot be found, SDRLAYER_NOTFOUND is returned.
42 * The methods with the ID interface usually handle that error in a
43 * meaningful way.
44 * If you not only got a name, but even a SdrLayer*, you can get the ID
45 * much faster via the layer directly.
47 * @param bInherited:
48 * TRUE If the layer/layer set cannot be found, we examine the parent layer admin,
49 * whether there's a corresponding definition
50 * FALSE We only search this layer admin
52 * Every page's layer admin has a parent layer admin (the model's). The model
53 * itself does not have a parent.
56 class SdrModel;
58 class SVX_DLLPUBLIC SdrLayer
60 friend class SdrLayerAdmin;
62 OUString maName;
63 OUString maTitle;
64 OUString maDescription;
65 bool mbVisibleODF; // corresponds to ODF draw:display
66 bool mbPrintableODF; // corresponds to ODF draw:display
67 bool mbLockedODF; // corresponds to ODF draw:protected
68 SdrModel* pModel; // For broadcasting
69 SdrLayerID const nID;
71 SdrLayer(SdrLayerID nNewID, const OUString& rNewName);
73 public:
74 bool operator==(const SdrLayer& rCmpLayer) const;
76 void SetName(const OUString& rNewName);
77 const OUString& GetName() const { return maName; }
79 void SetTitle(const OUString& rTitle) { maTitle = rTitle; }
80 const OUString& GetTitle() const { return maTitle; }
82 void SetDescription(const OUString& rDesc) { maDescription = rDesc; }
83 const OUString& GetDescription() const { return maDescription; }
85 void SetVisibleODF(bool bVisibleODF) { mbVisibleODF = bVisibleODF; }
86 bool IsVisibleODF() const { return mbVisibleODF; }
88 void SetPrintableODF(bool bPrintableODF) { mbPrintableODF = bPrintableODF; }
89 bool IsPrintableODF() const { return mbPrintableODF; }
91 void SetLockedODF(bool bLockedODF) { mbLockedODF = bLockedODF; }
92 bool IsLockedODF() const { return mbLockedODF; }
94 SdrLayerID GetID() const { return nID; }
95 void SetModel(SdrModel* pNewModel) { pModel=pNewModel; }
98 #define SDRLAYER_MAXCOUNT 255
99 #define SDRLAYERPOS_NOTFOUND 0xffff
101 // When Changing the layer data you currently have to set the Modify flag manually
102 class SVX_DLLPUBLIC SdrLayerAdmin {
103 friend class SdrView;
104 friend class SdrModel;
105 friend class SdrPage;
107 protected:
108 std::vector<std::unique_ptr<SdrLayer>> maLayers;
109 SdrLayerAdmin* pParent; // The page's admin knows the doc's admin
110 SdrModel* pModel; // For broadcasting
111 OUString maControlLayerName;
112 protected:
113 // Find a LayerID which is not in use yet. If all have been used up,
114 // we return 0.
115 // If you want to play safe, check GetLayerCount()<SDRLAYER_MAXCOUNT
116 // first, else all are given away already.
117 SdrLayerID GetUniqueLayerID() const;
118 void Broadcast() const;
119 public:
120 explicit SdrLayerAdmin(SdrLayerAdmin* pNewParent=nullptr);
121 SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin);
122 ~SdrLayerAdmin();
123 SdrLayerAdmin& operator=(const SdrLayerAdmin& rSrcLayerAdmin);
125 void SetModel(SdrModel* pNewModel);
127 void InsertLayer(std::unique_ptr<SdrLayer> pLayer, sal_uInt16 nPos);
128 std::unique_ptr<SdrLayer> RemoveLayer(sal_uInt16 nPos);
130 // Delete all layers
131 void ClearLayers();
133 // New layer is created and inserted
134 SdrLayer* NewLayer(const OUString& rName, sal_uInt16 nPos=0xFFFF);
136 // Iterate over all layers
137 sal_uInt16 GetLayerCount() const { return sal_uInt16(maLayers.size()); }
139 SdrLayer* GetLayer(sal_uInt16 i) { return maLayers[i].get(); }
140 const SdrLayer* GetLayer(sal_uInt16 i) const { return maLayers[i].get(); }
142 sal_uInt16 GetLayerPos(const SdrLayer* pLayer) const;
144 SdrLayer* GetLayer(const OUString& rName);
145 const SdrLayer* GetLayer(const OUString& rName) const;
146 SdrLayerID GetLayerID(const OUString& rName) const;
147 SdrLayer* GetLayerPerID(SdrLayerID nID) { return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayerPerID(nID)); }
148 const SdrLayer* GetLayerPerID(SdrLayerID nID) const;
150 void SetControlLayerName(const OUString& rNewName);
151 const OUString& GetControlLayerName() const { return maControlLayerName; }
153 // Removes all elements in rOutSet and then adds all IDs of layers from member aLayer
154 // that fulfill the criterion visible, printable, or locked respectively.
155 void getVisibleLayersODF( SdrLayerIDSet& rOutSet) const;
156 void getPrintableLayersODF( SdrLayerIDSet& rOutSet) const;
157 void getLockedLayersODF( SdrLayerIDSet& rOutSet) const;
159 // Generates a bitfield for settings.xml from the SdrLayerIDSet.
160 // Output is a UNO sequence of BYTE (which is 'short' in API).
161 void QueryValue(const SdrLayerIDSet& rViewLayerSet, css::uno::Any& rAny);
164 #endif // INCLUDED_SVX_SVDLAYER_HXX
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */