LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unodraw.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1011 1447 69.9 %
Date: 2014-04-11 Functions: 86 122 70.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10