1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir #include <comphelper/extract.hxx>
31*cdf0e10cSrcweir #include "ximp3dobject.hxx"
32*cdf0e10cSrcweir #include <xmloff/XMLShapeStyleContext.hxx>
33*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp>
37*cdf0e10cSrcweir #include "xexptran.hxx"
38*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
39*cdf0e10cSrcweir #include <xmloff/families.hxx>
40*cdf0e10cSrcweir #include "ximpstyl.hxx"
41*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
42*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/drawing/DoubleSequence.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using ::rtl::OUString;
46*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir using namespace ::com::sun::star;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
51*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir TYPEINIT1( SdXML3DObjectContext, SdXMLShapeContext );
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir SdXML3DObjectContext::SdXML3DObjectContext(
56*cdf0e10cSrcweir 	SvXMLImport& rImport,
57*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
58*cdf0e10cSrcweir 	const OUString& rLocalName,
59*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
60*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
61*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
62*cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
63*cdf0e10cSrcweir 	mbSetTransform( sal_False )
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
66*cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
67*cdf0e10cSrcweir 	{
68*cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
69*cdf0e10cSrcweir 		OUString aLocalName;
70*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
71*cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
72*cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DObjectAttrTokenMap();
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
75*cdf0e10cSrcweir 		{
76*cdf0e10cSrcweir 			case XML_TOK_3DOBJECT_DRAWSTYLE_NAME:
77*cdf0e10cSrcweir 			{
78*cdf0e10cSrcweir 				maDrawStyleName = sValue;
79*cdf0e10cSrcweir 				break;
80*cdf0e10cSrcweir 			}
81*cdf0e10cSrcweir 			case XML_TOK_3DOBJECT_TRANSFORM:
82*cdf0e10cSrcweir 			{
83*cdf0e10cSrcweir 				SdXMLImExTransform3D aTransform(sValue, GetImport().GetMM100UnitConverter());
84*cdf0e10cSrcweir 				if(aTransform.NeedsAction())
85*cdf0e10cSrcweir 					mbSetTransform = aTransform.GetFullHomogenTransform(mxHomMat);
86*cdf0e10cSrcweir 				break;
87*cdf0e10cSrcweir 			}
88*cdf0e10cSrcweir 		}
89*cdf0e10cSrcweir 	}
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir SdXML3DObjectContext::~SdXML3DObjectContext()
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir void SdXML3DObjectContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
103*cdf0e10cSrcweir 	if(xPropSet.is())
104*cdf0e10cSrcweir 	{
105*cdf0e10cSrcweir 		// set parameters
106*cdf0e10cSrcweir 		if(mbSetTransform)
107*cdf0e10cSrcweir 		{
108*cdf0e10cSrcweir 			uno::Any aAny;
109*cdf0e10cSrcweir 			aAny <<= mxHomMat;
110*cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")), aAny);
111*cdf0e10cSrcweir 		}
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 		// call parent
114*cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
115*cdf0e10cSrcweir 	}
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir void SdXML3DObjectContext::EndElement()
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir 	// call parent
123*cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
127*cdf0e10cSrcweir /*
128*cdf0e10cSrcweir void SdXML3DObjectContext::AddShape(uno::Reference< drawing::XShape >& xShape)
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	if(xShape.is() && mxShapes.is())
131*cdf0e10cSrcweir 	{
132*cdf0e10cSrcweir 		// set shape local
133*cdf0e10cSrcweir 		mxShape = xShape;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 		// add new shape to parent
136*cdf0e10cSrcweir 		mxShapes->add( xShape );
137*cdf0e10cSrcweir 	}
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir */
140*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
141*cdf0e10cSrcweir /*
142*cdf0e10cSrcweir void SdXML3DObjectContext::SetStyle()
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	// set style on shape
145*cdf0e10cSrcweir 	if(maDrawStyleName.getLength() && mxShape.is())
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		const SvXMLStyleContext* pStyle = 0L;
148*cdf0e10cSrcweir 		sal_Bool bAutoStyle(sal_False);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 		if(GetImport().GetShapeImport()->GetAutoStylesContext())
151*cdf0e10cSrcweir 			pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(
152*cdf0e10cSrcweir 			XML_STYLE_FAMILY_SD_GRAPHICS_ID, maDrawStyleName);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 		if(pStyle)
155*cdf0e10cSrcweir 			bAutoStyle = sal_True;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 		if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
158*cdf0e10cSrcweir 			pStyle = GetImport().GetShapeImport()->GetStylesContext()->
159*cdf0e10cSrcweir 			FindStyleChildContext(XML_STYLE_FAMILY_SD_GRAPHICS_ID, maDrawStyleName);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 		if(pStyle && pStyle->ISA(XMLShapeStyleContext))
162*cdf0e10cSrcweir 		{
163*cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
164*cdf0e10cSrcweir 			if(xPropSet.is())
165*cdf0e10cSrcweir 			{
166*cdf0e10cSrcweir 				XMLShapeStyleContext* pDocStyle = (XMLShapeStyleContext*)pStyle;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 				if(pDocStyle->GetStyle().is())
169*cdf0e10cSrcweir 				{
170*cdf0e10cSrcweir 					// set style on object
171*cdf0e10cSrcweir 					uno::Any aAny;
172*cdf0e10cSrcweir 					aAny <<= pDocStyle->GetStyle();
173*cdf0e10cSrcweir 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style")), aAny);
174*cdf0e10cSrcweir 				}
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 				if(bAutoStyle)
177*cdf0e10cSrcweir 				{
178*cdf0e10cSrcweir 					// set PropertySet on object
179*cdf0e10cSrcweir 					pDocStyle->FillPropertySet(xPropSet);
180*cdf0e10cSrcweir 				}
181*cdf0e10cSrcweir 			}
182*cdf0e10cSrcweir 		}
183*cdf0e10cSrcweir 	}
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir */
186*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
187*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir TYPEINIT1( SdXML3DCubeObjectShapeContext, SdXML3DObjectContext);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir SdXML3DCubeObjectShapeContext::SdXML3DCubeObjectShapeContext(
192*cdf0e10cSrcweir 	SvXMLImport& rImport,
193*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
194*cdf0e10cSrcweir 	const OUString& rLocalName,
195*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
196*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
197*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
198*cdf0e10cSrcweir :	SdXML3DObjectContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
199*cdf0e10cSrcweir 	maMinEdge(-2500.0, -2500.0, -2500.0),
200*cdf0e10cSrcweir 	maMaxEdge(2500.0, 2500.0, 2500.0),
201*cdf0e10cSrcweir 	mbMinEdgeUsed(sal_False),
202*cdf0e10cSrcweir 	mbMaxEdgeUsed(sal_False)
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
205*cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
206*cdf0e10cSrcweir 	{
207*cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
208*cdf0e10cSrcweir 		OUString aLocalName;
209*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
210*cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
211*cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DCubeObjectAttrTokenMap();
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
214*cdf0e10cSrcweir 		{
215*cdf0e10cSrcweir 			case XML_TOK_3DCUBEOBJ_MINEDGE:
216*cdf0e10cSrcweir 			{
217*cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
218*cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 				if(aNewVec != maMinEdge)
221*cdf0e10cSrcweir 				{
222*cdf0e10cSrcweir 					maMinEdge = aNewVec;
223*cdf0e10cSrcweir 					mbMinEdgeUsed = sal_True;
224*cdf0e10cSrcweir 				}
225*cdf0e10cSrcweir 				break;
226*cdf0e10cSrcweir 			}
227*cdf0e10cSrcweir 			case XML_TOK_3DCUBEOBJ_MAXEDGE:
228*cdf0e10cSrcweir 			{
229*cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
230*cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 				if(aNewVec != maMaxEdge)
233*cdf0e10cSrcweir 				{
234*cdf0e10cSrcweir 					maMaxEdge = aNewVec;
235*cdf0e10cSrcweir 					mbMaxEdgeUsed = sal_True;
236*cdf0e10cSrcweir 				}
237*cdf0e10cSrcweir 				break;
238*cdf0e10cSrcweir 			}
239*cdf0e10cSrcweir 		}
240*cdf0e10cSrcweir 	}
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir SdXML3DCubeObjectShapeContext::~SdXML3DCubeObjectShapeContext()
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir void SdXML3DCubeObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir 	// create shape
254*cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DCubeObject" );
255*cdf0e10cSrcweir 	if(mxShape.is())
256*cdf0e10cSrcweir 	{
257*cdf0e10cSrcweir 		// add, set style and properties from base shape
258*cdf0e10cSrcweir 		SetStyle();
259*cdf0e10cSrcweir 		SdXML3DObjectContext::StartElement(xAttrList);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 		// set local parameters on shape
262*cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
263*cdf0e10cSrcweir 		if(xPropSet.is())
264*cdf0e10cSrcweir 		{
265*cdf0e10cSrcweir 			// set parameters
266*cdf0e10cSrcweir 			drawing::Position3D aPosition3D;
267*cdf0e10cSrcweir 			drawing::Direction3D aDirection3D;
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 			// convert from min, max to size to be set
270*cdf0e10cSrcweir 			maMaxEdge = maMaxEdge - maMinEdge;
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 			aPosition3D.PositionX = maMinEdge.getX();
273*cdf0e10cSrcweir 			aPosition3D.PositionY = maMinEdge.getY();
274*cdf0e10cSrcweir 			aPosition3D.PositionZ = maMinEdge.getZ();
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 			aDirection3D.DirectionX = maMaxEdge.getX();
277*cdf0e10cSrcweir 			aDirection3D.DirectionY = maMaxEdge.getY();
278*cdf0e10cSrcweir 			aDirection3D.DirectionZ = maMaxEdge.getZ();
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 			uno::Any aAny;
281*cdf0e10cSrcweir 			aAny <<= aPosition3D;
282*cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")), aAny);
283*cdf0e10cSrcweir 			aAny <<= aDirection3D;
284*cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")), aAny);
285*cdf0e10cSrcweir 		}
286*cdf0e10cSrcweir 	}
287*cdf0e10cSrcweir }
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir void SdXML3DCubeObjectShapeContext::EndElement()
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir 	// call parent
294*cdf0e10cSrcweir 	SdXML3DObjectContext::EndElement();
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
298*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir TYPEINIT1( SdXML3DSphereObjectShapeContext, SdXML3DObjectContext);
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir SdXML3DSphereObjectShapeContext::SdXML3DSphereObjectShapeContext(
303*cdf0e10cSrcweir 	SvXMLImport& rImport,
304*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
305*cdf0e10cSrcweir 	const OUString& rLocalName,
306*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
307*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
308*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
309*cdf0e10cSrcweir :	SdXML3DObjectContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
310*cdf0e10cSrcweir 	maCenter(0.0, 0.0, 0.0),
311*cdf0e10cSrcweir 	maSize(5000.0, 5000.0, 5000.0),
312*cdf0e10cSrcweir 	mbCenterUsed(sal_False),
313*cdf0e10cSrcweir 	mbSizeUsed(sal_False)
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
316*cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
317*cdf0e10cSrcweir 	{
318*cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
319*cdf0e10cSrcweir 		OUString aLocalName;
320*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
321*cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
322*cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DSphereObjectAttrTokenMap();
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
325*cdf0e10cSrcweir 		{
326*cdf0e10cSrcweir 			case XML_TOK_3DSPHEREOBJ_CENTER:
327*cdf0e10cSrcweir 			{
328*cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
329*cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 				if(aNewVec != maCenter)
332*cdf0e10cSrcweir 				{
333*cdf0e10cSrcweir 					maCenter = aNewVec;
334*cdf0e10cSrcweir 					mbCenterUsed = sal_True;
335*cdf0e10cSrcweir 				}
336*cdf0e10cSrcweir 				break;
337*cdf0e10cSrcweir 			}
338*cdf0e10cSrcweir 			case XML_TOK_3DSPHEREOBJ_SIZE:
339*cdf0e10cSrcweir 			{
340*cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
341*cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 				if(aNewVec != maSize)
344*cdf0e10cSrcweir 				{
345*cdf0e10cSrcweir 					maSize = aNewVec;
346*cdf0e10cSrcweir 					mbSizeUsed = sal_True;
347*cdf0e10cSrcweir 				}
348*cdf0e10cSrcweir 				break;
349*cdf0e10cSrcweir 			}
350*cdf0e10cSrcweir 		}
351*cdf0e10cSrcweir 	}
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir SdXML3DSphereObjectShapeContext::~SdXML3DSphereObjectShapeContext()
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir void SdXML3DSphereObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
363*cdf0e10cSrcweir {
364*cdf0e10cSrcweir 	// create shape
365*cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DSphereObject" );
366*cdf0e10cSrcweir 	if(mxShape.is())
367*cdf0e10cSrcweir 	{
368*cdf0e10cSrcweir 		// add, set style and properties from base shape
369*cdf0e10cSrcweir 		SetStyle();
370*cdf0e10cSrcweir 		SdXML3DObjectContext::StartElement(xAttrList);
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 		// set local parameters on shape
373*cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
374*cdf0e10cSrcweir 		if(xPropSet.is())
375*cdf0e10cSrcweir 		{
376*cdf0e10cSrcweir 			// set parameters
377*cdf0e10cSrcweir 			drawing::Position3D aPosition3D;
378*cdf0e10cSrcweir 			drawing::Direction3D aDirection3D;
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 			aPosition3D.PositionX = maCenter.getX();
381*cdf0e10cSrcweir 			aPosition3D.PositionY = maCenter.getY();
382*cdf0e10cSrcweir 			aPosition3D.PositionZ = maCenter.getZ();
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 			aDirection3D.DirectionX = maSize.getX();
385*cdf0e10cSrcweir 			aDirection3D.DirectionY = maSize.getY();
386*cdf0e10cSrcweir 			aDirection3D.DirectionZ = maSize.getZ();
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 			uno::Any aAny;
389*cdf0e10cSrcweir 			aAny <<= aPosition3D;
390*cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")), aAny);
391*cdf0e10cSrcweir 			aAny <<= aDirection3D;
392*cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")), aAny);
393*cdf0e10cSrcweir 		}
394*cdf0e10cSrcweir 	}
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir void SdXML3DSphereObjectShapeContext::EndElement()
400*cdf0e10cSrcweir {
401*cdf0e10cSrcweir 	// call parent
402*cdf0e10cSrcweir 	SdXML3DObjectContext::EndElement();
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
406*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir TYPEINIT1( SdXML3DPolygonBasedShapeContext, SdXML3DObjectContext );
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir SdXML3DPolygonBasedShapeContext::SdXML3DPolygonBasedShapeContext(
411*cdf0e10cSrcweir 	SvXMLImport& rImport,
412*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
413*cdf0e10cSrcweir 	const OUString& rLocalName,
414*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
415*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
416*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
417*cdf0e10cSrcweir :	SdXML3DObjectContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
420*cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
421*cdf0e10cSrcweir 	{
422*cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
423*cdf0e10cSrcweir 		OUString aLocalName;
424*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
425*cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
426*cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DPolygonBasedAttrTokenMap();
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
429*cdf0e10cSrcweir 		{
430*cdf0e10cSrcweir 			case XML_TOK_3DPOLYGONBASED_VIEWBOX:
431*cdf0e10cSrcweir 			{
432*cdf0e10cSrcweir 				maViewBox = sValue;
433*cdf0e10cSrcweir 				break;
434*cdf0e10cSrcweir 			}
435*cdf0e10cSrcweir 			case XML_TOK_3DPOLYGONBASED_D:
436*cdf0e10cSrcweir 			{
437*cdf0e10cSrcweir 				maPoints = sValue;
438*cdf0e10cSrcweir 				break;
439*cdf0e10cSrcweir 			}
440*cdf0e10cSrcweir 		}
441*cdf0e10cSrcweir 	}
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir SdXML3DPolygonBasedShapeContext::~SdXML3DPolygonBasedShapeContext()
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir void SdXML3DPolygonBasedShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
453*cdf0e10cSrcweir {
454*cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
455*cdf0e10cSrcweir 	if(xPropSet.is())
456*cdf0e10cSrcweir 	{
457*cdf0e10cSrcweir 		// set parameters
458*cdf0e10cSrcweir 		if(maPoints.getLength() && maViewBox.getLength())
459*cdf0e10cSrcweir 		{
460*cdf0e10cSrcweir 			SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
461*cdf0e10cSrcweir 			awt::Point aMinPoint(aViewBox.GetX(), aViewBox.GetY());
462*cdf0e10cSrcweir 			awt::Size aMaxSize(aViewBox.GetWidth(), aViewBox.GetHeight());
463*cdf0e10cSrcweir 			SdXMLImExSvgDElement aPoints(maPoints, aViewBox,
464*cdf0e10cSrcweir 				aMinPoint, aMaxSize, GetImport().GetMM100UnitConverter());
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir 			// convert to double sequences
467*cdf0e10cSrcweir 			drawing::PointSequenceSequence& xPoSeSe =
468*cdf0e10cSrcweir 				(drawing::PointSequenceSequence&)aPoints.GetPointSequenceSequence();
469*cdf0e10cSrcweir 			sal_Int32 nOuterSequenceCount = xPoSeSe.getLength();
470*cdf0e10cSrcweir 			drawing::PointSequence* pInnerSequence = xPoSeSe.getArray();
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir 			drawing::PolyPolygonShape3D xPolyPolygon3D;
473*cdf0e10cSrcweir 			xPolyPolygon3D.SequenceX.realloc(nOuterSequenceCount);
474*cdf0e10cSrcweir 			xPolyPolygon3D.SequenceY.realloc(nOuterSequenceCount);
475*cdf0e10cSrcweir 			xPolyPolygon3D.SequenceZ.realloc(nOuterSequenceCount);
476*cdf0e10cSrcweir 			drawing::DoubleSequence* pOuterSequenceX = xPolyPolygon3D.SequenceX.getArray();
477*cdf0e10cSrcweir 			drawing::DoubleSequence* pOuterSequenceY = xPolyPolygon3D.SequenceY.getArray();
478*cdf0e10cSrcweir 			drawing::DoubleSequence* pOuterSequenceZ = xPolyPolygon3D.SequenceZ.getArray();
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 			for(sal_Int32 a(0L); a < nOuterSequenceCount; a++)
481*cdf0e10cSrcweir 			{
482*cdf0e10cSrcweir 				sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
483*cdf0e10cSrcweir 				awt::Point* pArray = pInnerSequence->getArray();
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 				pOuterSequenceX->realloc(nInnerSequenceCount);
486*cdf0e10cSrcweir 				pOuterSequenceY->realloc(nInnerSequenceCount);
487*cdf0e10cSrcweir 				pOuterSequenceZ->realloc(nInnerSequenceCount);
488*cdf0e10cSrcweir 				double* pInnerSequenceX = pOuterSequenceX->getArray();
489*cdf0e10cSrcweir 				double* pInnerSequenceY = pOuterSequenceY->getArray();
490*cdf0e10cSrcweir 				double* pInnerSequenceZ = pOuterSequenceZ->getArray();
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 				for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
493*cdf0e10cSrcweir 				{
494*cdf0e10cSrcweir 					*pInnerSequenceX++ = pArray->X;
495*cdf0e10cSrcweir 					*pInnerSequenceY++ = pArray->Y;
496*cdf0e10cSrcweir 					*pInnerSequenceZ++ = 0.0;
497*cdf0e10cSrcweir 					pArray++;
498*cdf0e10cSrcweir 				}
499*cdf0e10cSrcweir 				pInnerSequence++;
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir 				pOuterSequenceX++;
502*cdf0e10cSrcweir 				pOuterSequenceY++;
503*cdf0e10cSrcweir 				pOuterSequenceZ++;
504*cdf0e10cSrcweir 			}
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 			// set poly
507*cdf0e10cSrcweir 			uno::Any aAny;
508*cdf0e10cSrcweir 			aAny <<= xPolyPolygon3D;
509*cdf0e10cSrcweir 			xPropSet->setPropertyValue(
510*cdf0e10cSrcweir 				OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D")), aAny);
511*cdf0e10cSrcweir 		}
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 		// call parent
514*cdf0e10cSrcweir 		SdXML3DObjectContext::StartElement(xAttrList);
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir void SdXML3DPolygonBasedShapeContext::EndElement()
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir 	// call parent
523*cdf0e10cSrcweir 	SdXML3DObjectContext::EndElement();
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
527*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir TYPEINIT1( SdXML3DLatheObjectShapeContext, SdXML3DPolygonBasedShapeContext);
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir SdXML3DLatheObjectShapeContext::SdXML3DLatheObjectShapeContext(
532*cdf0e10cSrcweir 	SvXMLImport& rImport,
533*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
534*cdf0e10cSrcweir 	const OUString& rLocalName,
535*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
536*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
537*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
538*cdf0e10cSrcweir :	SdXML3DPolygonBasedShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
539*cdf0e10cSrcweir {
540*cdf0e10cSrcweir }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir SdXML3DLatheObjectShapeContext::~SdXML3DLatheObjectShapeContext()
545*cdf0e10cSrcweir {
546*cdf0e10cSrcweir }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir void SdXML3DLatheObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
551*cdf0e10cSrcweir {
552*cdf0e10cSrcweir 	// create shape
553*cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DLatheObject" );
554*cdf0e10cSrcweir 	if(mxShape.is())
555*cdf0e10cSrcweir 	{
556*cdf0e10cSrcweir 		// add, set style and properties from base shape
557*cdf0e10cSrcweir 		SetStyle();
558*cdf0e10cSrcweir 		SdXML3DPolygonBasedShapeContext::StartElement(xAttrList);
559*cdf0e10cSrcweir 	}
560*cdf0e10cSrcweir }
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir void SdXML3DLatheObjectShapeContext::EndElement()
565*cdf0e10cSrcweir {
566*cdf0e10cSrcweir 	// call parent
567*cdf0e10cSrcweir 	SdXML3DPolygonBasedShapeContext::EndElement();
568*cdf0e10cSrcweir }
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
571*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir TYPEINIT1( SdXML3DExtrudeObjectShapeContext, SdXML3DPolygonBasedShapeContext);
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir SdXML3DExtrudeObjectShapeContext::SdXML3DExtrudeObjectShapeContext(
576*cdf0e10cSrcweir 	SvXMLImport& rImport,
577*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
578*cdf0e10cSrcweir 	const OUString& rLocalName,
579*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
580*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
581*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
582*cdf0e10cSrcweir :	SdXML3DPolygonBasedShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
583*cdf0e10cSrcweir {
584*cdf0e10cSrcweir }
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir SdXML3DExtrudeObjectShapeContext::~SdXML3DExtrudeObjectShapeContext()
589*cdf0e10cSrcweir {
590*cdf0e10cSrcweir }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir void SdXML3DExtrudeObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DExtrudeObject" );
597*cdf0e10cSrcweir 	if(mxShape.is())
598*cdf0e10cSrcweir 	{
599*cdf0e10cSrcweir 		// add, set style and properties from base shape
600*cdf0e10cSrcweir 		SetStyle();
601*cdf0e10cSrcweir 		SdXML3DPolygonBasedShapeContext::StartElement(xAttrList);
602*cdf0e10cSrcweir 	}
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir void SdXML3DExtrudeObjectShapeContext::EndElement()
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	// call parent
610*cdf0e10cSrcweir 	SdXML3DPolygonBasedShapeContext::EndElement();
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir // EOF
614