Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVDMARK_HXX
30 : : #define _SVDMARK_HXX
31 : :
32 : : #include <vector>
33 : :
34 : : #include <tools/string.hxx>
35 : : #include "svx/svxdllapi.h"
36 : : #include <svx/sdrobjectuser.hxx>
37 : :
38 : : #include <set>
39 : :
40 : : class Rectangle;
41 : : class SdrPage;
42 : : class SdrObjList;
43 : : class SdrObject;
44 : : class SdrPageView;
45 : :
46 : : typedef std::set<sal_uInt16> SdrUShortCont;
47 : :
48 : :
49 : : // Alles was eine View ueber ein markiertes Objekt wissen muss
50 : : class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser
51 : : {
52 : : protected:
53 : : SdrObject* mpSelectedSdrObject; // the seleceted object
54 : : SdrPageView* mpPageView;
55 : : SdrUShortCont* mpPoints; // Markierte Punkte
56 : : SdrUShortCont* mpLines; // Markierte Linienabschnitte
57 : : SdrUShortCont* mpGluePoints; // Markierte Klebepunkte (deren Id's)
58 : : sal_Bool mbCon1; // fuer Connectoren
59 : : sal_Bool mbCon2; // fuer Connectoren
60 : : sal_uInt16 mnUser; // z.B. fuer CopyObjects, mitkopieren von Edges
61 : :
62 : : public:
63 : : explicit SdrMark(SdrObject* pNewObj = 0L, SdrPageView* pNewPageView = 0L);
64 : : SdrMark(const SdrMark& rMark);
65 : : virtual ~SdrMark();
66 : :
67 : : // derived from ObjectUser
68 : : virtual void ObjectInDestruction(const SdrObject& rObject);
69 : :
70 : : SdrMark& operator=(const SdrMark& rMark);
71 : : sal_Bool operator==(const SdrMark& rMark) const;
72 : : sal_Bool operator!=(const SdrMark& rMark) const
73 : : {
74 : : return !(operator==(rMark));
75 : : }
76 : :
77 : : void SetMarkedSdrObj(SdrObject* pNewObj);
78 : : SdrObject* GetMarkedSdrObj() const;
79 : :
80 : : SdrPageView* GetPageView() const
81 : : {
82 : : return mpPageView;
83 : : }
84 : :
85 : : void SetPageView(SdrPageView* pNewPageView)
86 : : {
87 : : mpPageView = pNewPageView;
88 : : }
89 : :
90 : : void SetCon1(sal_Bool bOn)
91 : : {
92 : : mbCon1 = bOn;
93 : : }
94 : :
95 : : sal_Bool IsCon1() const
96 : : {
97 : : return mbCon1;
98 : : }
99 : :
100 : : void SetCon2(sal_Bool bOn)
101 : : {
102 : : mbCon2 = bOn;
103 : : }
104 : :
105 : : sal_Bool IsCon2() const
106 : : {
107 : : return mbCon2;
108 : : }
109 : :
110 : : void SetUser(sal_uInt16 nVal)
111 : : {
112 : : mnUser = nVal;
113 : : }
114 : :
115 : : sal_uInt16 GetUser() const
116 : : {
117 : : return mnUser;
118 : : }
119 : :
120 : : const SdrUShortCont* GetMarkedPoints() const
121 : : {
122 : : return mpPoints;
123 : : }
124 : :
125 : : const SdrUShortCont* GetMarkedLines() const
126 : : {
127 : : return mpLines;
128 : : }
129 : :
130 : : const SdrUShortCont* GetMarkedGluePoints() const
131 : : {
132 : : return mpGluePoints;
133 : : }
134 : :
135 : 0 : SdrUShortCont* GetMarkedPoints()
136 : : {
137 : 0 : return mpPoints;
138 : : }
139 : :
140 : : SdrUShortCont* GetMarkedLines()
141 : : {
142 : : return mpLines;
143 : : }
144 : :
145 : : SdrUShortCont* GetMarkedGluePoints()
146 : : {
147 : : return mpGluePoints;
148 : : }
149 : :
150 : 0 : SdrUShortCont* ForceMarkedPoints()
151 : : {
152 [ # # ]: 0 : if(!mpPoints)
153 [ # # ]: 0 : mpPoints = new SdrUShortCont;
154 : :
155 : 0 : return mpPoints;
156 : : }
157 : :
158 : : SdrUShortCont* ForceMarkedLines()
159 : : {
160 : : if(!mpLines)
161 : : mpLines = new SdrUShortCont;
162 : :
163 : : return mpLines;
164 : : }
165 : :
166 : : SdrUShortCont* ForceMarkedGluePoints()
167 : : {
168 : : if(!mpGluePoints)
169 : : mpGluePoints = new SdrUShortCont;
170 : :
171 : : return mpGluePoints;
172 : : }
173 : : };
174 : :
175 : : class SVX_DLLPUBLIC SdrMarkList
176 : : {
177 : : protected:
178 : : std::vector<SdrMark*> maList;
179 : :
180 : : String maMarkName;
181 : : String maPointName;
182 : : String maGluePointName;
183 : :
184 : : sal_Bool mbPointNameOk;
185 : : sal_Bool mbGluePointNameOk;
186 : : sal_Bool mbNameOk;
187 : : sal_Bool mbSorted;
188 : :
189 : : private:
190 : : SVX_DLLPRIVATE sal_Bool operator==(const SdrMarkList& rCmpMarkList) const;
191 : : SVX_DLLPRIVATE void ImpForceSort();
192 : :
193 : : private:
194 : : SVX_DLLPRIVATE const XubString& GetPointMarkDescription(sal_Bool bGlue) const;
195 : :
196 : : public:
197 : 0 : SdrMarkList()
198 : : : maList(),
199 : : mbPointNameOk(sal_False),
200 : : mbGluePointNameOk(sal_False),
201 : : mbNameOk(sal_False),
202 [ # # ][ # # ]: 0 : mbSorted(sal_True)
[ # # ]
203 : : {
204 : 0 : }
205 : :
206 : 3 : SdrMarkList(const SdrMarkList& rLst)
207 [ + - ][ + - ]: 3 : : maList()
[ + - ]
208 : : {
209 [ + - ]: 3 : *this = rLst;
210 : 3 : }
211 : :
212 : 3 : ~SdrMarkList()
213 [ + - ][ + - ]: 3 : {
[ + - ]
214 [ + - ]: 3 : Clear();
215 : 3 : }
216 : :
217 : : void Clear();
218 : : void ForceSort() const;
219 : : void SetUnsorted()
220 : : {
221 : : mbSorted = sal_False;
222 : : }
223 : :
224 : 315896 : sal_uLong GetMarkCount() const
225 : : {
226 : 315896 : return maList.size();
227 : : }
228 : :
229 : 36 : SdrMark* GetMark(sal_uLong nNum) const
230 : : {
231 : 36 : return maList[nNum];
232 : : }
233 : :
234 : : sal_uLong FindObject(const SdrObject* pObj) const;
235 : : void InsertEntry(const SdrMark& rMark, sal_Bool bChkSort = sal_True);
236 : : void DeleteMark(sal_uLong nNum);
237 : : void ReplaceMark(const SdrMark& rNewMark, sal_uLong nNum);
238 : : void Merge(const SdrMarkList& rSrcList, sal_Bool bReverse = sal_False);
239 : : sal_Bool DeletePageView(const SdrPageView& rPV);
240 : : sal_Bool InsertPageView(const SdrPageView& rPV);
241 : :
242 : : void SetNameDirty()
243 : : {
244 : : mbNameOk = sal_False;
245 : : mbPointNameOk = sal_False;
246 : : mbGluePointNameOk = sal_False;
247 : : }
248 : :
249 : : // Eine verbale Beschreibung der markierten Objekte z.B.:
250 : : // "27 Linien", "12 Objekte", "Polygon" oder auch "Kein Objekt"
251 : : const String& GetMarkDescription() const;
252 : : const String& GetPointMarkDescription() const
253 : : {
254 : : return GetPointMarkDescription(sal_False);
255 : : }
256 : :
257 : : const String& GetGluePointMarkDescription() const
258 : : {
259 : : return GetPointMarkDescription(sal_True);
260 : : }
261 : :
262 : : // pPage=0L: Die Markierungen aller! Seiten beruecksichtigen
263 : : sal_Bool TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const;
264 : : sal_Bool TakeSnapRect(SdrPageView* pPageView, Rectangle& rRect) const;
265 : :
266 : : // Es werden saemtliche Entries kopiert!
267 : : void operator=(const SdrMarkList& rLst);
268 : : };
269 : :
270 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
271 : : // migrate selections
272 : :
273 : : namespace sdr
274 : : {
275 : : class SVX_DLLPUBLIC ViewSelection
276 : : {
277 : : SdrMarkList maMarkedObjectList;
278 : : SdrMarkList maEdgesOfMarkedNodes;
279 : : SdrMarkList maMarkedEdgesOfMarkedNodes;
280 : : std::vector<SdrObject*> maAllMarkedObjects;
281 : :
282 : : // bitfield
283 : : unsigned mbEdgesOfMarkedNodesDirty : 1;
284 : :
285 : : SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
286 : : SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
287 : :
288 : : public:
289 : : ViewSelection();
290 : :
291 : : void SetEdgesOfMarkedNodesDirty();
292 : :
293 : 315907 : const SdrMarkList& GetMarkedObjectList() const
294 : : {
295 : 315907 : return maMarkedObjectList;
296 : : }
297 : :
298 : : const SdrMarkList& GetEdgesOfMarkedNodes() const;
299 : : const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
300 : : const std::vector<SdrObject*>& GetAllMarkedObjects() const;
301 : :
302 : : SdrMarkList& GetMarkedObjectListWriteAccess()
303 : : {
304 : : return maMarkedObjectList;
305 : : }
306 : : };
307 : : } // end of namespace sdr
308 : :
309 : : #endif //_SVDMARK_HXX
310 : :
311 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|