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