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 .
25 #include <tools/string.hxx>
26 #include "svx/svxdllapi.h"
27 #include <svx/sdrobjectuser.hxx>
37 typedef std::set
<sal_uInt16
> SdrUShortCont
;
40 // Alles was eine View ueber ein markiertes Objekt wissen muss
41 class SVX_DLLPUBLIC SdrMark
: public sdr::ObjectUser
44 SdrObject
* mpSelectedSdrObject
; // the seleceted object
45 SdrPageView
* mpPageView
;
46 SdrUShortCont
* mpPoints
; // Markierte Punkte
47 SdrUShortCont
* mpLines
; // Markierte Linienabschnitte
48 SdrUShortCont
* mpGluePoints
; // Markierte Klebepunkte (deren Id's)
49 sal_Bool mbCon1
; // fuer Connectoren
50 sal_Bool mbCon2
; // fuer Connectoren
51 sal_uInt16 mnUser
; // z.B. fuer CopyObjects, mitkopieren von Edges
54 explicit SdrMark(SdrObject
* pNewObj
= 0L, SdrPageView
* pNewPageView
= 0L);
55 SdrMark(const SdrMark
& rMark
);
58 // derived from ObjectUser
59 virtual void ObjectInDestruction(const SdrObject
& rObject
);
61 SdrMark
& operator=(const SdrMark
& rMark
);
62 sal_Bool
operator==(const SdrMark
& rMark
) const;
63 sal_Bool
operator!=(const SdrMark
& rMark
) const
65 return !(operator==(rMark
));
68 void SetMarkedSdrObj(SdrObject
* pNewObj
);
69 SdrObject
* GetMarkedSdrObj() const;
71 SdrPageView
* GetPageView() const
76 void SetPageView(SdrPageView
* pNewPageView
)
78 mpPageView
= pNewPageView
;
81 void SetCon1(sal_Bool bOn
)
86 sal_Bool
IsCon1() const
91 void SetCon2(sal_Bool bOn
)
96 sal_Bool
IsCon2() const
101 void SetUser(sal_uInt16 nVal
)
106 sal_uInt16
GetUser() const
111 const SdrUShortCont
* GetMarkedPoints() const
116 const SdrUShortCont
* GetMarkedLines() const
121 const SdrUShortCont
* GetMarkedGluePoints() const
126 SdrUShortCont
* GetMarkedPoints()
131 SdrUShortCont
* GetMarkedLines()
136 SdrUShortCont
* GetMarkedGluePoints()
141 SdrUShortCont
* ForceMarkedPoints()
144 mpPoints
= new SdrUShortCont
;
149 SdrUShortCont
* ForceMarkedLines()
152 mpLines
= new SdrUShortCont
;
157 SdrUShortCont
* ForceMarkedGluePoints()
160 mpGluePoints
= new SdrUShortCont
;
166 class SVX_DLLPUBLIC SdrMarkList
169 std::vector
<SdrMark
*> maList
;
173 String maGluePointName
;
175 sal_Bool mbPointNameOk
;
176 sal_Bool mbGluePointNameOk
;
181 SVX_DLLPRIVATE sal_Bool
operator==(const SdrMarkList
& rCmpMarkList
) const;
182 SVX_DLLPRIVATE
void ImpForceSort();
185 SVX_DLLPRIVATE
const XubString
& GetPointMarkDescription(sal_Bool bGlue
) const;
190 mbPointNameOk(sal_False
),
191 mbGluePointNameOk(sal_False
),
197 SdrMarkList(const SdrMarkList
& rLst
)
209 void ForceSort() const;
212 mbSorted
= sal_False
;
215 sal_uLong
GetMarkCount() const
217 return maList
.size();
220 SdrMark
* GetMark(sal_uLong nNum
) const;
221 sal_uLong
FindObject(const SdrObject
* pObj
) const;
222 void InsertEntry(const SdrMark
& rMark
, sal_Bool bChkSort
= sal_True
);
223 void DeleteMark(sal_uLong nNum
);
224 void ReplaceMark(const SdrMark
& rNewMark
, sal_uLong nNum
);
225 void Merge(const SdrMarkList
& rSrcList
, sal_Bool bReverse
= sal_False
);
226 sal_Bool
DeletePageView(const SdrPageView
& rPV
);
227 sal_Bool
InsertPageView(const SdrPageView
& rPV
);
231 mbNameOk
= sal_False
;
232 mbPointNameOk
= sal_False
;
233 mbGluePointNameOk
= sal_False
;
236 // Eine verbale Beschreibung der markierten Objekte z.B.:
237 // "27 Linien", "12 Objekte", "Polygon" oder auch "Kein Objekt"
238 const String
& GetMarkDescription() const;
239 const String
& GetPointMarkDescription() const
241 return GetPointMarkDescription(sal_False
);
244 const String
& GetGluePointMarkDescription() const
246 return GetPointMarkDescription(sal_True
);
249 // pPage=0L: Die Markierungen aller! Seiten beruecksichtigen
250 sal_Bool
TakeBoundRect(SdrPageView
* pPageView
, Rectangle
& rRect
) const;
251 sal_Bool
TakeSnapRect(SdrPageView
* pPageView
, Rectangle
& rRect
) const;
253 // Es werden saemtliche Entries kopiert!
254 void operator=(const SdrMarkList
& rLst
);
257 ////////////////////////////////////////////////////////////////////////////////////////////////////
258 // migrate selections
262 class SVX_DLLPUBLIC ViewSelection
264 SdrMarkList maMarkedObjectList
;
265 SdrMarkList maEdgesOfMarkedNodes
;
266 SdrMarkList maMarkedEdgesOfMarkedNodes
;
267 std::vector
<SdrObject
*> maAllMarkedObjects
;
270 unsigned mbEdgesOfMarkedNodesDirty
: 1;
272 SVX_DLLPRIVATE
void ImpForceEdgesOfMarkedNodes();
273 SVX_DLLPRIVATE
void ImplCollectCompleteSelection(SdrObject
* pObj
);
278 void SetEdgesOfMarkedNodesDirty();
280 const SdrMarkList
& GetMarkedObjectList() const
282 return maMarkedObjectList
;
285 const SdrMarkList
& GetEdgesOfMarkedNodes() const;
286 const SdrMarkList
& GetMarkedEdgesOfMarkedNodes() const;
287 const std::vector
<SdrObject
*>& GetAllMarkedObjects() const;
289 SdrMarkList
& GetMarkedObjectListWriteAccess()
291 return maMarkedObjectList
;
294 } // end of namespace sdr
296 #endif //_SVDMARK_HXX
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */