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