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