LCOV - code coverage report
Current view: top level - svx/source/unodraw - unoshap3.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 547 0.0 %
Date: 2014-04-14 Functions: 0 55 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10