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