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 <config_options.h>
24 #include <o3tl/sorted_vector.hxx>
25 #include <rtl/ustring.hxx>
26 #include <svx/svxdllapi.h>
27 #include <svx/sdrobjectuser.hxx>
32 namespace tools
{ class Rectangle
; }
38 typedef o3tl::sorted_vector
<sal_uInt16
> SdrUShortCont
;
42 * Everything a View needs to know about a selected object
44 class SVXCORE_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
55 SAL_DLLPRIVATE
void setTime();
58 explicit SdrMark(SdrObject
* pNewObj
= nullptr, SdrPageView
* pNewPageView
= nullptr);
59 SAL_DLLPRIVATE
SdrMark(const SdrMark
& rMark
);
62 // Derived from ObjectUser
63 SAL_DLLPRIVATE
virtual void ObjectInDestruction(const SdrObject
& rObject
) override
;
65 SAL_DLLPRIVATE SdrMark
& operator=(const SdrMark
& rMark
);
67 SAL_DLLPRIVATE
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 SVXCORE_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;
154 : mbPointNameOk(false),
155 mbGluePointNameOk(false),
161 SdrMarkList(const SdrMarkList
& rLst
)
172 void ForceSort() const;
178 size_t GetMarkCount() const
180 return maList
.size();
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 SAL_DLLPRIVATE
void ReplaceMark(const SdrMark
& rNewMark
, size_t nNum
);
189 SAL_DLLPRIVATE
void Merge(const SdrMarkList
& rSrcList
, bool bReverse
= false);
190 SAL_DLLPRIVATE
bool DeletePageView(const SdrPageView
& rPV
);
191 SAL_DLLPRIVATE
bool InsertPageView(const SdrPageView
& rPV
);
196 mbPointNameOk
= false;
197 mbGluePointNameOk
= false;
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
205 return GetPointMarkDescription(false);
208 const OUString
& GetGluePointMarkDescription() const
210 return GetPointMarkDescription(true);
213 // pPage=0: Selection of everything! Respect Pages
214 bool TakeBoundRect(SdrPageView
const * pPageView
, tools::Rectangle
& rRect
) const;
215 SAL_DLLPRIVATE
bool TakeSnapRect(SdrPageView
const * pPageView
, tools::Rectangle
& rRect
) const;
217 // All Entries are copied!
218 SdrMarkList
& operator=(const SdrMarkList
& rLst
);
222 // migrate selections
226 class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC
) ViewSelection
228 SdrMarkList maMarkedObjectList
;
229 SdrMarkList maEdgesOfMarkedNodes
;
230 SdrMarkList maMarkedEdgesOfMarkedNodes
;
231 std::vector
<SdrObject
*> maAllMarkedObjects
;
233 bool mbEdgesOfMarkedNodesDirty
: 1;
235 SVX_DLLPRIVATE
void ImpForceEdgesOfMarkedNodes();
236 SVX_DLLPRIVATE
void ImplCollectCompleteSelection(SdrObject
* pObj
);
241 void SetEdgesOfMarkedNodesDirty();
243 const SdrMarkList
& GetMarkedObjectList() const
245 return maMarkedObjectList
;
248 const SdrMarkList
& GetEdgesOfMarkedNodes() const;
249 const SdrMarkList
& GetMarkedEdgesOfMarkedNodes() const;
250 const std::vector
<SdrObject
*>& GetAllMarkedObjects() const;
252 SdrMarkList
& GetMarkedObjectListWriteAccess()
254 return maMarkedObjectList
;
257 } // end of namespace sdr
259 #endif // INCLUDED_SVX_SVDMARK_HXX
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */