Bump version to 6.4-15
[LibreOffice.git] / include / svx / svdmark.hxx
blob1c0dd2af670a613030e2b7c6b61145f4bb0448e8
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>
27 #include <memory>
28 #include <set>
29 #include <vector>
31 namespace tools { class Rectangle; }
32 class SdrPage;
33 class SdrObjList;
34 class SdrObject;
35 class SdrPageView;
37 typedef std::set<sal_uInt16> SdrUShortCont;
40 /**
41 * Everything a View needs to know about a selected object
43 class SVX_DLLPUBLIC SdrMark final : public sdr::ObjectUser
45 sal_Int64 mnTimeStamp;
46 SdrObject* mpSelectedSdrObject; // the selected object
47 SdrPageView* mpPageView;
48 SdrUShortCont maPoints; // Selected Points
49 SdrUShortCont maGluePoints; // Selected Gluepoints (their Id's)
50 bool mbCon1; // for Connectors
51 bool mbCon2; // for Connectors
52 sal_uInt16 mnUser; // E.g. for CopyObjects, also copy Edges
54 void setTime();
56 public:
57 explicit SdrMark(SdrObject* pNewObj = nullptr, SdrPageView* pNewPageView = nullptr);
58 SdrMark(const SdrMark& rMark);
59 virtual ~SdrMark();
61 // Derived from ObjectUser
62 virtual void ObjectInDestruction(const SdrObject& rObject) override;
64 SdrMark& operator=(const SdrMark& rMark);
66 void SetMarkedSdrObj(SdrObject* pNewObj);
67 SdrObject* GetMarkedSdrObj() const { return mpSelectedSdrObject;}
69 SdrPageView* GetPageView() const
71 return mpPageView;
74 void SetPageView(SdrPageView* pNewPageView)
76 mpPageView = pNewPageView;
79 void SetCon1(bool bOn)
81 mbCon1 = bOn;
84 bool IsCon1() const
86 return mbCon1;
89 void SetCon2(bool bOn)
91 mbCon2 = bOn;
94 bool IsCon2() const
96 return mbCon2;
99 void SetUser(sal_uInt16 nVal)
101 mnUser = nVal;
104 sal_uInt16 GetUser() const
106 return mnUser;
109 const SdrUShortCont& GetMarkedPoints() const
111 return maPoints;
114 const SdrUShortCont& GetMarkedGluePoints() const
116 return maGluePoints;
119 SdrUShortCont& GetMarkedPoints()
121 return maPoints;
124 SdrUShortCont& GetMarkedGluePoints()
126 return maGluePoints;
129 sal_Int64 getTimeStamp() const
131 return mnTimeStamp;
135 class SVX_DLLPUBLIC SdrMarkList final
137 std::vector<std::unique_ptr<SdrMark>> maList;
139 OUString maMarkName;
140 OUString maPointName;
141 OUString maGluePointName;
143 bool mbPointNameOk;
144 bool mbGluePointNameOk;
145 bool mbNameOk;
146 bool mbSorted;
148 SVX_DLLPRIVATE void ImpForceSort();
149 SVX_DLLPRIVATE const OUString& GetPointMarkDescription(bool bGlue) const;
151 public:
152 SdrMarkList()
153 : maList(),
154 mbPointNameOk(false),
155 mbGluePointNameOk(false),
156 mbNameOk(false),
157 mbSorted(true)
161 SdrMarkList(const SdrMarkList& rLst)
162 : maList()
164 *this = rLst;
167 ~SdrMarkList()
169 Clear();
172 void Clear();
173 void ForceSort() const;
174 void SetUnsorted()
176 mbSorted = false;
179 size_t GetMarkCount() const
181 return maList.size();
184 SdrMark* GetMark(size_t nNum) const;
185 // returns SAL_MAX_SIZE if not found
186 size_t FindObject(const SdrObject* pObj) const;
187 void InsertEntry(const SdrMark& rMark, bool bChkSort = true);
188 void DeleteMark(size_t nNum);
189 void ReplaceMark(const SdrMark& rNewMark, size_t nNum);
190 void Merge(const SdrMarkList& rSrcList, bool bReverse = false);
191 bool DeletePageView(const SdrPageView& rPV);
192 bool InsertPageView(const SdrPageView& rPV);
194 void SetNameDirty()
196 mbNameOk = false;
197 mbPointNameOk = false;
198 mbGluePointNameOk = false;
201 // A verbal description of selected objects e.g.:
202 // "27 Lines", "12 Objects", "Polygon" or even "Not an object"
203 const OUString& GetMarkDescription() const;
204 const OUString& GetPointMarkDescription() const
206 return GetPointMarkDescription(false);
209 const OUString& GetGluePointMarkDescription() const
211 return GetPointMarkDescription(true);
214 // pPage=0: Selection of everything! Respect Pages
215 bool TakeBoundRect(SdrPageView const * pPageView, tools::Rectangle& rRect) const;
216 bool TakeSnapRect(SdrPageView const * pPageView, tools::Rectangle& rRect) const;
218 // All Entries are copied!
219 SdrMarkList& operator=(const SdrMarkList& rLst);
223 // migrate selections
225 namespace sdr
227 class SVX_DLLPUBLIC ViewSelection
229 SdrMarkList maMarkedObjectList;
230 SdrMarkList maEdgesOfMarkedNodes;
231 SdrMarkList maMarkedEdgesOfMarkedNodes;
232 std::vector<SdrObject*> maAllMarkedObjects;
234 bool mbEdgesOfMarkedNodesDirty : 1;
236 SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
237 SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
239 public:
240 ViewSelection();
242 void SetEdgesOfMarkedNodesDirty();
244 const SdrMarkList& GetMarkedObjectList() const
246 return maMarkedObjectList;
249 const SdrMarkList& GetEdgesOfMarkedNodes() const;
250 const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
251 const std::vector<SdrObject*>& GetAllMarkedObjects() const;
253 SdrMarkList& GetMarkedObjectListWriteAccess()
255 return maMarkedObjectList;
258 } // end of namespace sdr
260 #endif // INCLUDED_SVX_SVDMARK_HXX
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */