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