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 <rtl/ustring.hxx>
25 #include <svx/svxdllapi.h>
26 #include <svx/sdrobjectuser.hxx>
27 
28 #include <memory>
29 #include <set>
30 #include <vector>
31 
32 namespace tools { class Rectangle; }
33 class SdrPage;
34 class SdrObjList;
35 class SdrObject;
37 
38 typedef std::set<sal_uInt16> SdrUShortCont;
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  : maList(),
155  mbPointNameOk(false),
156  mbGluePointNameOk(false),
157  mbNameOk(false),
158  mbSorted(true)
159  {
160  }
161 
163  : maList()
164  {
165  *this = rLst;
166  }
167 
169  {
170  Clear();
171  }
172 
173  void Clear();
174  void ForceSort() const;
175  void SetUnsorted()
176  {
177  mbSorted = false;
178  }
179 
180  size_t GetMarkCount() const
181  {
182  return maList.size();
183  }
184 
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);
194 
196  {
197  mbNameOk = false;
198  mbPointNameOk = false;
199  mbGluePointNameOk = false;
200  }
201 
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
206  {
207  return GetPointMarkDescription(false);
208  }
209 
210  const OUString& GetGluePointMarkDescription() const
211  {
212  return GetPointMarkDescription(true);
213  }
214 
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;
218 
219  // All Entries are copied!
220  SdrMarkList& operator=(const SdrMarkList& rLst);
221 };
222 
223 
224 // migrate selections
225 
226 namespace sdr
227 {
228  class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) ViewSelection
229  {
230  SdrMarkList maMarkedObjectList;
231  SdrMarkList maEdgesOfMarkedNodes;
232  SdrMarkList maMarkedEdgesOfMarkedNodes;
233  std::vector<SdrObject*> maAllMarkedObjects;
234 
235  bool mbEdgesOfMarkedNodesDirty : 1;
236 
237  SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
238  SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
239 
240  public:
241  ViewSelection();
242 
243  void SetEdgesOfMarkedNodesDirty();
244 
245  const SdrMarkList& GetMarkedObjectList() const
246  {
247  return maMarkedObjectList;
248  }
249 
250  const SdrMarkList& GetEdgesOfMarkedNodes() const;
251  const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
252  const std::vector<SdrObject*>& GetAllMarkedObjects() const;
253 
254  SdrMarkList& GetMarkedObjectListWriteAccess()
255  {
256  return maMarkedObjectList;
257  }
258  };
259 } // end of namespace sdr
260 
261 #endif // INCLUDED_SVX_SVDMARK_HXX
262 
263 /* 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:180
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:162
bool IsCon1() const
Definition: svdmark.hxx:85
SdrPageView * mpPageView
Definition: svdmark.hxx:48
std::set< sal_uInt16 > SdrUShortCont
Definition: svdmark.hxx:36
void SetUnsorted()
Definition: svdmark.hxx:175
sal_Int64 getTimeStamp() const
Definition: svdmark.hxx:130
OUString maPointName
Definition: svdmark.hxx:141
sal_Int64 mnTimeStamp
Definition: svdmark.hxx:46
void SetNameDirty()
Definition: svdmark.hxx:195
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:210
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:312
bool mbPointNameOk
Definition: svdmark.hxx:144
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:205
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