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