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