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>
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 SdrPage;
34 class SdrObjList;
35 class SdrObject;
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 
57 public:
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;
142  OUString maGluePointName;
143 
146  bool mbNameOk;
147  bool mbSorted;
148 
149  SVX_DLLPRIVATE void ImpForceSort();
150  SVX_DLLPRIVATE const OUString& GetPointMarkDescription(bool bGlue) const;
151 
152 public:
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;
173  void SetUnsorted()
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 
224 namespace 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: */
bool mbCon2
Definition: svdmark.hxx:52
const SdrUShortCont & GetMarkedGluePoints() const
Definition: svdmark.hxx:115
size_t GetMarkCount() const
Definition: svdmark.hxx:178
bool mbCon1
Definition: svdmark.hxx:51
const SdrUShortCont & GetMarkedPoints() const
Definition: svdmark.hxx:110
SdrUShortCont maGluePoints
Definition: svdmark.hxx:50
SdrUShortCont maPoints
Definition: svdmark.hxx:49
SdrMarkList(const SdrMarkList &rLst)
Definition: svdmark.hxx:161
bool IsCon1() const
Definition: svdmark.hxx:85
SdrPageView * mpPageView
Definition: svdmark.hxx:48
void SetUnsorted()
Definition: svdmark.hxx:173
sal_Int64 getTimeStamp() const
Definition: svdmark.hxx:130
OUString maPointName
Definition: svdmark.hxx:141
o3tl::sorted_vector< sal_uInt16 > SdrUShortCont
Definition: svdmark.hxx:36
sal_Int64 mnTimeStamp
Definition: svdmark.hxx:46
void SetNameDirty()
Definition: svdmark.hxx:193
bool mbNameOk
Definition: svdmark.hxx:146
OUString maMarkName
Definition: svdmark.hxx:140
SdrObject * mpSelectedSdrObject
Definition: svdmark.hxx:47
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
Everything a View needs to know about a selected object.
Definition: svdmark.hxx:44
void SetUser(sal_uInt16 nVal)
Definition: svdmark.hxx:100
const OUString & GetGluePointMarkDescription() const
Definition: svdmark.hxx:208
void SetPageView(SdrPageView *pNewPageView)
Definition: svdmark.hxx:75
SdrPageView * GetPageView() const
Definition: svdmark.hxx:70
void SetCon1(bool bOn)
Definition: svdmark.hxx:80
SdrUShortCont & GetMarkedPoints()
Definition: svdmark.hxx:120
Abstract DrawObject.
Definition: svdobj.hxx:259
bool mbPointNameOk
Definition: svdmark.hxx:144
void Clear(EHistoryType eHistory)
virtual void ObjectInDestruction(const SdrObject &rObject)=0
SdrUShortCont & GetMarkedGluePoints()
Definition: svdmark.hxx:125
bool mbSorted
Definition: svdmark.hxx:147
sal_uInt16 GetUser() const
Definition: svdmark.hxx:105
std::vector< std::unique_ptr< SdrMark > > maList
Definition: svdmark.hxx:138
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
const OUString & GetPointMarkDescription() const
Definition: svdmark.hxx:203
OUString maGluePointName
Definition: svdmark.hxx:142
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
bool IsCon2() const
Definition: svdmark.hxx:95
bool mbGluePointNameOk
Definition: svdmark.hxx:145
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
sal_uInt16 mnUser
Definition: svdmark.hxx:53
void SetCon2(bool bOn)
Definition: svdmark.hxx:90