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