LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/svdraw - svdobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 860 1720 50.0 %
Date: 2013-07-09 Functions: 168 289 58.1 %
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 "sal/config.h"
      21             : 
      22             : #include <com/sun/star/lang/XComponent.hpp>
      23             : 
      24             : #include "svdconv.hxx"
      25             : 
      26             : #include <basegfx/matrix/b2dhommatrix.hxx>
      27             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      28             : #include <basegfx/polygon/b2dpolygon.hxx>
      29             : #include <basegfx/polygon/b2dpolygontools.hxx>
      30             : #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
      31             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      32             : #include <basegfx/range/b2drange.hxx>
      33             : #include <drawinglayer/processor2d/contourextractor2d.hxx>
      34             : #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
      35             : #include <editeng/editeng.hxx>
      36             : #include <editeng/eeitem.hxx>
      37             : #include <math.h>
      38             : #include <sfx2/objface.hxx>
      39             : #include <sfx2/objsh.hxx>
      40             : #include <svl/whiter.hxx>
      41             : #include <svtools/colorcfg.hxx>
      42             : #include <tools/bigint.hxx>
      43             : #include <tools/diagnose_ex.h>
      44             : #include <tools/helpers.hxx>
      45             : #include <tools/line.hxx>
      46             : #include <vcl/cvtsvm.hxx>
      47             : #include <vcl/graphictools.hxx>
      48             : #include <vcl/metaact.hxx>   // for TakeContour
      49             : #include <vcl/virdev.hxx>
      50             : #include <vector>
      51             : 
      52             : #include "svx/shapepropertynotifier.hxx"
      53             : #include "svx/svdglob.hxx"   // StringCache
      54             : #include "svx/svdotable.hxx"
      55             : #include "svx/xlinjoit.hxx"
      56             : 
      57             : #include <svx/fmmodel.hxx>
      58             : #include <svx/polysc3d.hxx>
      59             : #include <svx/sdr/contact/displayinfo.hxx>
      60             : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      61             : #include <svx/sdr/contact/viewcontactofgraphic.hxx>
      62             : #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
      63             : #include <svx/sdr/properties/emptyproperties.hxx>
      64             : #include <svx/sdrhittesthelper.hxx>
      65             : #include <svx/sdrobjectfilter.hxx>
      66             : #include <svx/svddrag.hxx>
      67             : #include <svx/svdetc.hxx>
      68             : #include <svx/svdhdl.hxx>
      69             : #include <svx/svditer.hxx>
      70             : #include <svx/svdmodel.hxx>
      71             : #include <svx/svdoashp.hxx>
      72             : #include <svx/svdobj.hxx>
      73             : #include <svx/svdocapt.hxx>  // Factory
      74             : #include <svx/svdocirc.hxx>  // Factory
      75             : #include <svx/svdoedge.hxx>  // Factory
      76             : #include <svx/svdograf.hxx>  // Factory
      77             : #include <svx/svdogrp.hxx>   // Factory
      78             : #include <svx/svdomeas.hxx>  // Factory
      79             : #include <svx/svdomedia.hxx>
      80             : #include <svx/svdoole2.hxx>  // Factory
      81             : #include <svx/svdopage.hxx>  // Factory
      82             : #include <svx/svdopath.hxx>  // Factory
      83             : #include <svx/svdorect.hxx>  // Factory
      84             : #include <svx/svdotext.hxx>  // Factory
      85             : #include <svx/svdouno.hxx>   // Factory
      86             : #include <svx/svdovirt.hxx>  // for Add/Del Ref
      87             : #include <svx/svdpage.hxx>
      88             : #include <svx/svdpool.hxx>
      89             : #include <svx/svdstr.hrc>    // the object's name
      90             : #include <svx/svdtrans.hxx>
      91             : #include <svx/svdundo.hxx>
      92             : #include <svx/svdview.hxx>   // for Dragging (check Ortho)
      93             : #include <svx/sxlayitm.hxx>
      94             : #include <svx/sxlogitm.hxx>
      95             : #include <svx/sxmovitm.hxx>
      96             : #include <svx/sxmspitm.hxx>
      97             : #include <svx/sxoneitm.hxx>
      98             : #include <svx/sxonitm.hxx>
      99             : #include <svx/sxopitm.hxx>
     100             : #include <svx/sxraitm.hxx>
     101             : #include <svx/sxreoitm.hxx>
     102             : #include <svx/sxrooitm.hxx>
     103             : #include <svx/sxsaitm.hxx>
     104             : #include <svx/sxsoitm.hxx>
     105             : #include <svx/sxtraitm.hxx>
     106             : #include <svx/unopage.hxx>
     107             : #include <svx/unoshape.hxx>
     108             : #include <svx/xbtmpit.hxx>
     109             : #include <svx/xenum.hxx>
     110             : #include <svx/xflclit.hxx>
     111             : #include <svx/xflftrit.hxx>
     112             : #include <svx/xflhtit.hxx>
     113             : #include <svx/xfltrit.hxx>
     114             : #include <svx/xgrad.hxx>
     115             : #include <svx/xhatch.hxx>
     116             : #include <svx/xlnclit.hxx>
     117             : #include <svx/xlndsit.hxx>
     118             : #include <svx/xlnedcit.hxx>
     119             : #include <svx/xlnedit.hxx>
     120             : #include <svx/xlnedwit.hxx>
     121             : #include <svx/xlnstcit.hxx>
     122             : #include <svx/xlnstit.hxx>
     123             : #include <svx/xlnstwit.hxx>
     124             : #include <svx/xlntrit.hxx>
     125             : #include <svx/xlnwtit.hxx>
     126             : #include <svx/xpoly.hxx>
     127             : 
     128             : using namespace ::com::sun::star;
     129             : 
     130             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     131             : 
     132           0 : TYPEINIT0(SdrObjUserCall);
     133             : 
     134        2155 : SdrObjUserCall::~SdrObjUserCall()
     135             : {
     136        2155 : }
     137             : 
     138        2922 : void SdrObjUserCall::Changed(const SdrObject& /*rObj*/, SdrUserCallType /*eType*/, const Rectangle& /*rOldBoundRect*/)
     139             : {
     140        2922 : }
     141             : 
     142           0 : SdrObjMacroHitRec::SdrObjMacroHitRec() :
     143             :     pOut(NULL),
     144             :     pVisiLayer(NULL),
     145             :     pPageView(NULL),
     146             :     nTol(0),
     147           0 :     bDown(false) {}
     148             : 
     149             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     150             : 
     151           0 : TYPEINIT0(SdrObjUserData);
     152             : 
     153        1895 : SdrObjUserData::SdrObjUserData(sal_uInt32 nInv, sal_uInt16 nId, sal_uInt16 nVer) :
     154             :     nInventor(nInv),
     155             :     nIdentifier(nId),
     156        1895 :     nVersion(nVer) {}
     157             : 
     158           4 : SdrObjUserData::SdrObjUserData(const SdrObjUserData& rData) :
     159             :     nInventor(rData.nInventor),
     160             :     nIdentifier(rData.nIdentifier),
     161           4 :     nVersion(rData.nVersion) {}
     162             : 
     163        1800 : SdrObjUserData::~SdrObjUserData() {}
     164             : 
     165       10950 : sal_uInt32 SdrObjUserData::GetInventor() const
     166             : {
     167       10950 :     return nInventor;
     168             : }
     169             : 
     170        9065 : sal_uInt16 SdrObjUserData::GetId() const
     171             : {
     172        9065 :     return nIdentifier;
     173             : }
     174             : 
     175           0 : bool SdrObjUserData::HasMacro(const SdrObject* /*pObj*/) const
     176             : {
     177           0 :     return false;
     178             : }
     179             : 
     180           0 : SdrObject* SdrObjUserData::CheckMacroHit(const SdrObjMacroHitRec& rRec, const SdrObject* pObj) const
     181             : {
     182           0 :     if(pObj)
     183             :     {
     184           0 :         if(rRec.pPageView)
     185             :         {
     186           0 :             return SdrObjectPrimitiveHit(*pObj, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
     187             :         }
     188             :     }
     189             : 
     190           0 :     return 0;
     191             : }
     192             : 
     193           0 : Pointer SdrObjUserData::GetMacroPointer(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
     194             : {
     195           0 :     return Pointer(POINTER_REFHAND);
     196             : }
     197             : 
     198           0 : void SdrObjUserData::PaintMacro(OutputDevice& rOut, const Rectangle& /*rDirtyRect*/, const SdrObjMacroHitRec& /*rRec*/, const SdrObject* pObj) const
     199             : {
     200           0 :     if(!pObj)
     201           0 :         return;
     202             : 
     203           0 :     const RasterOp eRop(rOut.GetRasterOp());
     204           0 :     const basegfx::B2DPolyPolygon aPolyPolygon(pObj->TakeXorPoly());
     205           0 :     const sal_uInt32 nCount(aPolyPolygon.count());
     206             : 
     207           0 :     rOut.SetLineColor(COL_BLACK);
     208           0 :     rOut.SetFillColor();
     209           0 :     rOut.SetRasterOp(ROP_INVERT);
     210             : 
     211           0 :     for(sal_uInt32 a(0); a < nCount; a++)
     212             :     {
     213           0 :         rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
     214             :     }
     215             : 
     216           0 :     rOut.SetRasterOp(eRop);
     217             : }
     218             : 
     219           0 : bool SdrObjUserData::DoMacro(const SdrObjMacroHitRec& /*rRec*/, SdrObject* /*pObj*/)
     220             : {
     221           0 :     return false;
     222             : }
     223             : 
     224           0 : OUString SdrObjUserData::GetMacroPopupComment(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
     225             : {
     226           0 :     return OUString();
     227             : }
     228             : 
     229        1434 : SdrObjUserDataList::SdrObjUserDataList() {}
     230        1341 : SdrObjUserDataList::~SdrObjUserDataList() {}
     231             : 
     232       10630 : size_t SdrObjUserDataList::GetUserDataCount() const
     233             : {
     234       10630 :     return static_cast<sal_uInt16>(maList.size());
     235             : }
     236             : 
     237           0 : const SdrObjUserData* SdrObjUserDataList::GetUserData(size_t nNum) const
     238             : {
     239           0 :     return &maList.at(nNum);
     240             : }
     241             : 
     242       10954 : SdrObjUserData* SdrObjUserDataList::GetUserData(size_t nNum)
     243             : {
     244       10954 :     return &maList.at(nNum);
     245             : }
     246             : 
     247        1589 : void SdrObjUserDataList::AppendUserData(SdrObjUserData* pData)
     248             : {
     249        1589 :     maList.push_back(pData);
     250        1589 : }
     251             : 
     252           0 : void SdrObjUserDataList::DeleteUserData(size_t nNum)
     253             : {
     254           0 :     maList.erase(maList.begin()+nNum);
     255           0 : }
     256             : 
     257             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     258             : 
     259             : DBG_NAME(SdrObjGeoData);
     260             : 
     261         187 : SdrObjGeoData::SdrObjGeoData():
     262             :     pGPL(NULL),
     263             :     bMovProt(false),
     264             :     bSizProt(false),
     265             :     bNoPrint(false),
     266             :     bClosedObj(false),
     267             :     mbVisible(true),
     268         187 :     mnLayerID(0)
     269             : {
     270             :     DBG_CTOR(SdrObjGeoData,NULL);
     271         187 : }
     272             : 
     273         187 : SdrObjGeoData::~SdrObjGeoData()
     274             : {
     275             :     DBG_DTOR(SdrObjGeoData,NULL);
     276         187 :     delete pGPL;
     277         187 : }
     278             : 
     279             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     280             : 
     281           0 : TYPEINIT0(SdrObjPlusData);
     282             : 
     283       23953 : SdrObjPlusData::SdrObjPlusData():
     284             :     pBroadcast(NULL),
     285             :     pUserDataList(NULL),
     286       23953 :     pGluePoints(NULL)
     287             : {
     288       23953 : }
     289             : 
     290       71580 : SdrObjPlusData::~SdrObjPlusData()
     291             : {
     292       23860 :     delete pBroadcast;
     293       23860 :     delete pUserDataList;
     294       23860 :     delete pGluePoints;
     295       47720 : }
     296             : 
     297           6 : SdrObjPlusData* SdrObjPlusData::Clone(SdrObject* pObj1) const
     298             : {
     299           6 :     SdrObjPlusData* pNeuPlusData=new SdrObjPlusData;
     300           6 :     if (pUserDataList!=NULL) {
     301           3 :         sal_uInt16 nAnz=pUserDataList->GetUserDataCount();
     302           3 :         if (nAnz!=0) {
     303           3 :             pNeuPlusData->pUserDataList=new SdrObjUserDataList;
     304           7 :             for (sal_uInt16 i=0; i<nAnz; i++) {
     305           4 :                 SdrObjUserData* pNeuUserData=pUserDataList->GetUserData(i)->Clone(pObj1);
     306           4 :                 if (pNeuUserData!=NULL) {
     307           4 :                     pNeuPlusData->pUserDataList->AppendUserData(pNeuUserData);
     308             :                 } else {
     309             :                     OSL_FAIL("SdrObjPlusData::Clone(): UserData.Clone() returns NULL.");
     310             :                 }
     311             :             }
     312             :         }
     313             :     }
     314           6 :     if (pGluePoints!=NULL) pNeuPlusData->pGluePoints=new SdrGluePointList(*pGluePoints);
     315             :     // MtfAnimator isn't copied either
     316             : 
     317             :     // #i68101#
     318             :     // copy object name, title and description
     319           6 :     pNeuPlusData->aObjName = aObjName;
     320           6 :     pNeuPlusData->aObjTitle = aObjTitle;
     321           6 :     pNeuPlusData->aObjDescription = aObjDescription;
     322             : 
     323           6 :     return pNeuPlusData;
     324             : }
     325             : 
     326          18 : void SdrObjPlusData::SetGluePoints(const SdrGluePointList& rPts)
     327             : {
     328          18 :     return *pGluePoints = rPts;
     329             : }
     330             : 
     331          29 : SdrObjTransformInfoRec::SdrObjTransformInfoRec() :
     332             :     bSelectAllowed(true),
     333             :     bMoveAllowed(true),
     334             :     bResizeFreeAllowed(true),
     335             :     bResizePropAllowed(true),
     336             :     bRotateFreeAllowed(true),
     337             :     bRotate90Allowed(true),
     338             :     bMirrorFreeAllowed(true),
     339             :     bMirror45Allowed(true),
     340             :     bMirror90Allowed(true),
     341             :     bTransparenceAllowed(true),
     342             :     bGradientAllowed(true),
     343             :     bShearAllowed(true),
     344             :     bEdgeRadiusAllowed(true),
     345             :     bNoOrthoDesired(true),
     346             :     bNoContortion(true),
     347             :     bCanConvToPath(true),
     348             :     bCanConvToPoly(true),
     349             :     bCanConvToContour(false),
     350             :     bCanConvToPathLineToArea(true),
     351          29 :     bCanConvToPolyLineToArea(true) {}
     352             : 
     353             : //////////////////////////////////////////////////////////////////////////////
     354             : // BaseProperties section
     355             : 
     356           0 : sdr::properties::BaseProperties* SdrObject::CreateObjectSpecificProperties()
     357             : {
     358           0 :     return new sdr::properties::EmptyProperties(*this);
     359             : }
     360             : 
     361     3001947 : sdr::properties::BaseProperties& SdrObject::GetProperties() const
     362             : {
     363     3001947 :     if(!mpProperties)
     364             :     {
     365             :         const_cast< SdrObject* >(this)->mpProperties =
     366       50458 :             const_cast< SdrObject* >(this)->CreateObjectSpecificProperties();
     367             :     }
     368             : 
     369     3001947 :     return *mpProperties;
     370             : }
     371             : 
     372             : //////////////////////////////////////////////////////////////////////////////
     373             : // ObjectUser section
     374             : 
     375       56485 : void SdrObject::AddObjectUser(sdr::ObjectUser& rNewUser)
     376             : {
     377       56485 :     maObjectUsers.push_back(&rNewUser);
     378       56485 : }
     379             : 
     380       98963 : void SdrObject::RemoveObjectUser(sdr::ObjectUser& rOldUser)
     381             : {
     382       98963 :     const ::sdr::ObjectUserVector::iterator aFindResult = ::std::find(maObjectUsers.begin(), maObjectUsers.end(), &rOldUser);
     383       98963 :     if(aFindResult != maObjectUsers.end())
     384             :     {
     385       51328 :         maObjectUsers.erase(aFindResult);
     386             :     }
     387       98963 : }
     388             : 
     389             : //////////////////////////////////////////////////////////////////////////////
     390             : // DrawContact section
     391             : 
     392           0 : sdr::contact::ViewContact* SdrObject::CreateObjectSpecificViewContact()
     393             : {
     394           0 :     return new sdr::contact::ViewContactOfSdrObj(*this);
     395             : }
     396             : 
     397      871886 : sdr::contact::ViewContact& SdrObject::GetViewContact() const
     398             : {
     399      871886 :     if(!mpViewContact)
     400             :     {
     401             :         const_cast< SdrObject* >(this)->mpViewContact =
     402       51334 :             const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact();
     403             :     }
     404             : 
     405      871886 :     return *mpViewContact;
     406             : }
     407             : 
     408             : // DrawContact support: Methods for handling Object changes
     409      435722 : void SdrObject::ActionChanged() const
     410             : {
     411             :     // Do necessary ViewContact actions
     412      435722 :     GetViewContact().ActionChanged();
     413      435722 : }
     414             : 
     415             : //////////////////////////////////////////////////////////////////////////////
     416             : 
     417      959343 : void SdrObject::SetBoundRectDirty()
     418             : {
     419      959343 :     aOutRect = Rectangle();
     420      959343 : }
     421             : 
     422             : //////////////////////////////////////////////////////////////////////////////
     423             : 
     424             : DBG_NAME(SdrObject);
     425     2052015 : TYPEINIT1(SdrObject,SfxListener);
     426             : 
     427       51678 : SdrObject::SdrObject()
     428             :     :mpProperties(0L)
     429             :     ,mpViewContact(0L)
     430             :     ,pObjList(NULL)
     431             :     ,pPage(NULL)
     432             :     ,pModel(NULL)
     433             :     ,pUserCall(NULL)
     434             :     ,pPlusData(NULL)
     435             :     ,nOrdNum(0)
     436             :     ,mnNavigationPosition(SAL_MAX_UINT32)
     437             :     ,mnLayerID(0)
     438             :     ,mpSvxShape( NULL )
     439             :     ,maWeakUnoShape()
     440       51678 :     ,mbDoNotInsertIntoPageAutomatically(false)
     441             : {
     442             :     DBG_CTOR(SdrObject,NULL);
     443       51678 :     bVirtObj         =false;
     444       51678 :     bSnapRectDirty   =true;
     445       51678 :     bNetLock         =false;
     446       51678 :     bInserted        =false;
     447       51678 :     bGrouped         =false;
     448       51678 :     bMovProt         =false;
     449       51678 :     bSizProt         =false;
     450       51678 :     bNoPrint         =false;
     451       51678 :     bEmptyPresObj    =false;
     452       51678 :     bNotVisibleAsMaster=false;
     453       51678 :     bClosedObj       =false;
     454       51678 :     mbVisible        = true;
     455             : 
     456             :     // #i25616#
     457       51678 :     mbLineIsOutsideGeometry = false;
     458             : 
     459             :     // #i25616#
     460       51678 :     mbSupportTextIndentingOnLineWidthChange = false;
     461             : 
     462       51678 :     bNotMasterCachable=false;
     463       51678 :     bIsEdge=false;
     464       51678 :     bIs3DObj=false;
     465       51678 :     bMarkProt=false;
     466       51678 :     bIsUnoObj=false;
     467       51678 : }
     468             : 
     469      103150 : SdrObject::~SdrObject()
     470             : {
     471             :     // tell all the registered ObjectUsers that the page is in destruction
     472       51575 :     ::sdr::ObjectUserVector aListCopy(maObjectUsers.begin(), maObjectUsers.end());
     473       56661 :     for(::sdr::ObjectUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
     474             :     {
     475        5086 :         sdr::ObjectUser* pObjectUser = *aIterator;
     476             :         DBG_ASSERT(pObjectUser, "SdrObject::~SdrObject: corrupt ObjectUser list (!)");
     477        5086 :         pObjectUser->ObjectInDestruction(*this);
     478             :     }
     479             : 
     480             :     // Clear the vector. This means that user do not need to call RemoveObjectUser()
     481             :     // when they get called from ObjectInDestruction().
     482       51575 :     maObjectUsers.clear();
     483             : 
     484             :     try
     485             :     {
     486       51575 :         SvxShape* pSvxShape = getSvxShape();
     487       51575 :         if ( pSvxShape )
     488             :         {
     489             :             OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
     490          15 :             pSvxShape->InvalidateSdrObject();
     491          15 :             uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW );
     492          15 :             xShapeComp->dispose();
     493             :         }
     494             :     }
     495           0 :     catch( const uno::Exception& )
     496             :     {
     497             :         DBG_UNHANDLED_EXCEPTION();
     498             :     }
     499             : 
     500             :     DBG_DTOR(SdrObject,NULL);
     501       51575 :     SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
     502       51575 :     delete pPlusData;
     503             : 
     504       51575 :     if(mpProperties)
     505             :     {
     506       50387 :         delete mpProperties;
     507       50387 :         mpProperties = 0L;
     508             :     }
     509             : 
     510       51575 :     if(mpViewContact)
     511             :     {
     512       51232 :         delete mpViewContact;
     513       51232 :         mpViewContact = 0L;
     514       51575 :     }
     515       51575 : }
     516             : 
     517      101984 : void SdrObject::Free( SdrObject*& _rpObject )
     518             : {
     519      101984 :     SdrObject* pObject = _rpObject; _rpObject = NULL;
     520      101984 :     if ( pObject == NULL )
     521             :         // nothing to do
     522       51129 :         return;
     523             : 
     524       50855 :     SvxShape* pShape = pObject->getSvxShape();
     525       50855 :     if ( pShape && pShape->HasSdrObjectOwnership() )
     526             :         // only the shape is allowed to delete me, and will reset the ownership before doing so
     527           0 :         return;
     528             : 
     529       50855 :     delete pObject;
     530             : }
     531             : 
     532       23947 : SdrObjPlusData* SdrObject::NewPlusData() const
     533             : {
     534       23947 :     return new SdrObjPlusData;
     535             : }
     536             : 
     537     1040877 : void SdrObject::SetRectsDirty(sal_Bool bNotMyself)
     538             : {
     539     1040877 :     if (!bNotMyself) {
     540      842373 :         SetBoundRectDirty();
     541      842373 :         bSnapRectDirty=true;
     542             :     }
     543     1040877 :     if (pObjList!=NULL) {
     544      919139 :         pObjList->SetRectsDirty();
     545             :     }
     546     1040877 : }
     547             : 
     548       80128 : void SdrObject::SetModel(SdrModel* pNewModel)
     549             : {
     550       80128 :     if(pNewModel && pPage)
     551             :     {
     552       77045 :         if(pPage->GetModel() != pNewModel)
     553             :         {
     554           0 :             pPage = NULL;
     555             :         }
     556             :     }
     557             : 
     558             :     // update listeners at possible API wrapper object
     559       80128 :     if( pModel != pNewModel )
     560             :     {
     561       51460 :         SvxShape* pShape = getSvxShape();
     562       51460 :         if( pShape )
     563         297 :             pShape->ChangeModel( pNewModel );
     564             :     }
     565             : 
     566       80128 :     pModel = pNewModel;
     567       80128 : }
     568             : 
     569     1179522 : SdrModel* SdrObject::GetModel() const
     570             : {
     571     1179522 :     return pModel;
     572             : }
     573             : 
     574       62677 : void SdrObject::SetObjList(SdrObjList* pNewObjList)
     575             : {
     576       62677 :     pObjList=pNewObjList;
     577       62677 : }
     578             : 
     579    13244789 : SdrObjList* SdrObject::GetObjList() const
     580             : {
     581    13244789 :     return pObjList;
     582             : }
     583             : 
     584      141346 : void SdrObject::SetPage(SdrPage* pNewPage)
     585             : {
     586      141346 :     SdrModel* pOldModel = pModel;
     587      141346 :     SdrPage* pOldPage = pPage;
     588             : 
     589      141346 :     pPage=pNewPage;
     590      141346 :     if (pPage!=NULL) {
     591       97361 :         SdrModel* pMod=pPage->GetModel();
     592       97361 :         if (pMod!=pModel && pMod!=NULL) {
     593       48991 :             SetModel(pMod);
     594             :         }}
     595             : 
     596             :     // The creation of the UNO shape in SdrObject::getUnoShape is influenced
     597             :     // by pPage, so when the page changes we need to discard the cached UNO
     598             :     // shape so that a new one will be created.
     599             :     // If the page is changing to another page with the same model, we
     600             :     // assume they create compatible UNO shape objects so we shouldn't have
     601             :     // to invalidate.
     602      141346 :     if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == pModel))
     603             :     {
     604       92972 :         SvxShape* const pShape(getSvxShape());
     605       92972 :         if (pShape && !pShape->HasSdrObjectOwnership())
     606       11334 :             setUnoShape(NULL);
     607             :     }
     608      141346 : }
     609             : 
     610      165394 : SdrPage* SdrObject::GetPage() const
     611             : {
     612      165394 :     return pPage;
     613             : }
     614             : 
     615             : // init global static itempool
     616             : SdrItemPool* SdrObject::mpGlobalItemPool = NULL;
     617             : 
     618      241276 : SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool()
     619             : {
     620      241276 :     if(!mpGlobalItemPool)
     621             :     {
     622          47 :         mpGlobalItemPool = new SdrItemPool();
     623          47 :         SfxItemPool* pGlobalOutlPool = EditEngine::CreatePool();
     624          47 :         mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool);
     625          47 :         mpGlobalItemPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit());
     626          47 :         mpGlobalItemPool->FreezeIdRanges();
     627             :     }
     628             : 
     629      241276 :     return *mpGlobalItemPool;
     630             : }
     631             : 
     632      362778 : SdrItemPool* SdrObject::GetObjectItemPool() const
     633             : {
     634      362778 :     if(pModel)
     635      207903 :         return (SdrItemPool*)(&pModel->GetItemPool());
     636             : 
     637             :     // use a static global default pool
     638      154875 :     return &SdrObject::GetGlobalDrawObjectItemPool();
     639             : }
     640             : 
     641      568645 : sal_uInt32 SdrObject::GetObjInventor()   const
     642             : {
     643      568645 :     return SdrInventor;
     644             : }
     645             : 
     646           0 : sal_uInt16 SdrObject::GetObjIdentifier() const
     647             : {
     648           0 :     return sal_uInt16(OBJ_NONE);
     649             : }
     650             : 
     651           0 : void SdrObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
     652             : {
     653           0 :     rInfo.bRotateFreeAllowed=false;
     654           0 :     rInfo.bMirrorFreeAllowed=false;
     655           0 :     rInfo.bTransparenceAllowed = false;
     656           0 :     rInfo.bGradientAllowed = false;
     657           0 :     rInfo.bShearAllowed     =false;
     658           0 :     rInfo.bEdgeRadiusAllowed=false;
     659           0 :     rInfo.bCanConvToPath    =false;
     660           0 :     rInfo.bCanConvToPoly    =false;
     661           0 :     rInfo.bCanConvToContour = false;
     662           0 :     rInfo.bCanConvToPathLineToArea=false;
     663           0 :     rInfo.bCanConvToPolyLineToArea=false;
     664           0 : }
     665             : 
     666      579322 : SdrLayerID SdrObject::GetLayer() const
     667             : {
     668      579322 :     return mnLayerID;
     669             : }
     670             : 
     671      124548 : void SdrObject::getMergedHierarchyLayerSet(SetOfByte& rSet) const
     672             : {
     673      124548 :     rSet.Set(GetLayer());
     674      124548 :     SdrObjList* pOL=GetSubList();
     675      124548 :     if (pOL!=NULL) {
     676       44927 :         sal_uIntPtr nObjAnz=pOL->GetObjCount();
     677      160290 :         for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
     678      115363 :             pOL->GetObj(nObjNum)->getMergedHierarchyLayerSet(rSet);
     679             :         }
     680             :     }
     681      124548 : }
     682             : 
     683        4002 : void SdrObject::NbcSetLayer(SdrLayerID nLayer)
     684             : {
     685        4002 :     mnLayerID = nLayer;
     686        4002 : }
     687             : 
     688        2786 : void SdrObject::SetLayer(SdrLayerID nLayer)
     689             : {
     690        2786 :     NbcSetLayer(nLayer);
     691        2786 :     SetChanged();
     692        2786 :     BroadcastObjectChange();
     693        2786 : }
     694             : 
     695         330 : void SdrObject::AddListener(SfxListener& rListener)
     696             : {
     697         330 :     ImpForcePlusData();
     698         330 :     if (pPlusData->pBroadcast==NULL) pPlusData->pBroadcast=new SfxBroadcaster;
     699         330 :     rListener.StartListening(*pPlusData->pBroadcast);
     700         330 : }
     701             : 
     702         328 : void SdrObject::RemoveListener(SfxListener& rListener)
     703             : {
     704         328 :     if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
     705         328 :         rListener.EndListening(*pPlusData->pBroadcast);
     706         328 :         if (!pPlusData->pBroadcast->HasListeners()) {
     707         328 :             delete pPlusData->pBroadcast;
     708         328 :             pPlusData->pBroadcast=NULL;
     709             :         }
     710             :     }
     711         328 : }
     712             : 
     713         126 : const SfxBroadcaster* SdrObject::GetBroadcaster() const
     714             : {
     715         126 :     return pPlusData!=NULL ? pPlusData->pBroadcast : NULL;
     716             : }
     717             : 
     718         328 : void SdrObject::AddReference(SdrVirtObj& rVrtObj)
     719             : {
     720         328 :     AddListener(rVrtObj);
     721         328 : }
     722             : 
     723         328 : void SdrObject::DelReference(SdrVirtObj& rVrtObj)
     724             : {
     725         328 :     RemoveListener(rVrtObj);
     726         328 : }
     727             : 
     728           0 : bool SdrObject::HasRefPoint() const
     729             : {
     730           0 :     return false;
     731             : }
     732             : 
     733           0 : Point SdrObject::GetRefPoint() const
     734             : {
     735           0 :     return GetCurrentBoundRect().Center();
     736             : }
     737             : 
     738           0 : void SdrObject::SetRefPoint(const Point& /*rPnt*/)
     739             : {
     740           0 : }
     741             : 
     742       49294 : bool SdrObject::IsGroupObject() const
     743             : {
     744       49294 :     return GetSubList()!=NULL;
     745             : }
     746             : 
     747      250859 : SdrObjList* SdrObject::GetSubList() const
     748             : {
     749      250859 :     return NULL;
     750             : }
     751             : 
     752         948 : SdrObject* SdrObject::GetUpGroup() const
     753             : {
     754         948 :     return pObjList!=NULL ? pObjList->GetOwnerObj() : NULL;
     755             : }
     756             : 
     757       23328 : void SdrObject::SetName(const OUString& rStr)
     758             : {
     759       23328 :     if (!rStr.isEmpty() && !pPlusData)
     760             :     {
     761       22188 :         ImpForcePlusData();
     762             :     }
     763             : 
     764       23328 :     if(pPlusData && !pPlusData->aObjName.equals(rStr))
     765             :     {
     766             :         // Undo/Redo for setting object's name (#i73249#)
     767       22310 :         bool bUndo( false );
     768       22310 :         if ( GetModel() && GetModel()->IsUndoEnabled() )
     769             :         {
     770         190 :             bUndo = true;
     771             :             SdrUndoAction* pUndoAction =
     772         190 :                     GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
     773             :                                                     *this,
     774             :                                                     SdrUndoObjStrAttr::OBJ_NAME,
     775             :                                                     GetName(),
     776         190 :                                                     rStr );
     777         190 :             GetModel()->BegUndo( pUndoAction->GetComment() );
     778         190 :             GetModel()->AddUndo( pUndoAction );
     779             :         }
     780       22310 :         pPlusData->aObjName = rStr;
     781             :         // Undo/Redo for setting object's name (#i73249#)
     782       22310 :         if ( bUndo )
     783             :         {
     784         190 :             GetModel()->EndUndo();
     785             :         }
     786       22310 :         SetChanged();
     787       22310 :         BroadcastObjectChange();
     788             :     }
     789       23328 : }
     790             : 
     791       72826 : OUString SdrObject::GetName() const
     792             : {
     793       72826 :     if(pPlusData)
     794             :     {
     795       45862 :         return pPlusData->aObjName;
     796             :     }
     797             : 
     798       26964 :     return OUString();
     799             : }
     800             : 
     801           2 : void SdrObject::SetTitle(const OUString& rStr)
     802             : {
     803           2 :     if (!rStr.isEmpty() && !pPlusData)
     804             :     {
     805           0 :         ImpForcePlusData();
     806             :     }
     807             : 
     808           2 :     if(pPlusData && pPlusData->aObjTitle != rStr)
     809             :     {
     810             :         // Undo/Redo for setting object's title (#i73249#)
     811           0 :         bool bUndo( false );
     812           0 :         if ( GetModel() && GetModel()->IsUndoEnabled() )
     813             :         {
     814           0 :             bUndo = true;
     815             :             SdrUndoAction* pUndoAction =
     816           0 :                     GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
     817             :                                                     *this,
     818             :                                                     SdrUndoObjStrAttr::OBJ_TITLE,
     819             :                                                     GetTitle(),
     820           0 :                                                     rStr );
     821           0 :             GetModel()->BegUndo( pUndoAction->GetComment() );
     822           0 :             GetModel()->AddUndo( pUndoAction );
     823             :         }
     824           0 :         pPlusData->aObjTitle = rStr;
     825             :         // Undo/Redo for setting object's title (#i73249#)
     826           0 :         if ( bUndo )
     827             :         {
     828           0 :             GetModel()->EndUndo();
     829             :         }
     830           0 :         SetChanged();
     831           0 :         BroadcastObjectChange();
     832             :     }
     833           2 : }
     834             : 
     835       46392 : OUString SdrObject::GetTitle() const
     836             : {
     837       46392 :     if(pPlusData)
     838             :     {
     839       21187 :         return pPlusData->aObjTitle;
     840             :     }
     841             : 
     842       25205 :     return OUString();
     843             : }
     844             : 
     845          28 : void SdrObject::SetDescription(const OUString& rStr)
     846             : {
     847          28 :     if (!rStr.isEmpty() && !pPlusData)
     848             :     {
     849          17 :         ImpForcePlusData();
     850             :     }
     851             : 
     852          28 :     if(pPlusData && !pPlusData->aObjDescription.equals(rStr))
     853             :     {
     854             :         // Undo/Redo for setting object's description (#i73249#)
     855          24 :         bool bUndo( false );
     856          24 :         if ( GetModel() && GetModel()->IsUndoEnabled() )
     857             :         {
     858           0 :             bUndo = true;
     859             :             SdrUndoAction* pUndoAction =
     860           0 :                     GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
     861             :                                                     *this,
     862             :                                                     SdrUndoObjStrAttr::OBJ_DESCRIPTION,
     863             :                                                     GetDescription(),
     864           0 :                                                     rStr );
     865           0 :             GetModel()->BegUndo( pUndoAction->GetComment() );
     866           0 :             GetModel()->AddUndo( pUndoAction );
     867             :         }
     868          24 :         pPlusData->aObjDescription = rStr;
     869             :         // Undo/Redo for setting object's description (#i73249#)
     870          24 :         if ( bUndo )
     871             :         {
     872           0 :             GetModel()->EndUndo();
     873             :         }
     874          24 :         SetChanged();
     875          24 :         BroadcastObjectChange();
     876             :     }
     877          28 : }
     878             : 
     879       46387 : OUString SdrObject::GetDescription() const
     880             : {
     881       46387 :     if(pPlusData)
     882             :     {
     883       21172 :         return pPlusData->aObjDescription;
     884             :     }
     885             : 
     886       25215 :     return OUString();
     887             : }
     888             : 
     889       10532 : sal_uInt32 SdrObject::GetOrdNum() const
     890             : {
     891       10532 :     if (pObjList!=NULL) {
     892       10532 :         if (pObjList->IsObjOrdNumsDirty()) {
     893        7100 :             pObjList->RecalcObjOrdNums();
     894             :         }
     895           0 :     } else ((SdrObject*)this)->nOrdNum=0;
     896       10532 :     return nOrdNum;
     897             : }
     898             : 
     899        5026 : sal_uInt32 SdrObject::GetOrdNumDirect() const
     900             : {
     901        5026 :     return nOrdNum;
     902             : }
     903             : 
     904       74183 : void SdrObject::SetOrdNum(sal_uInt32 nNum)
     905             : {
     906       74183 :     nOrdNum = nNum;
     907       74183 : }
     908             : 
     909         316 : sal_uInt32 SdrObject::GetNavigationPosition (void)
     910             : {
     911         316 :     if (pObjList!=NULL && pObjList->RecalcNavigationPositions())
     912             :     {
     913           0 :         return mnNavigationPosition;
     914             :     }
     915             :     else
     916         316 :         return GetOrdNum();
     917             : }
     918             : 
     919             : 
     920             : 
     921             : 
     922           0 : void SdrObject::SetNavigationPosition (const sal_uInt32 nNewPosition)
     923             : {
     924           0 :     mnNavigationPosition = nNewPosition;
     925           0 : }
     926             : 
     927             : 
     928             : 
     929             : 
     930             : // To make clearer that this method may trigger RecalcBoundRect and thus may be
     931             : // expensive and sometimes problematic (inside a bigger object change you will get
     932             : // non-useful BoundRects sometimes) I rename that method from GetBoundRect() to
     933             : // GetCurrentBoundRect().
     934       46625 : const Rectangle& SdrObject::GetCurrentBoundRect() const
     935             : {
     936       46625 :     if(aOutRect.IsEmpty())
     937             :     {
     938       43984 :         const_cast< SdrObject* >(this)->RecalcBoundRect();
     939             :     }
     940             : 
     941       46625 :     return aOutRect;
     942             : }
     943             : 
     944             : // To have a possibility to get the last calculated BoundRect e.g for producing
     945             : // the first rectangle for repaints (old and new need to be used) without forcing
     946             : // a RecalcBoundRect (which may be problematical and expensive sometimes) I add here
     947             : // a new method for accessing the last BoundRect.
     948      241032 : const Rectangle& SdrObject::GetLastBoundRect() const
     949             : {
     950      241032 :     return aOutRect;
     951             : }
     952             : 
     953       44998 : void SdrObject::RecalcBoundRect()
     954             : {
     955             :     // #i101680# suppress BoundRect calculations on import(s)
     956       44998 :     if(pModel && pModel->isLocked())
     957       30152 :         return;
     958             : 
     959             :     // central new method which will calculate the BoundRect using primitive geometry
     960       14846 :     if(aOutRect.IsEmpty())
     961             :     {
     962       14672 :         const drawinglayer::primitive2d::Primitive2DSequence xPrimitives(GetViewContact().getViewIndependentPrimitive2DSequence());
     963             : 
     964       14672 :         if(xPrimitives.hasElements())
     965             :         {
     966             :             // use neutral ViewInformation and get the range of the primitives
     967       14313 :             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
     968       14313 :             const basegfx::B2DRange aRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xPrimitives, aViewInformation2D));
     969             : 
     970       14313 :             if(!aRange.isEmpty())
     971             :             {
     972             :                 aOutRect = Rectangle(
     973       28390 :                         (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
     974       42585 :                         (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
     975       14195 :                 aOutRect -= GetGridOffset(); // don't include grid offset
     976       14195 :                 return;
     977         118 :             }
     978         477 :         }
     979             :     }
     980             : }
     981             : 
     982      315945 : void SdrObject::BroadcastObjectChange() const
     983             : {
     984      315945 :     if( pModel && pModel->isLocked() )
     985      622704 :         return;
     986             : 
     987        9186 :     bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast);
     988        9186 :     bool bObjectChange(IsInserted() && pModel);
     989             : 
     990        9186 :     if(bPlusDataBroadcast || bObjectChange)
     991             :     {
     992        6869 :         SdrHint aHint(*this);
     993             : 
     994        6869 :         if(bPlusDataBroadcast)
     995             :         {
     996           0 :             pPlusData->pBroadcast->Broadcast(aHint);
     997             :         }
     998             : 
     999        6869 :         if(bObjectChange)
    1000             :         {
    1001        6869 :             pModel->Broadcast(aHint);
    1002        6869 :         }
    1003             :     }
    1004             : }
    1005             : 
    1006      350982 : void SdrObject::SetChanged()
    1007             : {
    1008             :     // For testing purposes, use the new ViewContact for change
    1009             :     // notification now.
    1010      350982 :     ActionChanged();
    1011             : 
    1012      350982 :     if(IsInserted() && pModel)
    1013             :     {
    1014      264077 :         pModel->SetChanged();
    1015             :     }
    1016      350982 : }
    1017             : 
    1018             : // tooling for painting a single object to an OutputDevice.
    1019           1 : bool SdrObject::SingleObjectPainter(OutputDevice& rOut) const
    1020             : {
    1021           1 :     sdr::contact::SdrObjectVector aObjectVector;
    1022           1 :     aObjectVector.push_back(const_cast< SdrObject* >(this));
    1023             : 
    1024           2 :     sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aObjectVector, GetPage());
    1025           2 :     sdr::contact::DisplayInfo aDisplayInfo;
    1026             : 
    1027           1 :     aPainter.ProcessDisplay(aDisplayInfo);
    1028             : 
    1029           2 :     return true;
    1030             : }
    1031             : 
    1032           0 : bool SdrObject::LineGeometryUsageIsNecessary() const
    1033             : {
    1034           0 :     XLineStyle eXLS = (XLineStyle)((const XLineStyleItem&)GetMergedItem(XATTR_LINESTYLE)).GetValue();
    1035           0 :     return (eXLS != XLINE_NONE);
    1036             : }
    1037             : 
    1038           0 : SdrObject* SdrObject::Clone() const
    1039             : {
    1040           0 :     return CloneHelper< SdrObject >();
    1041             : }
    1042             : 
    1043          10 : SdrObject& SdrObject::operator=(const SdrObject& rObj)
    1044             : {
    1045          10 :     if( this == &rObj )
    1046           0 :         return *this;
    1047             : 
    1048          10 :     if(mpProperties)
    1049             :     {
    1050           0 :         delete mpProperties;
    1051           0 :         mpProperties = 0L;
    1052             :     }
    1053             : 
    1054          10 :     if(mpViewContact)
    1055             :     {
    1056           0 :         delete mpViewContact;
    1057           0 :         mpViewContact = 0L;
    1058             :     }
    1059             : 
    1060             :     // The Clone() method uses the local copy constructor from the individual
    1061             :     // sdr::properties::BaseProperties class. Since the target class maybe for another
    1062             :     // draw object, an SdrObject needs to be provided, as in the normal constructor.
    1063          10 :     mpProperties = &rObj.GetProperties().Clone(*this);
    1064             : 
    1065          10 :     pModel  =rObj.pModel;
    1066          10 :     pPage = rObj.pPage;
    1067          10 :     aOutRect=rObj.aOutRect;
    1068          10 :     mnLayerID = rObj.mnLayerID;
    1069          10 :     aAnchor =rObj.aAnchor;
    1070          10 :     bVirtObj=rObj.bVirtObj;
    1071          10 :     bSizProt=rObj.bSizProt;
    1072          10 :     bMovProt=rObj.bMovProt;
    1073          10 :     bNoPrint=rObj.bNoPrint;
    1074          10 :     mbVisible=rObj.mbVisible;
    1075          10 :     bMarkProt=rObj.bMarkProt;
    1076          10 :     bEmptyPresObj =rObj.bEmptyPresObj;
    1077          10 :     bNotVisibleAsMaster=rObj.bNotVisibleAsMaster;
    1078          10 :     bSnapRectDirty=true;
    1079          10 :     bNotMasterCachable=rObj.bNotMasterCachable;
    1080          10 :     delete pPlusData;
    1081          10 :     pPlusData=NULL;
    1082          10 :     if (rObj.pPlusData!=NULL) {
    1083           6 :         pPlusData=rObj.pPlusData->Clone(this);
    1084             :     }
    1085          10 :     if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
    1086           0 :         delete pPlusData->pBroadcast; // broadcaster isn't copied
    1087           0 :         pPlusData->pBroadcast=NULL;
    1088             :     }
    1089          10 :     aGridOffset = rObj.aGridOffset;
    1090          10 :     return *this;
    1091             : }
    1092             : 
    1093          59 : void SdrObject::TakeObjNameSingul(XubString& rName) const
    1094             : {
    1095          59 :     rName=ImpGetResStr(STR_ObjNameSingulNONE);
    1096             : 
    1097          59 :     String aName( GetName() );
    1098          59 :     if(aName.Len())
    1099             :     {
    1100           0 :         rName += sal_Unicode(' ');
    1101           0 :         rName += sal_Unicode('\'');
    1102           0 :         rName += aName;
    1103           0 :         rName += sal_Unicode('\'');
    1104          59 :     }
    1105          59 : }
    1106             : 
    1107           0 : void SdrObject::TakeObjNamePlural(XubString& rName) const
    1108             : {
    1109           0 :     rName=ImpGetResStr(STR_ObjNamePluralNONE);
    1110           0 : }
    1111             : 
    1112           0 : void SdrObject::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, sal_uInt16 nVal) const
    1113             : {
    1114           0 :     rStr = ImpGetResStr(nStrCacheID);
    1115           0 :     sal_Int32 nPos = rStr.indexOf("%1");
    1116           0 :     if (nPos >= 0)
    1117             :     {
    1118             :         // Replace '%1' with the object name.
    1119           0 :         XubString aObjName;
    1120           0 :         TakeObjNameSingul(aObjName);
    1121           0 :         rStr = rStr.replaceAt(nPos, 2, aObjName);
    1122             :     }
    1123             : 
    1124           0 :     nPos = rStr.indexOf("%2");
    1125           0 :     if (nPos >= 0)
    1126             :         // Replace '%2' with the passed value.
    1127           0 :         rStr = rStr.replaceAt(
    1128           0 :             nPos, 2, OUString::number(nVal));
    1129           0 : }
    1130             : 
    1131       24155 : void SdrObject::ImpForcePlusData()
    1132             : {
    1133       24155 :     if (!pPlusData)
    1134       23947 :         pPlusData = NewPlusData();
    1135       24155 : }
    1136             : 
    1137           0 : OUString SdrObject::GetWinkStr(long nWink, bool bNoDegChar) const
    1138             : {
    1139           0 :     OUString aStr;
    1140           0 :     if (pModel!=NULL) {
    1141           0 :         pModel->TakeWinkStr(nWink,aStr,bNoDegChar);
    1142             :     }
    1143           0 :     return aStr;
    1144             : }
    1145             : 
    1146           0 : OUString SdrObject::GetMetrStr(long nVal, MapUnit /*eWantMap*/, bool bNoUnitChars) const
    1147             : {
    1148           0 :     OUString aStr;
    1149           0 :     if (pModel!=NULL) {
    1150           0 :         pModel->TakeMetricStr(nVal,aStr,bNoUnitChars);
    1151             :     }
    1152           0 :     return aStr;
    1153             : }
    1154             : 
    1155           0 : basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
    1156             : {
    1157           0 :     basegfx::B2DPolyPolygon aRetval;
    1158           0 :     const Rectangle aR(GetCurrentBoundRect());
    1159           0 :     const basegfx::B2DRange aRange(aR.Left(), aR.Top(), aR.Right(), aR.Bottom());
    1160           0 :     aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
    1161             : 
    1162           0 :     return aRetval;
    1163             : }
    1164             : 
    1165           0 : basegfx::B2DPolyPolygon SdrObject::TakeContour() const
    1166             : {
    1167           0 :     basegfx::B2DPolyPolygon aRetval;
    1168             : 
    1169             :     // create cloned object without text, but with XLINE_SOLID,
    1170             :     // COL_BLACK as line color and XFILL_NONE
    1171           0 :     SdrObject* pClone = Clone();
    1172             : 
    1173           0 :     if(pClone)
    1174             :     {
    1175           0 :         const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(this);
    1176             : 
    1177           0 :         if(pTextObj)
    1178             :         {
    1179             :             // no text and no text animation
    1180           0 :             pClone->SetMergedItem(SdrTextAniKindItem(SDRTEXTANI_NONE));
    1181           0 :             pClone->SetOutlinerParaObject(0);
    1182             :         }
    1183             : 
    1184           0 :         const SdrEdgeObj* pEdgeObj = dynamic_cast< const SdrEdgeObj* >(this);
    1185             : 
    1186           0 :         if(pEdgeObj)
    1187             :         {
    1188             :             // create connections if connector, will be cleaned up when
    1189             :             // deleting the connector again
    1190           0 :             SdrObject* pLeft = pEdgeObj->GetConnectedNode(true);
    1191           0 :             SdrObject* pRight = pEdgeObj->GetConnectedNode(false);
    1192             : 
    1193           0 :             if(pLeft)
    1194             :             {
    1195           0 :                 pClone->ConnectToNode(true, pLeft);
    1196             :             }
    1197             : 
    1198           0 :             if(pRight)
    1199             :             {
    1200           0 :                 pClone->ConnectToNode(false, pRight);
    1201             :             }
    1202             :         }
    1203             : 
    1204           0 :         SfxItemSet aNewSet(*GetObjectItemPool());
    1205             : 
    1206             :         // #i101980# ignore LineWidth; that's what the old implementation
    1207             :         // did. With line width, the result may be huge due to fat/thick
    1208             :         // line decompositions
    1209           0 :         aNewSet.Put(XLineWidthItem(0));
    1210             : 
    1211             :         // solid black lines and no fill
    1212           0 :         aNewSet.Put(XLineStyleItem(XLINE_SOLID));
    1213           0 :         aNewSet.Put(XLineColorItem(String(), Color(COL_BLACK)));
    1214           0 :         aNewSet.Put(XFillStyleItem(XFILL_NONE));
    1215           0 :         pClone->SetMergedItemSet(aNewSet);
    1216             : 
    1217             :         // get sequence from clone
    1218           0 :         const sdr::contact::ViewContact& rVC(pClone->GetViewContact());
    1219           0 :         const drawinglayer::primitive2d::Primitive2DSequence xSequence(rVC.getViewIndependentPrimitive2DSequence());
    1220             : 
    1221           0 :         if(xSequence.hasElements())
    1222             :         {
    1223             :             // use neutral ViewInformation
    1224           0 :             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
    1225             : 
    1226             :             // create extractor, process and get result (with hairlines as opened polygons)
    1227           0 :             drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D, false);
    1228           0 :             aExtractor.process(xSequence);
    1229           0 :             const basegfx::B2DPolyPolygonVector& rResult(aExtractor.getExtractedContour());
    1230           0 :             const sal_uInt32 nSize(rResult.size());
    1231             : 
    1232             :             // when count is one, it is implied that the object has only its normal
    1233             :             // contour anyways and TakeCountour() is to return an empty PolyPolygon
    1234             :             // (see old implementation for historical reasons)
    1235           0 :             if(nSize > 1)
    1236             :             {
    1237             :                 // the topology for contour is correctly a vector of PolyPolygons; for
    1238             :                 // historical reasons cut it back to a single PolyPolygon here
    1239           0 :                 for(sal_uInt32 a(0); a < nSize; a++)
    1240             :                 {
    1241           0 :                     aRetval.append(rResult[a]);
    1242             :                 }
    1243           0 :             }
    1244             :         }
    1245             : 
    1246           0 :         delete pClone;
    1247             :     }
    1248             : 
    1249           0 :     return aRetval;
    1250             : }
    1251             : 
    1252           0 : sal_uInt32 SdrObject::GetHdlCount() const
    1253             : {
    1254           0 :     return 8L;
    1255             : }
    1256             : 
    1257           0 : SdrHdl* SdrObject::GetHdl(sal_uInt32 nHdlNum) const
    1258             : {
    1259           0 :     SdrHdl* pH=NULL;
    1260           0 :     const Rectangle& rR=GetSnapRect();
    1261           0 :     switch (nHdlNum) {
    1262           0 :         case 0: pH=new SdrHdl(rR.TopLeft(),     HDL_UPLFT); break;
    1263           0 :         case 1: pH=new SdrHdl(rR.TopCenter(),   HDL_UPPER); break;
    1264           0 :         case 2: pH=new SdrHdl(rR.TopRight(),    HDL_UPRGT); break;
    1265           0 :         case 3: pH=new SdrHdl(rR.LeftCenter(),  HDL_LEFT ); break;
    1266           0 :         case 4: pH=new SdrHdl(rR.RightCenter(), HDL_RIGHT); break;
    1267           0 :         case 5: pH=new SdrHdl(rR.BottomLeft(),  HDL_LWLFT); break;
    1268           0 :         case 6: pH=new SdrHdl(rR.BottomCenter(),HDL_LOWER); break;
    1269           0 :         case 7: pH=new SdrHdl(rR.BottomRight(), HDL_LWRGT); break;
    1270             :     }
    1271           0 :     return pH;
    1272             : }
    1273             : 
    1274           0 : sal_uInt32 SdrObject::GetPlusHdlCount(const SdrHdl& /*rHdl*/) const
    1275             : {
    1276           0 :     return 0L;
    1277             : }
    1278             : 
    1279           0 : SdrHdl* SdrObject::GetPlusHdl(const SdrHdl& /*rHdl*/, sal_uInt32 /*nPlNum*/) const
    1280             : {
    1281           0 :     return 0L;
    1282             : }
    1283             : 
    1284          24 : void SdrObject::AddToHdlList(SdrHdlList& rHdlList) const
    1285             : {
    1286          24 :     sal_uInt32 nAnz=GetHdlCount();
    1287         228 :     for (sal_uInt32 i=0L; i<nAnz; i++) {
    1288         204 :         SdrHdl* pHdl=GetHdl(i);
    1289         204 :         if (pHdl!=NULL) {
    1290         204 :             rHdlList.AddHdl(pHdl);
    1291             :         }
    1292             :     }
    1293          24 : }
    1294             : 
    1295           0 : Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const
    1296             : {
    1297           0 :     Rectangle aTmpRect(GetSnapRect());
    1298           0 :     Rectangle aRect(aTmpRect);
    1299           0 :     const SdrHdl* pHdl=rDrag.GetHdl();
    1300           0 :     SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
    1301           0 :     bool bEcke=(eHdl==HDL_UPLFT || eHdl==HDL_UPRGT || eHdl==HDL_LWLFT || eHdl==HDL_LWRGT);
    1302           0 :     bool bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
    1303           0 :     bool bBigOrtho=bEcke && bOrtho && rDrag.GetView()->IsBigOrtho();
    1304           0 :     Point aPos(rDrag.GetNow());
    1305           0 :     bool bLft=(eHdl==HDL_UPLFT || eHdl==HDL_LEFT  || eHdl==HDL_LWLFT);
    1306           0 :     bool bRgt=(eHdl==HDL_UPRGT || eHdl==HDL_RIGHT || eHdl==HDL_LWRGT);
    1307           0 :     bool bTop=(eHdl==HDL_UPRGT || eHdl==HDL_UPPER || eHdl==HDL_UPLFT);
    1308           0 :     bool bBtm=(eHdl==HDL_LWRGT || eHdl==HDL_LOWER || eHdl==HDL_LWLFT);
    1309           0 :     if (bLft) aTmpRect.Left()  =aPos.X();
    1310           0 :     if (bRgt) aTmpRect.Right() =aPos.X();
    1311           0 :     if (bTop) aTmpRect.Top()   =aPos.Y();
    1312           0 :     if (bBtm) aTmpRect.Bottom()=aPos.Y();
    1313           0 :     if (bOrtho) { // Ortho
    1314           0 :         long nWdt0=aRect.Right() -aRect.Left();
    1315           0 :         long nHgt0=aRect.Bottom()-aRect.Top();
    1316           0 :         long nXMul=aTmpRect.Right() -aTmpRect.Left();
    1317           0 :         long nYMul=aTmpRect.Bottom()-aTmpRect.Top();
    1318           0 :         long nXDiv=nWdt0;
    1319           0 :         long nYDiv=nHgt0;
    1320           0 :         bool bXNeg=(nXMul<0)!=(nXDiv<0);
    1321           0 :         bool bYNeg=(nYMul<0)!=(nYDiv<0);
    1322           0 :         nXMul=std::abs(nXMul);
    1323           0 :         nYMul=std::abs(nYMul);
    1324           0 :         nXDiv=std::abs(nXDiv);
    1325           0 :         nYDiv=std::abs(nYDiv);
    1326           0 :         Fraction aXFact(nXMul,nXDiv); // fractions for canceling
    1327           0 :         Fraction aYFact(nYMul,nYDiv); // and for comparing
    1328           0 :         nXMul=aXFact.GetNumerator();
    1329           0 :         nYMul=aYFact.GetNumerator();
    1330           0 :         nXDiv=aXFact.GetDenominator();
    1331           0 :         nYDiv=aYFact.GetDenominator();
    1332           0 :         if (bEcke) { // corner point handles
    1333           0 :             bool bUseX=(aXFact<aYFact) != bBigOrtho;
    1334           0 :             if (bUseX) {
    1335           0 :                 long nNeed=long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv));
    1336           0 :                 if (bYNeg) nNeed=-nNeed;
    1337           0 :                 if (bTop) aTmpRect.Top()=aTmpRect.Bottom()-nNeed;
    1338           0 :                 if (bBtm) aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
    1339             :             } else {
    1340           0 :                 long nNeed=long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv));
    1341           0 :                 if (bXNeg) nNeed=-nNeed;
    1342           0 :                 if (bLft) aTmpRect.Left()=aTmpRect.Right()-nNeed;
    1343           0 :                 if (bRgt) aTmpRect.Right()=aTmpRect.Left()+nNeed;
    1344             :             }
    1345             :         } else { // apex handles
    1346           0 :             if ((bLft || bRgt) && nXDiv!=0) {
    1347           0 :                 long nHgt0b=aRect.Bottom()-aRect.Top();
    1348           0 :                 long nNeed=long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv));
    1349           0 :                 aTmpRect.Top()-=(nNeed-nHgt0b)/2;
    1350           0 :                 aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
    1351             :             }
    1352           0 :             if ((bTop || bBtm) && nYDiv!=0) {
    1353           0 :                 long nWdt0b=aRect.Right()-aRect.Left();
    1354           0 :                 long nNeed=long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv));
    1355           0 :                 aTmpRect.Left()-=(nNeed-nWdt0b)/2;
    1356           0 :                 aTmpRect.Right()=aTmpRect.Left()+nNeed;
    1357             :             }
    1358             :         }
    1359             :     }
    1360           0 :     aTmpRect.Justify();
    1361           0 :     return aTmpRect;
    1362             : }
    1363             : 
    1364             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1365             : 
    1366          17 : bool SdrObject::hasSpecialDrag() const
    1367             : {
    1368          17 :     return false;
    1369             : }
    1370             : 
    1371           0 : bool SdrObject::supportsFullDrag() const
    1372             : {
    1373           0 :     return true;
    1374             : }
    1375             : 
    1376           0 : SdrObject* SdrObject::getFullDragClone() const
    1377             : {
    1378             :     // default uses simple clone
    1379           0 :     return Clone();
    1380             : }
    1381             : 
    1382           0 : bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
    1383             : {
    1384           0 :     const SdrHdl* pHdl = rDrag.GetHdl();
    1385             : 
    1386           0 :     SdrHdlKind eHdl = (pHdl == NULL) ? HDL_MOVE : pHdl->GetKind();
    1387             : 
    1388           0 :     if(eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT ||
    1389           0 :         eHdl==HDL_LEFT || eHdl==HDL_RIGHT || eHdl==HDL_LWLFT ||
    1390           0 :         eHdl==HDL_LOWER || eHdl==HDL_LWRGT)
    1391             :     {
    1392           0 :         return true;
    1393             :     }
    1394             : 
    1395           0 :     return false;
    1396             : }
    1397             : 
    1398           0 : bool SdrObject::applySpecialDrag(SdrDragStat& rDrag)
    1399             : {
    1400           0 :     Rectangle aNewRect(ImpDragCalcRect(rDrag));
    1401             : 
    1402           0 :     if(aNewRect != GetSnapRect())
    1403             :     {
    1404           0 :            NbcSetSnapRect(aNewRect);
    1405             :     }
    1406             : 
    1407           0 :     return true;
    1408             : }
    1409             : 
    1410           0 : String SdrObject::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
    1411             : {
    1412           0 :     return String();
    1413             : }
    1414             : 
    1415           0 : basegfx::B2DPolyPolygon SdrObject::getSpecialDragPoly(const SdrDragStat& /*rDrag*/) const
    1416             : {
    1417             :     // default has nothing to add
    1418           0 :     return basegfx::B2DPolyPolygon();
    1419             : }
    1420             : 
    1421             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1422             : // Create
    1423           0 : bool SdrObject::BegCreate(SdrDragStat& rStat)
    1424             : {
    1425           0 :     rStat.SetOrtho4Possible();
    1426           0 :     Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
    1427           0 :     aRect1.Justify();
    1428           0 :     rStat.SetActionRect(aRect1);
    1429           0 :     aOutRect = aRect1;
    1430           0 :     return true;
    1431             : }
    1432             : 
    1433           0 : bool SdrObject::MovCreate(SdrDragStat& rStat)
    1434             : {
    1435           0 :     rStat.TakeCreateRect(aOutRect);
    1436           0 :     rStat.SetActionRect(aOutRect);
    1437           0 :     aOutRect.Justify();
    1438             : 
    1439           0 :     return true;
    1440             : }
    1441             : 
    1442           0 : bool SdrObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
    1443             : {
    1444           0 :     rStat.TakeCreateRect(aOutRect);
    1445           0 :     aOutRect.Justify();
    1446             : 
    1447           0 :     return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
    1448             : }
    1449             : 
    1450           0 : void SdrObject::BrkCreate(SdrDragStat& /*rStat*/)
    1451             : {
    1452           0 : }
    1453             : 
    1454           0 : bool SdrObject::BckCreate(SdrDragStat& /*rStat*/)
    1455             : {
    1456           0 :     return false;
    1457             : }
    1458             : 
    1459           0 : basegfx::B2DPolyPolygon SdrObject::TakeCreatePoly(const SdrDragStat& rDrag) const
    1460             : {
    1461           0 :     Rectangle aRect1;
    1462           0 :     rDrag.TakeCreateRect(aRect1);
    1463           0 :     aRect1.Justify();
    1464             : 
    1465           0 :     basegfx::B2DPolyPolygon aRetval;
    1466           0 :     const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
    1467           0 :     aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
    1468           0 :     return aRetval;
    1469             : }
    1470             : 
    1471           0 : Pointer SdrObject::GetCreatePointer() const
    1472             : {
    1473           0 :     return Pointer(POINTER_CROSS);
    1474             : }
    1475             : 
    1476             : // transformations
    1477           0 : void SdrObject::NbcMove(const Size& rSiz)
    1478             : {
    1479           0 :     MoveRect(aOutRect,rSiz);
    1480           0 :     SetRectsDirty();
    1481           0 : }
    1482             : 
    1483           0 : void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
    1484             : {
    1485           0 :     bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
    1486           0 :     bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
    1487           0 :     if (bXMirr || bYMirr) {
    1488           0 :         Point aRef1(GetSnapRect().Center());
    1489           0 :         if (bXMirr) {
    1490           0 :             Point aRef2(aRef1);
    1491           0 :             aRef2.Y()++;
    1492           0 :             NbcMirrorGluePoints(aRef1,aRef2);
    1493             :         }
    1494           0 :         if (bYMirr) {
    1495           0 :             Point aRef2(aRef1);
    1496           0 :             aRef2.X()++;
    1497           0 :             NbcMirrorGluePoints(aRef1,aRef2);
    1498             :         }
    1499             :     }
    1500           0 :     ResizeRect(aOutRect,rRef,xFact,yFact);
    1501           0 :     SetRectsDirty();
    1502           0 : }
    1503             : 
    1504           0 : void SdrObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
    1505             : {
    1506           0 :     SetGlueReallyAbsolute(true);
    1507           0 :     aOutRect.Move(-rRef.X(),-rRef.Y());
    1508           0 :     Rectangle R(aOutRect);
    1509           0 :     if (sn==1.0 && cs==0.0) { // 90deg
    1510           0 :         aOutRect.Left()  =-R.Bottom();
    1511           0 :         aOutRect.Right() =-R.Top();
    1512           0 :         aOutRect.Top()   =R.Left();
    1513           0 :         aOutRect.Bottom()=R.Right();
    1514           0 :     } else if (sn==0.0 && cs==-1.0) { // 180deg
    1515           0 :         aOutRect.Left()  =-R.Right();
    1516           0 :         aOutRect.Right() =-R.Left();
    1517           0 :         aOutRect.Top()   =-R.Bottom();
    1518           0 :         aOutRect.Bottom()=-R.Top();
    1519           0 :     } else if (sn==-1.0 && cs==0.0) { // 270deg
    1520           0 :         aOutRect.Left()  =R.Top();
    1521           0 :         aOutRect.Right() =R.Bottom();
    1522           0 :         aOutRect.Top()   =-R.Right();
    1523           0 :         aOutRect.Bottom()=-R.Left();
    1524             :     }
    1525           0 :     aOutRect.Move(rRef.X(),rRef.Y());
    1526           0 :     aOutRect.Justify(); // just in case
    1527           0 :     SetRectsDirty();
    1528           0 :     NbcRotateGluePoints(rRef,nWink,sn,cs);
    1529           0 :     SetGlueReallyAbsolute(false);
    1530           0 : }
    1531             : 
    1532           0 : void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2)
    1533             : {
    1534           0 :     SetGlueReallyAbsolute(true);
    1535           0 :     aOutRect.Move(-rRef1.X(),-rRef1.Y());
    1536           0 :     Rectangle R(aOutRect);
    1537           0 :     long dx=rRef2.X()-rRef1.X();
    1538           0 :     long dy=rRef2.Y()-rRef1.Y();
    1539           0 :     if (dx==0) {          // vertical axis
    1540           0 :         aOutRect.Left() =-R.Right();
    1541           0 :         aOutRect.Right()=-R.Left();
    1542           0 :     } else if (dy==0) {   // horizontal axis
    1543           0 :         aOutRect.Top()   =-R.Bottom();
    1544           0 :         aOutRect.Bottom()=-R.Top();
    1545           0 :     } else if (dx==dy) {  // 45deg axis
    1546           0 :         aOutRect.Left()  =R.Top();
    1547           0 :         aOutRect.Right() =R.Bottom();
    1548           0 :         aOutRect.Top()   =R.Left();
    1549           0 :         aOutRect.Bottom()=R.Right();
    1550           0 :     } else if (dx==-dy) { // 45deg axis
    1551           0 :         aOutRect.Left()  =-R.Bottom();
    1552           0 :         aOutRect.Right() =-R.Top();
    1553           0 :         aOutRect.Top()   =-R.Right();
    1554           0 :         aOutRect.Bottom()=-R.Left();
    1555             :     }
    1556           0 :     aOutRect.Move(rRef1.X(),rRef1.Y());
    1557           0 :     aOutRect.Justify(); // just in case
    1558           0 :     SetRectsDirty();
    1559           0 :     NbcMirrorGluePoints(rRef1,rRef2);
    1560           0 :     SetGlueReallyAbsolute(false);
    1561           0 : }
    1562             : 
    1563           0 : void SdrObject::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
    1564             : {
    1565           0 :     SetGlueReallyAbsolute(true);
    1566           0 :     NbcShearGluePoints(rRef,nWink,tn,bVShear);
    1567           0 :     SetGlueReallyAbsolute(false);
    1568           0 : }
    1569             : 
    1570       75831 : void SdrObject::Move(const Size& rSiz)
    1571             : {
    1572       75831 :     if (rSiz.Width()!=0 || rSiz.Height()!=0) {
    1573       30724 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1574       30724 :         NbcMove(rSiz);
    1575       30724 :         SetChanged();
    1576       30724 :         BroadcastObjectChange();
    1577       30724 :         SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
    1578             :     }
    1579       75831 : }
    1580             : 
    1581          29 : void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
    1582             : {
    1583          29 :     if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
    1584          29 :         if (bUnsetRelative)
    1585             :         {
    1586          27 :             mnRelativeWidth.reset( );
    1587          27 :             mnRelativeHeight.reset( );
    1588             :         }
    1589          29 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1590          29 :         NbcResize(rRef,xFact,yFact);
    1591          29 :         SetChanged();
    1592          29 :         BroadcastObjectChange();
    1593          29 :         SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1594             :     }
    1595          29 : }
    1596             : 
    1597         395 : void SdrObject::Rotate(const Point& rRef, long nWink, double sn, double cs)
    1598             : {
    1599         395 :     if (nWink!=0) {
    1600         395 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1601         395 :         NbcRotate(rRef,nWink,sn,cs);
    1602         395 :         SetChanged();
    1603         395 :         BroadcastObjectChange();
    1604         395 :         SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1605             :     }
    1606         395 : }
    1607             : 
    1608           2 : void SdrObject::Mirror(const Point& rRef1, const Point& rRef2)
    1609             : {
    1610           2 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1611           2 :     NbcMirror(rRef1,rRef2);
    1612           2 :     SetChanged();
    1613           2 :     BroadcastObjectChange();
    1614           2 :     SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1615           2 : }
    1616             : 
    1617           0 : void SdrObject::Shear(const Point& rRef, long nWink, double tn, bool bVShear)
    1618             : {
    1619           0 :     if (nWink!=0) {
    1620           0 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1621           0 :         NbcShear(rRef,nWink,tn,bVShear);
    1622           0 :         SetChanged();
    1623           0 :         BroadcastObjectChange();
    1624           0 :         SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1625             :     }
    1626           0 : }
    1627             : 
    1628           0 : void SdrObject::NbcSetRelativePos(const Point& rPnt)
    1629             : {
    1630           0 :     Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
    1631           0 :     Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
    1632           0 :     NbcMove(aSiz); // This also calls SetRectsDirty()
    1633           0 : }
    1634             : 
    1635           0 : void SdrObject::SetRelativePos(const Point& rPnt)
    1636             : {
    1637           0 :     if (rPnt!=GetRelativePos()) {
    1638           0 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1639           0 :         NbcSetRelativePos(rPnt);
    1640           0 :         SetChanged();
    1641           0 :         BroadcastObjectChange();
    1642           0 :         SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
    1643             :     }
    1644           0 : }
    1645             : 
    1646           0 : Point SdrObject::GetRelativePos() const
    1647             : {
    1648           0 :     return GetSnapRect().TopLeft()-aAnchor;
    1649             : }
    1650             : 
    1651          20 : void SdrObject::ImpSetAnchorPos(const Point& rPnt)
    1652             : {
    1653          20 :     aAnchor = rPnt;
    1654          20 : }
    1655             : 
    1656         675 : void SdrObject::NbcSetAnchorPos(const Point& rPnt)
    1657             : {
    1658         675 :     Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
    1659         675 :     aAnchor=rPnt;
    1660         675 :     NbcMove(aSiz); // This also calls SetRectsDirty()
    1661         675 : }
    1662             : 
    1663        1163 : void SdrObject::SetAnchorPos(const Point& rPnt)
    1664             : {
    1665        1163 :     if (rPnt!=aAnchor) {
    1666         675 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1667         675 :         NbcSetAnchorPos(rPnt);
    1668         675 :         SetChanged();
    1669         675 :         BroadcastObjectChange();
    1670         675 :         SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
    1671             :     }
    1672        1163 : }
    1673             : 
    1674       47138 : const Point& SdrObject::GetAnchorPos() const
    1675             : {
    1676       47138 :     return aAnchor;
    1677             : }
    1678             : 
    1679           0 : void SdrObject::RecalcSnapRect()
    1680             : {
    1681           0 : }
    1682             : 
    1683         538 : const Rectangle& SdrObject::GetSnapRect() const
    1684             : {
    1685         538 :     return aOutRect;
    1686             : }
    1687             : 
    1688        3596 : void SdrObject::NbcSetSnapRect(const Rectangle& rRect)
    1689             : {
    1690        3596 :     aOutRect=rRect;
    1691        3596 : }
    1692             : 
    1693        2896 : const Rectangle& SdrObject::GetLogicRect() const
    1694             : {
    1695        2896 :     return GetSnapRect();
    1696             : }
    1697             : 
    1698        2008 : void SdrObject::NbcSetLogicRect(const Rectangle& rRect)
    1699             : {
    1700        2008 :     NbcSetSnapRect(rRect);
    1701        2008 : }
    1702             : 
    1703         295 : void SdrObject::AdjustToMaxRect( const Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
    1704             : {
    1705         295 :     SetLogicRect( rMaxRect );
    1706         295 : }
    1707             : 
    1708       55209 : void SdrObject::SetSnapRect(const Rectangle& rRect)
    1709             : {
    1710       55209 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1711       55209 :     NbcSetSnapRect(rRect);
    1712       55209 :     SetChanged();
    1713       55209 :     BroadcastObjectChange();
    1714       55209 :     SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1715       55209 : }
    1716             : 
    1717       30381 : void SdrObject::SetLogicRect(const Rectangle& rRect)
    1718             : {
    1719       30381 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1720       30381 :     NbcSetLogicRect(rRect);
    1721       30381 :     SetChanged();
    1722       30381 :     BroadcastObjectChange();
    1723       30381 :     SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1724       30381 : }
    1725             : 
    1726           0 : long SdrObject::GetRotateAngle() const
    1727             : {
    1728           0 :     return 0;
    1729             : }
    1730             : 
    1731           0 : long SdrObject::GetShearAngle(bool /*bVertical*/) const
    1732             : {
    1733           0 :     return 0;
    1734             : }
    1735             : 
    1736           0 : sal_uInt32 SdrObject::GetSnapPointCount() const
    1737             : {
    1738           0 :     return GetPointCount();
    1739             : }
    1740             : 
    1741           0 : Point SdrObject::GetSnapPoint(sal_uInt32 i) const
    1742             : {
    1743           0 :     return GetPoint(i);
    1744             : }
    1745             : 
    1746         103 : sal_Bool SdrObject::IsPolyObj() const
    1747             : {
    1748         103 :     return false;
    1749             : }
    1750             : 
    1751           0 : sal_uInt32 SdrObject::GetPointCount() const
    1752             : {
    1753           0 :     return 0L;
    1754             : }
    1755             : 
    1756           0 : Point SdrObject::GetPoint(sal_uInt32 /*i*/) const
    1757             : {
    1758           0 :     return Point();
    1759             : }
    1760             : 
    1761           0 : void SdrObject::SetPoint(const Point& rPnt, sal_uInt32 i)
    1762             : {
    1763           0 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1764           0 :     NbcSetPoint(rPnt, i);
    1765           0 :     SetChanged();
    1766           0 :     BroadcastObjectChange();
    1767           0 :     SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1768           0 : }
    1769             : 
    1770           0 : void SdrObject::NbcSetPoint(const Point& /*rPnt*/, sal_uInt32 /*i*/)
    1771             : {
    1772           0 : }
    1773             : 
    1774           0 : bool SdrObject::HasTextEdit() const
    1775             : {
    1776           0 :     return false;
    1777             : }
    1778             : 
    1779           0 : sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
    1780             : {
    1781           0 :     return false;
    1782             : }
    1783             : 
    1784           0 : void SdrObject::EndTextEdit(SdrOutliner& /*rOutl*/)
    1785             : {
    1786           0 : }
    1787             : 
    1788        1313 : void SdrObject::SetOutlinerParaObject(OutlinerParaObject* pTextObject)
    1789             : {
    1790        1313 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1791        1313 :     NbcSetOutlinerParaObject(pTextObject);
    1792        1313 :     SetChanged();
    1793        1313 :     BroadcastObjectChange();
    1794        1313 :     if (GetCurrentBoundRect()!=aBoundRect0) {
    1795         353 :         SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1796             :     }
    1797        1313 : }
    1798             : 
    1799           0 : void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject* /*pTextObject*/)
    1800             : {
    1801           0 : }
    1802             : 
    1803         524 : OutlinerParaObject* SdrObject::GetOutlinerParaObject() const
    1804             : {
    1805         524 :     return NULL;
    1806             : }
    1807             : 
    1808          24 : void SdrObject::NbcReformatText()
    1809             : {
    1810          24 : }
    1811             : 
    1812           0 : void SdrObject::ReformatText()
    1813             : {
    1814           0 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1815           0 :     NbcReformatText();
    1816           0 :     SetChanged();
    1817           0 :     BroadcastObjectChange();
    1818           0 :     if (GetCurrentBoundRect()!=aBoundRect0) {
    1819           0 :         SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1820             :     }
    1821           0 : }
    1822             : 
    1823           0 : void SdrObject::BurnInStyleSheetAttributes()
    1824             : {
    1825           0 :     GetProperties().ForceStyleToHardAttributes();
    1826           0 : }
    1827             : 
    1828           0 : SdrObjUserData* SdrObject::ImpGetMacroUserData() const
    1829             : {
    1830           0 :     SdrObjUserData* pData=NULL;
    1831           0 :     sal_uInt16 nAnz=GetUserDataCount();
    1832           0 :     for (sal_uInt16 nNum=nAnz; nNum>0 && pData==NULL;) {
    1833           0 :         nNum--;
    1834           0 :         pData=GetUserData(nNum);
    1835           0 :         if (!pData->HasMacro(this)) pData=NULL;
    1836             :     }
    1837           0 :     return pData;
    1838             : }
    1839             : 
    1840           0 : bool SdrObject::HasMacro() const
    1841             : {
    1842           0 :     SdrObjUserData* pData=ImpGetMacroUserData();
    1843           0 :     return pData!=NULL ? pData->HasMacro(this) : false;
    1844             : }
    1845             : 
    1846           0 : SdrObject* SdrObject::CheckMacroHit(const SdrObjMacroHitRec& rRec) const
    1847             : {
    1848           0 :     SdrObjUserData* pData = ImpGetMacroUserData();
    1849             : 
    1850           0 :     if(pData)
    1851             :     {
    1852           0 :         return pData->CheckMacroHit(rRec, this);
    1853             :     }
    1854             : 
    1855           0 :     if(rRec.pPageView)
    1856             :     {
    1857           0 :         return SdrObjectPrimitiveHit(*this, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
    1858             :     }
    1859             : 
    1860           0 :     return 0;
    1861             : }
    1862             : 
    1863           0 : Pointer SdrObject::GetMacroPointer(const SdrObjMacroHitRec& rRec) const
    1864             : {
    1865           0 :     SdrObjUserData* pData=ImpGetMacroUserData();
    1866           0 :     if (pData!=NULL) {
    1867           0 :         return pData->GetMacroPointer(rRec,this);
    1868             :     }
    1869           0 :     return Pointer(POINTER_REFHAND);
    1870             : }
    1871             : 
    1872           0 : void SdrObject::PaintMacro(OutputDevice& rOut, const Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const
    1873             : {
    1874           0 :     SdrObjUserData* pData=ImpGetMacroUserData();
    1875             : 
    1876           0 :     if(pData)
    1877             :     {
    1878           0 :         pData->PaintMacro(rOut,rDirtyRect,rRec,this);
    1879             :     }
    1880             :     else
    1881             :     {
    1882           0 :         const RasterOp eRop(rOut.GetRasterOp());
    1883           0 :         const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly());
    1884           0 :         const sal_uInt32 nCount(aPolyPolygon.count());
    1885             : 
    1886           0 :         rOut.SetLineColor(COL_BLACK);
    1887           0 :         rOut.SetFillColor();
    1888           0 :         rOut.SetRasterOp(ROP_INVERT);
    1889             : 
    1890           0 :         for(sal_uInt32 a(0); a < nCount; a++)
    1891             :         {
    1892           0 :             rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
    1893             :         }
    1894             : 
    1895           0 :         rOut.SetRasterOp(eRop);
    1896             :     }
    1897           0 : }
    1898             : 
    1899           0 : bool SdrObject::DoMacro(const SdrObjMacroHitRec& rRec)
    1900             : {
    1901           0 :     SdrObjUserData* pData=ImpGetMacroUserData();
    1902           0 :     if (pData!=NULL) {
    1903           0 :         return pData->DoMacro(rRec,this);
    1904             :     }
    1905           0 :     return false;
    1906             : }
    1907             : 
    1908           0 : OUString SdrObject::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
    1909             : {
    1910           0 :     SdrObjUserData* pData=ImpGetMacroUserData();
    1911           0 :     if (pData!=NULL) {
    1912           0 :         return pData->GetMacroPopupComment(rRec,this);
    1913             :     }
    1914           0 :     return OUString();
    1915             : }
    1916             : 
    1917           0 : bool SdrObject::IsMacroHit(const SdrObjMacroHitRec& rRec) const
    1918             : {
    1919           0 :     return CheckMacroHit(rRec) != NULL;
    1920             : }
    1921             : 
    1922             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1923             : 
    1924           0 : SdrObjGeoData* SdrObject::NewGeoData() const
    1925             : {
    1926           0 :     return new SdrObjGeoData;
    1927             : }
    1928             : 
    1929         187 : void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const
    1930             : {
    1931         187 :     rGeo.aBoundRect    =GetCurrentBoundRect();
    1932         187 :     rGeo.aAnchor       =aAnchor       ;
    1933         187 :     rGeo.bMovProt      =bMovProt      ;
    1934         187 :     rGeo.bSizProt      =bSizProt      ;
    1935         187 :     rGeo.bNoPrint      =bNoPrint      ;
    1936         187 :     rGeo.mbVisible     =mbVisible     ;
    1937         187 :     rGeo.bClosedObj    =bClosedObj    ;
    1938         187 :     rGeo.mnLayerID = mnLayerID;
    1939             : 
    1940             :     // user-defined glue points
    1941         187 :     if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
    1942           0 :         if (rGeo.pGPL!=NULL) {
    1943           0 :             *rGeo.pGPL=*pPlusData->pGluePoints;
    1944             :         } else {
    1945           0 :             rGeo.pGPL=new SdrGluePointList(*pPlusData->pGluePoints);
    1946             :         }
    1947             :     } else {
    1948         187 :         if (rGeo.pGPL!=NULL) {
    1949           0 :             delete rGeo.pGPL;
    1950           0 :             rGeo.pGPL=NULL;
    1951             :         }
    1952             :     }
    1953         187 : }
    1954             : 
    1955           0 : void SdrObject::RestGeoData(const SdrObjGeoData& rGeo)
    1956             : {
    1957           0 :     SetRectsDirty();
    1958           0 :     aOutRect      =rGeo.aBoundRect    ;
    1959           0 :     aAnchor       =rGeo.aAnchor       ;
    1960           0 :     bMovProt      =rGeo.bMovProt      ;
    1961           0 :     bSizProt      =rGeo.bSizProt      ;
    1962           0 :     bNoPrint      =rGeo.bNoPrint      ;
    1963           0 :     mbVisible     =rGeo.mbVisible     ;
    1964           0 :     bClosedObj    =rGeo.bClosedObj    ;
    1965           0 :     mnLayerID = rGeo.mnLayerID;
    1966             : 
    1967             :     // user-defined glue points
    1968           0 :     if (rGeo.pGPL!=NULL) {
    1969           0 :         ImpForcePlusData();
    1970           0 :         if (pPlusData->pGluePoints!=NULL) {
    1971           0 :             *pPlusData->pGluePoints=*rGeo.pGPL;
    1972             :         } else {
    1973           0 :             pPlusData->pGluePoints=new SdrGluePointList(*rGeo.pGPL);
    1974             :         }
    1975             :     } else {
    1976           0 :         if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
    1977           0 :             delete pPlusData->pGluePoints;
    1978           0 :             pPlusData->pGluePoints=NULL;
    1979             :         }
    1980             :     }
    1981           0 : }
    1982             : 
    1983           8 : SdrObjGeoData* SdrObject::GetGeoData() const
    1984             : {
    1985           8 :     SdrObjGeoData* pGeo=NewGeoData();
    1986           8 :     SaveGeoData(*pGeo);
    1987           8 :     return pGeo;
    1988             : }
    1989             : 
    1990           0 : void SdrObject::SetGeoData(const SdrObjGeoData& rGeo)
    1991             : {
    1992           0 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    1993           0 :     RestGeoData(rGeo);
    1994           0 :     SetChanged();
    1995           0 :     BroadcastObjectChange();
    1996           0 :     SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1997           0 : }
    1998             : 
    1999             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2000             : // ItemSet access
    2001             : 
    2002     1849199 : const SfxItemSet& SdrObject::GetObjectItemSet() const
    2003             : {
    2004     1849199 :     return GetProperties().GetObjectItemSet();
    2005             : }
    2006             : 
    2007      707370 : const SfxItemSet& SdrObject::GetMergedItemSet() const
    2008             : {
    2009      707370 :     return GetProperties().GetMergedItemSet();
    2010             : }
    2011             : 
    2012         884 : void SdrObject::SetObjectItem(const SfxPoolItem& rItem)
    2013             : {
    2014         884 :     GetProperties().SetObjectItem(rItem);
    2015         884 : }
    2016             : 
    2017       30365 : void SdrObject::SetMergedItem(const SfxPoolItem& rItem)
    2018             : {
    2019       30365 :     GetProperties().SetMergedItem(rItem);
    2020       30365 : }
    2021             : 
    2022         323 : void SdrObject::ClearMergedItem(const sal_uInt16 nWhich)
    2023             : {
    2024         323 :     GetProperties().ClearMergedItem(nWhich);
    2025         323 : }
    2026             : 
    2027           0 : void SdrObject::SetObjectItemSet(const SfxItemSet& rSet)
    2028             : {
    2029           0 :     GetProperties().SetObjectItemSet(rSet);
    2030           0 : }
    2031             : 
    2032        2942 : void SdrObject::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems)
    2033             : {
    2034        2942 :     GetProperties().SetMergedItemSet(rSet, bClearAllItems);
    2035        2942 : }
    2036             : 
    2037       47291 : const SfxPoolItem& SdrObject::GetObjectItem(const sal_uInt16 nWhich) const
    2038             : {
    2039       47291 :     return GetObjectItemSet().Get(nWhich);
    2040             : }
    2041             : 
    2042       32608 : SfxMapUnit SdrObject::GetObjectMapUnit() const
    2043             : {
    2044       32608 :     SfxMapUnit aRetval(SFX_MAPUNIT_100TH_MM);
    2045       32608 :     SdrItemPool* pPool = GetObjectItemPool();
    2046             : 
    2047       32608 :     if(pPool)
    2048             :     {
    2049       32608 :         aRetval = pPool->GetMetric(0);
    2050             :     }
    2051             :     else
    2052             :     {
    2053             :         OSL_ENSURE(pPool, "SdrObjects always need a pool (!)");
    2054             :     }
    2055             : 
    2056       32608 :     return aRetval;
    2057             : }
    2058             : 
    2059      630300 : const SfxPoolItem& SdrObject::GetMergedItem(const sal_uInt16 nWhich) const
    2060             : {
    2061      630300 :     return GetMergedItemSet().Get(nWhich);
    2062             : }
    2063             : 
    2064       50993 : void SdrObject::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
    2065             : {
    2066       50993 :     GetProperties().SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
    2067       50993 : }
    2068             : 
    2069          39 : void SdrObject::ApplyNotPersistAttr(const SfxItemSet& rAttr)
    2070             : {
    2071          39 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
    2072          39 :     NbcApplyNotPersistAttr(rAttr);
    2073          39 :     SetChanged();
    2074          39 :     BroadcastObjectChange();
    2075          39 :     SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    2076          39 : }
    2077             : 
    2078          39 : void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
    2079             : {
    2080          39 :     const Rectangle& rSnap=GetSnapRect();
    2081          39 :     const Rectangle& rLogic=GetLogicRect();
    2082          39 :     Point aRef1(rSnap.Center());
    2083          39 :     Point aRef2(aRef1); aRef2.Y()++;
    2084          39 :     const SfxPoolItem *pPoolItem=NULL;
    2085          39 :     if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,true,&pPoolItem)==SFX_ITEM_SET) {
    2086           0 :         aRef1.X()=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
    2087             :     }
    2088          39 :     if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,true,&pPoolItem)==SFX_ITEM_SET) {
    2089           0 :         aRef1.Y()=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
    2090             :     }
    2091          39 :     if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,true,&pPoolItem)==SFX_ITEM_SET) {
    2092           0 :         aRef2.X()=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
    2093             :     }
    2094          39 :     if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,true,&pPoolItem)==SFX_ITEM_SET) {
    2095           0 :         aRef2.Y()=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
    2096             :     }
    2097             : 
    2098          39 :     Rectangle aNewSnap(rSnap);
    2099          39 :     if (rAttr.GetItemState(SDRATTR_MOVEX,true,&pPoolItem)==SFX_ITEM_SET) {
    2100           0 :         long n=((const SdrMoveXItem*)pPoolItem)->GetValue();
    2101           0 :         aNewSnap.Move(n,0);
    2102             :     }
    2103          39 :     if (rAttr.GetItemState(SDRATTR_MOVEY,true,&pPoolItem)==SFX_ITEM_SET) {
    2104           0 :         long n=((const SdrMoveYItem*)pPoolItem)->GetValue();
    2105           0 :         aNewSnap.Move(0,n);
    2106             :     }
    2107          39 :     if (rAttr.GetItemState(SDRATTR_ONEPOSITIONX,true,&pPoolItem)==SFX_ITEM_SET) {
    2108           0 :         long n=((const SdrOnePositionXItem*)pPoolItem)->GetValue();
    2109           0 :         aNewSnap.Move(n-aNewSnap.Left(),0);
    2110             :     }
    2111          39 :     if (rAttr.GetItemState(SDRATTR_ONEPOSITIONY,true,&pPoolItem)==SFX_ITEM_SET) {
    2112           0 :         long n=((const SdrOnePositionYItem*)pPoolItem)->GetValue();
    2113           0 :         aNewSnap.Move(0,n-aNewSnap.Top());
    2114             :     }
    2115          39 :     if (rAttr.GetItemState(SDRATTR_ONESIZEWIDTH,true,&pPoolItem)==SFX_ITEM_SET) {
    2116           0 :         long n=((const SdrOneSizeWidthItem*)pPoolItem)->GetValue();
    2117           0 :         aNewSnap.Right()=aNewSnap.Left()+n;
    2118             :     }
    2119          39 :     if (rAttr.GetItemState(SDRATTR_ONESIZEHEIGHT,true,&pPoolItem)==SFX_ITEM_SET) {
    2120           0 :         long n=((const SdrOneSizeHeightItem*)pPoolItem)->GetValue();
    2121           0 :         aNewSnap.Bottom()=aNewSnap.Top()+n;
    2122             :     }
    2123          39 :     if (aNewSnap!=rSnap) {
    2124           0 :         if (aNewSnap.GetSize()==rSnap.GetSize()) {
    2125           0 :             NbcMove(Size(aNewSnap.Left()-rSnap.Left(),aNewSnap.Top()-rSnap.Top()));
    2126             :         } else {
    2127           0 :             NbcSetSnapRect(aNewSnap);
    2128             :         }
    2129             :     }
    2130             : 
    2131          39 :     if (rAttr.GetItemState(SDRATTR_SHEARANGLE,true,&pPoolItem)==SFX_ITEM_SET) {
    2132           0 :         long n=((const SdrShearAngleItem*)pPoolItem)->GetValue();
    2133           0 :         n-=GetShearAngle();
    2134           0 :         if (n!=0) {
    2135           0 :             double nTan=tan(n*nPi180);
    2136           0 :             NbcShear(aRef1,n,nTan,false);
    2137             :         }
    2138             :     }
    2139          39 :     if (rAttr.GetItemState(SDRATTR_ROTATEANGLE,true,&pPoolItem)==SFX_ITEM_SET) {
    2140           0 :         long n=((const SdrRotateAngleItem*)pPoolItem)->GetValue();
    2141           0 :         n-=GetRotateAngle();
    2142           0 :         if (n!=0) {
    2143           0 :             double nSin=sin(n*nPi180);
    2144           0 :             double nCos=cos(n*nPi180);
    2145           0 :             NbcRotate(aRef1,n,nSin,nCos);
    2146             :         }
    2147             :     }
    2148          39 :     if (rAttr.GetItemState(SDRATTR_ROTATEONE,true,&pPoolItem)==SFX_ITEM_SET) {
    2149           0 :         long n=((const SdrRotateOneItem*)pPoolItem)->GetValue();
    2150           0 :         double nSin=sin(n*nPi180);
    2151           0 :         double nCos=cos(n*nPi180);
    2152           0 :         NbcRotate(aRef1,n,nSin,nCos);
    2153             :     }
    2154          39 :     if (rAttr.GetItemState(SDRATTR_HORZSHEARONE,true,&pPoolItem)==SFX_ITEM_SET) {
    2155           0 :         long n=((const SdrHorzShearOneItem*)pPoolItem)->GetValue();
    2156           0 :         double nTan=tan(n*nPi180);
    2157           0 :         NbcShear(aRef1,n,nTan,false);
    2158             :     }
    2159          39 :     if (rAttr.GetItemState(SDRATTR_VERTSHEARONE,true,&pPoolItem)==SFX_ITEM_SET) {
    2160           0 :         long n=((const SdrVertShearOneItem*)pPoolItem)->GetValue();
    2161           0 :         double nTan=tan(n*nPi180);
    2162           0 :         NbcShear(aRef1,n,nTan,true);
    2163             :     }
    2164             : 
    2165          39 :     if (rAttr.GetItemState(SDRATTR_OBJMOVEPROTECT,true,&pPoolItem)==SFX_ITEM_SET) {
    2166           0 :         bool b=((const SdrObjMoveProtectItem*)pPoolItem)->GetValue();
    2167           0 :         SetMoveProtect(b);
    2168             :     }
    2169          39 :     if (rAttr.GetItemState(SDRATTR_OBJSIZEPROTECT,true,&pPoolItem)==SFX_ITEM_SET) {
    2170           0 :         bool b=((const SdrObjSizeProtectItem*)pPoolItem)->GetValue();
    2171           0 :         SetResizeProtect(b);
    2172             :     }
    2173             : 
    2174             :     /* move protect always sets size protect */
    2175          39 :     if( IsMoveProtect() )
    2176           0 :         SetResizeProtect( true );
    2177             : 
    2178          39 :     if (rAttr.GetItemState(SDRATTR_OBJPRINTABLE,true,&pPoolItem)==SFX_ITEM_SET) {
    2179           0 :         bool b=((const SdrObjPrintableItem*)pPoolItem)->GetValue();
    2180           0 :         SetPrintable(b);
    2181             :     }
    2182             : 
    2183          39 :     if (rAttr.GetItemState(SDRATTR_OBJVISIBLE,true,&pPoolItem)==SFX_ITEM_SET) {
    2184           0 :         bool b=((const SdrObjVisibleItem*)pPoolItem)->GetValue();
    2185           0 :         SetVisible(b);
    2186             :     }
    2187             : 
    2188          39 :     SdrLayerID nLayer=SDRLAYER_NOTFOUND;
    2189          39 :     if (rAttr.GetItemState(SDRATTR_LAYERID,true,&pPoolItem)==SFX_ITEM_SET) {
    2190           0 :         nLayer=((const SdrLayerIdItem*)pPoolItem)->GetValue();
    2191             :     }
    2192          39 :     if (rAttr.GetItemState(SDRATTR_LAYERNAME,true,&pPoolItem)==SFX_ITEM_SET && pModel!=NULL) {
    2193           0 :         XubString aLayerName=((const SdrLayerNameItem*)pPoolItem)->GetValue();
    2194           0 :         const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
    2195           0 :         if (pLayAd!=NULL) {
    2196           0 :             const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName, true);
    2197           0 :             if (pLayer!=NULL) {
    2198           0 :                 nLayer=pLayer->GetID();
    2199             :             }
    2200           0 :         }
    2201             : 
    2202             :     }
    2203          39 :     if (nLayer!=SDRLAYER_NOTFOUND) {
    2204           0 :         NbcSetLayer(nLayer);
    2205             :     }
    2206             : 
    2207          39 :     if (rAttr.GetItemState(SDRATTR_OBJECTNAME,true,&pPoolItem)==SFX_ITEM_SET) {
    2208          10 :         XubString aName=((const SdrObjectNameItem*)pPoolItem)->GetValue();
    2209          10 :         SetName(aName);
    2210             :     }
    2211          39 :     Rectangle aNewLogic(rLogic);
    2212          39 :     if (rAttr.GetItemState(SDRATTR_LOGICSIZEWIDTH,true,&pPoolItem)==SFX_ITEM_SET) {
    2213           0 :         long n=((const SdrLogicSizeWidthItem*)pPoolItem)->GetValue();
    2214           0 :         aNewLogic.Right()=aNewLogic.Left()+n;
    2215             :     }
    2216          39 :     if (rAttr.GetItemState(SDRATTR_LOGICSIZEHEIGHT,true,&pPoolItem)==SFX_ITEM_SET) {
    2217           0 :         long n=((const SdrLogicSizeHeightItem*)pPoolItem)->GetValue();
    2218           0 :         aNewLogic.Bottom()=aNewLogic.Top()+n;
    2219             :     }
    2220          39 :     if (aNewLogic!=rLogic) {
    2221           0 :         NbcSetLogicRect(aNewLogic);
    2222             :     }
    2223          39 :     Fraction aResizeX(1,1);
    2224          39 :     Fraction aResizeY(1,1);
    2225          39 :     if (rAttr.GetItemState(SDRATTR_RESIZEXONE,true,&pPoolItem)==SFX_ITEM_SET) {
    2226           0 :         aResizeX*=((const SdrResizeXOneItem*)pPoolItem)->GetValue();
    2227             :     }
    2228          39 :     if (rAttr.GetItemState(SDRATTR_RESIZEYONE,true,&pPoolItem)==SFX_ITEM_SET) {
    2229           0 :         aResizeY*=((const SdrResizeYOneItem*)pPoolItem)->GetValue();
    2230             :     }
    2231          39 :     if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) {
    2232           0 :         NbcResize(aRef1,aResizeX,aResizeY);
    2233             :     }
    2234          39 : }
    2235             : 
    2236           0 : static void lcl_SetItem(SfxItemSet& rAttr, bool bMerge, const SfxPoolItem& rItem)
    2237             : {
    2238           0 :     if (bMerge) rAttr.MergeValue(rItem,true);
    2239           0 :     else rAttr.Put(rItem);
    2240           0 : }
    2241             : 
    2242           0 : void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr, bool bMerge) const
    2243             : {
    2244           0 :     const Rectangle& rSnap=GetSnapRect();
    2245           0 :     const Rectangle& rLogic=GetLogicRect();
    2246           0 :     lcl_SetItem(rAttr,bMerge,SdrObjMoveProtectItem(IsMoveProtect()));
    2247           0 :     lcl_SetItem(rAttr,bMerge,SdrObjSizeProtectItem(IsResizeProtect()));
    2248           0 :     lcl_SetItem(rAttr,bMerge,SdrObjPrintableItem(IsPrintable()));
    2249           0 :     lcl_SetItem(rAttr,bMerge,SdrObjVisibleItem(IsVisible()));
    2250           0 :     lcl_SetItem(rAttr,bMerge,SdrRotateAngleItem(GetRotateAngle()));
    2251           0 :     lcl_SetItem(rAttr,bMerge,SdrShearAngleItem(GetShearAngle()));
    2252           0 :     lcl_SetItem(rAttr,bMerge,SdrOneSizeWidthItem(rSnap.GetWidth()-1));
    2253           0 :     lcl_SetItem(rAttr,bMerge,SdrOneSizeHeightItem(rSnap.GetHeight()-1));
    2254           0 :     lcl_SetItem(rAttr,bMerge,SdrOnePositionXItem(rSnap.Left()));
    2255           0 :     lcl_SetItem(rAttr,bMerge,SdrOnePositionYItem(rSnap.Top()));
    2256           0 :     if (rLogic.GetWidth()!=rSnap.GetWidth()) {
    2257           0 :         lcl_SetItem(rAttr,bMerge,SdrLogicSizeWidthItem(rLogic.GetWidth()-1));
    2258             :     }
    2259           0 :     if (rLogic.GetHeight()!=rSnap.GetHeight()) {
    2260           0 :         lcl_SetItem(rAttr,bMerge,SdrLogicSizeHeightItem(rLogic.GetHeight()-1));
    2261             :     }
    2262           0 :     XubString aName(GetName());
    2263             : 
    2264           0 :     if(aName.Len())
    2265             :     {
    2266           0 :         lcl_SetItem(rAttr, bMerge, SdrObjectNameItem(aName));
    2267             :     }
    2268             : 
    2269           0 :     lcl_SetItem(rAttr,bMerge,SdrLayerIdItem(GetLayer()));
    2270           0 :     const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
    2271           0 :     if (pLayAd!=NULL) {
    2272           0 :         const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
    2273           0 :         if (pLayer!=NULL) {
    2274           0 :             lcl_SetItem(rAttr,bMerge,SdrLayerNameItem(pLayer->GetName()));
    2275             :         }
    2276             :     }
    2277           0 :     Point aRef1(rSnap.Center());
    2278           0 :     Point aRef2(aRef1); aRef2.Y()++;
    2279           0 :     lcl_SetItem(rAttr,bMerge,SdrTransformRef1XItem(aRef1.X()));
    2280           0 :     lcl_SetItem(rAttr,bMerge,SdrTransformRef1YItem(aRef1.Y()));
    2281           0 :     lcl_SetItem(rAttr,bMerge,SdrTransformRef2XItem(aRef2.X()));
    2282           0 :     lcl_SetItem(rAttr,bMerge,SdrTransformRef2YItem(aRef2.Y()));
    2283           0 : }
    2284             : 
    2285      166052 : SfxStyleSheet* SdrObject::GetStyleSheet() const
    2286             : {
    2287      166052 :     return GetProperties().GetStyleSheet();
    2288             : }
    2289             : 
    2290         564 : void SdrObject::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr)
    2291             : {
    2292         564 :     Rectangle aBoundRect0;
    2293             : 
    2294         564 :     if(pUserCall)
    2295           3 :         aBoundRect0 = GetLastBoundRect();
    2296             : 
    2297         564 :     NbcSetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
    2298         564 :     SetChanged();
    2299         564 :     BroadcastObjectChange();
    2300         564 :     SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect0);
    2301         564 : }
    2302             : 
    2303        1025 : void SdrObject::NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
    2304             : {
    2305             :     // only allow graphic and presentation styles for shapes
    2306        1025 :     if( pNewStyleSheet && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PARA) && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PAGE) )
    2307        1025 :         return;
    2308             : 
    2309        1025 :     GetProperties().SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
    2310             : }
    2311             : 
    2312             : // Broadcasting while setting attributes is managed by the AttrObj.
    2313             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2314             : 
    2315         229 : bool SdrObject::IsNode() const
    2316             : {
    2317         229 :     return true;
    2318             : }
    2319             : 
    2320           0 : SdrGluePoint SdrObject::GetVertexGluePoint(sal_uInt16 nPosNum) const
    2321             : {
    2322             :     // #i41936# Use SnapRect for default GluePoints
    2323           0 :     const Rectangle aR(GetSnapRect());
    2324           0 :     Point aPt;
    2325             : 
    2326           0 :     switch(nPosNum)
    2327             :     {
    2328           0 :         case 0 : aPt = aR.TopCenter();    break;
    2329           0 :         case 1 : aPt = aR.RightCenter();  break;
    2330           0 :         case 2 : aPt = aR.BottomCenter(); break;
    2331           0 :         case 3 : aPt = aR.LeftCenter();   break;
    2332             :     }
    2333             : 
    2334           0 :     aPt -= aR.Center();
    2335           0 :     SdrGluePoint aGP(aPt);
    2336           0 :     aGP.SetPercent(false);
    2337             : 
    2338           0 :     return aGP;
    2339             : }
    2340             : 
    2341           0 : SdrGluePoint SdrObject::GetCornerGluePoint(sal_uInt16 nPosNum) const
    2342             : {
    2343           0 :     Rectangle aR(GetCurrentBoundRect());
    2344           0 :     Point aPt;
    2345           0 :     switch (nPosNum) {
    2346           0 :         case 0 : aPt=aR.TopLeft();     break;
    2347           0 :         case 1 : aPt=aR.TopRight();    break;
    2348           0 :         case 2 : aPt=aR.BottomRight(); break;
    2349           0 :         case 3 : aPt=aR.BottomLeft();  break;
    2350             :     }
    2351           0 :     aPt-=GetSnapRect().Center();
    2352           0 :     SdrGluePoint aGP(aPt);
    2353           0 :     aGP.SetPercent(false);
    2354           0 :     return aGP;
    2355             : }
    2356             : 
    2357      107252 : const SdrGluePointList* SdrObject::GetGluePointList() const
    2358             : {
    2359      107252 :     if (pPlusData!=NULL) return pPlusData->pGluePoints;
    2360       89203 :     return NULL;
    2361             : }
    2362             : 
    2363             : 
    2364          35 : SdrGluePointList* SdrObject::ForceGluePointList()
    2365             : {
    2366          35 :     ImpForcePlusData();
    2367          35 :     if (pPlusData->pGluePoints==NULL) {
    2368           4 :         pPlusData->pGluePoints=new SdrGluePointList;
    2369             :     }
    2370          35 :     return pPlusData->pGluePoints;
    2371             : }
    2372             : 
    2373         940 : void SdrObject::SetGlueReallyAbsolute(bool bOn)
    2374             : {
    2375             :     // First a const call to see whether there are any glue points.
    2376             :     // Force const call!
    2377         940 :     if (GetGluePointList()!=NULL) {
    2378           6 :         SdrGluePointList* pGPL=ForceGluePointList();
    2379           6 :         pGPL->SetReallyAbsolute(bOn,*this);
    2380             :     }
    2381         940 : }
    2382             : 
    2383         445 : void SdrObject::NbcRotateGluePoints(const Point& rRef, long nWink, double sn, double cs)
    2384             : {
    2385             :     // First a const call to see whether there are any glue points.
    2386             :     // Force const call!
    2387         445 :     if (GetGluePointList()!=NULL) {
    2388           3 :         SdrGluePointList* pGPL=ForceGluePointList();
    2389           3 :         pGPL->Rotate(rRef,nWink,sn,cs,this);
    2390             :     }
    2391         445 : }
    2392             : 
    2393      105701 : void SdrObject::NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2)
    2394             : {
    2395             :     // First a const call to see whether there are any glue points.
    2396             :     // Force const call!
    2397      105701 :     if (GetGluePointList()!=NULL) {
    2398           0 :         SdrGluePointList* pGPL=ForceGluePointList();
    2399           0 :         pGPL->Mirror(rRef1,rRef2,this);
    2400             :     }
    2401      105701 : }
    2402             : 
    2403           0 : void SdrObject::NbcShearGluePoints(const Point& rRef, long nWink, double tn, bool bVShear)
    2404             : {
    2405             :     // First a const call to see whether there are any glue points.
    2406             :     // Force const call!
    2407           0 :     if (GetGluePointList()!=NULL) {
    2408           0 :         SdrGluePointList* pGPL=ForceGluePointList();
    2409           0 :         pGPL->Shear(rRef,nWink,tn,bVShear,this);
    2410             :     }
    2411           0 : }
    2412             : 
    2413           0 : bool SdrObject::IsEdge() const
    2414             : {
    2415           0 :     return false;
    2416             : }
    2417             : 
    2418           0 : void SdrObject::ConnectToNode(bool /*bTail1*/, SdrObject* /*pObj*/)
    2419             : {
    2420           0 : }
    2421             : 
    2422           0 : void SdrObject::DisconnectFromNode(bool /*bTail1*/)
    2423             : {
    2424           0 : }
    2425             : 
    2426           0 : SdrObject* SdrObject::GetConnectedNode(bool /*bTail1*/) const
    2427             : {
    2428           0 :     return NULL;
    2429             : }
    2430             : 
    2431             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2432             : 
    2433           0 : void extractLineContourFromPrimitive2DSequence(
    2434             :     const drawinglayer::primitive2d::Primitive2DSequence& rxSequence,
    2435             :     basegfx::B2DPolygonVector& rExtractedHairlines,
    2436             :     basegfx::B2DPolyPolygonVector& rExtractedLineFills)
    2437             : {
    2438           0 :     rExtractedHairlines.clear();
    2439           0 :     rExtractedLineFills.clear();
    2440             : 
    2441           0 :     if(rxSequence.hasElements())
    2442             :     {
    2443             :         // use neutral ViewInformation
    2444           0 :         const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
    2445             : 
    2446             :         // create extractor, process and get result
    2447           0 :         drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D);
    2448           0 :         aExtractor.process(rxSequence);
    2449             : 
    2450             :         // copy line results
    2451           0 :         rExtractedHairlines = aExtractor.getExtractedHairlines();
    2452             : 
    2453             :         // copy fill rsults
    2454           0 :         rExtractedLineFills = aExtractor.getExtractedLineFills();
    2455             :     }
    2456           0 : }
    2457             : 
    2458             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2459             : 
    2460           0 : SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDash) const
    2461             : {
    2462           0 :     bool bNoChange(true);
    2463             : 
    2464           0 :     if(pRet->LineGeometryUsageIsNecessary())
    2465             :     {
    2466           0 :         basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
    2467           0 :         basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
    2468           0 :         const drawinglayer::primitive2d::Primitive2DSequence xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DSequence());
    2469             : 
    2470           0 :         if(xSequence.hasElements())
    2471             :         {
    2472           0 :             basegfx::B2DPolygonVector aExtractedHairlines;
    2473           0 :             basegfx::B2DPolyPolygonVector aExtractedLineFills;
    2474             : 
    2475           0 :             extractLineContourFromPrimitive2DSequence(xSequence, aExtractedHairlines, aExtractedLineFills);
    2476             : 
    2477           0 :             if(!aExtractedHairlines.empty())
    2478             :             {
    2479             :                 // for SdrObject creation, just copy all to a single Hairline-PolyPolygon
    2480           0 :                 for(sal_uInt32 a(0); a < aExtractedHairlines.size(); a++)
    2481             :                 {
    2482           0 :                     aMergedHairlinePolyPolygon.append(aExtractedHairlines[a]);
    2483             :                 }
    2484             :             }
    2485             : 
    2486             :             // check for fill rsults
    2487           0 :             if(!aExtractedLineFills.empty())
    2488             :             {
    2489             :                 // merge to a single PolyPolygon (OR)
    2490           0 :                 aMergedLineFillPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(aExtractedLineFills);
    2491           0 :             }
    2492             :         }
    2493             : 
    2494           0 :         if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
    2495             :         {
    2496           0 :             SfxItemSet aSet(pRet->GetMergedItemSet());
    2497           0 :             XFillStyle eOldFillStyle = ((const XFillStyleItem&)(aSet.Get(XATTR_FILLSTYLE))).GetValue();
    2498           0 :             SdrPathObj* aLinePolygonPart = NULL;
    2499           0 :             SdrPathObj* aLineHairlinePart = NULL;
    2500           0 :             bool bBuildGroup(false);
    2501             : 
    2502           0 :             if(aMergedLineFillPolyPolygon.count())
    2503             :             {
    2504             :                 // create SdrObject for filled line geometry
    2505           0 :                 aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
    2506           0 :                 aLinePolygonPart->SetModel(pRet->GetModel());
    2507             : 
    2508             :                 // correct item properties
    2509           0 :                 aSet.Put(XLineWidthItem(0L));
    2510           0 :                 aSet.Put(XLineStyleItem(XLINE_NONE));
    2511           0 :                 Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue();
    2512           0 :                 sal_uInt16 nTransLine = ((const XLineTransparenceItem&)(aSet.Get(XATTR_LINETRANSPARENCE))).GetValue();
    2513           0 :                 aSet.Put(XFillColorItem(XubString(), aColorLine));
    2514           0 :                 aSet.Put(XFillStyleItem(XFILL_SOLID));
    2515           0 :                 aSet.Put(XFillTransparenceItem(nTransLine));
    2516             : 
    2517           0 :                 aLinePolygonPart->SetMergedItemSet(aSet);
    2518             :             }
    2519             : 
    2520           0 :             if(aMergedHairlinePolyPolygon.count())
    2521             :             {
    2522             :                 // create SdrObject for hairline geometry
    2523             :                 // OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
    2524             :                 // to get a non-filled object. If the poly is closed, the PathObj takes care for
    2525             :                 // the correct closed state.
    2526           0 :                 aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
    2527           0 :                 aLineHairlinePart->SetModel(pRet->GetModel());
    2528             : 
    2529           0 :                 aSet.Put(XLineWidthItem(0L));
    2530           0 :                 aSet.Put(XFillStyleItem(XFILL_NONE));
    2531           0 :                 aSet.Put(XLineStyleItem(XLINE_SOLID));
    2532             : 
    2533             :                 // it is also necessary to switch off line start and ends here
    2534           0 :                 aSet.Put(XLineStartWidthItem(0));
    2535           0 :                 aSet.Put(XLineEndWidthItem(0));
    2536             : 
    2537           0 :                 aLineHairlinePart->SetMergedItemSet(aSet);
    2538             : 
    2539           0 :                 if(aLinePolygonPart)
    2540             :                 {
    2541           0 :                     bBuildGroup = true;
    2542             :                 }
    2543             :             }
    2544             : 
    2545             :             // check if original geometry should be added (e.g. filled and closed)
    2546           0 :             bool bAddOriginalGeometry(false);
    2547           0 :             SdrPathObj* pPath = PTR_CAST(SdrPathObj, pRet);
    2548             : 
    2549           0 :             if(pPath && pPath->IsClosed())
    2550             :             {
    2551           0 :                 if(eOldFillStyle != XFILL_NONE)
    2552             :                 {
    2553           0 :                     bAddOriginalGeometry = true;
    2554             :                 }
    2555             :             }
    2556             : 
    2557             :             // do we need a group?
    2558           0 :             if(bBuildGroup || bAddOriginalGeometry)
    2559             :             {
    2560           0 :                 SdrObject* pGroup = new SdrObjGroup;
    2561           0 :                 pGroup->SetModel(pRet->GetModel());
    2562             : 
    2563           0 :                 if(bAddOriginalGeometry)
    2564             :                 {
    2565             :                     // Add a clone of the original geometry.
    2566           0 :                     aSet.ClearItem();
    2567           0 :                     aSet.Put(pRet->GetMergedItemSet());
    2568           0 :                     aSet.Put(XLineStyleItem(XLINE_NONE));
    2569           0 :                     aSet.Put(XLineWidthItem(0L));
    2570             : 
    2571           0 :                     SdrObject* pClone = pRet->Clone();
    2572             : 
    2573           0 :                     pClone->SetModel(pRet->GetModel());
    2574           0 :                     pClone->SetMergedItemSet(aSet);
    2575             : 
    2576           0 :                     pGroup->GetSubList()->NbcInsertObject(pClone);
    2577             :                 }
    2578             : 
    2579           0 :                 if(aLinePolygonPart)
    2580             :                 {
    2581           0 :                     pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart);
    2582             :                 }
    2583             : 
    2584           0 :                 if(aLineHairlinePart)
    2585             :                 {
    2586           0 :                     pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
    2587             :                 }
    2588             : 
    2589           0 :                 pRet = pGroup;
    2590             : 
    2591             :                 // be more careful with the state describing bool
    2592           0 :                 bNoChange = false;
    2593             :             }
    2594             :             else
    2595             :             {
    2596           0 :                 if(aLinePolygonPart)
    2597             :                 {
    2598           0 :                     pRet = aLinePolygonPart;
    2599             :                     // be more careful with the state describing bool
    2600           0 :                     bNoChange = false;
    2601             :                 }
    2602           0 :                 else if(aLineHairlinePart)
    2603             :                 {
    2604           0 :                     pRet = aLineHairlinePart;
    2605             :                     // be more careful with the state describing bool
    2606           0 :                     bNoChange = false;
    2607             :                 }
    2608           0 :             }
    2609           0 :         }
    2610             :     }
    2611             : 
    2612           0 :     if(bNoChange)
    2613             :     {
    2614             :         // due to current method usage, create and return a clone when nothing has changed
    2615           0 :         SdrObject* pClone = pRet->Clone();
    2616           0 :         pClone->SetModel(pRet->GetModel());
    2617           0 :         pRet = pClone;
    2618             :     }
    2619             : 
    2620           0 :     return pRet;
    2621             : }
    2622             : 
    2623        1904 : bool SdrObject::IsVirtualObj() const
    2624             : {
    2625        1904 :     return bVirtObj;
    2626             : }
    2627             : 
    2628         423 : bool SdrObject::IsClosedObj() const
    2629             : {
    2630         423 :     return bClosedObj;
    2631             : }
    2632             : 
    2633       28980 : bool SdrObject::IsEdgeObj() const
    2634             : {
    2635       28980 :     return bIsEdge;
    2636             : }
    2637             : 
    2638         213 : bool SdrObject::Is3DObj() const
    2639             : {
    2640         213 :     return bIs3DObj;
    2641             : }
    2642             : 
    2643         123 : bool SdrObject::IsUnoObj() const
    2644             : {
    2645         123 :     return bIsUnoObj;
    2646             : }
    2647             : 
    2648          15 : void SdrObject::SetMarkProtect(bool bProt)
    2649             : {
    2650          15 :     bMarkProt = bProt;
    2651          15 : }
    2652             : 
    2653         369 : bool SdrObject::IsMarkProtect() const
    2654             : {
    2655         369 :     return bMarkProt;
    2656             : }
    2657             : 
    2658      486355 : bool SdrObject::IsInserted() const
    2659             : {
    2660      486355 :     return bInserted;
    2661             : }
    2662             : 
    2663         262 : bool SdrObject::IsMoveProtect() const
    2664             : {
    2665         262 :     return bMovProt;
    2666             : }
    2667             : 
    2668         675 : bool SdrObject::IsResizeProtect() const
    2669             : {
    2670         675 :     return bSizProt;
    2671             : }
    2672             : 
    2673         188 : bool SdrObject::IsPrintable() const
    2674             : {
    2675         188 :     return !bNoPrint;
    2676             : }
    2677             : 
    2678       27664 : bool SdrObject::IsVisible() const
    2679             : {
    2680       27664 :     return mbVisible;
    2681             : }
    2682             : 
    2683        1052 : void SdrObject::SetEmptyPresObj(bool bEpt)
    2684             : {
    2685        1052 :     bEmptyPresObj = bEpt;
    2686        1052 : }
    2687             : 
    2688       18909 : bool SdrObject::IsEmptyPresObj() const
    2689             : {
    2690       18909 :     return bEmptyPresObj;
    2691             : }
    2692             : 
    2693         158 : void SdrObject::SetNotVisibleAsMaster(bool bFlg)
    2694             : {
    2695         158 :     bNotVisibleAsMaster=bFlg;
    2696         158 : }
    2697             : 
    2698         915 : bool SdrObject::IsNotVisibleAsMaster() const
    2699             : {
    2700         915 :     return bNotVisibleAsMaster;
    2701             : }
    2702             : 
    2703         144 : bool SdrObject::LineIsOutsideGeometry() const
    2704             : {
    2705         144 :     return mbLineIsOutsideGeometry;
    2706             : }
    2707             : 
    2708       28870 : bool SdrObject::DoesSupportTextIndentingOnLineWidthChange() const
    2709             : {
    2710       28870 :     return mbSupportTextIndentingOnLineWidthChange;
    2711             : }
    2712             : 
    2713             : // convert this path object to contour object, even when it is a group
    2714           0 : SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash) const
    2715             : {
    2716           0 :     if(pRet->ISA(SdrObjGroup))
    2717             :     {
    2718           0 :         SdrObjList* pObjList2 = pRet->GetSubList();
    2719           0 :         SdrObject* pGroup = new SdrObjGroup;
    2720           0 :         pGroup->SetModel(pRet->GetModel());
    2721             : 
    2722           0 :         for(sal_uInt32 a=0;a<pObjList2->GetObjCount();a++)
    2723             :         {
    2724           0 :             SdrObject* pIterObj = pObjList2->GetObj(a);
    2725           0 :             pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash));
    2726             :         }
    2727             : 
    2728           0 :         pRet = pGroup;
    2729             :     }
    2730             :     else
    2731             :     {
    2732           0 :         if(pRet && pRet->ISA(SdrPathObj))
    2733             :         {
    2734           0 :             SdrPathObj* pPathObj = (SdrPathObj*)pRet;
    2735             : 
    2736             :             // bezier geometry got created, even for straight edges since the given
    2737             :             // object is a result of DoConvertToPolyObj. For conversion to contour
    2738             :             // this is not really needed and can be reduced again AFAP
    2739           0 :             pPathObj->SetPathPoly(basegfx::tools::simplifyCurveSegments(pPathObj->GetPathPoly()));
    2740             :         }
    2741             : 
    2742           0 :         pRet = ImpConvertToContourObj(pRet, bForceLineDash);
    2743             :     }
    2744             : 
    2745             :     // #i73441# preserve LayerID
    2746           0 :     if(pRet && pRet->GetLayer() != GetLayer())
    2747             :     {
    2748           0 :         pRet->SetLayer(GetLayer());
    2749             :     }
    2750             : 
    2751           0 :     return pRet;
    2752             : }
    2753             : 
    2754             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2755             : 
    2756          20 : SdrObject* SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const
    2757             : {
    2758          20 :     SdrObject* pRet = DoConvertToPolyObj(bBezier, true);
    2759             : 
    2760          20 :     if(pRet && bLineToArea)
    2761             :     {
    2762           0 :         SdrObject* pNewRet = ConvertToContourObj(pRet);
    2763           0 :         delete pRet;
    2764           0 :         pRet = pNewRet;
    2765             :     }
    2766             : 
    2767             :     // #i73441# preserve LayerID
    2768          20 :     if(pRet && pRet->GetLayer() != GetLayer())
    2769             :     {
    2770           0 :         pRet->SetLayer(GetLayer());
    2771             :     }
    2772             : 
    2773          20 :     return pRet;
    2774             : }
    2775             : 
    2776             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2777             : 
    2778           0 : SdrObject* SdrObject::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const
    2779             : {
    2780           0 :     return NULL;
    2781             : }
    2782             : 
    2783             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2784             : 
    2785       62677 : void SdrObject::SetInserted(bool bIns)
    2786             : {
    2787       62677 :     if (bIns!=IsInserted()) {
    2788       62677 :         bInserted=bIns;
    2789       62677 :         Rectangle aBoundRect0(GetLastBoundRect());
    2790       62677 :         if (bIns) SendUserCall(SDRUSERCALL_INSERTED,aBoundRect0);
    2791       11749 :         else SendUserCall(SDRUSERCALL_REMOVED,aBoundRect0);
    2792             : 
    2793       62677 :         if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
    2794          95 :             SdrHint aHint(*this);
    2795          95 :             aHint.SetKind(bIns?HINT_OBJINSERTED:HINT_OBJREMOVED);
    2796          95 :             pPlusData->pBroadcast->Broadcast(aHint);
    2797             :         }
    2798             :     }
    2799       62677 : }
    2800             : 
    2801          46 : void SdrObject::SetMoveProtect(bool bProt)
    2802             : {
    2803          46 :     if(IsMoveProtect() != bProt)
    2804             :     {
    2805             :         // #i77187# secured and simplified
    2806          15 :         bMovProt = bProt;
    2807          15 :         SetChanged();
    2808          15 :         BroadcastObjectChange();
    2809             :     }
    2810          46 : }
    2811             : 
    2812         165 : void SdrObject::SetResizeProtect(bool bProt)
    2813             : {
    2814         165 :     if(IsResizeProtect() != bProt)
    2815             :     {
    2816             :         // #i77187# secured and simplified
    2817         135 :         bSizProt = bProt;
    2818         135 :         SetChanged();
    2819         135 :         BroadcastObjectChange();
    2820             :     }
    2821         165 : }
    2822             : 
    2823        1579 : void SdrObject::SetPrintable(bool bPrn)
    2824             : {
    2825        1579 :     if( bPrn == bNoPrint )
    2826             :     {
    2827           0 :         bNoPrint=!bPrn;
    2828           0 :         SetChanged();
    2829           0 :         if (IsInserted() && pModel!=NULL)
    2830             :         {
    2831           0 :             SdrHint aHint(*this);
    2832           0 :             pModel->Broadcast(aHint);
    2833             :         }
    2834             :     }
    2835        1579 : }
    2836             : 
    2837        1579 : void SdrObject::SetVisible(bool bVisible)
    2838             : {
    2839        1579 :     if( bVisible != mbVisible )
    2840             :     {
    2841           0 :         mbVisible = bVisible;
    2842           0 :         SetChanged();
    2843           0 :         if (IsInserted() && pModel!=NULL)
    2844             :         {
    2845           0 :             SdrHint aHint(*this);
    2846           0 :             pModel->Broadcast(aHint);
    2847             :         }
    2848             :     }
    2849        1579 : }
    2850             : 
    2851             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2852             : 
    2853       51896 : sal_uInt16 SdrObject::GetUserDataCount() const
    2854             : {
    2855       51896 :     if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return 0;
    2856       10627 :     return pPlusData->pUserDataList->GetUserDataCount();
    2857             : }
    2858             : 
    2859       10950 : SdrObjUserData* SdrObject::GetUserData(sal_uInt16 nNum) const
    2860             : {
    2861       10950 :     if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return NULL;
    2862       10950 :     return pPlusData->pUserDataList->GetUserData(nNum);
    2863             : }
    2864             : 
    2865        1585 : void SdrObject::AppendUserData(SdrObjUserData* pData)
    2866             : {
    2867        1585 :     if (!pData)
    2868             :     {
    2869             :         OSL_FAIL("SdrObject::AppendUserData(): pData is NULL pointer.");
    2870        1585 :         return;
    2871             :     }
    2872             : 
    2873        1585 :     ImpForcePlusData();
    2874        1585 :     if (!pPlusData->pUserDataList)
    2875        1431 :         pPlusData->pUserDataList = new SdrObjUserDataList;
    2876             : 
    2877        1585 :     pPlusData->pUserDataList->AppendUserData(pData);
    2878             : }
    2879             : 
    2880           0 : void SdrObject::DeleteUserData(sal_uInt16 nNum)
    2881             : {
    2882           0 :     sal_uInt16 nAnz=GetUserDataCount();
    2883           0 :     if (nNum<nAnz) {
    2884           0 :         pPlusData->pUserDataList->DeleteUserData(nNum);
    2885           0 :         if (nAnz==1)  {
    2886           0 :             delete pPlusData->pUserDataList;
    2887           0 :             pPlusData->pUserDataList=NULL;
    2888             :         }
    2889             :     } else {
    2890             :         OSL_FAIL("SdrObject::DeleteUserData(): Invalid Index.");
    2891             :     }
    2892           0 : }
    2893             : 
    2894       99610 : void SdrObject::SetUserCall(SdrObjUserCall* pUser)
    2895             : {
    2896       99610 :     pUserCall = pUser;
    2897       99610 : }
    2898             : 
    2899      389208 : SdrObjUserCall* SdrObject::GetUserCall() const
    2900             : {
    2901      389208 :     return pUserCall;
    2902             : }
    2903             : 
    2904      401940 : void SdrObject::SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect) const
    2905             : {
    2906      401940 :     SdrObjGroup* pGroup = NULL;
    2907             : 
    2908      401940 :     if( pObjList && pObjList->GetListKind() == SDROBJLIST_GROUPOBJ )
    2909      296231 :         pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
    2910             : 
    2911      401940 :     if ( pUserCall )
    2912             :     {
    2913       12660 :         pUserCall->Changed( *this, eUserCall, rBoundRect );
    2914             :     }
    2915             : 
    2916     1100111 :     while( pGroup )
    2917             :     {
    2918             :         // broadcast to group
    2919      296231 :         if( pGroup->GetUserCall() )
    2920             :         {
    2921         258 :             SdrUserCallType eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
    2922             : 
    2923         258 :             switch( eUserCall )
    2924             :             {
    2925             :                 case SDRUSERCALL_MOVEONLY:
    2926          78 :                     eChildUserType = SDRUSERCALL_CHILD_MOVEONLY;
    2927          78 :                 break;
    2928             : 
    2929             :                 case SDRUSERCALL_RESIZE:
    2930          61 :                     eChildUserType = SDRUSERCALL_CHILD_RESIZE;
    2931          61 :                 break;
    2932             : 
    2933             :                 case SDRUSERCALL_CHGATTR:
    2934          97 :                     eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
    2935          97 :                 break;
    2936             : 
    2937             :                 case SDRUSERCALL_DELETE:
    2938           0 :                     eChildUserType = SDRUSERCALL_CHILD_DELETE;
    2939           0 :                 break;
    2940             : 
    2941             :                 case SDRUSERCALL_COPY:
    2942           0 :                     eChildUserType = SDRUSERCALL_CHILD_COPY;
    2943           0 :                 break;
    2944             : 
    2945             :                 case SDRUSERCALL_INSERTED:
    2946          22 :                     eChildUserType = SDRUSERCALL_CHILD_INSERTED;
    2947          22 :                 break;
    2948             : 
    2949             :                 case SDRUSERCALL_REMOVED:
    2950           0 :                     eChildUserType = SDRUSERCALL_CHILD_REMOVED;
    2951           0 :                 break;
    2952             : 
    2953           0 :                 default: break;
    2954             :             }
    2955             : 
    2956         258 :             pGroup->GetUserCall()->Changed( *this, eChildUserType, rBoundRect );
    2957             :         }
    2958             : 
    2959      881727 :         if( pGroup->GetObjList()                                       &&
    2960      570705 :             pGroup->GetObjList()->GetListKind() == SDROBJLIST_GROUPOBJ &&
    2961      274474 :             pGroup != (SdrObjGroup*) pObjList->GetOwnerObj() )
    2962           0 :             pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
    2963             :         else
    2964      296231 :             pGroup = NULL;
    2965             :     }
    2966             : 
    2967             :     // notify our UNO shape listeners
    2968      401940 :     switch ( eUserCall )
    2969             :     {
    2970             :     case SDRUSERCALL_RESIZE:
    2971      183494 :         notifyShapePropertyChange( ::svx::eShapeSize );
    2972             :         // fall through - RESIZE might also imply a change of the position
    2973             :     case SDRUSERCALL_MOVEONLY:
    2974      222575 :         notifyShapePropertyChange( ::svx::eShapePosition );
    2975      222575 :         break;
    2976             :     default:
    2977             :         // not interested in
    2978      179365 :         break;
    2979             :     }
    2980      401940 : }
    2981             : 
    2982             : // change ItemPool for this object
    2983       50410 : void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
    2984             : {
    2985       50410 :     if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
    2986             :     {
    2987       50410 :         GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
    2988             :     }
    2989       50410 : }
    2990             : 
    2991      207628 : void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
    2992             : {
    2993      207628 :     const uno::Reference< uno::XInterface>& xOldUnoShape( maWeakUnoShape );
    2994             :     // the UNO shape would be gutted by the following code; return early
    2995      207628 :     if ( _rxUnoShape == xOldUnoShape )
    2996             :     {
    2997      108334 :         if ( !xOldUnoShape.is() )
    2998             :         {
    2999             :             // make sure there is no stale impl. pointer if the UNO
    3000             :             // shape was destroyed meanwhile (remember we only hold weak
    3001             :             // reference to it!)
    3002       73627 :             mpSvxShape = 0;
    3003             :         }
    3004      315962 :         return;
    3005             :     }
    3006             : 
    3007       99294 :     bool bTransferOwnership( false );
    3008       99294 :     if ( xOldUnoShape.is() )
    3009             :     {
    3010       12762 :         bTransferOwnership = mpSvxShape->HasSdrObjectOwnership();
    3011             :         // Remove yourself from the current UNO shape. Its destructor
    3012             :         // will reset our UNO shape otherwise.
    3013       12762 :         mpSvxShape->InvalidateSdrObject();
    3014             :     }
    3015             : 
    3016       99294 :     maWeakUnoShape = _rxUnoShape;
    3017       99294 :     mpSvxShape = SvxShape::getImplementation( _rxUnoShape );
    3018             : 
    3019             :     // I think this may never happen... But I am not sure enough .-)
    3020       99294 :     if ( bTransferOwnership )
    3021             :     {
    3022           0 :         if ( _rxUnoShape.is() )
    3023           0 :             mpSvxShape->TakeSdrObjectOwnership();
    3024             :         SAL_WARN( "svx.uno", "a UNO shape took over an SdrObject previously owned by another UNO shape!");
    3025       99294 :     }
    3026             : }
    3027             : 
    3028             : /** only for internal use! */
    3029      654132 : SvxShape* SdrObject::getSvxShape()
    3030             : {
    3031             :     DBG_TESTSOLARMUTEX();
    3032             :         // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be
    3033             :         // guarded by the SolarMutex
    3034             : 
    3035      654132 :     uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
    3036             : #if OSL_DEBUG_LEVEL > 0
    3037             :     OSL_ENSURE( !( !xShape.is() && mpSvxShape ),
    3038             :         "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
    3039             : #endif
    3040             :     //#113608#, make sure mpSvxShape is always synchronized with maWeakUnoShape
    3041      654132 :     if ( mpSvxShape && !xShape.is() )
    3042           0 :         mpSvxShape = NULL;
    3043             : 
    3044      654132 :     return mpSvxShape;
    3045             : }
    3046             : 
    3047       53851 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
    3048             : {
    3049             :     // try weak reference first
    3050       53851 :     uno::Reference< uno::XInterface > xShape( getWeakUnoShape() );
    3051       53851 :     if( !xShape.is() )
    3052             :     {
    3053             :         OSL_ENSURE( mpSvxShape == NULL, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
    3054       38344 :         if ( pPage )
    3055             :         {
    3056       34834 :             uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
    3057       34834 :             if( xPage.is() )
    3058             :             {
    3059       34834 :                 SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
    3060       34834 :                 if( pDrawPage )
    3061             :                 {
    3062             :                     // create one
    3063       34834 :                     xShape = pDrawPage->_CreateShape( this );
    3064       34834 :                     impl_setUnoShape( xShape );
    3065             :                 }
    3066       34834 :             }
    3067             :         }
    3068             :         else
    3069             :         {
    3070        3510 :             mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL );
    3071        3510 :             maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape );
    3072             :         }
    3073             :     }
    3074             : 
    3075       53851 :     return xShape;
    3076             : }
    3077             : 
    3078      172794 : void SdrObject::setUnoShape(const uno::Reference<uno::XInterface >& _rxUnoShape)
    3079             : {
    3080      172794 :     impl_setUnoShape( _rxUnoShape );
    3081      172794 : }
    3082             : 
    3083        1135 : ::svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier()
    3084             : {
    3085             :     DBG_TESTSOLARMUTEX();
    3086             : 
    3087        1135 :     SvxShape* pSvxShape = getSvxShape();
    3088        1135 :     ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" );
    3089        1135 :     return pSvxShape->getShapePropertyChangeNotifier();
    3090             : }
    3091             : 
    3092      406135 : void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const
    3093             : {
    3094             :     DBG_TESTSOLARMUTEX();
    3095             : 
    3096      406135 :     SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
    3097      406135 :     if ( pSvxShape )
    3098      252765 :         return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty );
    3099             : }
    3100             : 
    3101             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    3102             : //
    3103             : // transformation interface for StarOfficeAPI. This implements support for
    3104             : // homogeneous 3x3 matrices containing the transformation of the SdrObject. At the
    3105             : // moment it contains a shearX, rotation and translation, but for setting all linear
    3106             : // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
    3107             : //
    3108             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    3109             : // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
    3110             : // with the base geometry and returns TRUE. Otherwise it returns FALSE.
    3111          52 : sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
    3112             : {
    3113             :     // any kind of SdrObject, just use SnapRect
    3114          52 :     Rectangle aRectangle(GetSnapRect());
    3115             : 
    3116             :     // convert to transformation values
    3117          52 :     basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
    3118         104 :     basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
    3119             : 
    3120             :     // position maybe relative to anchorpos, convert
    3121          52 :     if( pModel && pModel->IsWriter() )
    3122             :     {
    3123           0 :         if(GetAnchorPos().X() || GetAnchorPos().Y())
    3124             :         {
    3125           0 :             aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
    3126             :         }
    3127             :     }
    3128             : 
    3129             :     // force MapUnit to 100th mm
    3130          52 :     const SfxMapUnit eMapUnit(GetObjectMapUnit());
    3131          52 :     if(eMapUnit != SFX_MAPUNIT_100TH_MM)
    3132             :     {
    3133           0 :         switch(eMapUnit)
    3134             :         {
    3135             :             case SFX_MAPUNIT_TWIP :
    3136             :             {
    3137             :                 // position
    3138           0 :                 aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
    3139           0 :                 aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
    3140             : 
    3141             :                 // size
    3142           0 :                 aScale.setX(ImplTwipsToMM(aScale.getX()));
    3143           0 :                 aScale.setY(ImplTwipsToMM(aScale.getY()));
    3144             : 
    3145           0 :                 break;
    3146             :             }
    3147             :             default:
    3148             :             {
    3149             :                 OSL_FAIL("TRGetBaseGeometry: Missing unit translation to 100th mm!");
    3150             :             }
    3151             :         }
    3152             :     }
    3153             : 
    3154             :     // build matrix
    3155          52 :     rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate);
    3156             : 
    3157         104 :     return false;
    3158             : }
    3159             : 
    3160             : // sets the base geometry of the object using infos contained in the homogeneous 3x3 matrix.
    3161             : // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
    3162             : // to use (0,0) as upper left and will be scaled to the given size in the matrix.
    3163          37 : void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
    3164             : {
    3165             :     // break up matrix
    3166          37 :     basegfx::B2DTuple aScale;
    3167          74 :     basegfx::B2DTuple aTranslate;
    3168             :     double fRotate, fShearX;
    3169          37 :     rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
    3170             : 
    3171             :     // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
    3172             :     // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
    3173          37 :     if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
    3174             :     {
    3175           0 :         aScale.setX(fabs(aScale.getX()));
    3176           0 :         aScale.setY(fabs(aScale.getY()));
    3177           0 :         fRotate = fmod(fRotate + F_PI, F_2PI);
    3178             :     }
    3179             : 
    3180             :     // force metric to pool metric
    3181          37 :     const SfxMapUnit eMapUnit(GetObjectMapUnit());
    3182          37 :     if(eMapUnit != SFX_MAPUNIT_100TH_MM)
    3183             :     {
    3184           0 :         switch(eMapUnit)
    3185             :         {
    3186             :             case SFX_MAPUNIT_TWIP :
    3187             :             {
    3188             :                 // position
    3189           0 :                 aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
    3190           0 :                 aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
    3191             : 
    3192             :                 // size
    3193           0 :                 aScale.setX(ImplMMToTwips(aScale.getX()));
    3194           0 :                 aScale.setY(ImplMMToTwips(aScale.getY()));
    3195             : 
    3196           0 :                 break;
    3197             :             }
    3198             :             default:
    3199             :             {
    3200             :                 OSL_FAIL("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
    3201             :             }
    3202             :         }
    3203             :     }
    3204             : 
    3205             :     // if anchor is used, make position relative to it
    3206          37 :     if( pModel && pModel->IsWriter() )
    3207             :     {
    3208           0 :         if(GetAnchorPos().X() || GetAnchorPos().Y())
    3209             :         {
    3210           0 :             aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
    3211             :         }
    3212             :     }
    3213             : 
    3214             :     // build BaseRect
    3215          37 :     Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY()));
    3216          37 :     Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY())));
    3217             : 
    3218             :     // set BaseRect
    3219          74 :     SetSnapRect(aBaseRect);
    3220          37 : }
    3221             : 
    3222             : // Give info if object is in destruction
    3223           0 : bool SdrObject::IsInDestruction() const
    3224             : {
    3225           0 :     if(pModel)
    3226           0 :         return pModel->IsInDestruction();
    3227           0 :     return false;
    3228             : }
    3229             : 
    3230             : // return if fill is != XFILL_NONE
    3231           0 : bool SdrObject::HasFillStyle() const
    3232             : {
    3233           0 :     return (((const XFillStyleItem&)GetObjectItem(XATTR_FILLSTYLE)).GetValue() != XFILL_NONE);
    3234             : }
    3235             : 
    3236           0 : bool SdrObject::HasLineStyle() const
    3237             : {
    3238           0 :     return (((const XLineStyleItem&)GetObjectItem(XATTR_LINESTYLE)).GetValue() != XLINE_NONE);
    3239             : }
    3240             : 
    3241             : 
    3242             : // #i52224#
    3243             : // on import of OLE object from MS documents the BLIP size might be retrieved,
    3244             : // the following four methods are used to control it;
    3245             : // usually this data makes no sence after the import is finished, since the object
    3246             : // might be resized
    3247             : 
    3248           4 : Rectangle SdrObject::GetBLIPSizeRectangle() const
    3249             : {
    3250           4 :     return maBLIPSizeRectangle;
    3251             : }
    3252             : 
    3253          47 : void SdrObject::SetBLIPSizeRectangle( const Rectangle& aRect )
    3254             : {
    3255          47 :     maBLIPSizeRectangle = aRect;
    3256          47 : }
    3257             : 
    3258          75 : void SdrObject::SetContextWritingMode( const sal_Int16 /*_nContextWritingMode*/ )
    3259             : {
    3260             :     // this base class does not support different writing modes, so ignore the call
    3261          75 : }
    3262             : 
    3263           0 : void SdrObject::SetDoNotInsertIntoPageAutomatically(const bool bSet)
    3264             : {
    3265           0 :     mbDoNotInsertIntoPageAutomatically = bSet;
    3266           0 : }
    3267             : 
    3268         470 : bool SdrObject::IsDoNotInsertIntoPageAutomatically() const
    3269             : {
    3270         470 :     return mbDoNotInsertIntoPageAutomatically;
    3271             : }
    3272             : 
    3273             : 
    3274        1490 : SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel)
    3275             : {
    3276        1490 :     nInventor=nInvent;
    3277        1490 :     nIdentifier=nIdent;
    3278        1490 :     pNewObj=NULL;
    3279        1490 :     pPage=pNewPage;
    3280        1490 :     pModel=pNewModel;
    3281        1490 :     pObj=NULL;
    3282        1490 :     pNewData=NULL;
    3283        1490 : }
    3284             : 
    3285       47454 : SdrObject* SdrObjFactory::MakeNewObject(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pPage, SdrModel* pModel)
    3286             : {
    3287       47454 :     if(pModel == NULL && pPage != NULL)
    3288       47311 :         pModel = pPage->GetModel();
    3289       47454 :     SdrObject* pObj = NULL;
    3290             : 
    3291       47454 :     if(nInvent == SdrInventor)
    3292             :     {
    3293       45964 :         switch (nIdent)
    3294             :         {
    3295           0 :             case sal_uInt16(OBJ_NONE       ): pObj=new SdrObject;                   break;
    3296       18161 :             case sal_uInt16(OBJ_GRUP       ): pObj=new SdrObjGroup;                 break;
    3297           0 :             case sal_uInt16(OBJ_LINE       ): pObj=new SdrPathObj(OBJ_LINE       ); break;
    3298        6087 :             case sal_uInt16(OBJ_POLY       ): pObj=new SdrPathObj(OBJ_POLY       ); break;
    3299        3194 :             case sal_uInt16(OBJ_PLIN       ): pObj=new SdrPathObj(OBJ_PLIN       ); break;
    3300           3 :             case sal_uInt16(OBJ_PATHLINE   ): pObj=new SdrPathObj(OBJ_PATHLINE   ); break;
    3301         107 :             case sal_uInt16(OBJ_PATHFILL   ): pObj=new SdrPathObj(OBJ_PATHFILL   ); break;
    3302           0 :             case sal_uInt16(OBJ_FREELINE   ): pObj=new SdrPathObj(OBJ_FREELINE   ); break;
    3303           0 :             case sal_uInt16(OBJ_FREEFILL   ): pObj=new SdrPathObj(OBJ_FREEFILL   ); break;
    3304           0 :             case sal_uInt16(OBJ_PATHPOLY   ): pObj=new SdrPathObj(OBJ_POLY       ); break;
    3305           0 :             case sal_uInt16(OBJ_PATHPLIN   ): pObj=new SdrPathObj(OBJ_PLIN       ); break;
    3306           1 :             case sal_uInt16(OBJ_EDGE       ): pObj=new SdrEdgeObj;                  break;
    3307        6236 :             case sal_uInt16(OBJ_RECT       ): pObj=new SdrRectObj;                  break;
    3308          37 :             case sal_uInt16(OBJ_CIRC       ): pObj=new SdrCircObj(OBJ_CIRC       ); break;
    3309           0 :             case sal_uInt16(OBJ_SECT       ): pObj=new SdrCircObj(OBJ_SECT       ); break;
    3310           0 :             case sal_uInt16(OBJ_CARC       ): pObj=new SdrCircObj(OBJ_CARC       ); break;
    3311           0 :             case sal_uInt16(OBJ_CCUT       ): pObj=new SdrCircObj(OBJ_CCUT       ); break;
    3312       11877 :             case sal_uInt16(OBJ_TEXT       ): pObj=new SdrRectObj(OBJ_TEXT       ); break;
    3313           0 :             case sal_uInt16(OBJ_TEXTEXT    ): pObj=new SdrRectObj(OBJ_TEXTEXT    ); break;
    3314           1 :             case sal_uInt16(OBJ_TITLETEXT  ): pObj=new SdrRectObj(OBJ_TITLETEXT  ); break;
    3315           0 :             case sal_uInt16(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
    3316           0 :             case sal_uInt16(OBJ_MEASURE    ): pObj=new SdrMeasureObj;               break;
    3317          57 :             case sal_uInt16(OBJ_GRAF       ): pObj=new SdrGrafObj;                  break;
    3318          26 :             case sal_uInt16(OBJ_OLE2       ): pObj=new SdrOle2Obj;                  break;
    3319           0 :             case sal_uInt16(OBJ_FRAME      ): pObj=new SdrOle2Obj(true);            break;
    3320           8 :             case sal_uInt16(OBJ_CAPTION    ): pObj=new SdrCaptionObj;               break;
    3321           0 :             case sal_uInt16(OBJ_PAGE       ): pObj=new SdrPageObj;                  break;
    3322           0 :             case sal_uInt16(OBJ_UNO        ): pObj=new SdrUnoObj(String());         break;
    3323         167 :             case sal_uInt16(OBJ_CUSTOMSHAPE  ): pObj=new SdrObjCustomShape();       break;
    3324           0 :             case sal_uInt16(OBJ_MEDIA      ): pObj=new SdrMediaObj();               break;
    3325           2 :             case sal_uInt16(OBJ_TABLE      ): pObj=new ::sdr::table::SdrTableObj(pModel);   break;
    3326             :         }
    3327             :     }
    3328             : 
    3329       47454 :     if(pObj == NULL)
    3330             :     {
    3331        1490 :         SdrObjFactory* pFact=new SdrObjFactory(nInvent,nIdent,pPage,pModel);
    3332        1490 :         SdrLinkList& rLL=ImpGetUserMakeObjHdl();
    3333        1490 :         unsigned nAnz=rLL.GetLinkCount();
    3334        1490 :         unsigned i=0;
    3335        4470 :         while (i<nAnz && pObj==NULL) {
    3336        1490 :             rLL.GetLink(i).Call((void*)pFact);
    3337        1490 :             pObj=pFact->pNewObj;
    3338        1490 :             i++;
    3339             :         }
    3340        1490 :         delete pFact;
    3341             :     }
    3342             : 
    3343             :     if(pObj == NULL)
    3344             :     {
    3345             :         // Well, if no one wants it...
    3346             :     }
    3347             : 
    3348       47454 :     if(pObj != NULL)
    3349             :     {
    3350       47454 :         if(pPage != NULL)
    3351       47311 :             pObj->SetPage(pPage);
    3352         143 :         else if(pModel != NULL)
    3353           0 :             pObj->SetModel(pModel);
    3354             :     }
    3355             : 
    3356       47454 :     return pObj;
    3357             : }
    3358             : 
    3359         169 : void SdrObjFactory::InsertMakeObjectHdl(const Link& rLink)
    3360             : {
    3361         169 :     SdrLinkList& rLL=ImpGetUserMakeObjHdl();
    3362         169 :     rLL.InsertLink(rLink);
    3363         169 : }
    3364             : 
    3365          33 : void SdrObjFactory::RemoveMakeObjectHdl(const Link& rLink)
    3366             : {
    3367          33 :     SdrLinkList& rLL=ImpGetUserMakeObjHdl();
    3368          33 :     rLL.RemoveLink(rLink);
    3369          33 : }
    3370             : 
    3371         242 : void SdrObjFactory::InsertMakeUserDataHdl(const Link& rLink)
    3372             : {
    3373         242 :     SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
    3374         242 :     rLL.InsertLink(rLink);
    3375         242 : }
    3376             : 
    3377         226 : void SdrObjFactory::RemoveMakeUserDataHdl(const Link& rLink)
    3378             : {
    3379         226 :     SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
    3380         226 :     rLL.RemoveLink(rLink);
    3381         226 : }
    3382             : 
    3383             : namespace svx
    3384             : {
    3385           0 :     ISdrObjectFilter::~ISdrObjectFilter()
    3386             :     {
    3387           0 :     }
    3388         258 : }
    3389             : 
    3390             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10