Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/drawing/HomogenMatrix.hpp>
30 : : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
31 : : #include <com/sun/star/drawing/ProjectionMode.hpp>
32 : : #include <com/sun/star/drawing/ShadeMode.hpp>
33 : : #include <com/sun/star/drawing/Direction3D.hpp>
34 : : #include <com/sun/star/drawing/Position3D.hpp>
35 : : #include <com/sun/star/drawing/CameraGeometry.hpp>
36 : : #include <com/sun/star/drawing/DoubleSequence.hpp>
37 : : #include <tools/helpers.hxx>
38 : :
39 : : #include <sax/tools/converter.hxx>
40 : :
41 : : #include <xmloff/shapeexport.hxx>
42 : : #include "sdpropls.hxx"
43 : : #include <tools/debug.hxx>
44 : : #include <rtl/ustrbuf.hxx>
45 : : #include <xmloff/xmlexp.hxx>
46 : : #include <xmloff/xmluconv.hxx>
47 : : #include "xexptran.hxx"
48 : : #include <xmloff/xmltoken.hxx>
49 : : #include <basegfx/vector/b3dvector.hxx>
50 : :
51 : : #include "xmloff/xmlnmspe.hxx"
52 : :
53 : : using ::rtl::OUString;
54 : : using ::rtl::OUStringBuffer;
55 : :
56 : : using namespace ::com::sun::star;
57 : : using namespace ::xmloff::token;
58 : :
59 : :
60 : : //////////////////////////////////////////////////////////////////////////////
61 : :
62 : 0 : void XMLShapeExport::ImpExport3DSceneShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
63 : : {
64 [ # # ]: 0 : uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY);
65 [ # # ][ # # ]: 0 : if(xShapes.is() && xShapes->getCount())
[ # # ][ # # ]
[ # # ]
66 : : {
67 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
68 : : DBG_ASSERT( xPropSet.is(), "XMLShapeExport::ImpExport3DSceneShape can't export a scene without a propertyset" );
69 [ # # ]: 0 : if( xPropSet.is() )
70 : : {
71 : : // Transformation
72 [ # # ]: 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
73 : :
74 : : // 3d attributes
75 [ # # ]: 0 : export3DSceneAttributes( xPropSet );
76 : :
77 : : // write 3DScene shape
78 : 0 : sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
79 [ # # ]: 0 : SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DR3D, XML_SCENE, bCreateNewline, sal_True);
80 : :
81 [ # # ]: 0 : ImpExportDescription( xShape ); // #i68101#
82 [ # # ]: 0 : ImpExportEvents( xShape );
83 : :
84 : : // write 3DSceneLights
85 [ # # ]: 0 : export3DLamps( xPropSet );
86 : :
87 : : // #89764# if export of position is supressed for group shape,
88 : : // positions of contained objects should be written relative to
89 : : // the upper left edge of the group.
90 : 0 : awt::Point aUpperLeft;
91 : :
92 [ # # ]: 0 : if(!(nFeatures & SEF_EXPORT_POSITION))
93 : : {
94 : 0 : nFeatures |= SEF_EXPORT_POSITION;
95 [ # # ][ # # ]: 0 : aUpperLeft = xShape->getPosition();
96 : 0 : pRefPoint = &aUpperLeft;
97 : : }
98 : :
99 : : // write members
100 [ # # ][ # # ]: 0 : exportShapes( xShapes, nFeatures, pRefPoint );
101 : 0 : }
102 : 0 : }
103 : 0 : }
104 : :
105 : : //////////////////////////////////////////////////////////////////////////////
106 : :
107 : 0 : void XMLShapeExport::ImpExport3DShape(
108 : : const uno::Reference< drawing::XShape >& xShape,
109 : : XmlShapeType eShapeType, sal_Int32 /* nFeatures = SEF_DEFAULT */, awt::Point* /*pRefPoint = NULL */)
110 : : {
111 [ # # ]: 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
112 [ # # ]: 0 : if(xPropSet.is())
113 : : {
114 : 0 : OUString aStr;
115 : 0 : OUStringBuffer sStringBuffer;
116 : :
117 : : // transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
118 [ # # ][ # # ]: 0 : uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")));
[ # # ]
119 : 0 : drawing::HomogenMatrix xHomMat;
120 [ # # ]: 0 : aAny >>= xHomMat;
121 [ # # ]: 0 : SdXMLImExTransform3D aTransform;
122 [ # # ]: 0 : aTransform.AddHomogenMatrix(xHomMat);
123 [ # # ]: 0 : if(aTransform.NeedsAction())
124 [ # # ][ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
125 : :
126 [ # # # # ]: 0 : switch(eShapeType)
127 : : {
128 : : case XmlShapeTypeDraw3DCubeObject:
129 : : {
130 : : // write 3DCube shape
131 [ # # ]: 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, sal_True, sal_True);
132 : :
133 : : // minEdge
134 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")));
[ # # ]
135 : 0 : drawing::Position3D aPosition3D;
136 [ # # ]: 0 : aAny >>= aPosition3D;
137 : 0 : ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);
138 : :
139 : : // maxEdge
140 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")));
[ # # ]
141 : 0 : drawing::Direction3D aDirection3D;
142 [ # # ]: 0 : aAny >>= aDirection3D;
143 : 0 : ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);
144 : :
145 : : // transform maxEdge from distance to pos
146 : 0 : aDir3D = aPos3D + aDir3D;
147 : :
148 : : // write minEdge
149 [ # # ]: 0 : if(aPos3D != ::basegfx::B3DVector(-2500.0, -2500.0, -2500.0)) // write only when not default
150 : : {
151 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aPos3D);
152 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
153 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MIN_EDGE, aStr);
154 : : }
155 : :
156 : : // write maxEdge
157 [ # # ]: 0 : if(aDir3D != ::basegfx::B3DVector(2500.0, 2500.0, 2500.0)) // write only when not default
158 : : {
159 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aDir3D);
160 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
161 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr);
162 : : }
163 : :
164 [ # # ]: 0 : break;
165 : : }
166 : : case XmlShapeTypeDraw3DSphereObject:
167 : : {
168 : : // write 3DSphere shape
169 [ # # ]: 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, sal_True, sal_True);
170 : :
171 : : // Center
172 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")));
[ # # ]
173 : 0 : drawing::Position3D aPosition3D;
174 [ # # ]: 0 : aAny >>= aPosition3D;
175 : 0 : ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);
176 : :
177 : : // Size
178 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")));
[ # # ]
179 : 0 : drawing::Direction3D aDirection3D;
180 [ # # ]: 0 : aAny >>= aDirection3D;
181 : 0 : ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);
182 : :
183 : : // write Center
184 [ # # ]: 0 : if(aPos3D != ::basegfx::B3DVector(0.0, 0.0, 0.0)) // write only when not default
185 : : {
186 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aPos3D);
187 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
188 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_CENTER, aStr);
189 : : }
190 : :
191 : : // write Size
192 [ # # ]: 0 : if(aDir3D != ::basegfx::B3DVector(5000.0, 5000.0, 5000.0)) // write only when not default
193 : : {
194 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aDir3D);
195 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
196 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr);
197 : : }
198 : :
199 [ # # ]: 0 : break;
200 : : }
201 : : case XmlShapeTypeDraw3DLatheObject:
202 : : case XmlShapeTypeDraw3DExtrudeObject:
203 : : {
204 : : // write special 3DLathe/3DExtrude attributes
205 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D")));
[ # # ]
206 [ # # ]: 0 : drawing::PolyPolygonShape3D xPolyPolygon3D;
207 [ # # ]: 0 : aAny >>= xPolyPolygon3D;
208 : :
209 : : // look for maximal values
210 : 0 : double fXMin = 0;
211 : 0 : double fXMax = 0;
212 : 0 : double fYMin = 0;
213 : 0 : double fYMax = 0;
214 : 0 : sal_Bool bInit(sal_False);
215 : 0 : sal_Int32 nOuterSequenceCount(xPolyPolygon3D.SequenceX.getLength());
216 [ # # ]: 0 : drawing::DoubleSequence* pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
217 [ # # ]: 0 : drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();
218 : :
219 : : sal_Int32 a;
220 [ # # ]: 0 : for (a = 0; a < nOuterSequenceCount; a++)
221 : : {
222 : 0 : sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
223 [ # # ]: 0 : double* pArrayX = pInnerSequenceX->getArray();
224 [ # # ]: 0 : double* pArrayY = pInnerSequenceY->getArray();
225 : :
226 [ # # ]: 0 : for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
227 : : {
228 : 0 : double fX = *pArrayX++;
229 : 0 : double fY = *pArrayY++;
230 : :
231 [ # # ]: 0 : if(bInit)
232 : : {
233 [ # # ]: 0 : if(fX > fXMax)
234 : 0 : fXMax = fX;
235 : :
236 [ # # ]: 0 : if(fX < fXMin)
237 : 0 : fXMin = fX;
238 : :
239 [ # # ]: 0 : if(fY > fYMax)
240 : 0 : fYMax = fY;
241 : :
242 [ # # ]: 0 : if(fY < fYMin)
243 : 0 : fYMin = fY;
244 : : }
245 : : else
246 : : {
247 : 0 : fXMin = fXMax = fX;
248 : 0 : fYMin = fYMax = fY;
249 : 0 : bInit = sal_True;
250 : : }
251 : : }
252 : :
253 : 0 : pInnerSequenceX++;
254 : 0 : pInnerSequenceY++;
255 : : }
256 : :
257 : : // export ViewBox
258 : 0 : awt::Point aMinPoint(FRound(fXMin), FRound(fYMin));
259 : 0 : awt::Size aMaxSize(FRound(fXMax) - aMinPoint.X, FRound(fYMax) - aMinPoint.Y);
260 : : SdXMLImExViewBox aViewBox(
261 [ # # ]: 0 : aMinPoint.X, aMinPoint.Y, aMaxSize.Width, aMaxSize.Height);
262 : : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX,
263 [ # # ][ # # ]: 0 : aViewBox.GetExportString());
264 : :
265 : : // prepare svx:d element export
266 [ # # ]: 0 : SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport());
267 [ # # ]: 0 : pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
268 [ # # ]: 0 : pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();
269 : :
270 [ # # ]: 0 : for (a = 0; a < nOuterSequenceCount; a++)
271 : : {
272 : 0 : sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
273 [ # # ]: 0 : double* pArrayX = pInnerSequenceX->getArray();
274 [ # # ]: 0 : double* pArrayY = pInnerSequenceY->getArray();
275 [ # # ]: 0 : drawing::PointSequence aPoly(nInnerSequenceCount);
276 [ # # ]: 0 : awt::Point* pInnerSequence = aPoly.getArray();
277 : :
278 [ # # ]: 0 : for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
279 : : {
280 : 0 : double fX = *pArrayX++;
281 : 0 : double fY = *pArrayY++;
282 : :
283 : 0 : *pInnerSequence = awt::Point(FRound(fX), FRound(fY));
284 : 0 : pInnerSequence++;
285 : : }
286 : :
287 : : // calculate closed flag
288 [ # # ]: 0 : awt::Point* pFirst = aPoly.getArray();
289 : 0 : awt::Point* pLast = pFirst + (nInnerSequenceCount - 1);
290 [ # # ][ # # ]: 0 : sal_Bool bClosed = (pFirst->X == pLast->X && pFirst->Y == pLast->Y);
291 : :
292 : : aSvgDElement.AddPolygon(&aPoly, 0L, aMinPoint,
293 [ # # ]: 0 : aMaxSize, bClosed);
294 : :
295 : : // #80594# corrected error in PolyPolygon3D export for 3D XML
296 : 0 : pInnerSequenceX++;
297 : 0 : pInnerSequenceY++;
298 [ # # ]: 0 : }
299 : :
300 : : // write point array
301 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString());
302 : :
303 [ # # ]: 0 : if(eShapeType == XmlShapeTypeDraw3DLatheObject)
304 : : {
305 : : // write 3DLathe shape
306 [ # # ][ # # ]: 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_ROTATE, sal_True, sal_True);
307 : : }
308 : : else
309 : : {
310 : : // write 3DExtrude shape
311 [ # # ][ # # ]: 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_EXTRUDE, sal_True, sal_True);
312 : : }
313 [ # # ][ # # ]: 0 : break;
314 : : }
315 : : default:
316 : 0 : break;
317 [ # # ]: 0 : }
318 : 0 : }
319 : 0 : }
320 : :
321 : : //////////////////////////////////////////////////////////////////////////////
322 : :
323 : : /** helper for chart that adds all attributes of a 3d scene element to the export */
324 : 0 : void XMLShapeExport::export3DSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
325 : : {
326 : 0 : OUString aStr;
327 : 0 : OUStringBuffer sStringBuffer;
328 : :
329 : : // world transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
330 [ # # ][ # # ]: 0 : uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")));
[ # # ]
331 : 0 : drawing::HomogenMatrix xHomMat;
332 [ # # ]: 0 : aAny >>= xHomMat;
333 [ # # ]: 0 : SdXMLImExTransform3D aTransform;
334 [ # # ]: 0 : aTransform.AddHomogenMatrix(xHomMat);
335 [ # # ]: 0 : if(aTransform.NeedsAction())
336 [ # # ][ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
337 : :
338 : : // VRP, VPN, VUP
339 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DCameraGeometry")));
[ # # ]
340 : 0 : drawing::CameraGeometry aCamGeo;
341 [ # # ]: 0 : aAny >>= aCamGeo;
342 : :
343 : 0 : ::basegfx::B3DVector aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ);
344 [ # # ]: 0 : if(aVRP != ::basegfx::B3DVector(0.0, 0.0, 1.0)) // write only when not default
345 : : {
346 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aVRP);
347 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
348 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VRP, aStr);
349 : : }
350 : :
351 : 0 : ::basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ);
352 [ # # ]: 0 : if(aVPN != ::basegfx::B3DVector(0.0, 0.0, 1.0)) // write only when not default
353 : : {
354 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aVPN);
355 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
356 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VPN, aStr);
357 : : }
358 : :
359 : 0 : ::basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ);
360 [ # # ]: 0 : if(aVUP != ::basegfx::B3DVector(0.0, 1.0, 0.0)) // write only when not default
361 : : {
362 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aVUP);
363 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
364 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VUP, aStr);
365 : : }
366 : :
367 : : // projection "D3DScenePerspective" drawing::ProjectionMode
368 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective")));
[ # # ]
369 : : drawing::ProjectionMode xPrjMode;
370 [ # # ]: 0 : aAny >>= xPrjMode;
371 [ # # ]: 0 : if(xPrjMode == drawing::ProjectionMode_PARALLEL)
372 [ # # ]: 0 : aStr = GetXMLToken(XML_PARALLEL);
373 : : else
374 [ # # ]: 0 : aStr = GetXMLToken(XML_PERSPECTIVE);
375 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_PROJECTION, aStr);
376 : :
377 : : // distance
378 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance")));
[ # # ]
379 : 0 : sal_Int32 nDistance = 0;
380 : 0 : aAny >>= nDistance;
381 : 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
382 [ # # ]: 0 : nDistance);
383 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
384 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DISTANCE, aStr);
385 : :
386 : : // focalLength
387 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength")));
[ # # ]
388 : 0 : sal_Int32 nFocalLength = 0;
389 : 0 : aAny >>= nFocalLength;
390 : 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
391 [ # # ]: 0 : nFocalLength);
392 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
393 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, aStr);
394 : :
395 : : // shadowSlant
396 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant")));
[ # # ]
397 : 0 : sal_Int16 nShadowSlant = 0;
398 : 0 : aAny >>= nShadowSlant;
399 [ # # ]: 0 : ::sax::Converter::convertNumber(sStringBuffer, (sal_Int32)nShadowSlant);
400 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
401 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, aStr);
402 : :
403 : : // shadeMode
404 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode")));
[ # # ]
405 : : drawing::ShadeMode xShadeMode;
406 [ # # ][ # # ]: 0 : if(aAny >>= xShadeMode)
407 : : {
408 [ # # ]: 0 : if(xShadeMode == drawing::ShadeMode_FLAT)
409 [ # # ]: 0 : aStr = GetXMLToken(XML_FLAT);
410 [ # # ]: 0 : else if(xShadeMode == drawing::ShadeMode_PHONG)
411 [ # # ]: 0 : aStr = GetXMLToken(XML_PHONG);
412 [ # # ]: 0 : else if(xShadeMode == drawing::ShadeMode_SMOOTH)
413 [ # # ]: 0 : aStr = GetXMLToken(XML_GOURAUD);
414 : : else
415 [ # # ]: 0 : aStr = GetXMLToken(XML_DRAFT);
416 : : }
417 : : else
418 : : {
419 : : // ShadeMode enum not there, write default
420 [ # # ]: 0 : aStr = GetXMLToken(XML_GOURAUD);
421 : : }
422 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADE_MODE, aStr);
423 : :
424 : : // ambientColor
425 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")));
[ # # ]
426 : 0 : sal_Int32 nAmbientColor = 0;
427 : 0 : aAny >>= nAmbientColor;
428 [ # # ]: 0 : ::sax::Converter::convertColor(sStringBuffer, nAmbientColor);
429 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
430 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, aStr);
431 : :
432 : : // lightingMode
433 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting")));
[ # # ]
434 : 0 : sal_Bool bTwoSidedLighting = false;
435 : 0 : aAny >>= bTwoSidedLighting;
436 [ # # ]: 0 : ::sax::Converter::convertBool(sStringBuffer, bTwoSidedLighting);
437 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
438 [ # # ][ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, aStr);
439 : 0 : }
440 : :
441 : : /** helper for chart that exports all lamps from the propertyset */
442 : 0 : void XMLShapeExport::export3DLamps( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
443 : : {
444 : : // write lamps 1..8 as content
445 : 0 : OUString aStr;
446 : 0 : OUStringBuffer sStringBuffer;
447 : :
448 [ # # ]: 0 : const OUString aColorPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor") );
449 [ # # ]: 0 : const OUString aDirectionPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection") );
450 [ # # ]: 0 : const OUString aLightOnPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn") );
451 : :
452 : 0 : OUString aPropName;
453 : 0 : OUString aIndexStr;
454 : 0 : ::basegfx::B3DVector aLightDirection;
455 : 0 : drawing::Direction3D xLightDir;
456 : 0 : sal_Bool bLightOnOff = false;
457 [ # # ]: 0 : for(sal_Int32 nLamp = 1; nLamp <= 8; nLamp++)
458 : : {
459 : 0 : aIndexStr = OUString::valueOf( nLamp );
460 : :
461 : : // lightcolor
462 : 0 : aPropName = aColorPropName;
463 : 0 : aPropName += aIndexStr;
464 : 0 : sal_Int32 nLightColor = 0;
465 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( aPropName ) >>= nLightColor;
466 [ # # ]: 0 : ::sax::Converter::convertColor(sStringBuffer, nLightColor);
467 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
468 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIFFUSE_COLOR, aStr);
469 : :
470 : : // lightdirection
471 : 0 : aPropName = aDirectionPropName;
472 : 0 : aPropName += aIndexStr;
473 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(aPropName) >>= xLightDir;
[ # # ]
474 [ # # ]: 0 : aLightDirection = ::basegfx::B3DVector(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
475 [ # # ]: 0 : mrExport.GetMM100UnitConverter().convertB3DVector(sStringBuffer, aLightDirection);
476 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
477 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIRECTION, aStr);
478 : :
479 : : // lighton
480 : 0 : aPropName = aLightOnPropName;
481 : 0 : aPropName += aIndexStr;
482 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(aPropName) >>= bLightOnOff;
483 [ # # ]: 0 : ::sax::Converter::convertBool(sStringBuffer, bLightOnOff);
484 [ # # ]: 0 : aStr = sStringBuffer.makeStringAndClear();
485 [ # # ]: 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_ENABLED, aStr);
486 : :
487 : : // specular
488 : : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SPECULAR,
489 [ # # ][ # # ]: 0 : nLamp == 1 ? XML_TRUE : XML_FALSE);
490 : :
491 : : // write light entry
492 [ # # ]: 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_LIGHT, sal_True, sal_True);
493 [ # # ]: 0 : }
494 : 0 : }
495 : :
496 : : //////////////////////////////////////////////////////////////////////////////
497 : :
498 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|