LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdpage.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 564 848 66.5 %
Date: 2014-04-11 Functions: 94 126 74.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10