bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / svdlayer.hxx
blob491dcd253bf106f058612611b0ee68a5fbdd91ef
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 <algorithm>
27 #include <memory>
28 #include <vector>
30 /**
31 * Note on the layer mix with symbolic/ID-based interface:
32 * You create a new layer with
33 * pLayerAdmin->NewLayer("A new layer");
34 * This layer is automatically appended to the end of the list.
36 * The same holds true for layer sets.
38 * The interface for SdrLayerSet is based on LayerIDs. The app must get
39 * an ID for it at the SdrLayerAdmin, like so:
40 * SdrLayerID nLayerID=pLayerAdmin->GetLayerID("A new layer");
42 * If the layer cannot be found, SDRLAYER_NOTFOUND is returned.
43 * The methods with the ID interface usually handle that error in a
44 * meaningful way.
45 * If you not only got a name, but even a SdrLayer*, you can get the ID
46 * much faster via the layer directly.
48 * @param bInherited:
49 * TRUE If the layer/layer set cannot be found, we examine the parent layer admin,
50 * whether there's a corresponding definition
51 * FALSE We only search this layer admin
53 * Every page's layer admin has a parent layer admin (the model's). The model
54 * itself does not have a parent.
57 class SdrModel;
59 class SVX_DLLPUBLIC SdrLayer
61 friend class SdrLayerAdmin;
63 OUString maName;
64 OUString maTitle;
65 OUString maDescription;
66 bool mbVisibleODF; // corresponds to ODF draw:display
67 bool mbPrintableODF; // corresponds to ODF draw:display
68 bool mbLockedODF; // corresponds to ODF draw:protected
69 SdrModel* pModel; // For broadcasting
70 SdrLayerID const nID;
72 SdrLayer(SdrLayerID nNewID, const OUString& rNewName);
74 public:
75 bool operator==(const SdrLayer& rCmpLayer) const;
77 void SetName(const OUString& rNewName);
78 const OUString& GetName() const { return maName; }
80 void SetTitle(const OUString& rTitle) { maTitle = rTitle; }
81 const OUString& GetTitle() const { return maTitle; }
83 void SetDescription(const OUString& rDesc) { maDescription = rDesc; }
84 const OUString& GetDescription() const { return maDescription; }
86 void SetVisibleODF(const bool& rVisibleODF) { mbVisibleODF = rVisibleODF; }
87 bool IsVisibleODF() const { return mbVisibleODF; }
89 void SetPrintableODF(const bool& rPrintableODF) { mbPrintableODF = rPrintableODF; }
90 bool IsPrintableODF() const { return mbPrintableODF; }
92 void SetLockedODF(const bool& rLockedODF) { mbLockedODF = rLockedODF; }
93 bool IsLockedODF() const { return mbLockedODF; }
95 SdrLayerID GetID() const { return nID; }
96 void SetModel(SdrModel* pNewModel) { pModel=pNewModel; }
99 #define SDRLAYER_MAXCOUNT 255
100 #define SDRLAYERPOS_NOTFOUND 0xffff
102 // When Changing the layer data you currently have to set the Modify flag manually
103 class SVX_DLLPUBLIC SdrLayerAdmin {
104 friend class SdrView;
105 friend class SdrModel;
106 friend class SdrPage;
108 protected:
109 std::vector<std::unique_ptr<SdrLayer>> maLayers;
110 SdrLayerAdmin* pParent; // The page's admin knows the doc's admin
111 SdrModel* pModel; // For broadcasting
112 OUString maControlLayerName;
113 protected:
114 // Find a LayerID which is not in use yet. If all have been used up,
115 // we return 0.
116 // If you want to play safe, check GetLayerCount()<SDRLAYER_MAXCOUNT
117 // first, else all are given away already.
118 SdrLayerID GetUniqueLayerID() const;
119 void Broadcast() const;
120 public:
121 explicit SdrLayerAdmin(SdrLayerAdmin* pNewParent=nullptr);
122 SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin);
123 ~SdrLayerAdmin();
124 SdrLayerAdmin& operator=(const SdrLayerAdmin& rSrcLayerAdmin);
126 void SetModel(SdrModel* pNewModel);
128 void InsertLayer(std::unique_ptr<SdrLayer> pLayer, sal_uInt16 nPos);
129 std::unique_ptr<SdrLayer> RemoveLayer(sal_uInt16 nPos);
131 // Delete all layers
132 void ClearLayers();
134 // New layer is created and inserted
135 SdrLayer* NewLayer(const OUString& rName, sal_uInt16 nPos=0xFFFF);
137 // Iterate over all layers
138 sal_uInt16 GetLayerCount() const { return sal_uInt16(maLayers.size()); }
140 SdrLayer* GetLayer(sal_uInt16 i) { return maLayers[i].get(); }
141 const SdrLayer* GetLayer(sal_uInt16 i) const { return maLayers[i].get(); }
143 sal_uInt16 GetLayerPos(const SdrLayer* pLayer) const;
145 SdrLayer* GetLayer(const OUString& rName);
146 const SdrLayer* GetLayer(const OUString& rName) const;
147 SdrLayerID GetLayerID(const OUString& rName) const;
148 SdrLayer* GetLayerPerID(SdrLayerID nID) { return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayerPerID(nID)); }
149 const SdrLayer* GetLayerPerID(SdrLayerID nID) const;
151 void SetControlLayerName(const OUString& rNewName);
152 const OUString& GetControlLayerName() const { return maControlLayerName; }
154 // Removes all elements in rOutSet and then adds all IDs of layers from member aLayer
155 // that fulfill the criterion visible, printable, or locked respectively.
156 void getVisibleLayersODF( SdrLayerIDSet& rOutSet) const;
157 void getPrintableLayersODF( SdrLayerIDSet& rOutSet) const;
158 void getLockedLayersODF( SdrLayerIDSet& rOutSet) const;
160 // Generates a bitfield for settings.xml from the SdrLayerIDSet.
161 // Output is a uno sequence of BYTE (which is 'short' in API).
162 void QueryValue(const SdrLayerIDSet& rViewLayerSet, css::uno::Any& rAny);
165 #endif // INCLUDED_SVX_SVDLAYER_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */