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