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