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