/src/libreoffice/include/svx/svdmark.hxx
Line | Count | Source |
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_SVDMARK_HXX |
21 | | #define INCLUDED_SVX_SVDMARK_HXX |
22 | | |
23 | | #include <config_options.h> |
24 | | #include <o3tl/sorted_vector.hxx> |
25 | | #include <rtl/ustring.hxx> |
26 | | #include <svx/svxdllapi.h> |
27 | | #include <svx/sdrobjectuser.hxx> |
28 | | |
29 | | #include <memory> |
30 | | #include <vector> |
31 | | |
32 | | namespace tools { class Rectangle; } |
33 | | class SdrObject; |
34 | | class SdrPageView; |
35 | | |
36 | | typedef o3tl::sorted_vector<sal_uInt16> SdrUShortCont; |
37 | | |
38 | | |
39 | | /** |
40 | | * Everything a View needs to know about a selected object |
41 | | */ |
42 | | class SVXCORE_DLLPUBLIC SdrMark final : public sdr::ObjectUser |
43 | | { |
44 | | sal_Int64 mnTimeStamp; |
45 | | SdrObject* mpSelectedSdrObject; // the selected object |
46 | | SdrPageView* mpPageView; |
47 | | SdrUShortCont maPoints; // Selected Points |
48 | | SdrUShortCont maGluePoints; // 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 |
52 | | |
53 | | SAL_DLLPRIVATE void setTime(); |
54 | | |
55 | | public: |
56 | | explicit SdrMark(SdrObject* pNewObj = nullptr, SdrPageView* pNewPageView = nullptr); |
57 | | SAL_DLLPRIVATE SdrMark(const SdrMark& rMark); |
58 | | ~SdrMark(); |
59 | | |
60 | | // Derived from ObjectUser |
61 | | SAL_DLLPRIVATE virtual void ObjectInDestruction(const SdrObject& rObject) override; |
62 | | |
63 | | SAL_DLLPRIVATE SdrMark& operator=(const SdrMark& rMark); |
64 | | |
65 | | SAL_DLLPRIVATE void SetMarkedSdrObj(SdrObject* pNewObj); |
66 | 0 | SdrObject* GetMarkedSdrObj() const { return mpSelectedSdrObject;} |
67 | | |
68 | | SdrPageView* GetPageView() const |
69 | 0 | { |
70 | 0 | return mpPageView; |
71 | 0 | } |
72 | | |
73 | | void SetPageView(SdrPageView* pNewPageView) |
74 | 0 | { |
75 | 0 | mpPageView = pNewPageView; |
76 | 0 | } |
77 | | |
78 | | void SetCon1(bool bOn) |
79 | 0 | { |
80 | 0 | mbCon1 = bOn; |
81 | 0 | } |
82 | | |
83 | | bool IsCon1() const |
84 | 0 | { |
85 | 0 | return mbCon1; |
86 | 0 | } |
87 | | |
88 | | void SetCon2(bool bOn) |
89 | 0 | { |
90 | 0 | mbCon2 = bOn; |
91 | 0 | } |
92 | | |
93 | | bool IsCon2() const |
94 | 0 | { |
95 | 0 | return mbCon2; |
96 | 0 | } |
97 | | |
98 | | void SetUser(sal_uInt16 nVal) |
99 | 0 | { |
100 | 0 | mnUser = nVal; |
101 | 0 | } |
102 | | |
103 | | sal_uInt16 GetUser() const |
104 | 0 | { |
105 | 0 | return mnUser; |
106 | 0 | } |
107 | | |
108 | | const SdrUShortCont& GetMarkedPoints() const |
109 | 0 | { |
110 | 0 | return maPoints; |
111 | 0 | } |
112 | | |
113 | | const SdrUShortCont& GetMarkedGluePoints() const |
114 | 0 | { |
115 | 0 | return maGluePoints; |
116 | 0 | } |
117 | | |
118 | | SdrUShortCont& GetMarkedPoints() |
119 | 0 | { |
120 | 0 | return maPoints; |
121 | 0 | } |
122 | | |
123 | | SdrUShortCont& GetMarkedGluePoints() |
124 | 0 | { |
125 | 0 | return maGluePoints; |
126 | 0 | } |
127 | | |
128 | | sal_Int64 getTimeStamp() const |
129 | 0 | { |
130 | 0 | return mnTimeStamp; |
131 | 0 | } |
132 | | }; |
133 | | |
134 | | class SVXCORE_DLLPUBLIC SdrMarkList final |
135 | | { |
136 | | std::vector<std::unique_ptr<SdrMark>> maList; |
137 | | |
138 | | OUString maMarkName; |
139 | | OUString maPointName; |
140 | | OUString maGluePointName; |
141 | | |
142 | | bool mbPointNameOk; |
143 | | bool mbGluePointNameOk; |
144 | | bool mbNameOk; |
145 | | bool mbSorted; |
146 | | |
147 | | SVX_DLLPRIVATE void ImpForceSort(); |
148 | | SVX_DLLPRIVATE const OUString& GetPointMarkDescription(bool bGlue) const; |
149 | | |
150 | | public: |
151 | | SdrMarkList() |
152 | 470k | : mbPointNameOk(false), |
153 | 470k | mbGluePointNameOk(false), |
154 | 470k | mbNameOk(false), |
155 | 470k | mbSorted(true) |
156 | 470k | { |
157 | 470k | } |
158 | | |
159 | | SdrMarkList(const SdrMarkList& rLst) |
160 | 0 | { |
161 | 0 | *this = rLst; |
162 | 0 | } |
163 | | |
164 | | ~SdrMarkList() |
165 | 470k | { |
166 | 470k | Clear(); |
167 | 470k | } |
168 | | |
169 | | void Clear(); |
170 | | void ForceSort() const; |
171 | | void SetUnsorted() |
172 | 0 | { |
173 | 0 | mbSorted = false; |
174 | 0 | } |
175 | | |
176 | | size_t GetMarkCount() const |
177 | 2.15M | { |
178 | 2.15M | return maList.size(); |
179 | 2.15M | } |
180 | | |
181 | | SdrMark* GetMark(size_t nNum) const; |
182 | | // returns SAL_MAX_SIZE if not found |
183 | | size_t FindObject(const SdrObject* pObj) const; |
184 | | void InsertEntry(const SdrMark& rMark, bool bChkSort = true); |
185 | | void DeleteMark(size_t nNum); |
186 | | SAL_DLLPRIVATE void ReplaceMark(const SdrMark& rNewMark, size_t nNum); |
187 | | SAL_DLLPRIVATE void Merge(const SdrMarkList& rSrcList, bool bReverse = false); |
188 | | SAL_DLLPRIVATE bool DeletePageView(const SdrPageView& rPV); |
189 | | SAL_DLLPRIVATE bool InsertPageView(const SdrPageView& rPV); |
190 | | |
191 | | void SetNameDirty() |
192 | 695k | { |
193 | 695k | mbNameOk = false; |
194 | 695k | mbPointNameOk = false; |
195 | 695k | mbGluePointNameOk = false; |
196 | 695k | } |
197 | | |
198 | | // A verbal description of selected objects e.g.: |
199 | | // "27 Lines", "12 Objects", "Polygon" or even "Not an object" |
200 | | const OUString& GetMarkDescription() const; |
201 | | const OUString& GetPointMarkDescription() const |
202 | 0 | { |
203 | 0 | return GetPointMarkDescription(false); |
204 | 0 | } |
205 | | |
206 | | const OUString& GetGluePointMarkDescription() const |
207 | 0 | { |
208 | 0 | return GetPointMarkDescription(true); |
209 | 0 | } |
210 | | |
211 | | // pPage=0: Selection of everything! Respect Pages |
212 | | bool TakeBoundRect(SdrPageView const * pPageView, tools::Rectangle& rRect) const; |
213 | | SAL_DLLPRIVATE bool TakeSnapRect(SdrPageView const * pPageView, tools::Rectangle& rRect) const; |
214 | | |
215 | | // All Entries are copied! |
216 | | SdrMarkList& operator=(const SdrMarkList& rLst); |
217 | | }; |
218 | | |
219 | | |
220 | | // migrate selections |
221 | | |
222 | | namespace sdr |
223 | | { |
224 | | class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) ViewSelection |
225 | | { |
226 | | SdrMarkList maMarkedObjectList; |
227 | | SdrMarkList maEdgesOfMarkedNodes; |
228 | | SdrMarkList maMarkedEdgesOfMarkedNodes; |
229 | | std::vector<SdrObject*> maAllMarkedObjects; |
230 | | |
231 | | bool mbEdgesOfMarkedNodesDirty : 1; |
232 | | |
233 | | SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes(); |
234 | | SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj); |
235 | | |
236 | | public: |
237 | | ViewSelection(); |
238 | | |
239 | | void SetEdgesOfMarkedNodesDirty(); |
240 | | |
241 | | const SdrMarkList& GetMarkedObjectList() const |
242 | 1.95M | { |
243 | 1.95M | return maMarkedObjectList; |
244 | 1.95M | } |
245 | | |
246 | | const SdrMarkList& GetEdgesOfMarkedNodes() const; |
247 | | const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const; |
248 | | const std::vector<SdrObject*>& GetAllMarkedObjects() const; |
249 | | |
250 | | SdrMarkList& GetMarkedObjectListWriteAccess() |
251 | 136k | { |
252 | 136k | return maMarkedObjectList; |
253 | 136k | } |
254 | | }; |
255 | | } // end of namespace sdr |
256 | | |
257 | | #endif // INCLUDED_SVX_SVDMARK_HXX |
258 | | |
259 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |