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