LCOV - code coverage report
Current view: top level - libreoffice/svx/source/unodraw - unoshap2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 460 829 55.5 %
Date: 2012-12-27 Functions: 84 126 66.7 %
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 <com/sun/star/lang/DisposedException.hpp>
      21             : #include <com/sun/star/awt/FontSlant.hpp>
      22             : #include <com/sun/star/style/VerticalAlignment.hpp>
      23             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      24             : #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
      25             : #include <com/sun/star/awt/TextAlign.hpp>
      26             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      27             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      28             : #include <com/sun/star/drawing/PointSequence.hpp>
      29             : #include <com/sun/star/graphic/XGraphic.hpp>
      30             : #include <tools/urlobj.hxx>
      31             : #include <unotools/localfilehelper.hxx>
      32             : #include <vcl/svapp.hxx>
      33             : #include <osl/mutex.hxx>
      34             : #include <svtools/fltcall.hxx>
      35             : #include <svtools/filter.hxx>
      36             : 
      37             : #include <boost/scoped_ptr.hpp>
      38             : #include <svx/svdpool.hxx>
      39             : 
      40             : #include <editeng/unoprnms.hxx>
      41             : #include <svx/unoshape.hxx>
      42             : #include <svx/unopage.hxx>
      43             : #include <svx/svdobj.hxx>
      44             : #include <svx/svdpage.hxx>
      45             : #include <svx/svdmodel.hxx>
      46             : #include <svx/svdouno.hxx>
      47             : #include "shapeimpl.hxx"
      48             : #include "svx/unoshprp.hxx"
      49             : #include <svx/svdoashp.hxx>
      50             : 
      51             : // #i29181#
      52             : #include "svx/svdviter.hxx"
      53             : #include <svx/svdview.hxx>
      54             : #include <basegfx/matrix/b2dhommatrix.hxx>
      55             : #include <basegfx/polygon/b2dpolygon.hxx>
      56             : #include <basegfx/point/b2dpoint.hxx>
      57             : #include <basegfx/polygon/b2dpolygontools.hxx>
      58             : #include <basegfx/tools/unotools.hxx>
      59             : 
      60             : #include <comphelper/servicehelper.hxx>
      61             : #include <svtools/wmf.hxx>
      62             : 
      63             : using ::rtl::OUString;
      64             : using namespace ::osl;
      65             : using namespace ::cppu;
      66             : using namespace ::com::sun::star;
      67             : using namespace ::com::sun::star::uno;
      68             : using namespace ::com::sun::star::lang;
      69             : using namespace ::com::sun::star::container;
      70             : 
      71             : #define QUERYINT( xint ) \
      72             :     if( rType == ::getCppuType((const Reference< xint >*)0) ) \
      73             :         aAny <<= Reference< xint >(this)
      74             : 
      75             : /***********************************************************************
      76             : * class SvxShapeGroup                                                  *
      77             : ***********************************************************************/
      78             : 
      79        2146 : SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage  )  throw() :
      80        6438 :     SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_GROUP), getSvxMapProvider().GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ),
      81        6438 :     mxPage( pDrawPage )
      82             : {
      83        2146 : }
      84             : 
      85             : //----------------------------------------------------------------------
      86        4292 : SvxShapeGroup::~SvxShapeGroup() throw()
      87             : {
      88        4292 : }
      89             : 
      90             : //----------------------------------------------------------------------
      91        1241 : void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
      92             : {
      93        1241 :     SvxShape::Create( pNewObj, pNewPage );
      94        1241 :     mxPage = pNewPage;
      95        1241 : }
      96             : 
      97             : //----------------------------------------------------------------------
      98       16839 : uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType )
      99             :     throw(uno::RuntimeException)
     100             : {
     101       16839 :     return SvxShape::queryInterface( rType );
     102             : }
     103             : 
     104       16942 : uno::Any SAL_CALL SvxShapeGroup::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
     105             : {
     106       16942 :     uno::Any aAny;
     107             : 
     108       16942 :     QUERYINT( drawing::XShapeGroup );
     109       15507 :     else QUERYINT( drawing::XShapes );
     110       12787 :     else QUERYINT( container::XIndexAccess );
     111       12772 :     else QUERYINT( container::XElementAccess );
     112             :     else
     113       12772 :         return SvxShape::queryAggregation( rType );
     114             : 
     115        4170 :     return aAny;
     116             : }
     117             : 
     118       46546 : void SAL_CALL SvxShapeGroup::acquire() throw ( )
     119             : {
     120       46546 :     SvxShape::acquire();
     121       46546 : }
     122             : 
     123       46546 : void SAL_CALL SvxShapeGroup::release() throw ( )
     124             : {
     125       46546 :     SvxShape::release();
     126       46546 : }
     127             : 
     128           0 : uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes()
     129             :     throw (uno::RuntimeException)
     130             : {
     131           0 :     return SvxShape::getTypes();
     132             : }
     133             : 
     134             : namespace
     135             : {
     136             :     class theSvxShapeGroupImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxShapeGroupImplementationId > {};
     137             : }
     138             : 
     139           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxShapeGroup::getImplementationId()
     140             :     throw (uno::RuntimeException)
     141             : {
     142           0 :     return theSvxShapeGroupImplementationId::get().getSeq();
     143             : }
     144             : 
     145             : // ::com::sun::star::drawing::XShape
     146             : 
     147             : //----------------------------------------------------------------------
     148        2487 : OUString SAL_CALL SvxShapeGroup::getShapeType()
     149             :     throw( uno::RuntimeException )
     150             : {
     151        2487 :     return SvxShape::getShapeType();
     152             : }
     153             : 
     154             : //------------------------------------------------------------------1----
     155        1329 : awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException)
     156             : {
     157        1329 :     return SvxShape::getPosition();
     158             : }
     159             : 
     160             : //----------------------------------------------------------------------
     161        1414 : void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
     162             : {
     163        1414 :     SvxShape::setPosition(Position);
     164        1414 : }
     165             : 
     166             : //----------------------------------------------------------------------
     167             : 
     168        1378 : awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException)
     169             : {
     170        1378 :     return SvxShape::getSize();
     171             : }
     172             : 
     173             : //----------------------------------------------------------------------
     174        2313 : void SAL_CALL SvxShapeGroup::setSize( const awt::Size& rSize )
     175             :     throw(beans::PropertyVetoException, uno::RuntimeException)
     176             : {
     177        2313 :     SvxShape::setSize( rSize );
     178        2313 : }
     179             : 
     180             : // drawing::XShapeGroup
     181             : 
     182             : //----------------------------------------------------------------------
     183           0 : void SAL_CALL SvxShapeGroup::enterGroup(  ) throw(uno::RuntimeException)
     184             : {
     185             :     // Todo
     186             : //  pDrView->EnterMarkedGroup();
     187           0 : }
     188             : 
     189             : //----------------------------------------------------------------------
     190           0 : void SAL_CALL SvxShapeGroup::leaveGroup(  ) throw(uno::RuntimeException)
     191             : {
     192             :     // Todo
     193             : //  pDrView->LeaveOneGroup();
     194           0 : }
     195             : 
     196             : //----------------------------------------------------------------------
     197             : 
     198             : // XShapes
     199        3301 : void SAL_CALL SvxShapeGroup::add( const uno::Reference< drawing::XShape >& xShape )
     200             :     throw( uno::RuntimeException )
     201             : {
     202        3301 :     ::SolarMutexGuard aGuard;
     203             : 
     204        3301 :     SvxShape* pShape = SvxShape::getImplementation( xShape );
     205             : 
     206        3301 :     if( mpObj.is()&& mxPage.is() && pShape )
     207             :     {
     208        3301 :         SdrObject* pSdrShape = pShape->GetSdrObject();
     209        3301 :         if( pSdrShape == NULL )
     210        3301 :             pSdrShape = mxPage->_CreateSdrObject( xShape );
     211             : 
     212        3301 :         if( pSdrShape->IsInserted() )
     213           0 :             pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
     214             : 
     215        3301 :         mpObj->GetSubList()->InsertObject( pSdrShape );
     216        3301 :         pSdrShape->SetModel(mpObj->GetModel());
     217             : 
     218             :         // #85922# It makes no sense to set the layer asked
     219             :         // from the group object since these is an iteration
     220             :         // over the contained objects. In consequence, this
     221             :         // statement erases all layer information from the draw
     222             :         // objects. Layers need to be set at draw objects directly
     223             :         // and have nothing to do with grouping at all.
     224             :         // pSdrShape->SetLayer(pObject->GetLayer());
     225             : 
     226             :         // Establish connection between new SdrObject and its wrapper before
     227             :         // inserting the new shape into the group.  There a new wrapper
     228             :         // would be created when this connection would not already exist.
     229        3301 :         pShape->Create( pSdrShape, mxPage.get() );
     230             : 
     231        3301 :         if( mpModel )
     232        3301 :             mpModel->SetChanged();
     233             :     }
     234             :     else
     235             :     {
     236             :         OSL_FAIL("could not add XShape to group shape!");
     237        3301 :     }
     238        3301 : }
     239             : 
     240             : //----------------------------------------------------------------------
     241         533 : void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xShape )
     242             :     throw( uno::RuntimeException )
     243             : {
     244         533 :     ::SolarMutexGuard aGuard;
     245             : 
     246         533 :     SdrObject* pSdrShape = NULL;
     247         533 :     SvxShape* pShape = SvxShape::getImplementation( xShape );
     248             : 
     249         533 :     if( pShape )
     250         533 :         pSdrShape = pShape->GetSdrObject();
     251             : 
     252         533 :     if( !mpObj.is() || pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
     253           0 :         throw uno::RuntimeException();
     254             : 
     255         533 :     SdrObjList& rList = *pSdrShape->GetObjList();
     256             : 
     257         533 :     const sal_uInt32 nObjCount = rList.GetObjCount();
     258         533 :     sal_uInt32 nObjNum = 0;
     259        1476 :     while( nObjNum < nObjCount )
     260             :     {
     261         943 :         if(rList.GetObj( nObjNum ) == pSdrShape )
     262         533 :             break;
     263         410 :         nObjNum++;
     264             :     }
     265             : 
     266         533 :     if( nObjNum < nObjCount )
     267             :     {
     268             :         // #i29181#
     269             :         // If the SdrObject which is about to be deleted is in any selection,
     270             :         // deselect it first.
     271         533 :         SdrViewIter aIter( pSdrShape );
     272             : 
     273         533 :         for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
     274             :         {
     275           0 :             if(CONTAINER_ENTRY_NOTFOUND != pView->TryToFindMarkedObject(pSdrShape))
     276             :             {
     277           0 :                 pView->MarkObj(pSdrShape, pView->GetSdrPageView(), sal_True, sal_False);
     278             :             }
     279             :         }
     280             : 
     281         533 :         SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
     282         533 :         SdrObject::Free( pObject );
     283             :     }
     284             :     else
     285             :     {
     286             :         DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
     287             :     }
     288             : 
     289         533 :     if( mpModel )
     290         533 :         mpModel->SetChanged();
     291         533 : }
     292             : 
     293             : // XIndexAccess
     294             : 
     295             : //----------------------------------------------------------------------
     296        2464 : sal_Int32 SAL_CALL SvxShapeGroup::getCount() throw( uno::RuntimeException )
     297             : {
     298        2464 :     ::SolarMutexGuard aGuard;
     299             : 
     300        2464 :     sal_Int32 nRetval = 0;
     301             : 
     302        2464 :     if(mpObj.is() && mpObj->GetSubList())
     303        2464 :         nRetval = mpObj->GetSubList()->GetObjCount();
     304             :     else
     305           0 :         throw uno::RuntimeException();
     306             : 
     307        4928 :     return nRetval;
     308             : }
     309             : 
     310             : //----------------------------------------------------------------------
     311        2960 : uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
     312             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
     313             : {
     314        2960 :     ::SolarMutexGuard aGuard;
     315             : 
     316        2960 :     if( !mpObj.is() || mpObj->GetSubList() == NULL )
     317           0 :         throw uno::RuntimeException();
     318             : 
     319        2960 :     if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index )
     320           0 :         throw lang::IndexOutOfBoundsException();
     321             : 
     322        2960 :     SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
     323             : 
     324        2960 :     if(pDestObj == NULL)
     325           0 :         throw lang::IndexOutOfBoundsException();
     326             : 
     327        2960 :     Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY );
     328        2960 :     return uno::makeAny( xShape );
     329             : }
     330             : 
     331             : // ::com::sun::star::container::XElementAccess
     332             : 
     333             : //----------------------------------------------------------------------
     334           0 : uno::Type SAL_CALL SvxShapeGroup::getElementType() throw( uno::RuntimeException )
     335             : {
     336           0 :     return ::getCppuType(( const Reference< drawing::XShape >*)0);
     337             : }
     338             : 
     339             : //----------------------------------------------------------------------
     340           5 : sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException )
     341             : {
     342           5 :     ::SolarMutexGuard aGuard;
     343             : 
     344           5 :     return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
     345             : }
     346             : 
     347             : //----------------------------------------------------------------------
     348             : // ::com::sun::star::lang::XServiceInfo
     349             : 
     350           3 : uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
     351             :     throw(uno::RuntimeException)
     352             : {
     353           3 :     return SvxShape::getSupportedServiceNames();
     354             : }
     355             : 
     356             : /***********************************************************************
     357             : *                                                                      *
     358             : ***********************************************************************/
     359             : 
     360           4 : SvxShapeConnector::SvxShapeConnector( SdrObject* pObj )  throw() :
     361           4 :     SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
     362             : {
     363           4 : }
     364             : 
     365             : //----------------------------------------------------------------------
     366           8 : SvxShapeConnector::~SvxShapeConnector() throw()
     367             : {
     368           8 : }
     369             : 
     370             : //----------------------------------------------------------------------
     371             : 
     372          16 : uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType )
     373             :     throw(uno::RuntimeException)
     374             : {
     375          16 :     return SvxShapeText::queryInterface( rType );
     376             : }
     377             : 
     378          16 : uno::Any SAL_CALL SvxShapeConnector::queryAggregation( const uno::Type & rType )
     379             :     throw(uno::RuntimeException)
     380             : {
     381          16 :     uno::Any aAny;
     382             : 
     383          16 :     QUERYINT( drawing::XConnectorShape );
     384             :     else
     385          16 :         return SvxShapeText::queryAggregation( rType );
     386             : 
     387          16 :     return aAny;
     388             : }
     389             : 
     390          48 : void SAL_CALL SvxShapeConnector::acquire() throw ( )
     391             : {
     392          48 :     SvxShapeText::acquire();
     393          48 : }
     394             : 
     395          48 : void SAL_CALL SvxShapeConnector::release() throw ( )
     396             : {
     397          48 :     SvxShapeText::release();
     398          48 : }
     399             : // XTypeProvider
     400             : 
     401           0 : uno::Sequence< uno::Type > SAL_CALL SvxShapeConnector::getTypes()
     402             :     throw (uno::RuntimeException)
     403             : {
     404           0 :     return SvxShape::getTypes();
     405             : }
     406             : 
     407             : namespace
     408             : {
     409             :     class theSvxShapeConnectorImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxShapeConnectorImplementationId > {};
     410             : }
     411             : 
     412           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxShapeConnector::getImplementationId()
     413             :     throw (uno::RuntimeException)
     414             : {
     415           0 :     return theSvxShapeConnectorImplementationId::get().getSeq();
     416             : }
     417             : 
     418             : // ::com::sun::star::drawing::XShape
     419             : 
     420             : //----------------------------------------------------------------------
     421           0 : OUString SAL_CALL SvxShapeConnector::getShapeType()
     422             :     throw( uno::RuntimeException )
     423             : {
     424           0 :     return SvxShapeText::getShapeType();
     425             : }
     426             : 
     427             : //------------------------------------------------------------------1----
     428           0 : awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException)
     429             : {
     430           0 :     return SvxShapeText::getPosition();
     431             : }
     432             : 
     433             : //----------------------------------------------------------------------
     434           0 : void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
     435             : {
     436           0 :     SvxShapeText::setPosition(Position);
     437           0 : }
     438             : 
     439             : //----------------------------------------------------------------------
     440             : 
     441           0 : awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException)
     442             : {
     443           0 :     return SvxShapeText::getSize();
     444             : }
     445             : 
     446             : //----------------------------------------------------------------------
     447           0 : void SAL_CALL SvxShapeConnector::setSize( const awt::Size& rSize )
     448             :     throw(beans::PropertyVetoException, uno::RuntimeException)
     449             : {
     450           0 :     SvxShapeText::setSize( rSize );
     451           0 : }
     452             : 
     453             : //----------------------------------------------------------------------
     454             : 
     455             : // XConnectorShape
     456             : 
     457           0 : void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType ) throw( uno::RuntimeException )
     458             : {
     459           0 :     ::SolarMutexGuard aGuard;
     460             : 
     461           0 :     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
     462           0 :     SvxShape* pShape = SvxShape::getImplementation( xRef );
     463             : 
     464           0 :     if( pShape )
     465           0 :         mpObj->ConnectToNode( sal_True, pShape->mpObj.get() );
     466             : 
     467           0 :     if( mpModel )
     468           0 :         mpModel->SetChanged();
     469           0 : }
     470             : 
     471             : //----------------------------------------------------------------------
     472           0 : void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType  )
     473             :     throw( uno::RuntimeException )
     474             : {
     475           0 :     ::SolarMutexGuard aGuard;
     476             : 
     477           0 :     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
     478           0 :     SvxShape* pShape = SvxShape::getImplementation( xRef );
     479             : 
     480           0 :     if( mpObj.is() && pShape )
     481           0 :         mpObj->ConnectToNode( sal_False, pShape->mpObj.get() );
     482             : 
     483           0 :     if( mpModel )
     484           0 :         mpModel->SetChanged();
     485           0 : }
     486             : 
     487             : //----------------------------------------------------------------------
     488           0 : void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing::XConnectableShape >&  )
     489             :     throw( uno::RuntimeException )
     490             : {
     491           0 :     ::SolarMutexGuard aGuard;
     492             : 
     493           0 :     if(mpObj.is())
     494           0 :         mpObj->DisconnectFromNode( sal_True );
     495             : 
     496           0 :     if( mpModel )
     497           0 :         mpModel->SetChanged();
     498           0 : }
     499             : 
     500             : //----------------------------------------------------------------------
     501           0 : void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::XConnectableShape >& )
     502             :     throw( uno::RuntimeException )
     503             : {
     504           0 :     ::SolarMutexGuard aGuard;
     505             : 
     506           0 :     if(mpObj.is())
     507           0 :         mpObj->DisconnectFromNode( sal_False );
     508             : 
     509           0 :     if( mpModel )
     510           0 :         mpModel->SetChanged();
     511           0 : }
     512             : 
     513             : //----------------------------------------------------------------------
     514             : // ::com::sun::star::lang::XServiceInfo
     515             : //----------------------------------------------------------------------
     516           0 : uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException )
     517             : {
     518           0 :     return SvxShapeText::getSupportedServiceNames();
     519             : }
     520             : 
     521             : /***********************************************************************
     522             : * class SvxShapeControl                                                *
     523             : ***********************************************************************/
     524             : DBG_NAME(SvxShapeControl)
     525             : 
     526          10 : SvxShapeControl::SvxShapeControl( SdrObject* pObj )  throw() :
     527          10 :     SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONTROL), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) )
     528             : {
     529             :     DBG_CTOR(SvxShapeControl,NULL);
     530          10 :     setShapeKind( OBJ_UNO );
     531          10 : }
     532             : 
     533             : //----------------------------------------------------------------------
     534          20 : SvxShapeControl::~SvxShapeControl() throw()
     535             : {
     536             :     DBG_DTOR(SvxShapeControl,NULL);
     537          20 : }
     538             : 
     539             : //----------------------------------------------------------------------
     540         108 : uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType )
     541             :     throw(uno::RuntimeException)
     542             : {
     543         108 :     return SvxShapeText::queryInterface( rType );
     544             : }
     545             : 
     546         107 : uno::Any SAL_CALL SvxShapeControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
     547             : {
     548         107 :     uno::Any aAny;
     549             : 
     550         107 :     QUERYINT( drawing::XControlShape );
     551             :     else
     552          72 :         return SvxShapeText::queryAggregation( rType );
     553             : 
     554         142 :     return aAny;
     555             : }
     556             : 
     557         440 : void SAL_CALL SvxShapeControl::acquire() throw ( )
     558             : {
     559         440 :     SvxShapeText::acquire();
     560         440 : }
     561             : 
     562         440 : void SAL_CALL SvxShapeControl::release() throw ( )
     563             : {
     564         440 :     SvxShapeText::release();
     565         440 : }
     566             : // XTypeProvider
     567             : 
     568           0 : uno::Sequence< uno::Type > SAL_CALL SvxShapeControl::getTypes()
     569             :     throw (uno::RuntimeException)
     570             : {
     571           0 :     return SvxShape::getTypes();
     572             : }
     573             : 
     574             : namespace
     575             : {
     576             :     class theSvxShapeControlImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxShapeControlImplementationId > {};
     577             : }
     578             : 
     579           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxShapeControl::getImplementationId()
     580             :     throw (uno::RuntimeException)
     581             : {
     582           0 :     return theSvxShapeControlImplementationId::get().getSeq();
     583             : }
     584             : 
     585             : // ::com::sun::star::drawing::XShape
     586             : 
     587             : //----------------------------------------------------------------------
     588           0 : OUString SAL_CALL SvxShapeControl::getShapeType()
     589             :     throw( uno::RuntimeException )
     590             : {
     591           0 :     return SvxShapeText::getShapeType();
     592             : }
     593             : 
     594             : //------------------------------------------------------------------1----
     595           0 : awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException)
     596             : {
     597           0 :     return SvxShapeText::getPosition();
     598             : }
     599             : 
     600             : //----------------------------------------------------------------------
     601           2 : void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
     602             : {
     603           2 :     SvxShapeText::setPosition(Position);
     604           2 : }
     605             : 
     606             : //----------------------------------------------------------------------
     607             : 
     608           0 : awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException)
     609             : {
     610           0 :     return SvxShapeText::getSize();
     611             : }
     612             : 
     613             : //----------------------------------------------------------------------
     614           2 : void SAL_CALL SvxShapeControl::setSize( const awt::Size& rSize )
     615             :     throw(beans::PropertyVetoException, uno::RuntimeException)
     616             : {
     617           2 :     SvxShapeText::setSize( rSize );
     618           2 : }
     619             : 
     620             : //----------------------------------------------------------------------
     621             : // XControlShape
     622             : 
     623          24 : Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
     624             :     throw( uno::RuntimeException )
     625             : {
     626          24 :     ::SolarMutexGuard aGuard;
     627             : 
     628          24 :     Reference< awt::XControlModel > xModel;
     629             : 
     630          24 :     SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
     631          24 :     if( pUnoObj )
     632          24 :         xModel = pUnoObj->GetUnoControlModel();
     633             : 
     634          24 :     return xModel;
     635             : }
     636             : 
     637             : //----------------------------------------------------------------------
     638           9 : void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >& xControl )
     639             :     throw( uno::RuntimeException )
     640             : {
     641           9 :     ::SolarMutexGuard aGuard;
     642             : 
     643           9 :     SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
     644           9 :     if( pUnoObj )
     645           9 :         pUnoObj->SetUnoControlModel( xControl );
     646             : 
     647           9 :     if( mpModel )
     648           1 :         mpModel->SetChanged();
     649           9 : }
     650             : 
     651             : // XServiceInfo
     652           0 : uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException )
     653             : {
     654           0 :     return SvxShapeText::getSupportedServiceNames();
     655             : }
     656             : 
     657             : static struct
     658             : {
     659             :     const sal_Char* mpAPIName;
     660             :     sal_uInt16 mnAPINameLen;
     661             : 
     662             :     const sal_Char* mpFormName;
     663             :     sal_uInt16 mnFormNameLen;
     664             : }
     665             : SvxShapeControlPropertyMapping[] =
     666             : {
     667             :     // Warning: The first entry must be FontSlant because the any needs to be converted
     668             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), MAP_CHAR_LEN("FontSlant")  }, //  const sal_Int16 => ::com::sun::star::awt::FontSlant
     669             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), MAP_CHAR_LEN("FontName") },
     670             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), MAP_CHAR_LEN("FontStyleName") },
     671             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), MAP_CHAR_LEN("FontFamily") },
     672             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), MAP_CHAR_LEN("FontCharset") },
     673             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), MAP_CHAR_LEN("FontHeight") },
     674             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), MAP_CHAR_LEN("FontPitch" ) },
     675             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), MAP_CHAR_LEN("FontWeight" ) },
     676             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), MAP_CHAR_LEN("FontUnderline") },
     677             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), MAP_CHAR_LEN("FontStrikeout") },
     678             :     { MAP_CHAR_LEN("CharKerning"), MAP_CHAR_LEN("FontKerning") },
     679             :     { MAP_CHAR_LEN("CharWordMode"), MAP_CHAR_LEN("FontWordLineMode" ) },
     680             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR),   MAP_CHAR_LEN("TextColor") },
     681             :     { MAP_CHAR_LEN("CharRelief"),   MAP_CHAR_LEN("FontRelief") },
     682             :     { MAP_CHAR_LEN("CharUnderlineColor"),   MAP_CHAR_LEN("TextLineColor") },
     683             :     { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), MAP_CHAR_LEN("Align") },
     684             :     { MAP_CHAR_LEN("TextVerticalAdjust"), MAP_CHAR_LEN("VerticalAlign") },
     685             :     { MAP_CHAR_LEN("ControlBackground"), MAP_CHAR_LEN("BackgroundColor") },
     686             :     { MAP_CHAR_LEN("ControlSymbolColor"), MAP_CHAR_LEN("SymbolColor") },
     687             :     { MAP_CHAR_LEN("ControlBorder"), MAP_CHAR_LEN("Border") },
     688             :     { MAP_CHAR_LEN("ControlBorderColor"), MAP_CHAR_LEN("BorderColor") },
     689             :     { MAP_CHAR_LEN("ControlTextEmphasis"),  MAP_CHAR_LEN("FontEmphasisMark") },
     690             :     { MAP_CHAR_LEN("ImageScaleMode"),  MAP_CHAR_LEN("ScaleMode") },
     691             :     { MAP_CHAR_LEN("ControlWritingMode"), MAP_CHAR_LEN("WritingMode") },
     692             :     { NULL,0, NULL, 0 }
     693             : };
     694             : 
     695             : namespace
     696             : {
     697           0 :     static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
     698             :     {
     699           0 :         sal_uInt16 i = 0;
     700           0 :         while( SvxShapeControlPropertyMapping[i].mpAPIName )
     701             :         {
     702           0 :             if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 )
     703             :             {
     704           0 :                 rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US );
     705             :             }
     706           0 :             ++i;
     707             :         }
     708           0 :         return !rInternalName.isEmpty();
     709             :     }
     710             : 
     711             :     struct EnumConversionMap
     712             :     {
     713             :         sal_Int16   nAPIValue;
     714             :         sal_Int16   nFormValue;
     715             :     };
     716             : 
     717             :     EnumConversionMap aMapAdjustToAlign[] =
     718             :     {
     719             :         // note that order matters:
     720             :         // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
     721             :         // and use the first matching entry
     722             :         {style::ParagraphAdjust_LEFT,           (sal_Int16)awt::TextAlign::LEFT},
     723             :         {style::ParagraphAdjust_CENTER,         (sal_Int16)awt::TextAlign::CENTER},
     724             :         {style::ParagraphAdjust_RIGHT,          (sal_Int16)awt::TextAlign::RIGHT},
     725             :         {style::ParagraphAdjust_BLOCK,          (sal_Int16)awt::TextAlign::RIGHT},
     726             :         {style::ParagraphAdjust_STRETCH,        (sal_Int16)awt::TextAlign::LEFT},
     727             :         {-1,-1}
     728             :     };
     729             : 
     730           0 :     static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap )
     731             :     {
     732           0 :         sal_Int16 nValue = sal_Int16();
     733           0 :         OSL_VERIFY( _rValue >>= nValue );
     734             : 
     735           0 :         const EnumConversionMap* pEntry = _pMap;
     736           0 :         while ( pEntry && ( pEntry->nFormValue != -1 ) )
     737             :         {
     738           0 :             if ( nValue == pEntry->nFormValue )
     739             :             {
     740           0 :                 _rValue <<= pEntry->nAPIValue;
     741           0 :                 return;
     742             :             }
     743           0 :             ++pEntry;
     744             :         }
     745             :     }
     746             : 
     747           0 :     static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap )
     748             :     {
     749           0 :         sal_Int32 nValue = 0;
     750           0 :         OSL_VERIFY( _rValue >>= nValue );
     751             : 
     752           0 :         const EnumConversionMap* pEntry = _pMap;
     753           0 :         while ( pEntry && ( pEntry->nAPIValue != -1 ) )
     754             :         {
     755           0 :             if ( nValue == pEntry->nAPIValue )
     756             :             {
     757           0 :                 _rValue <<= pEntry->nFormValue;
     758           0 :                 return;
     759             :             }
     760           0 :             ++pEntry;
     761             :         }
     762             :     }
     763             : 
     764           0 :     static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue )
     765             :     {
     766           0 :         lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign );
     767           0 :     }
     768             : 
     769           0 :     static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue )
     770             :     {
     771           0 :         lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign );
     772           0 :     }
     773             : 
     774           0 :     void convertVerticalAdjustToVerticalAlign( Any& _rValue ) SAL_THROW( ( lang::IllegalArgumentException ) )
     775             :     {
     776           0 :         if ( !_rValue.hasValue() )
     777           0 :             return;
     778             : 
     779           0 :         drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
     780           0 :         style::VerticalAlignment    eAlign  = style::VerticalAlignment_TOP;
     781           0 :         if ( !( _rValue >>= eAdjust ) )
     782           0 :             throw lang::IllegalArgumentException();
     783           0 :         switch ( eAdjust )
     784             :         {
     785           0 :         case drawing::TextVerticalAdjust_TOP:    eAlign = style::VerticalAlignment_TOP; break;
     786           0 :         case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break;
     787           0 :         default:                                 eAlign = style::VerticalAlignment_MIDDLE; break;
     788             :         }
     789           0 :         _rValue <<= eAlign;
     790             :     }
     791             : 
     792           0 :     void convertVerticalAlignToVerticalAdjust( Any& _rValue )
     793             :     {
     794           0 :         if ( !_rValue.hasValue() )
     795           0 :             return;
     796           0 :         style::VerticalAlignment    eAlign  = style::VerticalAlignment_TOP;
     797           0 :         drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
     798           0 :         OSL_VERIFY( _rValue >>= eAlign );
     799           0 :         switch ( eAlign )
     800             :         {
     801           0 :         case style::VerticalAlignment_TOP:    eAdjust = drawing::TextVerticalAdjust_TOP; break;
     802           0 :         case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break;
     803           0 :         default:                              eAdjust = drawing::TextVerticalAdjust_CENTER; break;
     804             :         }
     805           0 :         _rValue <<= eAdjust;
     806             :     }
     807             : }
     808             : 
     809           0 : void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
     810             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
     811             : {
     812           0 :     OUString aFormsName;
     813           0 :     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
     814             :     {
     815           0 :         uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
     816           0 :         if( xControl.is() )
     817             :         {
     818           0 :             uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
     819           0 :             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
     820             :             {
     821           0 :                 uno::Any aConvertedValue( aValue );
     822           0 :                 if ( aFormsName == "FontSlant" )
     823             :                 {
     824             :                     awt::FontSlant nSlant;
     825           0 :                     if( !(aValue >>= nSlant ) )
     826           0 :                         throw lang::IllegalArgumentException();
     827           0 :                     aConvertedValue <<= (sal_Int16)nSlant;
     828             :                 }
     829           0 :                 else if ( aFormsName == "Align" )
     830             :                 {
     831           0 :                     lcl_convertParaAdjustmentToTextAlignment( aConvertedValue );
     832             :                 }
     833           0 :                 else if ( aFormsName == "VerticalAlign" )
     834             :                 {
     835           0 :                     convertVerticalAdjustToVerticalAlign( aConvertedValue );
     836             :                 }
     837             : 
     838           0 :                 xControl->setPropertyValue( aFormsName, aConvertedValue );
     839           0 :             }
     840           0 :         }
     841             :     }
     842             :     else
     843             :     {
     844           0 :         SvxShape::setPropertyValue( aPropertyName, aValue );
     845           0 :     }
     846           0 : }
     847             : 
     848           0 : uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName )
     849             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     850             : {
     851           0 :     OUString aFormsName;
     852           0 :     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
     853             :     {
     854           0 :         uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
     855             : 
     856           0 :         uno::Any aValue;
     857           0 :         if( xControl.is() )
     858             :         {
     859           0 :             uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
     860           0 :             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
     861             :             {
     862           0 :                 aValue = xControl->getPropertyValue( aFormsName );
     863           0 :                 if ( aFormsName == "FontSlant" )
     864             :                 {
     865           0 :                     awt::FontSlant eSlant = awt::FontSlant_NONE;
     866           0 :                     sal_Int16 nSlant = sal_Int16();
     867           0 :                     if ( aValue >>= nSlant )
     868             :                     {
     869           0 :                         eSlant = (awt::FontSlant)nSlant;
     870             :                     }
     871             :                     else
     872             :                     {
     873           0 :                         OSL_VERIFY( aValue >>= eSlant );
     874             :                     }
     875           0 :                     aValue <<= eSlant;
     876             :                 }
     877           0 :                 else if ( aFormsName == "Align" )
     878             :                 {
     879           0 :                     lcl_convertTextAlignmentToParaAdjustment( aValue );
     880             :                 }
     881           0 :                 else if ( aFormsName == "VerticalAlign" )
     882             :                 {
     883           0 :                     convertVerticalAlignToVerticalAdjust( aValue );
     884             :                 }
     885           0 :             }
     886             :         }
     887             : 
     888           0 :         return aValue;
     889             :     }
     890             :     else
     891             :     {
     892           0 :         return SvxShape::getPropertyValue( aPropertyName );
     893           0 :     }
     894             : 
     895             : }
     896             : 
     897             : // XPropertyState
     898           0 : beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
     899             : {
     900           0 :     OUString aFormsName;
     901           0 :     if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
     902             :     {
     903           0 :         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
     904           0 :         uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
     905             : 
     906           0 :         if( xControl.is() && xPropSet.is() )
     907             :         {
     908           0 :             uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
     909           0 :             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
     910             :             {
     911           0 :                 return xControl->getPropertyState( aFormsName );
     912           0 :             }
     913             :         }
     914             : 
     915           0 :         return beans::PropertyState_DEFAULT_VALUE;
     916             :     }
     917             :     else
     918             :     {
     919           0 :         return SvxShape::getPropertyState( PropertyName );
     920           0 :     }
     921             : }
     922             : 
     923           0 : void SAL_CALL SvxShapeControl::setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
     924             : {
     925           0 :     OUString aFormsName;
     926           0 :     if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
     927             :     {
     928           0 :         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
     929           0 :         uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
     930             : 
     931           0 :         if( xControl.is() && xPropSet.is() )
     932             :         {
     933           0 :             uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
     934           0 :             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
     935             :             {
     936           0 :                 xControl->setPropertyToDefault( aFormsName );
     937           0 :             }
     938           0 :         }
     939             :     }
     940             :     else
     941             :     {
     942           0 :         SvxShape::setPropertyToDefault( PropertyName );
     943           0 :     }
     944           0 : }
     945             : 
     946           0 : uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const ::rtl::OUString& aPropertyName )
     947             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     948             : {
     949           0 :     OUString aFormsName;
     950           0 :     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
     951             :     {
     952           0 :         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
     953             : 
     954           0 :         if( xControl.is() )
     955             :         {
     956           0 :             Any aDefault( xControl->getPropertyDefault( aFormsName ) );
     957           0 :             if ( aFormsName == "FontSlant" )
     958             :             {
     959           0 :                 sal_Int16 nSlant( 0 );
     960           0 :                 aDefault >>= nSlant;
     961           0 :                 aDefault <<= (awt::FontSlant)nSlant;
     962             :             }
     963           0 :             else if ( aFormsName == "Align" )
     964             :             {
     965           0 :                 lcl_convertTextAlignmentToParaAdjustment( aDefault );
     966             :             }
     967           0 :             else if ( aFormsName == "VerticalAlign" )
     968             :             {
     969           0 :                 convertVerticalAlignToVerticalAdjust( aDefault );
     970             :             }
     971           0 :             return aDefault;
     972             :         }
     973             : 
     974           0 :         throw beans::UnknownPropertyException();
     975             :     }
     976             :     else
     977             :     {
     978           0 :         return SvxShape::getPropertyDefault( aPropertyName );
     979           0 :     }
     980             : }
     981             : 
     982             : 
     983             : /***********************************************************************
     984             : * class SvxShapeDimensioning                                           *
     985             : ***********************************************************************/
     986             : 
     987             : //----------------------------------------------------------------------
     988           0 : SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw()
     989           0 : :   SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_DIMENSIONING), getSvxMapProvider().GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) )
     990             : {
     991           0 : }
     992             : 
     993             : //----------------------------------------------------------------------
     994           0 : SvxShapeDimensioning::~SvxShapeDimensioning() throw()
     995             : {
     996           0 : }
     997             : 
     998             : // ::com::sun::star::lang::XServiceInfo
     999           0 : uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException )
    1000             : {
    1001           0 :     return SvxShapeText::getSupportedServiceNames();
    1002             : }
    1003             : 
    1004             : /***********************************************************************
    1005             : *                                                                      *
    1006             : ***********************************************************************/
    1007             : 
    1008             : //----------------------------------------------------------------------
    1009           3 : SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
    1010           3 : :   SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CIRCLE), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
    1011             : {
    1012           3 : }
    1013             : 
    1014             : //----------------------------------------------------------------------
    1015           6 : SvxShapeCircle::~SvxShapeCircle() throw()
    1016             : {
    1017           6 : }
    1018             : 
    1019             : // ::com::sun::star::lang::XServiceInfo
    1020             : // XServiceInfo
    1021           0 : uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException )
    1022             : {
    1023           0 :     return SvxShapeText::getSupportedServiceNames();
    1024             : }
    1025             : 
    1026             : /***********************************************************************
    1027             : *                                                                      *
    1028             : ***********************************************************************/
    1029             : 
    1030             : #include <svx/svdopath.hxx>
    1031             : 
    1032             : //----------------------------------------------------------------------
    1033        1501 : SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
    1034             :  throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
    1035        4503 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
    1036        4503 : , mePolygonKind( eNew )
    1037             : {
    1038        1501 : }
    1039             : 
    1040             : //----------------------------------------------------------------------
    1041        3002 : SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
    1042             : {
    1043        3002 : }
    1044             : 
    1045         750 : basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw()
    1046             : {
    1047         750 :     basegfx::B2DPolyPolygon aRetval;
    1048             : 
    1049             :     // Zeiger auf innere sequences holen
    1050         750 :     const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray();
    1051         750 :     const drawing::PointSequence* pInnerSeqEnd   = pInnerSequence + pOuterSequence->getLength();
    1052             : 
    1053        2648 :     for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence)
    1054             :     {
    1055             :         // Neues Polygon vorbereiten
    1056        1898 :         basegfx::B2DPolygon aNewPolygon;
    1057             : 
    1058             :         // Zeiger auf Arrays holen
    1059        1898 :         const awt::Point* pArray    = pInnerSequence->getConstArray();
    1060        1898 :         const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength();
    1061             : 
    1062        7412 :         for(;pArray != pArrayEnd;++pArray)
    1063             :         {
    1064        5514 :             aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
    1065             :         }
    1066             : 
    1067             :         // check for closed state flag
    1068        1898 :         basegfx::tools::checkClosed(aNewPolygon);
    1069             : 
    1070             :         // Neues Teilpolygon einfuegen
    1071        1898 :         aRetval.append(aNewPolygon);
    1072        1898 :     }
    1073             : 
    1074         750 :     return aRetval;
    1075             : }
    1076             : 
    1077             : //----------------------------------------------------------------------
    1078             : 
    1079       11267 : bool SvxShapePolyPolygon::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1080             : {
    1081       11267 :     switch( pProperty->nWID )
    1082             :     {
    1083             :     case OWN_ATTR_VALUE_POLYPOLYGON:
    1084             :     {
    1085         742 :         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ) )
    1086             :         {
    1087         742 :             basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( (drawing::PointSequenceSequence*)rValue.getValue()));
    1088         742 :             SetPolygon(aNewPolyPolygon);
    1089         742 :             return true;
    1090             :         }
    1091           0 :         break;
    1092             :     }
    1093             :     case OWN_ATTR_BASE_GEOMETRY:
    1094             :     {
    1095           8 :         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0)))
    1096             :         {
    1097           8 :             if( mpObj.is() )
    1098             :             {
    1099           8 :                 basegfx::B2DPolyPolygon aNewPolyPolygon;
    1100           8 :                 basegfx::B2DHomMatrix aNewHomogenMatrix;
    1101             : 
    1102           8 :                 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
    1103           8 :                 aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon((drawing::PointSequenceSequence*)rValue.getValue());
    1104           8 :                 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
    1105             :             }
    1106           8 :             return true;
    1107             :         }
    1108           0 :         break;
    1109             :     }
    1110             :     case OWN_ATTR_VALUE_POLYGON:
    1111             :     {
    1112           0 :         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ))
    1113             :         {
    1114           0 :             drawing::PointSequence* pSequence = (drawing::PointSequence*)rValue.getValue();
    1115             : 
    1116             :             // Neues Polygon vorbereiten
    1117           0 :             basegfx::B2DPolygon aNewPolygon;
    1118             : 
    1119             :             // Zeiger auf Arrays holen
    1120             :             // Zeiger auf Arrays holen
    1121           0 :             const awt::Point* pArray    = pSequence->getConstArray();
    1122           0 :             const awt::Point* pArrayEnd = pArray + pSequence->getLength();
    1123             : 
    1124           0 :             for(;pArray != pArrayEnd;++pArray)
    1125             :             {
    1126           0 :                 aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
    1127             :             }
    1128             : 
    1129             :             // check for closed state flag
    1130           0 :             basegfx::tools::checkClosed(aNewPolygon);
    1131             : 
    1132             :             // Polygon setzen
    1133           0 :             SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon));
    1134           0 :             return true;
    1135             :         }
    1136           0 :         break;
    1137             :     }
    1138             :     default:
    1139       10517 :         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
    1140             :     }
    1141             : 
    1142           0 :     throw lang::IllegalArgumentException();
    1143             : }
    1144             : 
    1145          14 : void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval )
    1146             : {
    1147          14 :     if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() )
    1148           0 :         rRetval.realloc( rPolyPoly.count() );
    1149             : 
    1150             :     // Zeiger auf aeussere Arrays holen
    1151          14 :     drawing::PointSequence* pOuterSequence = rRetval.getArray();
    1152             : 
    1153          28 :     for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++)
    1154             :     {
    1155             :         // Einzelpolygon holen
    1156          14 :         const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(a));
    1157             : 
    1158             :         // #i75974# take closed stae into account, the API polygon still uses the old closed definition
    1159             :         // with last/first point are identical (cannot hold information about open polygons with identical
    1160             :         // first and last point, though)
    1161          14 :         const sal_uInt32 nPointCount(aPoly.count());
    1162          14 :         const bool bIsClosed(aPoly.isClosed());
    1163             : 
    1164             :         // Platz in Arrays schaffen
    1165          14 :         pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount);
    1166             : 
    1167             :         // Pointer auf arrays holen
    1168          14 :         awt::Point* pInnerSequence = pOuterSequence->getArray();
    1169             : 
    1170         106 :         for(sal_uInt32 b(0L); b < nPointCount; b++)
    1171             :         {
    1172          92 :             const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
    1173          92 :             *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
    1174          92 :             pInnerSequence++;
    1175          92 :         }
    1176             : 
    1177             :         // #i75974# copy first point
    1178          14 :         if(bIsClosed)
    1179             :         {
    1180           6 :             *pInnerSequence = *pOuterSequence->getArray();
    1181             :         }
    1182             : 
    1183          14 :         pOuterSequence++;
    1184          14 :     }
    1185          14 : }
    1186             : 
    1187             : //----------------------------------------------------------------------
    1188             : 
    1189         461 : bool SvxShapePolyPolygon::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1190             : {
    1191         461 :     switch( pProperty->nWID )
    1192             :     {
    1193             :     case OWN_ATTR_VALUE_POLYPOLYGON:
    1194             :     {
    1195             :         // PolyPolygon in eine struct PolyPolygon packen
    1196           7 :         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
    1197           7 :         drawing::PointSequenceSequence aRetval( rPolyPoly.count() );
    1198             : 
    1199           7 :         B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval );
    1200             : 
    1201           7 :         rValue <<= aRetval;
    1202           7 :         break;
    1203             :     }
    1204             :     case OWN_ATTR_BASE_GEOMETRY:
    1205             :     {
    1206             :         // pack a PolyPolygon in struct PolyPolygon
    1207           7 :         basegfx::B2DPolyPolygon aNewPolyPolygon;
    1208           7 :         basegfx::B2DHomMatrix aNewHomogenMatrix;
    1209             : 
    1210           7 :         if(mpObj.is())
    1211           7 :             mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
    1212             : 
    1213           7 :         drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
    1214           7 :         B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
    1215           7 :         rValue <<= aRetval;
    1216           7 :         break;
    1217             :     }
    1218             :     case OWN_ATTR_VALUE_POLYGON:
    1219             :     {
    1220             :         // PolyPolygon in eine struct PolyPolygon packen
    1221           0 :         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
    1222             : 
    1223           0 :         sal_Int32 nCount = 0;
    1224           0 :         if( rPolyPoly.count() > 0 )
    1225           0 :             nCount = rPolyPoly.getB2DPolygon(0L).count();
    1226             : 
    1227           0 :         drawing::PointSequence aRetval( nCount );
    1228             : 
    1229           0 :         if( nCount > 0 )
    1230             :         {
    1231             :             // Einzelpolygon holen
    1232           0 :             const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L));
    1233             : 
    1234             :             // Pointer auf arrays holen
    1235           0 :             awt::Point* pSequence = aRetval.getArray();
    1236             : 
    1237           0 :             for(sal_Int32 b=0;b<nCount;b++)
    1238             :             {
    1239           0 :                 const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
    1240           0 :                 *pSequence++ = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
    1241           0 :             }
    1242             :         }
    1243             : 
    1244           0 :         rValue <<= aRetval;
    1245           0 :         break;
    1246             :     }
    1247             :     case OWN_ATTR_VALUE_POLYGONKIND:
    1248             :     {
    1249           7 :         rValue <<= GetPolygonKind();
    1250           7 :         break;
    1251             :     }
    1252             :     default:
    1253         440 :         return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
    1254             :     }
    1255             : 
    1256          21 :     return true;
    1257             : }
    1258             : 
    1259             : //----------------------------------------------------------------------
    1260           7 : drawing::PolygonKind SvxShapePolyPolygon::GetPolygonKind() const throw()
    1261             : {
    1262           7 :     return mePolygonKind;
    1263             : }
    1264             : 
    1265             : //----------------------------------------------------------------------
    1266         742 : void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
    1267             : {
    1268         742 :     ::SolarMutexGuard aGuard;
    1269             : 
    1270         742 :     if(mpObj.is())
    1271         742 :         ((SdrPathObj*)mpObj.get())->SetPathPoly(rNew);
    1272         742 : }
    1273             : 
    1274             : //----------------------------------------------------------------------
    1275           7 : basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
    1276             : {
    1277           7 :     ::SolarMutexGuard aGuard;
    1278             : 
    1279           7 :     if(mpObj.is())
    1280             :     {
    1281           7 :         return ((SdrPathObj*)mpObj.get())->GetPathPoly();
    1282             :     }
    1283             :     else
    1284             :     {
    1285           0 :         return basegfx::B2DPolyPolygon();
    1286           7 :     }
    1287             : }
    1288             : 
    1289             : // ::com::sun::star::lang::XServiceInfo
    1290         137 : uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException )
    1291             : {
    1292         137 :     return SvxShapeText::getSupportedServiceNames();
    1293             : }
    1294             : 
    1295             : /***********************************************************************
    1296             : * class SvxShapePolyPolygonBezier                                      *
    1297             : ***********************************************************************/
    1298             : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
    1299             : #include <com/sun/star/drawing/FlagSequence.hpp>
    1300             : //----------------------------------------------------------------------
    1301          10 : SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw()
    1302          30 : :   SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGONBEZIER), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) )
    1303          30 : ,   mePolygonKind( eNew )
    1304             : {
    1305          10 : }
    1306             : 
    1307             : //----------------------------------------------------------------------
    1308          20 : SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw()
    1309             : {
    1310          20 : }
    1311             : 
    1312             : //----------------------------------------------------------------------
    1313             : 
    1314          29 : bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1315             : {
    1316          29 :     switch( pProperty->nWID )
    1317             :     {
    1318             :     case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
    1319             :     {
    1320           1 :         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0) ) )
    1321             :         {
    1322             :             basegfx::B2DPolyPolygon aNewPolyPolygon(
    1323             :                 basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
    1324           1 :                     *(drawing::PolyPolygonBezierCoords*)rValue.getValue()));
    1325           1 :             SetPolygon(aNewPolyPolygon);
    1326           1 :             return true;
    1327             :         }
    1328           0 :         break;
    1329             :     }
    1330             :     case OWN_ATTR_BASE_GEOMETRY:
    1331             :     {
    1332           4 :         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0)) )
    1333             :         {
    1334           4 :             if( mpObj.is() )
    1335             :             {
    1336           4 :                 basegfx::B2DPolyPolygon aNewPolyPolygon;
    1337           4 :                 basegfx::B2DHomMatrix aNewHomogenMatrix;
    1338             : 
    1339           4 :                 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
    1340             :                 aNewPolyPolygon = basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
    1341           4 :                     *(drawing::PolyPolygonBezierCoords*)rValue.getValue());
    1342           4 :                 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
    1343             :             }
    1344           4 :             return true;
    1345             :         }
    1346           0 :         break;
    1347             :     }
    1348             :     default:
    1349          24 :         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
    1350             :     }
    1351             : 
    1352           0 :     throw IllegalArgumentException();
    1353             : }
    1354             : 
    1355             : //----------------------------------------------------------------------
    1356             : 
    1357         317 : bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1358             : {
    1359         317 :     switch( pProperty->nWID )
    1360             :     {
    1361             :     case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
    1362             :     {
    1363             :         // PolyPolygon in eine struct PolyPolygon packen
    1364           4 :         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
    1365           4 :         drawing::PolyPolygonBezierCoords aRetval;
    1366           4 :         basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval);
    1367             : 
    1368           4 :         rValue <<= aRetval;
    1369           4 :         break;
    1370             :     }
    1371             :     case OWN_ATTR_BASE_GEOMETRY:
    1372             :     {
    1373             :         // PolyPolygon in eine struct PolyPolygon packen
    1374           4 :         basegfx::B2DPolyPolygon aNewPolyPolygon;
    1375           4 :         basegfx::B2DHomMatrix aNewHomogenMatrix;
    1376           4 :         mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
    1377           4 :         drawing::PolyPolygonBezierCoords aRetval;
    1378           4 :         basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
    1379             : 
    1380           4 :         rValue <<= aRetval;
    1381           4 :         break;
    1382             :     }
    1383             :     case OWN_ATTR_VALUE_POLYGONKIND:
    1384             :     {
    1385           4 :         rValue <<= GetPolygonKind();
    1386           4 :         break;
    1387             :     }
    1388             :     default:
    1389         305 :         return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
    1390             :     }
    1391          12 :     return true;
    1392             : }
    1393             : 
    1394             : //----------------------------------------------------------------------
    1395           4 : drawing::PolygonKind SvxShapePolyPolygonBezier::GetPolygonKind() const throw()
    1396             : {
    1397           4 :     return mePolygonKind;
    1398             : }
    1399             : 
    1400             : //----------------------------------------------------------------------
    1401           1 : void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
    1402             : {
    1403           1 :     ::SolarMutexGuard aGuard;
    1404             : 
    1405           1 :     if(mpObj.is())
    1406           1 :         static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
    1407           1 : }
    1408             : 
    1409             : //----------------------------------------------------------------------
    1410           4 : basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
    1411             : {
    1412           4 :     ::SolarMutexGuard aGuard;
    1413             : 
    1414           4 :     if(mpObj.is())
    1415             :     {
    1416           4 :         return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
    1417             :     }
    1418             :     else
    1419             :     {
    1420           0 :         return basegfx::B2DPolyPolygon();
    1421           4 :     }
    1422             : }
    1423             : 
    1424             : 
    1425             : // ::com::sun::star::lang::XServiceInfo
    1426          68 : uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException )
    1427             : {
    1428          68 :     return SvxShapeText::getSupportedServiceNames();
    1429             : }
    1430             : 
    1431             : /***********************************************************************
    1432             : * class SvxGraphicObject                                               *
    1433             : ***********************************************************************/
    1434             : #include <com/sun/star/awt/XBitmap.hpp>
    1435             : #include <vcl/cvtgrf.hxx>
    1436             : #include <svx/svdograf.hxx>
    1437             : #include <sfx2/docfile.hxx>
    1438             : #include <sfx2/app.hxx>
    1439             : #include <sfx2/fcontnr.hxx>
    1440             : 
    1441             : #include "toolkit/unohlp.hxx"
    1442             : 
    1443             : //----------------------------------------------------------------------
    1444          41 : SvxGraphicObject::SvxGraphicObject( SdrObject* pObj ) throw()
    1445          41 : :   SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
    1446             : {
    1447          41 : }
    1448             : 
    1449             : //----------------------------------------------------------------------
    1450          82 : SvxGraphicObject::~SvxGraphicObject() throw()
    1451             : {
    1452          82 : }
    1453             : 
    1454             : //----------------------------------------------------------------------
    1455             : 
    1456         348 : bool SvxGraphicObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1457             : {
    1458         348 :     bool bOk = false;
    1459         348 :     switch( pProperty->nWID )
    1460             :     {
    1461             :     case OWN_ATTR_VALUE_FILLBITMAP:
    1462             :     {
    1463           0 :         if( rValue.getValue() )
    1464             :         {
    1465           0 :             if( rValue.getValueType() == ::getCppuType(( const uno::Sequence< sal_Int8 >*)0) )
    1466             :             {
    1467           0 :                 uno::Sequence<sal_Int8>* pSeq( (uno::Sequence<sal_Int8>*)rValue.getValue() );
    1468           0 :                 SvMemoryStream  aMemStm;
    1469           0 :                 Graphic         aGraphic;
    1470             : 
    1471           0 :                 aMemStm.SetBuffer( (char*)pSeq->getConstArray(), pSeq->getLength(), sal_False, pSeq->getLength() );
    1472             : 
    1473           0 :                 if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
    1474             :                 {
    1475           0 :                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
    1476           0 :                     bOk = true;
    1477           0 :                 }
    1478             :             }
    1479             :         }
    1480           0 :         else if( (rValue.getValueType() == awt::XBitmap::static_type()) || (rValue.getValueType() == graphic::XGraphic::static_type()))
    1481             :         {
    1482           0 :             Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY );
    1483           0 :             if( xGraphic.is() )
    1484             :             {
    1485           0 :                 ((SdrGrafObj*)mpObj.get())->SetGraphic(Graphic(xGraphic));
    1486           0 :                 bOk = true;
    1487             :             }
    1488             :             else
    1489             :             {
    1490             :                 // Bitmap in das Objekt packen
    1491           0 :                 Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
    1492           0 :                 if( xBmp.is() )
    1493             :                 {
    1494             :                     // Bitmap einsetzen
    1495           0 :                     Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp ));
    1496           0 :                     ((SdrGrafObj*)mpObj.get())->SetGraphic(aGraphic);
    1497           0 :                     bOk = true;
    1498           0 :                 }
    1499           0 :             }
    1500             :         }
    1501           0 :         break;
    1502             :     }
    1503             :     case OWN_ATTR_GRAFURL:
    1504             :     {
    1505          33 :         OUString aURL;
    1506          33 :         if( rValue >>= aURL )
    1507             :         {
    1508          33 :             if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
    1509             :             {
    1510             :                 // graphic manager url
    1511          30 :                 aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
    1512          30 :                 String aTmpStr(aURL);
    1513          30 :                 rtl::OString aUniqueID(rtl::OUStringToOString(aTmpStr, RTL_TEXTENCODING_UTF8));
    1514          30 :                 GraphicObject aGrafObj(aUniqueID);
    1515             : 
    1516             :                 // #101808# since loading a graphic can cause a reschedule of the office
    1517             :                 //          it is possible that our shape is removed while where in this
    1518             :                 //          method.
    1519          30 :                 if( mpObj.is() )
    1520             :                 {
    1521          30 :                     static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink();
    1522          30 :                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj );
    1523          30 :                 }
    1524             :             }
    1525           3 :             else if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
    1526             :             {
    1527             :                 // normal link
    1528           0 :                 String              aFilterName;
    1529           0 :                 const SfxFilter*    pSfxFilter = NULL;
    1530           0 :                 SfxMedium           aSfxMedium( aURL, STREAM_READ | STREAM_SHARE_DENYNONE );
    1531             : 
    1532           0 :                 SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
    1533             : 
    1534           0 :                 if( !pSfxFilter )
    1535             :                 {
    1536           0 :                     INetURLObject aURLObj( aURL );
    1537             : 
    1538           0 :                     if( aURLObj.GetProtocol() == INET_PROT_NOT_VALID )
    1539             :                     {
    1540           0 :                         rtl::OUString aValidURL;
    1541             : 
    1542           0 :                         if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) )
    1543           0 :                             aURLObj = INetURLObject( aValidURL );
    1544             :                     }
    1545             : 
    1546           0 :                     if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID )
    1547             :                     {
    1548           0 :                         GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter();
    1549           0 :                         aFilterName = rGrfFilter.GetImportFormatName( rGrfFilter.GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
    1550           0 :                     }
    1551             :                 }
    1552             :                 else
    1553           0 :                     aFilterName = pSfxFilter->GetFilterName();
    1554             : 
    1555             :                 // #101808# since loading a graphic can cause a reschedule of the office
    1556             :                 //          it is possible that our shape is removed while where in this
    1557             :                 //          method.
    1558           0 :                 if( mpObj.is() )
    1559           0 :                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, aFilterName );
    1560             : 
    1561             :             }
    1562          33 :             bOk = true;
    1563             :         }
    1564          33 :         break;
    1565             :     }
    1566             : 
    1567             :     case OWN_ATTR_GRAFSTREAMURL:
    1568             :     {
    1569           3 :         OUString aStreamURL;
    1570             : 
    1571           3 :         if( rValue >>= aStreamURL )
    1572             :         {
    1573           3 :             if( aStreamURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
    1574           0 :                 aStreamURL = OUString();
    1575             : 
    1576           3 :             if( mpObj.is() )
    1577             :             {
    1578           3 :                 static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
    1579           3 :                 static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut();
    1580             :             }
    1581           3 :             bOk = true;
    1582             :         }
    1583           3 :         break;
    1584             :     }
    1585             : 
    1586             :     case OWN_ATTR_VALUE_GRAPHIC:
    1587             :     {
    1588           0 :         Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
    1589           0 :         if( xGraphic.is() )
    1590             :         {
    1591           0 :             static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
    1592           0 :             bOk = true;
    1593             :         }
    1594           0 :         break;
    1595             :     }
    1596             :     default:
    1597         312 :         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
    1598             :     }
    1599             : 
    1600          36 :     if( !bOk )
    1601           0 :         throw lang::IllegalArgumentException();
    1602             : 
    1603          36 :     if( mpModel )
    1604          36 :         mpModel->SetChanged();
    1605             : 
    1606          36 :     return true;
    1607             : }
    1608             : 
    1609             : //----------------------------------------------------------------------
    1610             : 
    1611         109 : bool SvxGraphicObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1612             : {
    1613         109 :     switch( pProperty->nWID )
    1614             :     {
    1615             :     case OWN_ATTR_VALUE_FILLBITMAP:
    1616             :     {
    1617           0 :         sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
    1618           0 :         const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
    1619             : 
    1620           0 :         if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
    1621             :         {
    1622             :             // Objekt in eine Bitmap packen
    1623           0 :             Reference< ::com::sun::star::awt::XBitmap >  xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
    1624           0 :             rValue <<= xBitmap;
    1625             :         }
    1626             :         else
    1627             :         {
    1628           0 :             SvMemoryStream aDestStrm( 65535, 65535 );
    1629             : 
    1630           0 :             ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False );
    1631             :             const uno::Sequence<sal_Int8> aSeq(
    1632           0 :                 static_cast< const sal_Int8* >(aDestStrm.GetData()),
    1633           0 :                 aDestStrm.GetEndOfData());
    1634           0 :             rValue <<= aSeq;
    1635             :         }
    1636           0 :         if ( bSwapped )
    1637           0 :             static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
    1638           0 :         break;
    1639             :     }
    1640             : 
    1641             :     case OWN_ATTR_GRAFURL:
    1642             :     {
    1643          21 :         if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() )
    1644             :         {
    1645           0 :             rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() );
    1646             :         }
    1647             :         else
    1648             :         {
    1649          21 :             sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
    1650          21 :             const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
    1651          21 :             OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
    1652          21 :             aURL += OStringToOUString(rGrafObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
    1653          21 :             rValue <<= aURL;
    1654          21 :             if ( bSwapped )
    1655           0 :                 static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
    1656             :         }
    1657          21 :         break;
    1658             :     }
    1659             : 
    1660             :     case OWN_ATTR_REPLACEMENTGRAFURL:
    1661             :     {
    1662           0 :         const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(mpObj.get())->GetReplacementGraphicObject();
    1663             : 
    1664           0 :         if(pGrafObj)
    1665             :         {
    1666           0 :             OUString aURL(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
    1667           0 :             aURL += OStringToOUString(pGrafObj->GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
    1668           0 :             rValue <<= aURL;
    1669             :         }
    1670             : 
    1671           0 :         break;
    1672             :     }
    1673             : 
    1674             :     case OWN_ATTR_GRAFSTREAMURL:
    1675             :     {
    1676           0 :         const OUString  aStreamURL( ( (SdrGrafObj*) mpObj.get() )->GetGrafStreamURL() );
    1677           0 :         if( !aStreamURL.isEmpty() )
    1678           0 :             rValue <<= aStreamURL;
    1679           0 :         break;
    1680             :     }
    1681             : 
    1682             :     case OWN_ATTR_VALUE_GRAPHIC:
    1683             :     {
    1684           1 :         sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
    1685           1 :         Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
    1686           1 :         rValue <<= xGraphic;
    1687           1 :         if ( bSwapped )
    1688           0 :             static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
    1689           1 :         break;
    1690             :     }
    1691             : 
    1692             :     case OWN_ATTR_GRAPHIC_STREAM:
    1693             :     {
    1694           0 :         rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
    1695           0 :         break;
    1696             :     }
    1697             :     default:
    1698          87 :         return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
    1699             :     }
    1700             : 
    1701          22 :     return true;
    1702             : }
    1703             : 
    1704             : ///////////////////////////////////////////////////////////////////////
    1705             : 
    1706           2 : SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw()
    1707           2 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CAPTION), getSvxMapProvider().GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) )
    1708             : {
    1709           2 : }
    1710             : 
    1711           4 : SvxShapeCaption::~SvxShapeCaption() throw()
    1712             : {
    1713           4 : }
    1714             : 
    1715             : /***********************************************************************
    1716             : * class SvxCustomShape                                                   *
    1717             : ***********************************************************************/
    1718             : 
    1719        4517 : SvxCustomShape::SvxCustomShape( SdrObject* pObj )  throw() :
    1720        4517 :     SvxShapeText( pObj, getSvxMapProvider().GetMap( SVXMAP_CUSTOMSHAPE ), getSvxMapProvider().GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) )
    1721             : {
    1722        4517 : }
    1723             : 
    1724             : //----------------------------------------------------------------------
    1725        9034 : SvxCustomShape::~SvxCustomShape() throw()
    1726             : {
    1727        9034 : }
    1728             : 
    1729             : //----------------------------------------------------------------------
    1730             : 
    1731          84 : void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
    1732             : {
    1733          84 :     SvxShapeText::Create( pNewObj, pNewPage );
    1734          84 : }
    1735             : 
    1736             : //----------------------------------------------------------------------
    1737             : 
    1738       13603 : uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType )
    1739             :     throw(uno::RuntimeException)
    1740             : {
    1741       13603 :     return SvxShapeText::queryInterface( rType );
    1742             : }
    1743             : 
    1744       14584 : uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType )
    1745             :     throw(uno::RuntimeException)
    1746             : {
    1747       14584 :     ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType );
    1748       14584 :     if ( !aReturn.hasValue() )
    1749         148 :         aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) );
    1750       14584 :     return aReturn;
    1751             : }
    1752             : 
    1753       46099 : void SAL_CALL SvxCustomShape::acquire() throw ( )
    1754             : {
    1755       46099 :     SvxShapeText::acquire();
    1756       46099 : }
    1757             : 
    1758       46099 : void SAL_CALL SvxCustomShape::release() throw ( )
    1759             : {
    1760       46099 :     SvxShapeText::release();
    1761       46099 : }
    1762             : 
    1763             : //----------------------------------------------------------------------
    1764             : 
    1765           0 : uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes()
    1766             :     throw (uno::RuntimeException)
    1767             : {
    1768           0 :     return SvxShapeText::getTypes();
    1769             : }
    1770             : 
    1771             : namespace
    1772             : {
    1773             :     class theSvxCustomShapeImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxCustomShapeImplementationId > {};
    1774             : }
    1775             : 
    1776           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
    1777             :     throw (uno::RuntimeException)
    1778             : {
    1779           0 :     return theSvxCustomShapeImplementationId::get().getSeq();
    1780             : }
    1781             : 
    1782             : // ::com::sun::star::drawing::XShape
    1783             : 
    1784             : //----------------------------------------------------------------------
    1785         301 : OUString SAL_CALL SvxCustomShape::getShapeType()
    1786             :     throw( uno::RuntimeException )
    1787             : {
    1788         301 :     return SvxShape::getShapeType();
    1789             : }
    1790             : 
    1791             : //------------------------------------------------------------------1----
    1792         145 : awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException)
    1793             : {
    1794         145 :     ::SolarMutexGuard aGuard;
    1795         145 :     if ( mpModel && mpObj.is() )
    1796             :     {
    1797          78 :         SdrAShapeObjGeoData aCustomShapeGeoData;
    1798          78 :         ((SdrObjCustomShape*)mpObj.get())->SaveGeoData( aCustomShapeGeoData );
    1799             : 
    1800          78 :         sal_Bool bMirroredX = sal_False;
    1801          78 :         sal_Bool bMirroredY = sal_False;
    1802             : 
    1803          78 :         if ( mpObj.is() )
    1804             :         {
    1805          78 :             bMirroredX = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredX() );
    1806          78 :             bMirroredY = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredY() );
    1807             :         }
    1808             :         // get aRect, this is the unrotated snaprect
    1809          78 :         Rectangle aRect(((SdrObjCustomShape*)mpObj.get())->GetLogicRect());
    1810          78 :         Rectangle aRectangle( aRect );
    1811             : 
    1812          78 :         if ( bMirroredX || bMirroredY )
    1813             :         {   // we have to retrieve the unmirrored rect
    1814             : 
    1815           3 :             GeoStat aNewGeo( aCustomShapeGeoData.aGeo );
    1816           3 :             if ( bMirroredX )
    1817             :             {
    1818           3 :                 Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
    1819           3 :                 Rectangle aBoundRect( aPol.GetBoundRect() );
    1820             : 
    1821           3 :                 Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
    1822           3 :                 Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
    1823             :                 sal_uInt16 i;
    1824           3 :                 sal_uInt16 nPntAnz=aPol.GetSize();
    1825          18 :                 for (i=0; i<nPntAnz; i++)
    1826             :                 {
    1827          15 :                     MirrorPoint(aPol[i],aRef1,aRef2);
    1828             :                 }
    1829             :                 // Polygon wenden und etwas schieben
    1830           3 :                 Polygon aPol0(aPol);
    1831           3 :                 aPol[0]=aPol0[1];
    1832           3 :                 aPol[1]=aPol0[0];
    1833           3 :                 aPol[2]=aPol0[3];
    1834           3 :                 aPol[3]=aPol0[2];
    1835           3 :                 aPol[4]=aPol0[1];
    1836           3 :                 Poly2Rect(aPol,aRectangle,aNewGeo);
    1837             :             }
    1838           3 :             if ( bMirroredY )
    1839             :             {
    1840           0 :                 Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
    1841           0 :                 Rectangle aBoundRect( aPol.GetBoundRect() );
    1842             : 
    1843           0 :                 Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
    1844           0 :                 Point aRef2( aRef1.X() + 1000, aRef1.Y() );
    1845             :                 sal_uInt16 i;
    1846           0 :                 sal_uInt16 nPntAnz=aPol.GetSize();
    1847           0 :                 for (i=0; i<nPntAnz; i++)
    1848             :                 {
    1849           0 :                     MirrorPoint(aPol[i],aRef1,aRef2);
    1850             :                 }
    1851             :                 // Polygon wenden und etwas schieben
    1852           0 :                 Polygon aPol0(aPol);
    1853           0 :                 aPol[0]=aPol0[1];
    1854           0 :                 aPol[1]=aPol0[0];
    1855           0 :                 aPol[2]=aPol0[3];
    1856           0 :                 aPol[3]=aPol0[2];
    1857           0 :                 aPol[4]=aPol0[1];
    1858           0 :                 Poly2Rect( aPol, aRectangle, aNewGeo );
    1859             :             }
    1860             :         }
    1861          78 :         Point aPt( aRectangle.TopLeft() );
    1862             : 
    1863          78 :         if( mpModel->IsWriter() )
    1864          13 :             aPt -= mpObj->GetAnchorPos();
    1865             : 
    1866          78 :         ForceMetricTo100th_mm(aPt);
    1867          78 :         return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
    1868             :     }
    1869             :     else
    1870          67 :         return SvxShape::getPosition();
    1871             : }
    1872             : 
    1873             : //----------------------------------------------------------------------
    1874         109 : void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
    1875             : {
    1876         109 :     SvxShapeText::setPosition(Position);
    1877         109 : }
    1878             : 
    1879             : //----------------------------------------------------------------------
    1880             : 
    1881         155 : awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException)
    1882             : {
    1883         155 :     return SvxShapeText::getSize();
    1884             : }
    1885             : 
    1886             : //----------------------------------------------------------------------
    1887          96 : void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize )
    1888             :     throw(beans::PropertyVetoException, uno::RuntimeException)
    1889             : {
    1890          96 :     SvxShapeText::setSize( rSize );
    1891          96 : }
    1892             : 
    1893             : //----------------------------------------------------------------------
    1894             : 
    1895             : //----------------------------------------------------------------------
    1896         799 : void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
    1897             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
    1898             : {
    1899         799 :     ::SolarMutexGuard aGuard;
    1900         799 :     SdrObject* pObject = mpObj.get();
    1901             : 
    1902         799 :     sal_Bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) );
    1903             : 
    1904         799 :     sal_Bool bMirroredX = sal_False;
    1905         799 :     sal_Bool bMirroredY = sal_False;
    1906             : 
    1907         799 :     if ( bCustomShapeGeometry )
    1908             :     {
    1909          74 :         bMirroredX = ( ((SdrObjCustomShape*)pObject)->IsMirroredX() );
    1910          74 :         bMirroredY = ( ((SdrObjCustomShape*)pObject)->IsMirroredY() );
    1911             :     }
    1912             : 
    1913         799 :     SvxShape::setPropertyValue( aPropertyName, aValue );
    1914             : 
    1915         799 :     if ( bCustomShapeGeometry )
    1916             :     {
    1917          74 :         ((SdrObjCustomShape*)pObject)->MergeDefaultAttributes(0);
    1918          74 :         Rectangle aRect( pObject->GetSnapRect() );
    1919             : 
    1920             :         // #i38892#
    1921          74 :         bool bNeedsMirrorX = ((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX;
    1922          74 :         bool bNeedsMirrorY = ((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY;
    1923             : 
    1924          74 :         boost::scoped_ptr< SdrGluePointList > pListCopy;
    1925          74 :         if( bNeedsMirrorX || bNeedsMirrorY )
    1926             :         {
    1927           3 :             const SdrGluePointList* pList = pObject->GetGluePointList();
    1928           3 :             if( pList )
    1929           0 :                 pListCopy.reset( new SdrGluePointList(*pList) );
    1930             :         }
    1931             : 
    1932          74 :         if ( bNeedsMirrorX )
    1933             :         {
    1934           3 :             Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
    1935           3 :             Point aBottom( aTop.X(), aTop.Y() + 1000 );
    1936           3 :             pObject->NbcMirror( aTop, aBottom );
    1937             :             // NbcMirroring is flipping the current mirror state,
    1938             :             // so we have to set the correct state again
    1939           3 :             ((SdrObjCustomShape*)pObject)->SetMirroredX( bMirroredX ? sal_False : sal_True );
    1940             :         }
    1941          74 :         if ( bNeedsMirrorY )
    1942             :         {
    1943           0 :             Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
    1944           0 :             Point aRight( aLeft.X() + 1000, aLeft.Y() );
    1945           0 :             pObject->NbcMirror( aLeft, aRight );
    1946             :             // NbcMirroring is flipping the current mirror state,
    1947             :             // so we have to set the correct state again
    1948           0 :             ((SdrObjCustomShape*)pObject)->SetMirroredY( bMirroredY ? sal_False : sal_True );
    1949             :         }
    1950             : 
    1951          74 :         if( pListCopy )
    1952             :         {
    1953           0 :             SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
    1954           0 :             if(pNewList)
    1955           0 :                 *pNewList = *pListCopy;
    1956          74 :         }
    1957         799 :     }
    1958         799 : }
    1959             : 
    1960        4846 : bool SvxCustomShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
    1961             : {
    1962        4846 :     switch( pProperty->nWID )
    1963             :     {
    1964             :     case SDRATTR_ROTATEANGLE:
    1965             :     {
    1966           2 :         double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
    1967           2 :         fAngle *= 100;
    1968           2 :         rValue <<= (sal_Int32)fAngle;
    1969           2 :         return true;
    1970             :     }
    1971             :     default:
    1972        4844 :         return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
    1973             :     }
    1974             : }
    1975             : //----------------------------------------------------------------------
    1976             : 
    1977          16 : void SvxCustomShape::createCustomShapeDefaults( const rtl::OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException)
    1978             : {
    1979          16 :     ((SdrObjCustomShape*)mpObj.get())->MergeDefaultAttributes( &rValueType );
    1980          16 : }
    1981             : 
    1982             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10