163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
363bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
563bba73cSAndrew Rist  * distributed with this work for additional information
663bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
763bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
1063bba73cSAndrew Rist  *
1163bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1263bba73cSAndrew Rist  *
1363bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist  * software distributed under the License is distributed on an
1563bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
1763bba73cSAndrew Rist  * specific language governing permissions and limitations
1863bba73cSAndrew Rist  * under the License.
1963bba73cSAndrew Rist  *
2063bba73cSAndrew Rist  *************************************************************/
2163bba73cSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
24*1f882ec4SArmin Le Grand 
25cdf0e10cSrcweir #include <comphelper/extract.hxx>
26cdf0e10cSrcweir #include "ximp3dobject.hxx"
27cdf0e10cSrcweir #include <xmloff/XMLShapeStyleContext.hxx>
28cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp>
32cdf0e10cSrcweir #include "xexptran.hxx"
33cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
34cdf0e10cSrcweir #include <xmloff/families.hxx>
35cdf0e10cSrcweir #include "ximpstyl.hxx"
36cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
37cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/DoubleSequence.hpp>
39*1f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolypolygon.hxx>
40*1f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolypolygontools.hxx>
41*1f882ec4SArmin Le Grand #include <basegfx/polygon/b3dpolypolygontools.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using ::rtl::OUString;
44cdf0e10cSrcweir using ::rtl::OUStringBuffer;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
49cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50cdf0e10cSrcweir 
51cdf0e10cSrcweir TYPEINIT1( SdXML3DObjectContext, SdXMLShapeContext );
52cdf0e10cSrcweir 
SdXML3DObjectContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)53cdf0e10cSrcweir SdXML3DObjectContext::SdXML3DObjectContext(
54cdf0e10cSrcweir 	SvXMLImport& rImport,
55cdf0e10cSrcweir 	sal_uInt16 nPrfx,
56cdf0e10cSrcweir 	const OUString& rLocalName,
57cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
58cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
59cdf0e10cSrcweir     sal_Bool bTemporaryShape)
60cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
61cdf0e10cSrcweir 	mbSetTransform( sal_False )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
64cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
67cdf0e10cSrcweir 		OUString aLocalName;
68cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
69cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
70cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DObjectAttrTokenMap();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 			case XML_TOK_3DOBJECT_DRAWSTYLE_NAME:
75cdf0e10cSrcweir 			{
76cdf0e10cSrcweir 				maDrawStyleName = sValue;
77cdf0e10cSrcweir 				break;
78cdf0e10cSrcweir 			}
79cdf0e10cSrcweir 			case XML_TOK_3DOBJECT_TRANSFORM:
80cdf0e10cSrcweir 			{
81cdf0e10cSrcweir 				SdXMLImExTransform3D aTransform(sValue, GetImport().GetMM100UnitConverter());
82cdf0e10cSrcweir 				if(aTransform.NeedsAction())
83cdf0e10cSrcweir 					mbSetTransform = aTransform.GetFullHomogenTransform(mxHomMat);
84cdf0e10cSrcweir 				break;
85cdf0e10cSrcweir 			}
86cdf0e10cSrcweir 		}
87cdf0e10cSrcweir 	}
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
91cdf0e10cSrcweir 
~SdXML3DObjectContext()92cdf0e10cSrcweir SdXML3DObjectContext::~SdXML3DObjectContext()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
97cdf0e10cSrcweir 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)98cdf0e10cSrcweir void SdXML3DObjectContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
101cdf0e10cSrcweir 	if(xPropSet.is())
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 		// set parameters
104cdf0e10cSrcweir 		if(mbSetTransform)
105cdf0e10cSrcweir 		{
106cdf0e10cSrcweir 			uno::Any aAny;
107cdf0e10cSrcweir 			aAny <<= mxHomMat;
108cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")), aAny);
109cdf0e10cSrcweir 		}
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 		// call parent
112cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
117cdf0e10cSrcweir 
EndElement()118cdf0e10cSrcweir void SdXML3DObjectContext::EndElement()
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	// call parent
121cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
125cdf0e10cSrcweir /*
126cdf0e10cSrcweir void SdXML3DObjectContext::AddShape(uno::Reference< drawing::XShape >& xShape)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	if(xShape.is() && mxShapes.is())
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir 		// set shape local
131cdf0e10cSrcweir 		mxShape = xShape;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 		// add new shape to parent
134cdf0e10cSrcweir 		mxShapes->add( xShape );
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir }
137cdf0e10cSrcweir */
138cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
139cdf0e10cSrcweir /*
140cdf0e10cSrcweir void SdXML3DObjectContext::SetStyle()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	// set style on shape
143cdf0e10cSrcweir 	if(maDrawStyleName.getLength() && mxShape.is())
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		const SvXMLStyleContext* pStyle = 0L;
146cdf0e10cSrcweir 		sal_Bool bAutoStyle(sal_False);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		if(GetImport().GetShapeImport()->GetAutoStylesContext())
149cdf0e10cSrcweir 			pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(
150cdf0e10cSrcweir 			XML_STYLE_FAMILY_SD_GRAPHICS_ID, maDrawStyleName);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 		if(pStyle)
153cdf0e10cSrcweir 			bAutoStyle = sal_True;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
156cdf0e10cSrcweir 			pStyle = GetImport().GetShapeImport()->GetStylesContext()->
157cdf0e10cSrcweir 			FindStyleChildContext(XML_STYLE_FAMILY_SD_GRAPHICS_ID, maDrawStyleName);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		if(pStyle && pStyle->ISA(XMLShapeStyleContext))
160cdf0e10cSrcweir 		{
161cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
162cdf0e10cSrcweir 			if(xPropSet.is())
163cdf0e10cSrcweir 			{
164cdf0e10cSrcweir 				XMLShapeStyleContext* pDocStyle = (XMLShapeStyleContext*)pStyle;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 				if(pDocStyle->GetStyle().is())
167cdf0e10cSrcweir 				{
168cdf0e10cSrcweir 					// set style on object
169cdf0e10cSrcweir 					uno::Any aAny;
170cdf0e10cSrcweir 					aAny <<= pDocStyle->GetStyle();
171cdf0e10cSrcweir 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style")), aAny);
172cdf0e10cSrcweir 				}
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 				if(bAutoStyle)
175cdf0e10cSrcweir 				{
176cdf0e10cSrcweir 					// set PropertySet on object
177cdf0e10cSrcweir 					pDocStyle->FillPropertySet(xPropSet);
178cdf0e10cSrcweir 				}
179cdf0e10cSrcweir 			}
180cdf0e10cSrcweir 		}
181cdf0e10cSrcweir 	}
182cdf0e10cSrcweir }
183cdf0e10cSrcweir */
184cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
185cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
186cdf0e10cSrcweir 
187cdf0e10cSrcweir TYPEINIT1( SdXML3DCubeObjectShapeContext, SdXML3DObjectContext);
188cdf0e10cSrcweir 
SdXML3DCubeObjectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)189cdf0e10cSrcweir SdXML3DCubeObjectShapeContext::SdXML3DCubeObjectShapeContext(
190cdf0e10cSrcweir 	SvXMLImport& rImport,
191cdf0e10cSrcweir 	sal_uInt16 nPrfx,
192cdf0e10cSrcweir 	const OUString& rLocalName,
193cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
194cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
195cdf0e10cSrcweir     sal_Bool bTemporaryShape)
196cdf0e10cSrcweir :	SdXML3DObjectContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
197cdf0e10cSrcweir 	maMinEdge(-2500.0, -2500.0, -2500.0),
198cdf0e10cSrcweir 	maMaxEdge(2500.0, 2500.0, 2500.0),
199cdf0e10cSrcweir 	mbMinEdgeUsed(sal_False),
200cdf0e10cSrcweir 	mbMaxEdgeUsed(sal_False)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
203cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
204cdf0e10cSrcweir 	{
205cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
206cdf0e10cSrcweir 		OUString aLocalName;
207cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
208cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
209cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DCubeObjectAttrTokenMap();
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
212cdf0e10cSrcweir 		{
213cdf0e10cSrcweir 			case XML_TOK_3DCUBEOBJ_MINEDGE:
214cdf0e10cSrcweir 			{
215cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
216cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 				if(aNewVec != maMinEdge)
219cdf0e10cSrcweir 				{
220cdf0e10cSrcweir 					maMinEdge = aNewVec;
221cdf0e10cSrcweir 					mbMinEdgeUsed = sal_True;
222cdf0e10cSrcweir 				}
223cdf0e10cSrcweir 				break;
224cdf0e10cSrcweir 			}
225cdf0e10cSrcweir 			case XML_TOK_3DCUBEOBJ_MAXEDGE:
226cdf0e10cSrcweir 			{
227cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
228cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 				if(aNewVec != maMaxEdge)
231cdf0e10cSrcweir 				{
232cdf0e10cSrcweir 					maMaxEdge = aNewVec;
233cdf0e10cSrcweir 					mbMaxEdgeUsed = sal_True;
234cdf0e10cSrcweir 				}
235cdf0e10cSrcweir 				break;
236cdf0e10cSrcweir 			}
237cdf0e10cSrcweir 		}
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
241cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
242cdf0e10cSrcweir 
~SdXML3DCubeObjectShapeContext()243cdf0e10cSrcweir SdXML3DCubeObjectShapeContext::~SdXML3DCubeObjectShapeContext()
244cdf0e10cSrcweir {
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
248cdf0e10cSrcweir 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)249cdf0e10cSrcweir void SdXML3DCubeObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir 	// create shape
252cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DCubeObject" );
253cdf0e10cSrcweir 	if(mxShape.is())
254cdf0e10cSrcweir 	{
255cdf0e10cSrcweir 		// add, set style and properties from base shape
256cdf0e10cSrcweir 		SetStyle();
257cdf0e10cSrcweir 		SdXML3DObjectContext::StartElement(xAttrList);
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 		// set local parameters on shape
260cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
261cdf0e10cSrcweir 		if(xPropSet.is())
262cdf0e10cSrcweir 		{
263cdf0e10cSrcweir 			// set parameters
264cdf0e10cSrcweir 			drawing::Position3D aPosition3D;
265cdf0e10cSrcweir 			drawing::Direction3D aDirection3D;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 			// convert from min, max to size to be set
268cdf0e10cSrcweir 			maMaxEdge = maMaxEdge - maMinEdge;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 			aPosition3D.PositionX = maMinEdge.getX();
271cdf0e10cSrcweir 			aPosition3D.PositionY = maMinEdge.getY();
272cdf0e10cSrcweir 			aPosition3D.PositionZ = maMinEdge.getZ();
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 			aDirection3D.DirectionX = maMaxEdge.getX();
275cdf0e10cSrcweir 			aDirection3D.DirectionY = maMaxEdge.getY();
276cdf0e10cSrcweir 			aDirection3D.DirectionZ = maMaxEdge.getZ();
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 			uno::Any aAny;
279cdf0e10cSrcweir 			aAny <<= aPosition3D;
280cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")), aAny);
281cdf0e10cSrcweir 			aAny <<= aDirection3D;
282cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")), aAny);
283cdf0e10cSrcweir 		}
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
288cdf0e10cSrcweir 
EndElement()289cdf0e10cSrcweir void SdXML3DCubeObjectShapeContext::EndElement()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	// call parent
292cdf0e10cSrcweir 	SdXML3DObjectContext::EndElement();
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
296cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
297cdf0e10cSrcweir 
298cdf0e10cSrcweir TYPEINIT1( SdXML3DSphereObjectShapeContext, SdXML3DObjectContext);
299cdf0e10cSrcweir 
SdXML3DSphereObjectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)300cdf0e10cSrcweir SdXML3DSphereObjectShapeContext::SdXML3DSphereObjectShapeContext(
301cdf0e10cSrcweir 	SvXMLImport& rImport,
302cdf0e10cSrcweir 	sal_uInt16 nPrfx,
303cdf0e10cSrcweir 	const OUString& rLocalName,
304cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
305cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
306cdf0e10cSrcweir     sal_Bool bTemporaryShape)
307cdf0e10cSrcweir :	SdXML3DObjectContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
308cdf0e10cSrcweir 	maCenter(0.0, 0.0, 0.0),
309cdf0e10cSrcweir 	maSize(5000.0, 5000.0, 5000.0),
310cdf0e10cSrcweir 	mbCenterUsed(sal_False),
311cdf0e10cSrcweir 	mbSizeUsed(sal_False)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
314cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
315cdf0e10cSrcweir 	{
316cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
317cdf0e10cSrcweir 		OUString aLocalName;
318cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
319cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
320cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DSphereObjectAttrTokenMap();
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
323cdf0e10cSrcweir 		{
324cdf0e10cSrcweir 			case XML_TOK_3DSPHEREOBJ_CENTER:
325cdf0e10cSrcweir 			{
326cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
327cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 				if(aNewVec != maCenter)
330cdf0e10cSrcweir 				{
331cdf0e10cSrcweir 					maCenter = aNewVec;
332cdf0e10cSrcweir 					mbCenterUsed = sal_True;
333cdf0e10cSrcweir 				}
334cdf0e10cSrcweir 				break;
335cdf0e10cSrcweir 			}
336cdf0e10cSrcweir 			case XML_TOK_3DSPHEREOBJ_SIZE:
337cdf0e10cSrcweir 			{
338cdf0e10cSrcweir 				::basegfx::B3DVector aNewVec;
339cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertB3DVector(aNewVec, sValue);
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 				if(aNewVec != maSize)
342cdf0e10cSrcweir 				{
343cdf0e10cSrcweir 					maSize = aNewVec;
344cdf0e10cSrcweir 					mbSizeUsed = sal_True;
345cdf0e10cSrcweir 				}
346cdf0e10cSrcweir 				break;
347cdf0e10cSrcweir 			}
348cdf0e10cSrcweir 		}
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
353cdf0e10cSrcweir 
~SdXML3DSphereObjectShapeContext()354cdf0e10cSrcweir SdXML3DSphereObjectShapeContext::~SdXML3DSphereObjectShapeContext()
355cdf0e10cSrcweir {
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
359cdf0e10cSrcweir 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)360cdf0e10cSrcweir void SdXML3DSphereObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir 	// create shape
363cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DSphereObject" );
364cdf0e10cSrcweir 	if(mxShape.is())
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir 		// add, set style and properties from base shape
367cdf0e10cSrcweir 		SetStyle();
368cdf0e10cSrcweir 		SdXML3DObjectContext::StartElement(xAttrList);
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 		// set local parameters on shape
371cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
372cdf0e10cSrcweir 		if(xPropSet.is())
373cdf0e10cSrcweir 		{
374cdf0e10cSrcweir 			// set parameters
375cdf0e10cSrcweir 			drawing::Position3D aPosition3D;
376cdf0e10cSrcweir 			drawing::Direction3D aDirection3D;
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 			aPosition3D.PositionX = maCenter.getX();
379cdf0e10cSrcweir 			aPosition3D.PositionY = maCenter.getY();
380cdf0e10cSrcweir 			aPosition3D.PositionZ = maCenter.getZ();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 			aDirection3D.DirectionX = maSize.getX();
383cdf0e10cSrcweir 			aDirection3D.DirectionY = maSize.getY();
384cdf0e10cSrcweir 			aDirection3D.DirectionZ = maSize.getZ();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 			uno::Any aAny;
387cdf0e10cSrcweir 			aAny <<= aPosition3D;
388cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")), aAny);
389cdf0e10cSrcweir 			aAny <<= aDirection3D;
390cdf0e10cSrcweir 			xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")), aAny);
391cdf0e10cSrcweir 		}
392cdf0e10cSrcweir 	}
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
396cdf0e10cSrcweir 
EndElement()397cdf0e10cSrcweir void SdXML3DSphereObjectShapeContext::EndElement()
398cdf0e10cSrcweir {
399cdf0e10cSrcweir 	// call parent
400cdf0e10cSrcweir 	SdXML3DObjectContext::EndElement();
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
403cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
404cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
405cdf0e10cSrcweir 
406cdf0e10cSrcweir TYPEINIT1( SdXML3DPolygonBasedShapeContext, SdXML3DObjectContext );
407cdf0e10cSrcweir 
SdXML3DPolygonBasedShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)408cdf0e10cSrcweir SdXML3DPolygonBasedShapeContext::SdXML3DPolygonBasedShapeContext(
409cdf0e10cSrcweir 	SvXMLImport& rImport,
410cdf0e10cSrcweir 	sal_uInt16 nPrfx,
411cdf0e10cSrcweir 	const OUString& rLocalName,
412cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
413cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
414cdf0e10cSrcweir     sal_Bool bTemporaryShape)
415cdf0e10cSrcweir :	SdXML3DObjectContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
418cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
419cdf0e10cSrcweir 	{
420cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
421cdf0e10cSrcweir 		OUString aLocalName;
422cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
423cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
424cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DPolygonBasedAttrTokenMap();
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
427cdf0e10cSrcweir 		{
428cdf0e10cSrcweir 			case XML_TOK_3DPOLYGONBASED_VIEWBOX:
429cdf0e10cSrcweir 			{
430cdf0e10cSrcweir 				maViewBox = sValue;
431cdf0e10cSrcweir 				break;
432cdf0e10cSrcweir 			}
433cdf0e10cSrcweir 			case XML_TOK_3DPOLYGONBASED_D:
434cdf0e10cSrcweir 			{
435cdf0e10cSrcweir 				maPoints = sValue;
436cdf0e10cSrcweir 				break;
437cdf0e10cSrcweir 			}
438cdf0e10cSrcweir 		}
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
443cdf0e10cSrcweir 
~SdXML3DPolygonBasedShapeContext()444cdf0e10cSrcweir SdXML3DPolygonBasedShapeContext::~SdXML3DPolygonBasedShapeContext()
445cdf0e10cSrcweir {
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
449cdf0e10cSrcweir 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)450cdf0e10cSrcweir void SdXML3DPolygonBasedShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
451cdf0e10cSrcweir {
452*1f882ec4SArmin Le Grand     uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
453*1f882ec4SArmin Le Grand 
454*1f882ec4SArmin Le Grand     if(xPropSet.is())
455*1f882ec4SArmin Le Grand     {
456*1f882ec4SArmin Le Grand         // set parameters
457*1f882ec4SArmin Le Grand         if(maPoints.getLength() && maViewBox.getLength())
458*1f882ec4SArmin Le Grand         {
459*1f882ec4SArmin Le Grand             // import 2d PolyPolygon from svg:d
460*1f882ec4SArmin Le Grand             basegfx::B2DPolyPolygon aPolyPolygon;
461*1f882ec4SArmin Le Grand 
462*1f882ec4SArmin Le Grand             if(basegfx::tools::importFromSvgD(aPolyPolygon, maPoints, true, 0))
463*1f882ec4SArmin Le Grand             {
464*1f882ec4SArmin Le Grand                 // convert to 3D PolyPolygon
465*1f882ec4SArmin Le Grand                 const basegfx::B3DPolyPolygon aB3DPolyPolygon(
466*1f882ec4SArmin Le Grand                     basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(
467*1f882ec4SArmin Le Grand                         aPolyPolygon));
468*1f882ec4SArmin Le Grand 
469*1f882ec4SArmin Le Grand                 // convert to UNO API class PolyPolygonShape3D
470*1f882ec4SArmin Le Grand                 drawing::PolyPolygonShape3D xPolyPolygon3D;
471*1f882ec4SArmin Le Grand                 basegfx::tools::B3DPolyPolygonToUnoPolyPolygonShape3D(
472*1f882ec4SArmin Le Grand                     aB3DPolyPolygon,
473*1f882ec4SArmin Le Grand                     xPolyPolygon3D);
474*1f882ec4SArmin Le Grand 
475*1f882ec4SArmin Le Grand                 // set polygon data
476*1f882ec4SArmin Le Grand                 uno::Any aAny;
477*1f882ec4SArmin Le Grand                 aAny <<= xPolyPolygon3D;
478*1f882ec4SArmin Le Grand                 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D")), aAny);
479*1f882ec4SArmin Le Grand             }
480*1f882ec4SArmin Le Grand             else
481*1f882ec4SArmin Le Grand             {
482*1f882ec4SArmin Le Grand                 OSL_ENSURE(false, "Error on importing svg:d for 3D PolyPolygon (!)");
483*1f882ec4SArmin Le Grand             }
484*1f882ec4SArmin Le Grand         }
485*1f882ec4SArmin Le Grand 
486*1f882ec4SArmin Le Grand         // call parent
487*1f882ec4SArmin Le Grand         SdXML3DObjectContext::StartElement(xAttrList);
488*1f882ec4SArmin Le Grand     }
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
492cdf0e10cSrcweir 
EndElement()493cdf0e10cSrcweir void SdXML3DPolygonBasedShapeContext::EndElement()
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	// call parent
496cdf0e10cSrcweir 	SdXML3DObjectContext::EndElement();
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
500cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
501cdf0e10cSrcweir 
502cdf0e10cSrcweir TYPEINIT1( SdXML3DLatheObjectShapeContext, SdXML3DPolygonBasedShapeContext);
503cdf0e10cSrcweir 
SdXML3DLatheObjectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)504cdf0e10cSrcweir SdXML3DLatheObjectShapeContext::SdXML3DLatheObjectShapeContext(
505cdf0e10cSrcweir 	SvXMLImport& rImport,
506cdf0e10cSrcweir 	sal_uInt16 nPrfx,
507cdf0e10cSrcweir 	const OUString& rLocalName,
508cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
509cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
510cdf0e10cSrcweir     sal_Bool bTemporaryShape)
511cdf0e10cSrcweir :	SdXML3DPolygonBasedShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir }
514cdf0e10cSrcweir 
515cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
516cdf0e10cSrcweir 
~SdXML3DLatheObjectShapeContext()517cdf0e10cSrcweir SdXML3DLatheObjectShapeContext::~SdXML3DLatheObjectShapeContext()
518cdf0e10cSrcweir {
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
522cdf0e10cSrcweir 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)523cdf0e10cSrcweir void SdXML3DLatheObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir 	// create shape
526cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DLatheObject" );
527cdf0e10cSrcweir 	if(mxShape.is())
528cdf0e10cSrcweir 	{
529cdf0e10cSrcweir 		// add, set style and properties from base shape
530cdf0e10cSrcweir 		SetStyle();
531cdf0e10cSrcweir 		SdXML3DPolygonBasedShapeContext::StartElement(xAttrList);
532cdf0e10cSrcweir 	}
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
536cdf0e10cSrcweir 
EndElement()537cdf0e10cSrcweir void SdXML3DLatheObjectShapeContext::EndElement()
538cdf0e10cSrcweir {
539cdf0e10cSrcweir 	// call parent
540cdf0e10cSrcweir 	SdXML3DPolygonBasedShapeContext::EndElement();
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
544cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
545cdf0e10cSrcweir 
546cdf0e10cSrcweir TYPEINIT1( SdXML3DExtrudeObjectShapeContext, SdXML3DPolygonBasedShapeContext);
547cdf0e10cSrcweir 
SdXML3DExtrudeObjectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)548cdf0e10cSrcweir SdXML3DExtrudeObjectShapeContext::SdXML3DExtrudeObjectShapeContext(
549cdf0e10cSrcweir 	SvXMLImport& rImport,
550cdf0e10cSrcweir 	sal_uInt16 nPrfx,
551cdf0e10cSrcweir 	const OUString& rLocalName,
552cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
553cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
554cdf0e10cSrcweir     sal_Bool bTemporaryShape)
555cdf0e10cSrcweir :	SdXML3DPolygonBasedShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
560cdf0e10cSrcweir 
~SdXML3DExtrudeObjectShapeContext()561cdf0e10cSrcweir SdXML3DExtrudeObjectShapeContext::~SdXML3DExtrudeObjectShapeContext()
562cdf0e10cSrcweir {
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
566cdf0e10cSrcweir 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)567cdf0e10cSrcweir void SdXML3DExtrudeObjectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
568cdf0e10cSrcweir {
569cdf0e10cSrcweir 	AddShape( "com.sun.star.drawing.Shape3DExtrudeObject" );
570cdf0e10cSrcweir 	if(mxShape.is())
571cdf0e10cSrcweir 	{
572cdf0e10cSrcweir 		// add, set style and properties from base shape
573cdf0e10cSrcweir 		SetStyle();
574cdf0e10cSrcweir 		SdXML3DPolygonBasedShapeContext::StartElement(xAttrList);
575cdf0e10cSrcweir 	}
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
579cdf0e10cSrcweir 
EndElement()580cdf0e10cSrcweir void SdXML3DExtrudeObjectShapeContext::EndElement()
581cdf0e10cSrcweir {
582cdf0e10cSrcweir 	// call parent
583cdf0e10cSrcweir 	SdXML3DPolygonBasedShapeContext::EndElement();
584cdf0e10cSrcweir }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir // EOF
587