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

Generated by: LCOV version 1.10