Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / svdmark.hxx
blob7c5181f8845e446866bcec63e6882be48e5ab6ae
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_SVDMARK_HXX
21 #define INCLUDED_SVX_SVDMARK_HXX
23 #include <rtl/ustring.hxx>
24 #include <svx/svxdllapi.h>
25 #include <svx/sdrobjectuser.hxx>
26 #include <tools/solar.h>
28 #include <set>
29 #include <vector>
31 class Rectangle;
32 class SdrPage;
33 class SdrObjList;
34 class SdrObject;
35 class SdrPageView;
37 typedef std::set<sal_uInt16> SdrUShortCont;
40 // Everything a View needs to know about a selected object
41 class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser
43 protected:
44 SdrObject* mpSelectedSdrObject; // the selected object
45 SdrPageView* mpPageView;
46 SdrUShortCont* mpPoints; // Selected Points
47 SdrUShortCont* mpLines; // Selected Line
48 SdrUShortCont* mpGluePoints; // Selected Gluepoints (their Id's)
49 bool mbCon1; // for Connectors
50 bool mbCon2; // for Connectors
51 sal_uInt16 mnUser; // E.g. for CopyObjects, also copy Edges
53 public:
54 explicit SdrMark(SdrObject* pNewObj = 0L, SdrPageView* pNewPageView = 0L);
55 SdrMark(const SdrMark& rMark);
56 virtual ~SdrMark();
58 // Derived from ObjectUser
59 virtual void ObjectInDestruction(const SdrObject& rObject) SAL_OVERRIDE;
61 SdrMark& operator=(const SdrMark& rMark);
62 bool operator==(const SdrMark& rMark) const;
63 bool operator!=(const SdrMark& rMark) const
65 return !(operator==(rMark));
68 void SetMarkedSdrObj(SdrObject* pNewObj);
69 SdrObject* GetMarkedSdrObj() const { return mpSelectedSdrObject;}
71 SdrPageView* GetPageView() const
73 return mpPageView;
76 void SetPageView(SdrPageView* pNewPageView)
78 mpPageView = pNewPageView;
81 void SetCon1(bool bOn)
83 mbCon1 = bOn;
86 bool IsCon1() const
88 return mbCon1;
91 void SetCon2(bool bOn)
93 mbCon2 = bOn;
96 bool IsCon2() const
98 return mbCon2;
101 void SetUser(sal_uInt16 nVal)
103 mnUser = nVal;
106 sal_uInt16 GetUser() const
108 return mnUser;
111 const SdrUShortCont* GetMarkedPoints() const
113 return mpPoints;
116 const SdrUShortCont* GetMarkedLines() const
118 return mpLines;
121 const SdrUShortCont* GetMarkedGluePoints() const
123 return mpGluePoints;
126 SdrUShortCont* GetMarkedPoints()
128 return mpPoints;
131 SdrUShortCont* GetMarkedLines()
133 return mpLines;
136 SdrUShortCont* GetMarkedGluePoints()
138 return mpGluePoints;
141 SdrUShortCont* ForceMarkedPoints()
143 if(!mpPoints)
144 mpPoints = new SdrUShortCont;
146 return mpPoints;
149 SdrUShortCont* ForceMarkedLines()
151 if(!mpLines)
152 mpLines = new SdrUShortCont;
154 return mpLines;
157 SdrUShortCont* ForceMarkedGluePoints()
159 if(!mpGluePoints)
160 mpGluePoints = new SdrUShortCont;
162 return mpGluePoints;
166 class SVX_DLLPUBLIC SdrMarkList
168 protected:
169 std::vector<SdrMark*> maList;
171 OUString maMarkName;
172 OUString maPointName;
173 OUString maGluePointName;
175 bool mbPointNameOk;
176 bool mbGluePointNameOk;
177 bool mbNameOk;
178 bool mbSorted;
180 private:
181 SVX_DLLPRIVATE bool operator==(const SdrMarkList& rCmpMarkList) const;
182 SVX_DLLPRIVATE void ImpForceSort();
184 private:
185 SVX_DLLPRIVATE const OUString& GetPointMarkDescription(bool bGlue) const;
187 public:
188 SdrMarkList()
189 : maList(),
190 mbPointNameOk(false),
191 mbGluePointNameOk(false),
192 mbNameOk(false),
193 mbSorted(true)
197 SdrMarkList(const SdrMarkList& rLst)
198 : maList()
200 *this = rLst;
203 ~SdrMarkList()
205 Clear();
208 void Clear();
209 void ForceSort() const;
210 void SetUnsorted()
212 mbSorted = false;
215 size_t GetMarkCount() const
217 return maList.size();
220 SdrMark* GetMark(size_t nNum) const;
221 // returns SAL_MAX_SIZE if not found
222 size_t FindObject(const SdrObject* pObj) const;
223 void InsertEntry(const SdrMark& rMark, bool bChkSort = true);
224 void DeleteMark(size_t nNum);
225 void ReplaceMark(const SdrMark& rNewMark, size_t nNum);
226 void Merge(const SdrMarkList& rSrcList, bool bReverse = false);
227 bool DeletePageView(const SdrPageView& rPV);
228 bool InsertPageView(const SdrPageView& rPV);
230 void SetNameDirty()
232 mbNameOk = false;
233 mbPointNameOk = false;
234 mbGluePointNameOk = false;
237 // A verbal description of selected objects e.g.:
238 // "27 Lines", "12 Objects", "Polygon" or even "Not an object"
239 const OUString& GetMarkDescription() const;
240 const OUString& GetPointMarkDescription() const
242 return GetPointMarkDescription(false);
245 const OUString& GetGluePointMarkDescription() const
247 return GetPointMarkDescription(true);
250 // pPage=0L: Selection of everything! Respect Pages
251 bool TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const;
252 bool TakeSnapRect(SdrPageView* pPageView, Rectangle& rRect) const;
254 // Es werden saemtliche Entries kopiert!
255 void operator=(const SdrMarkList& rLst);
259 // migrate selections
261 namespace sdr
263 class SVX_DLLPUBLIC ViewSelection
265 SdrMarkList maMarkedObjectList;
266 SdrMarkList maEdgesOfMarkedNodes;
267 SdrMarkList maMarkedEdgesOfMarkedNodes;
268 std::vector<SdrObject*> maAllMarkedObjects;
270 // bitfield
271 bool mbEdgesOfMarkedNodesDirty : 1;
273 SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
274 SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
276 public:
277 ViewSelection();
279 void SetEdgesOfMarkedNodesDirty();
281 const SdrMarkList& GetMarkedObjectList() const
283 return maMarkedObjectList;
286 const SdrMarkList& GetEdgesOfMarkedNodes() const;
287 const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
288 const std::vector<SdrObject*>& GetAllMarkedObjects() const;
290 SdrMarkList& GetMarkedObjectListWriteAccess()
292 return maMarkedObjectList;
295 } // end of namespace sdr
297 #endif // INCLUDED_SVX_SVDMARK_HXX
299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */