LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/unocore - unodraw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 820 1434 57.2 %
Date: 2012-12-27 Functions: 78 124 62.9 %
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             : 
      21             : #include <cmdid.h>
      22             : 
      23             : #include <unodraw.hxx>
      24             : #include <unocoll.hxx>
      25             : #include <unoframe.hxx>
      26             : #include <unoparagraph.hxx>
      27             : #include <unotextrange.hxx>
      28             : #include <svx/svditer.hxx>
      29             : #include <swunohelper.hxx>
      30             : #include <doc.hxx>
      31             : #include <IDocumentUndoRedo.hxx>
      32             : #include <fmtcntnt.hxx>
      33             : #include <fmtflcnt.hxx>
      34             : #include <txtatr.hxx>
      35             : #include <docsh.hxx>
      36             : #include <unomap.hxx>
      37             : #include <unoport.hxx>
      38             : #include <TextCursorHelper.hxx>
      39             : #include <dflyobj.hxx>
      40             : #include <ndtxt.hxx>
      41             : #include <svx/svdview.hxx>
      42             : #include <svx/unoshape.hxx>
      43             : #include <dcontact.hxx>
      44             : #include <svx/fmglob.hxx>
      45             : #include <fmtornt.hxx>
      46             : #include <fmtsrnd.hxx>
      47             : #include <fmtfollowtextflow.hxx>
      48             : #include <rootfrm.hxx>
      49             : #include <editeng/lrspitem.hxx>
      50             : #include <editeng/ulspitem.hxx>
      51             : #include <svx/shapepropertynotifier.hxx>
      52             : #include <crstate.hxx>
      53             : #include <comphelper/extract.hxx>
      54             : #include <comphelper/stl_types.hxx>
      55             : #include <comphelper/makesequence.hxx>
      56             : #include <svx/scene3d.hxx>
      57             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      58             : #include <fmtwrapinfluenceonobjpos.hxx>
      59             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      60             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      61             : #include <com/sun/star/drawing/PointSequence.hpp>
      62             : #include <switerator.hxx>
      63             : 
      64             : using ::rtl::OUString;
      65             : using namespace ::com::sun::star;
      66             : 
      67             : DECLARE_STL_USTRINGACCESS_MAP( uno::Sequence< sal_Int8 > *,  SwShapeImplementationIdMap );
      68             : 
      69          10 : static SwShapeImplementationIdMap aImplementationIdMap;
      70             : 
      71             : class SwShapeDescriptor_Impl
      72             : {
      73             :     SwFmtHoriOrient*    pHOrient;
      74             :     SwFmtVertOrient*    pVOrient;
      75             :     SwFmtAnchor*        pAnchor;
      76             :     SwFmtSurround*      pSurround;
      77             :     SvxULSpaceItem*     pULSpace;
      78             :     SvxLRSpaceItem*     pLRSpace;
      79             :     sal_Bool            bOpaque;
      80             :     uno::Reference< text::XTextRange > xTextRange;
      81             :     // #i26791#
      82             :     SwFmtFollowTextFlow* mpFollowTextFlow;
      83             :     // #i28701#
      84             :     SwFmtWrapInfluenceOnObjPos* pWrapInfluenceOnObjPos;
      85             :     // #i28749#
      86             :     sal_Int16 mnPositionLayoutDir;
      87             : 
      88             : public:
      89             :     bool    bInitializedPropertyNotifier;
      90             : 
      91             : public:
      92         411 :     SwShapeDescriptor_Impl() :
      93             :      // #i32349# - no defaults, in order to determine on
      94             :      // adding a shape, if positioning attributes are set or not.
      95             :      pHOrient( 0L ),
      96             :      pVOrient( 0L ),
      97             :      pAnchor(0),
      98             :      pSurround(0),
      99             :      pULSpace(0),
     100             :      pLRSpace(0),
     101             :      bOpaque(sal_False),
     102             :      // #i26791#
     103         411 :      mpFollowTextFlow( new SwFmtFollowTextFlow( sal_False ) ),
     104             :      // #i28701# #i35017#
     105             :      pWrapInfluenceOnObjPos( new SwFmtWrapInfluenceOnObjPos(
     106         411 :                             text::WrapInfluenceOnPosition::ONCE_CONCURRENT ) ),
     107             :      // #i28749#
     108             :      mnPositionLayoutDir( text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
     109        1233 :      bInitializedPropertyNotifier(false)
     110         411 :      {}
     111             : 
     112         411 :     ~SwShapeDescriptor_Impl()
     113         411 :     {
     114         411 :         delete pHOrient;
     115         411 :         delete pVOrient;
     116         411 :         delete pAnchor;
     117         411 :         delete pSurround;
     118         411 :         delete pULSpace;
     119         411 :         delete pLRSpace;
     120             :         // #i26791#
     121         411 :         delete mpFollowTextFlow;
     122             :         // #i28701#
     123         411 :         delete pWrapInfluenceOnObjPos;
     124         411 :     }
     125         132 :     SwFmtAnchor*    GetAnchor(bool bCreate = false)
     126             :         {
     127         132 :             if(bCreate && !pAnchor)
     128             :             {
     129           2 :                 pAnchor = new SwFmtAnchor(FLY_AS_CHAR);
     130             :             }
     131         132 :             return pAnchor;
     132             :         }
     133         418 :     SwFmtHoriOrient* GetHOrient(bool bCreate = false)
     134             :         {
     135         418 :             if (bCreate && !pHOrient)
     136             :             {
     137             :                 // #i26791#
     138          58 :                 pHOrient = new SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
     139             :             }
     140         418 :             return pHOrient;
     141             :         }
     142         418 :     SwFmtVertOrient* GetVOrient(bool bCreate = false)
     143             :         {
     144         418 :             if(bCreate && !pVOrient)
     145             :             {
     146             :                 // #i26791#
     147          58 :                 pVOrient = new SwFmtVertOrient( 0, text::VertOrientation::NONE, text::RelOrientation::FRAME );
     148             :             }
     149         418 :             return pVOrient;
     150             :         }
     151             : 
     152         116 :     SwFmtSurround*  GetSurround(bool bCreate = false)
     153             :         {
     154         116 :             if(bCreate && !pSurround)
     155           0 :                 pSurround = new SwFmtSurround();
     156         116 :             return pSurround;
     157             :         }
     158          58 :     SvxLRSpaceItem* GetLRSpace(bool bCreate = false)
     159             :         {
     160          58 :             if(bCreate && !pLRSpace)
     161           0 :                 pLRSpace = new SvxLRSpaceItem(RES_LR_SPACE);
     162          58 :             return pLRSpace;
     163             :         }
     164          58 :     SvxULSpaceItem* GetULSpace(bool bCreate = false)
     165             :         {
     166          58 :             if(bCreate && !pULSpace)
     167           0 :                 pULSpace = new SvxULSpaceItem(RES_UL_SPACE);
     168          58 :             return pULSpace;
     169             :         }
     170          59 :     uno::Reference< text::XTextRange > &    GetTextRange()
     171             :     {
     172          59 :         return xTextRange;
     173             :     }
     174          58 :     sal_Bool    IsOpaque() const
     175             :         {
     176          58 :             return bOpaque;
     177             :         }
     178          12 :     const sal_Bool&    GetOpaque() const
     179             :         {
     180          12 :             return bOpaque;
     181             :         }
     182           0 :     void RemoveHOrient(){DELETEZ(pHOrient);}
     183           0 :     void RemoveVOrient(){DELETEZ(pVOrient);}
     184           0 :     void RemoveAnchor(){DELETEZ(pAnchor);}
     185           0 :     void RemoveSurround(){DELETEZ(pSurround);}
     186           0 :     void RemoveULSpace(){DELETEZ(pULSpace);}
     187           0 :     void RemoveLRSpace(){DELETEZ(pLRSpace);}
     188           0 :     void SetOpaque(sal_Bool bSet){bOpaque = bSet;}
     189             : 
     190             :     // #i26791#
     191         116 :     SwFmtFollowTextFlow* GetFollowTextFlow( bool _bCreate = false )
     192             :     {
     193         116 :         if ( _bCreate && !mpFollowTextFlow )
     194           0 :             mpFollowTextFlow = new SwFmtFollowTextFlow( sal_False );
     195         116 :         return mpFollowTextFlow;
     196             :     }
     197           0 :     void RemoveFollowTextFlow()
     198             :     {
     199           0 :         DELETEZ(mpFollowTextFlow);
     200           0 :     }
     201             : 
     202             :     // #i28749#
     203           0 :     sal_Int16 GetPositionLayoutDir() const
     204             :     {
     205           0 :         return mnPositionLayoutDir;
     206             :     }
     207           0 :     void SetPositionLayoutDir( sal_Int16 _nPositionLayoutDir )
     208             :     {
     209           0 :         switch ( _nPositionLayoutDir )
     210             :         {
     211             :             case text::PositionLayoutDir::PositionInHoriL2R:
     212             :             case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
     213             :             {
     214           0 :                 mnPositionLayoutDir = _nPositionLayoutDir;
     215             :             }
     216           0 :             break;
     217             :             default:
     218             :             {
     219             :                 OSL_FAIL( "<SwShapeDescriptor_Impl::SetPositionLayoutDir(..)> - invalid attribute value." );
     220             :             }
     221             :         }
     222           0 :     }
     223             :     void RemovePositionLayoutDir()
     224             :     {
     225             :         mnPositionLayoutDir = text::PositionLayoutDir::PositionInLayoutDirOfAnchor;
     226             :     }
     227             : 
     228             :     // #i28701#
     229         116 :     inline SwFmtWrapInfluenceOnObjPos* GetWrapInfluenceOnObjPos(
     230             :                                         const bool _bCreate = false )
     231             :     {
     232         116 :         if ( _bCreate && !pWrapInfluenceOnObjPos )
     233             :         {
     234             :             pWrapInfluenceOnObjPos = new SwFmtWrapInfluenceOnObjPos(
     235             :                         // #i35017#
     236           0 :                         text::WrapInfluenceOnPosition::ONCE_CONCURRENT );
     237             :         }
     238         116 :         return pWrapInfluenceOnObjPos;
     239             :     }
     240           0 :     inline void RemoveWrapInfluenceOnObjPos()
     241             :     {
     242           0 :         DELETEZ(pWrapInfluenceOnObjPos);
     243           0 :     }
     244             : };
     245             : 
     246             : /****************************************************************************
     247             :     class SwFmDrawPage
     248             : ****************************************************************************/
     249         240 : SwFmDrawPage::SwFmDrawPage( SdrPage* pPage ) :
     250         240 :     SvxFmDrawPage( pPage ), pPageView(0)
     251             : {
     252         240 : }
     253             : 
     254         198 : SwFmDrawPage::~SwFmDrawPage() throw ()
     255             : {
     256          66 :     RemovePageView();
     257         132 : }
     258             : 
     259           0 : const SdrMarkList&  SwFmDrawPage::PreGroup(const uno::Reference< drawing::XShapes > & xShapes)
     260             : {
     261           0 :     _SelectObjectsInView( xShapes, GetPageView() );
     262           0 :     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
     263           0 :     return rMarkList;
     264             : }
     265             : 
     266           0 : void SwFmDrawPage::PreUnGroup(const uno::Reference< drawing::XShapeGroup >  xShapeGroup)
     267             : {
     268           0 :     uno::Reference< drawing::XShape >  xShape( xShapeGroup, uno::UNO_QUERY);
     269           0 :     _SelectObjectInView( xShape, GetPageView() );
     270           0 : }
     271             : 
     272           0 : SdrPageView*    SwFmDrawPage::GetPageView()
     273             : {
     274           0 :     if(!pPageView)
     275           0 :         pPageView = mpView->ShowSdrPage( mpPage );
     276           0 :     return pPageView;
     277             : }
     278             : 
     279          66 : void    SwFmDrawPage::RemovePageView()
     280             : {
     281          66 :     if(pPageView && mpView)
     282           0 :         mpView->HideSdrPage();
     283          66 :     pPageView = 0;
     284          66 : }
     285             : 
     286           0 : uno::Reference< uno::XInterface >   SwFmDrawPage::GetInterface( SdrObject* pObj )
     287             : {
     288           0 :     uno::Reference< XInterface >  xShape;
     289           0 :     if( pObj )
     290             :     {
     291           0 :         SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
     292           0 :         SwXShape* pxShape = SwIterator<SwXShape,SwFmt>::FirstElement( *pFmt );
     293           0 :         if(pxShape)
     294             :         {
     295           0 :             xShape =  *(cppu::OWeakObject*)pxShape;
     296             :         }
     297             :         else
     298           0 :             xShape = pObj->getUnoShape();
     299             :     }
     300           0 :     return xShape;
     301             : }
     302             : 
     303          70 : SdrObject* SwFmDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xShape ) throw ()
     304             : {
     305             :     //TODO: stimmt das so - kann die Methode weg?
     306          70 :     return SvxFmDrawPage::_CreateSdrObject( xShape );
     307             : }
     308             : 
     309         402 : uno::Reference< drawing::XShape >  SwFmDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
     310             : {
     311         402 :     uno::Reference< drawing::XShape >  xRet;
     312         402 :     if(pObj->ISA(SwVirtFlyDrawObj) || pObj->GetObjInventor() == SWGInventor)
     313             :     {
     314          65 :         SwFlyDrawContact* pFlyContact = (SwFlyDrawContact*)pObj->GetUserCall();
     315          65 :         if(pFlyContact)
     316             :         {
     317          65 :             FlyCntType eType = FLYCNTTYPE_ALL;
     318          65 :             SwFrmFmt* pFlyFmt = pFlyContact->GetFmt();
     319          65 :             SwDoc* pDoc = pFlyFmt->GetDoc();
     320             :             const SwNodeIndex* pIdx;
     321         195 :             if( RES_FLYFRMFMT == pFlyFmt->Which()
     322          65 :                 && 0 != ( pIdx = pFlyFmt->GetCntnt().GetCntntIdx() )
     323          65 :                 && pIdx->GetNodes().IsDocNodes()
     324             :                 )
     325             :             {
     326          65 :                 const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
     327          65 :                 if(!pNd->IsNoTxtNode())
     328          11 :                     eType = FLYCNTTYPE_FRM;
     329          54 :                 else if( pNd->IsGrfNode() )
     330          10 :                     eType = FLYCNTTYPE_GRF;
     331          44 :                 else if( pNd->IsOLENode() )
     332          44 :                     eType = FLYCNTTYPE_OLE;
     333             :             }
     334             :             else
     335             :             {
     336             :                 OSL_FAIL( "<SwFmDrawPage::_CreateShape(..)> - could not retrieve type. Thus, no shape created." );
     337           0 :                 return xRet;
     338             :             }
     339             :             OSL_ENSURE( eType != FLYCNTTYPE_ALL, "unexpected FlyCntType value for eType" );
     340          65 :             xRet = SwXFrames::GetObject( *pFlyFmt, eType );
     341             :         }
     342             :      }
     343             :     else
     344             :     {
     345             :         // own block - temporary object has to be destroyed before
     346             :         // the delegator is set #81670#
     347             :         {
     348         337 :             xRet = SvxFmDrawPage::_CreateShape( pObj );
     349             :         }
     350         337 :         uno::Reference< XUnoTunnel > xShapeTunnel(xRet, uno::UNO_QUERY);
     351             :         //don't create an SwXShape if it already exists
     352         337 :         SwXShape* pShape = 0;
     353         337 :         if(xShapeTunnel.is())
     354             :             pShape = reinterpret_cast< SwXShape * >(
     355         337 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
     356         337 :         if(!pShape)
     357             :         {
     358         337 :             xShapeTunnel = 0;
     359         337 :             uno::Reference< uno::XInterface > xCreate(xRet, uno::UNO_QUERY);
     360         337 :             xRet = 0;
     361         337 :             uno::Reference< beans::XPropertySet >  xPrSet;
     362         337 :             if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || ( PTR_CAST(E3dScene,pObj ) != NULL ) ) )
     363           6 :                 xPrSet = new SwXGroupShape( xCreate );
     364             :             else
     365         331 :                 xPrSet = new SwXShape( xCreate );
     366         337 :             xRet = uno::Reference< drawing::XShape >(xPrSet, uno::UNO_QUERY);
     367         337 :         }
     368             :     }
     369         402 :     return xRet;
     370             : }
     371             : 
     372             : /****************************************************************************
     373             :     class SwXShapesEnumeration
     374             : ****************************************************************************/
     375             : namespace
     376             : {
     377             :     class SwXShapesEnumeration
     378             :         : public SwSimpleEnumeration_Base
     379             :     {
     380             :         private:
     381             :             typedef ::std::list< ::com::sun::star::uno::Any > shapescontainer_t;
     382             :             shapescontainer_t m_aShapes;
     383             :         protected:
     384          16 :             virtual ~SwXShapesEnumeration() {};
     385             :         public:
     386             :             SwXShapesEnumeration(SwXDrawPage* const pDrawPage);
     387             : 
     388             :             //XEnumeration
     389             :             virtual sal_Bool SAL_CALL hasMoreElements(void) throw(uno::RuntimeException);
     390             :             virtual uno::Any SAL_CALL nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
     391             : 
     392             :             //XServiceInfo
     393             :             virtual OUString SAL_CALL getImplementationName(void) throw(uno::RuntimeException);
     394             :             virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(uno::RuntimeException);
     395             :             virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames(void) throw(uno::RuntimeException);
     396             :     };
     397             : }
     398             : 
     399           8 : SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage)
     400           8 :     : m_aShapes()
     401             : {
     402           8 :     SolarMutexGuard aGuard;
     403           8 :     ::std::insert_iterator<shapescontainer_t> pInserter = ::std::insert_iterator<shapescontainer_t>(m_aShapes, m_aShapes.begin());
     404           8 :     sal_Int32 nCount = pDrawPage->getCount();
     405           8 :     for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++)
     406             :     {
     407           0 :         uno::Reference<drawing::XShape> xShape = uno::Reference<drawing::XShape>(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY);
     408           0 :         *pInserter++ = uno::makeAny(xShape);
     409           8 :     }
     410           8 : }
     411             : 
     412           8 : sal_Bool SwXShapesEnumeration::hasMoreElements(void) throw(uno::RuntimeException)
     413             : {
     414           8 :     SolarMutexGuard aGuard;
     415           8 :     return !m_aShapes.empty();
     416             : }
     417             : 
     418           0 : uno::Any SwXShapesEnumeration::nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     419             : {
     420           0 :     SolarMutexGuard aGuard;
     421           0 :     if(m_aShapes.empty())
     422           0 :         throw container::NoSuchElementException();
     423           0 :     uno::Any aResult = *m_aShapes.begin();
     424           0 :     m_aShapes.pop_front();
     425           0 :     return aResult;
     426             : }
     427             : 
     428           0 : OUString SwXShapesEnumeration::getImplementationName(void) throw(uno::RuntimeException)
     429             : {
     430           0 :     return C2U("SwXShapeEnumeration");
     431             : }
     432             : 
     433           0 : sal_Bool SwXShapesEnumeration::supportsService(const OUString& ServiceName) throw(uno::RuntimeException)
     434             : {
     435           0 :     return C2U("com.sun.star.container.XEnumeration") == ServiceName;
     436             : }
     437             : 
     438           0 : uno::Sequence< OUString > SwXShapesEnumeration::getSupportedServiceNames(void) throw(uno::RuntimeException)
     439             : {
     440           0 :     return ::comphelper::makeSequence(C2U("com.sun.star.container.XEnumeration"));
     441             : }
     442             : 
     443             : /****************************************************************************
     444             :     class SwXDrawPage
     445             : ****************************************************************************/
     446           8 : uno::Reference< container::XEnumeration > SwXDrawPage::createEnumeration(void) throw( uno::RuntimeException )
     447             : {
     448           8 :     SolarMutexGuard aGuard;
     449             :     return uno::Reference< container::XEnumeration >(
     450           8 :         new SwXShapesEnumeration(this));
     451             : }
     452             : 
     453           0 : rtl::OUString SwXDrawPage::getImplementationName(void) throw( uno::RuntimeException )
     454             : {
     455           0 :     return C2U("SwXDrawPage");
     456             : }
     457             : 
     458           3 : sal_Bool SwXDrawPage::supportsService(const rtl::OUString& rServiceName) throw( uno::RuntimeException )
     459             : {
     460           3 :     return C2U("com.sun.star.drawing.GenericDrawPage") == rServiceName;
     461             : }
     462             : 
     463           0 : uno::Sequence< rtl::OUString > SwXDrawPage::getSupportedServiceNames(void) throw( uno::RuntimeException )
     464             : {
     465           0 :     uno::Sequence< rtl::OUString > aRet(1);
     466           0 :     rtl::OUString* pArray = aRet.getArray();
     467           0 :     pArray[0] = C2U("com.sun.star.drawing.GenericDrawPage");
     468           0 :     return aRet;
     469             : }
     470             : 
     471         240 : SwXDrawPage::SwXDrawPage(SwDoc* pDc) :
     472             :     pDoc(pDc),
     473         240 :     pDrawPage(0)
     474             : {
     475         240 : }
     476             : 
     477         198 : SwXDrawPage::~SwXDrawPage()
     478             : {
     479          66 :     if(xPageAgg.is())
     480             :     {
     481          66 :         uno::Reference< uno::XInterface >  xInt;
     482          66 :         xPageAgg->setDelegator(xInt);
     483             :     }
     484         132 : }
     485             : 
     486        3494 : uno::Any SwXDrawPage::queryInterface( const uno::Type& aType )
     487             :                                                 throw( uno::RuntimeException )
     488             : {
     489        3494 :     uno::Any aRet = SwXDrawPageBaseClass::queryInterface(aType);
     490        3494 :     if(!aRet.hasValue())
     491             :     {
     492             :         // secure with checking if page exists. This may not be the case
     493             :         // either for new SW docs with no yet graphics usage or when
     494             :         // the doc is closed and someone else still holds a UNO reference
     495             :         // to the XDrawPage (in that case, pDoc is set to 0)
     496         776 :         SwFmDrawPage* pPage = GetSvxPage();
     497             : 
     498         776 :         if(pPage)
     499             :         {
     500         776 :             aRet = pPage->queryAggregation(aType);
     501             :         }
     502             :     }
     503        3494 :     return aRet;
     504             : }
     505             : 
     506           0 : uno::Sequence< uno::Type > SwXDrawPage::getTypes() throw( uno::RuntimeException )
     507             : {
     508           0 :     uno::Sequence< uno::Type > aPageTypes = SwXDrawPageBaseClass::getTypes();
     509           0 :     uno::Sequence< uno::Type > aSvxTypes = GetSvxPage()->getTypes();
     510             : 
     511           0 :     long nIndex = aPageTypes.getLength();
     512           0 :     aPageTypes.realloc(aPageTypes.getLength() + aSvxTypes.getLength() + 1);
     513             : 
     514           0 :     uno::Type* pPageTypes = aPageTypes.getArray();
     515           0 :     const uno::Type* pSvxTypes = aSvxTypes.getConstArray();
     516             :     long nPos;
     517           0 :     for(nPos = 0; nPos < aSvxTypes.getLength(); nPos++)
     518             :     {
     519           0 :         pPageTypes[nIndex++] = pSvxTypes[nPos];
     520             :     }
     521           0 :     pPageTypes[nIndex] = ::getCppuType((uno::Reference<form::XFormsSupplier2>*)0);
     522           0 :     return aPageTypes;
     523             : }
     524             : 
     525          42 : sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException )
     526             : {
     527          42 :     SolarMutexGuard aGuard;
     528          42 :     if(!pDoc)
     529           0 :         throw uno::RuntimeException();
     530          42 :     if(!pDoc->GetDrawModel())
     531           0 :         return 0;
     532             :     else
     533             :     {
     534          42 :         ((SwXDrawPage*)this)->GetSvxPage();
     535          42 :         return pDrawPage->getCount();
     536          42 :     }
     537             : }
     538             : 
     539          61 : uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex)
     540             :         throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
     541             :                uno::RuntimeException )
     542             : {
     543          61 :     SolarMutexGuard aGuard;
     544          61 :     if(!pDoc)
     545           0 :         throw uno::RuntimeException();
     546          61 :     if(!pDoc->GetDrawModel())
     547           0 :         throw lang::IndexOutOfBoundsException();
     548             : 
     549          61 :     ((SwXDrawPage*)this)->GetSvxPage();
     550          61 :     return pDrawPage->getByIndex( nIndex );
     551             : }
     552             : 
     553           0 : uno::Type  SwXDrawPage::getElementType(void) throw( uno::RuntimeException )
     554             : {
     555           0 :     return ::getCppuType((const uno::Reference<drawing::XShape>*)0);
     556             : }
     557             : 
     558           0 : sal_Bool SwXDrawPage::hasElements(void) throw( uno::RuntimeException )
     559             : {
     560           0 :     SolarMutexGuard aGuard;
     561           0 :     if(!pDoc)
     562           0 :         throw uno::RuntimeException();
     563           0 :     if(!pDoc->GetDrawModel())
     564           0 :         return sal_False;
     565             :     else
     566           0 :         return ((SwXDrawPage*)this)->GetSvxPage()->hasElements();
     567             : }
     568             : 
     569          90 : void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
     570             :     throw( uno::RuntimeException )
     571             : {
     572          90 :     SolarMutexGuard aGuard;
     573          90 :     if(!pDoc)
     574           0 :         throw uno::RuntimeException();
     575          90 :     uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShape, uno::UNO_QUERY);
     576          90 :     SwXShape* pShape = 0;
     577          90 :     SvxShape* pSvxShape = 0;
     578          90 :     if(xShapeTunnel.is())
     579             :     {
     580             :         pShape      = reinterpret_cast< SwXShape * >(
     581          90 :                 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
     582             :         pSvxShape   = reinterpret_cast< SvxShape * >(
     583          90 :                 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
     584             :     }
     585             : 
     586          90 :     if(!pShape || pShape->GetRegisteredIn() || !pShape->m_bDescriptor )
     587             :     {
     588          32 :         uno::RuntimeException aExcept;
     589          32 :         if(pShape)
     590          32 :             aExcept.Message = C2U("object already inserted");
     591             :         else
     592           0 :             aExcept.Message = C2U("illegal object");
     593          32 :         throw aExcept;
     594             :     }
     595             : 
     596          58 :     if ( pSvxShape->GetSdrObject() )
     597             :     {
     598           0 :         if ( pSvxShape->GetSdrObject()->IsInserted() )
     599             :         {
     600          58 :             return;
     601             :         }
     602             :     }
     603          58 :     GetSvxPage()->add(xShape);
     604             : 
     605          58 :     uno::Reference< uno::XAggregation >     xAgg = pShape->GetAggregationInterface();
     606             : 
     607             :     OSL_ENSURE(pSvxShape, "warum gibt es hier kein SvxShape?");
     608             :     //diese Position ist auf jeden Fall in 1/100 mm
     609          58 :     awt::Point aMM100Pos(pSvxShape->getPosition());
     610             : 
     611             :     //jetzt noch die Properties aus dem SwShapeDescriptor_Impl auswerten
     612          58 :     SwShapeDescriptor_Impl* pDesc = pShape->GetDescImpl();
     613             : 
     614          58 :     SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     615          58 :                                         RES_FRMATR_END-1 );
     616          58 :     SwFmtAnchor aAnchor( FLY_AS_CHAR );
     617          58 :     sal_Bool bOpaque = sal_False;
     618          58 :     if( pDesc )
     619             :     {
     620          58 :         if(pDesc->GetSurround())
     621           0 :             aSet.Put( *pDesc->GetSurround());
     622             :         //die Items sind schon in Twip gesetzt
     623          58 :         if(pDesc->GetLRSpace())
     624             :         {
     625           0 :             aSet.Put(*pDesc->GetLRSpace());
     626             :         }
     627          58 :         if(pDesc->GetULSpace())
     628             :         {
     629           0 :             aSet.Put(*pDesc->GetULSpace());
     630             :         }
     631          58 :         if(pDesc->GetAnchor())
     632           2 :             aAnchor = *pDesc->GetAnchor();
     633             : 
     634             :         // #i32349# - if no horizontal position exists, create one
     635          58 :         if ( !pDesc->GetHOrient() )
     636             :         {
     637          58 :             SwFmtHoriOrient* pHori = pDesc->GetHOrient( true );
     638          58 :             SwTwips nHoriPos = MM100_TO_TWIP(aMM100Pos.X);
     639          58 :             pHori->SetPos( nHoriPos );
     640             :         }
     641             :         {
     642          58 :             if(pDesc->GetHOrient()->GetHoriOrient() == text::HoriOrientation::NONE)
     643          58 :                 aMM100Pos.X = TWIP_TO_MM100(pDesc->GetHOrient()->GetPos());
     644          58 :             aSet.Put( *pDesc->GetHOrient() );
     645             :         }
     646             :         // #i32349# - if no vertical position exists, create one
     647          58 :         if ( !pDesc->GetVOrient() )
     648             :         {
     649          58 :             SwFmtVertOrient* pVert = pDesc->GetVOrient( true );
     650          58 :             SwTwips nVertPos = MM100_TO_TWIP(aMM100Pos.Y);
     651          58 :             pVert->SetPos( nVertPos );
     652             :         }
     653             :         {
     654          58 :             if(pDesc->GetVOrient()->GetVertOrient() == text::VertOrientation::NONE)
     655          58 :                 aMM100Pos.Y = TWIP_TO_MM100(pDesc->GetVOrient()->GetPos());
     656          58 :             aSet.Put( *pDesc->GetVOrient() );
     657             :         }
     658             : 
     659          58 :         if(pDesc->GetSurround())
     660           0 :             aSet.Put( *pDesc->GetSurround());
     661          58 :         bOpaque = pDesc->IsOpaque();
     662             : 
     663             :         // #i26791#
     664          58 :         if ( pDesc->GetFollowTextFlow() )
     665             :         {
     666          58 :             aSet.Put( *pDesc->GetFollowTextFlow() );
     667             :         }
     668             : 
     669             :         // #i28701#
     670          58 :         if ( pDesc->GetWrapInfluenceOnObjPos() )
     671             :         {
     672          58 :             aSet.Put( *pDesc->GetWrapInfluenceOnObjPos() );
     673             :         }
     674             :     }
     675             : 
     676          58 :     pSvxShape->setPosition(aMM100Pos);
     677          58 :     SdrObject* pObj = pSvxShape->GetSdrObject();
     678             :     // #108784# - set layer of new drawing object to corresponding
     679             :     // invisible layer.
     680          58 :     if(FmFormInventor != pObj->GetObjInventor())
     681          58 :         pObj->SetLayer( bOpaque ? pDoc->GetInvisibleHeavenId() : pDoc->GetInvisibleHellId() );
     682             :     else
     683           0 :         pObj->SetLayer(pDoc->GetInvisibleControlsId());
     684             : 
     685          58 :     SwPaM* pPam = new SwPaM(pDoc->GetNodes().GetEndOfContent());
     686          58 :     SwUnoInternalPaM* pInternalPam = 0;
     687          58 :     uno::Reference< text::XTextRange >  xRg;
     688          58 :     if( pDesc && (xRg = pDesc->GetTextRange()).is() )
     689             :     {
     690           1 :         pInternalPam = new SwUnoInternalPaM(*pDoc);
     691           1 :         if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg))
     692             :         {
     693           1 :             if(FLY_AT_FLY == aAnchor.GetAnchorId() &&
     694           0 :                                 !pInternalPam->GetNode()->FindFlyStartNode())
     695             :             {
     696           0 :                         aAnchor.SetType(FLY_AS_CHAR);
     697             :             }
     698           1 :             else if (FLY_AT_PAGE == aAnchor.GetAnchorId())
     699             :             {
     700           0 :                 aAnchor.SetAnchor(pInternalPam->Start());
     701             :             }
     702             :         }
     703             :         else
     704           0 :             throw uno::RuntimeException();
     705             :     }
     706          57 :     else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetCurrentLayout())
     707             :     {
     708           0 :         SwCrsrMoveState aState( MV_SETONLYTEXT );
     709           0 :         Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y));
     710           0 :         pDoc->GetCurrentLayout()->GetCrsrOfst( pPam->GetPoint(), aTmp, &aState );   //swmod 080218
     711           0 :         aAnchor.SetAnchor( pPam->GetPoint() );
     712             : 
     713             :         // #i32349# - adjustment of vertical positioning
     714             :         // attributes no longer needed, because its already got a default.
     715             :     }
     716             :     else
     717             :     {
     718          57 :         aAnchor.SetType(FLY_AT_PAGE);
     719             : 
     720             :         // #i32349# - adjustment of vertical positioning
     721             :         // attributes no longer needed, because its already got a default.
     722             :     }
     723          58 :     aSet.Put(aAnchor);
     724          58 :     SwPaM* pTemp = pInternalPam;
     725          58 :     if ( !pTemp )
     726          57 :         pTemp = pPam;
     727          58 :     UnoActionContext aAction(pDoc);
     728          58 :     pDoc->Insert( *pTemp, *pObj, &aSet, NULL );
     729          58 :     SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
     730          58 :     if(pFmt)
     731          58 :         pFmt->Add(pShape);
     732          58 :     pShape->m_bDescriptor = sal_False;
     733             : 
     734          58 :     delete pPam;
     735          58 :     delete pInternalPam;
     736             : }
     737             : 
     738           1 : void SwXDrawPage::remove(const uno::Reference< drawing::XShape > & xShape) throw( uno::RuntimeException )
     739             : {
     740           1 :     SolarMutexGuard aGuard;
     741           1 :     if(!pDoc)
     742           0 :         throw uno::RuntimeException();
     743           1 :     uno::Reference<lang::XComponent> xComp(xShape, uno::UNO_QUERY);
     744           1 :     xComp->dispose();
     745           1 : }
     746             : 
     747           0 : uno::Reference< drawing::XShapeGroup >  SwXDrawPage::group(const uno::Reference< drawing::XShapes > & xShapes) throw( uno::RuntimeException )
     748             : {
     749           0 :     SolarMutexGuard aGuard;
     750           0 :     if(!pDoc || !xShapes.is())
     751           0 :         throw uno::RuntimeException();
     752           0 :     uno::Reference< drawing::XShapeGroup >  xRet;
     753           0 :     if(xPageAgg.is())
     754             :     {
     755             : 
     756           0 :         SwFmDrawPage* pPage = GetSvxPage();
     757           0 :         if(pPage)//kann das auch Null sein?
     758             :         {
     759             :             //markieren und MarkList zurueckgeben
     760           0 :             const SdrMarkList& rMarkList = pPage->PreGroup(xShapes);
     761           0 :             if ( rMarkList.GetMarkCount() > 1 )
     762             :             {
     763           0 :                 bool bFlyInCnt = false;
     764           0 :                 for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i )
     765             :                 {
     766           0 :                     const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
     767           0 :                     if (FLY_AS_CHAR == ::FindFrmFmt(const_cast<SdrObject*>(
     768           0 :                                             pObj))->GetAnchor().GetAnchorId())
     769             :                     {
     770           0 :                         bFlyInCnt = true;
     771             :                     }
     772             :                 }
     773           0 :                 if( bFlyInCnt )
     774           0 :                     throw uno::RuntimeException();
     775           0 :                 if( !bFlyInCnt )
     776             :                 {
     777           0 :                     UnoActionContext aContext(pDoc);
     778           0 :                     pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
     779             : 
     780           0 :                     SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() );
     781             :                     pDoc->ChgAnchor(
     782           0 :                         pPage->GetDrawView()->GetMarkedObjectList(),
     783             :                         FLY_AT_PARA/*int eAnchorId*/,
     784           0 :                         true, false );
     785             : 
     786           0 :                     pPage->GetDrawView()->UnmarkAll();
     787           0 :                     if(pContact)
     788             :                     {
     789           0 :                         uno::Reference< uno::XInterface >  xInt = pPage->GetInterface( pContact->GetMaster() );
     790           0 :                         xRet = uno::Reference< drawing::XShapeGroup >(xInt, uno::UNO_QUERY);
     791             :                     }
     792           0 :                     pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
     793             :                 }
     794             :             }
     795           0 :             pPage->RemovePageView();
     796             :         }
     797             :     }
     798           0 :     return xRet;
     799             : }
     800             : 
     801           0 : void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeGroup) throw( uno::RuntimeException )
     802             : {
     803           0 :     SolarMutexGuard aGuard;
     804           0 :     if(!pDoc)
     805           0 :         throw uno::RuntimeException();
     806           0 :     if(xPageAgg.is())
     807             :     {
     808           0 :         SwFmDrawPage* pPage = GetSvxPage();
     809           0 :         if(pPage)//kann das auch Null sein?
     810             :         {
     811           0 :             pPage->PreUnGroup(xShapeGroup);
     812           0 :             UnoActionContext aContext(pDoc);
     813           0 :             pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
     814             : 
     815           0 :             pDoc->UnGroupSelection( *pPage->GetDrawView() );
     816           0 :             pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(),
     817             :                         FLY_AT_PARA/*int eAnchorId*/,
     818           0 :                         true, false );
     819           0 :             pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
     820             :         }
     821           0 :         pPage->RemovePageView();
     822           0 :     }
     823           0 : }
     824             : 
     825         937 : SwFmDrawPage*   SwXDrawPage::GetSvxPage()
     826             : {
     827         937 :     if(!xPageAgg.is() && pDoc)
     828             :     {
     829         240 :         SolarMutexGuard aGuard;
     830             :         // #i52858#
     831         240 :         SdrModel* pModel = pDoc->GetOrCreateDrawModel();
     832         240 :         SdrPage* pPage = pModel->GetPage( 0 );
     833             : 
     834             :         {
     835             :             // waehrend des queryInterface braucht man ein Ref auf das
     836             :             // Objekt, sonst wird es geloescht.
     837         240 :             pDrawPage = new SwFmDrawPage(pPage);
     838         240 :             uno::Reference< drawing::XDrawPage >  xPage = pDrawPage;
     839         240 :             uno::Any aAgg = xPage->queryInterface(::getCppuType((uno::Reference< uno::XAggregation >*)0));
     840         240 :             if(aAgg.getValueType() == ::getCppuType((uno::Reference< uno::XAggregation >*)0))
     841         240 :                 xPageAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
     842             :         }
     843         240 :         if( xPageAgg.is() )
     844         240 :             xPageAgg->setDelegator( (cppu::OWeakObject*)this );
     845             :     }
     846         937 :     return pDrawPage;
     847             : }
     848             : 
     849             : // renamed and outlined to detect where it's called
     850          66 : void SwXDrawPage::InvalidateSwDoc()
     851             : {
     852          66 :     pDoc = 0;
     853          66 : }
     854             : 
     855         375 : TYPEINIT1(SwXShape, SwClient);
     856             : 
     857             : namespace
     858             : {
     859             :     class theSwXShapeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXShapeUnoTunnelId > {};
     860             : }
     861             : 
     862        1875 : const uno::Sequence< sal_Int8 > & SwXShape::getUnoTunnelId()
     863             : {
     864        1875 :     return theSwXShapeUnoTunnelId::get().getSeq();
     865             : }
     866             : 
     867        1382 : sal_Int64 SAL_CALL SwXShape::getSomething( const uno::Sequence< sal_Int8 >& rId )
     868             :     throw(uno::RuntimeException)
     869             : {
     870        2764 :     if( rId.getLength() == 16
     871        1382 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
     872        2764 :                                         rId.getConstArray(), 16 ) )
     873             :     {
     874         156 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
     875             :     }
     876             : 
     877        1226 :     if( xShapeAgg.is() )
     878             :     {
     879        1226 :         const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*)0 );
     880        1226 :         uno::Any aAgg = xShapeAgg->queryAggregation( rTunnelType );
     881        1226 :         if(aAgg.getValueType() == rTunnelType)
     882             :         {
     883             :             uno::Reference<lang::XUnoTunnel> xAggTunnel =
     884        1226 :                     *(uno::Reference<lang::XUnoTunnel>*)aAgg.getValue();
     885        1226 :             if(xAggTunnel.is())
     886        1226 :                 return xAggTunnel->getSomething(rId);
     887        1226 :         }
     888             :     }
     889           0 :     return 0;
     890             : }
     891             : namespace
     892             : {
     893         391 :     static void lcl_addShapePropertyEventFactories( SdrObject& _rObj, SwXShape& _rShape )
     894             :     {
     895         391 :         ::svx::PPropertyValueProvider pProvider( new ::svx::PropertyValueProvider( _rShape, "AnchorType" ) );
     896         391 :         _rObj.getShapePropertyChangeNotifier().registerProvider( ::svx::eTextShapeAnchorType, pProvider );
     897         391 :     }
     898             : }
     899             : 
     900             : 
     901         411 : SwXShape::SwXShape(uno::Reference< uno::XInterface > & xShape) :
     902         411 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)),
     903         411 :     m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)),
     904             :     pImplementationId(0),
     905           0 :     pImpl(new SwShapeDescriptor_Impl()),
     906        1233 :     m_bDescriptor(sal_True)
     907             : {
     908         411 :     if(xShape.is())  // default Ctor
     909             :     {
     910         411 :         const uno::Type& rAggType = ::getCppuType((const uno::Reference< uno::XAggregation >*)0);
     911             :         //aAgg contains a reference of the SvxShape!
     912             :         {
     913         411 :             uno::Any aAgg = xShape->queryInterface(rAggType);
     914         411 :             if(aAgg.getValueType() == rAggType)
     915         411 :                 xShapeAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
     916             :             // #i31698#
     917         411 :             if ( xShapeAgg.is() )
     918             :             {
     919         411 :                 xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< drawing::XShape >*)0) ) >>= mxShape;
     920             :                 OSL_ENSURE( mxShape.is(),
     921             :                         "<SwXShape::SwXShape(..)> - no XShape found at <xShapeAgg>" );
     922         411 :             }
     923             :         }
     924         411 :         xShape = 0;
     925         411 :         m_refCount++;
     926         411 :         if( xShapeAgg.is() )
     927         411 :             xShapeAgg->setDelegator( (cppu::OWeakObject*)this );
     928         411 :         m_refCount--;
     929             : 
     930         411 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
     931         411 :         SvxShape* pShape = 0;
     932         411 :         if(xShapeTunnel.is())
     933             :             pShape = reinterpret_cast< SvxShape * >(
     934         411 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
     935             : 
     936         411 :         SdrObject* pObj = pShape ? pShape->GetSdrObject() : 0;
     937         411 :         if(pObj)
     938             :         {
     939         337 :             SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
     940         337 :             if(pFmt)
     941         215 :                 pFmt->Add(this);
     942             : 
     943         337 :             lcl_addShapePropertyEventFactories( *pObj, *this );
     944         337 :             pImpl->bInitializedPropertyNotifier = true;
     945         411 :         }
     946             :     }
     947         411 : }
     948             : 
     949         105 : void SwXShape::AddExistingShapeToFmt( SdrObject& _rObj )
     950             : {
     951         105 :     SdrObjListIter aIter( _rObj, IM_DEEPNOGROUPS );
     952         433 :     while ( aIter.IsMore() )
     953             :     {
     954         223 :         SdrObject* pCurrent = aIter.Next();
     955             :         OSL_ENSURE( pCurrent, "SwXShape::AddExistingShapeToFmt: invalid object list element!" );
     956         223 :         if ( !pCurrent )
     957           0 :             continue;
     958             : 
     959         223 :         SwXShape* pSwShape = NULL;
     960         223 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel( pCurrent->getWeakUnoShape(), uno::UNO_QUERY );
     961         223 :         if ( xShapeTunnel.is() )
     962             :             pSwShape = reinterpret_cast< SwXShape * >(
     963          54 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething( SwXShape::getUnoTunnelId() ) ) );
     964         223 :         if ( pSwShape )
     965             :         {
     966          54 :             if ( pSwShape->m_bDescriptor )
     967             :             {
     968          54 :                 SwFrmFmt* pFmt = ::FindFrmFmt( const_cast< SdrObject* >( pCurrent ) );
     969          54 :                 if ( pFmt )
     970          54 :                     pFmt->Add( pSwShape );
     971          54 :                 pSwShape->m_bDescriptor = sal_False;
     972             :             }
     973             : 
     974          54 :             if ( !pSwShape->pImpl->bInitializedPropertyNotifier )
     975             :             {
     976          54 :                 lcl_addShapePropertyEventFactories( *pCurrent, *pSwShape );
     977          54 :                 pSwShape->pImpl->bInitializedPropertyNotifier = true;
     978             :             }
     979             :         }
     980         328 :     }
     981         105 : }
     982             : 
     983        1221 : SwXShape::~SwXShape()
     984             : {
     985         411 :     if (xShapeAgg.is())
     986             :     {
     987         411 :         uno::Reference< uno::XInterface >  xRef;
     988         411 :         xShapeAgg->setDelegator(xRef);
     989             :     }
     990         411 :     delete pImpl;
     991         810 : }
     992             : 
     993        4777 : uno::Any SwXShape::queryInterface( const uno::Type& aType ) throw( uno::RuntimeException )
     994             : {
     995        4777 :     uno::Any aRet = SwXShapeBaseClass::queryInterface(aType);
     996             :     // #i53320# - follow-up of #i31698#
     997             :     // interface drawing::XShape is overloaded. Thus, provide
     998             :     // correct object instance.
     999        4777 :     if(!aRet.hasValue() && xShapeAgg.is())
    1000             :     {
    1001         242 :         if(aType == ::getCppuType((uno::Reference<XShape>*)0))
    1002           0 :             aRet <<= uno::Reference<XShape>(this);
    1003             :         else
    1004         242 :             aRet = xShapeAgg->queryAggregation(aType);
    1005             :     }
    1006        4777 :     return aRet;
    1007             : }
    1008             : 
    1009           0 : uno::Sequence< uno::Type > SwXShape::getTypes(  ) throw(uno::RuntimeException)
    1010             : {
    1011           0 :     uno::Sequence< uno::Type > aRet = SwXShapeBaseClass::getTypes();
    1012           0 :     if(xShapeAgg.is())
    1013             :     {
    1014           0 :         uno::Any aProv = xShapeAgg->queryAggregation(::getCppuType((uno::Reference< XTypeProvider >*)0));
    1015           0 :         if(aProv.hasValue())
    1016             :         {
    1017           0 :             uno::Reference< XTypeProvider > xAggProv;
    1018           0 :             aProv >>= xAggProv;
    1019           0 :             uno::Sequence< uno::Type > aAggTypes = xAggProv->getTypes();
    1020           0 :             const uno::Type* pAggTypes = aAggTypes.getConstArray();
    1021           0 :             long nIndex = aRet.getLength();
    1022             : 
    1023           0 :             aRet.realloc(nIndex + aAggTypes.getLength());
    1024           0 :             uno::Type* pBaseTypes = aRet.getArray();
    1025             : 
    1026           0 :             for(long i = 0; i < aAggTypes.getLength(); i++)
    1027           0 :                 pBaseTypes[nIndex++] = pAggTypes[i];
    1028           0 :         }
    1029             :     }
    1030           0 :     return aRet;
    1031             : }
    1032             : 
    1033           0 : uno::Sequence< sal_Int8 > SwXShape::getImplementationId(  ) throw(uno::RuntimeException)
    1034             : {
    1035           0 :     SolarMutexGuard aGuard;
    1036             :     // do we need to compute the implementation id for this instance?
    1037           0 :     if( !pImplementationId && xShapeAgg.is())
    1038             :     {
    1039           0 :         uno::Reference< XShape > xAggShape;
    1040           0 :         xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< XShape >*)0) ) >>= xAggShape;
    1041             : 
    1042           0 :         if( xAggShape.is() )
    1043             :         {
    1044           0 :             const rtl::OUString aShapeType( xAggShape->getShapeType() );
    1045             :             // did we already compute an implementation id for the agregated shape type?
    1046           0 :             SwShapeImplementationIdMap::iterator aIter( aImplementationIdMap.find(aShapeType ) );
    1047           0 :             if( aIter == aImplementationIdMap.end() )
    1048             :             {
    1049             :                 // we need to create a new implementation id for this
    1050             :                 // note: this memory is not free'd until application exists
    1051             :                 //       but since we have a fixed set of shapetypes and the
    1052             :                 //       memory will be reused this is ok.
    1053           0 :                 pImplementationId = new uno::Sequence< sal_Int8 >( 16 );
    1054           0 :                 rtl_createUuid( (sal_uInt8 *) pImplementationId->getArray(), 0, sal_True );
    1055           0 :                 aImplementationIdMap[ aShapeType ] = pImplementationId;
    1056             :             }
    1057             :             else
    1058             :             {
    1059             :                 // use the already computed implementation id
    1060           0 :                 pImplementationId = (*aIter).second;
    1061           0 :             }
    1062           0 :         }
    1063             :     }
    1064           0 :     if( NULL == pImplementationId )
    1065             :     {
    1066             :         OSL_FAIL( "Could not create an implementation id for a SwXShape!" );
    1067           0 :         return uno::Sequence< sal_Int8 > ();
    1068             :     }
    1069             :     else
    1070             :     {
    1071           0 :         return *pImplementationId;
    1072           0 :     }
    1073             : }
    1074             : 
    1075         103 : uno::Reference< beans::XPropertySetInfo >  SwXShape::getPropertySetInfo(void) throw( uno::RuntimeException )
    1076             : {
    1077         103 :     SolarMutexGuard aGuard;
    1078         103 :     uno::Reference< beans::XPropertySetInfo >  aRet;
    1079         103 :     if(xShapeAgg.is())
    1080             :     {
    1081         103 :         const uno::Type& rPropSetType = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
    1082         103 :         uno::Any aPSet = xShapeAgg->queryAggregation( rPropSetType );
    1083         103 :         if(aPSet.getValueType() == rPropSetType && aPSet.getValue())
    1084             :         {
    1085             :             uno::Reference< beans::XPropertySet >  xPrSet =
    1086         103 :                     *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
    1087         103 :             uno::Reference< beans::XPropertySetInfo >  xInfo = xPrSet->getPropertySetInfo();
    1088             :             // PropertySetInfo verlaengern!
    1089         103 :             const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
    1090         103 :             aRet = new SfxExtItemPropertySetInfo( m_pPropertyMapEntries, aPropSeq );
    1091         103 :         }
    1092             :     }
    1093         103 :     if(!aRet.is())
    1094           0 :         aRet = m_pPropSet->getPropertySetInfo();
    1095         103 :     return aRet;
    1096             : }
    1097             : 
    1098         691 : void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::Any& aValue)
    1099             :      throw( beans::UnknownPropertyException, beans::PropertyVetoException,
    1100             :             lang::IllegalArgumentException, lang::WrappedTargetException,
    1101             :             uno::RuntimeException)
    1102             : {
    1103         691 :     SolarMutexGuard aGuard;
    1104         691 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1105         691 :     const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
    1106         691 :     if(xShapeAgg.is())
    1107             :     {
    1108         691 :         if(pEntry)
    1109             :         {
    1110         193 :             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1111           0 :                 throw beans::PropertyVetoException ( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1112             :             //mit Layout kann der Anker umgesetzt werden, ohne dass sich die Position aendert
    1113         193 :             if(pFmt)
    1114             :             {
    1115         190 :                 SwAttrSet aSet(pFmt->GetAttrSet());
    1116         190 :                 SwDoc* pDoc = pFmt->GetDoc();
    1117         190 :                 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId)
    1118             :                 {
    1119           0 :                     bool bDone = true;
    1120           0 :                     uno::Reference<text::XTextFrame> xFrame;
    1121           0 :                     if(aValue >>= xFrame)
    1122             :                     {
    1123           0 :                         uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
    1124           0 :                         SwXFrame* pFrame = xTunnel.is() ?
    1125             :                                 reinterpret_cast< SwXFrame * >(
    1126           0 :                                     sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
    1127           0 :                                 : 0;
    1128           0 :                         if(pFrame && pFrame->GetFrmFmt() &&
    1129           0 :                             pFrame->GetFrmFmt()->GetDoc() == pDoc)
    1130             :                         {
    1131           0 :                             UnoActionContext aCtx(pDoc);
    1132           0 :                             SfxItemSet aItemSet( pDoc->GetAttrPool(),
    1133           0 :                                         RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
    1134           0 :                             aItemSet.SetParent(&pFmt->GetAttrSet());
    1135           0 :                             SwFmtAnchor aAnchor = (const SwFmtAnchor&)aItemSet.Get(pEntry->nWID);
    1136           0 :                             SwPosition aPos(*pFrame->GetFrmFmt()->GetCntnt().GetCntntIdx());
    1137           0 :                             aAnchor.SetAnchor(&aPos);
    1138           0 :                             aAnchor.SetType(FLY_AT_FLY);
    1139           0 :                             aItemSet.Put(aAnchor);
    1140           0 :                             pFmt->SetFmtAttr(aItemSet);
    1141           0 :                             bDone = true;
    1142           0 :                         }
    1143             :                     }
    1144           0 :                     if(!bDone)
    1145           0 :                         throw lang::IllegalArgumentException();
    1146             :                 }
    1147         190 :                 else if(RES_OPAQUE == pEntry->nWID)
    1148             :                 {
    1149          12 :                     SvxShape* pSvxShape = GetSvxShape();
    1150             :                     SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
    1151          12 :                     if(pSvxShape)
    1152             :                     {
    1153          12 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1154             :                         // set layer of new drawing
    1155             :                         // object to corresponding invisible layer.
    1156          12 :                         bool bIsVisible = pDoc->IsVisibleLayerId( pObj->GetLayer() );
    1157          12 :                         if(FmFormInventor != pObj->GetObjInventor())
    1158             :                         {
    1159          12 :                             pObj->SetLayer( *(sal_Bool*)aValue.getValue()
    1160           9 :                                             ? ( bIsVisible ? pDoc->GetHeavenId() : pDoc->GetInvisibleHeavenId() )
    1161          33 :                                             : ( bIsVisible ? pDoc->GetHellId() : pDoc->GetInvisibleHellId() ));
    1162             :                         }
    1163             :                         else
    1164             :                         {
    1165           0 :                             pObj->SetLayer( bIsVisible ? pDoc->GetControlsId() : pDoc->GetInvisibleControlsId());
    1166             :                         }
    1167             : 
    1168             :                     }
    1169             : 
    1170             :                 }
    1171             :                 // #i26791# - special handling for property FN_TEXT_RANGE
    1172         178 :                 else if ( FN_TEXT_RANGE == pEntry->nWID )
    1173             :                 {
    1174          33 :                     SwFmtAnchor aAnchor( static_cast<const SwFmtAnchor&>(aSet.Get( RES_ANCHOR )) );
    1175          33 :                     if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
    1176             :                     {
    1177             :                         // set property <TextRange> not valid for to-page anchored shapes
    1178           0 :                         throw lang::IllegalArgumentException();
    1179             :                     }
    1180             :                     else
    1181             :                     {
    1182             :                         SwUnoInternalPaM* pInternalPam =
    1183          33 :                                         new SwUnoInternalPaM( *(pFmt->GetDoc()) );
    1184          33 :                         uno::Reference< text::XTextRange > xRg;
    1185          33 :                         aValue >>= xRg;
    1186          33 :                         if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
    1187             :                         {
    1188          33 :                             if (aAnchor.GetAnchorId() == FLY_AS_CHAR)
    1189             :                             {
    1190             :                                 //delete old SwFmtFlyCnt
    1191             :                                 //With AnchorAsCharacter the current TxtAttribute has to be deleted.
    1192             :                                 //Tbis removes the frame format too.
    1193             :                                 //To prevent this the connection between format and attribute has to be broken before.
    1194           4 :                                 const SwPosition *pPos = aAnchor.GetCntntAnchor();
    1195           4 :                                 SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
    1196             :                                 SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
    1197           4 :                                 const xub_StrLen nIdx = pPos->nContent.GetIndex();
    1198             :                                 SwTxtAttr * const pHnt =
    1199             :                                     pTxtNode->GetTxtAttrForCharAt(
    1200           4 :                                         nIdx, RES_TXTATR_FLYCNT );
    1201             :                                 SAL_WARN_IF( !pHnt || pHnt->Which() != RES_TXTATR_FLYCNT,
    1202             :                                             "sw.uno", "Missing FlyInCnt-Hint." );
    1203             :                                 SAL_WARN_IF( !pHnt || pHnt->GetFlyCnt().GetFrmFmt() != pFmt,
    1204             :                                             "sw.uno", "Wrong TxtFlyCnt-Hint." );
    1205           4 :                                 const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
    1206           4 :                                     .SetFlyFmt();
    1207             : 
    1208             :                                 //The connection is removed now the attribute can be deleted.
    1209             :                                 pTxtNode->DeleteAttributes(
    1210           4 :                                     RES_TXTATR_FLYCNT, nIdx );
    1211             :                                 //create a new one
    1212           4 :                                 SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode();
    1213             :                                 SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TxtNode." );
    1214           4 :                                 SwFmtFlyCnt aFmt( pFmt );
    1215           4 :                                 pNd->InsertItem(aFmt, pInternalPam->GetPoint()
    1216           4 :                                         ->nContent.GetIndex(), 0 );
    1217             :                             }
    1218             :                             else
    1219             :                             {
    1220          29 :                                 aAnchor.SetAnchor( pInternalPam->GetPoint() );
    1221          29 :                                 aSet.Put(aAnchor);
    1222          29 :                                 pFmt->SetFmtAttr(aSet);
    1223             :                             }
    1224             :                         }
    1225             :                         else
    1226             :                         {
    1227           0 :                             throw uno::RuntimeException();
    1228             :                         }
    1229          33 :                         delete pInternalPam;
    1230          33 :                     }
    1231             :                 }
    1232             :                 // #i28749#
    1233         145 :                 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
    1234             :                 {
    1235           0 :                     sal_Int16 nPositionLayoutDir = 0;
    1236           0 :                     aValue >>= nPositionLayoutDir;
    1237           0 :                     pFmt->SetPositionLayoutDir( nPositionLayoutDir );
    1238             :                 }
    1239         145 :                 else if( pDoc->GetCurrentLayout())  //swmod 080218
    1240             :                 {
    1241           0 :                     UnoActionContext aCtx(pDoc);
    1242           0 :                     if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
    1243             :                     {
    1244           0 :                         SdrObject* pObj = pFmt->FindSdrObject();
    1245           0 :                         SdrMarkList aList;
    1246           0 :                         SdrMark aMark(pObj);
    1247           0 :                         aList.InsertEntry(aMark);
    1248           0 :                         sal_Int32 nAnchor = 0;
    1249           0 :                         cppu::enum2int( nAnchor, aValue );
    1250             :                         pDoc->ChgAnchor( aList, (RndStdIds)nAnchor,
    1251           0 :                                                 false, true );
    1252             :                     }
    1253             :                     else
    1254             :                     {
    1255           0 :                         m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
    1256           0 :                         pFmt->SetFmtAttr(aSet);
    1257           0 :                     }
    1258             :                 }
    1259         145 :                 else if( RES_FRM_SIZE == pEntry->nWID &&
    1260             :                         ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ) )
    1261             :                 {
    1262           2 :                     SvxShape* pSvxShape = GetSvxShape();
    1263             :                     SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
    1264           2 :                     if(pSvxShape)
    1265             :                     {
    1266           2 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1267           2 :                         sal_Int16 nPercent(100);
    1268           2 :                         aValue >>= nPercent;
    1269           2 :                         if ( pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH )
    1270           1 :                             pObj->SetRelativeWidth( nPercent / 100.0 );
    1271             :                         else
    1272           1 :                             pObj->SetRelativeHeight( nPercent / 100.0 );
    1273           2 :                     }
    1274             :                 }
    1275             :                 else
    1276             :                 {
    1277         143 :                     m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
    1278             : 
    1279         143 :                     if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
    1280             :                     {
    1281          55 :                         bool bSetAttr = true;
    1282          55 :                         sal_Int32 eNewAnchor = SWUnoHelper::GetEnumAsInt32( aValue );
    1283             : 
    1284             :                         //if old anchor was in_cntnt the related text attribute has to be removed
    1285          55 :                         const SwFmtAnchor& rOldAnchor = pFmt->GetAnchor();
    1286          55 :                         RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
    1287          55 :                         SdrObject* pObj = pFmt->FindSdrObject();
    1288          55 :                         SwFrmFmt *pFlyFmt = FindFrmFmt( pObj );
    1289          55 :                         pFlyFmt->DelFrms();
    1290          55 :                         if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
    1291             :                             (FLY_AS_CHAR == eOldAnchorId))
    1292             :                         {
    1293             :                             //With AnchorAsCharacter the current TxtAttribute has to be deleted.
    1294             :                             //Tbis removes the frame format too.
    1295             :                             //To prevent this the connection between format and attribute has to be broken before.
    1296           1 :                             const SwPosition *pPos = rOldAnchor.GetCntntAnchor();
    1297           1 :                             SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
    1298             :                             SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
    1299           1 :                             const xub_StrLen nIdx = pPos->nContent.GetIndex();
    1300             :                             SwTxtAttr * const pHnt =
    1301             :                                 pTxtNode->GetTxtAttrForCharAt(
    1302           1 :                                     nIdx, RES_TXTATR_FLYCNT );
    1303             :                             SAL_WARN_IF( !pHnt || pHnt->Which() != RES_TXTATR_FLYCNT,
    1304             :                                         "sw.uno", "Missing FlyInCnt-Hint." );
    1305             :                             SAL_WARN_IF( !pHnt || pHnt->GetFlyCnt().GetFrmFmt() != pFlyFmt,
    1306             :                                         "sw.uno", "Wrong TxtFlyCnt-Hint." );
    1307           1 :                             const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
    1308           1 :                                 .SetFlyFmt();
    1309             : 
    1310             :                             //The connection is removed now the attribute can be deleted.
    1311           1 :                             pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
    1312             :                         }
    1313          54 :                         else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
    1314             :                                 (FLY_AT_PAGE == eOldAnchorId))
    1315             :                         {
    1316          36 :                             SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) );
    1317             :                             //if the fly has been anchored at page then it needs to be connected
    1318             :                             //to the content position
    1319          36 :                             SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
    1320          36 :                             if( pDoc->GetCurrentLayout() )
    1321             :                             {
    1322           0 :                                 SwCrsrMoveState aState( MV_SETONLYTEXT );
    1323           0 :                                 Point aTmp( pObj->GetSnapRect().TopLeft() );
    1324           0 :                                 pDoc->GetCurrentLayout()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
    1325             :                             }
    1326             :                             else
    1327             :                             {
    1328             :                                 //without access to the layout the last node of the body will be used as anchor position
    1329          36 :                                 aPam.Move( fnMoveBackward, fnGoDoc );
    1330             :                             }
    1331             :                             //anchor position has to be inserted after the text attribute has been inserted
    1332          36 :                             aNewAnchor.SetAnchor( aPam.GetPoint() );
    1333          36 :                             aSet.Put( aNewAnchor );
    1334          36 :                             pFmt->SetFmtAttr(aSet);
    1335          36 :                             bSetAttr = false;
    1336             :                         }
    1337          55 :                         if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
    1338             :                             (FLY_AS_CHAR != eOldAnchorId))
    1339             :                         {
    1340           6 :                             SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
    1341           6 :                             if( pDoc->GetCurrentLayout() )
    1342             :                             {
    1343           0 :                                 SwCrsrMoveState aState( MV_SETONLYTEXT );
    1344           0 :                                 Point aTmp( pObj->GetSnapRect().TopLeft() );
    1345           0 :                                 pDoc->GetCurrentLayout()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
    1346             :                             }
    1347             :                             else
    1348             :                             {
    1349             :                                 //without access to the layout the last node of the body will be used as anchor position
    1350           6 :                                 aPam.Move( fnMoveBackward, fnGoDoc );
    1351             :                             }
    1352             :                             //the RES_TXTATR_FLYCNT needs to be added now
    1353           6 :                             SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
    1354             :                             SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
    1355           6 :                             SwFmtFlyCnt aFmt( pFlyFmt );
    1356             :                             pNd->InsertItem(aFmt,
    1357           6 :                                 aPam.GetPoint()->nContent.GetIndex(), 0 );
    1358           6 :                             aPam.GetPoint()->nContent--; // InsertItem moved it
    1359             :                             SwFmtAnchor aNewAnchor(
    1360             :                                 dynamic_cast<const SwFmtAnchor&>(
    1361           6 :                                     aSet.Get(RES_ANCHOR)));
    1362           6 :                             aNewAnchor.SetAnchor( aPam.GetPoint() );
    1363           6 :                             aSet.Put( aNewAnchor );
    1364             :                         }
    1365          55 :                         if( bSetAttr )
    1366          19 :                             pFmt->SetFmtAttr(aSet);
    1367             :                     }
    1368             :                     else
    1369          88 :                         pFmt->SetFmtAttr(aSet);
    1370         190 :                 }
    1371             :             }
    1372             :             else
    1373             :             {
    1374           3 :                 SfxPoolItem* pItem = 0;
    1375           3 :                 switch(pEntry->nWID)
    1376             :                 {
    1377             :                     case RES_ANCHOR:
    1378           2 :                         pItem = pImpl->GetAnchor(true);
    1379           2 :                     break;
    1380             :                     case RES_HORI_ORIENT:
    1381           0 :                         pItem = pImpl->GetHOrient(true);
    1382           0 :                     break;
    1383             :                     case RES_VERT_ORIENT:
    1384           0 :                         pItem = pImpl->GetVOrient(true);
    1385           0 :                     break;
    1386             :                     case  RES_LR_SPACE:
    1387           0 :                         pItem = pImpl->GetLRSpace(true);
    1388           0 :                     break;
    1389             :                     case  RES_UL_SPACE:
    1390           0 :                         pItem = pImpl->GetULSpace(true);
    1391           0 :                     break;
    1392             :                     case  RES_SURROUND:
    1393           0 :                         pItem = pImpl->GetSurround(true);
    1394           0 :                     break;
    1395             :                     case  FN_TEXT_RANGE:
    1396             :                     {
    1397             :                         const uno::Type rTextRangeType =
    1398           1 :                             ::getCppuType((uno::Reference< text::XTextRange>*)0);
    1399           1 :                         if(aValue.getValueType() == rTextRangeType)
    1400             :                         {
    1401           1 :                             uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
    1402           1 :                             rRange = *(uno::Reference< text::XTextRange > *)aValue.getValue();
    1403           1 :                         }
    1404             :                     }
    1405           1 :                     break;
    1406             :                     case RES_OPAQUE :
    1407           0 :                         pImpl->SetOpaque(*(sal_Bool*)aValue.getValue());
    1408           0 :                     break;
    1409             :                     // #i26791#
    1410             :                     case RES_FOLLOW_TEXT_FLOW:
    1411             :                     {
    1412           0 :                         pItem = pImpl->GetFollowTextFlow( true );
    1413             :                     }
    1414           0 :                     break;
    1415             :                     // #i28701#
    1416             :                     case RES_WRAP_INFLUENCE_ON_OBJPOS:
    1417             :                     {
    1418           0 :                         pItem = pImpl->GetWrapInfluenceOnObjPos( true );
    1419             :                     }
    1420           0 :                     break;
    1421             :                     // #i28749#
    1422             :                     case FN_SHAPE_POSITION_LAYOUT_DIR :
    1423             :                     {
    1424           0 :                         sal_Int16 nPositionLayoutDir = 0;
    1425           0 :                         aValue >>= nPositionLayoutDir;
    1426           0 :                         pImpl->SetPositionLayoutDir( nPositionLayoutDir );
    1427             :                     }
    1428           0 :                     break;
    1429             :                 }
    1430           3 :                 if(pItem)
    1431           2 :                     ((SfxPoolItem*)pItem)->PutValue(aValue, pEntry->nMemberId);
    1432             :             }
    1433             :         }
    1434             :         else
    1435             :         {
    1436         498 :             uno::Reference< beans::XPropertySet >  xPrSet;
    1437             :             const uno::Type& rPSetType =
    1438         498 :                 ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
    1439         498 :             uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
    1440         498 :             if(aPSet.getValueType() != rPSetType || !aPSet.getValue())
    1441           0 :                 throw uno::RuntimeException();
    1442         498 :             xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
    1443             :             // #i31698# - setting the caption point of a
    1444             :             // caption object doesn't have to change the object position.
    1445             :             // Thus, keep the position, before the caption point is set and
    1446             :             // restore it afterwards.
    1447         498 :             awt::Point aKeepedPosition( 0, 0 );
    1448         498 :             if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
    1449             :             {
    1450           0 :                     aKeepedPosition = getPosition();
    1451             :             }
    1452         498 :             if( pFmt && pFmt->GetDoc()->GetCurrentViewShell() ) //swmod 071108//swmod 071225
    1453             :             {
    1454           0 :                 UnoActionContext aCtx(pFmt->GetDoc());
    1455           0 :                 xPrSet->setPropertyValue(rPropertyName, aValue);
    1456             :             }
    1457             :             else
    1458         498 :                 xPrSet->setPropertyValue(rPropertyName, aValue);
    1459             :             // #i31698# - restore object position, if caption point is set.
    1460         498 :             if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
    1461             :             {
    1462           0 :                 setPosition( aKeepedPosition );
    1463         498 :             }
    1464             :         }
    1465         691 :     }
    1466         691 : }
    1467             : 
    1468         533 : uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName)
    1469             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1470             :            uno::RuntimeException )
    1471             : {
    1472         533 :     SolarMutexGuard aGuard;
    1473         533 :     uno::Any aRet;
    1474         533 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1475         533 :     if(xShapeAgg.is())
    1476             :     {
    1477         533 :         const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
    1478         533 :         if(pEntry)
    1479             :         {
    1480         405 :             if(pFmt)
    1481             :             {
    1482         195 :                 if(RES_OPAQUE == pEntry->nWID)
    1483             :                 {
    1484           1 :                     SvxShape* pSvxShape = GetSvxShape();
    1485             :                     OSL_ENSURE(pSvxShape, "No SvxShape found!");
    1486           1 :                     if(pSvxShape)
    1487             :                     {
    1488           1 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1489             :                         // consider invisible layers
    1490             :                         sal_Bool bOpaque =
    1491           1 :                             ( pObj->GetLayer() != pFmt->GetDoc()->GetHellId() &&
    1492           1 :                               pObj->GetLayer() != pFmt->GetDoc()->GetInvisibleHellId() );
    1493           1 :                         aRet.setValue(&bOpaque, ::getBooleanCppuType());
    1494             :                     }
    1495             :                 }
    1496         194 :                 else if(FN_ANCHOR_POSITION == pEntry->nWID)
    1497             :                 {
    1498           3 :                     SvxShape* pSvxShape = GetSvxShape();
    1499             :                     OSL_ENSURE(pSvxShape, "No SvxShape found!");
    1500           3 :                     if(pSvxShape)
    1501             :                     {
    1502           3 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1503           3 :                         Point aPt = pObj->GetAnchorPos();
    1504           6 :                         awt::Point aPoint( TWIP_TO_MM100( aPt.X() ),
    1505           9 :                                            TWIP_TO_MM100( aPt.Y() ) );
    1506           3 :                         aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
    1507             :                     }
    1508             :                 }
    1509             :                 // #i26791# - special handling for FN_TEXT_RANGE
    1510         191 :                 else if ( FN_TEXT_RANGE == pEntry->nWID )
    1511             :                 {
    1512           0 :                     const SwFmtAnchor aAnchor = pFmt->GetAnchor();
    1513           0 :                     if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
    1514             :                     {
    1515             :                         // return nothing, because property <TextRange> isn't
    1516             :                         // valid for to-page anchored shapes
    1517           0 :                         uno::Any aAny;
    1518           0 :                         aRet = aAny;
    1519             :                     }
    1520             :                     else
    1521             :                     {
    1522           0 :                         if ( aAnchor.GetCntntAnchor() )
    1523             :                         {
    1524             :                             const uno::Reference< text::XTextRange > xTextRange
    1525             :                                 = SwXTextRange::CreateXTextRange(
    1526           0 :                                                     *pFmt->GetDoc(),
    1527           0 :                                                     *aAnchor.GetCntntAnchor(),
    1528           0 :                                                     0L );
    1529           0 :                             aRet.setValue(&xTextRange, ::getCppuType((uno::Reference<text::XTextRange>*)0));
    1530             :                         }
    1531             :                         else
    1532             :                         {
    1533             :                             // return nothing
    1534           0 :                             uno::Any aAny;
    1535           0 :                             aRet = aAny;
    1536             :                         }
    1537           0 :                     }
    1538             :                 }
    1539             :                 // #i28749#
    1540         191 :                 else if ( FN_SHAPE_TRANSFORMATION_IN_HORI_L2R == pEntry->nWID )
    1541             :                 {
    1542             :                     // get property <::drawing::Shape::Transformation>
    1543             :                     // without conversion to layout direction as below
    1544           0 :                     aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")) );
    1545             :                 }
    1546         191 :                 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
    1547             :                 {
    1548           0 :                     aRet <<= pFmt->GetPositionLayoutDir();
    1549             :                 }
    1550             :                 // #i36248#
    1551         191 :                 else if ( FN_SHAPE_STARTPOSITION_IN_HORI_L2R == pEntry->nWID )
    1552             :                 {
    1553             :                     // get property <::drawing::Shape::StartPosition>
    1554             :                     // without conversion to layout direction as below
    1555           0 :                     aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")) );
    1556             :                 }
    1557         191 :                 else if ( FN_SHAPE_ENDPOSITION_IN_HORI_L2R == pEntry->nWID )
    1558             :                 {
    1559             :                     // get property <::drawing::Shape::EndPosition>
    1560             :                     // without conversion to layout direction as below
    1561           0 :                     aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")) );
    1562             :                 }
    1563             :                 else
    1564             :                 {
    1565         191 :                     const SwAttrSet& rSet = pFmt->GetAttrSet();
    1566         191 :                     m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
    1567             :                 }
    1568             :             }
    1569             :             else
    1570             :             {
    1571         210 :                 SfxPoolItem* pItem = 0;
    1572         210 :                 switch(pEntry->nWID)
    1573             :                 {
    1574             :                     case RES_ANCHOR:
    1575          70 :                         pItem = pImpl->GetAnchor();
    1576          70 :                     break;
    1577             :                     case RES_HORI_ORIENT:
    1578          70 :                         pItem = pImpl->GetHOrient();
    1579          70 :                     break;
    1580             :                     case RES_VERT_ORIENT:
    1581          70 :                         pItem = pImpl->GetVOrient();
    1582          70 :                     break;
    1583             :                     case  RES_LR_SPACE:
    1584           0 :                         pItem = pImpl->GetLRSpace();
    1585           0 :                     break;
    1586             :                     case  RES_UL_SPACE:
    1587           0 :                         pItem = pImpl->GetULSpace();
    1588           0 :                     break;
    1589             :                     case  RES_SURROUND:
    1590           0 :                         pItem = pImpl->GetSurround();
    1591           0 :                     break;
    1592             :                     case FN_TEXT_RANGE :
    1593           0 :                         aRet.setValue(&pImpl->GetTextRange(), ::getCppuType((uno::Reference<text::XTextRange>*)0));
    1594           0 :                     break;
    1595             :                     case RES_OPAQUE :
    1596           0 :                         aRet.setValue(&pImpl->GetOpaque(), ::getBooleanCppuType());
    1597           0 :                     break;
    1598             :                     case FN_ANCHOR_POSITION :
    1599             :                     {
    1600           0 :                         awt::Point aPoint;
    1601           0 :                         aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
    1602             :                     }
    1603           0 :                     break;
    1604             :                     // #i26791#
    1605             :                     case RES_FOLLOW_TEXT_FLOW :
    1606             :                     {
    1607           0 :                         pItem = pImpl->GetFollowTextFlow();
    1608             :                     }
    1609           0 :                     break;
    1610             :                     // #i28701#
    1611             :                     case RES_WRAP_INFLUENCE_ON_OBJPOS:
    1612             :                     {
    1613           0 :                         pItem = pImpl->GetWrapInfluenceOnObjPos();
    1614             :                     }
    1615           0 :                     break;
    1616             :                     // #i28749#
    1617             :                     case FN_SHAPE_TRANSFORMATION_IN_HORI_L2R:
    1618             :                     {
    1619             :                         // get property <::drawing::Shape::Transformation>
    1620             :                         // without conversion to layout direction as below
    1621           0 :                         aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")) );
    1622             :                     }
    1623           0 :                     break;
    1624             :                     case FN_SHAPE_POSITION_LAYOUT_DIR:
    1625             :                     {
    1626           0 :                         aRet <<= pImpl->GetPositionLayoutDir();
    1627             :                     }
    1628           0 :                     break;
    1629             :                     // #i36248#
    1630             :                     case FN_SHAPE_STARTPOSITION_IN_HORI_L2R:
    1631             :                     {
    1632             :                         // get property <::drawing::Shape::StartPosition>
    1633             :                         // without conversion to layout direction as below
    1634           0 :                         aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")) );
    1635             :                     }
    1636           0 :                     break;
    1637             :                     case FN_SHAPE_ENDPOSITION_IN_HORI_L2R:
    1638             :                     {
    1639             :                         // get property <::drawing::Shape::StartPosition>
    1640             :                         // without conversion to layout direction as below
    1641           0 :                         aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")) );
    1642             :                     }
    1643           0 :                     break;
    1644             :                 }
    1645         210 :                 if(pItem)
    1646           2 :                     pItem->QueryValue(aRet, pEntry->nMemberId);
    1647             :             }
    1648             :         }
    1649             :         else
    1650             :         {
    1651         128 :             aRet = _getPropAtAggrObj( rPropertyName );
    1652             : 
    1653             :             // #i31698# - convert the position (translation)
    1654             :             // of the drawing object in the transformation
    1655         127 :             if ( rPropertyName == "Transformation" )
    1656             :             {
    1657           0 :                 drawing::HomogenMatrix3 aMatrix;
    1658           0 :                 aRet >>= aMatrix;
    1659           0 :                 aRet <<= _ConvertTransformationToLayoutDir( aMatrix );
    1660             :             }
    1661             :             // #i36248#
    1662         127 :             else if ( rPropertyName == "StartPosition" )
    1663             :             {
    1664           0 :                 awt::Point aStartPos;
    1665           0 :                 aRet >>= aStartPos;
    1666             :                 // #i59051#
    1667           0 :                 aRet <<= _ConvertStartOrEndPosToLayoutDir( aStartPos );
    1668             :             }
    1669         127 :             else if ( rPropertyName == "EndPosition" )
    1670             :             {
    1671           0 :                 awt::Point aEndPos;
    1672           0 :                 aRet >>= aEndPos;
    1673             :                 // #i59051#
    1674           0 :                 aRet <<= _ConvertStartOrEndPosToLayoutDir( aEndPos );
    1675             :             }
    1676             :             // #i59051#
    1677         127 :             else if ( rPropertyName == "PolyPolygonBezier" )
    1678             :             {
    1679           0 :                 drawing::PolyPolygonBezierCoords aPath;
    1680           0 :                 aRet >>= aPath;
    1681           0 :                 aRet <<= _ConvertPolyPolygonBezierToLayoutDir( aPath );
    1682             :             }
    1683             :         }
    1684             :     }
    1685         533 :     return aRet;
    1686             : }
    1687             : 
    1688         128 : uno::Any SwXShape::_getPropAtAggrObj( const ::rtl::OUString& _rPropertyName )
    1689             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1690             :            uno::RuntimeException )
    1691             : {
    1692         128 :     uno::Any aRet;
    1693             : 
    1694         128 :     uno::Reference< beans::XPropertySet >  xPrSet;
    1695             :     const uno::Type& rPSetType =
    1696         128 :                 ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
    1697         128 :     uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
    1698         128 :     if ( aPSet.getValueType() != rPSetType || !aPSet.getValue() )
    1699             :     {
    1700           0 :         throw uno::RuntimeException();
    1701             :     }
    1702         128 :     xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
    1703         128 :     aRet = xPrSet->getPropertyValue( _rPropertyName );
    1704             : 
    1705         128 :     return aRet;
    1706             : }
    1707             : 
    1708           1 : beans::PropertyState SwXShape::getPropertyState( const rtl::OUString& rPropertyName )
    1709             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
    1710             : {
    1711           1 :     SolarMutexGuard aGuard;
    1712           1 :     uno::Sequence< rtl::OUString > aNames(1);
    1713           1 :     rtl::OUString* pStrings = aNames.getArray();
    1714           1 :     pStrings[0] = rPropertyName;
    1715           1 :     uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
    1716           1 :     return aStates.getConstArray()[0];
    1717             : }
    1718             : 
    1719           1 : uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates(
    1720             :     const uno::Sequence< rtl::OUString >& aPropertyNames )
    1721             :         throw(beans::UnknownPropertyException, uno::RuntimeException)
    1722             : {
    1723           1 :     SolarMutexGuard aGuard;
    1724           1 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1725           1 :     uno::Sequence< beans::PropertyState > aRet(aPropertyNames.getLength());
    1726           1 :     if(xShapeAgg.is())
    1727             :     {
    1728           1 :         SvxShape* pSvxShape = GetSvxShape();
    1729           1 :         bool bGroupMember = false;
    1730           1 :         bool bFormControl = false;
    1731           1 :         SdrObject* pObject = pSvxShape->GetSdrObject();
    1732           1 :         if(pObject)
    1733             :         {
    1734           1 :             bGroupMember = pObject->GetUpGroup() != 0;
    1735           1 :             bFormControl = pObject->GetObjInventor() == FmFormInventor;
    1736             :         }
    1737           1 :         const rtl::OUString* pNames = aPropertyNames.getConstArray();
    1738           1 :         beans::PropertyState* pRet = aRet.getArray();
    1739           1 :         uno::Reference< XPropertyState >  xShapePrState;
    1740           2 :         for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++)
    1741             :         {
    1742           1 :             const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( pNames[nProperty] );
    1743           1 :             if(pEntry)
    1744             :             {
    1745           0 :                 if(RES_OPAQUE == pEntry->nWID)
    1746           0 :                     pRet[nProperty] = bFormControl ?
    1747           0 :                         beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
    1748           0 :                 else if(FN_ANCHOR_POSITION == pEntry->nWID)
    1749           0 :                     pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1750           0 :                 else if(FN_TEXT_RANGE == pEntry->nWID)
    1751           0 :                     pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1752           0 :                 else if(bGroupMember)
    1753           0 :                     pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
    1754           0 :                 else if(pFmt)
    1755             :                 {
    1756           0 :                     const SwAttrSet& rSet = pFmt->GetAttrSet();
    1757           0 :                     SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, sal_False);
    1758             : 
    1759           0 :                     if(SFX_ITEM_SET == eItemState)
    1760           0 :                         pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1761           0 :                     else if(SFX_ITEM_DEFAULT == eItemState)
    1762           0 :                         pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
    1763             :                     else
    1764           0 :                         pRet[nProperty] = beans::PropertyState_AMBIGUOUS_VALUE;
    1765             :                 }
    1766             :                 else
    1767             :                 {
    1768           0 :                     SfxPoolItem* pItem = 0;
    1769           0 :                     switch(pEntry->nWID)
    1770             :                     {
    1771             :                         case RES_ANCHOR:
    1772           0 :                             pItem = pImpl->GetAnchor();
    1773           0 :                         break;
    1774             :                         case RES_HORI_ORIENT:
    1775           0 :                             pItem = pImpl->GetHOrient();
    1776           0 :                         break;
    1777             :                         case RES_VERT_ORIENT:
    1778           0 :                             pItem = pImpl->GetVOrient();
    1779           0 :                         break;
    1780             :                         case  RES_LR_SPACE:
    1781           0 :                             pItem = pImpl->GetLRSpace();
    1782           0 :                         break;
    1783             :                         case  RES_UL_SPACE:
    1784           0 :                             pItem = pImpl->GetULSpace();
    1785           0 :                         break;
    1786             :                         case  RES_SURROUND:
    1787           0 :                             pItem = pImpl->GetSurround();
    1788           0 :                         break;
    1789             :                         // #i28701#
    1790             :                         case RES_WRAP_INFLUENCE_ON_OBJPOS:
    1791             :                         {
    1792           0 :                             pItem = pImpl->GetWrapInfluenceOnObjPos();
    1793             :                         }
    1794           0 :                         break;
    1795             :                     }
    1796           0 :                     if(pItem)
    1797           0 :                         pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1798             :                     else
    1799           0 :                         pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
    1800             :                 }
    1801             :             }
    1802             :             else
    1803             :             {
    1804           1 :                 if(!xShapePrState.is())
    1805             :                 {
    1806           1 :                     const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
    1807           1 :                     uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
    1808           1 :                     if(aPState.getValueType() != rPStateType || !aPState.getValue())
    1809           0 :                         throw uno::RuntimeException();
    1810           1 :                     xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
    1811             :                 }
    1812           1 :                 pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]);
    1813             :             }
    1814           1 :         }
    1815             :     }
    1816             :     else
    1817           0 :         throw uno::RuntimeException();
    1818           2 :     return aRet;
    1819             : }
    1820             : 
    1821           0 : void SwXShape::setPropertyToDefault( const rtl::OUString& rPropertyName )
    1822             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
    1823             : {
    1824           0 :     SolarMutexGuard aGuard;
    1825           0 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1826           0 :     if(xShapeAgg.is())
    1827             :     {
    1828           0 :         const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
    1829           0 :         if(pEntry)
    1830             :         {
    1831           0 :             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1832           0 :                 throw uno::RuntimeException( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1833           0 :             if(pFmt)
    1834             :             {
    1835           0 :                 const SfxItemSet& rSet = pFmt->GetAttrSet();
    1836           0 :                 SfxItemSet aSet(pFmt->GetDoc()->GetAttrPool(), pEntry->nWID, pEntry->nWID);
    1837           0 :                 aSet.SetParent(&rSet);
    1838           0 :                 aSet.ClearItem(pEntry->nWID);
    1839           0 :                 pFmt->GetDoc()->SetAttr(aSet, *pFmt);
    1840             :             }
    1841             :             else
    1842             :             {
    1843           0 :                 switch(pEntry->nWID)
    1844             :                 {
    1845           0 :                     case RES_ANCHOR:        pImpl->RemoveAnchor();  break;
    1846           0 :                     case RES_HORI_ORIENT:   pImpl->RemoveHOrient(); break;
    1847           0 :                     case RES_VERT_ORIENT:   pImpl->RemoveVOrient(); break;
    1848           0 :                     case  RES_LR_SPACE:     pImpl->RemoveLRSpace(); break;
    1849           0 :                     case  RES_UL_SPACE:     pImpl->RemoveULSpace(); break;
    1850           0 :                     case  RES_SURROUND:     pImpl->RemoveSurround();break;
    1851           0 :                     case RES_OPAQUE :       pImpl->SetOpaque(sal_False);  break;
    1852             :                     case FN_TEXT_RANGE :
    1853           0 :                     break;
    1854             :                     // #i26791#
    1855             :                     case RES_FOLLOW_TEXT_FLOW:
    1856             :                     {
    1857           0 :                         pImpl->RemoveFollowTextFlow();
    1858             :                     }
    1859           0 :                     break;
    1860             :                     // #i28701#
    1861             :                     case RES_WRAP_INFLUENCE_ON_OBJPOS:
    1862             :                     {
    1863           0 :                         pImpl->RemoveWrapInfluenceOnObjPos();
    1864             :                     }
    1865           0 :                     break;
    1866             :                 }
    1867             :             }
    1868             :         }
    1869             :         else
    1870             :         {
    1871           0 :             const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
    1872           0 :             uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
    1873           0 :             if(aPState.getValueType() != rPStateType || !aPState.getValue())
    1874           0 :                 throw uno::RuntimeException();
    1875           0 :             uno::Reference< XPropertyState > xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
    1876           0 :             xShapePrState->setPropertyToDefault( rPropertyName );
    1877             :         }
    1878             :     }
    1879             :     else
    1880           0 :         throw uno::RuntimeException();
    1881           0 : }
    1882             : 
    1883           0 : uno::Any SwXShape::getPropertyDefault( const rtl::OUString& rPropertyName )
    1884             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1885             :            uno::RuntimeException )
    1886             : {
    1887           0 :     SolarMutexGuard aGuard;
    1888           0 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1889           0 :     uno::Any aRet;
    1890           0 :     if(xShapeAgg.is())
    1891             :     {
    1892           0 :         const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
    1893           0 :         if(pEntry)
    1894             :         {
    1895           0 :             if(pEntry->nWID < RES_FRMATR_END && pFmt)
    1896             :             {
    1897             :                 const SfxPoolItem& rDefItem =
    1898           0 :                     pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
    1899           0 :                 rDefItem.QueryValue(aRet, pEntry->nMemberId);
    1900             :             }
    1901             :             else
    1902           0 :                 throw uno::RuntimeException();
    1903             :         }
    1904             :         else
    1905             :         {
    1906           0 :             const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
    1907           0 :             uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
    1908           0 :             if(aPState.getValueType() != rPStateType || !aPState.getValue())
    1909           0 :                 throw uno::RuntimeException();
    1910           0 :             uno::Reference< XPropertyState > xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
    1911           0 :             xShapePrState->getPropertyDefault( rPropertyName );
    1912             :         }
    1913             :     }
    1914             :     else
    1915           0 :         throw uno::RuntimeException();
    1916           0 :     return aRet;
    1917             : }
    1918             : 
    1919           0 : void SwXShape::addPropertyChangeListener(
    1920             :     const rtl::OUString& _propertyName,
    1921             :     const uno::Reference< beans::XPropertyChangeListener > & _listener )
    1922             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1923             :            uno::RuntimeException )
    1924             : {
    1925           0 :     if ( !xShapeAgg.is() )
    1926           0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no shape aggregate" ) ), *this );
    1927             : 
    1928             :     // must be handled by the aggregate
    1929           0 :     uno::Reference< beans::XPropertySet > xShapeProps;
    1930           0 :     if ( xShapeAgg->queryAggregation( beans::XPropertySet::static_type() ) >>= xShapeProps )
    1931           0 :         xShapeProps->addPropertyChangeListener( _propertyName, _listener );
    1932           0 : }
    1933             : 
    1934           0 : void SwXShape::removePropertyChangeListener(
    1935             :     const rtl::OUString& _propertyName,
    1936             :     const uno::Reference< beans::XPropertyChangeListener > & _listener)
    1937             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1938             :            uno::RuntimeException )
    1939             : {
    1940           0 :     if ( !xShapeAgg.is() )
    1941           0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no shape aggregate" ) ), *this );
    1942             : 
    1943             :     // must be handled by the aggregate
    1944           0 :     uno::Reference< beans::XPropertySet > xShapeProps;
    1945           0 :     if ( xShapeAgg->queryAggregation( beans::XPropertySet::static_type() ) >>= xShapeProps )
    1946           0 :         xShapeProps->removePropertyChangeListener( _propertyName, _listener );
    1947           0 : }
    1948             : 
    1949           0 : void SwXShape::addVetoableChangeListener(
    1950             :     const rtl::OUString& /*PropertyName*/,
    1951             :     const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/ )
    1952             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1953             :            uno::RuntimeException )
    1954             : {
    1955             :     OSL_FAIL("not implemented");
    1956           0 : }
    1957             : 
    1958           0 : void SwXShape::removeVetoableChangeListener(
    1959             :     const rtl::OUString& /*PropertyName*/,
    1960             :     const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
    1961             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1962             :            uno::RuntimeException )
    1963             : {
    1964             :     OSL_FAIL("not implemented");
    1965           0 : }
    1966             : 
    1967         147 : void SwXShape::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    1968             : {
    1969         147 :     ClientModify(this, pOld, pNew);
    1970         147 : }
    1971             : 
    1972          34 : void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
    1973             :     throw( lang::IllegalArgumentException, uno::RuntimeException )
    1974             : {
    1975          34 :     SolarMutexGuard aGuard;
    1976             : 
    1977             :     // get access to SwDoc
    1978             :     // (see also SwXTextRange::XTextRangeToSwPaM)
    1979          34 :     SwDoc*      pDoc = 0;
    1980          34 :     uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
    1981          34 :     if(xRangeTunnel.is())
    1982             :     {
    1983          34 :         SwXTextRange* pRange = 0;
    1984          34 :         OTextCursorHelper* pCursor = 0;
    1985          34 :         SwXTextPortion* pPortion = 0;
    1986          34 :         SwXText* pText = 0;
    1987          34 :         SwXParagraph* pParagraph = 0;
    1988             : 
    1989             :         pRange  = reinterpret_cast< SwXTextRange * >(
    1990          34 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
    1991             :         pText   = reinterpret_cast< SwXText * >(
    1992          34 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) ));
    1993             :         pCursor = reinterpret_cast< OTextCursorHelper * >(
    1994          34 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
    1995             :         pPortion = reinterpret_cast< SwXTextPortion * >(
    1996          34 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) ));
    1997             :         pParagraph = reinterpret_cast< SwXParagraph * >(
    1998          34 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId( ) ) ) );
    1999             : 
    2000          34 :         if (pRange)
    2001          33 :             pDoc = pRange->GetDoc();
    2002           1 :         else if (!pDoc && pText)
    2003           0 :             pDoc = pText->GetDoc();
    2004           1 :         else if (!pDoc && pCursor)
    2005           1 :             pDoc = pCursor->GetDoc();
    2006           0 :         else if ( !pDoc && pPortion && pPortion->GetCursor() )
    2007             :         {
    2008           0 :             pDoc = pPortion->GetCursor()->GetDoc();
    2009             :         }
    2010           0 :         else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) )
    2011             :         {
    2012           0 :             pDoc = const_cast<SwDoc*>(pParagraph->GetTxtNode()->GetDoc());
    2013             :         }
    2014             : 
    2015             :     }
    2016             : 
    2017          34 :     if(!pDoc)
    2018           0 :         throw uno::RuntimeException();
    2019          34 :     SwDocShell *pDocSh = pDoc->GetDocShell();
    2020          34 :     if (pDocSh)
    2021             :     {
    2022          33 :         uno::Reference< frame::XModel > xModel;
    2023          33 :         xModel = pDocSh->GetModel();
    2024          33 :         uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
    2025          33 :         if (xDPS.is())
    2026             :         {
    2027          33 :             uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
    2028          33 :             if (xDP.is())
    2029             :             {
    2030          33 :                 uno::Any aPos;
    2031          33 :                 aPos <<= xTextRange;
    2032          33 :                 setPropertyValue(S2U("TextRange"), aPos);
    2033          33 :                 uno::Reference< drawing::XShape > xTemp( (cppu::OWeakObject*) this, uno::UNO_QUERY );
    2034          65 :                 xDP->add( xTemp );
    2035          33 :             }
    2036          33 :         }
    2037          34 :     }
    2038           2 : }
    2039             : 
    2040           1 : uno::Reference< text::XTextRange >  SwXShape::getAnchor(void) throw( uno::RuntimeException )
    2041             : {
    2042           1 :     SolarMutexGuard aGuard;
    2043           1 :     uno::Reference< text::XTextRange >  aRef;
    2044           1 :     SwFrmFmt* pFmt = GetFrmFmt();
    2045           1 :     if(pFmt)
    2046             :     {
    2047           1 :         const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
    2048             :         // return an anchor for non-page bound frames
    2049             :         // and for page bound frames that have a page no == NULL and a content position
    2050           1 :         if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
    2051           0 :             (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
    2052             :         {
    2053           1 :             const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
    2054           1 :             aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
    2055             :         }
    2056             :     }
    2057             :     else
    2058           0 :         aRef = pImpl->GetTextRange();
    2059           1 :     return aRef;
    2060             : }
    2061             : 
    2062          44 : void SwXShape::dispose(void) throw( uno::RuntimeException )
    2063             : {
    2064          44 :     SolarMutexGuard aGuard;
    2065          44 :     SwFrmFmt* pFmt = GetFrmFmt();
    2066          44 :     if(pFmt)
    2067             :     {
    2068             :         // determine correct <SdrObject>
    2069          44 :         SdrObject* pObj = GetSvxShape()->GetSdrObject();
    2070             :         // safety assertion:
    2071             :         // <pObj> must be the same as <pFmt->FindSdrObject()>, if <pObj> isn't
    2072             :         // a 'virtual' drawing object.
    2073             :         // correct assertion and refine it for safety reason.
    2074             :         OSL_ENSURE( !pObj ||
    2075             :                 pObj->ISA(SwDrawVirtObj) ||
    2076             :                 pObj->GetUpGroup() ||
    2077             :                 pObj == pFmt->FindSdrObject(),
    2078             :                 "<SwXShape::dispose(..) - different 'master' drawing objects!!" );
    2079             :         // perform delete of draw frame format *not*
    2080             :         // for 'virtual' drawing objects.
    2081             :         // no delete of draw format for members
    2082             :         // of a group
    2083         110 :         if ( pObj &&
    2084          22 :              !pObj->ISA(SwDrawVirtObj) &&
    2085          22 :              !pObj->GetUpGroup() &&
    2086          22 :              pObj->IsInserted() )
    2087             :         {
    2088          22 :             if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
    2089             :             {
    2090           1 :                 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
    2091           1 :                 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
    2092           1 :                 const xub_StrLen nIdx = rPos.nContent.GetIndex();
    2093           1 :                 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
    2094             :             }
    2095             :             else
    2096          21 :                 pFmt->GetDoc()->DelLayoutFmt( pFmt );
    2097             :         }
    2098             :     }
    2099          44 :     if(xShapeAgg.is())
    2100             :     {
    2101          44 :         uno::Any aAgg(xShapeAgg->queryAggregation( ::getCppuType((uno::Reference<XComponent>*)0)));
    2102          44 :         uno::Reference<XComponent> xComp;
    2103          44 :         aAgg >>= xComp;
    2104          44 :         if(xComp.is())
    2105          44 :             xComp->dispose();
    2106          44 :     }
    2107          44 : }
    2108             : 
    2109           0 : void SwXShape::addEventListener(
    2110             :                     const uno::Reference< lang::XEventListener > & aListener)
    2111             :                     throw( uno::RuntimeException )
    2112             : {
    2113           0 :     uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    2114           0 :     SvxShape* pSvxShape = GetSvxShape();
    2115           0 :     if(pSvxShape)
    2116           0 :          pSvxShape->addEventListener(aListener);
    2117           0 : }
    2118             : 
    2119           0 : void SwXShape::removeEventListener(
    2120             :                     const uno::Reference< lang::XEventListener > & aListener)
    2121             :                     throw( uno::RuntimeException )
    2122             : {
    2123           0 :     SvxShape* pSvxShape = GetSvxShape();
    2124           0 :     if(pSvxShape)
    2125           0 :         pSvxShape->removeEventListener(aListener);
    2126           0 : }
    2127             : 
    2128           0 : rtl::OUString SwXShape::getImplementationName(void) throw( uno::RuntimeException )
    2129             : {
    2130           0 :     return C2U("SwXShape");
    2131             : }
    2132             : 
    2133          86 : sal_Bool SwXShape::supportsService(const rtl::OUString& rServiceName) throw( uno::RuntimeException )
    2134             : {
    2135          86 :     sal_Bool bRet = sal_False;
    2136          86 :     if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.drawing.Shape"))
    2137           0 :         bRet = sal_True;
    2138          86 :     else if(xShapeAgg.is())
    2139             :     {
    2140          86 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    2141          86 :         SvxShape* pSvxShape = GetSvxShape();
    2142          86 :         bRet = pSvxShape->supportsService(rServiceName);
    2143             :     }
    2144          86 :     return bRet;
    2145             : }
    2146             : 
    2147           0 : uno::Sequence< rtl::OUString > SwXShape::getSupportedServiceNames(void) throw( uno::RuntimeException )
    2148             : {
    2149           0 :     uno::Sequence< rtl::OUString > aSeq;
    2150           0 :     if(xShapeAgg.is())
    2151             :     {
    2152           0 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    2153           0 :         SvxShape* pSvxShape = GetSvxShape();
    2154           0 :         if(pSvxShape)
    2155           0 :             aSeq = pSvxShape->getSupportedServiceNames();
    2156             :     }
    2157             :     else
    2158             :     {
    2159           0 :         aSeq.realloc(1);
    2160           0 :         aSeq.getArray()[0] = C2U("com.sun.star.drawing.Shape");
    2161             :     }
    2162           0 :     return aSeq;
    2163             : }
    2164             : 
    2165         437 : SvxShape*   SwXShape::GetSvxShape()
    2166             : {
    2167         437 :     SvxShape* pSvxShape = 0;
    2168         437 :     if(xShapeAgg.is())
    2169             :     {
    2170         437 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    2171         437 :         if(xShapeTunnel.is())
    2172             :             pSvxShape = reinterpret_cast< SvxShape * >(
    2173         437 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    2174             :     }
    2175         437 :     return pSvxShape;
    2176             : }
    2177             : 
    2178             : // #i31698#
    2179             : // implementation of virtual methods from drawing::XShape
    2180          98 : awt::Point SAL_CALL SwXShape::getPosition() throw ( uno::RuntimeException )
    2181             : {
    2182          98 :     awt::Point aPos( _GetAttrPosition() );
    2183             : 
    2184             :     // handle group members
    2185          98 :     SvxShape* pSvxShape = GetSvxShape();
    2186          98 :     if ( pSvxShape )
    2187             :     {
    2188          98 :         SdrObject* pTopGroupObj = _GetTopGroupObj( pSvxShape );
    2189          98 :         if ( pTopGroupObj )
    2190             :         {
    2191             :             // #i34750# - get attribute position of top group
    2192             :             // shape and add offset between top group object and group member
    2193             :             uno::Reference< drawing::XShape > xGroupShape =
    2194           2 :                     uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
    2195           2 :                                                        uno::UNO_QUERY );
    2196           2 :             aPos = xGroupShape->getPosition();
    2197             :             // add offset between top group object and group member
    2198             :             // to the determined attribute position
    2199             :             // #i34750#:
    2200             :             // consider the layout direction
    2201           2 :             const Rectangle aMemberObjRect = GetSvxShape()->GetSdrObject()->GetSnapRect();
    2202           2 :             const Rectangle aGroupObjRect = pTopGroupObj->GetSnapRect();
    2203             :             // #i53320# - relative position of group member and
    2204             :             // top group object is always given in horizontal left-to-right layout.
    2205           2 :             awt::Point aOffset( 0, 0 );
    2206             :                 {
    2207           2 :                     aOffset.X = ( aMemberObjRect.Left() - aGroupObjRect.Left() );
    2208           2 :                     aOffset.Y = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
    2209             :                 }
    2210           2 :             aOffset.X = TWIP_TO_MM100(aOffset.X);
    2211           2 :             aOffset.Y = TWIP_TO_MM100(aOffset.Y);
    2212           2 :             aPos.X += aOffset.X;
    2213           2 :             aPos.Y += aOffset.Y;
    2214             :         }
    2215             :     }
    2216             : 
    2217          98 :     return aPos;
    2218             : }
    2219             : 
    2220          43 : void SAL_CALL SwXShape::setPosition( const awt::Point& aPosition )
    2221             :                                                 throw ( uno::RuntimeException )
    2222             : {
    2223          43 :     SdrObject* pTopGroupObj = _GetTopGroupObj();
    2224          43 :     if ( !pTopGroupObj )
    2225             :     {
    2226             :         // #i37877# - no adjustment of position attributes,
    2227             :         // if the position also has to be applied at the drawing object and
    2228             :         // a contact object is already registered at the drawing object.
    2229          35 :         bool bApplyPosAtDrawObj(false);
    2230          35 :         bool bNoAdjustOfPosProp(false);
    2231             :         // #i35798# - apply position also to drawing object,
    2232             :         // if drawing object has no anchor position set.
    2233          35 :         if ( mxShape.is() )
    2234             :         {
    2235          35 :             SvxShape* pSvxShape = GetSvxShape();
    2236          35 :             if ( pSvxShape )
    2237             :             {
    2238          35 :                 const SdrObject* pObj = pSvxShape->GetSdrObject();
    2239         105 :                 if ( pObj &&
    2240          35 :                      pObj->GetAnchorPos().X() == 0 &&
    2241          35 :                      pObj->GetAnchorPos().Y() == 0 )
    2242             :                 {
    2243          35 :                     bApplyPosAtDrawObj = true;
    2244          70 :                     if ( pObj->GetUserCall() &&
    2245          35 :                          pObj->GetUserCall()->ISA(SwDrawContact) )
    2246             :                     {
    2247          35 :                         bNoAdjustOfPosProp = true;
    2248             :                     }
    2249             :                 }
    2250             :             }
    2251             :         }
    2252             :         // shape isn't a group member. Thus, set positioning attributes
    2253          35 :         if ( !bNoAdjustOfPosProp )
    2254             :         {
    2255           0 :             _AdjustPositionProperties( aPosition );
    2256             :         }
    2257          35 :         if ( bApplyPosAtDrawObj )
    2258             :         {
    2259          35 :             mxShape->setPosition( aPosition );
    2260             :         }
    2261             :     }
    2262           8 :     else if ( mxShape.is() )
    2263             :     {
    2264             :         // shape is a member of a group. Thus, set its position.
    2265           8 :         awt::Point aNewPos( aPosition );
    2266             :         // The given position is given in the according layout direction. Thus,
    2267             :         // it has to be converted to a position in horizontal left-to-right
    2268             :         // layout.
    2269             :         // convert given absolute attribute position in layout direction into
    2270             :         // position in horizontal left-to-right layout.
    2271             :         {
    2272           8 :             aNewPos = _ConvertPositionToHoriL2R( aNewPos, getSize() );
    2273             :         }
    2274             :         // Convert given absolute position in horizontal left-to-right
    2275             :         // layout into relative position in horizontal left-to-right layout.
    2276             :         uno::Reference< drawing::XShape > xGroupShape =
    2277           8 :                 uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
    2278           8 :                                                    uno::UNO_QUERY );
    2279             :         {
    2280             :             // #i34750#
    2281             :             // use method <xGroupShape->getPosition()> to get the correct
    2282             :             // position of the top group object.
    2283             :             awt::Point aAttrPosInHoriL2R(
    2284           8 :                     _ConvertPositionToHoriL2R( xGroupShape->getPosition(),
    2285          16 :                                                xGroupShape->getSize() ) );
    2286           8 :             aNewPos.X -= aAttrPosInHoriL2R.X;
    2287           8 :             aNewPos.Y -= aAttrPosInHoriL2R.Y;
    2288             :         }
    2289             :         // convert relative position in horizontal left-to-right layout into
    2290             :         // absolute position in horizontal left-to-right layout
    2291             :         {
    2292             :             // #i34750#
    2293             :             // use method <SvxShape->getPosition()> to get the correct
    2294             :             // 'Drawing layer' position of the top group shape.
    2295             :             uno::Reference< lang::XUnoTunnel > xGrpShapeTunnel(
    2296           8 :                                                     pTopGroupObj->getUnoShape(),
    2297           8 :                                                     uno::UNO_QUERY );
    2298             :             SvxShape* pSvxGroupShape = reinterpret_cast< SvxShape * >(
    2299           8 :                     sal::static_int_cast< sal_IntPtr >( xGrpShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    2300           8 :             const awt::Point aGroupPos = pSvxGroupShape->getPosition();
    2301           8 :             aNewPos.X += aGroupPos.X;
    2302           8 :             aNewPos.Y += aGroupPos.Y;
    2303             :         }
    2304             :         // set position
    2305           8 :         mxShape->setPosition( aNewPos );
    2306             :     }
    2307          43 : }
    2308             : 
    2309         126 : awt::Size SAL_CALL SwXShape::getSize() throw ( uno::RuntimeException )
    2310             : {
    2311         126 :     awt::Size aSize;
    2312         126 :     if ( mxShape.is() )
    2313             :     {
    2314         126 :         aSize = mxShape->getSize();
    2315             :     }
    2316         126 :     return aSize;
    2317             : }
    2318             : 
    2319          44 : void SAL_CALL SwXShape::setSize( const awt::Size& aSize )
    2320             :                                         throw ( beans::PropertyVetoException,
    2321             :                                                 uno::RuntimeException )
    2322             : {
    2323          44 :     if ( mxShape.is() )
    2324             :     {
    2325          44 :         mxShape->setSize( aSize );
    2326             :     }
    2327          44 : }
    2328             : // #i31698#
    2329             : // implementation of virtual methods from drawing::XShapeDescriptor
    2330         141 : ::rtl::OUString SAL_CALL SwXShape::getShapeType() throw ( uno::RuntimeException )
    2331             : {
    2332         141 :     ::rtl::OUString aType;
    2333         141 :     if ( mxShape.is() )
    2334             :     {
    2335         141 :         aType = mxShape->getShapeType();
    2336             :     }
    2337         141 :     return aType;
    2338             : }
    2339             : /** method to determine top group object
    2340             :     #i31698#
    2341             : */
    2342         141 : SdrObject* SwXShape::_GetTopGroupObj( SvxShape* _pSvxShape )
    2343             : {
    2344         141 :     SdrObject* pTopGroupObj( 0L );
    2345             : 
    2346         141 :     SvxShape* pSvxShape = _pSvxShape ? _pSvxShape : GetSvxShape();
    2347         141 :     if ( pSvxShape )
    2348             :     {
    2349         141 :         SdrObject* pSdrObj = pSvxShape->GetSdrObject();
    2350         141 :         if ( pSdrObj && pSdrObj->GetUpGroup() )
    2351             :         {
    2352          10 :             pTopGroupObj = pSdrObj->GetUpGroup();
    2353          24 :             while ( pTopGroupObj->GetUpGroup() )
    2354             :             {
    2355           4 :                 pTopGroupObj = pTopGroupObj->GetUpGroup();
    2356             :             }
    2357             :         }
    2358             :     }
    2359             : 
    2360         141 :     return pTopGroupObj;
    2361             : }
    2362             : 
    2363             : /** method to determine position according to the positioning attributes
    2364             :     #i31698#
    2365             : */
    2366          98 : awt::Point SwXShape::_GetAttrPosition()
    2367             : {
    2368          98 :     awt::Point aAttrPos;
    2369             : 
    2370          98 :     uno::Any aHoriPos( getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")) ) );
    2371          98 :     aHoriPos >>= aAttrPos.X;
    2372          98 :     uno::Any aVertPos( getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")) ) );
    2373          98 :     aVertPos >>= aAttrPos.Y;
    2374             :     // #i35798# - fallback, if attribute position is (0,0)
    2375             :     // and no anchor position is applied to the drawing object
    2376          98 :     SvxShape* pSvxShape = GetSvxShape();
    2377          98 :     if ( pSvxShape )
    2378             :     {
    2379          98 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2380         151 :         if ( pObj &&
    2381          28 :              pObj->GetAnchorPos().X() == 0 &&
    2382          25 :              pObj->GetAnchorPos().Y() == 0 &&
    2383             :              aAttrPos.X == 0 && aAttrPos.Y == 0 )
    2384             :         {
    2385          21 :             const Rectangle aObjRect = pObj->GetSnapRect();
    2386          21 :             aAttrPos.X = TWIP_TO_MM100(aObjRect.Left());
    2387          21 :             aAttrPos.Y = TWIP_TO_MM100(aObjRect.Top());
    2388             :         }
    2389             :     }
    2390             :     // #i35007# - If drawing object is anchored as-character,
    2391             :     // it's x-position isn't sensible. Thus, return the x-position as zero in this case.
    2392             :     text::TextContentAnchorType eTextAnchorType =
    2393          98 :                             text::TextContentAnchorType_AT_PARAGRAPH;
    2394             :     {
    2395          98 :         rtl::OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
    2396          98 :         uno::Any aAny = getPropertyValue( sAnchorType );
    2397          98 :         aAny >>= eTextAnchorType;
    2398             :     }
    2399          98 :     if ( eTextAnchorType == text::TextContentAnchorType_AS_CHARACTER )
    2400             :     {
    2401           3 :         aAttrPos.X = 0;
    2402             :     }
    2403             : 
    2404          98 :     return aAttrPos;
    2405             : }
    2406             : 
    2407             : /** method to convert the position (translation) of the drawing object to
    2408             :     the layout direction horizontal left-to-right.
    2409             :     #i31698#
    2410             : */
    2411          16 : awt::Point SwXShape::_ConvertPositionToHoriL2R( const awt::Point _aObjPos,
    2412             :                                                 const awt::Size _aObjSize )
    2413             : {
    2414          16 :     awt::Point aObjPosInHoriL2R( _aObjPos );
    2415             : 
    2416          16 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    2417          16 :     if ( pFrmFmt )
    2418             :     {
    2419          16 :         SwFrmFmt::tLayoutDir eLayoutDir = pFrmFmt->GetLayoutDir();
    2420          16 :         switch ( eLayoutDir )
    2421             :         {
    2422             :             case SwFrmFmt::HORI_L2R:
    2423             :             {
    2424             :                 // nothing to do
    2425             :             }
    2426          16 :             break;
    2427             :             case SwFrmFmt::HORI_R2L:
    2428             :             {
    2429           0 :                 aObjPosInHoriL2R.X = -_aObjPos.X - _aObjSize.Width;
    2430             :             }
    2431           0 :             break;
    2432             :             case SwFrmFmt::VERT_R2L:
    2433             :             {
    2434           0 :                 aObjPosInHoriL2R.X = -_aObjPos.Y - _aObjSize.Width;
    2435           0 :                 aObjPosInHoriL2R.Y = _aObjPos.X;
    2436             :             }
    2437           0 :             break;
    2438             :             default:
    2439             :             {
    2440             :                 OSL_FAIL( "<SwXShape::_ConvertPositionToHoriL2R(..)> - unsupported layout direction" );
    2441             :             }
    2442             :         }
    2443             :     }
    2444             : 
    2445          16 :     return aObjPosInHoriL2R;
    2446             : }
    2447             : 
    2448             : /** method to convert the transformation of the drawing object to the layout
    2449             :     direction, the drawing object is in
    2450             :     #i31698#
    2451             : */
    2452           0 : drawing::HomogenMatrix3 SwXShape::_ConvertTransformationToLayoutDir(
    2453             :                                     drawing::HomogenMatrix3 _aMatrixInHoriL2R )
    2454             : {
    2455           0 :     drawing::HomogenMatrix3 aMatrix( _aMatrixInHoriL2R );
    2456             : 
    2457             :     // #i44334#, #i44681# - direct manipulation of the
    2458             :     // tranformation structure isn't valid, if it contains rotation.
    2459           0 :     SvxShape* pSvxShape = GetSvxShape();
    2460             :     OSL_ENSURE( pSvxShape,
    2461             :             "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SvxShape found!");
    2462           0 :     if ( pSvxShape )
    2463             :     {
    2464           0 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2465             :         OSL_ENSURE( pObj,
    2466             :                 "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SdrObject found!");
    2467           0 :         if ( pObj )
    2468             :         {
    2469             :             // get position of object in Writer coordinate system.
    2470           0 :             awt::Point aPos( getPosition() );
    2471             :             // get position of object in Drawing layer coordinate system
    2472           0 :             const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
    2473             :             const awt::Point aObjPos(
    2474           0 :                     TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
    2475           0 :                     TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
    2476             :             // determine difference between these positions according to the
    2477             :             // Writer coordinate system
    2478             :             const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
    2479           0 :                                              aPos.Y - aObjPos.Y );
    2480             :             // apply translation difference to transformation matrix.
    2481           0 :             if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
    2482             :             {
    2483             :                 // #i73079# - use correct matrix type
    2484           0 :                 ::basegfx::B2DHomMatrix aTempMatrix;
    2485             : 
    2486           0 :                 aTempMatrix.set(0, 0, aMatrix.Line1.Column1 );
    2487           0 :                 aTempMatrix.set(0, 1, aMatrix.Line1.Column2 );
    2488           0 :                 aTempMatrix.set(0, 2, aMatrix.Line1.Column3 );
    2489           0 :                 aTempMatrix.set(1, 0, aMatrix.Line2.Column1 );
    2490           0 :                 aTempMatrix.set(1, 1, aMatrix.Line2.Column2 );
    2491           0 :                 aTempMatrix.set(1, 2, aMatrix.Line2.Column3 );
    2492           0 :                 aTempMatrix.set(2, 0, aMatrix.Line3.Column1 );
    2493           0 :                 aTempMatrix.set(2, 1, aMatrix.Line3.Column2 );
    2494           0 :                 aTempMatrix.set(2, 2, aMatrix.Line3.Column3 );
    2495             :                 // #i73079#
    2496           0 :                 aTempMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
    2497           0 :                 aMatrix.Line1.Column1 = aTempMatrix.get(0, 0);
    2498           0 :                 aMatrix.Line1.Column2 = aTempMatrix.get(0, 1);
    2499           0 :                 aMatrix.Line1.Column3 = aTempMatrix.get(0, 2);
    2500           0 :                 aMatrix.Line2.Column1 = aTempMatrix.get(1, 0);
    2501           0 :                 aMatrix.Line2.Column2 = aTempMatrix.get(1, 1);
    2502           0 :                 aMatrix.Line2.Column3 = aTempMatrix.get(1, 2);
    2503           0 :                 aMatrix.Line3.Column1 = aTempMatrix.get(2, 0);
    2504           0 :                 aMatrix.Line3.Column2 = aTempMatrix.get(2, 1);
    2505           0 :                 aMatrix.Line3.Column3 = aTempMatrix.get(2, 2);
    2506             :             }
    2507             :         }
    2508             :     }
    2509             : 
    2510           0 :     return aMatrix;
    2511             : }
    2512             : 
    2513             : /** method to adjust the positioning properties
    2514             :     #i31698#
    2515             : */
    2516           0 : void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition )
    2517             : {
    2518             :     // handle x-position
    2519             :     // #i35007# - no handling of x-position, if drawing
    2520             :     // object is anchored as-character, because it doesn't make sense.
    2521             :     text::TextContentAnchorType eTextAnchorType =
    2522           0 :                             text::TextContentAnchorType_AT_PARAGRAPH;
    2523             :     {
    2524           0 :         rtl::OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
    2525           0 :         uno::Any aAny = getPropertyValue( sAnchorType );
    2526           0 :         aAny >>= eTextAnchorType;
    2527             :     }
    2528           0 :     if ( eTextAnchorType != text::TextContentAnchorType_AS_CHARACTER )
    2529             :     {
    2530             :         // determine current x-postion
    2531           0 :         rtl::OUString aHoriPosPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition") );
    2532           0 :         uno::Any aHoriPos( getPropertyValue( aHoriPosPropStr ) );
    2533           0 :         sal_Int32 dCurrX = 0;
    2534           0 :         aHoriPos >>= dCurrX;
    2535             :         // change x-position attribute, if needed
    2536           0 :         if ( dCurrX != _aPosition.X )
    2537             :         {
    2538             :             // adjust x-position orientation to text::HoriOrientation::NONE, if needed
    2539             :             // Note: has to be done before setting x-position attribute
    2540           0 :             rtl::OUString aHoriOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") );
    2541           0 :             uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) );
    2542             :             sal_Int16 eHoriOrient;
    2543           0 :             if (aHoriOrient >>= eHoriOrient) // may be void
    2544             :             {
    2545           0 :                 if ( eHoriOrient != text::HoriOrientation::NONE )
    2546             :                 {
    2547           0 :                     eHoriOrient = text::HoriOrientation::NONE;
    2548           0 :                     aHoriOrient <<= eHoriOrient;
    2549           0 :                     setPropertyValue( aHoriOrientPropStr, aHoriOrient );
    2550             :                 }
    2551             :             }
    2552             :             // set x-position attribute
    2553           0 :             aHoriPos <<= _aPosition.X;
    2554           0 :             setPropertyValue( aHoriPosPropStr, aHoriPos );
    2555           0 :         }
    2556             :     }
    2557             : 
    2558             :     // handle y-position
    2559             :     {
    2560             :         // determine current y-postion
    2561           0 :         rtl::OUString aVertPosPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition") );
    2562           0 :         uno::Any aVertPos( getPropertyValue( aVertPosPropStr ) );
    2563           0 :         sal_Int32 dCurrY = 0;
    2564           0 :         aVertPos >>= dCurrY;
    2565             :         // change y-position attribute, if needed
    2566           0 :         if ( dCurrY != _aPosition.Y )
    2567             :         {
    2568             :             // adjust y-position orientation to text::VertOrientation::NONE, if needed
    2569             :             // Note: has to be done before setting y-position attribute
    2570           0 :             rtl::OUString aVertOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrient") );
    2571           0 :             uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) );
    2572             :             sal_Int16 eVertOrient;
    2573           0 :             if (aVertOrient >>= eVertOrient) // may be void
    2574             :             {
    2575           0 :                 if ( eVertOrient != text::VertOrientation::NONE )
    2576             :                 {
    2577           0 :                     eVertOrient = text::VertOrientation::NONE;
    2578           0 :                     aVertOrient <<= eVertOrient;
    2579           0 :                     setPropertyValue( aVertOrientPropStr, aVertOrient );
    2580             :                 }
    2581             :             }
    2582             :             // set y-position attribute
    2583           0 :             aVertPos <<= _aPosition.Y;
    2584           0 :             setPropertyValue( aVertPosPropStr, aVertPos );
    2585           0 :         }
    2586             :     }
    2587           0 : }
    2588             : 
    2589             : /** method to convert start or end position of the drawing object to the
    2590             :     Writer specific position, which is the attribute position in layout direction
    2591             :     #i59051#
    2592             : */
    2593           0 : ::com::sun::star::awt::Point SwXShape::_ConvertStartOrEndPosToLayoutDir(
    2594             :                             const ::com::sun::star::awt::Point& aStartOrEndPos )
    2595             : {
    2596           0 :     awt::Point aConvertedPos( aStartOrEndPos );
    2597             : 
    2598           0 :     SvxShape* pSvxShape = GetSvxShape();
    2599             :     OSL_ENSURE( pSvxShape,
    2600             :             "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
    2601           0 :     if ( pSvxShape )
    2602             :     {
    2603           0 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2604             :         OSL_ENSURE( pObj,
    2605             :                 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
    2606           0 :         if ( pObj )
    2607             :         {
    2608             :             // get position of object in Writer coordinate system.
    2609           0 :             awt::Point aPos( getPosition() );
    2610             :             // get position of object in Drawing layer coordinate system
    2611           0 :             const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
    2612             :             const awt::Point aObjPos(
    2613           0 :                     TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
    2614           0 :                     TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
    2615             :             // determine difference between these positions according to the
    2616             :             // Writer coordinate system
    2617             :             const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
    2618           0 :                                              aPos.Y - aObjPos.Y );
    2619             :             // apply translation difference to transformation matrix.
    2620           0 :             if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
    2621             :             {
    2622           0 :                 aConvertedPos.X = aConvertedPos.X + aTranslateDiff.X;
    2623           0 :                 aConvertedPos.Y = aConvertedPos.Y + aTranslateDiff.Y;
    2624             :             }
    2625             :         }
    2626             :     }
    2627             : 
    2628           0 :     return aConvertedPos;
    2629             : }
    2630             : 
    2631           0 : ::com::sun::star::drawing::PolyPolygonBezierCoords SwXShape::_ConvertPolyPolygonBezierToLayoutDir(
    2632             :                     const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath )
    2633             : {
    2634           0 :     drawing::PolyPolygonBezierCoords aConvertedPath( aPath );
    2635             : 
    2636           0 :     SvxShape* pSvxShape = GetSvxShape();
    2637             :     OSL_ENSURE( pSvxShape,
    2638             :             "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
    2639           0 :     if ( pSvxShape )
    2640             :     {
    2641           0 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2642             :         OSL_ENSURE( pObj,
    2643             :                 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
    2644           0 :         if ( pObj )
    2645             :         {
    2646             :             // get position of object in Writer coordinate system.
    2647           0 :             awt::Point aPos( getPosition() );
    2648             :             // get position of object in Drawing layer coordinate system
    2649           0 :             const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
    2650             :             const awt::Point aObjPos(
    2651           0 :                     TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
    2652           0 :                     TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
    2653             :             // determine difference between these positions according to the
    2654             :             // Writer coordinate system
    2655             :             const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
    2656           0 :                                              aPos.Y - aObjPos.Y );
    2657             :             // apply translation difference to PolyPolygonBezier.
    2658           0 :             if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
    2659             :             {
    2660             :                 const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
    2661           0 :                     aTranslateDiff.X, aTranslateDiff.Y));
    2662             : 
    2663           0 :                 const sal_Int32 nOuterSequenceCount(aConvertedPath.Coordinates.getLength());
    2664           0 :                 drawing::PointSequence* pInnerSequence = aConvertedPath.Coordinates.getArray();
    2665           0 :                 for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
    2666             :                 {
    2667           0 :                     const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
    2668           0 :                     awt::Point* pArray = pInnerSequence->getArray();
    2669             : 
    2670           0 :                     for(sal_Int32 b(0); b < nInnerSequenceCount; b++)
    2671             :                     {
    2672           0 :                         basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y);
    2673           0 :                         aNewCoordinatePair *= aMatrix;
    2674           0 :                         pArray->X = basegfx::fround(aNewCoordinatePair.getX());
    2675           0 :                         pArray->Y = basegfx::fround(aNewCoordinatePair.getY());
    2676           0 :                         pArray++;
    2677           0 :                     }
    2678           0 :                 }
    2679             :             }
    2680             :         }
    2681             :     }
    2682             : 
    2683           0 :     return aConvertedPath;
    2684             : }
    2685             : 
    2686          12 : SwXGroupShape::SwXGroupShape(uno::Reference< XInterface > & xShape) :
    2687          12 :         SwXShape(xShape)
    2688             : {
    2689             : #if OSL_DEBUG_LEVEL > 0
    2690             :     uno::Reference<XShapes> xShapes(xShapeAgg, uno::UNO_QUERY);
    2691             :     OSL_ENSURE(xShapes.is(), "no SvxShape found or shape is not a group shape");
    2692             : #endif
    2693          12 : }
    2694             : 
    2695          24 : SwXGroupShape::~SwXGroupShape()
    2696             : {
    2697          24 : }
    2698             : 
    2699         295 : uno::Any SwXGroupShape::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
    2700             : {
    2701         295 :     uno::Any aRet;
    2702         295 :     if(rType == ::getCppuType((uno::Reference<XShapes>*)0))
    2703          11 :         aRet <<= uno::Reference<XShapes>(this);
    2704             :     else
    2705         284 :         aRet = SwXShape::queryInterface(rType);
    2706         295 :     return aRet;
    2707             : }
    2708             : 
    2709        2981 : void SwXGroupShape::acquire(  ) throw()
    2710             : {
    2711        2981 :     SwXShape::acquire();
    2712        2981 : }
    2713             : 
    2714        2981 : void SwXGroupShape::release(  ) throw()
    2715             : {
    2716        2981 :     SwXShape::release();
    2717        2981 : }
    2718             : 
    2719          12 : void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException)
    2720             : {
    2721          12 :     SolarMutexGuard aGuard;
    2722          12 :     SvxShape* pSvxShape = GetSvxShape();
    2723          12 :     SwFrmFmt* pFmt = GetFrmFmt();
    2724          12 :     if(pSvxShape && pFmt)
    2725             :     {
    2726          12 :         uno::Reference<XShapes> xShapes;
    2727          12 :         if( xShapeAgg.is() )
    2728             :         {
    2729          12 :             const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
    2730          12 :             uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2731          12 :             aAgg >>= xShapes;
    2732             :         }
    2733          12 :         if(xShapes.is())
    2734          12 :             xShapes->add(xShape);
    2735             :         else
    2736           0 :             throw uno::RuntimeException();
    2737             : 
    2738          12 :         uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY);
    2739          12 :         SwXShape* pSwShape = 0;
    2740          12 :         if(xShape.is())
    2741             :             pSwShape = reinterpret_cast< SwXShape * >(
    2742          12 :                     sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
    2743          12 :         if(pSwShape && pSwShape->m_bDescriptor)
    2744             :         {
    2745             :             SvxShape* pAddShape = reinterpret_cast< SvxShape * >(
    2746          12 :                     sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    2747          12 :             if(pAddShape)
    2748             :             {
    2749          12 :                 SdrObject* pObj = pAddShape->GetSdrObject();
    2750          12 :                 if(pObj)
    2751             :                 {
    2752          12 :                     SwDoc* pDoc = pFmt->GetDoc();
    2753             :                     // set layer of new drawing
    2754             :                     // object to corresponding invisible layer.
    2755          12 :                     if( FmFormInventor != pObj->GetObjInventor())
    2756             :                     {
    2757          12 :                         pObj->SetLayer( pSwShape->pImpl->GetOpaque()
    2758           0 :                                         ? pDoc->GetInvisibleHeavenId()
    2759          24 :                                         : pDoc->GetInvisibleHellId() );
    2760             :                     }
    2761             :                     else
    2762             :                     {
    2763           0 :                         pObj->SetLayer(pDoc->GetInvisibleControlsId());
    2764             :                     }
    2765             :                 }
    2766             :             }
    2767          12 :             pSwShape->m_bDescriptor = sal_False;
    2768             :             //add the group member to the format of the group
    2769          12 :             SwFrmFmt* pShapeFmt = ::FindFrmFmt( pSvxShape->GetSdrObject() );
    2770          12 :             if(pShapeFmt)
    2771          12 :                 pFmt->Add(pSwShape);
    2772          12 :         }
    2773             :     }
    2774             :     else
    2775           0 :         throw uno::RuntimeException();
    2776          12 : }
    2777             : 
    2778           0 : void SwXGroupShape::remove( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException)
    2779             : {
    2780           0 :     SolarMutexGuard aGuard;
    2781           0 :     uno::Reference<XShapes> xShapes;
    2782           0 :     if( xShapeAgg.is() )
    2783             :     {
    2784           0 :         const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
    2785           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2786           0 :         aAgg >>= xShapes;
    2787             :     }
    2788           0 :     if(!xShapes.is())
    2789           0 :         throw uno::RuntimeException();
    2790           0 :     xShapes->remove(xShape);
    2791           0 : }
    2792             : 
    2793           3 : sal_Int32 SwXGroupShape::getCount(void) throw( uno::RuntimeException )
    2794             : {
    2795           3 :     SolarMutexGuard aGuard;
    2796           3 :     uno::Reference<XIndexAccess> xAcc;
    2797           3 :     if( xShapeAgg.is() )
    2798             :     {
    2799           3 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2800           3 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2801           3 :         aAgg >>= xAcc;
    2802             :     }
    2803           3 :     if(!xAcc.is())
    2804           0 :         throw uno::RuntimeException();
    2805           3 :     return xAcc->getCount();
    2806             : }
    2807             : 
    2808           6 : uno::Any SwXGroupShape::getByIndex(sal_Int32 nIndex)
    2809             :         throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
    2810             :                uno::RuntimeException )
    2811             : {
    2812           6 :     SolarMutexGuard aGuard;
    2813           6 :     uno::Reference<XIndexAccess> xAcc;
    2814           6 :     if( xShapeAgg.is() )
    2815             :     {
    2816           6 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2817           6 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2818           6 :         aAgg >>= xAcc;
    2819             :     }
    2820           6 :     if(!xAcc.is())
    2821           0 :         throw uno::RuntimeException();
    2822           6 :     return xAcc->getByIndex(nIndex);
    2823             : }
    2824             : 
    2825           0 : uno::Type SwXGroupShape::getElementType(  ) throw(uno::RuntimeException)
    2826             : {
    2827           0 :     SolarMutexGuard aGuard;
    2828           0 :     uno::Reference<XIndexAccess> xAcc;
    2829           0 :     if( xShapeAgg.is() )
    2830             :     {
    2831           0 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2832           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2833           0 :         aAgg >>= xAcc;
    2834             :     }
    2835           0 :     if(!xAcc.is())
    2836           0 :         throw uno::RuntimeException();
    2837           0 :     return xAcc->getElementType();
    2838             : }
    2839             : 
    2840           5 : sal_Bool SwXGroupShape::hasElements(  ) throw(uno::RuntimeException)
    2841             : {
    2842           5 :     SolarMutexGuard aGuard;
    2843           5 :     uno::Reference<XIndexAccess> xAcc;
    2844           5 :     if( xShapeAgg.is() )
    2845             :     {
    2846           5 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2847           5 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2848           5 :         aAgg >>= xAcc;
    2849             :     }
    2850           5 :     if(!xAcc.is())
    2851           0 :         throw uno::RuntimeException();
    2852           5 :     return xAcc->hasElements();
    2853          30 : }
    2854             : 
    2855             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10