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/svdpage.hxx>
31 : :
32 : : // HACK
33 : : #include <sot/storage.hxx>
34 : : #include <sot/clsids.hxx>
35 : : #include <svx/svdview.hxx>
36 : : #include <string.h>
37 : : #ifndef _STRING_H
38 : : #define _STRING_H
39 : : #endif
40 : : #include <vcl/svapp.hxx>
41 : :
42 : : #include <tools/diagnose_ex.h>
43 : : #include <tools/helpers.hxx>
44 : :
45 : : #include <svx/svdetc.hxx>
46 : : #include <svx/svdobj.hxx>
47 : : #include <svx/svdogrp.hxx>
48 : : #include <svx/svdograf.hxx> // for SwapInAll()
49 : : #include <svx/svdoedge.hxx> // for copying the connectors
50 : : #include <svx/svdoole2.hxx> // special case OLE at SdrExchangeFormat
51 : : #include "svx/svditer.hxx"
52 : : #include <svx/svdmodel.hxx>
53 : : #include <svx/svdlayer.hxx>
54 : : #include <svx/svdotext.hxx>
55 : : #include <svx/svdpagv.hxx>
56 : : #include <svx/svdundo.hxx>
57 : : #include <svx/fmglob.hxx>
58 : : #include <svx/polysc3d.hxx>
59 : :
60 : : #include <svx/fmdpage.hxx>
61 : :
62 : : #include <sfx2/objsh.hxx>
63 : : #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
64 : : #include <svx/sdr/contact/viewobjectcontact.hxx>
65 : : #include <svx/sdr/contact/displayinfo.hxx>
66 : : #include <algorithm>
67 : : #include <svl/smplhint.hxx>
68 : : #include <rtl/strbuf.hxx>
69 : :
70 : : using namespace ::com::sun::star;
71 : :
72 : 0 : class SdrObjList::WeakSdrObjectContainerType
73 : : : public ::std::vector<SdrObjectWeakRef>
74 : : {
75 : : public:
76 : 0 : WeakSdrObjectContainerType (const sal_Int32 nInitialSize)
77 : 0 : : ::std::vector<SdrObjectWeakRef>(nInitialSize) {};
78 : : };
79 : :
80 : :
81 : :
82 : : static const sal_Int32 InitialObjectContainerCapacity (64);
83 : : DBG_NAME(SdrObjList)
84 : :
85 [ - + ]: 264081 : TYPEINIT0(SdrObjList);
86 : :
87 : 40539 : SdrObjList::SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage, SdrObjList* pNewUpList):
88 : : maList(),
89 : : mpNavigationOrder(),
90 [ + - ][ + - ]: 40539 : mbIsNavigationOrderDirty(false)
91 : : {
92 : : DBG_CTOR(SdrObjList,NULL);
93 [ + - ]: 40539 : maList.reserve(InitialObjectContainerCapacity);
94 : 40539 : pModel=pNewModel;
95 : 40539 : pPage=pNewPage;
96 : 40539 : pUpList=pNewUpList;
97 : 40539 : bObjOrdNumsDirty=sal_False;
98 : 40539 : bRectsDirty=sal_False;
99 : 40539 : pOwnerObj=NULL;
100 : 40539 : eListKind=SDROBJLIST_UNKNOWN;
101 : 40539 : }
102 : :
103 : 0 : SdrObjList::SdrObjList(const SdrObjList& rSrcList):
104 : : maList(),
105 : : mpNavigationOrder(),
106 [ # # ][ # # ]: 0 : mbIsNavigationOrderDirty(false)
107 : : {
108 : : DBG_CTOR(SdrObjList,NULL);
109 [ # # ]: 0 : maList.reserve(InitialObjectContainerCapacity);
110 : 0 : pModel=NULL;
111 : 0 : pPage=NULL;
112 : 0 : pUpList=NULL;
113 : 0 : bObjOrdNumsDirty=sal_False;
114 : 0 : bRectsDirty=sal_False;
115 : 0 : pOwnerObj=NULL;
116 : 0 : eListKind=SDROBJLIST_UNKNOWN;
117 [ # # ]: 0 : *this=rSrcList;
118 : 0 : }
119 : :
120 [ + - ]: 40405 : SdrObjList::~SdrObjList()
121 : : {
122 : : DBG_DTOR(SdrObjList,NULL);
123 : :
124 : : // To avoid that the Clear() method will broadcast changes when in destruction
125 : : // which would call virtual methos (not allowed in destructor), the model is set
126 : : // to NULL here.
127 : 40405 : pModel = 0L;
128 : :
129 [ + - ]: 40405 : Clear(); // delete contents of container
130 [ - + ]: 75219 : }
131 : :
132 : 0 : void SdrObjList::operator=(const SdrObjList& rSrcList)
133 : : {
134 : 0 : Clear();
135 : 0 : eListKind=rSrcList.eListKind;
136 : 0 : CopyObjects(rSrcList);
137 : 0 : }
138 : :
139 : 0 : void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
140 : : {
141 [ # # ]: 0 : Clear();
142 : 0 : bObjOrdNumsDirty=sal_False;
143 : 0 : bRectsDirty =sal_False;
144 : 0 : sal_uIntPtr nCloneErrCnt=0;
145 [ # # ]: 0 : sal_uIntPtr nAnz=rSrcList.GetObjCount();
146 : 0 : SdrInsertReason aReason(SDRREASON_COPY);
147 : : sal_uIntPtr no;
148 [ # # ]: 0 : for (no=0; no<nAnz; no++) {
149 [ # # ]: 0 : SdrObject* pSO=rSrcList.GetObj(no);
150 : :
151 [ # # ]: 0 : SdrObject* pDO = pSO->Clone();
152 : :
153 [ # # ]: 0 : if (pDO!=NULL) {
154 [ # # ]: 0 : pDO->SetModel(pModel);
155 [ # # ]: 0 : pDO->SetPage(pPage);
156 [ # # ]: 0 : NbcInsertObject(pDO,CONTAINER_APPEND,&aReason);
157 : : } else {
158 : 0 : nCloneErrCnt++;
159 : : }
160 : : }
161 : :
162 : : // and now for the Connectors
163 : : // The new objects would be shown in the rSrcList
164 : : // and then the object connections are made.
165 : : // Similar implementation are setup as the following:
166 : : // void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
167 : : // SdrModel* SdrExchangeView::GetMarkedObjModel() const
168 : : // BOOL SdrExchangeView::Paste(const SdrModel& rMod,...)
169 : : // void SdrEditView::CopyMarked()
170 [ # # ]: 0 : if (nCloneErrCnt==0) {
171 [ # # ]: 0 : for (no=0; no<nAnz; no++) {
172 [ # # ]: 0 : const SdrObject* pSrcOb=rSrcList.GetObj(no);
173 [ # # ][ # # ]: 0 : SdrEdgeObj* pSrcEdge=PTR_CAST(SdrEdgeObj,pSrcOb);
[ # # ][ # # ]
174 [ # # ]: 0 : if (pSrcEdge!=NULL) {
175 [ # # ]: 0 : SdrObject* pSrcNode1=pSrcEdge->GetConnectedNode(sal_True);
176 [ # # ]: 0 : SdrObject* pSrcNode2=pSrcEdge->GetConnectedNode(sal_False);
177 [ # # ][ # # ]: 0 : if (pSrcNode1!=NULL && pSrcNode1->GetObjList()!=pSrcEdge->GetObjList()) pSrcNode1=NULL; // can't do this
[ # # ][ # # ]
[ # # ]
178 [ # # ][ # # ]: 0 : if (pSrcNode2!=NULL && pSrcNode2->GetObjList()!=pSrcEdge->GetObjList()) pSrcNode2=NULL; // across all lists (yet)
[ # # ][ # # ]
[ # # ]
179 [ # # ][ # # ]: 0 : if (pSrcNode1!=NULL || pSrcNode2!=NULL) {
180 [ # # ]: 0 : SdrObject* pEdgeObjTmp=GetObj(no);
181 [ # # ][ # # ]: 0 : SdrEdgeObj* pDstEdge=PTR_CAST(SdrEdgeObj,pEdgeObjTmp);
[ # # ][ # # ]
182 [ # # ]: 0 : if (pDstEdge!=NULL) {
183 [ # # ]: 0 : if (pSrcNode1!=NULL) {
184 [ # # ]: 0 : sal_uIntPtr nDstNode1=pSrcNode1->GetOrdNum();
185 [ # # ]: 0 : SdrObject* pDstNode1=GetObj(nDstNode1);
186 [ # # ]: 0 : if (pDstNode1!=NULL) { // else we get an error!
187 [ # # ]: 0 : pDstEdge->ConnectToNode(sal_True,pDstNode1);
188 : : } else {
189 : : OSL_FAIL("SdrObjList::operator=(): pDstNode1==NULL!");
190 : : }
191 : : }
192 [ # # ]: 0 : if (pSrcNode2!=NULL) {
193 [ # # ]: 0 : sal_uIntPtr nDstNode2=pSrcNode2->GetOrdNum();
194 [ # # ]: 0 : SdrObject* pDstNode2=GetObj(nDstNode2);
195 [ # # ]: 0 : if (pDstNode2!=NULL) { // else the node was probably not selected
196 [ # # ]: 0 : pDstEdge->ConnectToNode(sal_False,pDstNode2);
197 : : } else {
198 : : OSL_FAIL("SdrObjList::operator=(): pDstNode2==NULL!");
199 : : }
200 : : }
201 : : } else {
202 : : OSL_FAIL("SdrObjList::operator=(): pDstEdge==NULL!");
203 : : }
204 : : }
205 : : }
206 : : }
207 : : } else {
208 : : #ifdef DBG_UTIL
209 : : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
210 : : "SdrObjList::operator=(): Error when cloning "));
211 : :
212 : : if(nCloneErrCnt == 1)
213 : : {
214 : : aStr.append(RTL_CONSTASCII_STRINGPARAM("a drawing object."));
215 : : }
216 : : else
217 : : {
218 : : aStr.append(static_cast<sal_Int32>(nCloneErrCnt));
219 : : aStr.append(RTL_CONSTASCII_STRINGPARAM(" drawing objects."));
220 : : }
221 : :
222 : : aStr.append(RTL_CONSTASCII_STRINGPARAM(
223 : : " Not copying connectors."));
224 : :
225 : : OSL_FAIL(aStr.getStr());
226 : : #endif
227 : : }
228 : 0 : }
229 : :
230 : 40405 : void SdrObjList::Clear()
231 : : {
232 : 40405 : sal_Bool bObjectsRemoved(sal_False);
233 : :
234 [ + + ]: 110916 : while( ! maList.empty())
235 : : {
236 : : // remove last object from list
237 [ + - ]: 70511 : SdrObject* pObj = maList.back();
238 [ + - ]: 70511 : RemoveObjectFromContainer(maList.size()-1);
239 : :
240 : : // flushViewObjectContacts() is done since SdrObject::Free is not guaranteed
241 : : // to delete the object and thus refresh visualisations
242 [ + - ][ + - ]: 70511 : pObj->GetViewContact().flushViewObjectContacts(true);
243 : :
244 : 70511 : bObjectsRemoved = sal_True;
245 : :
246 : : // sent remove hint (after removal, see RemoveObject())
247 [ - + ]: 70511 : if(pModel)
248 : : {
249 [ # # ]: 0 : SdrHint aHint(*pObj);
250 [ # # ]: 0 : aHint.SetKind(HINT_OBJREMOVED);
251 [ # # ]: 0 : aHint.SetPage(pPage);
252 [ # # ][ # # ]: 0 : pModel->Broadcast(aHint);
253 : : }
254 : :
255 : : // delete the object itself
256 [ + - ]: 70511 : SdrObject::Free( pObj );
257 : : }
258 : :
259 [ - + ][ # # ]: 40405 : if(pModel && bObjectsRemoved)
260 : : {
261 : 0 : pModel->SetChanged();
262 : : }
263 : 40405 : }
264 : :
265 : 0 : SdrPage* SdrObjList::GetPage() const
266 : : {
267 : 0 : return pPage;
268 : : }
269 : :
270 : 110866 : void SdrObjList::SetPage(SdrPage* pNewPage)
271 : : {
272 [ + + ]: 110866 : if (pPage!=pNewPage) {
273 : 73422 : pPage=pNewPage;
274 : 73422 : sal_uIntPtr nAnz=GetObjCount();
275 [ + + ]: 138220 : for (sal_uIntPtr no=0; no<nAnz; no++) {
276 : 64798 : SdrObject* pObj=GetObj(no);
277 : 64798 : pObj->SetPage(pPage);
278 : : }
279 : : }
280 : 110866 : }
281 : :
282 : 445588 : SdrModel* SdrObjList::GetModel() const
283 : : {
284 : 445588 : return pModel;
285 : : }
286 : :
287 : 40556 : void SdrObjList::SetModel(SdrModel* pNewModel)
288 : : {
289 [ + + ]: 40556 : if (pModel!=pNewModel) {
290 : 37489 : pModel=pNewModel;
291 : 37489 : sal_uIntPtr nAnz=GetObjCount();
292 [ + + ]: 37877 : for (sal_uIntPtr i=0; i<nAnz; i++) {
293 : 388 : SdrObject* pObj=GetObj(i);
294 : 388 : pObj->SetModel(pModel);
295 : : }
296 : : }
297 : 40556 : }
298 : :
299 : 12924 : void SdrObjList::RecalcObjOrdNums()
300 : : {
301 : 12924 : sal_uIntPtr nAnz=GetObjCount();
302 [ + + ]: 46503 : for (sal_uIntPtr no=0; no<nAnz; no++) {
303 : 33579 : SdrObject* pObj=GetObj(no);
304 : 33579 : pObj->SetOrdNum(no);
305 : : }
306 : 12924 : bObjOrdNumsDirty=sal_False;
307 : 12924 : }
308 : :
309 : 58905 : void SdrObjList::RecalcRects()
310 : : {
311 : 58905 : aOutRect=Rectangle();
312 : 58905 : aSnapRect=aOutRect;
313 : 58905 : sal_uIntPtr nAnz=GetObjCount();
314 : : sal_uIntPtr i;
315 [ + + ]: 179835 : for (i=0; i<nAnz; i++) {
316 : 120930 : SdrObject* pObj=GetObj(i);
317 [ + + ]: 120930 : if (i==0) {
318 : 51036 : aOutRect=pObj->GetCurrentBoundRect();
319 : 51036 : aSnapRect=pObj->GetSnapRect();
320 : : } else {
321 : 69894 : aOutRect.Union(pObj->GetCurrentBoundRect());
322 : 69894 : aSnapRect.Union(pObj->GetSnapRect());
323 : : }
324 : : }
325 : 58905 : }
326 : :
327 : 12780207 : void SdrObjList::SetRectsDirty()
328 : : {
329 : 12780207 : bRectsDirty=sal_True;
330 [ + + ]: 12780207 : if (pUpList!=NULL) pUpList->SetRectsDirty();
331 : 12780207 : }
332 : :
333 : 93067 : void SdrObjList::impChildInserted(SdrObject& rChild) const
334 : : {
335 : 93067 : sdr::contact::ViewContact* pParent = rChild.GetViewContact().GetParentContact();
336 : :
337 [ + - ]: 93067 : if(pParent)
338 : : {
339 : 93067 : pParent->ActionChildInserted(rChild.GetViewContact());
340 : : }
341 : 93067 : }
342 : :
343 : 92968 : void SdrObjList::NbcInsertObject(SdrObject* pObj, sal_uIntPtr nPos, const SdrInsertReason* /*pReason*/)
344 : : {
345 : : DBG_ASSERT(pObj!=NULL,"SdrObjList::NbcInsertObject(NULL)");
346 [ + - ]: 92968 : if (pObj!=NULL) {
347 : : DBG_ASSERT(!pObj->IsInserted(),"ZObjekt already has the status Inserted.");
348 : 92968 : sal_uIntPtr nAnz=GetObjCount();
349 [ + + ]: 92968 : if (nPos>nAnz) nPos=nAnz;
350 : 92968 : InsertObjectIntoContainer(*pObj,nPos);
351 : :
352 [ + + ]: 92968 : if (nPos<nAnz) bObjOrdNumsDirty=sal_True;
353 : 92968 : pObj->SetOrdNum(nPos);
354 : 92968 : pObj->SetObjList(this);
355 : 92968 : pObj->SetPage(pPage);
356 : :
357 : : // Inform the parent about change to allow invalidations at
358 : : // evtl. existing parent visualisations
359 : 92968 : impChildInserted(*pObj);
360 : :
361 [ + + ]: 92968 : if (!bRectsDirty) {
362 : 29180 : aOutRect.Union(pObj->GetCurrentBoundRect());
363 : 29180 : aSnapRect.Union(pObj->GetSnapRect());
364 : : }
365 : 92968 : pObj->SetInserted(sal_True); // calls the UserCall (among others)
366 : : }
367 : 92968 : }
368 : :
369 : 89717 : void SdrObjList::InsertObject(SdrObject* pObj, sal_uIntPtr nPos, const SdrInsertReason* pReason)
370 : : {
371 : : DBG_ASSERT(pObj!=NULL,"SdrObjList::InsertObject(NULL)");
372 : :
373 [ + - ]: 89717 : if(pObj)
374 : : {
375 : : // if anchor is used, reset it before grouping
376 [ + + ]: 89717 : if(GetOwnerObj())
377 : : {
378 : 85893 : const Point& rAnchorPos = pObj->GetAnchorPos();
379 [ - + ][ - + ]: 85893 : if(rAnchorPos.X() || rAnchorPos.Y())
[ + - ]
380 [ # # ]: 0 : pObj->NbcSetAnchorPos(Point());
381 : : }
382 : :
383 : : // do insert to new group
384 : 89717 : NbcInsertObject(pObj, nPos, pReason);
385 : :
386 : : // In case the object is inserted into a group and doesn't overlap with
387 : : // the group's other members, it needs an own repaint.
388 [ + + ]: 89717 : if(pOwnerObj)
389 : : {
390 : : // only repaint here
391 : 85893 : pOwnerObj->ActionChanged();
392 : : }
393 : :
394 [ + + ]: 89717 : if(pModel)
395 : : {
396 : : // TODO: We need a different broadcast here!
397 : : // Repaint from object number ... (heads-up: GroupObj)
398 [ + - ]: 89689 : if(pObj->GetPage())
399 : : {
400 [ + - ]: 89689 : SdrHint aHint(*pObj);
401 : :
402 [ + - ]: 89689 : aHint.SetKind(HINT_OBJINSERTED);
403 [ + - ][ + - ]: 89689 : pModel->Broadcast(aHint);
404 : : }
405 : :
406 : 89689 : pModel->SetChanged();
407 : : }
408 : : }
409 : 89717 : }
410 : :
411 : 20432 : SdrObject* SdrObjList::NbcRemoveObject(sal_uIntPtr nObjNum)
412 : : {
413 [ - + ]: 20432 : if (nObjNum >= maList.size())
414 : : {
415 : : OSL_ASSERT(nObjNum<maList.size());
416 : 0 : return NULL;
417 : : }
418 : :
419 : 20432 : sal_uIntPtr nAnz=GetObjCount();
420 : 20432 : SdrObject* pObj=maList[nObjNum];
421 : 20432 : RemoveObjectFromContainer(nObjNum);
422 : :
423 : : DBG_ASSERT(pObj!=NULL,"Could not find object to remove.");
424 [ + - ]: 20432 : if (pObj!=NULL) {
425 : : // flushViewObjectContacts() clears the VOC's and those invalidate
426 : 20432 : pObj->GetViewContact().flushViewObjectContacts(true);
427 : :
428 : : DBG_ASSERT(pObj->IsInserted(),"ZObjekt does not have the status Inserted.");
429 : 20432 : pObj->SetInserted(sal_False); // Ruft u.a. den UserCall
430 : 20432 : pObj->SetObjList(NULL);
431 : 20432 : pObj->SetPage(NULL);
432 [ - + ]: 20432 : if (!bObjOrdNumsDirty) { // optimizing for the case that the last object has to be removed
433 [ # # ]: 0 : if (nObjNum!=sal_uIntPtr(nAnz-1)) {
434 : 0 : bObjOrdNumsDirty=sal_True;
435 : : }
436 : : }
437 : 20432 : SetRectsDirty();
438 : : }
439 : 20432 : return pObj;
440 : : }
441 : :
442 : 1848 : SdrObject* SdrObjList::RemoveObject(sal_uIntPtr nObjNum)
443 : : {
444 [ - + ]: 1848 : if (nObjNum >= maList.size())
445 : : {
446 : : OSL_ASSERT(nObjNum<maList.size());
447 : 0 : return NULL;
448 : : }
449 : :
450 : 1848 : sal_uIntPtr nAnz=GetObjCount();
451 : 1848 : SdrObject* pObj=maList[nObjNum];
452 : 1848 : RemoveObjectFromContainer(nObjNum);
453 : :
454 : : DBG_ASSERT(pObj!=NULL,"Object to remove not found.");
455 [ + - ]: 1848 : if(pObj)
456 : : {
457 : : // flushViewObjectContacts() clears the VOC's and those invalidate
458 : 1848 : pObj->GetViewContact().flushViewObjectContacts(true);
459 : :
460 : : DBG_ASSERT(pObj->IsInserted(),"ZObjekt does not have the status Inserted.");
461 [ + - ]: 1848 : if (pModel!=NULL) {
462 : : // TODO: We need a different broadcast here.
463 [ + - ]: 1848 : if (pObj->GetPage()!=NULL) {
464 [ + - ]: 1848 : SdrHint aHint(*pObj);
465 [ + - ]: 1848 : aHint.SetKind(HINT_OBJREMOVED);
466 [ + - ][ + - ]: 1848 : pModel->Broadcast(aHint);
467 : : }
468 : 1848 : pModel->SetChanged();
469 : : }
470 : 1848 : pObj->SetInserted(sal_False); // calls, among other things, the UserCall
471 : 1848 : pObj->SetObjList(NULL);
472 : 1848 : pObj->SetPage(NULL);
473 [ - + ]: 1848 : if (!bObjOrdNumsDirty) { // optimization for the case that the last object is removed
474 [ # # ]: 0 : if (nObjNum!=sal_uIntPtr(nAnz-1)) {
475 : 0 : bObjOrdNumsDirty=sal_True;
476 : : }
477 : : }
478 : 1848 : SetRectsDirty();
479 : :
480 [ + + ][ + + ]: 1848 : if(pOwnerObj && !GetObjCount())
[ + + ]
481 : : {
482 : : // empty group created; it needs to be repainted since it's
483 : : // visualization changes
484 : 9 : pOwnerObj->ActionChanged();
485 : : }
486 : : }
487 : 1848 : return pObj;
488 : : }
489 : :
490 : 0 : SdrObject* SdrObjList::NbcReplaceObject(SdrObject* pNewObj, sal_uIntPtr nObjNum)
491 : : {
492 [ # # ][ # # ]: 0 : if (nObjNum >= maList.size() || pNewObj == NULL)
[ # # ]
493 : : {
494 : : OSL_ASSERT(nObjNum<maList.size());
495 : : OSL_ASSERT(pNewObj!=NULL);
496 : 0 : return NULL;
497 : : }
498 : :
499 : 0 : SdrObject* pObj=maList[nObjNum];
500 : : DBG_ASSERT(pObj!=NULL,"SdrObjList::ReplaceObject: Could not find object to remove.");
501 [ # # ]: 0 : if (pObj!=NULL) {
502 : : DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: ZObjekt does not have status Inserted.");
503 : 0 : pObj->SetInserted(sal_False);
504 : 0 : pObj->SetObjList(NULL);
505 : 0 : pObj->SetPage(NULL);
506 : 0 : ReplaceObjectInContainer(*pNewObj,nObjNum);
507 : :
508 : : // flushViewObjectContacts() clears the VOC's and those invalidate
509 : 0 : pObj->GetViewContact().flushViewObjectContacts(true);
510 : :
511 : 0 : pNewObj->SetOrdNum(nObjNum);
512 : 0 : pNewObj->SetObjList(this);
513 : 0 : pNewObj->SetPage(pPage);
514 : :
515 : : // Inform the parent about change to allow invalidations at
516 : : // evtl. existing parent visualisations
517 : 0 : impChildInserted(*pNewObj);
518 : :
519 : 0 : pNewObj->SetInserted(sal_True);
520 : 0 : SetRectsDirty();
521 : : }
522 : 0 : return pObj;
523 : : }
524 : :
525 : 99 : SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, sal_uIntPtr nObjNum)
526 : : {
527 [ - + ]: 99 : if (nObjNum >= maList.size())
528 : : {
529 : : OSL_ASSERT(nObjNum<maList.size());
530 : 0 : return NULL;
531 : : }
532 [ - + ]: 99 : if (pNewObj == NULL)
533 : : {
534 : : OSL_ASSERT(pNewObj!=NULL);
535 : 0 : return NULL;
536 : : }
537 : :
538 : 99 : SdrObject* pObj=maList[nObjNum];
539 : : DBG_ASSERT(pObj!=NULL,"SdrObjList::ReplaceObject: Could not find object to remove.");
540 [ + - ]: 99 : if (pObj!=NULL) {
541 : : DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: ZObjekt does not have status Inserted.");
542 [ + - ]: 99 : if (pModel!=NULL) {
543 : : // TODO: We need a different broadcast here.
544 [ + - ]: 99 : if (pObj->GetPage()!=NULL) {
545 [ + - ]: 99 : SdrHint aHint(*pObj);
546 [ + - ]: 99 : aHint.SetKind(HINT_OBJREMOVED);
547 [ + - ][ + - ]: 99 : pModel->Broadcast(aHint);
548 : : }
549 : : }
550 : 99 : pObj->SetInserted(sal_False);
551 : 99 : pObj->SetObjList(NULL);
552 : 99 : pObj->SetPage(NULL);
553 : 99 : ReplaceObjectInContainer(*pNewObj,nObjNum);
554 : :
555 : : // flushViewObjectContacts() clears the VOC's and those invalidate
556 : 99 : pObj->GetViewContact().flushViewObjectContacts(true);
557 : :
558 : 99 : pNewObj->SetOrdNum(nObjNum);
559 : 99 : pNewObj->SetObjList(this);
560 : 99 : pNewObj->SetPage(pPage);
561 : :
562 : : // Inform the parent about change to allow invalidations at
563 : : // evtl. existing parent visualisations
564 : 99 : impChildInserted(*pNewObj);
565 : :
566 : 99 : pNewObj->SetInserted(sal_True);
567 [ + - ]: 99 : if (pModel!=NULL) {
568 : : // TODO: We need a different broadcast here.
569 [ + - ]: 99 : if (pNewObj->GetPage()!=NULL) {
570 [ + - ]: 99 : SdrHint aHint(*pNewObj);
571 [ + - ]: 99 : aHint.SetKind(HINT_OBJINSERTED);
572 [ + - ][ + - ]: 99 : pModel->Broadcast(aHint);
573 : : }
574 : 99 : pModel->SetChanged();
575 : : }
576 : 99 : SetRectsDirty();
577 : : }
578 : 99 : return pObj;
579 : : }
580 : :
581 : 0 : SdrObject* SdrObjList::NbcSetObjectOrdNum(sal_uIntPtr nOldObjNum, sal_uIntPtr nNewObjNum)
582 : : {
583 [ # # ][ # # ]: 0 : if (nOldObjNum >= maList.size() || nNewObjNum >= maList.size())
[ # # ]
584 : : {
585 : : OSL_ASSERT(nOldObjNum<maList.size());
586 : : OSL_ASSERT(nNewObjNum<maList.size());
587 : 0 : return NULL;
588 : : }
589 : :
590 : 0 : SdrObject* pObj=maList[nOldObjNum];
591 [ # # ]: 0 : if (nOldObjNum==nNewObjNum) return pObj;
592 : : DBG_ASSERT(pObj!=NULL,"SdrObjList::NbcSetObjectOrdNum: Object not found.");
593 [ # # ]: 0 : if (pObj!=NULL) {
594 : : DBG_ASSERT(pObj->IsInserted(),"SdrObjList::NbcSetObjectOrdNum: ZObjekt does not have status Inserted.");
595 : 0 : RemoveObjectFromContainer(nOldObjNum);
596 : :
597 : 0 : InsertObjectIntoContainer(*pObj,nNewObjNum);
598 : :
599 : : // No need to delete visualisation data since same object
600 : : // gets inserted again. Also a single ActionChanged is enough
601 : 0 : pObj->ActionChanged();
602 : :
603 : 0 : pObj->SetOrdNum(nNewObjNum);
604 : 0 : bObjOrdNumsDirty=sal_True;
605 : : }
606 : 0 : return pObj;
607 : : }
608 : :
609 : 10948 : SdrObject* SdrObjList::SetObjectOrdNum(sal_uIntPtr nOldObjNum, sal_uIntPtr nNewObjNum)
610 : : {
611 [ + - ][ - + ]: 10948 : if (nOldObjNum >= maList.size() || nNewObjNum >= maList.size())
[ - + ]
612 : : {
613 : : OSL_ASSERT(nOldObjNum<maList.size());
614 : : OSL_ASSERT(nNewObjNum<maList.size());
615 : 0 : return NULL;
616 : : }
617 : :
618 : 10948 : SdrObject* pObj=maList[nOldObjNum];
619 [ + + ]: 10948 : if (nOldObjNum==nNewObjNum) return pObj;
620 : : DBG_ASSERT(pObj!=NULL,"SdrObjList::SetObjectOrdNum: Object not found.");
621 [ + - ]: 8152 : if (pObj!=NULL) {
622 : : DBG_ASSERT(pObj->IsInserted(),"SdrObjList::SetObjectOrdNum: ZObjekt does not have status Inserted.");
623 : 8152 : RemoveObjectFromContainer(nOldObjNum);
624 : 8152 : InsertObjectIntoContainer(*pObj,nNewObjNum);
625 : :
626 : : // No need to delete visualisation data since same object
627 : : // gets inserted again. Also a single ActionChanged is enough
628 : 8152 : pObj->ActionChanged();
629 : :
630 : 8152 : pObj->SetOrdNum(nNewObjNum);
631 : 8152 : bObjOrdNumsDirty=sal_True;
632 [ + - ]: 8152 : if (pModel!=NULL)
633 : : {
634 : : // TODO: We need a different broadcast here.
635 [ + - ][ + - ]: 8152 : if (pObj->GetPage()!=NULL) pModel->Broadcast(SdrHint(*pObj));
636 : 8152 : pModel->SetChanged();
637 : : }
638 : : }
639 : 10948 : return pObj;
640 : : }
641 : :
642 : 53095 : const Rectangle& SdrObjList::GetAllObjSnapRect() const
643 : : {
644 [ + + ]: 53095 : if (bRectsDirty) {
645 : 6135 : ((SdrObjList*)this)->RecalcRects();
646 : 6135 : ((SdrObjList*)this)->bRectsDirty=sal_False;
647 : : }
648 : 53095 : return aSnapRect;
649 : : }
650 : :
651 : 54284 : const Rectangle& SdrObjList::GetAllObjBoundRect() const
652 : : {
653 : : // #i106183# for deep group hierarchies like in chart2, the invalidates
654 : : // through the hierarchy are not correct; use a 2nd hint for the needed
655 : : // recalculation. Future versions will have no bool flag at all, but
656 : : // just aOutRect in empty state to represent an invalid state, thus
657 : : // it's a step in the right direction.
658 [ + + ][ + + ]: 54284 : if (bRectsDirty || aOutRect.IsEmpty())
[ + + ]
659 : : {
660 : 52770 : ((SdrObjList*)this)->RecalcRects();
661 : 52770 : ((SdrObjList*)this)->bRectsDirty=sal_False;
662 : : }
663 : 54284 : return aOutRect;
664 : : }
665 : :
666 : 2238 : void SdrObjList::NbcReformatAllTextObjects()
667 : : {
668 : 2238 : sal_uIntPtr nAnz=GetObjCount();
669 : 2238 : sal_uIntPtr nNum=0;
670 : :
671 [ + + ]: 2269 : while (nNum<nAnz)
672 : : {
673 : 31 : SdrObject* pObj = GetObj(nNum);
674 : :
675 : 31 : pObj->NbcReformatText();
676 : 31 : nAnz=GetObjCount(); // ReformatText may delete an object
677 : 31 : nNum++;
678 : : }
679 : :
680 : 2238 : }
681 : :
682 : 2238 : void SdrObjList::ReformatAllTextObjects()
683 : : {
684 : 2238 : NbcReformatAllTextObjects();
685 : 2238 : }
686 : :
687 : : /** steps over all available objects and reformats all
688 : : edge objects that are connected to other objects so that
689 : : they may reposition themselves.
690 : : */
691 : 0 : void SdrObjList::ReformatAllEdgeObjects()
692 : : {
693 : 0 : const sal_uInt32 nCount=GetObjCount();
694 : : sal_uInt32 nObj;
695 : :
696 [ # # ]: 0 : for( nObj = 0; nObj < nCount; nObj++ )
697 : : {
698 : 0 : SdrObject* pObj = GetObj(nObj);
699 [ # # ]: 0 : if( pObj->ISA(SdrEdgeObj) )
700 : 0 : static_cast<SdrEdgeObj*>(pObj)->Reformat();
701 : : }
702 : 0 : }
703 : :
704 : 0 : void SdrObjList::BurnInStyleSheetAttributes()
705 : : {
706 [ # # ]: 0 : for(sal_uInt32 a(0L); a < GetObjCount(); a++)
707 : : {
708 : 0 : GetObj(a)->BurnInStyleSheetAttributes();
709 : : }
710 : 0 : }
711 : :
712 : 3853482 : sal_uIntPtr SdrObjList::GetObjCount() const
713 : : {
714 : 3853482 : return maList.size();
715 : : }
716 : :
717 : :
718 : :
719 : :
720 : 2326518 : SdrObject* SdrObjList::GetObj(sal_uIntPtr nNum) const
721 : : {
722 [ - + ]: 2326518 : if (nNum >= maList.size())
723 : : {
724 : : OSL_ASSERT(nNum<maList.size());
725 : 0 : return NULL;
726 : : }
727 : : else
728 : 2326518 : return maList[nNum];
729 : : }
730 : :
731 : :
732 : :
733 : :
734 : 0 : bool SdrObjList::IsReadOnly() const
735 : : {
736 : 0 : bool bRet = false;
737 [ # # ][ # # ]: 0 : if (pPage!=NULL && pPage!=this) bRet=pPage->IsReadOnly();
738 : 0 : return bRet;
739 : : }
740 : :
741 : 0 : sal_uIntPtr SdrObjList::CountAllObjects() const
742 : : {
743 : 0 : sal_uIntPtr nCnt=GetObjCount();
744 : 0 : sal_uIntPtr nAnz=nCnt;
745 [ # # ]: 0 : for (sal_uInt16 nNum=0; nNum<nAnz; nNum++) {
746 : 0 : SdrObjList* pSubOL=GetObj(nNum)->GetSubList();
747 [ # # ]: 0 : if (pSubOL!=NULL) {
748 : 0 : nCnt+=pSubOL->CountAllObjects();
749 : : }
750 : : }
751 : 0 : return nCnt;
752 : : }
753 : :
754 : 0 : void SdrObjList::ForceSwapInObjects() const
755 : : {
756 : 0 : sal_uIntPtr nObjAnz=GetObjCount();
757 [ # # ]: 0 : for (sal_uIntPtr nObjNum=nObjAnz; nObjNum>0;) {
758 : 0 : SdrObject* pObj=GetObj(--nObjNum);
759 [ # # ][ # # ]: 0 : SdrGrafObj* pGrafObj=PTR_CAST(SdrGrafObj,pObj);
760 [ # # ]: 0 : if (pGrafObj!=NULL) {
761 : 0 : pGrafObj->ForceSwapIn();
762 : : }
763 : 0 : SdrObjList* pOL=pObj->GetSubList();
764 [ # # ]: 0 : if (pOL!=NULL) {
765 : 0 : pOL->ForceSwapInObjects();
766 : : }
767 : : }
768 : 0 : }
769 : :
770 : 0 : void SdrObjList::ForceSwapOutObjects() const
771 : : {
772 : 0 : sal_uIntPtr nObjAnz=GetObjCount();
773 [ # # ]: 0 : for (sal_uIntPtr nObjNum=nObjAnz; nObjNum>0;) {
774 : 0 : SdrObject* pObj=GetObj(--nObjNum);
775 [ # # ][ # # ]: 0 : SdrGrafObj* pGrafObj=PTR_CAST(SdrGrafObj,pObj);
776 [ # # ]: 0 : if (pGrafObj!=NULL) {
777 : 0 : pGrafObj->ForceSwapOut();
778 : : }
779 : 0 : SdrObjList* pOL=pObj->GetSubList();
780 [ # # ]: 0 : if (pOL!=NULL) {
781 : 0 : pOL->ForceSwapOutObjects();
782 : : }
783 : : }
784 : 0 : }
785 : :
786 : 0 : void SdrObjList::FlattenGroups()
787 : : {
788 : 0 : sal_Int32 nObj = GetObjCount();
789 : : sal_Int32 i;
790 [ # # ]: 0 : for( i=nObj-1; i>=0; --i)
791 : 0 : UnGroupObj(i);
792 : 0 : }
793 : :
794 : 0 : void SdrObjList::UnGroupObj( sal_uIntPtr nObjNum )
795 : : {
796 : : // if the given object is no group, this method is a noop
797 : 0 : SdrObject* pUngroupObj = GetObj( nObjNum );
798 [ # # ]: 0 : if( pUngroupObj )
799 : : {
800 : 0 : SdrObjList* pSrcLst = pUngroupObj->GetSubList();
801 [ # # ][ # # ]: 0 : if( pUngroupObj->ISA( SdrObjGroup ) && pSrcLst )
[ # # ]
802 : : {
803 : 0 : SdrObjGroup* pUngroupGroup = static_cast< SdrObjGroup* > (pUngroupObj);
804 : :
805 : : // ungroup recursively (has to be head recursion,
806 : : // otherwise our indices will get trashed when doing it in
807 : : // the loop)
808 : 0 : pSrcLst->FlattenGroups();
809 : :
810 : : // the position at which we insert the members of rUngroupGroup
811 : 0 : sal_Int32 nInsertPos( pUngroupGroup->GetOrdNum() );
812 : :
813 : : SdrObject* pObj;
814 : 0 : sal_Int32 i, nAnz = pSrcLst->GetObjCount();
815 [ # # ]: 0 : for( i=0; i<nAnz; ++i )
816 : : {
817 [ # # ]: 0 : pObj = pSrcLst->RemoveObject(0);
818 : 0 : SdrInsertReason aReason(SDRREASON_VIEWCALL, pUngroupGroup);
819 [ # # ]: 0 : InsertObject(pObj, nInsertPos, &aReason);
820 : 0 : ++nInsertPos;
821 : : }
822 : :
823 : 0 : RemoveObject(nInsertPos);
824 : : }
825 : : }
826 : : #ifdef DBG_UTIL
827 : : else
828 : : OSL_FAIL("SdrObjList::UnGroupObj: object index invalid");
829 : : #endif
830 : 0 : }
831 : :
832 : :
833 : :
834 : :
835 : 202182 : bool SdrObjList::HasObjectNavigationOrder (void) const
836 : : {
837 : 202182 : return mpNavigationOrder.get() != NULL;
838 : : }
839 : :
840 : :
841 : :
842 : :
843 : 0 : void SdrObjList::SetObjectNavigationPosition (
844 : : SdrObject& rObject,
845 : : const sal_uInt32 nNewPosition)
846 : : {
847 : : // When the navigation order container has not yet been created then
848 : : // create one now. It is initialized with the z-order taken from
849 : : // maList.
850 [ # # ]: 0 : if (mpNavigationOrder.get() == NULL)
851 : : {
852 [ # # ][ # # ]: 0 : mpNavigationOrder.reset(new WeakSdrObjectContainerType(maList.size()));
[ # # ]
853 : : ::std::copy(
854 : : maList.begin(),
855 : : maList.end(),
856 [ # # ]: 0 : mpNavigationOrder->begin());
857 : : }
858 : : OSL_ASSERT(mpNavigationOrder.get()!=NULL);
859 : : OSL_ASSERT( mpNavigationOrder->size() == maList.size());
860 : :
861 [ # # ]: 0 : SdrObjectWeakRef aReference (&rObject);
862 : :
863 : : // Look up the object whose navigation position is to be changed.
864 : : WeakSdrObjectContainerType::iterator iObject (::std::find(
865 : 0 : mpNavigationOrder->begin(),
866 : 0 : mpNavigationOrder->end(),
867 [ # # ]: 0 : aReference));
868 [ # # ][ # # ]: 0 : if (iObject == mpNavigationOrder->end())
869 : : {
870 : : // The given object is not a member of the navigation order.
871 : 0 : return;
872 : : }
873 : :
874 : : // Move the object to its new position.
875 [ # # ]: 0 : const sal_uInt32 nOldPosition = ::std::distance(mpNavigationOrder->begin(), iObject);
876 [ # # ]: 0 : if (nOldPosition != nNewPosition)
877 : : {
878 [ # # ]: 0 : mpNavigationOrder->erase(iObject);
879 : 0 : sal_uInt32 nInsertPosition (nNewPosition);
880 : : // Adapt insertion position for the just erased object.
881 [ # # ]: 0 : if (nNewPosition >= nOldPosition)
882 : 0 : nInsertPosition -= 1;
883 [ # # ]: 0 : if (nInsertPosition >= mpNavigationOrder->size())
884 [ # # ]: 0 : mpNavigationOrder->push_back(aReference);
885 : : else
886 [ # # ][ # # ]: 0 : mpNavigationOrder->insert(mpNavigationOrder->begin()+nInsertPosition, aReference);
887 : :
888 : 0 : mbIsNavigationOrderDirty = true;
889 : :
890 : : // The navigation order is written out to file so mark the model as modified.
891 [ # # ]: 0 : if (pModel != NULL)
892 [ # # ]: 0 : pModel->SetChanged();
893 [ # # ][ # # ]: 0 : }
894 : : }
895 : :
896 : :
897 : :
898 : :
899 : 0 : SdrObject* SdrObjList::GetObjectForNavigationPosition (const sal_uInt32 nNavigationPosition) const
900 : : {
901 [ # # ]: 0 : if (HasObjectNavigationOrder())
902 : : {
903 : : // There is a user defined navigation order. Make sure the object
904 : : // index is correct and look up the object in mpNavigationOrder.
905 [ # # ]: 0 : if (nNavigationPosition >= mpNavigationOrder->size())
906 : : {
907 : : OSL_ASSERT(nNavigationPosition < mpNavigationOrder->size());
908 : : }
909 : : else
910 : 0 : return (*mpNavigationOrder)[nNavigationPosition].get();
911 : : }
912 : : else
913 : : {
914 : : // There is no user defined navigation order. Use the z-order
915 : : // instead.
916 [ # # ]: 0 : if (nNavigationPosition >= maList.size())
917 : : {
918 : : OSL_ASSERT(nNavigationPosition < maList.size());
919 : : }
920 : : else
921 : 0 : return maList[nNavigationPosition];
922 : : }
923 : 0 : return NULL;
924 : : }
925 : :
926 : :
927 : :
928 : :
929 : 0 : void SdrObjList::ClearObjectNavigationOrder (void)
930 : : {
931 : 0 : mpNavigationOrder.reset();
932 : 0 : mbIsNavigationOrderDirty = true;
933 : 0 : }
934 : :
935 : :
936 : :
937 : :
938 : 399 : bool SdrObjList::RecalcNavigationPositions (void)
939 : : {
940 [ - + ]: 399 : if (mbIsNavigationOrderDirty)
941 : : {
942 [ # # ]: 0 : if (mpNavigationOrder.get() != NULL)
943 : : {
944 : 0 : mbIsNavigationOrderDirty = false;
945 : :
946 : 0 : WeakSdrObjectContainerType::iterator iObject;
947 [ # # ]: 0 : WeakSdrObjectContainerType::const_iterator iEnd (mpNavigationOrder->end());
948 : 0 : sal_uInt32 nIndex (0);
949 [ # # ][ # # ]: 0 : for (iObject=mpNavigationOrder->begin(); iObject!=iEnd; ++iObject,++nIndex)
950 [ # # ]: 0 : (*iObject)->SetNavigationPosition(nIndex);
951 : : }
952 : : }
953 : :
954 : 399 : return mpNavigationOrder.get() != NULL;
955 : : }
956 : :
957 : :
958 : :
959 : :
960 : 0 : void SdrObjList::SetNavigationOrder (const uno::Reference<container::XIndexAccess>& rxOrder)
961 : : {
962 [ # # ]: 0 : if (rxOrder.is())
963 : : {
964 : 0 : const sal_Int32 nCount = rxOrder->getCount();
965 [ # # ]: 0 : if ((sal_uInt32)nCount != maList.size())
966 : 0 : return;
967 : :
968 [ # # ]: 0 : if (mpNavigationOrder.get() == NULL)
969 [ # # ]: 0 : mpNavigationOrder.reset(new WeakSdrObjectContainerType(nCount));
970 : :
971 [ # # ]: 0 : for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
972 : : {
973 [ # # ][ # # ]: 0 : uno::Reference<uno::XInterface> xShape (rxOrder->getByIndex(nIndex), uno::UNO_QUERY);
[ # # ]
974 [ # # ]: 0 : SdrObject* pObject = SdrObject::getSdrObjectFromXShape(xShape);
975 [ # # ]: 0 : if (pObject == NULL)
976 : : break;
977 [ # # ][ # # ]: 0 : (*mpNavigationOrder)[nIndex] = pObject;
[ # # ][ # # ]
978 : 0 : }
979 : :
980 : 0 : mbIsNavigationOrderDirty = true;
981 : : }
982 : : else
983 : 0 : ClearObjectNavigationOrder();
984 : : }
985 : :
986 : :
987 : :
988 : :
989 : 101120 : void SdrObjList::InsertObjectIntoContainer (
990 : : SdrObject& rObject,
991 : : const sal_uInt32 nInsertPosition)
992 : : {
993 : : OSL_ASSERT(nInsertPosition<=maList.size());
994 : :
995 : : // Update the navigation positions.
996 [ - + ]: 101120 : if (HasObjectNavigationOrder())
997 : : {
998 : : // The new object does not have a user defined position so append it
999 : : // to the list.
1000 : 0 : rObject.SetNavigationPosition(mpNavigationOrder->size());
1001 [ # # ]: 0 : mpNavigationOrder->push_back(&rObject);
1002 : : }
1003 : :
1004 : : // Insert object into object list. Because the insert() method requires
1005 : : // a valid iterator as insertion position, we have to use push_back() to
1006 : : // insert at the end of the list.
1007 [ + + ]: 101120 : if (nInsertPosition >= maList.size())
1008 [ + - ]: 92801 : maList.push_back(&rObject);
1009 : : else
1010 [ + - ][ + - ]: 8319 : maList.insert(maList.begin()+nInsertPosition, &rObject);
1011 : 101120 : bObjOrdNumsDirty=sal_True;
1012 : 101120 : }
1013 : :
1014 : :
1015 : :
1016 : :
1017 : 99 : void SdrObjList::ReplaceObjectInContainer (
1018 : : SdrObject& rNewObject,
1019 : : const sal_uInt32 nObjectPosition)
1020 : : {
1021 [ - + ]: 99 : if (nObjectPosition >= maList.size())
1022 : : {
1023 : : OSL_ASSERT(nObjectPosition<maList.size());
1024 : 99 : return;
1025 : : }
1026 : :
1027 : : // Update the navigation positions.
1028 [ - + ]: 99 : if (HasObjectNavigationOrder())
1029 : : {
1030 : : // A user defined position of the object that is to be replaced is
1031 : : // not transferred to the new object so erase the former and append
1032 : : // the later object from/to the navigation order.
1033 : : OSL_ASSERT(nObjectPosition < maList.size());
1034 [ # # ][ # # ]: 0 : SdrObjectWeakRef aReference (maList[nObjectPosition]);
1035 : : WeakSdrObjectContainerType::iterator iObject (::std::find(
1036 : 0 : mpNavigationOrder->begin(),
1037 : 0 : mpNavigationOrder->end(),
1038 [ # # ]: 0 : aReference));
1039 [ # # ][ # # ]: 0 : if (iObject != mpNavigationOrder->end())
1040 [ # # ]: 0 : mpNavigationOrder->erase(iObject);
1041 : :
1042 [ # # ][ # # ]: 0 : mpNavigationOrder->push_back(&rNewObject);
[ # # ]
1043 : :
1044 [ # # ]: 0 : mbIsNavigationOrderDirty = true;
1045 : : }
1046 : :
1047 : 99 : maList[nObjectPosition] = &rNewObject;
1048 : 99 : bObjOrdNumsDirty=sal_True;
1049 : : }
1050 : :
1051 : :
1052 : :
1053 : :
1054 : 100943 : void SdrObjList::RemoveObjectFromContainer (
1055 : : const sal_uInt32 nObjectPosition)
1056 : : {
1057 [ - + ]: 100943 : if (nObjectPosition >= maList.size())
1058 : : {
1059 : : OSL_ASSERT(nObjectPosition<maList.size());
1060 : 100943 : return;
1061 : : }
1062 : :
1063 : : // Update the navigation positions.
1064 [ - + ]: 100943 : if (HasObjectNavigationOrder())
1065 : : {
1066 [ # # ][ # # ]: 0 : SdrObjectWeakRef aReference (maList[nObjectPosition]);
1067 : : WeakSdrObjectContainerType::iterator iObject (::std::find(
1068 : 0 : mpNavigationOrder->begin(),
1069 : 0 : mpNavigationOrder->end(),
1070 [ # # ]: 0 : aReference));
1071 [ # # ][ # # ]: 0 : if (iObject != mpNavigationOrder->end())
1072 [ # # ]: 0 : mpNavigationOrder->erase(iObject);
1073 [ # # ]: 0 : mbIsNavigationOrderDirty = true;
1074 : : }
1075 : :
1076 [ + - ][ + - ]: 100943 : maList.erase(maList.begin()+nObjectPosition);
1077 : 100943 : bObjOrdNumsDirty=sal_True;
1078 : : }
1079 : :
1080 : :
1081 : :
1082 : :
1083 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1084 : :
1085 : 25 : void SdrPageGridFrameList::Clear()
1086 : : {
1087 : 25 : sal_uInt16 nAnz=GetCount();
1088 [ + + ]: 50 : for (sal_uInt16 i=0; i<nAnz; i++) {
1089 : 25 : delete GetObject(i);
1090 : : }
1091 : 25 : aList.clear();
1092 : 25 : }
1093 : :
1094 : : //////////////////////////////////////////////////////////////////////////////
1095 : : // PageUser section
1096 : :
1097 : 855 : void SdrPage::AddPageUser(sdr::PageUser& rNewUser)
1098 : : {
1099 [ + - ]: 855 : maPageUsers.push_back(&rNewUser);
1100 : 855 : }
1101 : :
1102 : 843 : void SdrPage::RemovePageUser(sdr::PageUser& rOldUser)
1103 : : {
1104 [ + - ]: 843 : const ::sdr::PageUserVector::iterator aFindResult = ::std::find(maPageUsers.begin(), maPageUsers.end(), &rOldUser);
1105 [ + - ][ + - ]: 843 : if(aFindResult != maPageUsers.end())
1106 : : {
1107 [ + - ]: 843 : maPageUsers.erase(aFindResult);
1108 : : }
1109 : 843 : }
1110 : :
1111 : : //////////////////////////////////////////////////////////////////////////////
1112 : : // DrawContact section
1113 : :
1114 : 3000 : sdr::contact::ViewContact* SdrPage::CreateObjectSpecificViewContact()
1115 : : {
1116 [ + - ]: 3000 : return new sdr::contact::ViewContactOfSdrPage(*this);
1117 : : }
1118 : :
1119 : 241215 : sdr::contact::ViewContact& SdrPage::GetViewContact() const
1120 : : {
1121 [ + + ]: 241215 : if(!mpViewContact)
1122 : : {
1123 : : const_cast< SdrPage* >(this)->mpViewContact =
1124 : 3000 : const_cast< SdrPage* >(this)->CreateObjectSpecificViewContact();
1125 : : }
1126 : :
1127 : 241215 : return *mpViewContact;
1128 : : }
1129 : :
1130 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1131 : :
1132 : 3078 : void SdrPageProperties::ImpRemoveStyleSheet()
1133 : : {
1134 [ + + ]: 3078 : if(mpStyleSheet)
1135 : : {
1136 : 159 : EndListening(*mpStyleSheet);
1137 : 159 : mpProperties->SetParent(0);
1138 : 159 : mpStyleSheet = 0;
1139 : : }
1140 : 3078 : }
1141 : :
1142 : 252 : void SdrPageProperties::ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet)
1143 : : {
1144 [ + + ]: 252 : if(mpStyleSheet != &rNewStyleSheet)
1145 : : {
1146 : 162 : ImpRemoveStyleSheet();
1147 : 162 : mpStyleSheet = &rNewStyleSheet;
1148 : 162 : StartListening(rNewStyleSheet);
1149 : 162 : mpProperties->SetParent(&rNewStyleSheet.GetItemSet());
1150 : : }
1151 : 252 : }
1152 : :
1153 : 633 : void ImpPageChange(SdrPage& rSdrPage)
1154 : : {
1155 : 633 : rSdrPage.ActionChanged();
1156 : :
1157 [ + - ]: 633 : if(rSdrPage.GetModel())
1158 : : {
1159 [ + - ][ + - ]: 633 : rSdrPage.GetModel()->SetChanged(true);
1160 [ + - ]: 633 : SdrHint aHint(HINT_PAGEORDERCHG);
1161 [ + - ]: 633 : aHint.SetPage(&rSdrPage);
1162 [ + - ][ + - ]: 633 : rSdrPage.GetModel()->Broadcast(aHint);
[ + - ]
1163 : : }
1164 : 633 : }
1165 : :
1166 : 3050 : SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
1167 : : : SfxListener(),
1168 : : mpSdrPage(&rSdrPage),
1169 : : mpStyleSheet(0),
1170 [ + - ][ + - ]: 3050 : mpProperties(new SfxItemSet(mpSdrPage->GetModel()->GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST))
[ + - ]
1171 : : {
1172 [ + + ]: 3050 : if(!rSdrPage.IsMasterPage())
1173 : : {
1174 [ + - ][ + - ]: 2569 : mpProperties->Put(XFillStyleItem(XFILL_NONE));
[ + - ]
1175 : : }
1176 : 3050 : }
1177 : :
1178 : 2916 : SdrPageProperties::~SdrPageProperties()
1179 : : {
1180 [ + - ]: 2916 : ImpRemoveStyleSheet();
1181 [ + - ][ + - ]: 2916 : delete mpProperties;
1182 [ - + ]: 5832 : }
1183 : :
1184 : 61 : void SdrPageProperties::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
1185 : : {
1186 [ - + ]: 61 : const SfxSimpleHint* pSimpleHint = dynamic_cast< const SfxSimpleHint* >(&rHint);
1187 : :
1188 [ + - ]: 61 : if(pSimpleHint)
1189 : : {
1190 [ + - - ]: 61 : switch(pSimpleHint->GetId())
1191 : : {
1192 : : case SFX_HINT_DATACHANGED :
1193 : : {
1194 : : // notify change, broadcast
1195 : 61 : ImpPageChange(*mpSdrPage);
1196 : 61 : break;
1197 : : }
1198 : : case SFX_HINT_DYING :
1199 : : {
1200 : : // Style needs to be forgotten
1201 : 0 : ImpRemoveStyleSheet();
1202 : 61 : break;
1203 : : }
1204 : : }
1205 : : }
1206 : 61 : }
1207 : :
1208 : 9118 : const SfxItemSet& SdrPageProperties::GetItemSet() const
1209 : : {
1210 : 9118 : return *mpProperties;
1211 : : }
1212 : :
1213 : 18 : void SdrPageProperties::PutItemSet(const SfxItemSet& rSet)
1214 : : {
1215 : : OSL_ENSURE(!mpSdrPage->IsMasterPage(), "Item set at MasterPage Attributes (!)");
1216 : 18 : mpProperties->Put(rSet);
1217 : 18 : ImpPageChange(*mpSdrPage);
1218 : 18 : }
1219 : :
1220 : 32 : void SdrPageProperties::PutItem(const SfxPoolItem& rItem)
1221 : : {
1222 : : OSL_ENSURE(!mpSdrPage->IsMasterPage(), "Item set at MasterPage Attributes (!)");
1223 : 32 : mpProperties->Put(rItem);
1224 : 32 : ImpPageChange(*mpSdrPage);
1225 : 32 : }
1226 : :
1227 : 270 : void SdrPageProperties::ClearItem(const sal_uInt16 nWhich)
1228 : : {
1229 : 270 : mpProperties->ClearItem(nWhich);
1230 : 270 : ImpPageChange(*mpSdrPage);
1231 : 270 : }
1232 : :
1233 : 252 : void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet)
1234 : : {
1235 [ + - ]: 252 : if(pStyleSheet)
1236 : : {
1237 : 252 : ImpAddStyleSheet(*pStyleSheet);
1238 : : }
1239 : : else
1240 : : {
1241 : 0 : ImpRemoveStyleSheet();
1242 : : }
1243 : :
1244 : 252 : ImpPageChange(*mpSdrPage);
1245 : 252 : }
1246 : :
1247 : 1758 : SfxStyleSheet* SdrPageProperties::GetStyleSheet() const
1248 : : {
1249 : 1758 : return mpStyleSheet;
1250 : : }
1251 : :
1252 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1253 : :
1254 [ + - ][ # # ]: 343561 : TYPEINIT1(SdrPage,SdrObjList);
1255 : : DBG_NAME(SdrPage)
1256 : 3050 : SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
1257 : : : SdrObjList(&rNewModel, this),
1258 : : mpViewContact(0L),
1259 : : nWdt(10L),
1260 : : nHgt(10L),
1261 : : nBordLft(0L),
1262 : : nBordUpp(0L),
1263 : : nBordRgt(0L),
1264 : : nBordLwr(0L),
1265 [ + - ]: 3050 : pLayerAdmin(new SdrLayerAdmin(&rNewModel.GetLayerAdmin())),
1266 : : mpSdrPageProperties(0),
1267 : : mpMasterPageDescriptor(0L),
1268 : : nPageNum(0L),
1269 : : mbMaster(bMasterPage),
1270 : : mbInserted(false),
1271 : : mbObjectsNotPersistent(false),
1272 : : mbSwappingLocked(false),
1273 [ + - ][ + - ]: 6100 : mbPageBorderOnlyLeftRight(false)
1274 : : {
1275 : : DBG_CTOR(SdrPage,NULL);
1276 : 3050 : aPrefVisiLayers.SetAll();
1277 [ + + ]: 3050 : eListKind = (bMasterPage) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
1278 : :
1279 [ + - ][ + - ]: 3050 : mpSdrPageProperties = new SdrPageProperties(*this);
1280 : 3050 : }
1281 : :
1282 : 0 : SdrPage::SdrPage(const SdrPage& rSrcPage)
1283 : : : SdrObjList(rSrcPage.pModel, this),
1284 : : tools::WeakBase< SdrPage >(),
1285 : : mpViewContact(0L),
1286 : : nWdt(rSrcPage.nWdt),
1287 : : nHgt(rSrcPage.nHgt),
1288 : : nBordLft(rSrcPage.nBordLft),
1289 : : nBordUpp(rSrcPage.nBordUpp),
1290 : : nBordRgt(rSrcPage.nBordRgt),
1291 : : nBordLwr(rSrcPage.nBordLwr),
1292 [ # # ]: 0 : pLayerAdmin(new SdrLayerAdmin(rSrcPage.pModel->GetLayerAdmin())),
1293 : : mpSdrPageProperties(0),
1294 : : mpMasterPageDescriptor(0L),
1295 : : nPageNum(rSrcPage.nPageNum),
1296 : : mbMaster(rSrcPage.mbMaster),
1297 : : mbInserted(false),
1298 : : mbObjectsNotPersistent(rSrcPage.mbObjectsNotPersistent),
1299 : : mbSwappingLocked(rSrcPage.mbSwappingLocked),
1300 [ # # ][ # # ]: 0 : mbPageBorderOnlyLeftRight(rSrcPage.mbPageBorderOnlyLeftRight)
1301 : : {
1302 : : DBG_CTOR(SdrPage,NULL);
1303 : 0 : aPrefVisiLayers.SetAll();
1304 [ # # ]: 0 : eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
1305 : :
1306 : : // copy things from source
1307 : : // Warning: this leads to slicing (see issue 93186) and has to be
1308 : : // removed as soon as possible.
1309 [ # # ]: 0 : *this = rSrcPage;
1310 : : OSL_ENSURE(mpSdrPageProperties,
1311 : : "SdrPage::SdrPage: operator= did not create needed SdrPageProperties (!)");
1312 : :
1313 : : // be careful and correct eListKind, a member of SdrObjList which
1314 : : // will be changed by the SdrOIbjList::operator= before...
1315 [ # # ]: 0 : eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
1316 : :
1317 : : // The previous assignment to *this may have resulted in a call to
1318 : : // createUnoPage at a partially initialized (sliced) SdrPage object.
1319 : : // Due to the vtable being not yet fully set-up at this stage,
1320 : : // createUnoPage() may have been called at the wrong class.
1321 : : // To force a call to the right createUnoPage() at a later time when the
1322 : : // new object is full constructed mxUnoPage is disposed now.
1323 [ # # ]: 0 : uno::Reference<lang::XComponent> xComponent (mxUnoPage, uno::UNO_QUERY);
1324 [ # # ]: 0 : if (xComponent.is())
1325 : : {
1326 [ # # ]: 0 : mxUnoPage = NULL;
1327 [ # # ][ # # ]: 0 : xComponent->dispose();
1328 : 0 : }
1329 : 0 : }
1330 : :
1331 [ + - ]: 2916 : SdrPage::~SdrPage()
1332 : : {
1333 [ + + ]: 2916 : if( mxUnoPage.is() ) try
1334 : : {
1335 [ + - ]: 1855 : uno::Reference< lang::XComponent > xPageComponent( mxUnoPage, uno::UNO_QUERY_THROW );
1336 : 1855 : mxUnoPage.clear();
1337 [ + - ][ # # ]: 1855 : xPageComponent->dispose();
[ + - ]
1338 : : }
1339 [ # # ]: 0 : catch( const uno::Exception& )
1340 : : {
1341 : : DBG_UNHANDLED_EXCEPTION();
1342 : : }
1343 : :
1344 : : // tell all the registered PageUsers that the page is in destruction
1345 : : // This causes some (all?) PageUsers to remove themselves from the list
1346 : : // of page users. Therefore we have to use a copy of the list for the
1347 : : // iteration.
1348 [ + - ]: 2916 : ::sdr::PageUserVector aListCopy (maPageUsers.begin(), maPageUsers.end());
1349 [ + - ][ - + ]: 2916 : for(::sdr::PageUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
1350 : : {
1351 : 0 : sdr::PageUser* pPageUser = *aIterator;
1352 : : DBG_ASSERT(pPageUser, "SdrPage::~SdrPage: corrupt PageUser list (!)");
1353 [ # # ]: 0 : pPageUser->PageInDestruction(*this);
1354 : : }
1355 : :
1356 : : // Clear the vector. This means that user do not need to call RemovePageUser()
1357 : : // when they get called from PageInDestruction().
1358 : 2916 : maPageUsers.clear();
1359 : :
1360 [ + - ][ + - ]: 2916 : delete pLayerAdmin;
1361 : :
1362 [ + - ]: 2916 : TRG_ClearMasterPage();
1363 : :
1364 [ + + ]: 2916 : if(mpViewContact)
1365 : : {
1366 [ + - ][ + - ]: 2866 : delete mpViewContact;
1367 : 2866 : mpViewContact = 0L;
1368 : : }
1369 : :
1370 : : {
1371 [ + - ][ + - ]: 2916 : delete mpSdrPageProperties;
1372 : 2916 : mpSdrPageProperties = 0;
1373 : : }
1374 : :
1375 : 2916 : DBG_DTOR(SdrPage,NULL);
1376 [ - + ]: 2972 : }
1377 : :
1378 : 0 : SdrPage& SdrPage::operator=(const SdrPage& rSrcPage)
1379 : : {
1380 [ # # ]: 0 : if( this == &rSrcPage )
1381 : 0 : return *this;
1382 [ # # ]: 0 : if(mpViewContact)
1383 : : {
1384 [ # # ]: 0 : delete mpViewContact;
1385 : 0 : mpViewContact = 0L;
1386 : : }
1387 : :
1388 : : // Joe also sets some parameters for the class this one
1389 : : // is derived from. SdrObjList does the same bad handling of
1390 : : // copy constructor and operator=, so i better let it stand here.
1391 : 0 : pPage = this;
1392 : :
1393 : : // copy all the local parameters to make this instance
1394 : : // a valid copy of source page before copying and inserting
1395 : : // the contained objects
1396 : 0 : mbMaster = rSrcPage.mbMaster;
1397 : 0 : mbSwappingLocked = rSrcPage.mbSwappingLocked;
1398 : 0 : mbPageBorderOnlyLeftRight = rSrcPage.mbPageBorderOnlyLeftRight;
1399 : 0 : aPrefVisiLayers = rSrcPage.aPrefVisiLayers;
1400 : 0 : nWdt = rSrcPage.nWdt;
1401 : 0 : nHgt = rSrcPage.nHgt;
1402 : 0 : nBordLft = rSrcPage.nBordLft;
1403 : 0 : nBordUpp = rSrcPage.nBordUpp;
1404 : 0 : nBordRgt = rSrcPage.nBordRgt;
1405 : 0 : nBordLwr = rSrcPage.nBordLwr;
1406 : 0 : nPageNum = rSrcPage.nPageNum;
1407 : :
1408 [ # # ]: 0 : if(rSrcPage.TRG_HasMasterPage())
1409 : : {
1410 : 0 : TRG_SetMasterPage(rSrcPage.TRG_GetMasterPage());
1411 : 0 : TRG_SetMasterPageVisibleLayers(rSrcPage.TRG_GetMasterPageVisibleLayers());
1412 : : }
1413 : : else
1414 : : {
1415 : 0 : TRG_ClearMasterPage();
1416 : : }
1417 : :
1418 : 0 : mbObjectsNotPersistent = rSrcPage.mbObjectsNotPersistent;
1419 : :
1420 : : {
1421 : : // #i111122# delete SdrPageProperties when model is different
1422 [ # # ][ # # ]: 0 : if(mpSdrPageProperties && GetModel() != rSrcPage.GetModel())
[ # # ]
1423 : : {
1424 [ # # ]: 0 : delete mpSdrPageProperties;
1425 : 0 : mpSdrPageProperties = 0;
1426 : : }
1427 : :
1428 [ # # ]: 0 : if(!mpSdrPageProperties)
1429 : : {
1430 [ # # ]: 0 : mpSdrPageProperties = new SdrPageProperties(*this);
1431 : : }
1432 : : else
1433 : : {
1434 : 0 : mpSdrPageProperties->ClearItem(0);
1435 : : }
1436 : :
1437 [ # # ]: 0 : if(!IsMasterPage())
1438 : : {
1439 : 0 : mpSdrPageProperties->PutItemSet(rSrcPage.getSdrPageProperties().GetItemSet());
1440 : : }
1441 : :
1442 : 0 : mpSdrPageProperties->SetStyleSheet(rSrcPage.getSdrPageProperties().GetStyleSheet());
1443 : : }
1444 : :
1445 : : // Now copy the contained objects (by cloning them)
1446 : 0 : SdrObjList::operator=(rSrcPage);
1447 : 0 : return *this;
1448 : : }
1449 : :
1450 : 0 : SdrPage* SdrPage::Clone() const
1451 : : {
1452 : 0 : return Clone(NULL);
1453 : : }
1454 : :
1455 : 0 : SdrPage* SdrPage::Clone(SdrModel* pNewModel) const
1456 : : {
1457 [ # # ]: 0 : if (pNewModel==NULL) pNewModel=pModel;
1458 [ # # ]: 0 : SdrPage* pPage2=new SdrPage(*pNewModel);
1459 : 0 : *pPage2=*this;
1460 : 0 : return pPage2;
1461 : : }
1462 : :
1463 : 69082 : void SdrPage::SetSize(const Size& aSiz)
1464 : : {
1465 : 69082 : bool bChanged(false);
1466 : :
1467 [ + + ]: 69082 : if(aSiz.Width() != nWdt)
1468 : : {
1469 : 67620 : nWdt = aSiz.Width();
1470 : 67620 : bChanged = true;
1471 : : }
1472 : :
1473 [ + + ]: 69082 : if(aSiz.Height() != nHgt)
1474 : : {
1475 : 4773 : nHgt = aSiz.Height();
1476 : 4773 : bChanged = true;
1477 : : }
1478 : :
1479 [ + + ]: 69082 : if(bChanged)
1480 : : {
1481 : 68074 : SetChanged();
1482 : : }
1483 : 69082 : }
1484 : :
1485 : 74148 : Size SdrPage::GetSize() const
1486 : : {
1487 : 74148 : return Size(nWdt,nHgt);
1488 : : }
1489 : :
1490 : 23763 : sal_Int32 SdrPage::GetWdt() const
1491 : : {
1492 : 23763 : return nWdt;
1493 : : }
1494 : :
1495 : 0 : void SdrPage::SetOrientation(Orientation eOri)
1496 : : {
1497 : : // square: handle like portrait format
1498 [ # # ]: 0 : Size aSiz(GetSize());
1499 [ # # ]: 0 : if (aSiz.Width()!=aSiz.Height()) {
1500 [ # # ]: 0 : if ((eOri==ORIENTATION_PORTRAIT) == (aSiz.Width()>aSiz.Height())) {
1501 [ # # ]: 0 : SetSize(Size(aSiz.Height(),aSiz.Width()));
1502 : : }
1503 : : }
1504 : 0 : }
1505 : :
1506 : 0 : Orientation SdrPage::GetOrientation() const
1507 : : {
1508 : : // square: handle like portrait format
1509 : 0 : Orientation eRet=ORIENTATION_PORTRAIT;
1510 [ # # ]: 0 : Size aSiz(GetSize());
1511 [ # # ]: 0 : if (aSiz.Width()>aSiz.Height()) eRet=ORIENTATION_LANDSCAPE;
1512 : 0 : return eRet;
1513 : : }
1514 : :
1515 : 23763 : sal_Int32 SdrPage::GetHgt() const
1516 : : {
1517 : 23763 : return nHgt;
1518 : : }
1519 : :
1520 : 232 : void SdrPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1521 : : {
1522 : 232 : bool bChanged(false);
1523 : :
1524 [ + - ]: 232 : if(nBordLft != nLft)
1525 : : {
1526 : 232 : nBordLft = nLft;
1527 : 232 : bChanged = true;
1528 : : }
1529 : :
1530 [ + - ]: 232 : if(nBordUpp != nUpp)
1531 : : {
1532 : 232 : nBordUpp = nUpp;
1533 : 232 : bChanged = true;
1534 : : }
1535 : :
1536 [ + - ]: 232 : if(nBordRgt != nRgt)
1537 : : {
1538 : 232 : nBordRgt = nRgt;
1539 : 232 : bChanged = true;
1540 : : }
1541 : :
1542 [ + - ]: 232 : if(nBordLwr != nLwr)
1543 : : {
1544 : 232 : nBordLwr = nLwr;
1545 : 232 : bChanged = true;
1546 : : }
1547 : :
1548 [ + - ]: 232 : if(bChanged)
1549 : : {
1550 : 232 : SetChanged();
1551 : : }
1552 : 232 : }
1553 : :
1554 : 40 : void SdrPage::SetLftBorder(sal_Int32 nBorder)
1555 : : {
1556 [ + - ]: 40 : if(nBordLft != nBorder)
1557 : : {
1558 : 40 : nBordLft = nBorder;
1559 : 40 : SetChanged();
1560 : : }
1561 : 40 : }
1562 : :
1563 : 40 : void SdrPage::SetUppBorder(sal_Int32 nBorder)
1564 : : {
1565 [ + - ]: 40 : if(nBordUpp != nBorder)
1566 : : {
1567 : 40 : nBordUpp = nBorder;
1568 : 40 : SetChanged();
1569 : : }
1570 : 40 : }
1571 : :
1572 : 40 : void SdrPage::SetRgtBorder(sal_Int32 nBorder)
1573 : : {
1574 [ + - ]: 40 : if(nBordRgt != nBorder)
1575 : : {
1576 : 40 : nBordRgt=nBorder;
1577 : 40 : SetChanged();
1578 : : }
1579 : 40 : }
1580 : :
1581 : 40 : void SdrPage::SetLwrBorder(sal_Int32 nBorder)
1582 : : {
1583 [ + - ]: 40 : if(nBordLwr != nBorder)
1584 : : {
1585 : 40 : nBordLwr=nBorder;
1586 : 40 : SetChanged();
1587 : : }
1588 : 40 : }
1589 : :
1590 : 15613 : sal_Int32 SdrPage::GetLftBorder() const
1591 : : {
1592 : 15613 : return nBordLft;
1593 : : }
1594 : :
1595 : 14506 : sal_Int32 SdrPage::GetUppBorder() const
1596 : : {
1597 : 14506 : return nBordUpp;
1598 : : }
1599 : :
1600 : 8370 : sal_Int32 SdrPage::GetRgtBorder() const
1601 : : {
1602 : 8370 : return nBordRgt;
1603 : : }
1604 : :
1605 : 8370 : sal_Int32 SdrPage::GetLwrBorder() const
1606 : : {
1607 : 8370 : return nBordLwr;
1608 : : }
1609 : :
1610 : 3053 : void SdrPage::SetModel(SdrModel* pNewModel)
1611 : : {
1612 : 3053 : SdrModel* pOldModel=pModel;
1613 : 3053 : SdrObjList::SetModel(pNewModel);
1614 [ - + ]: 3053 : if (pNewModel!=pOldModel)
1615 : : {
1616 [ # # ]: 0 : if (pNewModel!=NULL) {
1617 : 0 : pLayerAdmin->SetParent(&pNewModel->GetLayerAdmin());
1618 : : } else {
1619 : 0 : pLayerAdmin->SetParent(NULL);
1620 : : }
1621 : 0 : pLayerAdmin->SetModel(pNewModel);
1622 : :
1623 : : // create new SdrPageProperties with new model (due to SfxItemSet there)
1624 : : // and copy ItemSet and StyleSheet
1625 [ # # ]: 0 : SdrPageProperties *pNew = new SdrPageProperties(*this);
1626 : :
1627 [ # # ]: 0 : if(!IsMasterPage())
1628 : : {
1629 : 0 : pNew->PutItemSet(getSdrPageProperties().GetItemSet());
1630 : : }
1631 : :
1632 : 0 : pNew->SetStyleSheet(getSdrPageProperties().GetStyleSheet());
1633 : :
1634 [ # # ]: 0 : delete mpSdrPageProperties;
1635 : 0 : mpSdrPageProperties = pNew;
1636 : : }
1637 : :
1638 : : // update listeners at possible API wrapper object
1639 [ - + ]: 3053 : if( pOldModel != pNewModel )
1640 : : {
1641 [ # # ]: 0 : if( mxUnoPage.is() )
1642 : : {
1643 : 0 : SvxDrawPage* pPage2 = SvxDrawPage::getImplementation( mxUnoPage );
1644 [ # # ]: 0 : if( pPage2 )
1645 : 0 : pPage2->ChangeModel( pNewModel );
1646 : : }
1647 : : }
1648 : 3053 : }
1649 : :
1650 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1651 : :
1652 : : // #i68775# React on PageNum changes (from Model in most cases)
1653 : 3271 : void SdrPage::SetPageNum(sal_uInt16 nNew)
1654 : : {
1655 [ + + ]: 3271 : if(nNew != nPageNum)
1656 : : {
1657 : : // change
1658 : 1023 : nPageNum = nNew;
1659 : :
1660 : : // notify visualisations, also notifies e.g. buffered MasterPages
1661 : 1023 : ActionChanged();
1662 : : }
1663 : 3271 : }
1664 : :
1665 : 8926 : sal_uInt16 SdrPage::GetPageNum() const
1666 : : {
1667 [ + + ]: 8926 : if (!mbInserted)
1668 : 91 : return 0;
1669 : :
1670 [ + + ]: 8835 : if (mbMaster) {
1671 [ + - ][ + + ]: 721 : if (pModel && pModel->IsMPgNumsDirty())
[ + + ]
1672 : 8 : ((SdrModel*)pModel)->RecalcPageNums(sal_True);
1673 : : } else {
1674 [ + - ][ + + ]: 8114 : if (pModel && pModel->IsPagNumsDirty())
[ + + ]
1675 : 43 : ((SdrModel*)pModel)->RecalcPageNums(sal_False);
1676 : : }
1677 : 8926 : return nPageNum;
1678 : : }
1679 : :
1680 : 69198 : void SdrPage::SetChanged()
1681 : : {
1682 : : // For test purposes, use the new ViewContact for change
1683 : : // notification now.
1684 : 69198 : ActionChanged();
1685 : :
1686 [ + - ]: 69198 : if( pModel )
1687 : : {
1688 : 69198 : pModel->SetChanged();
1689 : : }
1690 : 69198 : }
1691 : :
1692 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1693 : : // MasterPage interface
1694 : :
1695 : 651 : void SdrPage::TRG_SetMasterPage(SdrPage& rNew)
1696 : : {
1697 [ + + ][ + - ]: 651 : if(mpMasterPageDescriptor && &(mpMasterPageDescriptor->GetUsedPage()) == &rNew)
[ + + ]
1698 : 651 : return;
1699 : :
1700 [ - + ]: 630 : if(mpMasterPageDescriptor)
1701 : 0 : TRG_ClearMasterPage();
1702 : :
1703 [ + - ]: 630 : mpMasterPageDescriptor = new ::sdr::MasterPageDescriptor(*this, rNew);
1704 : 630 : GetViewContact().ActionChanged();
1705 : : }
1706 : :
1707 : 3002 : void SdrPage::TRG_ClearMasterPage()
1708 : : {
1709 [ + + ]: 3002 : if(mpMasterPageDescriptor)
1710 : : {
1711 : 621 : SetChanged();
1712 : :
1713 : : // the flushViewObjectContacts() will do needed invalidates by deleting the involved VOCs
1714 : 621 : mpMasterPageDescriptor->GetUsedPage().GetViewContact().flushViewObjectContacts(true);
1715 : :
1716 [ + - ]: 621 : delete mpMasterPageDescriptor;
1717 : 621 : mpMasterPageDescriptor = 0L;
1718 : : }
1719 : 3002 : }
1720 : :
1721 : 7082 : SdrPage& SdrPage::TRG_GetMasterPage() const
1722 : : {
1723 : : DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPage(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1724 : 7082 : return mpMasterPageDescriptor->GetUsedPage();
1725 : : }
1726 : :
1727 : 915 : const SetOfByte& SdrPage::TRG_GetMasterPageVisibleLayers() const
1728 : : {
1729 : : DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1730 : 915 : return mpMasterPageDescriptor->GetVisibleLayers();
1731 : : }
1732 : :
1733 : 97 : void SdrPage::TRG_SetMasterPageVisibleLayers(const SetOfByte& rNew)
1734 : : {
1735 : : DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_SetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1736 : 97 : mpMasterPageDescriptor->SetVisibleLayers(rNew);
1737 : 97 : }
1738 : :
1739 : 5635 : sdr::contact::ViewContact& SdrPage::TRG_GetMasterPageDescriptorViewContact() const
1740 : : {
1741 : : DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPageDescriptorViewContact(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1742 : 5635 : return mpMasterPageDescriptor->GetViewContact();
1743 : : }
1744 : :
1745 : : // used from SdrModel::RemoveMasterPage
1746 : 12 : void SdrPage::TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage)
1747 : : {
1748 [ + - ]: 12 : if(TRG_HasMasterPage())
1749 : : {
1750 [ - + ]: 12 : if(&TRG_GetMasterPage() == &rRemovedPage)
1751 : : {
1752 : 0 : TRG_ClearMasterPage();
1753 : : }
1754 : : }
1755 : 12 : }
1756 : :
1757 : 0 : const SdrPageGridFrameList* SdrPage::GetGridFrameList(const SdrPageView* /*pPV*/, const Rectangle* /*pRect*/) const
1758 : : {
1759 : 0 : return NULL;
1760 : : }
1761 : :
1762 : 0 : XubString SdrPage::GetLayoutName() const
1763 : : {
1764 : 0 : return String();
1765 : : }
1766 : :
1767 : 5972 : void SdrPage::SetInserted( bool bIns )
1768 : : {
1769 [ + - ]: 5972 : if( (bool) mbInserted != bIns )
1770 : : {
1771 : 5972 : mbInserted = bIns;
1772 : :
1773 [ + - ]: 5972 : SdrObjListIter aIter( *this, IM_FLAT );
1774 [ + + ]: 8041 : while ( aIter.IsMore() )
1775 : : {
1776 [ + - ]: 2069 : SdrObject* pObj = aIter.Next();
1777 [ + - ][ + - ]: 2069 : if ( pObj->ISA(SdrOle2Obj) )
[ + + ]
1778 : : {
1779 [ - + ]: 26 : if( mbInserted )
1780 [ # # ]: 0 : ( (SdrOle2Obj*) pObj)->Connect();
1781 : : else
1782 [ + - ]: 26 : ( (SdrOle2Obj*) pObj)->Disconnect();
1783 : : }
1784 : 5972 : }
1785 : : }
1786 : 5972 : }
1787 : :
1788 : :
1789 : 147773 : uno::Reference< uno::XInterface > SdrPage::getUnoPage()
1790 : : {
1791 : : // try weak reference first
1792 [ + + ]: 147773 : if( !mxUnoPage.is() )
1793 : : {
1794 : : // create one
1795 [ + - ]: 1955 : mxUnoPage = createUnoPage();
1796 : : }
1797 : :
1798 : 147773 : return mxUnoPage;
1799 : : }
1800 : :
1801 : 56 : uno::Reference< uno::XInterface > SdrPage::createUnoPage()
1802 : : {
1803 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt =
1804 [ + - ][ + - ]: 56 : static_cast<cppu::OWeakObject*>( new SvxFmDrawPage( this ) );
1805 : 56 : return xInt;
1806 : : }
1807 : :
1808 : 22889 : SfxStyleSheet* SdrPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
1809 : : {
1810 : 22889 : return pObj->GetStyleSheet();
1811 : : }
1812 : :
1813 : : /** returns an averaged background color of this page */
1814 : : // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
1815 : 2993 : Color SdrPage::GetPageBackgroundColor( SdrPageView* pView, bool bScreenDisplay ) const
1816 : : {
1817 : 2993 : Color aColor;
1818 : :
1819 [ + + ][ + - ]: 2993 : if(bScreenDisplay && (!pView || pView->GetApplicationDocumentColor() == COL_AUTO))
[ + - ][ + + ]
[ + + ][ + -
# # # # ]
[ + - ]
1820 : : {
1821 [ + - ]: 2993 : svtools::ColorConfig aColorConfig;
1822 [ + - ][ + - ]: 2993 : aColor = aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor;
1823 : : }
1824 : : else
1825 : : {
1826 : 0 : aColor = pView->GetApplicationDocumentColor();
1827 : : }
1828 : :
1829 : 2993 : const SfxItemSet* pBackgroundFill = &getSdrPageProperties().GetItemSet();
1830 : :
1831 [ + + ][ + + ]: 2993 : if(!IsMasterPage() && TRG_HasMasterPage())
[ + + ]
1832 : : {
1833 [ + - ]: 2881 : if(XFILL_NONE == ((const XFillStyleItem&)pBackgroundFill->Get(XATTR_FILLSTYLE)).GetValue())
1834 : : {
1835 : 2881 : pBackgroundFill = &TRG_GetMasterPage().getSdrPageProperties().GetItemSet();
1836 : : }
1837 : : }
1838 : :
1839 : 2993 : GetDraftFillColor(*pBackgroundFill, aColor);
1840 : :
1841 : 2993 : return aColor;
1842 : : }
1843 : :
1844 : : /** *deprecated, use GetBackgroundColor with SdrPageView */
1845 : 119 : Color SdrPage::GetPageBackgroundColor() const
1846 : : // #i75566# GetBackgroundColor -> GetPageBackgroundColor
1847 : : {
1848 : 119 : return GetPageBackgroundColor( NULL, true );
1849 : : }
1850 : :
1851 : : /** this method returns true if the object from the ViewObjectContact should
1852 : : be visible on this page while rendering.
1853 : : bEdit selects if visibility test is for an editing view or a final render,
1854 : : like printing.
1855 : : */
1856 : 9756 : bool SdrPage::checkVisibility(
1857 : : const sdr::contact::ViewObjectContact& /*rOriginal*/,
1858 : : const sdr::contact::DisplayInfo& /*rDisplayInfo*/,
1859 : : bool /*bEdit*/)
1860 : : {
1861 : : // this will be handled in the application if needed
1862 : 9756 : return true;
1863 : : }
1864 : :
1865 : : // DrawContact support: Methods for handling Page changes
1866 : 71319 : void SdrPage::ActionChanged() const
1867 : : {
1868 : : // Do necessary ViewContact actions
1869 : 71319 : GetViewContact().ActionChanged();
1870 : :
1871 : : // #i48535# also handle MasterPage change
1872 [ + + ]: 71319 : if(TRG_HasMasterPage())
1873 : : {
1874 : 1159 : TRG_GetMasterPageDescriptorViewContact().ActionChanged();
1875 : : }
1876 : 71319 : }
1877 : :
1878 : : //////////////////////////////////////////////////////////////////////////////
1879 : : // sdr::Comment interface
1880 : :
1881 : 0 : const SdrPageProperties* SdrPage::getCorrectSdrPageProperties() const
1882 : : {
1883 [ # # ]: 0 : if(mpMasterPageDescriptor)
1884 : : {
1885 : 0 : return mpMasterPageDescriptor->getCorrectSdrPageProperties();
1886 : : }
1887 : : else
1888 : : {
1889 : 0 : return &getSdrPageProperties();
1890 : : }
1891 : : }
1892 : :
1893 : : //////////////////////////////////////////////////////////////////////////////
1894 : : // use new redirector instead of pPaintProc
1895 : :
1896 : 0 : StandardCheckVisisbilityRedirector::StandardCheckVisisbilityRedirector()
1897 : 0 : : ViewObjectContactRedirector()
1898 : : {
1899 : 0 : }
1900 : :
1901 : 0 : StandardCheckVisisbilityRedirector::~StandardCheckVisisbilityRedirector()
1902 : : {
1903 [ # # ]: 0 : }
1904 : :
1905 : 0 : drawinglayer::primitive2d::Primitive2DSequence StandardCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence(
1906 : : const sdr::contact::ViewObjectContact& rOriginal,
1907 : : const sdr::contact::DisplayInfo& rDisplayInfo)
1908 : : {
1909 : 0 : SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
1910 : :
1911 [ # # ]: 0 : if(pObject)
1912 : : {
1913 [ # # ]: 0 : if(pObject->GetPage())
1914 : : {
1915 [ # # ]: 0 : if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false))
1916 : : {
1917 : 0 : return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1918 : : }
1919 : : }
1920 : :
1921 : 0 : return drawinglayer::primitive2d::Primitive2DSequence();
1922 : : }
1923 : : else
1924 : : {
1925 : : // not an object, maybe a page
1926 : 0 : return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1927 : : }
1928 : : }
1929 : :
1930 : :
1931 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|