LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdobj.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 932 1770 52.7 %
Date: 2014-04-11 Functions: 174 291 59.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10