1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "ximp3dscene.hxx"
27cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
28cdf0e10cSrcweir #include "xexptran.hxx"
29cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
30cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
31cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/CameraGeometry.hpp>
33cdf0e10cSrcweir #include "eventimp.hxx"
34cdf0e10cSrcweir #include "descriptionimp.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir using ::rtl::OUString;
37cdf0e10cSrcweir using ::rtl::OUStringBuffer;
38cdf0e10cSrcweir
39cdf0e10cSrcweir using namespace ::com::sun::star;
40cdf0e10cSrcweir using namespace ::xmloff::token;
41cdf0e10cSrcweir
42cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
43cdf0e10cSrcweir // dr3d:3dlight context
44cdf0e10cSrcweir
SdXML3DLightContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList)45cdf0e10cSrcweir SdXML3DLightContext::SdXML3DLightContext(
46cdf0e10cSrcweir SvXMLImport& rImport,
47cdf0e10cSrcweir sal_uInt16 nPrfx,
48cdf0e10cSrcweir const rtl::OUString& rLName,
49cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList)
50cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrfx, rLName),
51cdf0e10cSrcweir maDiffuseColor(0x00000000),
52cdf0e10cSrcweir maDirection(0.0, 0.0, 1.0),
53cdf0e10cSrcweir mbEnabled(sal_False),
54cdf0e10cSrcweir mbSpecular(sal_False)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir // read attributes for the 3DScene
57cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
58cdf0e10cSrcweir for(sal_Int16 i=0; i < nAttrCount; i++)
59cdf0e10cSrcweir {
60cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i );
61cdf0e10cSrcweir OUString aLocalName;
62cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
63cdf0e10cSrcweir OUString sValue = xAttrList->getValueByIndex( i );
64cdf0e10cSrcweir const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DLightAttrTokenMap();
65cdf0e10cSrcweir
66cdf0e10cSrcweir switch(rAttrTokenMap.Get(nPrefix, aLocalName))
67cdf0e10cSrcweir {
68cdf0e10cSrcweir case XML_TOK_3DLIGHT_DIFFUSE_COLOR:
69cdf0e10cSrcweir {
70cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertColor(maDiffuseColor, sValue);
71cdf0e10cSrcweir break;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir case XML_TOK_3DLIGHT_DIRECTION:
74cdf0e10cSrcweir {
75cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertB3DVector(maDirection, sValue);
76cdf0e10cSrcweir break;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir case XML_TOK_3DLIGHT_ENABLED:
79cdf0e10cSrcweir {
80cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertBool(mbEnabled, sValue);
81cdf0e10cSrcweir break;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir case XML_TOK_3DLIGHT_SPECULAR:
84cdf0e10cSrcweir {
85cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertBool(mbSpecular, sValue);
86cdf0e10cSrcweir break;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir }
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
~SdXML3DLightContext()92cdf0e10cSrcweir SdXML3DLightContext::~SdXML3DLightContext()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
97cdf0e10cSrcweir
98cdf0e10cSrcweir TYPEINIT1( SdXML3DSceneShapeContext, SdXMLShapeContext );
99cdf0e10cSrcweir
SdXML3DSceneShapeContext(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 bTemporaryShapes)100cdf0e10cSrcweir SdXML3DSceneShapeContext::SdXML3DSceneShapeContext(
101cdf0e10cSrcweir SvXMLImport& rImport,
102cdf0e10cSrcweir sal_uInt16 nPrfx,
103cdf0e10cSrcweir const OUString& rLocalName,
104cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
105cdf0e10cSrcweir uno::Reference< drawing::XShapes >& rShapes,
106cdf0e10cSrcweir sal_Bool bTemporaryShapes)
107cdf0e10cSrcweir : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShapes ), SdXML3DSceneAttributesHelper( rImport )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
112cdf0e10cSrcweir
~SdXML3DSceneShapeContext()113cdf0e10cSrcweir SdXML3DSceneShapeContext::~SdXML3DSceneShapeContext()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
118cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)119cdf0e10cSrcweir void SdXML3DSceneShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir // create new 3DScene shape and add it to rShapes, use it
122cdf0e10cSrcweir // as base for the new 3DScene import
123cdf0e10cSrcweir AddShape( "com.sun.star.drawing.Shape3DSceneObject" );
124cdf0e10cSrcweir if( mxShape.is() )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir SetStyle();
127cdf0e10cSrcweir
128cdf0e10cSrcweir mxChilds = uno::Reference< drawing::XShapes >::query( mxShape );
129cdf0e10cSrcweir if( mxChilds.is() )
130cdf0e10cSrcweir GetImport().GetShapeImport()->pushGroupForSorting( mxChilds );
131cdf0e10cSrcweir
132cdf0e10cSrcweir SetLayer();
133cdf0e10cSrcweir
134cdf0e10cSrcweir // set pos, size, shear and rotate
135cdf0e10cSrcweir SetTransformation();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir // read attributes for the 3DScene
139cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
140cdf0e10cSrcweir for(sal_Int16 i=0; i < nAttrCount; i++)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i );
143cdf0e10cSrcweir OUString aLocalName;
144cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
145cdf0e10cSrcweir OUString sValue = xAttrList->getValueByIndex( i );
146cdf0e10cSrcweir processSceneAttribute( nPrefix, aLocalName, sValue );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir // #91047# call parent function is missing here, added it
150cdf0e10cSrcweir if(mxShape.is())
151cdf0e10cSrcweir {
152cdf0e10cSrcweir // call parent
153cdf0e10cSrcweir SdXMLShapeContext::StartElement(xAttrList);
154cdf0e10cSrcweir }
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
158cdf0e10cSrcweir
EndElement()159cdf0e10cSrcweir void SdXML3DSceneShapeContext::EndElement()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir if(mxShape.is())
162cdf0e10cSrcweir {
163cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
164cdf0e10cSrcweir if(xPropSet.is())
165cdf0e10cSrcweir {
166cdf0e10cSrcweir setSceneAttributes( xPropSet );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir if( mxChilds.is() )
170cdf0e10cSrcweir GetImport().GetShapeImport()->popGroupAndSort();
171cdf0e10cSrcweir
172cdf0e10cSrcweir // call parent
173cdf0e10cSrcweir SdXMLShapeContext::EndElement();
174cdf0e10cSrcweir }
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
177cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
178cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)179cdf0e10cSrcweir SvXMLImportContext* SdXML3DSceneShapeContext::CreateChildContext( sal_uInt16 nPrefix,
180cdf0e10cSrcweir const OUString& rLocalName,
181cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList>& xAttrList )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir SvXMLImportContext* pContext = 0L;
184cdf0e10cSrcweir
185cdf0e10cSrcweir // #i68101#
186cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_SVG &&
187cdf0e10cSrcweir (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir pContext = new SdXMLDescriptionContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir pContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
194cdf0e10cSrcweir }
195cdf0e10cSrcweir // look for local light context first
196cdf0e10cSrcweir else if(nPrefix == XML_NAMESPACE_DR3D && IsXMLToken( rLocalName, XML_LIGHT ) )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir // dr3d:light inside dr3d:scene context
199cdf0e10cSrcweir pContext = create3DLightContext( nPrefix, rLocalName, xAttrList );
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir // call GroupChildContext function at common ShapeImport
203cdf0e10cSrcweir if(!pContext)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir pContext = GetImport().GetShapeImport()->Create3DSceneChildContext(
206cdf0e10cSrcweir GetImport(), nPrefix, rLocalName, xAttrList, mxChilds);
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
209cdf0e10cSrcweir // call parent when no own context was created
210cdf0e10cSrcweir if(!pContext)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir pContext = SvXMLImportContext::CreateChildContext(
213cdf0e10cSrcweir nPrefix, rLocalName, xAttrList);
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir return pContext;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
219cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
220cdf0e10cSrcweir
SdXML3DSceneAttributesHelper(SvXMLImport & rImporter)221cdf0e10cSrcweir SdXML3DSceneAttributesHelper::SdXML3DSceneAttributesHelper( SvXMLImport& rImporter )
222cdf0e10cSrcweir : mrImport( rImporter ),
223cdf0e10cSrcweir mbSetTransform( sal_False ),
224cdf0e10cSrcweir mxPrjMode(drawing::ProjectionMode_PERSPECTIVE),
225cdf0e10cSrcweir mnDistance(1000),
226cdf0e10cSrcweir mnFocalLength(1000),
227cdf0e10cSrcweir mnShadowSlant(0),
228cdf0e10cSrcweir mxShadeMode(drawing::ShadeMode_SMOOTH),
229cdf0e10cSrcweir maAmbientColor(0x00666666),
230cdf0e10cSrcweir mbLightingMode(sal_False),
231cdf0e10cSrcweir maVRP(0.0, 0.0, 1.0),
232cdf0e10cSrcweir maVPN(0.0, 0.0, 1.0),
233cdf0e10cSrcweir maVUP(0.0, 1.0, 0.0),
234cdf0e10cSrcweir mbVRPUsed(sal_False),
235cdf0e10cSrcweir mbVPNUsed(sal_False),
236cdf0e10cSrcweir mbVUPUsed(sal_False)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
~SdXML3DSceneAttributesHelper()240cdf0e10cSrcweir SdXML3DSceneAttributesHelper::~SdXML3DSceneAttributesHelper()
241cdf0e10cSrcweir {
242cdf0e10cSrcweir // release remembered light contexts, they are no longer needed
243cdf0e10cSrcweir while(maList.Count())
244cdf0e10cSrcweir maList.Remove(maList.Count() - 1)->ReleaseRef();
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir /** creates a 3d ligth context and adds it to the internal list for later processing */
create3DLightContext(sal_uInt16 nPrfx,const rtl::OUString & rLName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList)248cdf0e10cSrcweir SvXMLImportContext * SdXML3DSceneAttributesHelper::create3DLightContext( sal_uInt16 nPrfx, const rtl::OUString& rLName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList)
249cdf0e10cSrcweir {
250cdf0e10cSrcweir SvXMLImportContext* pContext = new SdXML3DLightContext(mrImport, nPrfx, rLName, xAttrList);
251cdf0e10cSrcweir
252cdf0e10cSrcweir // remember SdXML3DLightContext for later evaluation
253cdf0e10cSrcweir if(pContext)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir pContext->AddRef();
256cdf0e10cSrcweir maList.Insert((SdXML3DLightContext*)pContext, LIST_APPEND);
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir return pContext;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir /** this should be called for each scene attribute */
processSceneAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)263cdf0e10cSrcweir void SdXML3DSceneAttributesHelper::processSceneAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir if( XML_NAMESPACE_DR3D == nPrefix )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir SdXMLImExTransform3D aTransform(rValue, mrImport.GetMM100UnitConverter());
270cdf0e10cSrcweir if(aTransform.NeedsAction())
271cdf0e10cSrcweir mbSetTransform = aTransform.GetFullHomogenTransform(mxHomMat);
272cdf0e10cSrcweir return;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_VRP ) )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir ::basegfx::B3DVector aNewVec;
277cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertB3DVector(aNewVec, rValue);
278cdf0e10cSrcweir
279cdf0e10cSrcweir if(aNewVec != maVRP)
280cdf0e10cSrcweir {
281cdf0e10cSrcweir maVRP = aNewVec;
282cdf0e10cSrcweir mbVRPUsed = sal_True;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir return;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_VPN ) )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir ::basegfx::B3DVector aNewVec;
289cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertB3DVector(aNewVec, rValue);
290cdf0e10cSrcweir
291cdf0e10cSrcweir if(aNewVec != maVPN)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir maVPN = aNewVec;
294cdf0e10cSrcweir mbVPNUsed = sal_True;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir return;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_VUP ) )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir ::basegfx::B3DVector aNewVec;
301cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertB3DVector(aNewVec, rValue);
302cdf0e10cSrcweir
303cdf0e10cSrcweir if(aNewVec != maVUP)
304cdf0e10cSrcweir {
305cdf0e10cSrcweir maVUP = aNewVec;
306cdf0e10cSrcweir mbVUPUsed = sal_True;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir return;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PROJECTION ) )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PARALLEL ) )
313cdf0e10cSrcweir mxPrjMode = drawing::ProjectionMode_PARALLEL;
314cdf0e10cSrcweir else
315cdf0e10cSrcweir mxPrjMode = drawing::ProjectionMode_PERSPECTIVE;
316cdf0e10cSrcweir return;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_DISTANCE ) )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertMeasure(mnDistance, rValue);
321cdf0e10cSrcweir return;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_FOCAL_LENGTH ) )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertMeasure(mnFocalLength, rValue);
326cdf0e10cSrcweir return;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_SHADOW_SLANT ) )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertNumber(mnShadowSlant, rValue);
331cdf0e10cSrcweir return;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_SHADE_MODE ) )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir if( IsXMLToken( rValue, XML_FLAT ) )
336cdf0e10cSrcweir mxShadeMode = drawing::ShadeMode_FLAT;
337cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_PHONG ) )
338cdf0e10cSrcweir mxShadeMode = drawing::ShadeMode_PHONG;
339cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_GOURAUD ) )
340cdf0e10cSrcweir mxShadeMode = drawing::ShadeMode_SMOOTH;
341cdf0e10cSrcweir else
342cdf0e10cSrcweir mxShadeMode = drawing::ShadeMode_DRAFT;
343cdf0e10cSrcweir return;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_AMBIENT_COLOR ) )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertColor(maAmbientColor, rValue);
348cdf0e10cSrcweir return;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_LIGHTING_MODE ) )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir mrImport.GetMM100UnitConverter().convertBool(mbLightingMode, rValue);
353cdf0e10cSrcweir return;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir }
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
358cdf0e10cSrcweir /** this sets the scene attributes at this propertyset */
setSceneAttributes(const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & xPropSet)359cdf0e10cSrcweir void SdXML3DSceneAttributesHelper::setSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir uno::Any aAny;
362cdf0e10cSrcweir
363cdf0e10cSrcweir // world transformation
364cdf0e10cSrcweir if(mbSetTransform)
365cdf0e10cSrcweir {
366cdf0e10cSrcweir aAny <<= mxHomMat;
367cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")), aAny);
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir // distance
371cdf0e10cSrcweir aAny <<= mnDistance;
372cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance")), aAny);
373cdf0e10cSrcweir
374cdf0e10cSrcweir // focalLength
375cdf0e10cSrcweir aAny <<= mnFocalLength;
376cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength")), aAny);
377cdf0e10cSrcweir
378cdf0e10cSrcweir // shadowSlant
379cdf0e10cSrcweir aAny <<= (sal_Int16)mnShadowSlant;
380cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant")), aAny);
381cdf0e10cSrcweir
382cdf0e10cSrcweir // shadeMode
383cdf0e10cSrcweir aAny <<= mxShadeMode;
384cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode")), aAny);
385cdf0e10cSrcweir
386cdf0e10cSrcweir // ambientColor
387cdf0e10cSrcweir aAny <<= maAmbientColor.GetColor();
388cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")), aAny);
389cdf0e10cSrcweir
390cdf0e10cSrcweir // lightingMode
391cdf0e10cSrcweir aAny <<= mbLightingMode;
392cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting")), aAny);
393cdf0e10cSrcweir
394cdf0e10cSrcweir if(maList.Count())
395cdf0e10cSrcweir {
396cdf0e10cSrcweir uno::Any aAny2;
397cdf0e10cSrcweir uno::Any aAny3;
398cdf0e10cSrcweir
399cdf0e10cSrcweir // set lights
400cdf0e10cSrcweir for(sal_uInt32 a(0L); a < maList.Count(); a++)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir SdXML3DLightContext* pCtx = (SdXML3DLightContext*)maList.GetObject(a);
403cdf0e10cSrcweir
404cdf0e10cSrcweir // set anys
405cdf0e10cSrcweir aAny <<= pCtx->GetDiffuseColor().GetColor();
406cdf0e10cSrcweir drawing::Direction3D xLightDir;
407cdf0e10cSrcweir xLightDir.DirectionX = pCtx->GetDirection().getX();
408cdf0e10cSrcweir xLightDir.DirectionY = pCtx->GetDirection().getY();
409cdf0e10cSrcweir xLightDir.DirectionZ = pCtx->GetDirection().getZ();
410cdf0e10cSrcweir aAny2 <<= xLightDir;
411cdf0e10cSrcweir aAny3 <<= pCtx->GetEnabled();
412cdf0e10cSrcweir
413cdf0e10cSrcweir switch(a)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir case 0:
416cdf0e10cSrcweir {
417cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor1")), aAny);
418cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection1")), aAny2);
419cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn1")), aAny3);
420cdf0e10cSrcweir break;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir case 1:
423cdf0e10cSrcweir {
424cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor2")), aAny);
425cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection2")), aAny2);
426cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn2")), aAny3);
427cdf0e10cSrcweir break;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir case 2:
430cdf0e10cSrcweir {
431cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor3")), aAny);
432cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection3")), aAny2);
433cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn3")), aAny3);
434cdf0e10cSrcweir break;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir case 3:
437cdf0e10cSrcweir {
438cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor4")), aAny);
439cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection4")), aAny2);
440cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn4")), aAny3);
441cdf0e10cSrcweir break;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir case 4:
444cdf0e10cSrcweir {
445cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor5")), aAny);
446cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection5")), aAny2);
447cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn5")), aAny3);
448cdf0e10cSrcweir break;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir case 5:
451cdf0e10cSrcweir {
452cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor6")), aAny);
453cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection6")), aAny2);
454cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn6")), aAny3);
455cdf0e10cSrcweir break;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir case 6:
458cdf0e10cSrcweir {
459cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor7")), aAny);
460cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection7")), aAny2);
461cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn7")), aAny3);
462cdf0e10cSrcweir break;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir case 7:
465cdf0e10cSrcweir {
466cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor8")), aAny);
467cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection8")), aAny2);
468cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn8")), aAny3);
469cdf0e10cSrcweir break;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir }
472cdf0e10cSrcweir }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir // CameraGeometry and camera settings
476cdf0e10cSrcweir drawing::CameraGeometry aCamGeo;
477cdf0e10cSrcweir aCamGeo.vrp.PositionX = maVRP.getX();
478cdf0e10cSrcweir aCamGeo.vrp.PositionY = maVRP.getY();
479cdf0e10cSrcweir aCamGeo.vrp.PositionZ = maVRP.getZ();
480cdf0e10cSrcweir aCamGeo.vpn.DirectionX = maVPN.getX();
481cdf0e10cSrcweir aCamGeo.vpn.DirectionY = maVPN.getY();
482cdf0e10cSrcweir aCamGeo.vpn.DirectionZ = maVPN.getZ();
483cdf0e10cSrcweir aCamGeo.vup.DirectionX = maVUP.getX();
484cdf0e10cSrcweir aCamGeo.vup.DirectionY = maVUP.getY();
485cdf0e10cSrcweir aCamGeo.vup.DirectionZ = maVUP.getZ();
486cdf0e10cSrcweir aAny <<= aCamGeo;
487cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DCameraGeometry")), aAny);
488cdf0e10cSrcweir
489cdf0e10cSrcweir // #91047# set drawing::ProjectionMode AFTER camera geometry is set
490cdf0e10cSrcweir // projection "D3DScenePerspective" drawing::ProjectionMode
491cdf0e10cSrcweir aAny <<= mxPrjMode;
492cdf0e10cSrcweir xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective")), aAny);
493cdf0e10cSrcweir }
494