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