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