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>
26 #include <tools/solar.h>
32 namespace tools
{ class Rectangle
; }
38 typedef std::set
<sal_uInt16
> SdrUShortCont
;
42 * Everything a View needs to know about a selected object
44 class SVX_DLLPUBLIC SdrMark final
: public sdr::ObjectUser
46 sal_Int64 mnTimeStamp
;
47 SdrObject
* mpSelectedSdrObject
; // the selected object
48 SdrPageView
* mpPageView
;
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
58 explicit SdrMark(SdrObject
* pNewObj
= nullptr, SdrPageView
* pNewPageView
= nullptr);
59 SdrMark(const SdrMark
& rMark
);
62 // Derived from ObjectUser
63 virtual void ObjectInDestruction(const SdrObject
& rObject
) override
;
65 SdrMark
& operator=(const SdrMark
& rMark
);
67 void SetMarkedSdrObj(SdrObject
* pNewObj
);
68 SdrObject
* GetMarkedSdrObj() const { return mpSelectedSdrObject
;}
70 SdrPageView
* GetPageView() const
75 void SetPageView(SdrPageView
* pNewPageView
)
77 mpPageView
= pNewPageView
;
80 void SetCon1(bool bOn
)
90 void SetCon2(bool bOn
)
100 void SetUser(sal_uInt16 nVal
)
105 sal_uInt16
GetUser() const
110 const SdrUShortCont
& GetMarkedPoints() const
115 const SdrUShortCont
& GetMarkedGluePoints() const
120 SdrUShortCont
& GetMarkedPoints()
125 SdrUShortCont
& GetMarkedGluePoints()
130 sal_Int64
getTimeStamp() const
136 class SVX_DLLPUBLIC SdrMarkList final
138 std::vector
<std::unique_ptr
<SdrMark
>> maList
;
141 OUString maPointName
;
142 OUString maGluePointName
;
145 bool mbGluePointNameOk
;
149 SVX_DLLPRIVATE
void ImpForceSort();
150 SVX_DLLPRIVATE
const OUString
& GetPointMarkDescription(bool bGlue
) const;
155 mbPointNameOk(false),
156 mbGluePointNameOk(false),
162 SdrMarkList(const SdrMarkList
& rLst
)
174 void ForceSort() const;
180 size_t GetMarkCount() const
182 return maList
.size();
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
);
198 mbPointNameOk
= false;
199 mbGluePointNameOk
= false;
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
207 return GetPointMarkDescription(false);
210 const OUString
& GetGluePointMarkDescription() const
212 return GetPointMarkDescription(true);
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;
219 // All Entries are copied!
220 SdrMarkList
& operator=(const SdrMarkList
& rLst
);
224 // migrate selections
228 class SVX_DLLPUBLIC ViewSelection
230 SdrMarkList maMarkedObjectList
;
231 SdrMarkList maEdgesOfMarkedNodes
;
232 SdrMarkList maMarkedEdgesOfMarkedNodes
;
233 std::vector
<SdrObject
*> maAllMarkedObjects
;
235 bool mbEdgesOfMarkedNodesDirty
: 1;
237 SVX_DLLPRIVATE
void ImpForceEdgesOfMarkedNodes();
238 SVX_DLLPRIVATE
void ImplCollectCompleteSelection(SdrObject
* pObj
);
243 void SetEdgesOfMarkedNodesDirty();
245 const SdrMarkList
& GetMarkedObjectList() const
247 return maMarkedObjectList
;
250 const SdrMarkList
& GetEdgesOfMarkedNodes() const;
251 const SdrMarkList
& GetMarkedEdgesOfMarkedNodes() const;
252 const std::vector
<SdrObject
*>& GetAllMarkedObjects() const;
254 SdrMarkList
& GetMarkedObjectListWriteAccess()
256 return maMarkedObjectList
;
259 } // end of namespace sdr
261 #endif // INCLUDED_SVX_SVDMARK_HXX
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */