LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unodraw.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1447 0.0 %
Date: 2014-04-14 Functions: 0 122 0.0 %
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           0 :     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           0 :      mpFollowTextFlow( new SwFmtFollowTextFlow( sal_False ) ),
     100             :      // #i28701# #i35017#
     101             :      pWrapInfluenceOnObjPos( new SwFmtWrapInfluenceOnObjPos(
     102           0 :                             text::WrapInfluenceOnPosition::ONCE_CONCURRENT ) ),
     103             :      // #i28749#
     104             :      mnPositionLayoutDir( text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
     105           0 :      bInitializedPropertyNotifier(false)
     106           0 :      {}
     107             : 
     108           0 :     ~SwShapeDescriptor_Impl()
     109           0 :     {
     110           0 :         delete pHOrient;
     111           0 :         delete pVOrient;
     112           0 :         delete pAnchor;
     113           0 :         delete pSurround;
     114           0 :         delete pULSpace;
     115           0 :         delete pLRSpace;
     116             :         // #i26791#
     117           0 :         delete mpFollowTextFlow;
     118             :         // #i28701#
     119           0 :         delete pWrapInfluenceOnObjPos;
     120           0 :     }
     121           0 :     SwFmtAnchor*    GetAnchor(bool bCreate = false)
     122             :         {
     123           0 :             if(bCreate && !pAnchor)
     124             :             {
     125           0 :                 pAnchor = new SwFmtAnchor(FLY_AS_CHAR);
     126             :             }
     127           0 :             return pAnchor;
     128             :         }
     129           0 :     SwFmtHoriOrient* GetHOrient(bool bCreate = false)
     130             :         {
     131           0 :             if (bCreate && !pHOrient)
     132             :             {
     133             :                 // #i26791#
     134           0 :                 pHOrient = new SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
     135             :             }
     136           0 :             return pHOrient;
     137             :         }
     138           0 :     SwFmtVertOrient* GetVOrient(bool bCreate = false)
     139             :         {
     140           0 :             if(bCreate && !pVOrient)
     141             :             {
     142             :                 // #i26791#
     143           0 :                 pVOrient = new SwFmtVertOrient( 0, text::VertOrientation::NONE, text::RelOrientation::FRAME );
     144             :             }
     145           0 :             return pVOrient;
     146             :         }
     147             : 
     148           0 :     SwFmtSurround*  GetSurround(bool bCreate = false)
     149             :         {
     150           0 :             if(bCreate && !pSurround)
     151           0 :                 pSurround = new SwFmtSurround();
     152           0 :             return pSurround;
     153             :         }
     154           0 :     SvxLRSpaceItem* GetLRSpace(bool bCreate = false)
     155             :         {
     156           0 :             if(bCreate && !pLRSpace)
     157           0 :                 pLRSpace = new SvxLRSpaceItem(RES_LR_SPACE);
     158           0 :             return pLRSpace;
     159             :         }
     160           0 :     SvxULSpaceItem* GetULSpace(bool bCreate = false)
     161             :         {
     162           0 :             if(bCreate && !pULSpace)
     163           0 :                 pULSpace = new SvxULSpaceItem(RES_UL_SPACE);
     164           0 :             return pULSpace;
     165             :         }
     166           0 :     uno::Reference< text::XTextRange > &    GetTextRange()
     167             :     {
     168           0 :         return xTextRange;
     169             :     }
     170           0 :     sal_Bool    IsOpaque() const
     171             :         {
     172           0 :             return bOpaque;
     173             :         }
     174           0 :     const sal_Bool&    GetOpaque() const
     175             :         {
     176           0 :             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           0 :     SwFmtFollowTextFlow* GetFollowTextFlow( bool _bCreate = false )
     188             :     {
     189           0 :         if ( _bCreate && !mpFollowTextFlow )
     190           0 :             mpFollowTextFlow = new SwFmtFollowTextFlow( sal_False );
     191           0 :         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           0 :     inline SwFmtWrapInfluenceOnObjPos* GetWrapInfluenceOnObjPos(
     226             :                                         const bool _bCreate = false )
     227             :     {
     228           0 :         if ( _bCreate && !pWrapInfluenceOnObjPos )
     229             :         {
     230             :             pWrapInfluenceOnObjPos = new SwFmtWrapInfluenceOnObjPos(
     231             :                         // #i35017#
     232           0 :                         text::WrapInfluenceOnPosition::ONCE_CONCURRENT );
     233             :         }
     234           0 :         return pWrapInfluenceOnObjPos;
     235             :     }
     236           0 :     inline void RemoveWrapInfluenceOnObjPos()
     237             :     {
     238           0 :         DELETEZ(pWrapInfluenceOnObjPos);
     239           0 :     }
     240             : };
     241             : 
     242             : /****************************************************************************
     243             :     class SwFmDrawPage
     244             : ****************************************************************************/
     245           0 : SwFmDrawPage::SwFmDrawPage( SdrPage* pPage ) :
     246           0 :     SvxFmDrawPage( pPage ), pPageView(0)
     247             : {
     248           0 : }
     249             : 
     250           0 : SwFmDrawPage::~SwFmDrawPage() throw ()
     251             : {
     252           0 :     RemovePageView();
     253           0 : }
     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           0 : void    SwFmDrawPage::RemovePageView()
     276             : {
     277           0 :     if(pPageView && mpView)
     278           0 :         mpView->HideSdrPage();
     279           0 :     pPageView = 0;
     280           0 : }
     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           0 : SdrObject* SwFmDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xShape ) throw (std::exception)
     300             : {
     301             :     //TODO: stimmt das so - kann die Methode weg?
     302           0 :     return SvxFmDrawPage::_CreateSdrObject( xShape );
     303             : }
     304             : 
     305           0 : uno::Reference< drawing::XShape >  SwFmDrawPage::_CreateShape( SdrObject *pObj ) const throw (std::exception)
     306             : {
     307           0 :     uno::Reference< drawing::XShape >  xRet;
     308           0 :     if(pObj->ISA(SwVirtFlyDrawObj) || pObj->GetObjInventor() == SWGInventor)
     309             :     {
     310           0 :         SwFlyDrawContact* pFlyContact = (SwFlyDrawContact*)pObj->GetUserCall();
     311           0 :         if(pFlyContact)
     312             :         {
     313           0 :             FlyCntType eType = FLYCNTTYPE_ALL;
     314           0 :             SwFrmFmt* pFlyFmt = pFlyContact->GetFmt();
     315           0 :             SwDoc* pDoc = pFlyFmt->GetDoc();
     316             :             const SwNodeIndex* pIdx;
     317           0 :             if( RES_FLYFRMFMT == pFlyFmt->Which()
     318           0 :                 && 0 != ( pIdx = pFlyFmt->GetCntnt().GetCntntIdx() )
     319           0 :                 && pIdx->GetNodes().IsDocNodes()
     320             :                 )
     321             :             {
     322           0 :                 const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
     323           0 :                 if(!pNd->IsNoTxtNode())
     324           0 :                     eType = FLYCNTTYPE_FRM;
     325           0 :                 else if( pNd->IsGrfNode() )
     326           0 :                     eType = FLYCNTTYPE_GRF;
     327           0 :                 else if( pNd->IsOLENode() )
     328           0 :                     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           0 :             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           0 :             xRet = SvxFmDrawPage::_CreateShape( pObj );
     345             :         }
     346           0 :         uno::Reference< XUnoTunnel > xShapeTunnel(xRet, uno::UNO_QUERY);
     347             :         //don't create an SwXShape if it already exists
     348           0 :         SwXShape* pShape = 0;
     349           0 :         if(xShapeTunnel.is())
     350             :             pShape = reinterpret_cast< SwXShape * >(
     351           0 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
     352           0 :         if(!pShape)
     353             :         {
     354           0 :             xShapeTunnel = 0;
     355           0 :             uno::Reference< uno::XInterface > xCreate(xRet, uno::UNO_QUERY);
     356           0 :             xRet = 0;
     357           0 :             uno::Reference< beans::XPropertySet >  xPrSet;
     358           0 :             if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || ( PTR_CAST(E3dScene,pObj ) != NULL ) ) )
     359           0 :                 xPrSet = new SwXGroupShape( xCreate );
     360             :             else
     361           0 :                 xPrSet = new SwXShape( xCreate );
     362           0 :             xRet = uno::Reference< drawing::XShape >(xPrSet, uno::UNO_QUERY);
     363           0 :         }
     364             :     }
     365           0 :     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           0 :             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           0 : SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage)
     396           0 :     : m_aShapes()
     397             : {
     398           0 :     SolarMutexGuard aGuard;
     399           0 :     ::std::insert_iterator<shapescontainer_t> pInserter = ::std::insert_iterator<shapescontainer_t>(m_aShapes, m_aShapes.begin());
     400           0 :     sal_Int32 nCount = pDrawPage->getCount();
     401           0 :     for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++)
     402             :     {
     403           0 :         uno::Reference<drawing::XShape> xShape = uno::Reference<drawing::XShape>(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY);
     404           0 :         *pInserter++ = uno::makeAny(xShape);
     405           0 :     }
     406           0 : }
     407             : 
     408           0 : sal_Bool SwXShapesEnumeration::hasMoreElements(void) throw(uno::RuntimeException, std::exception)
     409             : {
     410           0 :     SolarMutexGuard aGuard;
     411           0 :     return !m_aShapes.empty();
     412             : }
     413             : 
     414           0 : uno::Any SwXShapesEnumeration::nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     415             : {
     416           0 :     SolarMutexGuard aGuard;
     417           0 :     if(m_aShapes.empty())
     418           0 :         throw container::NoSuchElementException();
     419           0 :     uno::Any aResult = *m_aShapes.begin();
     420           0 :     m_aShapes.pop_front();
     421           0 :     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           0 : uno::Reference< container::XEnumeration > SwXDrawPage::createEnumeration(void) throw( uno::RuntimeException, std::exception )
     443             : {
     444           0 :     SolarMutexGuard aGuard;
     445             :     return uno::Reference< container::XEnumeration >(
     446           0 :         new SwXShapesEnumeration(this));
     447             : }
     448             : 
     449           0 : OUString SwXDrawPage::getImplementationName(void) throw( uno::RuntimeException, std::exception )
     450             : {
     451           0 :     return OUString("SwXDrawPage");
     452             : }
     453             : 
     454           0 : sal_Bool SwXDrawPage::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
     455             : {
     456           0 :     return cppu::supportsService(this, rServiceName);
     457             : }
     458             : 
     459           0 : uno::Sequence< OUString > SwXDrawPage::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
     460             : {
     461           0 :     uno::Sequence< OUString > aRet(1);
     462           0 :     OUString* pArray = aRet.getArray();
     463           0 :     pArray[0] = "com.sun.star.drawing.GenericDrawPage";
     464           0 :     return aRet;
     465             : }
     466             : 
     467           0 : SwXDrawPage::SwXDrawPage(SwDoc* pDc) :
     468             :     pDoc(pDc),
     469           0 :     pDrawPage(0)
     470             : {
     471           0 : }
     472             : 
     473           0 : SwXDrawPage::~SwXDrawPage()
     474             : {
     475           0 :     if(xPageAgg.is())
     476             :     {
     477           0 :         uno::Reference< uno::XInterface >  xInt;
     478           0 :         xPageAgg->setDelegator(xInt);
     479             :     }
     480           0 : }
     481             : 
     482           0 : uno::Any SwXDrawPage::queryInterface( const uno::Type& aType )
     483             :                                                 throw( uno::RuntimeException, std::exception )
     484             : {
     485           0 :     uno::Any aRet = SwXDrawPageBaseClass::queryInterface(aType);
     486           0 :     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           0 :         SwFmDrawPage* pPage = GetSvxPage();
     493             : 
     494           0 :         if(pPage)
     495             :         {
     496           0 :             aRet = pPage->queryAggregation(aType);
     497             :         }
     498             :     }
     499           0 :     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           0 : sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException, std::exception )
     522             : {
     523           0 :     SolarMutexGuard aGuard;
     524           0 :     if(!pDoc)
     525           0 :         throw uno::RuntimeException();
     526           0 :     if(!pDoc->GetDrawModel())
     527           0 :         return 0;
     528             :     else
     529             :     {
     530           0 :         ((SwXDrawPage*)this)->GetSvxPage();
     531           0 :         return pDrawPage->getCount();
     532           0 :     }
     533             : }
     534             : 
     535           0 : uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex)
     536             :         throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
     537             :                uno::RuntimeException, std::exception )
     538             : {
     539           0 :     SolarMutexGuard aGuard;
     540           0 :     if(!pDoc)
     541           0 :         throw uno::RuntimeException();
     542           0 :     if(!pDoc->GetDrawModel())
     543           0 :         throw lang::IndexOutOfBoundsException();
     544             : 
     545           0 :     ((SwXDrawPage*)this)->GetSvxPage();
     546           0 :     return pDrawPage->getByIndex( nIndex );
     547             : }
     548             : 
     549           0 : uno::Type  SwXDrawPage::getElementType(void) throw( uno::RuntimeException, std::exception )
     550             : {
     551           0 :     return ::getCppuType((const uno::Reference<drawing::XShape>*)0);
     552             : }
     553             : 
     554           0 : sal_Bool SwXDrawPage::hasElements(void) throw( uno::RuntimeException, std::exception )
     555             : {
     556           0 :     SolarMutexGuard aGuard;
     557           0 :     if(!pDoc)
     558           0 :         throw uno::RuntimeException();
     559           0 :     if(!pDoc->GetDrawModel())
     560           0 :         return sal_False;
     561             :     else
     562           0 :         return ((SwXDrawPage*)this)->GetSvxPage()->hasElements();
     563             : }
     564             : 
     565           0 : void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
     566             :     throw( uno::RuntimeException, std::exception )
     567             : {
     568           0 :     SolarMutexGuard aGuard;
     569           0 :     if(!pDoc)
     570           0 :         throw uno::RuntimeException();
     571           0 :     uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShape, uno::UNO_QUERY);
     572           0 :     SwXShape* pShape = 0;
     573           0 :     SvxShape* pSvxShape = 0;
     574           0 :     if(xShapeTunnel.is())
     575             :     {
     576             :         pShape      = reinterpret_cast< SwXShape * >(
     577           0 :                 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
     578             :         pSvxShape   = reinterpret_cast< SvxShape * >(
     579           0 :                 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
     580             :     }
     581             : 
     582           0 :     if(!pShape || pShape->GetRegisteredIn() || !pShape->m_bDescriptor )
     583             :     {
     584           0 :         uno::RuntimeException aExcept;
     585           0 :         if(pShape)
     586           0 :             aExcept.Message = "object already inserted";
     587             :         else
     588           0 :             aExcept.Message = "illegal object";
     589           0 :         throw aExcept;
     590             :     }
     591             : 
     592           0 :     if ( pSvxShape->GetSdrObject() )
     593             :     {
     594           0 :         if ( pSvxShape->GetSdrObject()->IsInserted() )
     595             :         {
     596           0 :             return;
     597             :         }
     598             :     }
     599           0 :     GetSvxPage()->add(xShape);
     600             : 
     601           0 :     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           0 :     awt::Point aMM100Pos(pSvxShape->getPosition());
     606             : 
     607             :     //jetzt noch die Properties aus dem SwShapeDescriptor_Impl auswerten
     608           0 :     SwShapeDescriptor_Impl* pDesc = pShape->GetDescImpl();
     609             : 
     610           0 :     SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     611           0 :                                         RES_FRMATR_END-1 );
     612           0 :     SwFmtAnchor aAnchor( FLY_AS_CHAR );
     613           0 :     sal_Bool bOpaque = sal_False;
     614           0 :     if( pDesc )
     615             :     {
     616           0 :         if(pDesc->GetSurround())
     617           0 :             aSet.Put( *pDesc->GetSurround());
     618             :         //die Items sind schon in Twip gesetzt
     619           0 :         if(pDesc->GetLRSpace())
     620             :         {
     621           0 :             aSet.Put(*pDesc->GetLRSpace());
     622             :         }
     623           0 :         if(pDesc->GetULSpace())
     624             :         {
     625           0 :             aSet.Put(*pDesc->GetULSpace());
     626             :         }
     627           0 :         if(pDesc->GetAnchor())
     628           0 :             aAnchor = *pDesc->GetAnchor();
     629             : 
     630             :         // #i32349# - if no horizontal position exists, create one
     631           0 :         if ( !pDesc->GetHOrient() )
     632             :         {
     633           0 :             SwFmtHoriOrient* pHori = pDesc->GetHOrient( true );
     634           0 :             SwTwips nHoriPos = convertMm100ToTwip(aMM100Pos.X);
     635           0 :             pHori->SetPos( nHoriPos );
     636             :         }
     637             :         {
     638           0 :             if(pDesc->GetHOrient()->GetHoriOrient() == text::HoriOrientation::NONE)
     639           0 :                 aMM100Pos.X = convertTwipToMm100(pDesc->GetHOrient()->GetPos());
     640           0 :             aSet.Put( *pDesc->GetHOrient() );
     641             :         }
     642             :         // #i32349# - if no vertical position exists, create one
     643           0 :         if ( !pDesc->GetVOrient() )
     644             :         {
     645           0 :             SwFmtVertOrient* pVert = pDesc->GetVOrient( true );
     646           0 :             SwTwips nVertPos = convertMm100ToTwip(aMM100Pos.Y);
     647           0 :             pVert->SetPos( nVertPos );
     648             :         }
     649             :         {
     650           0 :             if(pDesc->GetVOrient()->GetVertOrient() == text::VertOrientation::NONE)
     651           0 :                 aMM100Pos.Y = convertTwipToMm100(pDesc->GetVOrient()->GetPos());
     652           0 :             aSet.Put( *pDesc->GetVOrient() );
     653             :         }
     654             : 
     655           0 :         if(pDesc->GetSurround())
     656           0 :             aSet.Put( *pDesc->GetSurround());
     657           0 :         bOpaque = pDesc->IsOpaque();
     658             : 
     659             :         // #i26791#
     660           0 :         if ( pDesc->GetFollowTextFlow() )
     661             :         {
     662           0 :             aSet.Put( *pDesc->GetFollowTextFlow() );
     663             :         }
     664             : 
     665             :         // #i28701#
     666           0 :         if ( pDesc->GetWrapInfluenceOnObjPos() )
     667             :         {
     668           0 :             aSet.Put( *pDesc->GetWrapInfluenceOnObjPos() );
     669             :         }
     670             :     }
     671             : 
     672           0 :     pSvxShape->setPosition(aMM100Pos);
     673           0 :     SdrObject* pObj = pSvxShape->GetSdrObject();
     674             :     // #108784# - set layer of new drawing object to corresponding
     675             :     // invisible layer.
     676           0 :     if(FmFormInventor != pObj->GetObjInventor())
     677           0 :         pObj->SetLayer( bOpaque ? pDoc->GetInvisibleHeavenId() : pDoc->GetInvisibleHellId() );
     678             :     else
     679           0 :         pObj->SetLayer(pDoc->GetInvisibleControlsId());
     680             : 
     681           0 :     SwPaM* pPam = new SwPaM(pDoc->GetNodes().GetEndOfContent());
     682           0 :     SwUnoInternalPaM* pInternalPam = 0;
     683           0 :     uno::Reference< text::XTextRange >  xRg;
     684           0 :     if( pDesc && (xRg = pDesc->GetTextRange()).is() )
     685             :     {
     686           0 :         pInternalPam = new SwUnoInternalPaM(*pDoc);
     687           0 :         if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg))
     688             :         {
     689           0 :             if(FLY_AT_FLY == aAnchor.GetAnchorId() &&
     690           0 :                                 !pInternalPam->GetNode()->FindFlyStartNode())
     691             :             {
     692           0 :                         aAnchor.SetType(FLY_AS_CHAR);
     693             :             }
     694           0 :             else if (FLY_AT_PAGE == aAnchor.GetAnchorId())
     695             :             {
     696           0 :                 aAnchor.SetAnchor(pInternalPam->Start());
     697             :             }
     698             :         }
     699             :         else
     700           0 :             throw uno::RuntimeException();
     701             :     }
     702           0 :     else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetCurrentLayout())
     703             :     {
     704           0 :         SwCrsrMoveState aState( MV_SETONLYTEXT );
     705           0 :         Point aTmp(convertMm100ToTwip(aMM100Pos.X), convertMm100ToTwip(aMM100Pos.Y));
     706           0 :         pDoc->GetCurrentLayout()->GetCrsrOfst( pPam->GetPoint(), aTmp, &aState );
     707           0 :         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           0 :         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           0 :     aSet.Put(aAnchor);
     720           0 :     SwPaM* pTemp = pInternalPam;
     721           0 :     if ( !pTemp )
     722           0 :         pTemp = pPam;
     723           0 :     UnoActionContext aAction(pDoc);
     724           0 :     pDoc->InsertDrawObj( *pTemp, *pObj, aSet );
     725           0 :     SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
     726           0 :     if(pFmt)
     727           0 :         pFmt->Add(pShape);
     728           0 :     pShape->m_bDescriptor = sal_False;
     729             : 
     730           0 :     delete pPam;
     731           0 :     delete pInternalPam;
     732             : }
     733             : 
     734           0 : void SwXDrawPage::remove(const uno::Reference< drawing::XShape > & xShape) throw( uno::RuntimeException, std::exception )
     735             : {
     736           0 :     SolarMutexGuard aGuard;
     737           0 :     if(!pDoc)
     738           0 :         throw uno::RuntimeException();
     739           0 :     uno::Reference<lang::XComponent> xComp(xShape, uno::UNO_QUERY);
     740           0 :     xComp->dispose();
     741           0 : }
     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           0 : SwFmDrawPage*   SwXDrawPage::GetSvxPage()
     823             : {
     824           0 :     if(!xPageAgg.is() && pDoc)
     825             :     {
     826           0 :         SolarMutexGuard aGuard;
     827             :         // #i52858#
     828           0 :         SdrModel* pModel = pDoc->GetOrCreateDrawModel();
     829           0 :         SdrPage* pPage = pModel->GetPage( 0 );
     830             : 
     831             :         {
     832             :             // waehrend des queryInterface braucht man ein Ref auf das
     833             :             // Objekt, sonst wird es geloescht.
     834           0 :             pDrawPage = new SwFmDrawPage(pPage);
     835           0 :             uno::Reference< drawing::XDrawPage >  xPage = pDrawPage;
     836           0 :             uno::Any aAgg = xPage->queryInterface(::getCppuType((uno::Reference< uno::XAggregation >*)0));
     837           0 :             if(aAgg.getValueType() == ::getCppuType((uno::Reference< uno::XAggregation >*)0))
     838           0 :                 xPageAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
     839             :         }
     840           0 :         if( xPageAgg.is() )
     841           0 :             xPageAgg->setDelegator( (cppu::OWeakObject*)this );
     842             :     }
     843           0 :     return pDrawPage;
     844             : }
     845             : 
     846             : // renamed and outlined to detect where it's called
     847           0 : void SwXDrawPage::InvalidateSwDoc()
     848             : {
     849           0 :     pDoc = 0;
     850           0 : }
     851             : 
     852           0 : TYPEINIT1(SwXShape, SwClient);
     853             : 
     854             : namespace
     855             : {
     856             :     class theSwXShapeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXShapeUnoTunnelId > {};
     857             : }
     858             : 
     859           0 : const uno::Sequence< sal_Int8 > & SwXShape::getUnoTunnelId()
     860             : {
     861           0 :     return theSwXShapeUnoTunnelId::get().getSeq();
     862             : }
     863             : 
     864           0 : sal_Int64 SAL_CALL SwXShape::getSomething( const uno::Sequence< sal_Int8 >& rId )
     865             :     throw(uno::RuntimeException, std::exception)
     866             : {
     867           0 :     if( rId.getLength() == 16
     868           0 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
     869           0 :                                         rId.getConstArray(), 16 ) )
     870             :     {
     871           0 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
     872             :     }
     873             : 
     874           0 :     if( xShapeAgg.is() )
     875             :     {
     876           0 :         const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*)0 );
     877           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rTunnelType );
     878           0 :         if(aAgg.getValueType() == rTunnelType)
     879             :         {
     880             :             uno::Reference<lang::XUnoTunnel> xAggTunnel =
     881           0 :                     *(uno::Reference<lang::XUnoTunnel>*)aAgg.getValue();
     882           0 :             if(xAggTunnel.is())
     883           0 :                 return xAggTunnel->getSomething(rId);
     884           0 :         }
     885             :     }
     886           0 :     return 0;
     887             : }
     888             : namespace
     889             : {
     890           0 :     static void lcl_addShapePropertyEventFactories( SdrObject& _rObj, SwXShape& _rShape )
     891             :     {
     892           0 :         ::svx::PPropertyValueProvider pProvider( new ::svx::PropertyValueProvider( _rShape, "AnchorType" ) );
     893           0 :         _rObj.getShapePropertyChangeNotifier().registerProvider( ::svx::eTextShapeAnchorType, pProvider );
     894           0 :     }
     895             : }
     896             : 
     897           0 : SwXShape::SwXShape(uno::Reference< uno::XInterface > & xShape) :
     898           0 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)),
     899           0 :     m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)),
     900           0 :     pImpl(new SwShapeDescriptor_Impl()),
     901           0 :     m_bDescriptor(sal_True)
     902             : {
     903           0 :     if(xShape.is())  // default Ctor
     904             :     {
     905           0 :         const uno::Type& rAggType = ::getCppuType((const uno::Reference< uno::XAggregation >*)0);
     906             :         //aAgg contains a reference of the SvxShape!
     907             :         {
     908           0 :             uno::Any aAgg = xShape->queryInterface(rAggType);
     909           0 :             if(aAgg.getValueType() == rAggType)
     910           0 :                 xShapeAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
     911             :             // #i31698#
     912           0 :             if ( xShapeAgg.is() )
     913             :             {
     914           0 :                 xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< drawing::XShape >*)0) ) >>= mxShape;
     915             :                 OSL_ENSURE( mxShape.is(),
     916             :                         "<SwXShape::SwXShape(..)> - no XShape found at <xShapeAgg>" );
     917           0 :             }
     918             :         }
     919           0 :         xShape = 0;
     920           0 :         m_refCount++;
     921           0 :         if( xShapeAgg.is() )
     922           0 :             xShapeAgg->setDelegator( (cppu::OWeakObject*)this );
     923           0 :         m_refCount--;
     924             : 
     925           0 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
     926           0 :         SvxShape* pShape = 0;
     927           0 :         if(xShapeTunnel.is())
     928             :             pShape = reinterpret_cast< SvxShape * >(
     929           0 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
     930             : 
     931           0 :         SdrObject* pObj = pShape ? pShape->GetSdrObject() : 0;
     932           0 :         if(pObj)
     933             :         {
     934           0 :             SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
     935           0 :             if(pFmt)
     936           0 :                 pFmt->Add(this);
     937             : 
     938           0 :             lcl_addShapePropertyEventFactories( *pObj, *this );
     939           0 :             pImpl->bInitializedPropertyNotifier = true;
     940           0 :         }
     941             :     }
     942           0 : }
     943             : 
     944           0 : void SwXShape::AddExistingShapeToFmt( SdrObject& _rObj )
     945             : {
     946           0 :     SdrObjListIter aIter( _rObj, IM_DEEPNOGROUPS );
     947           0 :     while ( aIter.IsMore() )
     948             :     {
     949           0 :         SdrObject* pCurrent = aIter.Next();
     950             :         OSL_ENSURE( pCurrent, "SwXShape::AddExistingShapeToFmt: invalid object list element!" );
     951           0 :         if ( !pCurrent )
     952           0 :             continue;
     953             : 
     954           0 :         SwXShape* pSwShape = NULL;
     955           0 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel( pCurrent->getWeakUnoShape(), uno::UNO_QUERY );
     956           0 :         if ( xShapeTunnel.is() )
     957             :             pSwShape = reinterpret_cast< SwXShape * >(
     958           0 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething( SwXShape::getUnoTunnelId() ) ) );
     959           0 :         if ( pSwShape )
     960             :         {
     961           0 :             if ( pSwShape->m_bDescriptor )
     962             :             {
     963           0 :                 SwFrmFmt* pFmt = ::FindFrmFmt( const_cast< SdrObject* >( pCurrent ) );
     964           0 :                 if ( pFmt )
     965           0 :                     pFmt->Add( pSwShape );
     966           0 :                 pSwShape->m_bDescriptor = sal_False;
     967             :             }
     968             : 
     969           0 :             if ( !pSwShape->pImpl->bInitializedPropertyNotifier )
     970             :             {
     971           0 :                 lcl_addShapePropertyEventFactories( *pCurrent, *pSwShape );
     972           0 :                 pSwShape->pImpl->bInitializedPropertyNotifier = true;
     973             :             }
     974             :         }
     975           0 :     }
     976           0 : }
     977             : 
     978           0 : SwXShape::~SwXShape()
     979             : {
     980           0 :     if (xShapeAgg.is())
     981             :     {
     982           0 :         uno::Reference< uno::XInterface >  xRef;
     983           0 :         xShapeAgg->setDelegator(xRef);
     984             :     }
     985           0 :     delete pImpl;
     986           0 : }
     987             : 
     988           0 : uno::Any SwXShape::queryInterface( const uno::Type& aType ) throw( uno::RuntimeException, std::exception )
     989             : {
     990           0 :     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           0 :     if(!aRet.hasValue() && xShapeAgg.is())
     995             :     {
     996           0 :         if(aType == ::getCppuType((uno::Reference<XShape>*)0))
     997           0 :             aRet <<= uno::Reference<XShape>(this);
     998             :         else
     999           0 :             aRet = xShapeAgg->queryAggregation(aType);
    1000             :     }
    1001           0 :     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           0 : uno::Reference< beans::XPropertySetInfo >  SwXShape::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception )
    1034             : {
    1035           0 :     SolarMutexGuard aGuard;
    1036           0 :     uno::Reference< beans::XPropertySetInfo >  aRet;
    1037           0 :     if(xShapeAgg.is())
    1038             :     {
    1039           0 :         const uno::Type& rPropSetType = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
    1040           0 :         uno::Any aPSet = xShapeAgg->queryAggregation( rPropSetType );
    1041           0 :         if(aPSet.getValueType() == rPropSetType && aPSet.getValue())
    1042             :         {
    1043             :             uno::Reference< beans::XPropertySet >  xPrSet =
    1044           0 :                     *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
    1045           0 :             uno::Reference< beans::XPropertySetInfo >  xInfo = xPrSet->getPropertySetInfo();
    1046             :             // PropertySetInfo verlaengern!
    1047           0 :             const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
    1048           0 :             aRet = new SfxExtItemPropertySetInfo( m_pPropertyMapEntries, aPropSeq );
    1049           0 :         }
    1050             :     }
    1051           0 :     if(!aRet.is())
    1052           0 :         aRet = m_pPropSet->getPropertySetInfo();
    1053           0 :     return aRet;
    1054             : }
    1055             : 
    1056           0 : 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           0 :     SolarMutexGuard aGuard;
    1062           0 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1063           0 :     const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
    1064           0 :     if(xShapeAgg.is())
    1065             :     {
    1066           0 :         if(pEntry)
    1067             :         {
    1068           0 :             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           0 :             if(pFmt)
    1072             :             {
    1073           0 :                 SwAttrSet aSet(pFmt->GetAttrSet());
    1074           0 :                 SwDoc* pDoc = pFmt->GetDoc();
    1075           0 :                 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           0 :                 else if(RES_OPAQUE == pEntry->nWID)
    1106             :                 {
    1107           0 :                     SvxShape* pSvxShape = GetSvxShape();
    1108             :                     SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
    1109           0 :                     if(pSvxShape)
    1110             :                     {
    1111           0 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1112             :                         // set layer of new drawing
    1113             :                         // object to corresponding invisible layer.
    1114           0 :                         bool bIsVisible = pDoc->IsVisibleLayerId( pObj->GetLayer() );
    1115           0 :                         if(FmFormInventor != pObj->GetObjInventor())
    1116             :                         {
    1117           0 :                             pObj->SetLayer( *(sal_Bool*)aValue.getValue()
    1118           0 :                                             ? ( bIsVisible ? pDoc->GetHeavenId() : pDoc->GetInvisibleHeavenId() )
    1119           0 :                                             : ( 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           0 :                 else if ( FN_TEXT_RANGE == pEntry->nWID )
    1131             :                 {
    1132           0 :                     SwFmtAnchor aAnchor( static_cast<const SwFmtAnchor&>(aSet.Get( RES_ANCHOR )) );
    1133           0 :                     if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
    1134             :                     {
    1135             :                         // set property <TextRange> not valid for to-page anchored shapes
    1136           0 :                         throw lang::IllegalArgumentException();
    1137             :                     }
    1138             :                     else
    1139             :                     {
    1140             :                         SwUnoInternalPaM* pInternalPam =
    1141           0 :                                         new SwUnoInternalPaM( *(pFmt->GetDoc()) );
    1142           0 :                         uno::Reference< text::XTextRange > xRg;
    1143           0 :                         aValue >>= xRg;
    1144           0 :                         if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
    1145             :                         {
    1146           0 :                             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           0 :                                 const SwPosition *pPos = aAnchor.GetCntntAnchor();
    1153           0 :                                 SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
    1154             :                                 SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
    1155           0 :                                 const sal_Int32 nIdx = pPos->nContent.GetIndex();
    1156             :                                 SwTxtAttr * const pHnt =
    1157             :                                     pTxtNode->GetTxtAttrForCharAt(
    1158           0 :                                         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           0 :                                 const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
    1164           0 :                                     .SetFlyFmt();
    1165             : 
    1166             :                                 //The connection is removed now the attribute can be deleted.
    1167           0 :                                 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
    1168             :                                 //create a new one
    1169           0 :                                 SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode();
    1170             :                                 SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TxtNode." );
    1171           0 :                                 SwFmtFlyCnt aFmt( pFmt );
    1172           0 :                                 pNd->InsertItem(aFmt, pInternalPam->GetPoint()
    1173           0 :                                         ->nContent.GetIndex(), 0 );
    1174             :                             }
    1175             :                             else
    1176             :                             {
    1177           0 :                                 aAnchor.SetAnchor( pInternalPam->GetPoint() );
    1178           0 :                                 aSet.Put(aAnchor);
    1179           0 :                                 pFmt->SetFmtAttr(aSet);
    1180             :                             }
    1181             :                         }
    1182             :                         else
    1183             :                         {
    1184           0 :                             throw uno::RuntimeException();
    1185             :                         }
    1186           0 :                         delete pInternalPam;
    1187           0 :                     }
    1188             :                 }
    1189             :                 // #i28749#
    1190           0 :                 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
    1191             :                 {
    1192           0 :                     sal_Int16 nPositionLayoutDir = 0;
    1193           0 :                     aValue >>= nPositionLayoutDir;
    1194           0 :                     pFmt->SetPositionLayoutDir( nPositionLayoutDir );
    1195             :                 }
    1196           0 :                 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           0 :                 else if( RES_FRM_SIZE == pEntry->nWID &&
    1217           0 :                         ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH
    1218           0 :                           || pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION
    1219           0 :                           || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION ) )
    1220             :                 {
    1221           0 :                     SvxShape* pSvxShape = GetSvxShape();
    1222             :                     SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
    1223           0 :                     if(pSvxShape)
    1224             :                     {
    1225           0 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1226           0 :                         sal_Int16 nPercent(100);
    1227           0 :                         aValue >>= nPercent;
    1228           0 :                         switch (pEntry->nMemberId)
    1229             :                         {
    1230             :                         case MID_FRMSIZE_REL_WIDTH:
    1231           0 :                             pObj->SetRelativeWidth( nPercent / 100.0 );
    1232           0 :                         break;
    1233             :                         case MID_FRMSIZE_REL_HEIGHT:
    1234           0 :                             pObj->SetRelativeHeight( nPercent / 100.0 );
    1235           0 :                         break;
    1236             :                         case MID_FRMSIZE_REL_WIDTH_RELATION:
    1237           0 :                             pObj->SetRelativeWidthRelation(nPercent);
    1238           0 :                         break;
    1239             :                         case MID_FRMSIZE_REL_HEIGHT_RELATION:
    1240           0 :                             pObj->SetRelativeHeightRelation(nPercent);
    1241           0 :                         break;
    1242             :                         }
    1243           0 :                     }
    1244             :                 }
    1245             :                 else
    1246             :                 {
    1247           0 :                     m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
    1248             : 
    1249           0 :                     if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
    1250             :                     {
    1251           0 :                         bool bSetAttr = true;
    1252           0 :                         sal_Int32 eNewAnchor = SWUnoHelper::GetEnumAsInt32( aValue );
    1253             : 
    1254             :                         //if old anchor was in_cntnt the related text attribute has to be removed
    1255           0 :                         const SwFmtAnchor& rOldAnchor = pFmt->GetAnchor();
    1256           0 :                         RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
    1257           0 :                         SdrObject* pObj = pFmt->FindSdrObject();
    1258           0 :                         SwFrmFmt *pFlyFmt = FindFrmFmt( pObj );
    1259           0 :                         pFlyFmt->DelFrms();
    1260           0 :                         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           0 :                             const SwPosition *pPos = rOldAnchor.GetCntntAnchor();
    1267           0 :                             SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
    1268             :                             SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
    1269           0 :                             const sal_Int32 nIdx = pPos->nContent.GetIndex();
    1270             :                             SwTxtAttr * const pHnt =
    1271             :                                 pTxtNode->GetTxtAttrForCharAt(
    1272           0 :                                     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           0 :                             const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
    1278           0 :                                 .SetFlyFmt();
    1279             : 
    1280             :                             //The connection is removed now the attribute can be deleted.
    1281           0 :                             pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
    1282             :                         }
    1283           0 :                         else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
    1284             :                                 (FLY_AT_PAGE == eOldAnchorId))
    1285             :                         {
    1286           0 :                             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           0 :                             SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
    1290           0 :                             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           0 :                                 aPam.Move( fnMoveBackward, fnGoDoc );
    1300             :                             }
    1301             :                             //anchor position has to be inserted after the text attribute has been inserted
    1302           0 :                             aNewAnchor.SetAnchor( aPam.GetPoint() );
    1303           0 :                             aSet.Put( aNewAnchor );
    1304           0 :                             pFmt->SetFmtAttr(aSet);
    1305           0 :                             bSetAttr = false;
    1306             :                         }
    1307           0 :                         if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
    1308             :                             (FLY_AS_CHAR != eOldAnchorId))
    1309             :                         {
    1310           0 :                             SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
    1311           0 :                             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           0 :                                 aPam.Move( fnMoveBackward, fnGoDoc );
    1321             :                             }
    1322             :                             //the RES_TXTATR_FLYCNT needs to be added now
    1323           0 :                             SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
    1324             :                             SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
    1325           0 :                             SwFmtFlyCnt aFmt( pFlyFmt );
    1326             :                             pNd->InsertItem(aFmt,
    1327           0 :                                 aPam.GetPoint()->nContent.GetIndex(), 0 );
    1328           0 :                             aPam.GetPoint()->nContent--; // InsertItem moved it
    1329             :                             SwFmtAnchor aNewAnchor(
    1330             :                                 dynamic_cast<const SwFmtAnchor&>(
    1331           0 :                                     aSet.Get(RES_ANCHOR)));
    1332           0 :                             aNewAnchor.SetAnchor( aPam.GetPoint() );
    1333           0 :                             aSet.Put( aNewAnchor );
    1334             :                         }
    1335           0 :                         if( bSetAttr )
    1336           0 :                             pFmt->SetFmtAttr(aSet);
    1337             :                     }
    1338             :                     else
    1339           0 :                         pFmt->SetFmtAttr(aSet);
    1340           0 :                 }
    1341             :             }
    1342             :             else
    1343             :             {
    1344           0 :                 SfxPoolItem* pItem = 0;
    1345           0 :                 switch(pEntry->nWID)
    1346             :                 {
    1347             :                     case RES_ANCHOR:
    1348           0 :                         pItem = pImpl->GetAnchor(true);
    1349           0 :                     break;
    1350             :                     case RES_HORI_ORIENT:
    1351           0 :                         pItem = pImpl->GetHOrient(true);
    1352           0 :                     break;
    1353             :                     case RES_VERT_ORIENT:
    1354           0 :                         pItem = pImpl->GetVOrient(true);
    1355           0 :                     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           0 :                             ::getCppuType((uno::Reference< text::XTextRange>*)0);
    1369           0 :                         if(aValue.getValueType() == rTextRangeType)
    1370             :                         {
    1371           0 :                             uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
    1372           0 :                             rRange = *(uno::Reference< text::XTextRange > *)aValue.getValue();
    1373           0 :                         }
    1374             :                     }
    1375           0 :                     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           0 :                 if(pItem)
    1401           0 :                     ((SfxPoolItem*)pItem)->PutValue(aValue, pEntry->nMemberId);
    1402             :             }
    1403             :         }
    1404             :         else
    1405             :         {
    1406           0 :             uno::Reference< beans::XPropertySet >  xPrSet;
    1407             :             const uno::Type& rPSetType =
    1408           0 :                 ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
    1409           0 :             uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
    1410           0 :             if(aPSet.getValueType() != rPSetType || !aPSet.getValue())
    1411           0 :                 throw uno::RuntimeException();
    1412           0 :             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           0 :             awt::Point aKeepedPosition( 0, 0 );
    1418           0 :             if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
    1419             :             {
    1420           0 :                     aKeepedPosition = getPosition();
    1421             :             }
    1422           0 :             if( pFmt && pFmt->GetDoc()->GetCurrentViewShell() )
    1423             :             {
    1424           0 :                 UnoActionContext aCtx(pFmt->GetDoc());
    1425           0 :                 xPrSet->setPropertyValue(rPropertyName, aValue);
    1426             :             }
    1427             :             else
    1428           0 :                 xPrSet->setPropertyValue(rPropertyName, aValue);
    1429             :             // #i31698# - restore object position, if caption point is set.
    1430           0 :             if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
    1431             :             {
    1432           0 :                 setPosition( aKeepedPosition );
    1433           0 :             }
    1434             :         }
    1435           0 :     }
    1436           0 : }
    1437             : 
    1438           0 : uno::Any SwXShape::getPropertyValue(const OUString& rPropertyName)
    1439             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1440             :            uno::RuntimeException, std::exception )
    1441             : {
    1442           0 :     SolarMutexGuard aGuard;
    1443           0 :     uno::Any aRet;
    1444           0 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1445           0 :     if(xShapeAgg.is())
    1446             :     {
    1447           0 :         const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
    1448           0 :         if(pEntry)
    1449             :         {
    1450           0 :             if(pFmt)
    1451             :             {
    1452           0 :                 if(RES_OPAQUE == pEntry->nWID)
    1453             :                 {
    1454           0 :                     SvxShape* pSvxShape = GetSvxShape();
    1455             :                     OSL_ENSURE(pSvxShape, "No SvxShape found!");
    1456           0 :                     if(pSvxShape)
    1457             :                     {
    1458           0 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1459             :                         // consider invisible layers
    1460             :                         sal_Bool bOpaque =
    1461           0 :                             ( pObj->GetLayer() != pFmt->GetDoc()->GetHellId() &&
    1462           0 :                               pObj->GetLayer() != pFmt->GetDoc()->GetInvisibleHellId() );
    1463           0 :                         aRet.setValue(&bOpaque, ::getBooleanCppuType());
    1464             :                     }
    1465             :                 }
    1466           0 :                 else if(FN_ANCHOR_POSITION == pEntry->nWID)
    1467             :                 {
    1468           0 :                     SvxShape* pSvxShape = GetSvxShape();
    1469             :                     OSL_ENSURE(pSvxShape, "No SvxShape found!");
    1470           0 :                     if(pSvxShape)
    1471             :                     {
    1472           0 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1473           0 :                         Point aPt = pObj->GetAnchorPos();
    1474           0 :                         awt::Point aPoint( convertTwipToMm100( aPt.X() ),
    1475           0 :                                            convertTwipToMm100( aPt.Y() ) );
    1476           0 :                         aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
    1477             :                     }
    1478             :                 }
    1479             :                 // #i26791# - special handling for FN_TEXT_RANGE
    1480           0 :                 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           0 :                 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           0 :                 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
    1517             :                 {
    1518           0 :                     aRet <<= pFmt->GetPositionLayoutDir();
    1519             :                 }
    1520             :                 // #i36248#
    1521           0 :                 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           0 :                 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           0 :                 else if (pEntry->nWID == RES_FRM_SIZE &&
    1534           0 :                          (pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT ||
    1535           0 :                           pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ||
    1536           0 :                           pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION ||
    1537           0 :                           pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION))
    1538             :                 {
    1539           0 :                     SvxShape* pSvxShape = GetSvxShape();
    1540             :                     SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
    1541           0 :                     sal_Int16 nRet = 0;
    1542           0 :                     if (pSvxShape)
    1543             :                     {
    1544           0 :                         SdrObject* pObj = pSvxShape->GetSdrObject();
    1545           0 :                         switch (pEntry->nMemberId)
    1546             :                         {
    1547             :                         case MID_FRMSIZE_REL_WIDTH:
    1548           0 :                             if (pObj->GetRelativeWidth())
    1549           0 :                                 nRet = *pObj->GetRelativeWidth() * 100;
    1550           0 :                             break;
    1551             :                         case MID_FRMSIZE_REL_HEIGHT:
    1552           0 :                             if (pObj->GetRelativeHeight())
    1553           0 :                                 nRet = *pObj->GetRelativeHeight() * 100;
    1554           0 :                             break;
    1555             :                         case MID_FRMSIZE_REL_WIDTH_RELATION:
    1556           0 :                             nRet = pObj->GetRelativeWidthRelation();
    1557           0 :                             break;
    1558             :                         case MID_FRMSIZE_REL_HEIGHT_RELATION:
    1559           0 :                             nRet = pObj->GetRelativeHeightRelation();
    1560           0 :                             break;
    1561             :                         }
    1562             :                     }
    1563           0 :                     aRet = uno::makeAny(nRet);
    1564             :                 }
    1565             :                 else
    1566             :                 {
    1567           0 :                     const SwAttrSet& rSet = pFmt->GetAttrSet();
    1568           0 :                     m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
    1569             :                 }
    1570             :             }
    1571             :             else
    1572             :             {
    1573           0 :                 SfxPoolItem* pItem = 0;
    1574           0 :                 switch(pEntry->nWID)
    1575             :                 {
    1576             :                     case RES_ANCHOR:
    1577           0 :                         pItem = pImpl->GetAnchor();
    1578           0 :                     break;
    1579             :                     case RES_HORI_ORIENT:
    1580           0 :                         pItem = pImpl->GetHOrient();
    1581           0 :                     break;
    1582             :                     case RES_VERT_ORIENT:
    1583           0 :                         pItem = pImpl->GetVOrient();
    1584           0 :                     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           0 :                 if(pItem)
    1648           0 :                     pItem->QueryValue(aRet, pEntry->nMemberId);
    1649             :             }
    1650             :         }
    1651             :         else
    1652             :         {
    1653           0 :             aRet = _getPropAtAggrObj( rPropertyName );
    1654             : 
    1655             :             // #i31698# - convert the position (translation)
    1656             :             // of the drawing object in the transformation
    1657           0 :             if ( rPropertyName == "Transformation" )
    1658             :             {
    1659           0 :                 drawing::HomogenMatrix3 aMatrix;
    1660           0 :                 aRet >>= aMatrix;
    1661           0 :                 aRet <<= _ConvertTransformationToLayoutDir( aMatrix );
    1662             :             }
    1663             :             // #i36248#
    1664           0 :             else if ( rPropertyName == "StartPosition" )
    1665             :             {
    1666           0 :                 awt::Point aStartPos;
    1667           0 :                 aRet >>= aStartPos;
    1668             :                 // #i59051#
    1669           0 :                 aRet <<= _ConvertStartOrEndPosToLayoutDir( aStartPos );
    1670             :             }
    1671           0 :             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           0 :             else if ( rPropertyName == "PolyPolygonBezier" )
    1680             :             {
    1681           0 :                 drawing::PolyPolygonBezierCoords aPath;
    1682           0 :                 aRet >>= aPath;
    1683           0 :                 aRet <<= _ConvertPolyPolygonBezierToLayoutDir( aPath );
    1684             :             }
    1685             :         }
    1686             :     }
    1687           0 :     return aRet;
    1688             : }
    1689             : 
    1690           0 : uno::Any SwXShape::_getPropAtAggrObj( const OUString& _rPropertyName )
    1691             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException,
    1692             :            uno::RuntimeException )
    1693             : {
    1694           0 :     uno::Any aRet;
    1695             : 
    1696           0 :     uno::Reference< beans::XPropertySet >  xPrSet;
    1697             :     const uno::Type& rPSetType =
    1698           0 :                 ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
    1699           0 :     uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
    1700           0 :     if ( aPSet.getValueType() != rPSetType || !aPSet.getValue() )
    1701             :     {
    1702           0 :         throw uno::RuntimeException();
    1703             :     }
    1704           0 :     xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
    1705           0 :     aRet = xPrSet->getPropertyValue( _rPropertyName );
    1706             : 
    1707           0 :     return aRet;
    1708             : }
    1709             : 
    1710           0 : beans::PropertyState SwXShape::getPropertyState( const OUString& rPropertyName )
    1711             :     throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1712             : {
    1713           0 :     SolarMutexGuard aGuard;
    1714           0 :     uno::Sequence< OUString > aNames(1);
    1715           0 :     OUString* pStrings = aNames.getArray();
    1716           0 :     pStrings[0] = rPropertyName;
    1717           0 :     uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
    1718           0 :     return aStates.getConstArray()[0];
    1719             : }
    1720             : 
    1721           0 : uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates(
    1722             :     const uno::Sequence< OUString >& aPropertyNames )
    1723             :         throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1724             : {
    1725           0 :     SolarMutexGuard aGuard;
    1726           0 :     SwFrmFmt*   pFmt = GetFrmFmt();
    1727           0 :     uno::Sequence< beans::PropertyState > aRet(aPropertyNames.getLength());
    1728           0 :     if(xShapeAgg.is())
    1729             :     {
    1730           0 :         SvxShape* pSvxShape = GetSvxShape();
    1731           0 :         bool bGroupMember = false;
    1732           0 :         bool bFormControl = false;
    1733           0 :         SdrObject* pObject = pSvxShape ? pSvxShape->GetSdrObject() : NULL;
    1734           0 :         if(pObject)
    1735             :         {
    1736           0 :             bGroupMember = pObject->GetUpGroup() != 0;
    1737           0 :             bFormControl = pObject->GetObjInventor() == FmFormInventor;
    1738             :         }
    1739           0 :         const OUString* pNames = aPropertyNames.getConstArray();
    1740           0 :         beans::PropertyState* pRet = aRet.getArray();
    1741           0 :         uno::Reference< XPropertyState >  xShapePrState;
    1742           0 :         for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++)
    1743             :         {
    1744           0 :             const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap().getByName( pNames[nProperty] );
    1745           0 :             if(pEntry)
    1746             :             {
    1747           0 :                 if(RES_OPAQUE == pEntry->nWID)
    1748           0 :                     pRet[nProperty] = bFormControl ?
    1749           0 :                         beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
    1750           0 :                 else if(FN_ANCHOR_POSITION == pEntry->nWID)
    1751           0 :                     pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1752           0 :                 else if(FN_TEXT_RANGE == pEntry->nWID)
    1753           0 :                     pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1754           0 :                 else if(bGroupMember)
    1755           0 :                     pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
    1756           0 :                 else if (pEntry->nWID == RES_FRM_SIZE &&
    1757           0 :                          (pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION ||
    1758           0 :                           pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION))
    1759           0 :                     pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
    1760           0 :                 else if(pFmt)
    1761             :                 {
    1762           0 :                     const SwAttrSet& rSet = pFmt->GetAttrSet();
    1763           0 :                     SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, false);
    1764             : 
    1765           0 :                     if(SFX_ITEM_SET == eItemState)
    1766           0 :                         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           0 :                 if(!xShapePrState.is())
    1811             :                 {
    1812           0 :                     const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
    1813           0 :                     uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
    1814           0 :                     if(aPState.getValueType() != rPStateType || !aPState.getValue())
    1815           0 :                         throw uno::RuntimeException();
    1816           0 :                     xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
    1817             :                 }
    1818           0 :                 pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]);
    1819             :             }
    1820           0 :         }
    1821             :     }
    1822             :     else
    1823           0 :         throw uno::RuntimeException();
    1824           0 :     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           0 : void SwXShape::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    1974             : {
    1975           0 :     ClientModify(this, pOld, pNew);
    1976           0 : }
    1977             : 
    1978           0 : void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
    1979             :     throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
    1980             : {
    1981           0 :     SolarMutexGuard aGuard;
    1982             : 
    1983             :     // get access to SwDoc
    1984             :     // (see also SwXTextRange::XTextRangeToSwPaM)
    1985           0 :     SwDoc*      pDoc = 0;
    1986           0 :     uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
    1987           0 :     if(xRangeTunnel.is())
    1988             :     {
    1989           0 :         SwXTextRange* pRange = 0;
    1990           0 :         OTextCursorHelper* pCursor = 0;
    1991           0 :         SwXTextPortion* pPortion = 0;
    1992           0 :         SwXText* pText = 0;
    1993           0 :         SwXParagraph* pParagraph = 0;
    1994             : 
    1995             :         pRange  = reinterpret_cast< SwXTextRange * >(
    1996           0 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
    1997             :         pText   = reinterpret_cast< SwXText * >(
    1998           0 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) ));
    1999             :         pCursor = reinterpret_cast< OTextCursorHelper * >(
    2000           0 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
    2001             :         pPortion = reinterpret_cast< SwXTextPortion * >(
    2002           0 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) ));
    2003             :         pParagraph = reinterpret_cast< SwXParagraph * >(
    2004           0 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId( ) ) ) );
    2005             : 
    2006           0 :         if (pRange)
    2007           0 :             pDoc = pRange->GetDoc();
    2008           0 :         else if (!pDoc && pText)
    2009           0 :             pDoc = pText->GetDoc();
    2010           0 :         else if (!pDoc && pCursor)
    2011           0 :             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           0 :     if(!pDoc)
    2024           0 :         throw uno::RuntimeException();
    2025           0 :     SwDocShell *pDocSh = pDoc->GetDocShell();
    2026           0 :     if (pDocSh)
    2027             :     {
    2028           0 :         uno::Reference< frame::XModel > xModel;
    2029           0 :         xModel = pDocSh->GetModel();
    2030           0 :         uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
    2031           0 :         if (xDPS.is())
    2032             :         {
    2033           0 :             uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
    2034           0 :             if (xDP.is())
    2035             :             {
    2036           0 :                 uno::Any aPos;
    2037           0 :                 aPos <<= xTextRange;
    2038           0 :                 setPropertyValue("TextRange", aPos);
    2039           0 :                 uno::Reference< drawing::XShape > xTemp( (cppu::OWeakObject*) this, uno::UNO_QUERY );
    2040           0 :                 xDP->add( xTemp );
    2041           0 :             }
    2042           0 :         }
    2043           0 :     }
    2044           0 : }
    2045             : 
    2046           0 : uno::Reference< text::XTextRange >  SwXShape::getAnchor(void) throw( uno::RuntimeException, std::exception )
    2047             : {
    2048           0 :     SolarMutexGuard aGuard;
    2049           0 :     uno::Reference< text::XTextRange >  aRef;
    2050           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    2051           0 :     if(pFmt)
    2052             :     {
    2053           0 :         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           0 :         if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
    2057           0 :             (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
    2058             :         {
    2059           0 :             const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
    2060           0 :             aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
    2061             :         }
    2062             :     }
    2063             :     else
    2064           0 :         aRef = pImpl->GetTextRange();
    2065           0 :     return aRef;
    2066             : }
    2067             : 
    2068           0 : void SwXShape::dispose(void) throw( uno::RuntimeException, std::exception )
    2069             : {
    2070           0 :     SolarMutexGuard aGuard;
    2071           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    2072           0 :     if(pFmt)
    2073             :     {
    2074             :         // determine correct <SdrObject>
    2075           0 :         SvxShape* pSvxShape = GetSvxShape();
    2076           0 :         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           0 :         if ( pObj &&
    2091           0 :              !pObj->ISA(SwDrawVirtObj) &&
    2092           0 :              !pObj->GetUpGroup() &&
    2093           0 :              pObj->IsInserted() )
    2094             :         {
    2095           0 :             if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
    2096             :             {
    2097           0 :                 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
    2098           0 :                 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
    2099           0 :                 const sal_Int32 nIdx = rPos.nContent.GetIndex();
    2100           0 :                 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
    2101             :             }
    2102             :             else
    2103           0 :                 pFmt->GetDoc()->DelLayoutFmt( pFmt );
    2104             :         }
    2105             :     }
    2106           0 :     if(xShapeAgg.is())
    2107             :     {
    2108           0 :         uno::Any aAgg(xShapeAgg->queryAggregation( ::getCppuType((uno::Reference<XComponent>*)0)));
    2109           0 :         uno::Reference<XComponent> xComp;
    2110           0 :         aAgg >>= xComp;
    2111           0 :         if(xComp.is())
    2112           0 :             xComp->dispose();
    2113           0 :     }
    2114           0 : }
    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           0 : sal_Bool SwXShape::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    2141             : {
    2142           0 :     return cppu::supportsService(this, rServiceName);
    2143             : }
    2144             : 
    2145           0 : uno::Sequence< OUString > SwXShape::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    2146             : {
    2147           0 :     uno::Sequence< OUString > aSeq;
    2148           0 :     if(xShapeAgg.is())
    2149             :     {
    2150           0 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    2151           0 :         SvxShape* pSvxShape = GetSvxShape();
    2152           0 :         if(pSvxShape)
    2153           0 :             aSeq = pSvxShape->getSupportedServiceNames();
    2154             :     }
    2155             :     else
    2156             :     {
    2157           0 :         aSeq.realloc(1);
    2158           0 :         aSeq.getArray()[0] = "com.sun.star.drawing.Shape";
    2159             :     }
    2160           0 :     return aSeq;
    2161             : }
    2162             : 
    2163           0 : SvxShape*   SwXShape::GetSvxShape()
    2164             : {
    2165           0 :     SvxShape* pSvxShape = 0;
    2166           0 :     if(xShapeAgg.is())
    2167             :     {
    2168           0 :         uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    2169           0 :         if(xShapeTunnel.is())
    2170             :             pSvxShape = reinterpret_cast< SvxShape * >(
    2171           0 :                     sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    2172             :     }
    2173           0 :     return pSvxShape;
    2174             : }
    2175             : 
    2176             : // #i31698#
    2177             : // implementation of virtual methods from drawing::XShape
    2178           0 : awt::Point SAL_CALL SwXShape::getPosition() throw ( uno::RuntimeException, std::exception )
    2179             : {
    2180           0 :     awt::Point aPos( _GetAttrPosition() );
    2181             : 
    2182             :     // handle group members
    2183           0 :     SvxShape* pSvxShape = GetSvxShape();
    2184           0 :     if ( pSvxShape )
    2185             :     {
    2186           0 :         SdrObject* pTopGroupObj = _GetTopGroupObj( pSvxShape );
    2187           0 :         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           0 :                     uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
    2193           0 :                                                        uno::UNO_QUERY );
    2194           0 :             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           0 :             const Rectangle aMemberObjRect = GetSvxShape()->GetSdrObject()->GetSnapRect();
    2200           0 :             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           0 :             awt::Point aOffset( 0, 0 );
    2204             :                 {
    2205           0 :                     aOffset.X = ( aMemberObjRect.Left() - aGroupObjRect.Left() );
    2206           0 :                     aOffset.Y = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
    2207             :                 }
    2208           0 :             aOffset.X = convertTwipToMm100(aOffset.X);
    2209           0 :             aOffset.Y = convertTwipToMm100(aOffset.Y);
    2210           0 :             aPos.X += aOffset.X;
    2211           0 :             aPos.Y += aOffset.Y;
    2212             :         }
    2213             :     }
    2214             : 
    2215           0 :     return aPos;
    2216             : }
    2217             : 
    2218           0 : void SAL_CALL SwXShape::setPosition( const awt::Point& aPosition )
    2219             :                                                 throw ( uno::RuntimeException, std::exception )
    2220             : {
    2221           0 :     SdrObject* pTopGroupObj = _GetTopGroupObj();
    2222           0 :     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           0 :         bool bApplyPosAtDrawObj(false);
    2228           0 :         bool bNoAdjustOfPosProp(false);
    2229             :         // #i35798# - apply position also to drawing object,
    2230             :         // if drawing object has no anchor position set.
    2231           0 :         if ( mxShape.is() )
    2232             :         {
    2233           0 :             SvxShape* pSvxShape = GetSvxShape();
    2234           0 :             if ( pSvxShape )
    2235             :             {
    2236           0 :                 const SdrObject* pObj = pSvxShape->GetSdrObject();
    2237           0 :                 if ( pObj &&
    2238           0 :                      pObj->GetAnchorPos().X() == 0 &&
    2239           0 :                      pObj->GetAnchorPos().Y() == 0 )
    2240             :                 {
    2241           0 :                     bApplyPosAtDrawObj = true;
    2242           0 :                     if ( pObj->GetUserCall() &&
    2243           0 :                          pObj->GetUserCall()->ISA(SwDrawContact) )
    2244             :                     {
    2245           0 :                         bNoAdjustOfPosProp = true;
    2246             :                     }
    2247             :                 }
    2248             :             }
    2249             :         }
    2250             :         // shape isn't a group member. Thus, set positioning attributes
    2251           0 :         if ( !bNoAdjustOfPosProp )
    2252             :         {
    2253           0 :             _AdjustPositionProperties( aPosition );
    2254             :         }
    2255           0 :         if ( bApplyPosAtDrawObj )
    2256             :         {
    2257           0 :             mxShape->setPosition( aPosition );
    2258             :         }
    2259             :     }
    2260           0 :     else if ( mxShape.is() )
    2261             :     {
    2262             :         // shape is a member of a group. Thus, set its position.
    2263           0 :         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           0 :             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           0 :                 uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
    2276           0 :                                                    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           0 :                     _ConvertPositionToHoriL2R( xGroupShape->getPosition(),
    2283           0 :                                                xGroupShape->getSize() ) );
    2284           0 :             aNewPos.X -= aAttrPosInHoriL2R.X;
    2285           0 :             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           0 :                                                     pTopGroupObj->getUnoShape(),
    2295           0 :                                                     uno::UNO_QUERY );
    2296             :             SvxShape* pSvxGroupShape = reinterpret_cast< SvxShape * >(
    2297           0 :                     sal::static_int_cast< sal_IntPtr >( xGrpShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    2298           0 :             const awt::Point aGroupPos = pSvxGroupShape->getPosition();
    2299           0 :             aNewPos.X += aGroupPos.X;
    2300           0 :             aNewPos.Y += aGroupPos.Y;
    2301             :         }
    2302             :         // set position
    2303           0 :         mxShape->setPosition( aNewPos );
    2304             :     }
    2305           0 : }
    2306             : 
    2307           0 : awt::Size SAL_CALL SwXShape::getSize() throw ( uno::RuntimeException, std::exception )
    2308             : {
    2309           0 :     awt::Size aSize;
    2310           0 :     if ( mxShape.is() )
    2311             :     {
    2312           0 :         aSize = mxShape->getSize();
    2313             :     }
    2314           0 :     return aSize;
    2315             : }
    2316             : 
    2317           0 : void SAL_CALL SwXShape::setSize( const awt::Size& aSize )
    2318             :                                         throw ( beans::PropertyVetoException,
    2319             :                                                 uno::RuntimeException, std::exception )
    2320             : {
    2321           0 :     if ( mxShape.is() )
    2322             :     {
    2323           0 :         mxShape->setSize( aSize );
    2324             :     }
    2325           0 : }
    2326             : // #i31698#
    2327             : // implementation of virtual methods from drawing::XShapeDescriptor
    2328           0 : OUString SAL_CALL SwXShape::getShapeType() throw ( uno::RuntimeException, std::exception )
    2329             : {
    2330           0 :     OUString aType;
    2331           0 :     if ( mxShape.is() )
    2332             :     {
    2333           0 :         aType = mxShape->getShapeType();
    2334             :     }
    2335           0 :     return aType;
    2336             : }
    2337             : /** method to determine top group object
    2338             :     #i31698#
    2339             : */
    2340           0 : SdrObject* SwXShape::_GetTopGroupObj( SvxShape* _pSvxShape )
    2341             : {
    2342           0 :     SdrObject* pTopGroupObj( 0L );
    2343             : 
    2344           0 :     SvxShape* pSvxShape = _pSvxShape ? _pSvxShape : GetSvxShape();
    2345           0 :     if ( pSvxShape )
    2346             :     {
    2347           0 :         SdrObject* pSdrObj = pSvxShape->GetSdrObject();
    2348           0 :         if ( pSdrObj && pSdrObj->GetUpGroup() )
    2349             :         {
    2350           0 :             pTopGroupObj = pSdrObj->GetUpGroup();
    2351           0 :             while ( pTopGroupObj->GetUpGroup() )
    2352             :             {
    2353           0 :                 pTopGroupObj = pTopGroupObj->GetUpGroup();
    2354             :             }
    2355             :         }
    2356             :     }
    2357             : 
    2358           0 :     return pTopGroupObj;
    2359             : }
    2360             : 
    2361             : /** method to determine position according to the positioning attributes
    2362             :     #i31698#
    2363             : */
    2364           0 : awt::Point SwXShape::_GetAttrPosition()
    2365             : {
    2366           0 :     awt::Point aAttrPos;
    2367             : 
    2368           0 :     uno::Any aHoriPos( getPropertyValue("HoriOrientPosition") );
    2369           0 :     aHoriPos >>= aAttrPos.X;
    2370           0 :     uno::Any aVertPos( getPropertyValue("VertOrientPosition") );
    2371           0 :     aVertPos >>= aAttrPos.Y;
    2372             :     // #i35798# - fallback, if attribute position is (0,0)
    2373             :     // and no anchor position is applied to the drawing object
    2374           0 :     SvxShape* pSvxShape = GetSvxShape();
    2375           0 :     if ( pSvxShape )
    2376             :     {
    2377           0 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2378           0 :         if ( pObj &&
    2379           0 :              pObj->GetAnchorPos().X() == 0 &&
    2380           0 :              pObj->GetAnchorPos().Y() == 0 &&
    2381           0 :              aAttrPos.X == 0 && aAttrPos.Y == 0 )
    2382             :         {
    2383           0 :             const Rectangle aObjRect = pObj->GetSnapRect();
    2384           0 :             aAttrPos.X = convertTwipToMm100(aObjRect.Left());
    2385           0 :             aAttrPos.Y = convertTwipToMm100(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           0 :                             text::TextContentAnchorType_AT_PARAGRAPH;
    2392             :     {
    2393           0 :         OUString sAnchorType( "AnchorType" );
    2394           0 :         uno::Any aAny = getPropertyValue( sAnchorType );
    2395           0 :         aAny >>= eTextAnchorType;
    2396             :     }
    2397           0 :     if ( eTextAnchorType == text::TextContentAnchorType_AS_CHARACTER )
    2398             :     {
    2399           0 :         aAttrPos.X = 0;
    2400             :     }
    2401             : 
    2402           0 :     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           0 : awt::Point SwXShape::_ConvertPositionToHoriL2R( const awt::Point _aObjPos,
    2410             :                                                 const awt::Size _aObjSize )
    2411             : {
    2412           0 :     awt::Point aObjPosInHoriL2R( _aObjPos );
    2413             : 
    2414           0 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    2415           0 :     if ( pFrmFmt )
    2416             :     {
    2417           0 :         SwFrmFmt::tLayoutDir eLayoutDir = pFrmFmt->GetLayoutDir();
    2418           0 :         switch ( eLayoutDir )
    2419             :         {
    2420             :             case SwFrmFmt::HORI_L2R:
    2421             :             {
    2422             :                 // nothing to do
    2423             :             }
    2424           0 :             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           0 :     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           0 : drawing::HomogenMatrix3 SwXShape::_ConvertTransformationToLayoutDir(
    2451             :                                     drawing::HomogenMatrix3 _aMatrixInHoriL2R )
    2452             : {
    2453           0 :     drawing::HomogenMatrix3 aMatrix( _aMatrixInHoriL2R );
    2454             : 
    2455             :     // #i44334#, #i44681# - direct manipulation of the
    2456             :     // tranformation structure isn't valid, if it contains rotation.
    2457           0 :     SvxShape* pSvxShape = GetSvxShape();
    2458             :     OSL_ENSURE( pSvxShape,
    2459             :             "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SvxShape found!");
    2460           0 :     if ( pSvxShape )
    2461             :     {
    2462           0 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2463             :         OSL_ENSURE( pObj,
    2464             :                 "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SdrObject found!");
    2465           0 :         if ( pObj )
    2466             :         {
    2467             :             // get position of object in Writer coordinate system.
    2468           0 :             awt::Point aPos( getPosition() );
    2469             :             // get position of object in Drawing layer coordinate system
    2470           0 :             const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
    2471             :             const awt::Point aObjPos(
    2472           0 :                     convertTwipToMm100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
    2473           0 :                     convertTwipToMm100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
    2474             :             // determine difference between these positions according to the
    2475             :             // Writer coordinate system
    2476           0 :             const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
    2477           0 :                                              aPos.Y - aObjPos.Y );
    2478             :             // apply translation difference to transformation matrix.
    2479           0 :             if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
    2480             :             {
    2481             :                 // #i73079# - use correct matrix type
    2482           0 :                 ::basegfx::B2DHomMatrix aTempMatrix;
    2483             : 
    2484           0 :                 aTempMatrix.set(0, 0, aMatrix.Line1.Column1 );
    2485           0 :                 aTempMatrix.set(0, 1, aMatrix.Line1.Column2 );
    2486           0 :                 aTempMatrix.set(0, 2, aMatrix.Line1.Column3 );
    2487           0 :                 aTempMatrix.set(1, 0, aMatrix.Line2.Column1 );
    2488           0 :                 aTempMatrix.set(1, 1, aMatrix.Line2.Column2 );
    2489           0 :                 aTempMatrix.set(1, 2, aMatrix.Line2.Column3 );
    2490           0 :                 aTempMatrix.set(2, 0, aMatrix.Line3.Column1 );
    2491           0 :                 aTempMatrix.set(2, 1, aMatrix.Line3.Column2 );
    2492           0 :                 aTempMatrix.set(2, 2, aMatrix.Line3.Column3 );
    2493             :                 // #i73079#
    2494           0 :                 aTempMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
    2495           0 :                 aMatrix.Line1.Column1 = aTempMatrix.get(0, 0);
    2496           0 :                 aMatrix.Line1.Column2 = aTempMatrix.get(0, 1);
    2497           0 :                 aMatrix.Line1.Column3 = aTempMatrix.get(0, 2);
    2498           0 :                 aMatrix.Line2.Column1 = aTempMatrix.get(1, 0);
    2499           0 :                 aMatrix.Line2.Column2 = aTempMatrix.get(1, 1);
    2500           0 :                 aMatrix.Line2.Column3 = aTempMatrix.get(1, 2);
    2501           0 :                 aMatrix.Line3.Column1 = aTempMatrix.get(2, 0);
    2502           0 :                 aMatrix.Line3.Column2 = aTempMatrix.get(2, 1);
    2503           0 :                 aMatrix.Line3.Column3 = aTempMatrix.get(2, 2);
    2504             :             }
    2505             :         }
    2506             :     }
    2507             : 
    2508           0 :     return aMatrix;
    2509             : }
    2510             : 
    2511             : /** method to adjust the positioning properties
    2512             :     #i31698#
    2513             : */
    2514           0 : 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           0 :                             text::TextContentAnchorType_AT_PARAGRAPH;
    2521             :     {
    2522           0 :         OUString sAnchorType( "AnchorType" );
    2523           0 :         uno::Any aAny = getPropertyValue( sAnchorType );
    2524           0 :         aAny >>= eTextAnchorType;
    2525             :     }
    2526           0 :     if ( eTextAnchorType != text::TextContentAnchorType_AS_CHARACTER )
    2527             :     {
    2528             :         // determine current x-position
    2529           0 :         OUString aHoriPosPropStr("HoriOrientPosition");
    2530           0 :         uno::Any aHoriPos( getPropertyValue( aHoriPosPropStr ) );
    2531           0 :         sal_Int32 dCurrX = 0;
    2532           0 :         aHoriPos >>= dCurrX;
    2533             :         // change x-position attribute, if needed
    2534           0 :         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           0 :             OUString aHoriOrientPropStr("HoriOrient");
    2539           0 :             uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) );
    2540             :             sal_Int16 eHoriOrient;
    2541           0 :             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           0 :             aHoriPos <<= _aPosition.X;
    2552           0 :             setPropertyValue( aHoriPosPropStr, aHoriPos );
    2553           0 :         }
    2554             :     }
    2555             : 
    2556             :     // handle y-position
    2557             :     {
    2558             :         // determine current y-position
    2559           0 :         OUString aVertPosPropStr("VertOrientPosition");
    2560           0 :         uno::Any aVertPos( getPropertyValue( aVertPosPropStr ) );
    2561           0 :         sal_Int32 dCurrY = 0;
    2562           0 :         aVertPos >>= dCurrY;
    2563             :         // change y-position attribute, if needed
    2564           0 :         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           0 :             OUString aVertOrientPropStr("VertOrient");
    2569           0 :             uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) );
    2570             :             sal_Int16 eVertOrient;
    2571           0 :             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           0 :             aVertPos <<= _aPosition.Y;
    2582           0 :             setPropertyValue( aVertPosPropStr, aVertPos );
    2583           0 :         }
    2584             :     }
    2585           0 : }
    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 :                     convertTwipToMm100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
    2612           0 :                     convertTwipToMm100( 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           0 : ::com::sun::star::drawing::PolyPolygonBezierCoords SwXShape::_ConvertPolyPolygonBezierToLayoutDir(
    2630             :                     const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath )
    2631             : {
    2632           0 :     drawing::PolyPolygonBezierCoords aConvertedPath( aPath );
    2633             : 
    2634           0 :     SvxShape* pSvxShape = GetSvxShape();
    2635             :     OSL_ENSURE( pSvxShape,
    2636             :             "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
    2637           0 :     if ( pSvxShape )
    2638             :     {
    2639           0 :         const SdrObject* pObj = pSvxShape->GetSdrObject();
    2640             :         OSL_ENSURE( pObj,
    2641             :                 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
    2642           0 :         if ( pObj )
    2643             :         {
    2644             :             // get position of object in Writer coordinate system.
    2645           0 :             awt::Point aPos( getPosition() );
    2646             :             // get position of object in Drawing layer coordinate system
    2647           0 :             const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
    2648             :             const awt::Point aObjPos(
    2649           0 :                     convertTwipToMm100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
    2650           0 :                     convertTwipToMm100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
    2651             :             // determine difference between these positions according to the
    2652             :             // Writer coordinate system
    2653           0 :             const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
    2654           0 :                                              aPos.Y - aObjPos.Y );
    2655             :             // apply translation difference to PolyPolygonBezier.
    2656           0 :             if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
    2657             :             {
    2658             :                 const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
    2659           0 :                     aTranslateDiff.X, aTranslateDiff.Y));
    2660             : 
    2661           0 :                 const sal_Int32 nOuterSequenceCount(aConvertedPath.Coordinates.getLength());
    2662           0 :                 drawing::PointSequence* pInnerSequence = aConvertedPath.Coordinates.getArray();
    2663           0 :                 for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
    2664             :                 {
    2665           0 :                     const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
    2666           0 :                     awt::Point* pArray = pInnerSequence->getArray();
    2667             : 
    2668           0 :                     for(sal_Int32 b(0); b < nInnerSequenceCount; b++)
    2669             :                     {
    2670           0 :                         basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y);
    2671           0 :                         aNewCoordinatePair *= aMatrix;
    2672           0 :                         pArray->X = basegfx::fround(aNewCoordinatePair.getX());
    2673           0 :                         pArray->Y = basegfx::fround(aNewCoordinatePair.getY());
    2674           0 :                         pArray++;
    2675           0 :                     }
    2676           0 :                 }
    2677             :             }
    2678             :         }
    2679             :     }
    2680             : 
    2681           0 :     return aConvertedPath;
    2682             : }
    2683             : 
    2684           0 : SwXGroupShape::SwXGroupShape(uno::Reference< XInterface > & xShape) :
    2685           0 :         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           0 : }
    2692             : 
    2693           0 : SwXGroupShape::~SwXGroupShape()
    2694             : {
    2695           0 : }
    2696             : 
    2697           0 : uno::Any SwXGroupShape::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    2698             : {
    2699           0 :     uno::Any aRet;
    2700           0 :     if(rType == ::getCppuType((uno::Reference<XShapes>*)0))
    2701           0 :         aRet <<= uno::Reference<XShapes>(this);
    2702             :     else
    2703           0 :         aRet = SwXShape::queryInterface(rType);
    2704           0 :     return aRet;
    2705             : }
    2706             : 
    2707           0 : void SwXGroupShape::acquire(  ) throw()
    2708             : {
    2709           0 :     SwXShape::acquire();
    2710           0 : }
    2711             : 
    2712           0 : void SwXGroupShape::release(  ) throw()
    2713             : {
    2714           0 :     SwXShape::release();
    2715           0 : }
    2716             : 
    2717           0 : void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException, std::exception)
    2718             : {
    2719           0 :     SolarMutexGuard aGuard;
    2720           0 :     SvxShape* pSvxShape = GetSvxShape();
    2721           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    2722           0 :     if(pSvxShape && pFmt)
    2723             :     {
    2724           0 :         uno::Reference<XShapes> xShapes;
    2725           0 :         if( xShapeAgg.is() )
    2726             :         {
    2727           0 :             const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
    2728           0 :             uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2729           0 :             aAgg >>= xShapes;
    2730             :         }
    2731           0 :         if(xShapes.is())
    2732           0 :             xShapes->add(xShape);
    2733             :         else
    2734           0 :             throw uno::RuntimeException();
    2735             : 
    2736           0 :         uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY);
    2737           0 :         SwXShape* pSwShape = 0;
    2738           0 :         if(xShape.is())
    2739             :             pSwShape = reinterpret_cast< SwXShape * >(
    2740           0 :                     sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
    2741           0 :         if(pSwShape && pSwShape->m_bDescriptor)
    2742             :         {
    2743             :             SvxShape* pAddShape = reinterpret_cast< SvxShape * >(
    2744           0 :                     sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    2745           0 :             if(pAddShape)
    2746             :             {
    2747           0 :                 SdrObject* pObj = pAddShape->GetSdrObject();
    2748           0 :                 if(pObj)
    2749             :                 {
    2750           0 :                     SwDoc* pDoc = pFmt->GetDoc();
    2751             :                     // set layer of new drawing
    2752             :                     // object to corresponding invisible layer.
    2753           0 :                     if( FmFormInventor != pObj->GetObjInventor())
    2754             :                     {
    2755           0 :                         pObj->SetLayer( pSwShape->pImpl->GetOpaque()
    2756           0 :                                         ? pDoc->GetInvisibleHeavenId()
    2757           0 :                                         : pDoc->GetInvisibleHellId() );
    2758             :                     }
    2759             :                     else
    2760             :                     {
    2761           0 :                         pObj->SetLayer(pDoc->GetInvisibleControlsId());
    2762             :                     }
    2763             :                 }
    2764             :             }
    2765           0 :             pSwShape->m_bDescriptor = sal_False;
    2766             :             //add the group member to the format of the group
    2767           0 :             SwFrmFmt* pShapeFmt = ::FindFrmFmt( pSvxShape->GetSdrObject() );
    2768           0 :             if(pShapeFmt)
    2769           0 :                 pFmt->Add(pSwShape);
    2770           0 :         }
    2771             :     }
    2772             :     else
    2773           0 :         throw uno::RuntimeException();
    2774           0 : }
    2775             : 
    2776           0 : void SwXGroupShape::remove( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException, std::exception)
    2777             : {
    2778           0 :     SolarMutexGuard aGuard;
    2779           0 :     uno::Reference<XShapes> xShapes;
    2780           0 :     if( xShapeAgg.is() )
    2781             :     {
    2782           0 :         const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
    2783           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2784           0 :         aAgg >>= xShapes;
    2785             :     }
    2786           0 :     if(!xShapes.is())
    2787           0 :         throw uno::RuntimeException();
    2788           0 :     xShapes->remove(xShape);
    2789           0 : }
    2790             : 
    2791           0 : sal_Int32 SwXGroupShape::getCount(void) throw( uno::RuntimeException, std::exception )
    2792             : {
    2793           0 :     SolarMutexGuard aGuard;
    2794           0 :     uno::Reference<XIndexAccess> xAcc;
    2795           0 :     if( xShapeAgg.is() )
    2796             :     {
    2797           0 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2798           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2799           0 :         aAgg >>= xAcc;
    2800             :     }
    2801           0 :     if(!xAcc.is())
    2802           0 :         throw uno::RuntimeException();
    2803           0 :     return xAcc->getCount();
    2804             : }
    2805             : 
    2806           0 : uno::Any SwXGroupShape::getByIndex(sal_Int32 nIndex)
    2807             :         throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
    2808             :                uno::RuntimeException, std::exception )
    2809             : {
    2810           0 :     SolarMutexGuard aGuard;
    2811           0 :     uno::Reference<XIndexAccess> xAcc;
    2812           0 :     if( xShapeAgg.is() )
    2813             :     {
    2814           0 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2815           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2816           0 :         aAgg >>= xAcc;
    2817             :     }
    2818           0 :     if(!xAcc.is())
    2819           0 :         throw uno::RuntimeException();
    2820           0 :     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           0 : sal_Bool SwXGroupShape::hasElements(  ) throw(uno::RuntimeException, std::exception)
    2839             : {
    2840           0 :     SolarMutexGuard aGuard;
    2841           0 :     uno::Reference<XIndexAccess> xAcc;
    2842           0 :     if( xShapeAgg.is() )
    2843             :     {
    2844           0 :         const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
    2845           0 :         uno::Any aAgg = xShapeAgg->queryAggregation( rType );
    2846           0 :         aAgg >>= xAcc;
    2847             :     }
    2848           0 :     if(!xAcc.is())
    2849           0 :         throw uno::RuntimeException();
    2850           0 :     return xAcc->hasElements();
    2851             : }
    2852             : 
    2853             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10