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/drawing/HomogenMatrix.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/drawing/Position3D.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/drawing/DoubleSequence.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/drawing/CameraGeometry.hpp> 37*cdf0e10cSrcweir #include <vcl/svapp.hxx> 38*cdf0e10cSrcweir #include <vos/mutex.hxx> 39*cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <rtl/uuid.h> 42*cdf0e10cSrcweir #include <rtl/memory.h> 43*cdf0e10cSrcweir #include <svx/svdpool.hxx> 44*cdf0e10cSrcweir #include <svx/unoshape.hxx> 45*cdf0e10cSrcweir #include <svx/unopage.hxx> 46*cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 47*cdf0e10cSrcweir #include <svx/polysc3d.hxx> 48*cdf0e10cSrcweir #include "svx/globl3d.hxx" 49*cdf0e10cSrcweir #include <svx/cube3d.hxx> 50*cdf0e10cSrcweir #include <svx/sphere3d.hxx> 51*cdf0e10cSrcweir #include <svx/lathe3d.hxx> 52*cdf0e10cSrcweir #include <svx/extrud3d.hxx> 53*cdf0e10cSrcweir #include <svx/polygn3d.hxx> 54*cdf0e10cSrcweir #include "svx/unoshprp.hxx" 55*cdf0e10cSrcweir #include "svx/svdmodel.hxx" 56*cdf0e10cSrcweir #include <basegfx/polygon/b3dpolygon.hxx> 57*cdf0e10cSrcweir #include <basegfx/polygon/b3dpolygontools.hxx> 58*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> 59*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir using ::rtl::OUString; 62*cdf0e10cSrcweir using namespace ::vos; 63*cdf0e10cSrcweir using namespace ::cppu; 64*cdf0e10cSrcweir using namespace ::com::sun::star; 65*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 66*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 67*cdf0e10cSrcweir using namespace ::com::sun::star::container; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir #define INTERFACE_TYPE( xint ) \ 70*cdf0e10cSrcweir ::getCppuType((const Reference< xint >*)0) 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir #define QUERYINT( xint ) \ 73*cdf0e10cSrcweir if( rType == ::getCppuType((const Reference< xint >*)0) ) \ 74*cdf0e10cSrcweir aAny <<= Reference< xint >(this) 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir /*********************************************************************** 77*cdf0e10cSrcweir * class Svx3DSceneObject * 78*cdf0e10cSrcweir ***********************************************************************/ 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //---------------------------------------------------------------------- 81*cdf0e10cSrcweir Svx3DSceneObject::Svx3DSceneObject( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw() 82*cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DSCENEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DSCENEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) 83*cdf0e10cSrcweir , mxPage( pDrawPage ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir //---------------------------------------------------------------------- 88*cdf0e10cSrcweir Svx3DSceneObject::~Svx3DSceneObject() throw() 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir //---------------------------------------------------------------------- 93*cdf0e10cSrcweir void Svx3DSceneObject::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir SvxShape::Create( pNewObj, pNewPage ); 96*cdf0e10cSrcweir mxPage = pNewPage; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir //---------------------------------------------------------------------- 100*cdf0e10cSrcweir uno::Any SAL_CALL Svx3DSceneObject::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir uno::Any aAny; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir QUERYINT( drawing::XShapes ); 105*cdf0e10cSrcweir else QUERYINT( container::XIndexAccess ); 106*cdf0e10cSrcweir else QUERYINT( container::XElementAccess ); 107*cdf0e10cSrcweir else 108*cdf0e10cSrcweir return SvxShape::queryAggregation( rType ); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir return aAny; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir uno::Any SAL_CALL Svx3DSceneObject::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir return SvxShape::queryInterface( rType ); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir void SAL_CALL Svx3DSceneObject::acquire() throw ( ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir SvxShape::acquire(); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void SAL_CALL Svx3DSceneObject::release() throw ( ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir SvxShape::release(); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir // XTypeProvider 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Svx3DSceneObject::getTypes() 131*cdf0e10cSrcweir throw (uno::RuntimeException) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir return SvxShape::getTypes(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL Svx3DSceneObject::getImplementationId() 138*cdf0e10cSrcweir throw (uno::RuntimeException) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 141*cdf0e10cSrcweir if( aId.getLength() == 0 ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir aId.realloc( 16 ); 144*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir return aId; 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir //---------------------------------------------------------------------- 150*cdf0e10cSrcweir void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape ) 151*cdf0e10cSrcweir throw( uno::RuntimeException) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( xShape ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if(!mpObj.is() || !mxPage.is() || pShape == NULL || NULL != pShape->GetSdrObject() ) 158*cdf0e10cSrcweir throw uno::RuntimeException(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir SdrObject* pSdrShape = mxPage->_CreateSdrObject( xShape ); 161*cdf0e10cSrcweir if( pSdrShape->ISA(E3dObject) ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir mpObj->GetSubList()->NbcInsertObject( pSdrShape ); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if(pShape) 166*cdf0e10cSrcweir pShape->Create( pSdrShape, mxPage.get() ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir else 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir SdrObject::Free( pSdrShape ); 171*cdf0e10cSrcweir throw uno::RuntimeException(); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir if( mpModel ) 175*cdf0e10cSrcweir mpModel->SetChanged(); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir //---------------------------------------------------------------------- 179*cdf0e10cSrcweir void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xShape ) 180*cdf0e10cSrcweir throw( uno::RuntimeException ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( xShape ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir if(!mpObj.is() || pShape == NULL) 187*cdf0e10cSrcweir throw uno::RuntimeException(); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir SdrObject* pSdrShape = pShape->GetSdrObject(); 190*cdf0e10cSrcweir if(pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get()) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir throw uno::RuntimeException(); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir else 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir SdrObjList& rList = *pSdrShape->GetObjList(); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir const sal_uInt32 nObjCount = rList.GetObjCount(); 199*cdf0e10cSrcweir sal_uInt32 nObjNum = 0; 200*cdf0e10cSrcweir while( nObjNum < nObjCount ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if(rList.GetObj( nObjNum ) == pSdrShape ) 203*cdf0e10cSrcweir break; 204*cdf0e10cSrcweir nObjNum++; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir if( nObjNum < nObjCount ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir SdrObject* pObject = rList.NbcRemoveObject( nObjNum ); 210*cdf0e10cSrcweir SdrObject::Free( pObject ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir else 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" ); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir //---------------------------------------------------------------------- 220*cdf0e10cSrcweir sal_Int32 SAL_CALL Svx3DSceneObject::getCount() 221*cdf0e10cSrcweir throw( uno::RuntimeException ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir sal_Int32 nRetval = 0; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir if(mpObj.is() && mpObj->ISA(E3dPolyScene) && mpObj->GetSubList()) 228*cdf0e10cSrcweir nRetval = mpObj->GetSubList()->GetObjCount(); 229*cdf0e10cSrcweir return nRetval; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir //---------------------------------------------------------------------- 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir uno::Any SAL_CALL Svx3DSceneObject::getByIndex( sal_Int32 Index ) 235*cdf0e10cSrcweir throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir if( !mpObj.is() || mpObj->GetSubList() == NULL ) 240*cdf0e10cSrcweir throw uno::RuntimeException(); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index ) 243*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index ); 246*cdf0e10cSrcweir if(pDestObj == NULL) 247*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY ); 250*cdf0e10cSrcweir uno::Any aAny; 251*cdf0e10cSrcweir aAny <<= xShape; 252*cdf0e10cSrcweir return aAny; 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir //---------------------------------------------------------------------- 256*cdf0e10cSrcweir // ::com::sun::star::container::XElementAccess 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir uno::Type SAL_CALL Svx3DSceneObject::getElementType() 259*cdf0e10cSrcweir throw( uno::RuntimeException ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir return ::getCppuType(( const Reference< drawing::XShape>*)0); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir //---------------------------------------------------------------------- 265*cdf0e10cSrcweir sal_Bool SAL_CALL Svx3DSceneObject::hasElements() 266*cdf0e10cSrcweir throw( uno::RuntimeException ) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir //---------------------------------------------------------------------- 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir static bool ConvertHomogenMatrixToObject( E3dObject* pObject, const Any& rValue ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir drawing::HomogenMatrix m; 278*cdf0e10cSrcweir if( rValue >>= m ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir basegfx::B3DHomMatrix aMat; 281*cdf0e10cSrcweir aMat.set(0, 0, m.Line1.Column1); 282*cdf0e10cSrcweir aMat.set(0, 1, m.Line1.Column2); 283*cdf0e10cSrcweir aMat.set(0, 2, m.Line1.Column3); 284*cdf0e10cSrcweir aMat.set(0, 3, m.Line1.Column4); 285*cdf0e10cSrcweir aMat.set(1, 0, m.Line2.Column1); 286*cdf0e10cSrcweir aMat.set(1, 1, m.Line2.Column2); 287*cdf0e10cSrcweir aMat.set(1, 2, m.Line2.Column3); 288*cdf0e10cSrcweir aMat.set(1, 3, m.Line2.Column4); 289*cdf0e10cSrcweir aMat.set(2, 0, m.Line3.Column1); 290*cdf0e10cSrcweir aMat.set(2, 1, m.Line3.Column2); 291*cdf0e10cSrcweir aMat.set(2, 2, m.Line3.Column3); 292*cdf0e10cSrcweir aMat.set(2, 3, m.Line3.Column4); 293*cdf0e10cSrcweir aMat.set(3, 0, m.Line4.Column1); 294*cdf0e10cSrcweir aMat.set(3, 1, m.Line4.Column2); 295*cdf0e10cSrcweir aMat.set(3, 2, m.Line4.Column3); 296*cdf0e10cSrcweir aMat.set(3, 3, m.Line4.Column4); 297*cdf0e10cSrcweir pObject->SetTransform(aMat); 298*cdf0e10cSrcweir return true; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir return false; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir static void ConvertObjectToHomogenMatric( E3dObject* pObject, Any& rValue ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir drawing::HomogenMatrix aHomMat; 306*cdf0e10cSrcweir const basegfx::B3DHomMatrix& rMat = pObject->GetTransform(); 307*cdf0e10cSrcweir aHomMat.Line1.Column1 = rMat.get(0, 0); 308*cdf0e10cSrcweir aHomMat.Line1.Column2 = rMat.get(0, 1); 309*cdf0e10cSrcweir aHomMat.Line1.Column3 = rMat.get(0, 2); 310*cdf0e10cSrcweir aHomMat.Line1.Column4 = rMat.get(0, 3); 311*cdf0e10cSrcweir aHomMat.Line2.Column1 = rMat.get(1, 0); 312*cdf0e10cSrcweir aHomMat.Line2.Column2 = rMat.get(1, 1); 313*cdf0e10cSrcweir aHomMat.Line2.Column3 = rMat.get(1, 2); 314*cdf0e10cSrcweir aHomMat.Line2.Column4 = rMat.get(1, 3); 315*cdf0e10cSrcweir aHomMat.Line3.Column1 = rMat.get(2, 0); 316*cdf0e10cSrcweir aHomMat.Line3.Column2 = rMat.get(2, 1); 317*cdf0e10cSrcweir aHomMat.Line3.Column3 = rMat.get(2, 2); 318*cdf0e10cSrcweir aHomMat.Line3.Column4 = rMat.get(2, 3); 319*cdf0e10cSrcweir aHomMat.Line4.Column1 = rMat.get(3, 0); 320*cdf0e10cSrcweir aHomMat.Line4.Column2 = rMat.get(3, 1); 321*cdf0e10cSrcweir aHomMat.Line4.Column3 = rMat.get(3, 2); 322*cdf0e10cSrcweir aHomMat.Line4.Column4 = rMat.get(3, 3); 323*cdf0e10cSrcweir rValue <<= aHomMat; 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir //---------------------------------------------------------------------- 327*cdf0e10cSrcweir #include <svx/svditer.hxx> 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir struct ImpRememberTransAndRect 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir basegfx::B3DHomMatrix maMat; 332*cdf0e10cSrcweir Rectangle maRect; 333*cdf0e10cSrcweir }; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir bool Svx3DSceneObject::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) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir switch( pProperty->nWID ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir // Transformationsmatrix in das Objekt packen 342*cdf0e10cSrcweir if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) 343*cdf0e10cSrcweir return true; 344*cdf0e10cSrcweir break; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY: 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir // set CameraGeometry at scene 349*cdf0e10cSrcweir E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() ); 350*cdf0e10cSrcweir drawing::CameraGeometry aCamGeo; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir if(rValue >>= aCamGeo) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir basegfx::B3DPoint aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ); 355*cdf0e10cSrcweir basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ); 356*cdf0e10cSrcweir basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // rescue scene transformation 359*cdf0e10cSrcweir ImpRememberTransAndRect aSceneTAR; 360*cdf0e10cSrcweir aSceneTAR.maMat = pScene->GetTransform(); 361*cdf0e10cSrcweir aSceneTAR.maRect = pScene->GetSnapRect(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir // rescue object transformations 364*cdf0e10cSrcweir SdrObjListIter aIter(*pScene->GetSubList(), IM_DEEPWITHGROUPS); 365*cdf0e10cSrcweir List aObjTrans; 366*cdf0e10cSrcweir while(aIter.IsMore()) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir E3dObject* p3DObj = (E3dObject*)aIter.Next(); 369*cdf0e10cSrcweir basegfx::B3DHomMatrix* pNew = new basegfx::B3DHomMatrix; 370*cdf0e10cSrcweir *pNew = p3DObj->GetTransform(); 371*cdf0e10cSrcweir aObjTrans.Insert(pNew, LIST_APPEND); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir // reset object transformations 375*cdf0e10cSrcweir aIter.Reset(); 376*cdf0e10cSrcweir while(aIter.IsMore()) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir E3dObject* p3DObj = (E3dObject*)aIter.Next(); 379*cdf0e10cSrcweir p3DObj->NbcSetTransform(basegfx::B3DHomMatrix()); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir // reset scene transformation and make a complete recalc 383*cdf0e10cSrcweir pScene->NbcSetTransform(basegfx::B3DHomMatrix()); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir // fill old camera from new parameters 386*cdf0e10cSrcweir Camera3D aCam(pScene->GetCamera()); 387*cdf0e10cSrcweir const basegfx::B3DRange& rVolume = pScene->GetBoundVolume(); 388*cdf0e10cSrcweir double fW = rVolume.getWidth(); 389*cdf0e10cSrcweir double fH = rVolume.getHeight(); 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir const SfxItemSet& rSceneSet = pScene->GetMergedItemSet(); 392*cdf0e10cSrcweir double fCamPosZ = 393*cdf0e10cSrcweir (double)((const SfxUInt32Item&)rSceneSet.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue(); 394*cdf0e10cSrcweir double fCamFocal = 395*cdf0e10cSrcweir (double)((const SfxUInt32Item&)rSceneSet.Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir aCam.SetAutoAdjustProjection(sal_False); 398*cdf0e10cSrcweir aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH); 399*cdf0e10cSrcweir basegfx::B3DPoint aLookAt; 400*cdf0e10cSrcweir basegfx::B3DPoint aCamPos(0.0, 0.0, fCamPosZ); 401*cdf0e10cSrcweir aCam.SetPosAndLookAt(aCamPos, aLookAt); 402*cdf0e10cSrcweir aCam.SetFocalLength(fCamFocal / 100.0); 403*cdf0e10cSrcweir aCam.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fCamPosZ), aLookAt, fCamFocal / 100.0); 404*cdf0e10cSrcweir aCam.SetDeviceWindow(Rectangle(0, 0, (long)fW, (long)fH)); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // set at scene 407*cdf0e10cSrcweir pScene->SetCamera(aCam); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir // #91047# use imported VRP, VPN and VUP (if used) 410*cdf0e10cSrcweir sal_Bool bVRPUsed(!aVRP.equal(basegfx::B3DPoint(0.0, 0.0, 1.0))); 411*cdf0e10cSrcweir sal_Bool bVPNUsed(!aVPN.equal(basegfx::B3DVector(0.0, 0.0, 1.0))); 412*cdf0e10cSrcweir sal_Bool bVUPUsed(!aVUP.equal(basegfx::B3DVector(0.0, 1.0, 0.0))); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir if(bVRPUsed || bVPNUsed || bVUPUsed) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir pScene->GetCameraSet().SetViewportValues(aVRP, aVPN, aVUP); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir // set object transformations again at objects 420*cdf0e10cSrcweir aIter.Reset(); 421*cdf0e10cSrcweir sal_uInt32 nIndex(0L); 422*cdf0e10cSrcweir while(aIter.IsMore()) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir E3dObject* p3DObj = (E3dObject*)aIter.Next(); 425*cdf0e10cSrcweir basegfx::B3DHomMatrix* pMat = (basegfx::B3DHomMatrix*)aObjTrans.GetObject(nIndex++); 426*cdf0e10cSrcweir p3DObj->NbcSetTransform(*pMat); 427*cdf0e10cSrcweir delete pMat; 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir // set scene transformation again at scene 431*cdf0e10cSrcweir pScene->NbcSetTransform(aSceneTAR.maMat); 432*cdf0e10cSrcweir pScene->NbcSetSnapRect(aSceneTAR.maRect); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir return true; 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir break; 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir default: 439*cdf0e10cSrcweir return SvxShape::setPropertyValueImpl(rName, pProperty, rValue); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir throw IllegalArgumentException(); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir //---------------------------------------------------------------------- 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir bool Svx3DSceneObject::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) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir switch( pProperty->nWID ) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir // Objekt in eine homogene 4x4 Matrix packen 454*cdf0e10cSrcweir ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); 455*cdf0e10cSrcweir break; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY: 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir // get CameraGeometry from scene 460*cdf0e10cSrcweir E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() ); 461*cdf0e10cSrcweir drawing::CameraGeometry aCamGeo; 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir // fill Vectors from scene camera 464*cdf0e10cSrcweir B3dCamera& aCameraSet = pScene->GetCameraSet(); 465*cdf0e10cSrcweir basegfx::B3DPoint aVRP(aCameraSet.GetVRP()); 466*cdf0e10cSrcweir basegfx::B3DVector aVPN(aCameraSet.GetVPN()); 467*cdf0e10cSrcweir basegfx::B3DVector aVUP(aCameraSet.GetVUV()); 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir // transfer to structure 470*cdf0e10cSrcweir aCamGeo.vrp.PositionX = aVRP.getX(); 471*cdf0e10cSrcweir aCamGeo.vrp.PositionY = aVRP.getY(); 472*cdf0e10cSrcweir aCamGeo.vrp.PositionZ = aVRP.getZ(); 473*cdf0e10cSrcweir aCamGeo.vpn.DirectionX = aVPN.getX(); 474*cdf0e10cSrcweir aCamGeo.vpn.DirectionY = aVPN.getY(); 475*cdf0e10cSrcweir aCamGeo.vpn.DirectionZ = aVPN.getZ(); 476*cdf0e10cSrcweir aCamGeo.vup.DirectionX = aVUP.getX(); 477*cdf0e10cSrcweir aCamGeo.vup.DirectionY = aVUP.getY(); 478*cdf0e10cSrcweir aCamGeo.vup.DirectionZ = aVUP.getZ(); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir rValue <<= aCamGeo; 481*cdf0e10cSrcweir break; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir default: 484*cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir return true; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 491*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL Svx3DSceneObject::getSupportedServiceNames() 492*cdf0e10cSrcweir throw(uno::RuntimeException) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); 495*cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.Shape3DScene" ); 496*cdf0e10cSrcweir return aSeq; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir /*********************************************************************** 500*cdf0e10cSrcweir * * 501*cdf0e10cSrcweir ***********************************************************************/ 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir //---------------------------------------------------------------------- 504*cdf0e10cSrcweir Svx3DCubeObject::Svx3DCubeObject( SdrObject* pObj ) throw() 505*cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DCUBEOBJEKT), aSvxMapProvider.GetPropertySet(SVXMAP_3DCUBEOBJEKT, SdrObject::GetGlobalDrawObjectItemPool()) ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir //---------------------------------------------------------------------- 510*cdf0e10cSrcweir Svx3DCubeObject::~Svx3DCubeObject() throw() 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir //---------------------------------------------------------------------- 515*cdf0e10cSrcweir bool Svx3DCubeObject::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) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir switch( pProperty->nWID ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir // Transformationsmatrix in das Objekt packen 524*cdf0e10cSrcweir if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) 525*cdf0e10cSrcweir return true; 526*cdf0e10cSrcweir break; 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POSITION: 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir // Position in das Objekt packen 531*cdf0e10cSrcweir drawing::Position3D aUnoPos; 532*cdf0e10cSrcweir if( rValue >>= aUnoPos ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ); 535*cdf0e10cSrcweir static_cast< E3dCubeObj* >( mpObj.get() )->SetCubePos(aPos); 536*cdf0e10cSrcweir return true; 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir break; 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_SIZE: 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir // Groesse in das Objekt packen 543*cdf0e10cSrcweir drawing::Direction3D aDirection; 544*cdf0e10cSrcweir if( rValue >>= aDirection ) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir basegfx::B3DVector aSize(aDirection.DirectionX, aDirection.DirectionY, aDirection.DirectionZ); 547*cdf0e10cSrcweir static_cast< E3dCubeObj* >( mpObj.get() )->SetCubeSize(aSize); 548*cdf0e10cSrcweir return true; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir break; 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POS_IS_CENTER: 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir sal_Bool bNew = sal_False; 555*cdf0e10cSrcweir // sal_Bool bPosIsCenter in das Objekt packen 556*cdf0e10cSrcweir if( rValue >>= bNew ) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir static_cast< E3dCubeObj* >( mpObj.get() )->SetPosIsCenter(bNew); 559*cdf0e10cSrcweir return true; 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir break; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir default: 564*cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir throw IllegalArgumentException(); 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir //---------------------------------------------------------------------- 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir bool Svx3DCubeObject::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) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir switch( pProperty->nWID ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir // Transformation in eine homogene Matrix packen 579*cdf0e10cSrcweir ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); 580*cdf0e10cSrcweir break; 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POSITION: 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir // Position packen 585*cdf0e10cSrcweir const basegfx::B3DPoint& rPos = ((E3dCubeObj*)mpObj.get())->GetCubePos(); 586*cdf0e10cSrcweir drawing::Position3D aPos; 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir aPos.PositionX = rPos.getX(); 589*cdf0e10cSrcweir aPos.PositionY = rPos.getY(); 590*cdf0e10cSrcweir aPos.PositionZ = rPos.getZ(); 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir rValue <<= aPos; 593*cdf0e10cSrcweir break; 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_SIZE: 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir // Groesse packen 598*cdf0e10cSrcweir const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(mpObj.get())->GetCubeSize(); 599*cdf0e10cSrcweir drawing::Direction3D aDir; 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir aDir.DirectionX = rSize.getX(); 602*cdf0e10cSrcweir aDir.DirectionY = rSize.getY(); 603*cdf0e10cSrcweir aDir.DirectionZ = rSize.getZ(); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir rValue <<= aDir; 606*cdf0e10cSrcweir break; 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POS_IS_CENTER: 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir rValue <<= static_cast<E3dCubeObj*>(mpObj.get())->GetPosIsCenter(); 611*cdf0e10cSrcweir break; 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir default: 614*cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 615*cdf0e10cSrcweir } 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir return true; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 621*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL Svx3DCubeObject::getSupportedServiceNames() 622*cdf0e10cSrcweir throw(uno::RuntimeException) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); 625*cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", 626*cdf0e10cSrcweir "com.sun.star.drawing.Shape3DCube"); 627*cdf0e10cSrcweir return aSeq; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir /*********************************************************************** 631*cdf0e10cSrcweir * * 632*cdf0e10cSrcweir ***********************************************************************/ 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir //---------------------------------------------------------------------- 635*cdf0e10cSrcweir Svx3DSphereObject::Svx3DSphereObject( SdrObject* pObj ) throw() 636*cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DSPHEREOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DSPHEREOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir //---------------------------------------------------------------------- 641*cdf0e10cSrcweir Svx3DSphereObject::~Svx3DSphereObject() throw() 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir //---------------------------------------------------------------------- 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir bool Svx3DSphereObject::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) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir switch( pProperty->nWID ) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir // Transformationsmatrix in das Objekt packen 654*cdf0e10cSrcweir if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) 655*cdf0e10cSrcweir return true; 656*cdf0e10cSrcweir break; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POSITION: 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir // Position in das Objekt packen 662*cdf0e10cSrcweir drawing::Position3D aUnoPos; 663*cdf0e10cSrcweir if( rValue >>= aUnoPos ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ); 666*cdf0e10cSrcweir static_cast<E3dSphereObj*>(mpObj.get())->SetCenter(aPos); 667*cdf0e10cSrcweir return true; 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir break; 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_SIZE: 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir // Groesse in das Objekt packen 675*cdf0e10cSrcweir drawing::Direction3D aDir; 676*cdf0e10cSrcweir if( rValue >>= aDir ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir basegfx::B3DVector aPos(aDir.DirectionX, aDir.DirectionY, aDir.DirectionZ); 679*cdf0e10cSrcweir static_cast<E3dSphereObj*>(mpObj.get())->SetSize(aPos); 680*cdf0e10cSrcweir return true; 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir break; 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir default: 685*cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir throw IllegalArgumentException(); 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir //---------------------------------------------------------------------- 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir bool Svx3DSphereObject::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) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir switch( pProperty->nWID ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir // Transformation in eine homogene Matrix packen 700*cdf0e10cSrcweir ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); 701*cdf0e10cSrcweir break; 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POSITION: 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir // Position packen 706*cdf0e10cSrcweir const basegfx::B3DPoint& rPos = ((E3dSphereObj*)mpObj.get())->Center(); 707*cdf0e10cSrcweir drawing::Position3D aPos; 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir aPos.PositionX = rPos.getX(); 710*cdf0e10cSrcweir aPos.PositionY = rPos.getY(); 711*cdf0e10cSrcweir aPos.PositionZ = rPos.getZ(); 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir rValue <<= aPos; 714*cdf0e10cSrcweir break; 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_SIZE: 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir // Groesse packen 719*cdf0e10cSrcweir const basegfx::B3DVector& rSize = ((E3dSphereObj*)mpObj.get())->Size(); 720*cdf0e10cSrcweir drawing::Direction3D aDir; 721*cdf0e10cSrcweir 722*cdf0e10cSrcweir aDir.DirectionX = rSize.getX(); 723*cdf0e10cSrcweir aDir.DirectionY = rSize.getY(); 724*cdf0e10cSrcweir aDir.DirectionZ = rSize.getZ(); 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir rValue <<= aDir; 727*cdf0e10cSrcweir break; 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir default: 730*cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir return true; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 737*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL Svx3DSphereObject::getSupportedServiceNames() 738*cdf0e10cSrcweir throw(uno::RuntimeException) 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); 741*cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", 742*cdf0e10cSrcweir "com.sun.star.drawing.Shape3DSphere"); 743*cdf0e10cSrcweir return aSeq; 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir /*********************************************************************** 747*cdf0e10cSrcweir * * 748*cdf0e10cSrcweir ***********************************************************************/ 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir //---------------------------------------------------------------------- 751*cdf0e10cSrcweir Svx3DLatheObject::Svx3DLatheObject( SdrObject* pObj ) throw() 752*cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DLATHEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DLATHEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir //---------------------------------------------------------------------- 757*cdf0e10cSrcweir Svx3DLatheObject::~Svx3DLatheObject() throw() 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir bool PolyPolygonShape3D_to_B3dPolyPolygon( 762*cdf0e10cSrcweir const Any& rValue, 763*cdf0e10cSrcweir basegfx::B3DPolyPolygon& rResultPolygon, 764*cdf0e10cSrcweir bool bCorrectPolygon) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir drawing::PolyPolygonShape3D aSourcePolyPolygon; 767*cdf0e10cSrcweir if( !(rValue >>= aSourcePolyPolygon) ) 768*cdf0e10cSrcweir return false; 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir sal_Int32 nOuterSequenceCount = aSourcePolyPolygon.SequenceX.getLength(); 771*cdf0e10cSrcweir if(nOuterSequenceCount != aSourcePolyPolygon.SequenceY.getLength() || nOuterSequenceCount != aSourcePolyPolygon.SequenceZ.getLength()) 772*cdf0e10cSrcweir return false; 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir drawing::DoubleSequence* pInnerSequenceX = aSourcePolyPolygon.SequenceX.getArray(); 775*cdf0e10cSrcweir drawing::DoubleSequence* pInnerSequenceY = aSourcePolyPolygon.SequenceY.getArray(); 776*cdf0e10cSrcweir drawing::DoubleSequence* pInnerSequenceZ = aSourcePolyPolygon.SequenceZ.getArray(); 777*cdf0e10cSrcweir for(sal_Int32 a(0L);a<nOuterSequenceCount;a++) 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir sal_Int32 nInnerSequenceCount = pInnerSequenceX->getLength(); 780*cdf0e10cSrcweir if(nInnerSequenceCount != pInnerSequenceY->getLength() || nInnerSequenceCount != pInnerSequenceZ->getLength()) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir return false; 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir basegfx::B3DPolygon aNewPolygon; 785*cdf0e10cSrcweir double* pArrayX = pInnerSequenceX->getArray(); 786*cdf0e10cSrcweir double* pArrayY = pInnerSequenceY->getArray(); 787*cdf0e10cSrcweir double* pArrayZ = pInnerSequenceZ->getArray(); 788*cdf0e10cSrcweir for(sal_Int32 b(0L);b<nInnerSequenceCount;b++) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir aNewPolygon.append(basegfx::B3DPoint(*pArrayX++,*pArrayY++,*pArrayZ++)); 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir pInnerSequenceX++; 793*cdf0e10cSrcweir pInnerSequenceY++; 794*cdf0e10cSrcweir pInnerSequenceZ++; 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir // #i101520# correction is needed for imported polygons of old format, 797*cdf0e10cSrcweir // see callers 798*cdf0e10cSrcweir if(bCorrectPolygon) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir basegfx::tools::checkClosed(aNewPolygon); 801*cdf0e10cSrcweir } 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir rResultPolygon.append(aNewPolygon); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir return true; 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir static void B3dPolyPolygon_to_PolyPolygonShape3D( const basegfx::B3DPolyPolygon& rSourcePolyPolygon, Any& rValue ) 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir drawing::PolyPolygonShape3D aRetval; 811*cdf0e10cSrcweir aRetval.SequenceX.realloc(rSourcePolyPolygon.count()); 812*cdf0e10cSrcweir aRetval.SequenceY.realloc(rSourcePolyPolygon.count()); 813*cdf0e10cSrcweir aRetval.SequenceZ.realloc(rSourcePolyPolygon.count()); 814*cdf0e10cSrcweir drawing::DoubleSequence* pOuterSequenceX = aRetval.SequenceX.getArray(); 815*cdf0e10cSrcweir drawing::DoubleSequence* pOuterSequenceY = aRetval.SequenceY.getArray(); 816*cdf0e10cSrcweir drawing::DoubleSequence* pOuterSequenceZ = aRetval.SequenceZ.getArray(); 817*cdf0e10cSrcweir for(sal_uInt32 a(0L);a<rSourcePolyPolygon.count();a++) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir const basegfx::B3DPolygon aPoly(rSourcePolyPolygon.getB3DPolygon(a)); 820*cdf0e10cSrcweir sal_Int32 nPointCount(aPoly.count()); 821*cdf0e10cSrcweir if(aPoly.isClosed()) nPointCount++; 822*cdf0e10cSrcweir pOuterSequenceX->realloc(nPointCount); 823*cdf0e10cSrcweir pOuterSequenceY->realloc(nPointCount); 824*cdf0e10cSrcweir pOuterSequenceZ->realloc(nPointCount); 825*cdf0e10cSrcweir double* pInnerSequenceX = pOuterSequenceX->getArray(); 826*cdf0e10cSrcweir double* pInnerSequenceY = pOuterSequenceY->getArray(); 827*cdf0e10cSrcweir double* pInnerSequenceZ = pOuterSequenceZ->getArray(); 828*cdf0e10cSrcweir for(sal_uInt32 b(0L);b<aPoly.count();b++) 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(b)); 831*cdf0e10cSrcweir *pInnerSequenceX++ = aPoint.getX(); 832*cdf0e10cSrcweir *pInnerSequenceY++ = aPoint.getY(); 833*cdf0e10cSrcweir *pInnerSequenceZ++ = aPoint.getZ(); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir if(aPoly.isClosed()) 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(0L)); 838*cdf0e10cSrcweir *pInnerSequenceX++ = aPoint.getX(); 839*cdf0e10cSrcweir *pInnerSequenceY++ = aPoint.getY(); 840*cdf0e10cSrcweir *pInnerSequenceZ++ = aPoint.getZ(); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir pOuterSequenceX++; 843*cdf0e10cSrcweir pOuterSequenceY++; 844*cdf0e10cSrcweir pOuterSequenceZ++; 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir rValue <<= aRetval; 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir //---------------------------------------------------------------------- 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir bool Svx3DLatheObject::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) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir switch( pProperty->nWID ) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 856*cdf0e10cSrcweir { 857*cdf0e10cSrcweir // Transformationsmatrix in das Objekt packen 858*cdf0e10cSrcweir if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) 859*cdf0e10cSrcweir return true; 860*cdf0e10cSrcweir break; 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir // Polygondefinition in das Objekt packen 865*cdf0e10cSrcweir basegfx::B3DPolyPolygon aNewB3DPolyPolygon; 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir // #i101520# Probably imported 868*cdf0e10cSrcweir if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir // #105127# SetPolyPoly3D sets the Svx3DVerticalSegmentsItem to the number 871*cdf0e10cSrcweir // of points of the polygon. Thus, value gets lost. To avoid this, rescue 872*cdf0e10cSrcweir // item here and re-set after setting the polygon. 873*cdf0e10cSrcweir const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments()); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir // Polygon setzen 876*cdf0e10cSrcweir const basegfx::B3DHomMatrix aIdentity; 877*cdf0e10cSrcweir const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); 878*cdf0e10cSrcweir static_cast<E3dLatheObj*>(mpObj.get())->SetPolyPoly2D(aB2DPolyPolygon); 879*cdf0e10cSrcweir const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments()); 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir if(nPrevVerticalSegs != nPostVerticalSegs) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir // restore the vertical segment count 884*cdf0e10cSrcweir static_cast<E3dLatheObj*>(mpObj.get())->SetMergedItem(Svx3DVerticalSegmentsItem(nPrevVerticalSegs)); 885*cdf0e10cSrcweir } 886*cdf0e10cSrcweir return true; 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir break; 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir default: 891*cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 892*cdf0e10cSrcweir } 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir throw IllegalArgumentException(); 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir //---------------------------------------------------------------------- 898*cdf0e10cSrcweir bool Svx3DLatheObject::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) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir switch( pProperty->nWID ) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 903*cdf0e10cSrcweir { 904*cdf0e10cSrcweir // Transformation in eine homogene Matrix packen 905*cdf0e10cSrcweir drawing::HomogenMatrix aHomMat; 906*cdf0e10cSrcweir basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform(); 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir // pack evtl. transformed matrix to output 909*cdf0e10cSrcweir aHomMat.Line1.Column1 = aMat.get(0, 0); 910*cdf0e10cSrcweir aHomMat.Line1.Column2 = aMat.get(0, 1); 911*cdf0e10cSrcweir aHomMat.Line1.Column3 = aMat.get(0, 2); 912*cdf0e10cSrcweir aHomMat.Line1.Column4 = aMat.get(0, 3); 913*cdf0e10cSrcweir aHomMat.Line2.Column1 = aMat.get(1, 0); 914*cdf0e10cSrcweir aHomMat.Line2.Column2 = aMat.get(1, 1); 915*cdf0e10cSrcweir aHomMat.Line2.Column3 = aMat.get(1, 2); 916*cdf0e10cSrcweir aHomMat.Line2.Column4 = aMat.get(1, 3); 917*cdf0e10cSrcweir aHomMat.Line3.Column1 = aMat.get(2, 0); 918*cdf0e10cSrcweir aHomMat.Line3.Column2 = aMat.get(2, 1); 919*cdf0e10cSrcweir aHomMat.Line3.Column3 = aMat.get(2, 2); 920*cdf0e10cSrcweir aHomMat.Line3.Column4 = aMat.get(2, 3); 921*cdf0e10cSrcweir aHomMat.Line4.Column1 = aMat.get(3, 0); 922*cdf0e10cSrcweir aHomMat.Line4.Column2 = aMat.get(3, 1); 923*cdf0e10cSrcweir aHomMat.Line4.Column3 = aMat.get(3, 2); 924*cdf0e10cSrcweir aHomMat.Line4.Column4 = aMat.get(3, 3); 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir rValue <<= aHomMat; 927*cdf0e10cSrcweir break; 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(mpObj.get())->GetPolyPoly2D(); 932*cdf0e10cSrcweir const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue); 935*cdf0e10cSrcweir break; 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir default: 938*cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir return true; 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 945*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL Svx3DLatheObject::getSupportedServiceNames() 946*cdf0e10cSrcweir throw(uno::RuntimeException) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); 949*cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", 950*cdf0e10cSrcweir "com.sun.star.drawing.Shape3DLathe"); 951*cdf0e10cSrcweir return aSeq; 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir /*********************************************************************** 955*cdf0e10cSrcweir * * 956*cdf0e10cSrcweir ***********************************************************************/ 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir Svx3DExtrudeObject::Svx3DExtrudeObject( SdrObject* pObj ) throw() 959*cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DEXTRUDEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DEXTRUDEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir //---------------------------------------------------------------------- 964*cdf0e10cSrcweir Svx3DExtrudeObject::~Svx3DExtrudeObject() throw() 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir //---------------------------------------------------------------------- 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir bool Svx3DExtrudeObject::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) 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir switch( pProperty->nWID ) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 975*cdf0e10cSrcweir { 976*cdf0e10cSrcweir // Transformationsmatrix in das Objekt packen 977*cdf0e10cSrcweir if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) 978*cdf0e10cSrcweir return true; 979*cdf0e10cSrcweir break; 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: 983*cdf0e10cSrcweir { 984*cdf0e10cSrcweir // Polygondefinition in das Objekt packen 985*cdf0e10cSrcweir basegfx::B3DPolyPolygon aNewB3DPolyPolygon; 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir // #i101520# Probably imported 988*cdf0e10cSrcweir if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) ) 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir // Polygon setzen 991*cdf0e10cSrcweir const basegfx::B3DHomMatrix aIdentity; 992*cdf0e10cSrcweir const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); 993*cdf0e10cSrcweir static_cast<E3dExtrudeObj*>(mpObj.get())->SetExtrudePolygon(aB2DPolyPolygon); 994*cdf0e10cSrcweir return true; 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir break; 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir default: 999*cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir throw IllegalArgumentException(); 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir //---------------------------------------------------------------------- 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir bool Svx3DExtrudeObject::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) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir switch( pProperty->nWID ) 1010*cdf0e10cSrcweir { 1011*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir // Transformation in eine homogene Matrix packen 1014*cdf0e10cSrcweir drawing::HomogenMatrix aHomMat; 1015*cdf0e10cSrcweir basegfx::B3DHomMatrix aMat = ((E3dObject*)mpObj.get())->GetTransform(); 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir // pack evtl. transformed matrix to output 1018*cdf0e10cSrcweir aHomMat.Line1.Column1 = aMat.get(0, 0); 1019*cdf0e10cSrcweir aHomMat.Line1.Column2 = aMat.get(0, 1); 1020*cdf0e10cSrcweir aHomMat.Line1.Column3 = aMat.get(0, 2); 1021*cdf0e10cSrcweir aHomMat.Line1.Column4 = aMat.get(0, 3); 1022*cdf0e10cSrcweir aHomMat.Line2.Column1 = aMat.get(1, 0); 1023*cdf0e10cSrcweir aHomMat.Line2.Column2 = aMat.get(1, 1); 1024*cdf0e10cSrcweir aHomMat.Line2.Column3 = aMat.get(1, 2); 1025*cdf0e10cSrcweir aHomMat.Line2.Column4 = aMat.get(1, 3); 1026*cdf0e10cSrcweir aHomMat.Line3.Column1 = aMat.get(2, 0); 1027*cdf0e10cSrcweir aHomMat.Line3.Column2 = aMat.get(2, 1); 1028*cdf0e10cSrcweir aHomMat.Line3.Column3 = aMat.get(2, 2); 1029*cdf0e10cSrcweir aHomMat.Line3.Column4 = aMat.get(2, 3); 1030*cdf0e10cSrcweir aHomMat.Line4.Column1 = aMat.get(3, 0); 1031*cdf0e10cSrcweir aHomMat.Line4.Column2 = aMat.get(3, 1); 1032*cdf0e10cSrcweir aHomMat.Line4.Column3 = aMat.get(3, 2); 1033*cdf0e10cSrcweir aHomMat.Line4.Column4 = aMat.get(3, 3); 1034*cdf0e10cSrcweir 1035*cdf0e10cSrcweir rValue <<= aHomMat; 1036*cdf0e10cSrcweir break; 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir 1039*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: 1040*cdf0e10cSrcweir { 1041*cdf0e10cSrcweir // Polygondefinition packen 1042*cdf0e10cSrcweir const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(mpObj.get())->GetExtrudePolygon(); 1043*cdf0e10cSrcweir const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); 1044*cdf0e10cSrcweir 1045*cdf0e10cSrcweir B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue); 1046*cdf0e10cSrcweir break; 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir default: 1049*cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweir return true; 1053*cdf0e10cSrcweir } 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 1056*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL Svx3DExtrudeObject::getSupportedServiceNames() 1057*cdf0e10cSrcweir throw(uno::RuntimeException) 1058*cdf0e10cSrcweir { 1059*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); 1060*cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", 1061*cdf0e10cSrcweir "com.sun.star.drawing.Shape3DExtrude"); 1062*cdf0e10cSrcweir return aSeq; 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir /*********************************************************************** 1066*cdf0e10cSrcweir * * 1067*cdf0e10cSrcweir ***********************************************************************/ 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir //---------------------------------------------------------------------- 1070*cdf0e10cSrcweir Svx3DPolygonObject::Svx3DPolygonObject( SdrObject* pObj ) throw() 1071*cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DPOLYGONOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DPOLYGONOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) 1072*cdf0e10cSrcweir { 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir //---------------------------------------------------------------------- 1076*cdf0e10cSrcweir Svx3DPolygonObject::~Svx3DPolygonObject() throw() 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir } 1079*cdf0e10cSrcweir 1080*cdf0e10cSrcweir //---------------------------------------------------------------------- 1081*cdf0e10cSrcweir bool Svx3DPolygonObject::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) 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir switch( pProperty->nWID ) 1084*cdf0e10cSrcweir { 1085*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir // Transformationsmatrix in das Objekt packen 1088*cdf0e10cSrcweir if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) 1089*cdf0e10cSrcweir return true; 1090*cdf0e10cSrcweir break; 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir // Polygondefinition in das Objekt packen 1096*cdf0e10cSrcweir basegfx::B3DPolyPolygon aNewB3DPolyPolygon; 1097*cdf0e10cSrcweir 1098*cdf0e10cSrcweir // #i101520# Direct API data (e.g. from chart) 1099*cdf0e10cSrcweir if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) 1100*cdf0e10cSrcweir { 1101*cdf0e10cSrcweir // Polygon setzen 1102*cdf0e10cSrcweir static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyPolygon3D(aNewB3DPolyPolygon); 1103*cdf0e10cSrcweir return true; 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir break; 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D: 1108*cdf0e10cSrcweir { 1109*cdf0e10cSrcweir // Normalendefinition in das Objekt packen 1110*cdf0e10cSrcweir basegfx::B3DPolyPolygon aNewB3DPolyPolygon; 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir // #i101520# Direct API data (e.g. from chart) 1113*cdf0e10cSrcweir if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) 1114*cdf0e10cSrcweir { 1115*cdf0e10cSrcweir // Polygon setzen 1116*cdf0e10cSrcweir static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyNormals3D(aNewB3DPolyPolygon); 1117*cdf0e10cSrcweir return true; 1118*cdf0e10cSrcweir } 1119*cdf0e10cSrcweir break; 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D: 1122*cdf0e10cSrcweir { 1123*cdf0e10cSrcweir // Texturdefinition in das Objekt packen 1124*cdf0e10cSrcweir basegfx::B3DPolyPolygon aNewB3DPolyPolygon; 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir // #i101520# Direct API data (e.g. from chart) 1127*cdf0e10cSrcweir if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir // Polygon setzen 1130*cdf0e10cSrcweir const basegfx::B3DHomMatrix aIdentity; 1131*cdf0e10cSrcweir const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); 1132*cdf0e10cSrcweir static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyTexture2D(aB2DPolyPolygon); 1133*cdf0e10cSrcweir return true; 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir break; 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_LINEONLY: 1138*cdf0e10cSrcweir { 1139*cdf0e10cSrcweir sal_Bool bNew = sal_False; 1140*cdf0e10cSrcweir if( rValue >>= bNew ) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir static_cast<E3dPolygonObj*>(mpObj.get())->SetLineOnly(bNew); 1143*cdf0e10cSrcweir return true; 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir break; 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir default: 1148*cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 1149*cdf0e10cSrcweir } 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir throw IllegalArgumentException(); 1152*cdf0e10cSrcweir } 1153*cdf0e10cSrcweir 1154*cdf0e10cSrcweir //---------------------------------------------------------------------- 1155*cdf0e10cSrcweir bool Svx3DPolygonObject::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) 1156*cdf0e10cSrcweir { 1157*cdf0e10cSrcweir switch( pProperty->nWID ) 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); 1162*cdf0e10cSrcweir break; 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: 1166*cdf0e10cSrcweir { 1167*cdf0e10cSrcweir B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyPolygon3D(),rValue); 1168*cdf0e10cSrcweir break; 1169*cdf0e10cSrcweir } 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D: 1172*cdf0e10cSrcweir { 1173*cdf0e10cSrcweir B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyNormals3D(),rValue); 1174*cdf0e10cSrcweir break; 1175*cdf0e10cSrcweir } 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D: 1178*cdf0e10cSrcweir { 1179*cdf0e10cSrcweir // Texturdefinition packen 1180*cdf0e10cSrcweir const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyTexture2D(); 1181*cdf0e10cSrcweir const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon,rValue); 1184*cdf0e10cSrcweir break; 1185*cdf0e10cSrcweir } 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir case OWN_ATTR_3D_VALUE_LINEONLY: 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir rValue <<= (sal_Bool)static_cast<E3dPolygonObj*>(mpObj.get())->GetLineOnly(); 1190*cdf0e10cSrcweir break; 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir default: 1194*cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 1195*cdf0e10cSrcweir } 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir return true; 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 1201*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL Svx3DPolygonObject::getSupportedServiceNames() 1202*cdf0e10cSrcweir throw(uno::RuntimeException) 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); 1205*cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", 1206*cdf0e10cSrcweir "com.sun.star.drawing.Shape3DPolygon"); 1207*cdf0e10cSrcweir return aSeq; 1208*cdf0e10cSrcweir } 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir // eof 1211