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