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 : :
30 : : #include <svx/svdmrkv.hxx>
31 : : #include <svx/svdetc.hxx>
32 : : #include <svx/svdoedge.hxx>
33 : : #include "svx/svdglob.hxx"
34 : : #include <svx/svdpagv.hxx>
35 : : #include <svx/svdpage.hxx>
36 : : #include "svddrgm1.hxx"
37 : :
38 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
39 : : // Point Selection
40 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
41 : :
42 : 1449 : sal_Bool SdrMarkView::HasMarkablePoints() const
43 : : {
44 : 1449 : ForceUndirtyMrkPnt();
45 : 1449 : bool bRet=false;
46 [ - + ]: 1449 : if (!ImpIsFrameHandles()) {
47 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
48 [ # # ]: 0 : if (nMarkAnz<=nFrameHandlesLimit) {
49 [ # # ][ # # ]: 0 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
[ # # ]
50 : 0 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
51 : 0 : const SdrObject* pObj=pM->GetMarkedSdrObj();
52 : 0 : bRet=pObj->IsPolyObj();
53 : : }
54 : : }
55 : : }
56 : 1449 : return bRet;
57 : : }
58 : :
59 : 0 : sal_uIntPtr SdrMarkView::GetMarkablePointCount() const
60 : : {
61 : 0 : ForceUndirtyMrkPnt();
62 : 0 : sal_uIntPtr nAnz=0;
63 [ # # ]: 0 : if (!ImpIsFrameHandles()) {
64 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
65 [ # # ]: 0 : if (nMarkAnz<=nFrameHandlesLimit) {
66 [ # # ]: 0 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
67 : 0 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
68 : 0 : const SdrObject* pObj=pM->GetMarkedSdrObj();
69 [ # # ]: 0 : if (pObj->IsPolyObj()) {
70 : 0 : nAnz+=pObj->GetPointCount();
71 : : }
72 : : }
73 : : }
74 : : }
75 : 0 : return nAnz;
76 : : }
77 : :
78 : 2246 : sal_Bool SdrMarkView::HasMarkedPoints() const
79 : : {
80 : 2246 : ForceUndirtyMrkPnt();
81 : 2246 : sal_Bool bRet=sal_False;
82 [ + + ]: 2246 : if (!ImpIsFrameHandles()) {
83 : 89 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
84 [ + - ]: 89 : if (nMarkAnz<=nFrameHandlesLimit) {
85 [ + + ][ + - ]: 110 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
[ + + ]
86 : 21 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
87 : 21 : const SdrUShortCont* pPts=pM->GetMarkedPoints();
88 [ # # ][ - + ]: 21 : bRet=pPts!=NULL && !pPts->empty();
89 : : }
90 : : }
91 : : }
92 : 2246 : return bRet;
93 : : }
94 : :
95 : 0 : sal_uIntPtr SdrMarkView::GetMarkedPointCount() const
96 : : {
97 : 0 : ForceUndirtyMrkPnt();
98 : 0 : sal_uIntPtr nAnz=0;
99 [ # # ]: 0 : if (!ImpIsFrameHandles()) {
100 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
101 [ # # ]: 0 : if (nMarkAnz<=nFrameHandlesLimit) {
102 [ # # ]: 0 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
103 : 0 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
104 : 0 : const SdrUShortCont* pPts=pM->GetMarkedPoints();
105 [ # # ]: 0 : if (pPts!=NULL) nAnz+=pPts->size();
106 : : }
107 : : }
108 : : }
109 : 0 : return nAnz;
110 : : }
111 : :
112 : 16 : sal_Bool SdrMarkView::IsPointMarkable(const SdrHdl& rHdl) const
113 : : {
114 [ - + ][ # # ]: 16 : return !ImpIsFrameHandles() && &rHdl!=NULL && !rHdl.IsPlusHdl() && rHdl.GetKind()!=HDL_GLUE && rHdl.GetKind()!=HDL_SMARTTAG && rHdl.GetObj()!=NULL && rHdl.GetObj()->IsPolyObj();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
115 : : }
116 : :
117 : 0 : sal_Bool SdrMarkView::MarkPointHelper(SdrHdl* pHdl, SdrMark* pMark, sal_Bool bUnmark)
118 : : {
119 : 0 : return ImpMarkPoint( pHdl, pMark, bUnmark );
120 : : }
121 : :
122 : 0 : sal_Bool SdrMarkView::ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, sal_Bool bUnmark)
123 : : {
124 [ # # ][ # # ]: 0 : if (pHdl==NULL || pHdl->IsPlusHdl() || pHdl->GetKind()==HDL_GLUE)
[ # # ][ # # ]
125 : 0 : return sal_False;
126 : :
127 [ # # ]: 0 : if (pHdl->IsSelected() != bUnmark)
128 : 0 : return sal_False;
129 : :
130 : 0 : SdrObject* pObj=pHdl->GetObj();
131 [ # # ][ # # ]: 0 : if (pObj==NULL || !pObj->IsPolyObj())
[ # # ]
132 : 0 : return sal_False;
133 : :
134 [ # # ]: 0 : if (pMark==NULL)
135 : : {
136 : 0 : sal_uIntPtr nMarkNum=TryToFindMarkedObject(pObj);
137 [ # # ]: 0 : if (nMarkNum==CONTAINER_ENTRY_NOTFOUND)
138 : 0 : return sal_False;
139 : 0 : pMark=GetSdrMarkByIndex(nMarkNum);
140 : : }
141 : 0 : const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
142 : 0 : SdrUShortCont* pPts=pMark->ForceMarkedPoints();
143 [ # # ]: 0 : if (!bUnmark)
144 : : {
145 [ # # ]: 0 : pPts->insert((sal_uInt16)nHdlNum);
146 : : }
147 : : else
148 : : {
149 [ # # ]: 0 : SdrUShortCont::const_iterator it = pPts->find( (sal_uInt16)nHdlNum );
150 [ # # ][ # # ]: 0 : if (it != pPts->end())
151 : : {
152 [ # # ]: 0 : pPts->erase(it);
153 : : }
154 : : else
155 : : {
156 : 0 : return sal_False; // error case!
157 : : }
158 : : }
159 : :
160 : 0 : pHdl->SetSelected(!bUnmark);
161 [ # # ]: 0 : if (!bPlusHdlAlways)
162 : : {
163 [ # # ]: 0 : if (!bUnmark)
164 : : {
165 : 0 : sal_uInt32 nAnz(pObj->GetPlusHdlCount(*pHdl));
166 [ # # ]: 0 : for (sal_uInt32 i=0; i<nAnz; i++)
167 : : {
168 : 0 : SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,i);
169 [ # # ]: 0 : if (pPlusHdl!=NULL)
170 : : {
171 : 0 : pPlusHdl->SetObj(pObj);
172 : 0 : pPlusHdl->SetPageView(pMark->GetPageView());
173 : 0 : pPlusHdl->SetPlusHdl(sal_True);
174 : 0 : aHdl.AddHdl(pPlusHdl);
175 : : }
176 : : }
177 : : }
178 : : else
179 : : {
180 [ # # ]: 0 : for (sal_uIntPtr i = aHdl.GetHdlCount(); i>0;)
181 : : {
182 : 0 : i--;
183 : 0 : SdrHdl* pPlusHdl=aHdl.GetHdl(i);
184 [ # # ][ # # ]: 0 : if (pPlusHdl->IsPlusHdl() && pPlusHdl->GetSourceHdlNum()==nHdlNum)
[ # # ]
185 : : {
186 : 0 : aHdl.RemoveHdl(i);
187 [ # # ]: 0 : delete pPlusHdl;
188 : : }
189 : : }
190 : : }
191 : : }
192 : :
193 : 0 : aHdl.Sort();
194 : :
195 : 0 : return sal_True;
196 : : }
197 : :
198 : :
199 : 0 : sal_Bool SdrMarkView::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark)
200 : : {
201 [ # # ]: 0 : if (&rHdl==NULL) return sal_False;
202 : 0 : ForceUndirtyMrkPnt();
203 : 0 : sal_Bool bRet=sal_False;
204 : 0 : const SdrObject* pObj=rHdl.GetObj();
205 [ # # ][ # # ]: 0 : if (IsPointMarkable(rHdl) && rHdl.IsSelected()==bUnmark) {
[ # # ]
206 : 0 : sal_uIntPtr nMarkNum=TryToFindMarkedObject(pObj);
207 [ # # ]: 0 : if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) {
208 : 0 : SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
209 : 0 : pM->ForceMarkedPoints();
210 [ # # ]: 0 : if (ImpMarkPoint(&rHdl,pM,bUnmark)) {
211 : 0 : MarkListHasChanged();
212 : 0 : bRet=sal_True;
213 : : }
214 : : }
215 : : }
216 : :
217 : 0 : return bRet;
218 : : }
219 : :
220 : 130 : sal_Bool SdrMarkView::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
221 : : {
222 : 130 : ForceUndirtyMrkPnt();
223 : 130 : sal_Bool bChgd=sal_False;
224 : 130 : SortMarkedObjects();
225 : 130 : const SdrObject* pObj0=NULL;
226 : 130 : const SdrPageView* pPV0=NULL;
227 : 130 : SdrMark* pM=NULL;
228 : 130 : aHdl.Sort();
229 : 130 : sal_uIntPtr nHdlAnz=aHdl.GetHdlCount();
230 [ + + ]: 146 : for (sal_uIntPtr nHdlNum=nHdlAnz; nHdlNum>0;) {
231 : 16 : nHdlNum--;
232 : 16 : SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
233 [ # # ][ - + ]: 16 : if (IsPointMarkable(*pHdl) && pHdl->IsSelected()==bUnmark) {
[ - + ]
234 : 0 : const SdrObject* pObj=pHdl->GetObj();
235 : 0 : const SdrPageView* pPV=pHdl->GetPageView();
236 [ # # ][ # # ]: 0 : if (pObj!=pObj0 || pPV!=pPV0 || pM==NULL) { // This section is for optimization,
[ # # ]
237 [ # # ]: 0 : sal_uIntPtr nMarkNum=TryToFindMarkedObject(pObj); // so ImpMarkPoint() doesn't always
238 [ # # ]: 0 : if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) { // have to search the object in the MarkList.
239 [ # # ]: 0 : pM=GetSdrMarkByIndex(nMarkNum);
240 : 0 : pObj0=pObj;
241 : 0 : pPV0=pPV;
242 [ # # ]: 0 : pM->ForceMarkedPoints();
243 : : } else {
244 : : #ifdef DBG_UTIL
245 : : if (pObj->IsInserted()) {
246 : : OSL_FAIL("SdrMarkView::MarkPoints(const Rectangle* pRect): Selected object not found.");
247 : : }
248 : : #endif
249 : 0 : pM=NULL;
250 : : }
251 : : }
252 : 0 : Point aPos(pHdl->GetPos());
253 [ # # ][ # # ]: 0 : if (pM!=NULL && (pRect==NULL || pRect->IsInside(aPos))) {
[ # # ][ # # ]
[ # # ]
254 [ # # ][ # # ]: 0 : if (ImpMarkPoint(pHdl,pM,bUnmark)) bChgd=sal_True;
255 : : }
256 : : }
257 : : }
258 [ - + ]: 130 : if (bChgd) {
259 : 0 : MarkListHasChanged();
260 : : }
261 : :
262 : 130 : return bChgd;
263 : : }
264 : :
265 : 0 : sal_Bool SdrMarkView::MarkNextPoint(const Point& /*rPnt*/, sal_Bool /*bPrev*/)
266 : : {
267 : 0 : ForceUndirtyMrkPnt();
268 : 0 : sal_Bool bChgd=sal_False;
269 : 0 : SortMarkedObjects();
270 : : // ...
271 [ # # ]: 0 : if (bChgd) {
272 : 0 : MarkListHasChanged();
273 : : }
274 : 0 : return bChgd;
275 : : }
276 : :
277 : 0 : const Rectangle& SdrMarkView::GetMarkedPointsRect() const
278 : : {
279 : 0 : ForceUndirtyMrkPnt();
280 [ # # ]: 0 : if (bMarkedPointsRectsDirty) ImpSetPointsRects();
281 : 0 : return aMarkedPointsRect;
282 : : }
283 : :
284 : 1373 : void SdrMarkView::SetPlusHandlesAlwaysVisible(sal_Bool bOn)
285 : : { // TODO: Optimize HandlePaint!
286 : 1373 : ForceUndirtyMrkPnt();
287 [ - + ]: 1373 : if (bOn!=bPlusHdlAlways) {
288 : 0 : bPlusHdlAlways=bOn;
289 : 0 : SetMarkHandles();
290 : 0 : MarkListHasChanged();
291 : : }
292 : 1373 : }
293 : :
294 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
295 : : // ImpSetPointsRects() is for PolyPoints and GluePoints!
296 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
297 : :
298 : 0 : void SdrMarkView::ImpSetPointsRects() const
299 : : {
300 [ # # ]: 0 : Rectangle aPnts;
301 [ # # ]: 0 : Rectangle aGlue;
302 : 0 : sal_uIntPtr nHdlAnz=aHdl.GetHdlCount();
303 [ # # ]: 0 : for (sal_uIntPtr nHdlNum=0; nHdlNum<nHdlAnz; nHdlNum++) {
304 [ # # ]: 0 : const SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
305 : 0 : SdrHdlKind eKind=pHdl->GetKind();
306 [ # # ][ # # ]: 0 : if ((eKind==HDL_POLY && pHdl->IsSelected()) || eKind==HDL_GLUE) {
[ # # ][ # # ]
307 : 0 : Point aPt(pHdl->GetPos());
308 [ # # ]: 0 : Rectangle& rR=eKind==HDL_GLUE ? aGlue : aPnts;
309 [ # # ][ # # ]: 0 : if (rR.IsEmpty()) {
310 [ # # ]: 0 : rR=Rectangle(aPt,aPt);
311 : : } else {
312 [ # # ]: 0 : if (aPt.X()<rR.Left ()) rR.Left ()=aPt.X();
313 [ # # ]: 0 : if (aPt.X()>rR.Right ()) rR.Right ()=aPt.X();
314 [ # # ]: 0 : if (aPt.Y()<rR.Top ()) rR.Top ()=aPt.Y();
315 [ # # ]: 0 : if (aPt.Y()>rR.Bottom()) rR.Bottom()=aPt.Y();
316 : : }
317 : : }
318 : : }
319 : 0 : ((SdrMarkView*)this)->aMarkedPointsRect=aPnts;
320 : 0 : ((SdrMarkView*)this)->aMarkedGluePointsRect=aGlue;
321 : 0 : ((SdrMarkView*)this)->bMarkedPointsRectsDirty=sal_False;
322 : 0 : }
323 : :
324 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
325 : : // UndirtyMrkPnt() is for PolyPoints and GluePoints!
326 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
327 : :
328 : 4384 : void SdrMarkView::UndirtyMrkPnt() const
329 : : {
330 : 4384 : sal_Bool bChg=sal_False;
331 : 4384 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
332 [ - + ]: 4384 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
333 : 0 : SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
334 : 0 : const SdrObject* pObj=pM->GetMarkedSdrObj();
335 : : // PolyPoints
336 : 0 : SdrUShortCont* pPts=pM->GetMarkedPoints();
337 [ # # ]: 0 : if (pPts!=NULL) {
338 [ # # ]: 0 : if (pObj->IsPolyObj()) {
339 : : // Remove invalid selected points, that is, all
340 : : // entries above the number of points in the object.
341 [ # # ]: 0 : sal_uInt32 nMax(pObj->GetPointCount());
342 : :
343 [ # # ]: 0 : SdrUShortCont::const_iterator it = pPts->lower_bound(nMax);
344 [ # # ][ # # ]: 0 : if( it != pPts->end() )
345 : : {
346 [ # # ]: 0 : pPts->erase(it, pPts->end() );
347 : 0 : bChg = sal_True;
348 : : }
349 : : }
350 : : else
351 : : {
352 : : OSL_FAIL("SdrMarkView::UndirtyMrkPnt(): Selected points on an object that is not a PolyObj!");
353 [ # # ][ # # ]: 0 : if(pPts && !pPts->empty())
[ # # ]
354 : : {
355 : 0 : pPts->clear();
356 : 0 : bChg = sal_True;
357 : : }
358 : : }
359 : : }
360 : :
361 : : // GluePoints
362 : 0 : pPts=pM->GetMarkedGluePoints();
363 : 0 : const SdrGluePointList* pGPL=pObj->GetGluePointList();
364 [ # # ]: 0 : if (pPts!=NULL) {
365 [ # # ]: 0 : if (pGPL!=NULL) {
366 : : // Remove invalid selected glue points, that is, all entries
367 : : // (IDs) that aren't contained in the GluePointList of the
368 : : // object
369 [ # # ][ # # ]: 0 : for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); )
370 : : {
371 [ # # ]: 0 : sal_uInt16 nId=*it;
372 [ # # ][ # # ]: 0 : if (pGPL->FindGluePoint(nId)==SDRGLUEPOINT_NOTFOUND) {
373 [ # # ][ # # ]: 0 : pPts->erase(it++);
374 : 0 : bChg=sal_True;
375 : : }
376 : : else
377 [ # # ]: 0 : ++it;
378 : : }
379 : : } else {
380 [ # # ][ # # ]: 0 : if (pPts!=NULL && !pPts->empty()) {
[ # # ]
381 : 0 : pPts->clear(); // object doesn't have any glue points (any more)
382 : 0 : bChg=sal_True;
383 : : }
384 : : }
385 : : }
386 : : }
387 [ - + ]: 4384 : if (bChg) ((SdrMarkView*)this)->bMarkedPointsRectsDirty=sal_True;
388 : 4384 : ((SdrMarkView*)this)->bMrkPntDirty=sal_False;
389 : 4384 : }
390 : :
391 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
392 : :
393 : 0 : sal_Bool SdrMarkView::HasMarkableGluePoints() const
394 : : {
395 : 0 : sal_Bool bRet=sal_False;
396 [ # # ]: 0 : if (IsGluePointEditMode()) {
397 : 0 : ForceUndirtyMrkPnt();
398 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
399 [ # # ][ # # ]: 0 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
[ # # ]
400 : 0 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
401 : 0 : const SdrObject* pObj=pM->GetMarkedSdrObj();
402 : 0 : const SdrGluePointList* pGPL=pObj->GetGluePointList();
403 : :
404 : : // #i38892#
405 [ # # ][ # # ]: 0 : if(pGPL && pGPL->GetCount())
[ # # ]
406 : : {
407 [ # # ][ # # ]: 0 : for(sal_uInt16 a(0); !bRet && a < pGPL->GetCount(); a++)
[ # # ]
408 : : {
409 [ # # ]: 0 : if((*pGPL)[a].IsUserDefined())
410 : : {
411 : 0 : bRet = sal_True;
412 : : }
413 : : }
414 : : }
415 : : }
416 : : }
417 : 0 : return bRet;
418 : : }
419 : :
420 : 2245 : sal_Bool SdrMarkView::HasMarkedGluePoints() const
421 : : {
422 : 2245 : ForceUndirtyMrkPnt();
423 : 2245 : sal_Bool bRet=sal_False;
424 : 2245 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
425 [ + + ][ + - ]: 2993 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
[ + + ]
426 : 748 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
427 : 748 : const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
428 [ # # ][ - + ]: 748 : bRet=pPts!=NULL && !pPts->empty();
429 : : }
430 : 2245 : return bRet;
431 : : }
432 : :
433 : 0 : sal_Bool SdrMarkView::MarkGluePoints(const Rectangle* pRect, sal_Bool bUnmark)
434 : : {
435 [ # # ][ # # ]: 0 : if (!IsGluePointEditMode() && !bUnmark) return sal_False;
[ # # ]
436 : 0 : ForceUndirtyMrkPnt();
437 : 0 : sal_Bool bChgd=sal_False;
438 : 0 : SortMarkedObjects();
439 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
440 [ # # ]: 0 : for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
441 : 0 : SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
442 : 0 : const SdrObject* pObj=pM->GetMarkedSdrObj();
443 : 0 : const SdrGluePointList* pGPL=pObj->GetGluePointList();
444 : 0 : SdrUShortCont* pPts=pM->GetMarkedGluePoints();
445 [ # # ][ # # ]: 0 : if (bUnmark && pRect==NULL) { // UnmarkAll
446 [ # # ][ # # ]: 0 : if (pPts!=NULL && !pPts->empty()) {
[ # # ]
447 : 0 : pPts->clear();
448 : 0 : bChgd=sal_True;
449 : : }
450 : : } else {
451 [ # # ][ # # ]: 0 : if (pGPL!=NULL && (pPts!=NULL || !bUnmark)) {
[ # # ]
452 : 0 : sal_uInt16 nGPAnz=pGPL->GetCount();
453 [ # # ]: 0 : for (sal_uInt16 nGPNum=0; nGPNum<nGPAnz; nGPNum++) {
454 : 0 : const SdrGluePoint& rGP=(*pGPL)[nGPNum];
455 : :
456 : : // #i38892#
457 [ # # ]: 0 : if(rGP.IsUserDefined())
458 : : {
459 [ # # ]: 0 : Point aPos(rGP.GetAbsolutePos(*pObj));
460 [ # # ][ # # ]: 0 : if (pRect==NULL || pRect->IsInside(aPos)) {
[ # # ][ # # ]
461 [ # # ]: 0 : if (pPts==NULL)
462 [ # # ]: 0 : pPts=pM->ForceMarkedGluePoints();
463 [ # # ][ # # ]: 0 : bool bContains = pPts->find( rGP.GetId() ) != pPts->end();
464 [ # # ][ # # ]: 0 : if (!bUnmark && !bContains) {
465 : 0 : bChgd=sal_True;
466 [ # # ]: 0 : pPts->insert(rGP.GetId());
467 : : }
468 [ # # ][ # # ]: 0 : if (bUnmark && bContains) {
469 : 0 : bChgd=sal_True;
470 [ # # ]: 0 : pPts->erase(rGP.GetId());
471 : : }
472 : : }
473 : : }
474 : : }
475 : : }
476 : : }
477 : : }
478 [ # # ]: 0 : if (bChgd) {
479 : 0 : AdjustMarkHdl();
480 : 0 : MarkListHasChanged();
481 : : }
482 : 0 : return bChgd;
483 : : }
484 : :
485 : 0 : sal_Bool SdrMarkView::PickGluePoint(const Point& rPnt, SdrObject*& rpObj, sal_uInt16& rnId, SdrPageView*& rpPV, sal_uIntPtr nOptions) const
486 : : {
487 : 0 : SdrObject* pObj0=rpObj;
488 : 0 : sal_uInt16 nId0=rnId;
489 : 0 : rpObj=NULL; rpPV=NULL; rnId=0;
490 [ # # ]: 0 : if (!IsGluePointEditMode()) return sal_False;
491 : 0 : sal_Bool bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
492 : 0 : sal_Bool bNext=(nOptions & SDRSEARCH_NEXT) !=0;
493 : 0 : OutputDevice* pOut=(OutputDevice*)pActualOutDev;
494 [ # # ]: 0 : if (pOut==NULL) pOut=GetFirstOutputDevice();
495 [ # # ]: 0 : if (pOut==NULL) return sal_False;
496 : 0 : SortMarkedObjects();
497 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
498 [ # # ]: 0 : sal_uIntPtr nMarkNum=bBack ? 0 : nMarkAnz;
499 [ # # ]: 0 : if (bNext) {
500 : 0 : nMarkNum=((SdrMarkView*)this)->TryToFindMarkedObject(pObj0);
501 [ # # ]: 0 : if (nMarkNum==CONTAINER_ENTRY_NOTFOUND) return sal_False;
502 [ # # ]: 0 : if (!bBack) nMarkNum++;
503 : : }
504 [ # # ][ # # ]: 0 : while (bBack ? nMarkNum<nMarkAnz : nMarkNum>0) {
505 [ # # ]: 0 : if (!bBack) nMarkNum--;
506 : 0 : const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
507 : 0 : SdrObject* pObj=pM->GetMarkedSdrObj();
508 : 0 : SdrPageView* pPV=pM->GetPageView();
509 : 0 : const SdrGluePointList* pGPL=pObj->GetGluePointList();
510 [ # # ]: 0 : if (pGPL!=NULL) {
511 : 0 : sal_uInt16 nNum=pGPL->HitTest(rPnt,*pOut,pObj,bBack,bNext,nId0);
512 [ # # ]: 0 : if (nNum!=SDRGLUEPOINT_NOTFOUND)
513 : : {
514 : : // #i38892#
515 : 0 : const SdrGluePoint& rCandidate = (*pGPL)[nNum];
516 : :
517 [ # # ]: 0 : if(rCandidate.IsUserDefined())
518 : : {
519 : 0 : rpObj=pObj;
520 : 0 : rnId=(*pGPL)[nNum].GetId();
521 : 0 : rpPV=pPV;
522 : 0 : return sal_True;
523 : : }
524 : : }
525 : : }
526 : 0 : bNext=sal_False; // HitNextGluePoint only for the first Obj
527 [ # # ]: 0 : if (bBack) nMarkNum++;
528 : : }
529 : 0 : return sal_False;
530 : : }
531 : :
532 : 0 : sal_Bool SdrMarkView::MarkGluePoint(const SdrObject* pObj, sal_uInt16 nId, const SdrPageView* /*pPV*/, sal_Bool bUnmark)
533 : : {
534 [ # # ]: 0 : if (!IsGluePointEditMode()) return sal_False;
535 : 0 : ForceUndirtyMrkPnt();
536 : 0 : sal_Bool bChgd=sal_False;
537 [ # # ]: 0 : if (pObj!=NULL) {
538 : 0 : sal_uIntPtr nMarkPos=TryToFindMarkedObject(pObj);
539 [ # # ]: 0 : if (nMarkPos!=CONTAINER_ENTRY_NOTFOUND) {
540 : 0 : SdrMark* pM=GetSdrMarkByIndex(nMarkPos);
541 [ # # ]: 0 : SdrUShortCont* pPts=bUnmark ? pM->GetMarkedGluePoints() : pM->ForceMarkedGluePoints();
542 [ # # ]: 0 : if (pPts!=NULL) {
543 [ # # ][ # # ]: 0 : bool bContains = pPts->find( nId ) != pPts->end();
544 [ # # ][ # # ]: 0 : if (!bUnmark && !bContains) {
545 : 0 : bChgd=sal_True;
546 : 0 : pPts->insert(nId);
547 : : }
548 [ # # ][ # # ]: 0 : if (bUnmark && bContains) {
549 : 0 : bChgd=sal_True;
550 : 0 : pPts->erase(nId);
551 : : }
552 : : }
553 : : } else {
554 : : // TODO: implement implicit selection of objects
555 : : }
556 : : }
557 [ # # ]: 0 : if (bChgd) {
558 : 0 : AdjustMarkHdl();
559 : 0 : MarkListHasChanged();
560 : : }
561 : 0 : return bChgd;
562 : : }
563 : :
564 : 0 : sal_Bool SdrMarkView::IsGluePointMarked(const SdrObject* pObj, sal_uInt16 nId) const
565 : : {
566 : 0 : ForceUndirtyMrkPnt();
567 : 0 : sal_Bool bRet=sal_False;
568 : 0 : sal_uIntPtr nPos=((SdrMarkView*)this)->TryToFindMarkedObject(pObj); // casting to NonConst
569 [ # # ]: 0 : if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
570 : 0 : const SdrMark* pM=GetSdrMarkByIndex(nPos);
571 : 0 : const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
572 [ # # ]: 0 : if (pPts!=NULL) {
573 [ # # ][ # # ]: 0 : bRet = pPts->find( nId ) != pPts->end();
574 : : }
575 : : }
576 : 0 : return bRet;
577 : : }
578 : :
579 : 0 : SdrHdl* SdrMarkView::GetGluePointHdl(const SdrObject* pObj, sal_uInt16 nId) const
580 : : {
581 : 0 : ForceUndirtyMrkPnt();
582 : 0 : sal_uIntPtr nHdlAnz=aHdl.GetHdlCount();
583 [ # # ]: 0 : for (sal_uIntPtr nHdlNum=0; nHdlNum<nHdlAnz; nHdlNum++) {
584 : 0 : SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
585 [ # # ][ # # : 0 : if (pHdl->GetObj()==pObj &&
# # # # ]
586 : 0 : pHdl->GetKind()==HDL_GLUE &&
587 : 0 : pHdl->GetObjHdlNum()==nId ) return pHdl;
588 : : }
589 : 0 : return NULL;
590 : : }
591 : :
592 : 0 : sal_Bool SdrMarkView::MarkNextGluePoint(const Point& /*rPnt*/, sal_Bool /*bPrev*/)
593 : : {
594 : 0 : ForceUndirtyMrkPnt();
595 : 0 : sal_Bool bChgd=sal_False;
596 : 0 : SortMarkedObjects();
597 : : // ...
598 [ # # ]: 0 : if (bChgd) {
599 : 0 : MarkListHasChanged();
600 : : }
601 : 0 : return bChgd;
602 : : }
603 : :
604 : 0 : const Rectangle& SdrMarkView::GetMarkedGluePointsRect() const
605 : : {
606 : 0 : ForceUndirtyMrkPnt();
607 [ # # ]: 0 : if (bMarkedPointsRectsDirty) ImpSetPointsRects();
608 : 0 : return aMarkedGluePointsRect;
609 : : }
610 : :
611 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|