bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / svdmark.hxx
blob4b901f6ab2adaeae30cace5247d8d509d505e15a
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 <memory>
29 #include <set>
30 #include <vector>
32 namespace tools { class Rectangle; }
33 class SdrPage;
34 class SdrObjList;
35 class SdrObject;
36 class SdrPageView;
38 typedef std::set<sal_uInt16> SdrUShortCont;
41 /**
42 * Everything a View needs to know about a selected object
44 class SVX_DLLPUBLIC SdrMark final : public sdr::ObjectUser
46 sal_Int64 mnTimeStamp;
47 SdrObject* mpSelectedSdrObject; // the selected object
48 SdrPageView* mpPageView;
49 SdrUShortCont maPoints; // Selected Points
50 SdrUShortCont maGluePoints; // Selected Gluepoints (their Id's)
51 bool mbCon1; // for Connectors
52 bool mbCon2; // for Connectors
53 sal_uInt16 mnUser; // E.g. for CopyObjects, also copy Edges
55 void setTime();
57 public:
58 explicit SdrMark(SdrObject* pNewObj = nullptr, SdrPageView* pNewPageView = nullptr);
59 SdrMark(const SdrMark& rMark);
60 virtual ~SdrMark();
62 // Derived from ObjectUser
63 virtual void ObjectInDestruction(const SdrObject& rObject) override;
65 SdrMark& operator=(const SdrMark& rMark);
67 void SetMarkedSdrObj(SdrObject* pNewObj);
68 SdrObject* GetMarkedSdrObj() const { return mpSelectedSdrObject;}
70 SdrPageView* GetPageView() const
72 return mpPageView;
75 void SetPageView(SdrPageView* pNewPageView)
77 mpPageView = pNewPageView;
80 void SetCon1(bool bOn)
82 mbCon1 = bOn;
85 bool IsCon1() const
87 return mbCon1;
90 void SetCon2(bool bOn)
92 mbCon2 = bOn;
95 bool IsCon2() const
97 return mbCon2;
100 void SetUser(sal_uInt16 nVal)
102 mnUser = nVal;
105 sal_uInt16 GetUser() const
107 return mnUser;
110 const SdrUShortCont& GetMarkedPoints() const
112 return maPoints;
115 const SdrUShortCont& GetMarkedGluePoints() const
117 return maGluePoints;
120 SdrUShortCont& GetMarkedPoints()
122 return maPoints;
125 SdrUShortCont& GetMarkedGluePoints()
127 return maGluePoints;
130 sal_Int64 getTimeStamp() const
132 return mnTimeStamp;
136 class SVX_DLLPUBLIC SdrMarkList final
138 std::vector<std::unique_ptr<SdrMark>> maList;
140 OUString maMarkName;
141 OUString maPointName;
142 OUString maGluePointName;
144 bool mbPointNameOk;
145 bool mbGluePointNameOk;
146 bool mbNameOk;
147 bool mbSorted;
149 SVX_DLLPRIVATE void ImpForceSort();
150 SVX_DLLPRIVATE const OUString& GetPointMarkDescription(bool bGlue) const;
152 public:
153 SdrMarkList()
154 : maList(),
155 mbPointNameOk(false),
156 mbGluePointNameOk(false),
157 mbNameOk(false),
158 mbSorted(true)
162 SdrMarkList(const SdrMarkList& rLst)
163 : maList()
165 *this = rLst;
168 ~SdrMarkList()
170 Clear();
173 void Clear();
174 void ForceSort() const;
175 void SetUnsorted()
177 mbSorted = false;
180 size_t GetMarkCount() const
182 return maList.size();
185 SdrMark* GetMark(size_t nNum) const;
186 // returns SAL_MAX_SIZE if not found
187 size_t FindObject(const SdrObject* pObj) const;
188 void InsertEntry(const SdrMark& rMark, bool bChkSort = true);
189 void DeleteMark(size_t nNum);
190 void ReplaceMark(const SdrMark& rNewMark, size_t nNum);
191 void Merge(const SdrMarkList& rSrcList, bool bReverse = false);
192 bool DeletePageView(const SdrPageView& rPV);
193 bool InsertPageView(const SdrPageView& rPV);
195 void SetNameDirty()
197 mbNameOk = false;
198 mbPointNameOk = false;
199 mbGluePointNameOk = false;
202 // A verbal description of selected objects e.g.:
203 // "27 Lines", "12 Objects", "Polygon" or even "Not an object"
204 const OUString& GetMarkDescription() const;
205 const OUString& GetPointMarkDescription() const
207 return GetPointMarkDescription(false);
210 const OUString& GetGluePointMarkDescription() const
212 return GetPointMarkDescription(true);
215 // pPage=0: Selection of everything! Respect Pages
216 bool TakeBoundRect(SdrPageView const * pPageView, tools::Rectangle& rRect) const;
217 bool TakeSnapRect(SdrPageView const * pPageView, tools::Rectangle& rRect) const;
219 // All Entries are copied!
220 SdrMarkList& operator=(const SdrMarkList& rLst);
224 // migrate selections
226 namespace sdr
228 class SVX_DLLPUBLIC ViewSelection
230 SdrMarkList maMarkedObjectList;
231 SdrMarkList maEdgesOfMarkedNodes;
232 SdrMarkList maMarkedEdgesOfMarkedNodes;
233 std::vector<SdrObject*> maAllMarkedObjects;
235 bool mbEdgesOfMarkedNodesDirty : 1;
237 SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
238 SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
240 public:
241 ViewSelection();
243 void SetEdgesOfMarkedNodesDirty();
245 const SdrMarkList& GetMarkedObjectList() const
247 return maMarkedObjectList;
250 const SdrMarkList& GetEdgesOfMarkedNodes() const;
251 const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
252 const std::vector<SdrObject*>& GetAllMarkedObjects() const;
254 SdrMarkList& GetMarkedObjectListWriteAccess()
256 return maMarkedObjectList;
259 } // end of namespace sdr
261 #endif // INCLUDED_SVX_SVDMARK_HXX
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */