1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
44 * If you not only got a name, but even a SdrLayer*, you can get the ID
45 * much faster via the layer directly.
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.
58 class SVXCORE_DLLPUBLIC SdrLayer
60 friend class SdrLayerAdmin
;
64 OUString maDescription
;
65 SdrModel
* pModel
; // For broadcasting
66 bool mbVisibleODF
; // corresponds to ODF draw:display
67 bool mbPrintableODF
; // corresponds to ODF draw:display
68 bool mbLockedODF
; // corresponds to ODF draw:protected
71 SdrLayer(SdrLayerID nNewID
, const OUString
& rNewName
);
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 SVXCORE_DLLPUBLIC SdrLayerAdmin
{
103 friend class SdrView
;
104 friend class SdrModel
;
105 friend class SdrPage
;
107 std::vector
<std::unique_ptr
<SdrLayer
>> maLayers
;
108 SdrLayerAdmin
* pParent
; // The page's admin knows the doc's admin
109 SdrModel
* pModel
; // For broadcasting
110 OUString maControlLayerName
;
111 // Find a LayerID which is not in use yet. If all have been used up,
113 // If you want to play safe, check GetLayerCount()<SDRLAYER_MAXCOUNT
114 // first, else all are given away already.
115 SdrLayerID
GetUniqueLayerID() const;
116 void Broadcast() const;
118 explicit SdrLayerAdmin(SdrLayerAdmin
* pNewParent
=nullptr);
119 SdrLayerAdmin(const SdrLayerAdmin
& rSrcLayerAdmin
);
121 SdrLayerAdmin
& operator=(const SdrLayerAdmin
& rSrcLayerAdmin
);
123 void SetModel(SdrModel
* pNewModel
);
125 void InsertLayer(std::unique_ptr
<SdrLayer
> pLayer
, sal_uInt16 nPos
);
126 std::unique_ptr
<SdrLayer
> RemoveLayer(sal_uInt16 nPos
);
131 // New layer is created and inserted
132 SdrLayer
* NewLayer(const OUString
& rName
, sal_uInt16 nPos
=0xFFFF);
134 // Iterate over all layers
135 sal_uInt16
GetLayerCount() const { return sal_uInt16(maLayers
.size()); }
137 SdrLayer
* GetLayer(sal_uInt16 i
) { return maLayers
[i
].get(); }
138 const SdrLayer
* GetLayer(sal_uInt16 i
) const { return maLayers
[i
].get(); }
140 sal_uInt16
GetLayerPos(const SdrLayer
* pLayer
) const;
142 SdrLayer
* GetLayer(const OUString
& rName
);
143 const SdrLayer
* GetLayer(const OUString
& rName
) const;
144 SdrLayerID
GetLayerID(const OUString
& rName
) const;
145 SdrLayer
* GetLayerPerID(SdrLayerID nID
) { return const_cast<SdrLayer
*>(const_cast<const SdrLayerAdmin
*>(this)->GetLayerPerID(nID
)); }
146 const SdrLayer
* GetLayerPerID(SdrLayerID nID
) const;
148 void SetControlLayerName(const OUString
& rNewName
);
149 const OUString
& GetControlLayerName() const { return maControlLayerName
; }
151 // Removes all elements in rOutSet and then adds all IDs of layers from member aLayer
152 // that fulfill the criterion visible, printable, or locked respectively.
153 void getVisibleLayersODF( SdrLayerIDSet
& rOutSet
) const;
154 void getPrintableLayersODF( SdrLayerIDSet
& rOutSet
) const;
155 void getLockedLayersODF( SdrLayerIDSet
& rOutSet
) const;
157 // Generates a bitfield for settings.xml from the SdrLayerIDSet.
158 // Output is a UNO sequence of BYTE (which is 'short' in API).
159 void QueryValue(const SdrLayerIDSet
& rViewLayerSet
, css::uno::Any
& rAny
);
162 #endif // INCLUDED_SVX_SVDLAYER_HXX
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */