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 10cdf0e10cSrcweir * 1163bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 2063bba73cSAndrew Rist *************************************************************/ 2163bba73cSAndrew Rist 22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 23cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 241f882ec4SArmin Le Grand 25cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix.hpp> 26cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> 27cdf0e10cSrcweir #include <com/sun/star/drawing/ProjectionMode.hpp> 28cdf0e10cSrcweir #include <com/sun/star/drawing/ShadeMode.hpp> 29cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp> 30cdf0e10cSrcweir #include <com/sun/star/drawing/Position3D.hpp> 31cdf0e10cSrcweir #include <com/sun/star/drawing/CameraGeometry.hpp> 32cdf0e10cSrcweir #include <com/sun/star/drawing/DoubleSequence.hpp> 33cdf0e10cSrcweir #include <tools/gen.hxx> 34cdf0e10cSrcweir #include <xmloff/shapeexport.hxx> 35cdf0e10cSrcweir #include "sdpropls.hxx" 36cdf0e10cSrcweir #include <tools/debug.hxx> 37cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 38cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 39cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 40cdf0e10cSrcweir #include "xexptran.hxx" 41cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 42cdf0e10cSrcweir #include <basegfx/vector/b3dvector.hxx> 431f882ec4SArmin Le Grand #include <xmloff/xmlnmspe.hxx> 441f882ec4SArmin Le Grand #include <basegfx/polygon/b3dpolypolygon.hxx> 451f882ec4SArmin Le Grand #include <basegfx/polygon/b3dpolypolygontools.hxx> 461f882ec4SArmin Le Grand #include <basegfx/matrix/b3dhommatrix.hxx> 471f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolypolygon.hxx> 481f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolypolygontools.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir using ::rtl::OUString; 51cdf0e10cSrcweir using ::rtl::OUStringBuffer; 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace ::com::sun::star; 54cdf0e10cSrcweir using namespace ::xmloff::token; 55cdf0e10cSrcweir 56cdf0e10cSrcweir 57cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 58cdf0e10cSrcweir 59cdf0e10cSrcweir void XMLShapeExport::ImpExport3DSceneShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY); 62cdf0e10cSrcweir if(xShapes.is() && xShapes->getCount()) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); 65cdf0e10cSrcweir DBG_ASSERT( xPropSet.is(), "XMLShapeExport::ImpExport3DSceneShape can't export a scene without a propertyset" ); 66cdf0e10cSrcweir if( xPropSet.is() ) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir // Transformation 69cdf0e10cSrcweir ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); 70cdf0e10cSrcweir 71cdf0e10cSrcweir // 3d attributes 72cdf0e10cSrcweir export3DSceneAttributes( xPropSet ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir // write 3DScene shape 75cdf0e10cSrcweir sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210# 76cdf0e10cSrcweir SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DR3D, XML_SCENE, bCreateNewline, sal_True); 77cdf0e10cSrcweir 78cdf0e10cSrcweir ImpExportDescription( xShape ); // #i68101# 79cdf0e10cSrcweir ImpExportEvents( xShape ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir // write 3DSceneLights 82cdf0e10cSrcweir export3DLamps( xPropSet ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir // #89764# if export of position is supressed for group shape, 85cdf0e10cSrcweir // positions of contained objects should be written relative to 86cdf0e10cSrcweir // the upper left edge of the group. 87cdf0e10cSrcweir awt::Point aUpperLeft; 88cdf0e10cSrcweir 89cdf0e10cSrcweir if(!(nFeatures & SEF_EXPORT_POSITION)) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir nFeatures |= SEF_EXPORT_POSITION; 92cdf0e10cSrcweir aUpperLeft = xShape->getPosition(); 93cdf0e10cSrcweir pRefPoint = &aUpperLeft; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir // write members 97cdf0e10cSrcweir exportShapes( xShapes, nFeatures, pRefPoint ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 103cdf0e10cSrcweir 104cdf0e10cSrcweir void XMLShapeExport::ImpExport3DShape( 105cdf0e10cSrcweir const uno::Reference< drawing::XShape >& xShape, 106cdf0e10cSrcweir XmlShapeType eShapeType, sal_Int32 /* nFeatures = SEF_DEFAULT */, awt::Point* /*pRefPoint = NULL */) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); 109cdf0e10cSrcweir if(xPropSet.is()) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir OUString aStr; 112cdf0e10cSrcweir OUStringBuffer sStringBuffer; 113cdf0e10cSrcweir 114cdf0e10cSrcweir // transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix") 115cdf0e10cSrcweir uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix"))); 116cdf0e10cSrcweir drawing::HomogenMatrix xHomMat; 117cdf0e10cSrcweir aAny >>= xHomMat; 118cdf0e10cSrcweir SdXMLImExTransform3D aTransform; 119cdf0e10cSrcweir aTransform.AddHomogenMatrix(xHomMat); 120cdf0e10cSrcweir if(aTransform.NeedsAction()) 121cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter())); 122cdf0e10cSrcweir 123cdf0e10cSrcweir switch(eShapeType) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir case XmlShapeTypeDraw3DCubeObject: 126cdf0e10cSrcweir { 127cdf0e10cSrcweir // minEdge 128cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition"))); 129cdf0e10cSrcweir drawing::Position3D aPosition3D; 130cdf0e10cSrcweir aAny >>= aPosition3D; 131cdf0e10cSrcweir ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir // maxEdge 134cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize"))); 135cdf0e10cSrcweir drawing::Direction3D aDirection3D; 136cdf0e10cSrcweir aAny >>= aDirection3D; 137cdf0e10cSrcweir ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir // transform maxEdge from distance to pos 140cdf0e10cSrcweir aDir3D = aPos3D + aDir3D; 141cdf0e10cSrcweir 142cdf0e10cSrcweir // write minEdge 143cdf0e10cSrcweir if(aPos3D != ::basegfx::B3DVector(-2500.0, -2500.0, -2500.0)) // write only when not default 144cdf0e10cSrcweir { 145cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aPos3D); 146cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 147cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MIN_EDGE, aStr); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir // write maxEdge 151cdf0e10cSrcweir if(aDir3D != ::basegfx::B3DVector(2500.0, 2500.0, 2500.0)) // write only when not default 152cdf0e10cSrcweir { 153cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aDir3D); 154cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 155cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158*5e6b5d64SArmin Le Grand // write 3DCube shape 159*5e6b5d64SArmin Le Grand // #123542# Do this *after* the attributes are added, else these will be lost since opening 160*5e6b5d64SArmin Le Grand // the scope will clear the global attribute list at the exporter 161*5e6b5d64SArmin Le Grand SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, sal_True, sal_True); 162*5e6b5d64SArmin Le Grand 163cdf0e10cSrcweir break; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir case XmlShapeTypeDraw3DSphereObject: 166cdf0e10cSrcweir { 167cdf0e10cSrcweir // Center 168cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition"))); 169cdf0e10cSrcweir drawing::Position3D aPosition3D; 170cdf0e10cSrcweir aAny >>= aPosition3D; 171cdf0e10cSrcweir ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir // Size 174cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize"))); 175cdf0e10cSrcweir drawing::Direction3D aDirection3D; 176cdf0e10cSrcweir aAny >>= aDirection3D; 177cdf0e10cSrcweir ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir // write Center 180cdf0e10cSrcweir if(aPos3D != ::basegfx::B3DVector(0.0, 0.0, 0.0)) // write only when not default 181cdf0e10cSrcweir { 182cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aPos3D); 183cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 184cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_CENTER, aStr); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir // write Size 188cdf0e10cSrcweir if(aDir3D != ::basegfx::B3DVector(5000.0, 5000.0, 5000.0)) // write only when not default 189cdf0e10cSrcweir { 190cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aDir3D); 191cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 192cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir 195*5e6b5d64SArmin Le Grand // write 3DSphere shape 196*5e6b5d64SArmin Le Grand // #123542# Do this *after* the attributes are added, else these will be lost since opening 197*5e6b5d64SArmin Le Grand // the scope will clear the global attribute list at the exporter 198*5e6b5d64SArmin Le Grand SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, sal_True, sal_True); 199*5e6b5d64SArmin Le Grand 200cdf0e10cSrcweir break; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir case XmlShapeTypeDraw3DLatheObject: 203cdf0e10cSrcweir case XmlShapeTypeDraw3DExtrudeObject: 204cdf0e10cSrcweir { 2051f882ec4SArmin Le Grand // write special 3DLathe/3DExtrude attributes, get 3D PolyPolygon as drawing::PolyPolygonShape3D 206cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D"))); 207cdf0e10cSrcweir drawing::PolyPolygonShape3D xPolyPolygon3D; 208cdf0e10cSrcweir aAny >>= xPolyPolygon3D; 209cdf0e10cSrcweir 2101f882ec4SArmin Le Grand // convert to 3D PolyPolygon 2111f882ec4SArmin Le Grand const basegfx::B3DPolyPolygon aPolyPolygon3D( 2121f882ec4SArmin Le Grand basegfx::tools::UnoPolyPolygonShape3DToB3DPolyPolygon( 2131f882ec4SArmin Le Grand xPolyPolygon3D)); 214cdf0e10cSrcweir 2151f882ec4SArmin Le Grand // convert to 2D PolyPolygon using identity 3D transformation (just grep X and Y) 2161f882ec4SArmin Le Grand const basegfx::B3DHomMatrix aB3DHomMatrixFor2DConversion; 2171f882ec4SArmin Le Grand const basegfx::B2DPolyPolygon aPolyPolygon( 2181f882ec4SArmin Le Grand basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon( 2191f882ec4SArmin Le Grand aPolyPolygon3D, 2201f882ec4SArmin Le Grand aB3DHomMatrixFor2DConversion)); 221cdf0e10cSrcweir 2221f882ec4SArmin Le Grand // get 2D range of it 2231f882ec4SArmin Le Grand const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); 224cdf0e10cSrcweir 225cdf0e10cSrcweir // export ViewBox 226cdf0e10cSrcweir SdXMLImExViewBox aViewBox( 2271f882ec4SArmin Le Grand aPolyPolygonRange.getMinX(), 2281f882ec4SArmin Le Grand aPolyPolygonRange.getMinY(), 2291f882ec4SArmin Le Grand aPolyPolygonRange.getWidth(), 2301f882ec4SArmin Le Grand aPolyPolygonRange.getHeight()); 231cdf0e10cSrcweir 2321f882ec4SArmin Le Grand mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); 233cdf0e10cSrcweir 2341f882ec4SArmin Le Grand // prepare svg:d string 2351f882ec4SArmin Le Grand const ::rtl::OUString aPolygonString( 2361f882ec4SArmin Le Grand basegfx::tools::exportToSvgD( 2371f882ec4SArmin Le Grand aPolyPolygon, 2381f882ec4SArmin Le Grand true, // bUseRelativeCoordinates 2391f882ec4SArmin Le Grand false, // bDetectQuadraticBeziers TTTT: not used in old, but maybe activated now 2401f882ec4SArmin Le Grand true)); // bHandleRelativeNextPointCompatible 241cdf0e10cSrcweir 242cdf0e10cSrcweir // write point array 2431f882ec4SArmin Le Grand mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); 244cdf0e10cSrcweir 245cdf0e10cSrcweir if(eShapeType == XmlShapeTypeDraw3DLatheObject) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir // write 3DLathe shape 248cdf0e10cSrcweir SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_ROTATE, sal_True, sal_True); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir else 251cdf0e10cSrcweir { 252cdf0e10cSrcweir // write 3DExtrude shape 253cdf0e10cSrcweir SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_EXTRUDE, sal_True, sal_True); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir break; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir default: 258cdf0e10cSrcweir break; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir } 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 264cdf0e10cSrcweir 265cdf0e10cSrcweir /** helper for chart that adds all attributes of a 3d scene element to the export */ 266cdf0e10cSrcweir void XMLShapeExport::export3DSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir OUString aStr; 269cdf0e10cSrcweir OUStringBuffer sStringBuffer; 270cdf0e10cSrcweir 271cdf0e10cSrcweir // world transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix") 272cdf0e10cSrcweir uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix"))); 273cdf0e10cSrcweir drawing::HomogenMatrix xHomMat; 274cdf0e10cSrcweir aAny >>= xHomMat; 275cdf0e10cSrcweir SdXMLImExTransform3D aTransform; 276cdf0e10cSrcweir aTransform.AddHomogenMatrix(xHomMat); 277cdf0e10cSrcweir if(aTransform.NeedsAction()) 278cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter())); 279cdf0e10cSrcweir 280cdf0e10cSrcweir // VRP, VPN, VUP 281cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DCameraGeometry"))); 282cdf0e10cSrcweir drawing::CameraGeometry aCamGeo; 283cdf0e10cSrcweir aAny >>= aCamGeo; 284cdf0e10cSrcweir 285cdf0e10cSrcweir ::basegfx::B3DVector aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ); 286cdf0e10cSrcweir if(aVRP != ::basegfx::B3DVector(0.0, 0.0, 1.0)) // write only when not default 287cdf0e10cSrcweir { 288cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aVRP); 289cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 290cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VRP, aStr); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir ::basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ); 294cdf0e10cSrcweir if(aVPN != ::basegfx::B3DVector(0.0, 0.0, 1.0)) // write only when not default 295cdf0e10cSrcweir { 296cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aVPN); 297cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 298cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VPN, aStr); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir ::basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ); 302cdf0e10cSrcweir if(aVUP != ::basegfx::B3DVector(0.0, 1.0, 0.0)) // write only when not default 303cdf0e10cSrcweir { 304cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aVUP); 305cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 306cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VUP, aStr); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir // projection "D3DScenePerspective" drawing::ProjectionMode 310cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective"))); 311cdf0e10cSrcweir drawing::ProjectionMode xPrjMode; 312cdf0e10cSrcweir aAny >>= xPrjMode; 313cdf0e10cSrcweir if(xPrjMode == drawing::ProjectionMode_PARALLEL) 314cdf0e10cSrcweir aStr = GetXMLToken(XML_PARALLEL); 315cdf0e10cSrcweir else 316cdf0e10cSrcweir aStr = GetXMLToken(XML_PERSPECTIVE); 317cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_PROJECTION, aStr); 318cdf0e10cSrcweir 319cdf0e10cSrcweir // distance 320cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance"))); 321cdf0e10cSrcweir sal_Int32 nDistance = 0; 322cdf0e10cSrcweir aAny >>= nDistance; 323cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDistance); 324cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 325cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DISTANCE, aStr); 326cdf0e10cSrcweir 327cdf0e10cSrcweir // focalLength 328cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength"))); 329cdf0e10cSrcweir sal_Int32 nFocalLength = 0; 330cdf0e10cSrcweir aAny >>= nFocalLength; 331cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nFocalLength); 332cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 333cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, aStr); 334cdf0e10cSrcweir 335cdf0e10cSrcweir // shadowSlant 336cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant"))); 337cdf0e10cSrcweir sal_Int16 nShadowSlant = 0; 338cdf0e10cSrcweir aAny >>= nShadowSlant; 339cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertNumber(sStringBuffer, (sal_Int32)nShadowSlant); 340cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 341cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, aStr); 342cdf0e10cSrcweir 343cdf0e10cSrcweir // shadeMode 344cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode"))); 345cdf0e10cSrcweir drawing::ShadeMode xShadeMode; 346cdf0e10cSrcweir if(aAny >>= xShadeMode) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir if(xShadeMode == drawing::ShadeMode_FLAT) 349cdf0e10cSrcweir aStr = GetXMLToken(XML_FLAT); 350cdf0e10cSrcweir else if(xShadeMode == drawing::ShadeMode_PHONG) 351cdf0e10cSrcweir aStr = GetXMLToken(XML_PHONG); 352cdf0e10cSrcweir else if(xShadeMode == drawing::ShadeMode_SMOOTH) 353cdf0e10cSrcweir aStr = GetXMLToken(XML_GOURAUD); 354cdf0e10cSrcweir else 355cdf0e10cSrcweir aStr = GetXMLToken(XML_DRAFT); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir else 358cdf0e10cSrcweir { 359cdf0e10cSrcweir // ShadeMode enum not there, write default 360cdf0e10cSrcweir aStr = GetXMLToken(XML_GOURAUD); 361cdf0e10cSrcweir } 362cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADE_MODE, aStr); 363cdf0e10cSrcweir 364cdf0e10cSrcweir // ambientColor 365cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))); 366cdf0e10cSrcweir sal_Int32 aColTemp = 0; 367cdf0e10cSrcweir Color aAmbientColor; 368cdf0e10cSrcweir aAny >>= aColTemp; aAmbientColor.SetColor(aColTemp); 369cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertColor(sStringBuffer, aAmbientColor); 370cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 371cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, aStr); 372cdf0e10cSrcweir 373cdf0e10cSrcweir // lightingMode 374cdf0e10cSrcweir aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting"))); 375cdf0e10cSrcweir sal_Bool bTwoSidedLighting = false; 376cdf0e10cSrcweir aAny >>= bTwoSidedLighting; 377cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertBool(sStringBuffer, bTwoSidedLighting); 378cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 379cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, aStr); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir /** helper for chart that exports all lamps from the propertyset */ 383cdf0e10cSrcweir void XMLShapeExport::export3DLamps( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir // write lamps 1..8 as content 386cdf0e10cSrcweir OUString aStr; 387cdf0e10cSrcweir OUStringBuffer sStringBuffer; 388cdf0e10cSrcweir 389cdf0e10cSrcweir const OUString aColorPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor") ); 390cdf0e10cSrcweir const OUString aDirectionPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection") ); 391cdf0e10cSrcweir const OUString aLightOnPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn") ); 392cdf0e10cSrcweir 393cdf0e10cSrcweir OUString aPropName; 394cdf0e10cSrcweir OUString aIndexStr; 395cdf0e10cSrcweir sal_Int32 aColTemp = 0; 396cdf0e10cSrcweir Color aLightColor; 397cdf0e10cSrcweir ::basegfx::B3DVector aLightDirection; 398cdf0e10cSrcweir drawing::Direction3D xLightDir; 399cdf0e10cSrcweir sal_Bool bLightOnOff = false; 400cdf0e10cSrcweir for(sal_Int32 nLamp = 1; nLamp <= 8; nLamp++) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir aIndexStr = OUString::valueOf( nLamp ); 403cdf0e10cSrcweir 404cdf0e10cSrcweir // lightcolor 405cdf0e10cSrcweir aPropName = aColorPropName; 406cdf0e10cSrcweir aPropName += aIndexStr; 407cdf0e10cSrcweir xPropSet->getPropertyValue( aPropName ) >>= aColTemp; 408cdf0e10cSrcweir aLightColor.SetColor(aColTemp); 409cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertColor(sStringBuffer, aLightColor); 410cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 411cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIFFUSE_COLOR, aStr); 412cdf0e10cSrcweir 413cdf0e10cSrcweir // lightdirection 414cdf0e10cSrcweir aPropName = aDirectionPropName; 415cdf0e10cSrcweir aPropName += aIndexStr; 416cdf0e10cSrcweir xPropSet->getPropertyValue(aPropName) >>= xLightDir; 417cdf0e10cSrcweir aLightDirection = ::basegfx::B3DVector(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); 418cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aLightDirection); 419cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 420cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIRECTION, aStr); 421cdf0e10cSrcweir 422cdf0e10cSrcweir // lighton 423cdf0e10cSrcweir aPropName = aLightOnPropName; 424cdf0e10cSrcweir aPropName += aIndexStr; 425cdf0e10cSrcweir xPropSet->getPropertyValue(aPropName) >>= bLightOnOff; 426cdf0e10cSrcweir mrExport.GetMM100UnitConverter().convertBool(sStringBuffer, bLightOnOff); 427cdf0e10cSrcweir aStr = sStringBuffer.makeStringAndClear(); 428cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_ENABLED, aStr); 429cdf0e10cSrcweir 430cdf0e10cSrcweir // specular 431cdf0e10cSrcweir mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SPECULAR, 432cdf0e10cSrcweir nLamp == 1 ? XML_TRUE : XML_FALSE); 433cdf0e10cSrcweir 434cdf0e10cSrcweir // write light entry 435cdf0e10cSrcweir SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_LIGHT, sal_True, sal_True); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir } 438cdf0e10cSrcweir 439cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 440