LibreOffice Module svx (master)  1
svdlayer.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SVDLAYER_HXX
21 #define INCLUDED_SVX_SVDLAYER_HXX
22 
23 #include <svx/svdsob.hxx>
24 #include <svx/svdtypes.hxx>
25 #include <svx/svxdllapi.h>
26 #include <memory>
27 #include <vector>
28 
56 class SdrModel;
57 
59 {
60  friend class SdrLayerAdmin;
61 
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;
70 
71  SdrLayer(SdrLayerID nNewID, const OUString& rNewName);
72 
73 public:
74  bool operator==(const SdrLayer& rCmpLayer) const;
75 
76  void SetName(const OUString& rNewName);
77  const OUString& GetName() const { return maName; }
78 
79  void SetTitle(const OUString& rTitle) { maTitle = rTitle; }
80  const OUString& GetTitle() const { return maTitle; }
81 
82  void SetDescription(const OUString& rDesc) { maDescription = rDesc; }
83  const OUString& GetDescription() const { return maDescription; }
84 
85  void SetVisibleODF(bool bVisibleODF) { mbVisibleODF = bVisibleODF; }
86  bool IsVisibleODF() const { return mbVisibleODF; }
87 
88  void SetPrintableODF(bool bPrintableODF) { mbPrintableODF = bPrintableODF; }
89  bool IsPrintableODF() const { return mbPrintableODF; }
90 
91  void SetLockedODF(bool bLockedODF) { mbLockedODF = bLockedODF; }
92  bool IsLockedODF() const { return mbLockedODF; }
93 
94  SdrLayerID GetID() const { return nID; }
95  void SetModel(SdrModel* pNewModel) { pModel=pNewModel; }
96 };
97 
98 #define SDRLAYER_MAXCOUNT 255
99 #define SDRLAYERPOS_NOTFOUND 0xffff
100 
101 // When Changing the layer data you currently have to set the Modify flag manually
103 friend class SdrView;
104 friend class SdrModel;
105 friend class SdrPage;
106 
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
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);
124 
125  void SetModel(SdrModel* pNewModel);
126 
127  void InsertLayer(std::unique_ptr<SdrLayer> pLayer, sal_uInt16 nPos);
128  std::unique_ptr<SdrLayer> RemoveLayer(sal_uInt16 nPos);
129 
130  // Delete all layers
131  void ClearLayers();
132 
133  // New layer is created and inserted
134  SdrLayer* NewLayer(const OUString& rName, sal_uInt16 nPos=0xFFFF);
135 
136  // Iterate over all layers
137  sal_uInt16 GetLayerCount() const { return sal_uInt16(maLayers.size()); }
138 
139  SdrLayer* GetLayer(sal_uInt16 i) { return maLayers[i].get(); }
140  const SdrLayer* GetLayer(sal_uInt16 i) const { return maLayers[i].get(); }
141 
142  sal_uInt16 GetLayerPos(const SdrLayer* pLayer) const;
143 
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;
149 
150  void SetControlLayerName(const OUString& rNewName);
151  const OUString& GetControlLayerName() const { return maControlLayerName; }
152 
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;
158 
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);
162 };
163 
164 #endif // INCLUDED_SVX_SVDLAYER_HXX
165 
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsPrintableODF() const
Definition: svdlayer.hxx:89
SdrModel * pModel
Definition: svdlayer.hxx:68
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
bool mbPrintableODF
Definition: svdlayer.hxx:66
SdrModel * pModel
Definition: svdlayer.hxx:110
OUString maName
Definition: svdlayer.hxx:62
SdrLayerID GetID() const
Definition: svdlayer.hxx:94
void SetModel(SdrModel *pNewModel)
Definition: svdlayer.hxx:95
void SetLockedODF(bool bLockedODF)
Definition: svdlayer.hxx:91
const OUString & GetDescription() const
Definition: svdlayer.hxx:83
SdrLayer * GetLayer(sal_uInt16 i)
Definition: svdlayer.hxx:139
sal_uInt16 GetLayerCount() const
Definition: svdlayer.hxx:137
const OUString & GetControlLayerName() const
Definition: svdlayer.hxx:151
const OUString & GetName() const
Definition: svdlayer.hxx:77
SdrLayer * GetLayerPerID(SdrLayerID nID)
Definition: svdlayer.hxx:147
void SetVisibleODF(bool bVisibleODF)
Definition: svdlayer.hxx:85
void SetDescription(const OUString &rDesc)
Definition: svdlayer.hxx:82
SdrPage & operator=(const SdrPage &)=delete
const SdrLayer * GetLayer(sal_uInt16 i) const
Definition: svdlayer.hxx:140
SdrLayerAdmin * pParent
Definition: svdlayer.hxx:109
void SetTitle(const OUString &rTitle)
Definition: svdlayer.hxx:79
bool mbLockedODF
Definition: svdlayer.hxx:67
bool mbVisibleODF
Definition: svdlayer.hxx:65
OUString maDescription
Definition: svdlayer.hxx:64
OUString maControlLayerName
Definition: svdlayer.hxx:111
void SetPrintableODF(bool bPrintableODF)
Definition: svdlayer.hxx:88
std::vector< std::unique_ptr< SdrLayer > > maLayers
Definition: svdlayer.hxx:108
const OUString & GetTitle() const
Definition: svdlayer.hxx:80
SdrLayerID const nID
Definition: svdlayer.hxx:69
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
OUString maTitle
Definition: svdlayer.hxx:63
bool IsVisibleODF() const
Definition: svdlayer.hxx:86
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
bool IsLockedODF() const
Definition: svdlayer.hxx:92