calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / tools / primitive2dxmldump.cxx
blob08f585a3638b62eb5a134956f734ddf604ffd1ff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <drawinglayer/tools/primitive2dxmldump.hxx>
12 #include <rtl/string.hxx>
13 #include <tools/stream.hxx>
14 #include <tools/XmlWriter.hxx>
16 #include <math.h>
17 #include <memory>
18 #include <sal/log.hxx>
20 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
21 #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
22 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
23 #include <drawinglayer/primitive2d/Tools.hxx>
24 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
25 #include <drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx>
26 #include <drawinglayer/primitive2d/PolygonStrokeArrowPrimitive2D.hxx>
27 #include <drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx>
28 #include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx>
29 #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
30 #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
31 #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
32 #include <primitive2d/textlineprimitive2d.hxx>
33 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
34 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
35 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
36 #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
37 #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
38 #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
40 #include <drawinglayer/primitive2d/sceneprimitive2d.hxx>
41 #include <drawinglayer/geometry/viewinformation2d.hxx>
42 #include <drawinglayer/attribute/lineattribute.hxx>
43 #include <drawinglayer/attribute/fontattribute.hxx>
45 #include <basegfx/polygon/b2dpolypolygontools.hxx>
46 #include <basegfx/polygon/b2dpolygontools.hxx>
47 #include <basegfx/utils/gradienttools.hxx>
48 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
49 #include <toolkit/helper/vclunohelper.hxx>
51 #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
52 #include <drawinglayer/primitive3d/Tools.hxx>
53 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
54 #include <drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx>
55 #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
56 #include <drawinglayer/attribute/sdrfillattribute.hxx>
57 #include <drawinglayer/attribute/fillhatchattribute.hxx>
58 #include <drawinglayer/attribute/fillgradientattribute.hxx>
59 #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
60 #include <drawinglayer/attribute/materialattribute3d.hxx>
62 using namespace drawinglayer::primitive2d;
64 namespace drawinglayer
66 namespace
68 const size_t constMaxActionType = 513;
70 OUString convertColorToString(const basegfx::BColor& rColor)
72 OUString aRGBString = Color(rColor).AsRGBHexString();
73 return "#" + aRGBString;
76 void writeMatrix(::tools::XmlWriter& rWriter, const basegfx::B2DHomMatrix& rMatrix)
78 rWriter.attribute("xy11", rMatrix.get(0, 0));
79 rWriter.attribute("xy12", rMatrix.get(0, 1));
80 rWriter.attribute("xy13", rMatrix.get(0, 2));
81 rWriter.attribute("xy21", rMatrix.get(1, 0));
82 rWriter.attribute("xy22", rMatrix.get(1, 1));
83 rWriter.attribute("xy23", rMatrix.get(1, 2));
84 rWriter.attribute("xy31", rMatrix.get(2, 0));
85 rWriter.attribute("xy32", rMatrix.get(2, 1));
86 rWriter.attribute("xy33", rMatrix.get(2, 2));
89 void writeMatrix3D(::tools::XmlWriter& rWriter, const basegfx::B3DHomMatrix& rMatrix)
91 rWriter.attribute("xy11", rMatrix.get(0, 0));
92 rWriter.attribute("xy12", rMatrix.get(0, 1));
93 rWriter.attribute("xy13", rMatrix.get(0, 2));
94 rWriter.attribute("xy14", rMatrix.get(0, 3));
95 rWriter.attribute("xy21", rMatrix.get(1, 0));
96 rWriter.attribute("xy22", rMatrix.get(1, 1));
97 rWriter.attribute("xy23", rMatrix.get(1, 2));
98 rWriter.attribute("xy24", rMatrix.get(1, 3));
99 rWriter.attribute("xy31", rMatrix.get(2, 0));
100 rWriter.attribute("xy32", rMatrix.get(2, 1));
101 rWriter.attribute("xy33", rMatrix.get(2, 2));
102 rWriter.attribute("xy34", rMatrix.get(2, 3));
103 rWriter.attribute("xy41", rMatrix.get(3, 0));
104 rWriter.attribute("xy42", rMatrix.get(3, 1));
105 rWriter.attribute("xy43", rMatrix.get(3, 2));
106 rWriter.attribute("xy44", rMatrix.get(3, 3));
109 void writePolyPolygon(::tools::XmlWriter& rWriter, const basegfx::B2DPolyPolygon& rB2DPolyPolygon)
111 rWriter.startElement("polypolygon");
112 const basegfx::B2DRange aB2DRange(rB2DPolyPolygon.getB2DRange());
113 rWriter.attributeDouble("height", aB2DRange.getHeight());
114 rWriter.attributeDouble("width", aB2DRange.getWidth());
115 rWriter.attributeDouble("minx", aB2DRange.getMinX());
116 rWriter.attributeDouble("miny", aB2DRange.getMinY());
117 rWriter.attributeDouble("maxx", aB2DRange.getMaxX());
118 rWriter.attributeDouble("maxy", aB2DRange.getMaxY());
119 rWriter.attribute("path", basegfx::utils::exportToSvgD(rB2DPolyPolygon, true, true, false));
121 for (basegfx::B2DPolygon const& rPolygon : rB2DPolyPolygon)
123 rWriter.startElement("polygon");
124 for (sal_uInt32 i = 0; i < rPolygon.count(); ++i)
126 basegfx::B2DPoint const& rPoint = rPolygon.getB2DPoint(i);
128 rWriter.startElement("point");
129 rWriter.attribute("x", OUString::number(rPoint.getX()));
130 rWriter.attribute("y", OUString::number(rPoint.getY()));
131 rWriter.endElement();
133 rWriter.endElement();
136 rWriter.endElement();
139 void writeStrokeAttribute(::tools::XmlWriter& rWriter,
140 const drawinglayer::attribute::StrokeAttribute& rStrokeAttribute)
142 if (!rStrokeAttribute.getDotDashArray().empty())
144 rWriter.startElement("stroke");
146 OUString sDotDash;
147 for (double fDotDash : rStrokeAttribute.getDotDashArray())
149 sDotDash += OUString::number(lround(fDotDash)) + " ";
151 rWriter.attribute("dotDashArray", sDotDash);
152 rWriter.attribute("fullDotDashLength", rStrokeAttribute.getFullDotDashLen());
153 rWriter.endElement();
157 void writeLineAttribute(::tools::XmlWriter& rWriter,
158 const drawinglayer::attribute::LineAttribute& rLineAttribute)
160 rWriter.startElement("line");
161 rWriter.attribute("color", convertColorToString(rLineAttribute.getColor()));
162 rWriter.attribute("width", rLineAttribute.getWidth());
163 switch (rLineAttribute.getLineJoin())
165 case basegfx::B2DLineJoin::NONE:
166 rWriter.attribute("linejoin", "NONE");
167 break;
168 case basegfx::B2DLineJoin::Bevel:
169 rWriter.attribute("linejoin", "Bevel");
170 break;
171 case basegfx::B2DLineJoin::Miter:
173 rWriter.attribute("linejoin", "Miter");
174 rWriter.attribute("miterangle",
175 basegfx::rad2deg(rLineAttribute.getMiterMinimumAngle()));
176 break;
178 case basegfx::B2DLineJoin::Round:
179 rWriter.attribute("linejoin", "Round");
180 break;
181 default:
182 rWriter.attribute("linejoin", "Unknown");
183 break;
185 switch (rLineAttribute.getLineCap())
187 case css::drawing::LineCap::LineCap_BUTT:
188 rWriter.attribute("linecap", "BUTT");
189 break;
190 case css::drawing::LineCap::LineCap_ROUND:
191 rWriter.attribute("linecap", "ROUND");
192 break;
193 case css::drawing::LineCap::LineCap_SQUARE:
194 rWriter.attribute("linecap", "SQUARE");
195 break;
196 default:
197 rWriter.attribute("linecap", "Unknown");
198 break;
201 rWriter.endElement();
204 void writeSdrLineAttribute(::tools::XmlWriter& rWriter,
205 const drawinglayer::attribute::SdrLineAttribute& rLineAttribute)
207 if (rLineAttribute.isDefault())
208 return;
210 rWriter.startElement("line");
211 rWriter.attribute("color", convertColorToString(rLineAttribute.getColor()));
212 rWriter.attribute("width", rLineAttribute.getWidth());
213 rWriter.attribute("transparence", rLineAttribute.getTransparence());
215 switch (rLineAttribute.getJoin())
217 case basegfx::B2DLineJoin::NONE:
218 rWriter.attribute("linejoin", "NONE");
219 break;
220 case basegfx::B2DLineJoin::Bevel:
221 rWriter.attribute("linejoin", "Bevel");
222 break;
223 case basegfx::B2DLineJoin::Miter:
224 rWriter.attribute("linejoin", "Miter");
225 break;
226 case basegfx::B2DLineJoin::Round:
227 rWriter.attribute("linejoin", "Round");
228 break;
229 default:
230 rWriter.attribute("linejoin", "Unknown");
231 break;
233 switch (rLineAttribute.getCap())
235 case css::drawing::LineCap::LineCap_BUTT:
236 rWriter.attribute("linecap", "BUTT");
237 break;
238 case css::drawing::LineCap::LineCap_ROUND:
239 rWriter.attribute("linecap", "ROUND");
240 break;
241 case css::drawing::LineCap::LineCap_SQUARE:
242 rWriter.attribute("linecap", "SQUARE");
243 break;
244 default:
245 rWriter.attribute("linecap", "Unknown");
246 break;
249 if (!rLineAttribute.getDotDashArray().empty())
251 OUString sDotDash;
252 for (double fDotDash : rLineAttribute.getDotDashArray())
254 sDotDash += OUString::number(fDotDash) + " ";
256 rWriter.attribute("dotDashArray", sDotDash);
257 rWriter.attribute("fullDotDashLength", rLineAttribute.getFullDotDashLen());
260 rWriter.endElement();
263 void writeSdrFillAttribute(::tools::XmlWriter& rWriter,
264 const drawinglayer::attribute::SdrFillAttribute& rFillAttribute)
266 if (rFillAttribute.isDefault())
267 return;
269 rWriter.startElement("fill");
270 rWriter.attribute("color", convertColorToString(rFillAttribute.getColor()));
271 rWriter.attribute("transparence", rFillAttribute.getTransparence());
273 auto const& rGradient = rFillAttribute.getGradient();
274 if (!rGradient.isDefault())
276 rWriter.startElement("gradient");
277 switch (rGradient.getStyle())
279 default: // GradientStyle_MAKE_FIXED_SIZE
280 case css::awt::GradientStyle_LINEAR:
281 rWriter.attribute("style", "Linear");
282 break;
283 case css::awt::GradientStyle_AXIAL:
284 rWriter.attribute("style", "Axial");
285 break;
286 case css::awt::GradientStyle_RADIAL:
287 rWriter.attribute("style", "Radial");
288 break;
289 case css::awt::GradientStyle_ELLIPTICAL:
290 rWriter.attribute("style", "Elliptical");
291 break;
292 case css::awt::GradientStyle_SQUARE:
293 rWriter.attribute("style", "Square");
294 break;
295 case css::awt::GradientStyle_RECT:
296 rWriter.attribute("style", "Rect");
297 break;
299 rWriter.attribute("border", rGradient.getBorder());
300 rWriter.attribute("offsetX", rGradient.getOffsetX());
301 rWriter.attribute("offsetY", rGradient.getOffsetY());
302 rWriter.attribute("angle", rGradient.getAngle());
303 rWriter.attribute("steps", rGradient.getSteps());
305 auto const& rColorStops(rGradient.getColorStops());
306 for (size_t a(0); a < rColorStops.size(); a++)
308 if (0 == a)
309 rWriter.attribute("startColor",
310 convertColorToString(rColorStops[a].getStopColor()));
311 else if (rColorStops.size() == a + 1)
312 rWriter.attribute("endColor", convertColorToString(rColorStops[a].getStopColor()));
313 else
315 rWriter.startElement("colorStop");
316 rWriter.attribute("stopOffset", rColorStops[a].getStopOffset());
317 rWriter.attribute("stopColor", convertColorToString(rColorStops[a].getStopColor()));
318 rWriter.endElement();
321 rWriter.endElement();
324 auto const& rHatch = rFillAttribute.getHatch();
325 if (!rHatch.isDefault())
327 rWriter.startElement("hatch");
328 switch (rHatch.getStyle())
330 case drawinglayer::attribute::HatchStyle::Single:
331 rWriter.attribute("style", "Single");
332 break;
333 case drawinglayer::attribute::HatchStyle::Double:
334 rWriter.attribute("style", "Double");
335 break;
336 case drawinglayer::attribute::HatchStyle::Triple:
337 rWriter.attribute("style", "Triple");
338 break;
340 rWriter.attribute("distance", rHatch.getDistance());
341 rWriter.attribute("angle", rHatch.getAngle());
342 rWriter.attribute("color", convertColorToString(rHatch.getColor()));
343 rWriter.attribute("minimalDescreteDistance", rHatch.getMinimalDiscreteDistance());
344 rWriter.attribute("isFillBackground", sal_Int32(rHatch.isFillBackground()));
345 rWriter.endElement();
348 auto const& rGraphic = rFillAttribute.getFillGraphic();
349 if (!rGraphic.isDefault())
351 rWriter.startElement("graphic");
352 // TODO
353 rWriter.endElement();
356 rWriter.endElement();
359 void writeShadeMode(::tools::XmlWriter& rWriter, const css::drawing::ShadeMode& rMode)
361 switch (rMode)
363 case css::drawing::ShadeMode_FLAT:
364 rWriter.attribute("shadeMode", "Flat");
365 break;
366 case css::drawing::ShadeMode_SMOOTH:
367 rWriter.attribute("shadeMode", "Smooth");
368 break;
369 case css::drawing::ShadeMode_PHONG:
370 rWriter.attribute("shadeMode", "Phong");
371 break;
372 case css::drawing::ShadeMode_DRAFT:
373 rWriter.attribute("shadeMode", "Draft");
374 break;
375 default:
376 rWriter.attribute("shadeMode", "Undefined");
377 break;
381 void writeProjectionMode(::tools::XmlWriter& rWriter, const css::drawing::ProjectionMode& rMode)
383 switch (rMode)
385 case css::drawing::ProjectionMode_PARALLEL:
386 rWriter.attribute("projectionMode", "Parallel");
387 break;
388 case css::drawing::ProjectionMode_PERSPECTIVE:
389 rWriter.attribute("projectionMode", "Perspective");
390 break;
391 default:
392 rWriter.attribute("projectionMode", "Undefined");
393 break;
397 void writeNormalsKind(::tools::XmlWriter& rWriter, const css::drawing::NormalsKind& rKind)
399 switch (rKind)
401 case css::drawing::NormalsKind_SPECIFIC:
402 rWriter.attribute("normalsKind", "Specific");
403 break;
404 case css::drawing::NormalsKind_FLAT:
405 rWriter.attribute("normalsKind", "Flat");
406 break;
407 case css::drawing::NormalsKind_SPHERE:
408 rWriter.attribute("normalsKind", "Sphere");
409 break;
410 default:
411 rWriter.attribute("normalsKind", "Undefined");
412 break;
416 void writeTextureProjectionMode(::tools::XmlWriter& rWriter, const char* pElement,
417 const css::drawing::TextureProjectionMode& rMode)
419 switch (rMode)
421 case css::drawing::TextureProjectionMode_OBJECTSPECIFIC:
422 rWriter.attribute(pElement, "Specific");
423 break;
424 case css::drawing::TextureProjectionMode_PARALLEL:
425 rWriter.attribute(pElement, "Parallel");
426 break;
427 case css::drawing::TextureProjectionMode_SPHERE:
428 rWriter.attribute(pElement, "Sphere");
429 break;
430 default:
431 rWriter.attribute(pElement, "Undefined");
432 break;
436 void writeTextureKind(::tools::XmlWriter& rWriter, const css::drawing::TextureKind2& rKind)
438 switch (rKind)
440 case css::drawing::TextureKind2_LUMINANCE:
441 rWriter.attribute("textureKind", "Luminance");
442 break;
443 case css::drawing::TextureKind2_INTENSITY:
444 rWriter.attribute("textureKind", "Intensity");
445 break;
446 case css::drawing::TextureKind2_COLOR:
447 rWriter.attribute("textureKind", "Color");
448 break;
449 default:
450 rWriter.attribute("textureKind", "Undefined");
451 break;
455 void writeTextureMode(::tools::XmlWriter& rWriter, const css::drawing::TextureMode& rMode)
457 switch (rMode)
459 case css::drawing::TextureMode_REPLACE:
460 rWriter.attribute("textureMode", "Replace");
461 break;
462 case css::drawing::TextureMode_MODULATE:
463 rWriter.attribute("textureMode", "Modulate");
464 break;
465 case css::drawing::TextureMode_BLEND:
466 rWriter.attribute("textureMode", "Blend");
467 break;
468 default:
469 rWriter.attribute("textureMode", "Undefined");
470 break;
474 void writeMaterialAttribute(::tools::XmlWriter& rWriter,
475 const drawinglayer::attribute::MaterialAttribute3D& rMaterial)
477 rWriter.startElement("material");
478 rWriter.attribute("color", convertColorToString(rMaterial.getColor()));
479 rWriter.attribute("specular", convertColorToString(rMaterial.getSpecular()));
480 rWriter.attribute("emission", convertColorToString(rMaterial.getEmission()));
481 rWriter.attribute("specularIntensity", rMaterial.getSpecularIntensity());
482 rWriter.endElement();
485 void writeSpreadMethod(::tools::XmlWriter& rWriter,
486 const drawinglayer::primitive2d::SpreadMethod& rSpreadMethod)
488 switch (rSpreadMethod)
490 case drawinglayer::primitive2d::SpreadMethod::Pad:
491 rWriter.attribute("spreadmethod", "pad");
492 break;
493 case drawinglayer::primitive2d::SpreadMethod::Reflect:
494 rWriter.attribute("spreadmethod", "reflect");
495 break;
496 case drawinglayer::primitive2d::SpreadMethod::Repeat:
497 rWriter.attribute("spreadmethod", "repeat");
498 break;
499 default:
500 rWriter.attribute("spreadmethod", "unknown");
504 } // end anonymous namespace
506 Primitive2dXmlDump::Primitive2dXmlDump()
507 : maFilter(constMaxActionType, false)
511 Primitive2dXmlDump::~Primitive2dXmlDump() = default;
513 void Primitive2dXmlDump::dump(
514 const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
515 const OUString& rStreamName)
517 std::unique_ptr<SvStream> pStream;
519 if (rStreamName.isEmpty())
520 pStream.reset(new SvMemoryStream());
521 else
522 pStream.reset(new SvFileStream(rStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
524 ::tools::XmlWriter aWriter(pStream.get());
525 aWriter.startDocument();
526 aWriter.startElement("primitive2D");
528 decomposeAndWrite(rPrimitive2DSequence, aWriter);
530 aWriter.endElement();
531 aWriter.endDocument();
533 pStream->Seek(STREAM_SEEK_TO_BEGIN);
536 namespace
538 class Primitive3DXmlDump
540 public:
541 void decomposeAndWrite(const drawinglayer::primitive3d::Primitive3DContainer& rSequence,
542 ::tools::XmlWriter& rWriter)
544 for (size_t i = 0; i < rSequence.size(); i++)
546 drawinglayer::primitive3d::Primitive3DReference xReference = rSequence[i];
547 const auto* pBasePrimitive
548 = static_cast<const drawinglayer::primitive3d::BasePrimitive3D*>(xReference.get());
549 sal_uInt32 nId = pBasePrimitive->getPrimitive3DID();
550 OUString sCurrentElementTag = drawinglayer::primitive3d::idToString(nId);
551 switch (nId)
553 case PRIMITIVE3D_ID_SDREXTRUDEPRIMITIVE3D:
555 const auto* pExtrudePrimitive3D
556 = static_cast<const drawinglayer::primitive3d::SdrExtrudePrimitive3D*>(
557 xReference.get());
558 rWriter.startElement("extrude3D");
560 rWriter.startElement("matrix3D");
561 writeMatrix3D(rWriter, pExtrudePrimitive3D->getTransform());
562 rWriter.endElement();
564 rWriter.attribute("textureSizeX", pExtrudePrimitive3D->getTextureSize().getX());
565 rWriter.attribute("textureSizeY", pExtrudePrimitive3D->getTextureSize().getY());
566 auto const& rLFSAttribute = pExtrudePrimitive3D->getSdrLFSAttribute();
567 writeSdrLineAttribute(rWriter, rLFSAttribute.getLine());
568 writeSdrFillAttribute(rWriter, rLFSAttribute.getFill());
570 rWriter.startElement("object3Dattributes");
572 auto const& r3DObjectAttributes
573 = pExtrudePrimitive3D->getSdr3DObjectAttribute();
575 writeNormalsKind(rWriter, r3DObjectAttributes.getNormalsKind());
576 writeTextureProjectionMode(rWriter, "textureProjectionX",
577 r3DObjectAttributes.getTextureProjectionX());
578 writeTextureProjectionMode(rWriter, "textureProjectionY",
579 r3DObjectAttributes.getTextureProjectionY());
580 writeTextureKind(rWriter, r3DObjectAttributes.getTextureKind());
581 writeTextureMode(rWriter, r3DObjectAttributes.getTextureMode());
582 writeMaterialAttribute(rWriter, r3DObjectAttributes.getMaterial());
584 rWriter.attribute("normalsInvert",
585 sal_Int32(r3DObjectAttributes.getNormalsInvert()));
586 rWriter.attribute("doubleSided",
587 sal_Int32(r3DObjectAttributes.getDoubleSided()));
588 rWriter.attribute("shadow3D", sal_Int32(r3DObjectAttributes.getShadow3D()));
589 rWriter.attribute("textureFilter",
590 sal_Int32(r3DObjectAttributes.getTextureFilter()));
591 rWriter.attribute("reducedGeometry",
592 sal_Int32(r3DObjectAttributes.getReducedLineGeometry()));
594 rWriter.endElement();
596 rWriter.attribute("depth", pExtrudePrimitive3D->getDepth());
597 rWriter.attribute("diagonal", pExtrudePrimitive3D->getDiagonal());
598 rWriter.attribute("backScale", pExtrudePrimitive3D->getBackScale());
599 rWriter.attribute("smoothNormals",
600 sal_Int32(pExtrudePrimitive3D->getSmoothNormals()));
601 rWriter.attribute("smoothLids",
602 sal_Int32(pExtrudePrimitive3D->getSmoothLids()));
603 rWriter.attribute("characterMode",
604 sal_Int32(pExtrudePrimitive3D->getCharacterMode()));
605 rWriter.attribute("closeFront",
606 sal_Int32(pExtrudePrimitive3D->getCloseFront()));
607 rWriter.attribute("closeBack", sal_Int32(pExtrudePrimitive3D->getCloseBack()));
608 writePolyPolygon(rWriter, pExtrudePrimitive3D->getPolyPolygon());
609 rWriter.endElement();
611 break;
613 default:
615 rWriter.startElement("unhandled");
616 rWriter.attribute("id",
617 OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8));
618 rWriter.attribute("idNumber", nId);
620 drawinglayer::geometry::ViewInformation3D aViewInformation3D;
621 drawinglayer::primitive3d::Primitive3DContainer aContainer;
622 aContainer = pBasePrimitive->get3DDecomposition(aViewInformation3D);
623 decomposeAndWrite(aContainer, rWriter);
624 rWriter.endElement();
626 break;
632 xmlDocUniquePtr Primitive2dXmlDump::dumpAndParse(
633 const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
634 const OUString& rStreamName)
636 std::unique_ptr<SvStream> pStream;
638 if (rStreamName.isEmpty())
639 pStream.reset(new SvMemoryStream());
640 else
641 pStream.reset(new SvFileStream(rStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
643 ::tools::XmlWriter aWriter(pStream.get());
644 aWriter.startDocument();
645 aWriter.startElement("primitive2D");
647 decomposeAndWrite(rPrimitive2DSequence, aWriter);
649 aWriter.endElement();
650 aWriter.endDocument();
652 pStream->Seek(STREAM_SEEK_TO_BEGIN);
654 std::size_t nSize = pStream->remainingSize();
655 std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]);
656 pStream->ReadBytes(pBuffer.get(), nSize);
657 pBuffer[nSize] = 0;
658 SAL_INFO("drawinglayer", "Parsed XML: " << pBuffer.get());
660 return xmlDocUniquePtr(xmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get())));
663 void Primitive2dXmlDump::decomposeAndWrite(
664 const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
665 ::tools::XmlWriter& rWriter)
667 for (size_t i = 0; i < rPrimitive2DSequence.size(); i++)
669 const BasePrimitive2D* pBasePrimitive = rPrimitive2DSequence[i].get();
670 sal_uInt32 nId = pBasePrimitive->getPrimitive2DID();
671 if (nId < maFilter.size() && maFilter[nId])
672 continue;
674 OUString sCurrentElementTag = drawinglayer::primitive2d::idToString(nId);
676 switch (nId)
678 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D:
680 const BitmapPrimitive2D& rBitmapPrimitive2D
681 = dynamic_cast<const BitmapPrimitive2D&>(*pBasePrimitive);
682 rWriter.startElement("bitmap");
683 writeMatrix(rWriter, rBitmapPrimitive2D.getTransform());
685 const BitmapEx aBitmapEx(rBitmapPrimitive2D.getBitmap());
686 const Size& rSizePixel(aBitmapEx.GetSizePixel());
688 rWriter.attribute("height", rSizePixel.getHeight());
689 rWriter.attribute("width", rSizePixel.getWidth());
690 rWriter.attribute("checksum", OString(std::to_string(aBitmapEx.GetChecksum())));
692 for (tools::Long y = 0; y < rSizePixel.getHeight(); y++)
694 rWriter.startElement("data");
695 OUString aBitmapData = "";
696 for (tools::Long x = 0; x < rSizePixel.getHeight(); x++)
698 if (x != 0)
699 aBitmapData = aBitmapData + ",";
700 aBitmapData = aBitmapData + aBitmapEx.GetPixelColor(x, y).AsRGBHexString();
702 rWriter.attribute("row", aBitmapData);
703 rWriter.endElement();
705 rWriter.endElement();
707 break;
708 case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D:
710 const HiddenGeometryPrimitive2D& rHiddenGeometryPrimitive2D
711 = dynamic_cast<const HiddenGeometryPrimitive2D&>(*pBasePrimitive);
712 rWriter.startElement("hiddengeometry");
713 decomposeAndWrite(rHiddenGeometryPrimitive2D.getChildren(), rWriter);
714 rWriter.endElement();
716 break;
718 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D:
720 const TransformPrimitive2D& rTransformPrimitive2D
721 = dynamic_cast<const TransformPrimitive2D&>(*pBasePrimitive);
722 rWriter.startElement("transform");
723 writeMatrix(rWriter, rTransformPrimitive2D.getTransformation());
724 decomposeAndWrite(rTransformPrimitive2D.getChildren(), rWriter);
725 rWriter.endElement();
727 break;
729 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D:
731 const PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D
732 = dynamic_cast<const PolyPolygonColorPrimitive2D&>(*pBasePrimitive);
734 rWriter.startElement("polypolygoncolor");
735 rWriter.attribute("color",
736 convertColorToString(rPolyPolygonColorPrimitive2D.getBColor()));
738 const basegfx::B2DPolyPolygon& aB2DPolyPolygon(
739 rPolyPolygonColorPrimitive2D.getB2DPolyPolygon());
740 writePolyPolygon(rWriter, aB2DPolyPolygon);
742 rWriter.endElement();
744 break;
745 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D:
747 const PointArrayPrimitive2D& rPointArrayPrimitive2D
748 = dynamic_cast<const PointArrayPrimitive2D&>(*pBasePrimitive);
749 rWriter.startElement("pointarray");
751 rWriter.attribute("color",
752 convertColorToString(rPointArrayPrimitive2D.getRGBColor()));
754 const std::vector<basegfx::B2DPoint> aPositions
755 = rPointArrayPrimitive2D.getPositions();
756 for (std::vector<basegfx::B2DPoint>::const_iterator iter = aPositions.begin();
757 iter != aPositions.end(); ++iter)
759 rWriter.startElement("point");
760 rWriter.attribute("x", OUString::number(iter->getX()));
761 rWriter.attribute("y", OUString::number(iter->getY()));
762 rWriter.endElement();
765 rWriter.endElement();
767 break;
769 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D:
771 const PolygonStrokeArrowPrimitive2D& rPolygonStrokeArrowPrimitive2D
772 = dynamic_cast<const PolygonStrokeArrowPrimitive2D&>(*pBasePrimitive);
773 rWriter.startElement("polygonstrokearrow");
775 rWriter.startElement("polygon");
776 rWriter.content(basegfx::utils::exportToSvgPoints(
777 rPolygonStrokeArrowPrimitive2D.getB2DPolygon()));
778 rWriter.endElement();
780 if (rPolygonStrokeArrowPrimitive2D.getStart().getB2DPolyPolygon().count())
782 rWriter.startElement("linestartattribute");
783 rWriter.attribute("width",
784 rPolygonStrokeArrowPrimitive2D.getStart().getWidth());
785 rWriter.attribute("centered",
786 static_cast<sal_Int32>(
787 rPolygonStrokeArrowPrimitive2D.getStart().isCentered()));
788 writePolyPolygon(rWriter,
789 rPolygonStrokeArrowPrimitive2D.getStart().getB2DPolyPolygon());
790 rWriter.endElement();
793 if (rPolygonStrokeArrowPrimitive2D.getEnd().getB2DPolyPolygon().count())
795 rWriter.startElement("lineendattribute");
796 rWriter.attribute("width", rPolygonStrokeArrowPrimitive2D.getEnd().getWidth());
797 rWriter.attribute("centered",
798 static_cast<sal_Int32>(
799 rPolygonStrokeArrowPrimitive2D.getEnd().isCentered()));
800 writePolyPolygon(rWriter,
801 rPolygonStrokeArrowPrimitive2D.getEnd().getB2DPolyPolygon());
802 rWriter.endElement();
805 writeLineAttribute(rWriter, rPolygonStrokeArrowPrimitive2D.getLineAttribute());
806 writeStrokeAttribute(rWriter, rPolygonStrokeArrowPrimitive2D.getStrokeAttribute());
807 rWriter.endElement();
809 break;
811 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
813 const PolygonStrokePrimitive2D& rPolygonStrokePrimitive2D
814 = dynamic_cast<const PolygonStrokePrimitive2D&>(*pBasePrimitive);
815 rWriter.startElement("polygonstroke");
817 rWriter.startElement("polygon");
818 rWriter.content(
819 basegfx::utils::exportToSvgPoints(rPolygonStrokePrimitive2D.getB2DPolygon()));
820 rWriter.endElement();
822 writeLineAttribute(rWriter, rPolygonStrokePrimitive2D.getLineAttribute());
823 writeStrokeAttribute(rWriter, rPolygonStrokePrimitive2D.getStrokeAttribute());
824 rWriter.endElement();
826 break;
827 case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D:
829 const PolyPolygonStrokePrimitive2D& rPolyPolygonStrokePrimitive2D
830 = dynamic_cast<const PolyPolygonStrokePrimitive2D&>(*pBasePrimitive);
831 rWriter.startElement("polypolygonstroke");
833 writeLineAttribute(rWriter, rPolyPolygonStrokePrimitive2D.getLineAttribute());
834 writeStrokeAttribute(rWriter, rPolyPolygonStrokePrimitive2D.getStrokeAttribute());
835 writePolyPolygon(rWriter, rPolyPolygonStrokePrimitive2D.getB2DPolyPolygon());
837 rWriter.endElement();
839 break;
841 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
843 const PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D
844 = dynamic_cast<const PolygonHairlinePrimitive2D&>(*pBasePrimitive);
845 rWriter.startElement("polygonhairline");
847 rWriter.attribute("color",
848 convertColorToString(rPolygonHairlinePrimitive2D.getBColor()));
850 rWriter.startElement("polygon");
851 rWriter.content(
852 basegfx::utils::exportToSvgPoints(rPolygonHairlinePrimitive2D.getB2DPolygon()));
853 rWriter.endElement();
855 rWriter.endElement();
857 break;
859 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D:
861 const TextDecoratedPortionPrimitive2D& rTextDecoratedPortionPrimitive2D
862 = dynamic_cast<const TextDecoratedPortionPrimitive2D&>(*pBasePrimitive);
863 rWriter.startElement("textdecoratedportion");
864 writeMatrix(rWriter, rTextDecoratedPortionPrimitive2D.getTextTransform());
866 rWriter.attribute("text", rTextDecoratedPortionPrimitive2D.getText());
867 rWriter.attribute(
868 "fontcolor",
869 convertColorToString(rTextDecoratedPortionPrimitive2D.getFontColor()));
871 const drawinglayer::attribute::FontAttribute& aFontAttribute
872 = rTextDecoratedPortionPrimitive2D.getFontAttribute();
873 rWriter.attribute("familyname", aFontAttribute.getFamilyName());
874 rWriter.endElement();
876 break;
878 case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D:
880 const TextLinePrimitive2D& rTextLinePrimitive2D
881 = dynamic_cast<const TextLinePrimitive2D&>(*pBasePrimitive);
882 rWriter.startElement("textline");
883 writeMatrix(rWriter, rTextLinePrimitive2D.getObjectTransformation());
885 rWriter.attribute("width", rTextLinePrimitive2D.getWidth());
886 rWriter.attribute("offset", rTextLinePrimitive2D.getOffset());
887 rWriter.attribute("height", rTextLinePrimitive2D.getHeight());
888 rWriter.attribute("color",
889 convertColorToString(rTextLinePrimitive2D.getLineColor()));
890 rWriter.endElement();
892 break;
894 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D:
896 const TextSimplePortionPrimitive2D& rTextSimplePortionPrimitive2D
897 = dynamic_cast<const TextSimplePortionPrimitive2D&>(*pBasePrimitive);
898 rWriter.startElement("textsimpleportion");
900 basegfx::B2DVector aScale, aTranslate;
901 double fRotate, fShearX;
902 if (rTextSimplePortionPrimitive2D.getTextTransform().decompose(aScale, aTranslate,
903 fRotate, fShearX))
905 rWriter.attribute("width", aScale.getX());
906 rWriter.attribute("height", aScale.getY());
908 rWriter.attribute("x", aTranslate.getX());
909 rWriter.attribute("y", aTranslate.getY());
910 OUString aText = rTextSimplePortionPrimitive2D.getText();
911 // TODO share code with sax_fastparser::FastSaxSerializer::write().
912 rWriter.attribute("text", aText.replaceAll("\x01", "&#9;"));
913 rWriter.attribute("fontcolor", convertColorToString(
914 rTextSimplePortionPrimitive2D.getFontColor()));
916 const drawinglayer::attribute::FontAttribute& aFontAttribute
917 = rTextSimplePortionPrimitive2D.getFontAttribute();
918 rWriter.attribute("familyname", aFontAttribute.getFamilyName());
919 rWriter.endElement();
921 break;
923 case PRIMITIVE2D_ID_GROUPPRIMITIVE2D:
925 const GroupPrimitive2D& rGroupPrimitive2D
926 = dynamic_cast<const GroupPrimitive2D&>(*pBasePrimitive);
927 rWriter.startElement("group");
928 decomposeAndWrite(rGroupPrimitive2D.getChildren(), rWriter);
929 rWriter.endElement();
931 break;
933 case PRIMITIVE2D_ID_MASKPRIMITIVE2D:
935 const MaskPrimitive2D& rMaskPrimitive2D
936 = dynamic_cast<const MaskPrimitive2D&>(*pBasePrimitive);
937 rWriter.startElement("mask");
938 writePolyPolygon(rWriter, rMaskPrimitive2D.getMask());
939 decomposeAndWrite(rMaskPrimitive2D.getChildren(), rWriter);
940 rWriter.endElement();
942 break;
944 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D:
946 const UnifiedTransparencePrimitive2D& rUnifiedTransparencePrimitive2D
947 = dynamic_cast<const UnifiedTransparencePrimitive2D&>(*pBasePrimitive);
948 rWriter.startElement("unifiedtransparence");
949 rWriter.attribute(
950 "transparence",
951 std::lround(100 * rUnifiedTransparencePrimitive2D.getTransparence()));
952 decomposeAndWrite(rUnifiedTransparencePrimitive2D.getChildren(), rWriter);
953 rWriter.endElement();
955 break;
957 case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D:
959 const ObjectInfoPrimitive2D& rObjectInfoPrimitive2D
960 = dynamic_cast<const ObjectInfoPrimitive2D&>(*pBasePrimitive);
961 rWriter.startElement("objectinfo");
963 decomposeAndWrite(rObjectInfoPrimitive2D.getChildren(), rWriter);
964 rWriter.endElement();
966 break;
968 case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D:
970 const StructureTagPrimitive2D& rStructureTagPrimitive2D
971 = dynamic_cast<const StructureTagPrimitive2D&>(*pBasePrimitive);
972 rWriter.startElement("structuretag");
973 rWriter.attribute("structureelement",
974 rStructureTagPrimitive2D.getStructureElement());
976 decomposeAndWrite(rStructureTagPrimitive2D.getChildren(), rWriter);
977 rWriter.endElement();
979 break;
981 case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D:
983 const SvgRadialGradientPrimitive2D& rSvgRadialGradientPrimitive2D
984 = dynamic_cast<const SvgRadialGradientPrimitive2D&>(*pBasePrimitive);
985 rWriter.startElement("svgradialgradient");
986 if (rSvgRadialGradientPrimitive2D.isFocalSet())
988 basegfx::B2DPoint aFocalAttribute = rSvgRadialGradientPrimitive2D.getFocal();
989 rWriter.attribute("focalx", aFocalAttribute.getX());
990 rWriter.attribute("focaly", aFocalAttribute.getY());
993 basegfx::B2DPoint aStartPoint = rSvgRadialGradientPrimitive2D.getStart();
994 rWriter.attribute("startx", aStartPoint.getX());
995 rWriter.attribute("starty", aStartPoint.getY());
996 rWriter.attribute("radius",
997 OString::number(rSvgRadialGradientPrimitive2D.getRadius()));
998 writeSpreadMethod(rWriter, rSvgRadialGradientPrimitive2D.getSpreadMethod());
999 rWriter.attributeDouble(
1000 "opacity",
1001 rSvgRadialGradientPrimitive2D.getGradientEntries().front().getOpacity());
1003 rWriter.startElement("transform");
1004 writeMatrix(rWriter, rSvgRadialGradientPrimitive2D.getGradientTransform());
1005 rWriter.endElement();
1007 writePolyPolygon(rWriter, rSvgRadialGradientPrimitive2D.getPolyPolygon());
1008 rWriter.endElement();
1010 break;
1012 case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D:
1014 const SvgLinearGradientPrimitive2D& rSvgLinearGradientPrimitive2D
1015 = dynamic_cast<const SvgLinearGradientPrimitive2D&>(*pBasePrimitive);
1016 rWriter.startElement("svglineargradient");
1017 basegfx::B2DPoint aStartAttribute = rSvgLinearGradientPrimitive2D.getStart();
1018 basegfx::B2DPoint aEndAttribute = rSvgLinearGradientPrimitive2D.getEnd();
1020 rWriter.attribute("startx", aStartAttribute.getX());
1021 rWriter.attribute("starty", aStartAttribute.getY());
1022 rWriter.attribute("endx", aEndAttribute.getX());
1023 rWriter.attribute("endy", aEndAttribute.getY());
1024 writeSpreadMethod(rWriter, rSvgLinearGradientPrimitive2D.getSpreadMethod());
1025 rWriter.attributeDouble(
1026 "opacity",
1027 rSvgLinearGradientPrimitive2D.getGradientEntries().front().getOpacity());
1029 rWriter.startElement("transform");
1030 writeMatrix(rWriter, rSvgLinearGradientPrimitive2D.getGradientTransform());
1031 rWriter.endElement();
1033 writePolyPolygon(rWriter, rSvgLinearGradientPrimitive2D.getPolyPolygon());
1035 rWriter.endElement();
1037 break;
1039 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D:
1041 const MetafilePrimitive2D& rMetafilePrimitive2D
1042 = dynamic_cast<const MetafilePrimitive2D&>(*pBasePrimitive);
1043 rWriter.startElement("metafile");
1044 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1045 // since the graphic is not rendered in a document, we do not need a concrete view information
1046 rMetafilePrimitive2D.get2DDecomposition(
1047 aPrimitiveContainer, drawinglayer::geometry::ViewInformation2D());
1048 decomposeAndWrite(aPrimitiveContainer, rWriter);
1049 rWriter.endElement();
1052 break;
1054 case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D:
1056 // SdrRectanglePrimitive2D is private to us.
1057 rWriter.startElement("sdrrectangle");
1058 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1059 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1060 drawinglayer::geometry::ViewInformation2D());
1061 decomposeAndWrite(aPrimitiveContainer, rWriter);
1062 rWriter.endElement();
1063 break;
1066 case PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D:
1068 // SdrBlockTextPrimitive2D is private to us.
1069 rWriter.startElement("sdrblocktext");
1070 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1071 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1072 drawinglayer::geometry::ViewInformation2D());
1073 decomposeAndWrite(aPrimitiveContainer, rWriter);
1074 rWriter.endElement();
1075 break;
1078 case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D:
1080 // TextHierarchyBlockPrimitive2D.
1081 rWriter.startElement("texthierarchyblock");
1082 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1083 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1084 drawinglayer::geometry::ViewInformation2D());
1085 decomposeAndWrite(aPrimitiveContainer, rWriter);
1086 rWriter.endElement();
1087 break;
1090 case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D:
1092 // TextHierarchyParagraphPrimitive2D.
1093 rWriter.startElement("texthierarchyparagraph");
1094 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1095 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1096 drawinglayer::geometry::ViewInformation2D());
1097 decomposeAndWrite(aPrimitiveContainer, rWriter);
1098 rWriter.endElement();
1099 break;
1102 case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D:
1104 // TextHierarchyLinePrimitive2D.
1105 rWriter.startElement("texthierarchyline");
1106 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1107 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1108 drawinglayer::geometry::ViewInformation2D());
1109 decomposeAndWrite(aPrimitiveContainer, rWriter);
1110 rWriter.endElement();
1111 break;
1114 case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D:
1116 // ShadowPrimitive2D.
1117 rWriter.startElement("shadow");
1118 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1119 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1120 drawinglayer::geometry::ViewInformation2D());
1121 decomposeAndWrite(aPrimitiveContainer, rWriter);
1122 rWriter.endElement();
1123 break;
1126 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D:
1128 // ModifiedColorPrimitive2D.
1129 rWriter.startElement("modifiedColor");
1130 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1131 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1132 drawinglayer::geometry::ViewInformation2D());
1133 decomposeAndWrite(aPrimitiveContainer, rWriter);
1134 rWriter.endElement();
1135 break;
1138 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D:
1140 const auto& rScenePrimitive2D
1141 = dynamic_cast<const drawinglayer::primitive2d::ScenePrimitive2D&>(
1142 *pBasePrimitive);
1143 rWriter.startElement("scene");
1145 auto const& rSceneAttribute = rScenePrimitive2D.getSdrSceneAttribute();
1147 rWriter.attribute("shadowSlant", rSceneAttribute.getShadowSlant());
1148 rWriter.attribute("isTwoSidedLighting",
1149 sal_Int32(rSceneAttribute.getTwoSidedLighting()));
1150 writeShadeMode(rWriter, rSceneAttribute.getShadeMode());
1151 writeProjectionMode(rWriter, rSceneAttribute.getProjectionMode());
1153 auto const& rLightingAttribute = rScenePrimitive2D.getSdrLightingAttribute();
1154 rWriter.attribute("ambientLightColor",
1155 convertColorToString(rLightingAttribute.getAmbientLightColor()));
1156 rWriter.startElement("lights");
1157 for (auto const& rLight : rLightingAttribute.getLightVector())
1159 rWriter.startElement("light");
1160 rWriter.attribute("color", convertColorToString(rLight.getColor()));
1161 rWriter.attribute("directionVectorX", rLight.getDirection().getX());
1162 rWriter.attribute("directionVectorY", rLight.getDirection().getY());
1163 rWriter.attribute("specular", sal_Int32(rLight.getSpecular()));
1164 rWriter.endElement();
1166 rWriter.endElement();
1168 Primitive3DXmlDump aPrimitive3DXmlDump;
1169 aPrimitive3DXmlDump.decomposeAndWrite(rScenePrimitive2D.getChildren3D(), rWriter);
1171 rWriter.endElement();
1172 break;
1175 default:
1177 OString aName("unhandled");
1178 switch (nId)
1180 case PRIMITIVE2D_ID_RANGE_SVX | 14: // PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D
1182 aName = "sdrCell";
1183 break;
1186 rWriter.startElement(aName);
1187 rWriter.attribute("id",
1188 OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8));
1189 rWriter.attribute("idNumber", nId);
1191 auto pBufferedDecomposition
1192 = dynamic_cast<const BufferedDecompositionPrimitive2D*>(pBasePrimitive);
1193 if (pBufferedDecomposition)
1195 rWriter.attribute(
1196 "transparenceForShadow",
1197 OString::number(pBufferedDecomposition->getTransparenceForShadow()));
1200 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
1201 pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
1202 drawinglayer::geometry::ViewInformation2D());
1203 decomposeAndWrite(aPrimitiveContainer, rWriter);
1204 rWriter.endElement();
1206 break;
1211 } // end namespace drawinglayer
1213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */