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