1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDMARK_HXX
21 #define INCLUDED_SVX_SVDMARK_HXX
23 #include <rtl/ustring.hxx>
24 #include <svx/svxdllapi.h>
25 #include <svx/sdrobjectuser.hxx>
31 namespace tools
{ class Rectangle
; }
37 typedef std::set
<sal_uInt16
> SdrUShortCont
;
41 * Everything a View needs to know about a selected object
43 class SVX_DLLPUBLIC SdrMark final
: public sdr::ObjectUser
45 sal_Int64 mnTimeStamp
;
46 SdrObject
* mpSelectedSdrObject
; // the selected object
47 SdrPageView
* mpPageView
;
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
57 explicit SdrMark(SdrObject
* pNewObj
= nullptr, SdrPageView
* pNewPageView
= nullptr);
58 SdrMark(const SdrMark
& rMark
);
61 // Derived from ObjectUser
62 virtual void ObjectInDestruction(const SdrObject
& rObject
) override
;
64 SdrMark
& operator=(const SdrMark
& rMark
);
66 void SetMarkedSdrObj(SdrObject
* pNewObj
);
67 SdrObject
* GetMarkedSdrObj() const { return mpSelectedSdrObject
;}
69 SdrPageView
* GetPageView() const
74 void SetPageView(SdrPageView
* pNewPageView
)
76 mpPageView
= pNewPageView
;
79 void SetCon1(bool bOn
)
89 void SetCon2(bool bOn
)
99 void SetUser(sal_uInt16 nVal
)
104 sal_uInt16
GetUser() const
109 const SdrUShortCont
& GetMarkedPoints() const
114 const SdrUShortCont
& GetMarkedGluePoints() const
119 SdrUShortCont
& GetMarkedPoints()
124 SdrUShortCont
& GetMarkedGluePoints()
129 sal_Int64
getTimeStamp() const
135 class SVX_DLLPUBLIC SdrMarkList final
137 std::vector
<std::unique_ptr
<SdrMark
>> maList
;
140 OUString maPointName
;
141 OUString maGluePointName
;
144 bool mbGluePointNameOk
;
148 SVX_DLLPRIVATE
void ImpForceSort();
149 SVX_DLLPRIVATE
const OUString
& GetPointMarkDescription(bool bGlue
) const;
154 mbPointNameOk(false),
155 mbGluePointNameOk(false),
161 SdrMarkList(const SdrMarkList
& rLst
)
173 void ForceSort() const;
179 size_t GetMarkCount() const
181 return maList
.size();
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
);
197 mbPointNameOk
= false;
198 mbGluePointNameOk
= false;
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
206 return GetPointMarkDescription(false);
209 const OUString
& GetGluePointMarkDescription() const
211 return GetPointMarkDescription(true);
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;
218 // All Entries are copied!
219 SdrMarkList
& operator=(const SdrMarkList
& rLst
);
223 // migrate selections
227 class SVX_DLLPUBLIC ViewSelection
229 SdrMarkList maMarkedObjectList
;
230 SdrMarkList maEdgesOfMarkedNodes
;
231 SdrMarkList maMarkedEdgesOfMarkedNodes
;
232 std::vector
<SdrObject
*> maAllMarkedObjects
;
234 bool mbEdgesOfMarkedNodesDirty
: 1;
236 SVX_DLLPRIVATE
void ImpForceEdgesOfMarkedNodes();
237 SVX_DLLPRIVATE
void ImplCollectCompleteSelection(SdrObject
* pObj
);
242 void SetEdgesOfMarkedNodesDirty();
244 const SdrMarkList
& GetMarkedObjectList() const
246 return maMarkedObjectList
;
249 const SdrMarkList
& GetEdgesOfMarkedNodes() const;
250 const SdrMarkList
& GetMarkedEdgesOfMarkedNodes() const;
251 const std::vector
<SdrObject
*>& GetAllMarkedObjects() const;
253 SdrMarkList
& GetMarkedObjectListWriteAccess()
255 return maMarkedObjectList
;
258 } // end of namespace sdr
260 #endif // INCLUDED_SVX_SVDMARK_HXX
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */