1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <drawinglayer/tools/primitive2dxmldump.hxx>
12 #include <rtl/string.hxx>
13 #include <tools/stream.hxx>
14 #include <tools/XmlWriter.hxx>
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/softedgeprimitive2d.hxx>
32 #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
33 #include <primitive2d/textlineprimitive2d.hxx>
34 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
35 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
36 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
37 #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
38 #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
40 #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
41 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/sceneprimitive2d.hxx>
43 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
44 #include <drawinglayer/geometry/viewinformation2d.hxx>
45 #include <drawinglayer/attribute/lineattribute.hxx>
46 #include <drawinglayer/attribute/fontattribute.hxx>
48 #include <basegfx/polygon/b2dpolypolygontools.hxx>
49 #include <basegfx/polygon/b2dpolygontools.hxx>
50 #include <basegfx/utils/gradienttools.hxx>
51 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
52 #include <toolkit/helper/vclunohelper.hxx>
54 #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
55 #include <drawinglayer/primitive3d/Tools.hxx>
56 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
57 #include <drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx>
58 #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
59 #include <drawinglayer/attribute/sdrfillattribute.hxx>
60 #include <drawinglayer/attribute/fillhatchattribute.hxx>
61 #include <drawinglayer/attribute/fillgradientattribute.hxx>
62 #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
63 #include <drawinglayer/attribute/materialattribute3d.hxx>
65 using namespace drawinglayer::primitive2d
;
67 namespace drawinglayer
71 const size_t constMaxActionType
= 513;
73 OUString
convertColorToString(const basegfx::BColor
& rColor
)
75 OUString aRGBString
= Color(rColor
).AsRGBHexString();
76 return "#" + aRGBString
;
79 void writeMatrix(::tools::XmlWriter
& rWriter
, const basegfx::B2DHomMatrix
& rMatrix
)
81 rWriter
.attribute("xy11", rMatrix
.get(0, 0));
82 rWriter
.attribute("xy12", rMatrix
.get(0, 1));
83 rWriter
.attribute("xy13", rMatrix
.get(0, 2));
84 rWriter
.attribute("xy21", rMatrix
.get(1, 0));
85 rWriter
.attribute("xy22", rMatrix
.get(1, 1));
86 rWriter
.attribute("xy23", rMatrix
.get(1, 2));
87 rWriter
.attribute("xy31", 0);
88 rWriter
.attribute("xy32", 0);
89 rWriter
.attribute("xy33", 1);
92 void writeMatrix3D(::tools::XmlWriter
& rWriter
, const basegfx::B3DHomMatrix
& rMatrix
)
94 rWriter
.attribute("xy11", rMatrix
.get(0, 0));
95 rWriter
.attribute("xy12", rMatrix
.get(0, 1));
96 rWriter
.attribute("xy13", rMatrix
.get(0, 2));
97 rWriter
.attribute("xy14", rMatrix
.get(0, 3));
98 rWriter
.attribute("xy21", rMatrix
.get(1, 0));
99 rWriter
.attribute("xy22", rMatrix
.get(1, 1));
100 rWriter
.attribute("xy23", rMatrix
.get(1, 2));
101 rWriter
.attribute("xy24", rMatrix
.get(1, 3));
102 rWriter
.attribute("xy31", rMatrix
.get(2, 0));
103 rWriter
.attribute("xy32", rMatrix
.get(2, 1));
104 rWriter
.attribute("xy33", rMatrix
.get(2, 2));
105 rWriter
.attribute("xy34", rMatrix
.get(2, 3));
106 rWriter
.attribute("xy41", rMatrix
.get(3, 0));
107 rWriter
.attribute("xy42", rMatrix
.get(3, 1));
108 rWriter
.attribute("xy43", rMatrix
.get(3, 2));
109 rWriter
.attribute("xy44", rMatrix
.get(3, 3));
112 void writePolyPolygon(::tools::XmlWriter
& rWriter
, const basegfx::B2DPolyPolygon
& rB2DPolyPolygon
)
114 rWriter
.startElement("polypolygon");
115 const basegfx::B2DRange
aB2DRange(rB2DPolyPolygon
.getB2DRange());
116 rWriter
.attributeDouble("height", aB2DRange
.getHeight());
117 rWriter
.attributeDouble("width", aB2DRange
.getWidth());
118 rWriter
.attributeDouble("minx", aB2DRange
.getMinX());
119 rWriter
.attributeDouble("miny", aB2DRange
.getMinY());
120 rWriter
.attributeDouble("maxx", aB2DRange
.getMaxX());
121 rWriter
.attributeDouble("maxy", aB2DRange
.getMaxY());
122 rWriter
.attribute("path", basegfx::utils::exportToSvgD(rB2DPolyPolygon
, true, true, false));
124 for (basegfx::B2DPolygon
const& rPolygon
: rB2DPolyPolygon
)
126 rWriter
.startElement("polygon");
127 for (sal_uInt32 i
= 0; i
< rPolygon
.count(); ++i
)
129 basegfx::B2DPoint
const& rPoint
= rPolygon
.getB2DPoint(i
);
131 rWriter
.startElement("point");
132 rWriter
.attribute("x", OUString::number(rPoint
.getX()));
133 rWriter
.attribute("y", OUString::number(rPoint
.getY()));
134 rWriter
.endElement();
136 rWriter
.endElement();
139 rWriter
.endElement();
142 void writeStrokeAttribute(::tools::XmlWriter
& rWriter
,
143 const drawinglayer::attribute::StrokeAttribute
& rStrokeAttribute
)
145 if (!rStrokeAttribute
.getDotDashArray().empty())
147 rWriter
.startElement("stroke");
150 for (double fDotDash
: rStrokeAttribute
.getDotDashArray())
152 sDotDash
+= OUString::number(lround(fDotDash
)) + " ";
154 rWriter
.attribute("dotDashArray", sDotDash
);
155 rWriter
.attribute("fullDotDashLength", rStrokeAttribute
.getFullDotDashLen());
156 rWriter
.endElement();
160 void writeLineAttribute(::tools::XmlWriter
& rWriter
,
161 const drawinglayer::attribute::LineAttribute
& rLineAttribute
)
163 rWriter
.startElement("line");
164 rWriter
.attribute("color", convertColorToString(rLineAttribute
.getColor()));
165 rWriter
.attribute("width", rLineAttribute
.getWidth());
166 switch (rLineAttribute
.getLineJoin())
168 case basegfx::B2DLineJoin::NONE
:
169 rWriter
.attribute("linejoin", "NONE");
171 case basegfx::B2DLineJoin::Bevel
:
172 rWriter
.attribute("linejoin", "Bevel");
174 case basegfx::B2DLineJoin::Miter
:
176 rWriter
.attribute("linejoin", "Miter");
177 rWriter
.attribute("miterangle",
178 basegfx::rad2deg(rLineAttribute
.getMiterMinimumAngle()));
181 case basegfx::B2DLineJoin::Round
:
182 rWriter
.attribute("linejoin", "Round");
185 rWriter
.attribute("linejoin", "Unknown");
188 switch (rLineAttribute
.getLineCap())
190 case css::drawing::LineCap::LineCap_BUTT
:
191 rWriter
.attribute("linecap", "BUTT");
193 case css::drawing::LineCap::LineCap_ROUND
:
194 rWriter
.attribute("linecap", "ROUND");
196 case css::drawing::LineCap::LineCap_SQUARE
:
197 rWriter
.attribute("linecap", "SQUARE");
200 rWriter
.attribute("linecap", "Unknown");
204 rWriter
.endElement();
207 void writeSdrLineAttribute(::tools::XmlWriter
& rWriter
,
208 const drawinglayer::attribute::SdrLineAttribute
& rLineAttribute
)
210 if (rLineAttribute
.isDefault())
213 rWriter
.startElement("line");
214 rWriter
.attribute("color", convertColorToString(rLineAttribute
.getColor()));
215 rWriter
.attribute("width", rLineAttribute
.getWidth());
216 rWriter
.attribute("transparence", rLineAttribute
.getTransparence());
218 switch (rLineAttribute
.getJoin())
220 case basegfx::B2DLineJoin::NONE
:
221 rWriter
.attribute("linejoin", "NONE");
223 case basegfx::B2DLineJoin::Bevel
:
224 rWriter
.attribute("linejoin", "Bevel");
226 case basegfx::B2DLineJoin::Miter
:
227 rWriter
.attribute("linejoin", "Miter");
229 case basegfx::B2DLineJoin::Round
:
230 rWriter
.attribute("linejoin", "Round");
233 rWriter
.attribute("linejoin", "Unknown");
236 switch (rLineAttribute
.getCap())
238 case css::drawing::LineCap::LineCap_BUTT
:
239 rWriter
.attribute("linecap", "BUTT");
241 case css::drawing::LineCap::LineCap_ROUND
:
242 rWriter
.attribute("linecap", "ROUND");
244 case css::drawing::LineCap::LineCap_SQUARE
:
245 rWriter
.attribute("linecap", "SQUARE");
248 rWriter
.attribute("linecap", "Unknown");
252 if (!rLineAttribute
.getDotDashArray().empty())
255 for (double fDotDash
: rLineAttribute
.getDotDashArray())
257 sDotDash
+= OUString::number(fDotDash
) + " ";
259 rWriter
.attribute("dotDashArray", sDotDash
);
260 rWriter
.attribute("fullDotDashLength", rLineAttribute
.getFullDotDashLen());
263 rWriter
.endElement();
266 void writeSdrFillAttribute(::tools::XmlWriter
& rWriter
,
267 const drawinglayer::attribute::SdrFillAttribute
& rFillAttribute
)
269 if (rFillAttribute
.isDefault())
272 rWriter
.startElement("fill");
273 rWriter
.attribute("color", convertColorToString(rFillAttribute
.getColor()));
274 rWriter
.attribute("transparence", rFillAttribute
.getTransparence());
276 auto const& rGradient
= rFillAttribute
.getGradient();
277 if (!rGradient
.isDefault())
279 rWriter
.startElement("gradient");
280 switch (rGradient
.getStyle())
282 default: // GradientStyle_MAKE_FIXED_SIZE
283 case css::awt::GradientStyle_LINEAR
:
284 rWriter
.attribute("style", "Linear");
286 case css::awt::GradientStyle_AXIAL
:
287 rWriter
.attribute("style", "Axial");
289 case css::awt::GradientStyle_RADIAL
:
290 rWriter
.attribute("style", "Radial");
292 case css::awt::GradientStyle_ELLIPTICAL
:
293 rWriter
.attribute("style", "Elliptical");
295 case css::awt::GradientStyle_SQUARE
:
296 rWriter
.attribute("style", "Square");
298 case css::awt::GradientStyle_RECT
:
299 rWriter
.attribute("style", "Rect");
302 rWriter
.attribute("border", rGradient
.getBorder());
303 rWriter
.attribute("offsetX", rGradient
.getOffsetX());
304 rWriter
.attribute("offsetY", rGradient
.getOffsetY());
305 rWriter
.attribute("angle", rGradient
.getAngle());
306 rWriter
.attribute("steps", rGradient
.getSteps());
308 auto const& rColorStops(rGradient
.getColorStops());
309 for (size_t a(0); a
< rColorStops
.size(); a
++)
312 rWriter
.attribute("startColor",
313 convertColorToString(rColorStops
[a
].getStopColor()));
314 else if (rColorStops
.size() == a
+ 1)
315 rWriter
.attribute("endColor", convertColorToString(rColorStops
[a
].getStopColor()));
318 rWriter
.startElement("colorStop");
319 rWriter
.attribute("stopOffset", rColorStops
[a
].getStopOffset());
320 rWriter
.attribute("stopColor", convertColorToString(rColorStops
[a
].getStopColor()));
321 rWriter
.endElement();
324 rWriter
.endElement();
327 auto const& rHatch
= rFillAttribute
.getHatch();
328 if (!rHatch
.isDefault())
330 rWriter
.startElement("hatch");
331 switch (rHatch
.getStyle())
333 case drawinglayer::attribute::HatchStyle::Single
:
334 rWriter
.attribute("style", "Single");
336 case drawinglayer::attribute::HatchStyle::Double
:
337 rWriter
.attribute("style", "Double");
339 case drawinglayer::attribute::HatchStyle::Triple
:
340 rWriter
.attribute("style", "Triple");
343 rWriter
.attribute("distance", rHatch
.getDistance());
344 rWriter
.attribute("angle", rHatch
.getAngle());
345 rWriter
.attribute("color", convertColorToString(rHatch
.getColor()));
346 rWriter
.attribute("minimalDescreteDistance", rHatch
.getMinimalDiscreteDistance());
347 rWriter
.attribute("isFillBackground", sal_Int32(rHatch
.isFillBackground()));
348 rWriter
.endElement();
351 auto const& rGraphic
= rFillAttribute
.getFillGraphic();
352 if (!rGraphic
.isDefault())
354 rWriter
.startElement("graphic");
356 rWriter
.endElement();
359 rWriter
.endElement();
362 void writeShadeMode(::tools::XmlWriter
& rWriter
, const css::drawing::ShadeMode
& rMode
)
366 case css::drawing::ShadeMode_FLAT
:
367 rWriter
.attribute("shadeMode", "Flat");
369 case css::drawing::ShadeMode_SMOOTH
:
370 rWriter
.attribute("shadeMode", "Smooth");
372 case css::drawing::ShadeMode_PHONG
:
373 rWriter
.attribute("shadeMode", "Phong");
375 case css::drawing::ShadeMode_DRAFT
:
376 rWriter
.attribute("shadeMode", "Draft");
379 rWriter
.attribute("shadeMode", "Undefined");
384 void writeProjectionMode(::tools::XmlWriter
& rWriter
, const css::drawing::ProjectionMode
& rMode
)
388 case css::drawing::ProjectionMode_PARALLEL
:
389 rWriter
.attribute("projectionMode", "Parallel");
391 case css::drawing::ProjectionMode_PERSPECTIVE
:
392 rWriter
.attribute("projectionMode", "Perspective");
395 rWriter
.attribute("projectionMode", "Undefined");
400 void writeNormalsKind(::tools::XmlWriter
& rWriter
, const css::drawing::NormalsKind
& rKind
)
404 case css::drawing::NormalsKind_SPECIFIC
:
405 rWriter
.attribute("normalsKind", "Specific");
407 case css::drawing::NormalsKind_FLAT
:
408 rWriter
.attribute("normalsKind", "Flat");
410 case css::drawing::NormalsKind_SPHERE
:
411 rWriter
.attribute("normalsKind", "Sphere");
414 rWriter
.attribute("normalsKind", "Undefined");
419 void writeTextureProjectionMode(::tools::XmlWriter
& rWriter
, const char* pElement
,
420 const css::drawing::TextureProjectionMode
& rMode
)
424 case css::drawing::TextureProjectionMode_OBJECTSPECIFIC
:
425 rWriter
.attribute(pElement
, "Specific");
427 case css::drawing::TextureProjectionMode_PARALLEL
:
428 rWriter
.attribute(pElement
, "Parallel");
430 case css::drawing::TextureProjectionMode_SPHERE
:
431 rWriter
.attribute(pElement
, "Sphere");
434 rWriter
.attribute(pElement
, "Undefined");
439 void writeTextureKind(::tools::XmlWriter
& rWriter
, const css::drawing::TextureKind2
& rKind
)
443 case css::drawing::TextureKind2_LUMINANCE
:
444 rWriter
.attribute("textureKind", "Luminance");
446 case css::drawing::TextureKind2_INTENSITY
:
447 rWriter
.attribute("textureKind", "Intensity");
449 case css::drawing::TextureKind2_COLOR
:
450 rWriter
.attribute("textureKind", "Color");
453 rWriter
.attribute("textureKind", "Undefined");
458 void writeTextureMode(::tools::XmlWriter
& rWriter
, const css::drawing::TextureMode
& rMode
)
462 case css::drawing::TextureMode_REPLACE
:
463 rWriter
.attribute("textureMode", "Replace");
465 case css::drawing::TextureMode_MODULATE
:
466 rWriter
.attribute("textureMode", "Modulate");
468 case css::drawing::TextureMode_BLEND
:
469 rWriter
.attribute("textureMode", "Blend");
472 rWriter
.attribute("textureMode", "Undefined");
477 void writeMaterialAttribute(::tools::XmlWriter
& rWriter
,
478 const drawinglayer::attribute::MaterialAttribute3D
& rMaterial
)
480 rWriter
.startElement("material");
481 rWriter
.attribute("color", convertColorToString(rMaterial
.getColor()));
482 rWriter
.attribute("specular", convertColorToString(rMaterial
.getSpecular()));
483 rWriter
.attribute("emission", convertColorToString(rMaterial
.getEmission()));
484 rWriter
.attribute("specularIntensity", rMaterial
.getSpecularIntensity());
485 rWriter
.endElement();
488 void writeSpreadMethod(::tools::XmlWriter
& rWriter
,
489 const drawinglayer::primitive2d::SpreadMethod
& rSpreadMethod
)
491 switch (rSpreadMethod
)
493 case drawinglayer::primitive2d::SpreadMethod::Pad
:
494 rWriter
.attribute("spreadmethod", "pad");
496 case drawinglayer::primitive2d::SpreadMethod::Reflect
:
497 rWriter
.attribute("spreadmethod", "reflect");
499 case drawinglayer::primitive2d::SpreadMethod::Repeat
:
500 rWriter
.attribute("spreadmethod", "repeat");
503 rWriter
.attribute("spreadmethod", "unknown");
507 } // end anonymous namespace
509 Primitive2dXmlDump::Primitive2dXmlDump()
510 : maFilter(constMaxActionType
, false)
514 Primitive2dXmlDump::~Primitive2dXmlDump() = default;
516 void Primitive2dXmlDump::dump(
517 const drawinglayer::primitive2d::Primitive2DContainer
& rPrimitive2DSequence
,
518 const OUString
& rStreamName
)
520 std::unique_ptr
<SvStream
> pStream
;
522 if (rStreamName
.isEmpty())
523 pStream
.reset(new SvMemoryStream());
525 pStream
.reset(new SvFileStream(rStreamName
, StreamMode::STD_READWRITE
| StreamMode::TRUNC
));
527 ::tools::XmlWriter
aWriter(pStream
.get());
528 aWriter
.startDocument();
529 aWriter
.startElement("primitive2D");
531 decomposeAndWrite(rPrimitive2DSequence
, aWriter
);
533 aWriter
.endElement();
534 aWriter
.endDocument();
536 pStream
->Seek(STREAM_SEEK_TO_BEGIN
);
541 class Primitive3DXmlDump
544 void decomposeAndWrite(const drawinglayer::primitive3d::Primitive3DContainer
& rSequence
,
545 ::tools::XmlWriter
& rWriter
)
547 for (size_t i
= 0; i
< rSequence
.size(); i
++)
549 drawinglayer::primitive3d::Primitive3DReference xReference
= rSequence
[i
];
550 const auto* pBasePrimitive
551 = static_cast<const drawinglayer::primitive3d::BasePrimitive3D
*>(xReference
.get());
552 sal_uInt32 nId
= pBasePrimitive
->getPrimitive3DID();
553 OUString sCurrentElementTag
= drawinglayer::primitive3d::idToString(nId
);
556 case PRIMITIVE3D_ID_SDREXTRUDEPRIMITIVE3D
:
558 const auto* pExtrudePrimitive3D
559 = static_cast<const drawinglayer::primitive3d::SdrExtrudePrimitive3D
*>(
561 rWriter
.startElement("extrude3D");
563 rWriter
.startElement("matrix3D");
564 writeMatrix3D(rWriter
, pExtrudePrimitive3D
->getTransform());
565 rWriter
.endElement();
567 rWriter
.attribute("textureSizeX", pExtrudePrimitive3D
->getTextureSize().getX());
568 rWriter
.attribute("textureSizeY", pExtrudePrimitive3D
->getTextureSize().getY());
569 auto const& rLFSAttribute
= pExtrudePrimitive3D
->getSdrLFSAttribute();
570 writeSdrLineAttribute(rWriter
, rLFSAttribute
.getLine());
571 writeSdrFillAttribute(rWriter
, rLFSAttribute
.getFill());
573 rWriter
.startElement("object3Dattributes");
575 auto const& r3DObjectAttributes
576 = pExtrudePrimitive3D
->getSdr3DObjectAttribute();
578 writeNormalsKind(rWriter
, r3DObjectAttributes
.getNormalsKind());
579 writeTextureProjectionMode(rWriter
, "textureProjectionX",
580 r3DObjectAttributes
.getTextureProjectionX());
581 writeTextureProjectionMode(rWriter
, "textureProjectionY",
582 r3DObjectAttributes
.getTextureProjectionY());
583 writeTextureKind(rWriter
, r3DObjectAttributes
.getTextureKind());
584 writeTextureMode(rWriter
, r3DObjectAttributes
.getTextureMode());
585 writeMaterialAttribute(rWriter
, r3DObjectAttributes
.getMaterial());
587 rWriter
.attribute("normalsInvert",
588 sal_Int32(r3DObjectAttributes
.getNormalsInvert()));
589 rWriter
.attribute("doubleSided",
590 sal_Int32(r3DObjectAttributes
.getDoubleSided()));
591 rWriter
.attribute("shadow3D", sal_Int32(r3DObjectAttributes
.getShadow3D()));
592 rWriter
.attribute("textureFilter",
593 sal_Int32(r3DObjectAttributes
.getTextureFilter()));
594 rWriter
.attribute("reducedGeometry",
595 sal_Int32(r3DObjectAttributes
.getReducedLineGeometry()));
597 rWriter
.endElement();
599 rWriter
.attribute("depth", pExtrudePrimitive3D
->getDepth());
600 rWriter
.attribute("diagonal", pExtrudePrimitive3D
->getDiagonal());
601 rWriter
.attribute("backScale", pExtrudePrimitive3D
->getBackScale());
602 rWriter
.attribute("smoothNormals",
603 sal_Int32(pExtrudePrimitive3D
->getSmoothNormals()));
604 rWriter
.attribute("smoothLids",
605 sal_Int32(pExtrudePrimitive3D
->getSmoothLids()));
606 rWriter
.attribute("characterMode",
607 sal_Int32(pExtrudePrimitive3D
->getCharacterMode()));
608 rWriter
.attribute("closeFront",
609 sal_Int32(pExtrudePrimitive3D
->getCloseFront()));
610 rWriter
.attribute("closeBack", sal_Int32(pExtrudePrimitive3D
->getCloseBack()));
611 writePolyPolygon(rWriter
, pExtrudePrimitive3D
->getPolyPolygon());
612 rWriter
.endElement();
618 rWriter
.startElement("unhandled");
619 rWriter
.attribute("id",
620 OUStringToOString(sCurrentElementTag
, RTL_TEXTENCODING_UTF8
));
621 rWriter
.attribute("idNumber", nId
);
623 drawinglayer::geometry::ViewInformation3D aViewInformation3D
;
624 drawinglayer::primitive3d::Primitive3DContainer aContainer
;
625 aContainer
= pBasePrimitive
->get3DDecomposition(aViewInformation3D
);
626 decomposeAndWrite(aContainer
, rWriter
);
627 rWriter
.endElement();
635 xmlDocUniquePtr
Primitive2dXmlDump::dumpAndParse(
636 const drawinglayer::primitive2d::Primitive2DContainer
& rPrimitive2DSequence
,
637 const OUString
& rStreamName
)
639 std::unique_ptr
<SvStream
> pStream
;
641 if (rStreamName
.isEmpty())
642 pStream
.reset(new SvMemoryStream());
644 pStream
.reset(new SvFileStream(rStreamName
, StreamMode::STD_READWRITE
| StreamMode::TRUNC
));
646 ::tools::XmlWriter
aWriter(pStream
.get());
647 aWriter
.startDocument();
648 aWriter
.startElement("primitive2D");
650 decomposeAndWrite(rPrimitive2DSequence
, aWriter
);
652 aWriter
.endElement();
653 aWriter
.endDocument();
655 pStream
->Seek(STREAM_SEEK_TO_BEGIN
);
657 std::size_t nSize
= pStream
->remainingSize();
658 std::unique_ptr
<sal_uInt8
[]> pBuffer(new sal_uInt8
[nSize
+ 1]);
659 pStream
->ReadBytes(pBuffer
.get(), nSize
);
661 SAL_INFO("drawinglayer", "Parsed XML: " << pBuffer
.get());
663 return xmlDocUniquePtr(xmlParseDoc(reinterpret_cast<xmlChar
*>(pBuffer
.get())));
666 void Primitive2dXmlDump::decomposeAndWrite(
667 const drawinglayer::primitive2d::Primitive2DContainer
& rPrimitive2DSequence
,
668 ::tools::XmlWriter
& rWriter
)
670 for (size_t i
= 0; i
< rPrimitive2DSequence
.size(); i
++)
672 const BasePrimitive2D
* pBasePrimitive
= rPrimitive2DSequence
[i
].get();
673 sal_uInt32 nId
= pBasePrimitive
->getPrimitive2DID();
674 if (nId
< maFilter
.size() && maFilter
[nId
])
677 OUString sCurrentElementTag
= drawinglayer::primitive2d::idToString(nId
);
681 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
:
683 const BitmapPrimitive2D
& rBitmapPrimitive2D
684 = dynamic_cast<const BitmapPrimitive2D
&>(*pBasePrimitive
);
685 rWriter
.startElement("bitmap");
686 writeMatrix(rWriter
, rBitmapPrimitive2D
.getTransform());
688 const BitmapEx
aBitmapEx(rBitmapPrimitive2D
.getBitmap());
689 const Size
& rSizePixel(aBitmapEx
.GetSizePixel());
691 rWriter
.attribute("height", rSizePixel
.getHeight());
692 rWriter
.attribute("width", rSizePixel
.getWidth());
693 rWriter
.attribute("checksum", OString(std::to_string(aBitmapEx
.GetChecksum())));
695 for (tools::Long y
= 0; y
< rSizePixel
.getHeight(); y
++)
697 rWriter
.startElement("data");
698 OUString aBitmapData
= "";
699 for (tools::Long x
= 0; x
< rSizePixel
.getHeight(); x
++)
702 aBitmapData
= aBitmapData
+ ",";
703 aBitmapData
= aBitmapData
+ aBitmapEx
.GetPixelColor(x
, y
).AsRGBHexString();
705 rWriter
.attribute("row", aBitmapData
);
706 rWriter
.endElement();
708 rWriter
.endElement();
711 case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D
:
713 const HiddenGeometryPrimitive2D
& rHiddenGeometryPrimitive2D
714 = dynamic_cast<const HiddenGeometryPrimitive2D
&>(*pBasePrimitive
);
715 rWriter
.startElement("hiddengeometry");
716 decomposeAndWrite(rHiddenGeometryPrimitive2D
.getChildren(), rWriter
);
717 rWriter
.endElement();
721 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
:
723 const TransformPrimitive2D
& rTransformPrimitive2D
724 = dynamic_cast<const TransformPrimitive2D
&>(*pBasePrimitive
);
725 rWriter
.startElement("transform");
726 writeMatrix(rWriter
, rTransformPrimitive2D
.getTransformation());
727 decomposeAndWrite(rTransformPrimitive2D
.getChildren(), rWriter
);
728 rWriter
.endElement();
732 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
:
734 const PolyPolygonColorPrimitive2D
& rPolyPolygonColorPrimitive2D
735 = dynamic_cast<const PolyPolygonColorPrimitive2D
&>(*pBasePrimitive
);
737 rWriter
.startElement("polypolygoncolor");
738 rWriter
.attribute("color",
739 convertColorToString(rPolyPolygonColorPrimitive2D
.getBColor()));
741 const basegfx::B2DPolyPolygon
& aB2DPolyPolygon(
742 rPolyPolygonColorPrimitive2D
.getB2DPolyPolygon());
743 writePolyPolygon(rWriter
, aB2DPolyPolygon
);
745 rWriter
.endElement();
748 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
:
750 const PointArrayPrimitive2D
& rPointArrayPrimitive2D
751 = dynamic_cast<const PointArrayPrimitive2D
&>(*pBasePrimitive
);
752 rWriter
.startElement("pointarray");
754 rWriter
.attribute("color",
755 convertColorToString(rPointArrayPrimitive2D
.getRGBColor()));
757 const std::vector
<basegfx::B2DPoint
> aPositions
758 = rPointArrayPrimitive2D
.getPositions();
759 for (std::vector
<basegfx::B2DPoint
>::const_iterator iter
= aPositions
.begin();
760 iter
!= aPositions
.end(); ++iter
)
762 rWriter
.startElement("point");
763 rWriter
.attribute("x", OUString::number(iter
->getX()));
764 rWriter
.attribute("y", OUString::number(iter
->getY()));
765 rWriter
.endElement();
768 rWriter
.endElement();
772 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D
:
774 const PolygonStrokeArrowPrimitive2D
& rPolygonStrokeArrowPrimitive2D
775 = dynamic_cast<const PolygonStrokeArrowPrimitive2D
&>(*pBasePrimitive
);
776 rWriter
.startElement("polygonstrokearrow");
778 rWriter
.startElement("polygon");
779 rWriter
.content(basegfx::utils::exportToSvgPoints(
780 rPolygonStrokeArrowPrimitive2D
.getB2DPolygon()));
781 rWriter
.endElement();
783 if (rPolygonStrokeArrowPrimitive2D
.getStart().getB2DPolyPolygon().count())
785 rWriter
.startElement("linestartattribute");
786 rWriter
.attribute("width",
787 rPolygonStrokeArrowPrimitive2D
.getStart().getWidth());
788 rWriter
.attribute("centered",
789 static_cast<sal_Int32
>(
790 rPolygonStrokeArrowPrimitive2D
.getStart().isCentered()));
791 writePolyPolygon(rWriter
,
792 rPolygonStrokeArrowPrimitive2D
.getStart().getB2DPolyPolygon());
793 rWriter
.endElement();
796 if (rPolygonStrokeArrowPrimitive2D
.getEnd().getB2DPolyPolygon().count())
798 rWriter
.startElement("lineendattribute");
799 rWriter
.attribute("width", rPolygonStrokeArrowPrimitive2D
.getEnd().getWidth());
800 rWriter
.attribute("centered",
801 static_cast<sal_Int32
>(
802 rPolygonStrokeArrowPrimitive2D
.getEnd().isCentered()));
803 writePolyPolygon(rWriter
,
804 rPolygonStrokeArrowPrimitive2D
.getEnd().getB2DPolyPolygon());
805 rWriter
.endElement();
808 writeLineAttribute(rWriter
, rPolygonStrokeArrowPrimitive2D
.getLineAttribute());
809 writeStrokeAttribute(rWriter
, rPolygonStrokeArrowPrimitive2D
.getStrokeAttribute());
810 rWriter
.endElement();
814 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
:
816 const PolygonStrokePrimitive2D
& rPolygonStrokePrimitive2D
817 = dynamic_cast<const PolygonStrokePrimitive2D
&>(*pBasePrimitive
);
818 rWriter
.startElement("polygonstroke");
820 rWriter
.startElement("polygon");
822 basegfx::utils::exportToSvgPoints(rPolygonStrokePrimitive2D
.getB2DPolygon()));
823 rWriter
.endElement();
825 writeLineAttribute(rWriter
, rPolygonStrokePrimitive2D
.getLineAttribute());
826 writeStrokeAttribute(rWriter
, rPolygonStrokePrimitive2D
.getStrokeAttribute());
827 rWriter
.endElement();
830 case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D
:
832 const PolyPolygonStrokePrimitive2D
& rPolyPolygonStrokePrimitive2D
833 = dynamic_cast<const PolyPolygonStrokePrimitive2D
&>(*pBasePrimitive
);
834 rWriter
.startElement("polypolygonstroke");
836 writeLineAttribute(rWriter
, rPolyPolygonStrokePrimitive2D
.getLineAttribute());
837 writeStrokeAttribute(rWriter
, rPolyPolygonStrokePrimitive2D
.getStrokeAttribute());
838 writePolyPolygon(rWriter
, rPolyPolygonStrokePrimitive2D
.getB2DPolyPolygon());
840 rWriter
.endElement();
844 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
:
846 const PolygonHairlinePrimitive2D
& rPolygonHairlinePrimitive2D
847 = dynamic_cast<const PolygonHairlinePrimitive2D
&>(*pBasePrimitive
);
848 rWriter
.startElement("polygonhairline");
850 rWriter
.attribute("color",
851 convertColorToString(rPolygonHairlinePrimitive2D
.getBColor()));
853 rWriter
.startElement("polygon");
855 basegfx::utils::exportToSvgPoints(rPolygonHairlinePrimitive2D
.getB2DPolygon()));
856 rWriter
.endElement();
858 rWriter
.endElement();
862 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D
:
864 const TextDecoratedPortionPrimitive2D
& rTextDecoratedPortionPrimitive2D
865 = dynamic_cast<const TextDecoratedPortionPrimitive2D
&>(*pBasePrimitive
);
866 rWriter
.startElement("textdecoratedportion");
867 writeMatrix(rWriter
, rTextDecoratedPortionPrimitive2D
.getTextTransform());
869 rWriter
.attribute("text", rTextDecoratedPortionPrimitive2D
.getText());
872 convertColorToString(rTextDecoratedPortionPrimitive2D
.getFontColor()));
874 const drawinglayer::attribute::FontAttribute
& aFontAttribute
875 = rTextDecoratedPortionPrimitive2D
.getFontAttribute();
876 rWriter
.attribute("familyname", aFontAttribute
.getFamilyName());
877 rWriter
.endElement();
881 case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D
:
883 const TextLinePrimitive2D
& rTextLinePrimitive2D
884 = dynamic_cast<const TextLinePrimitive2D
&>(*pBasePrimitive
);
885 rWriter
.startElement("textline");
886 writeMatrix(rWriter
, rTextLinePrimitive2D
.getObjectTransformation());
888 rWriter
.attribute("width", rTextLinePrimitive2D
.getWidth());
889 rWriter
.attribute("offset", rTextLinePrimitive2D
.getOffset());
890 rWriter
.attribute("height", rTextLinePrimitive2D
.getHeight());
891 rWriter
.attribute("color",
892 convertColorToString(rTextLinePrimitive2D
.getLineColor()));
893 rWriter
.endElement();
897 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D
:
899 const TextSimplePortionPrimitive2D
& rTextSimplePortionPrimitive2D
900 = dynamic_cast<const TextSimplePortionPrimitive2D
&>(*pBasePrimitive
);
901 rWriter
.startElement("textsimpleportion");
903 basegfx::B2DVector aScale
, aTranslate
;
904 double fRotate
, fShearX
;
905 if (rTextSimplePortionPrimitive2D
.getTextTransform().decompose(aScale
, aTranslate
,
908 rWriter
.attribute("width", aScale
.getX());
909 rWriter
.attribute("height", aScale
.getY());
911 rWriter
.attribute("x", aTranslate
.getX());
912 rWriter
.attribute("y", aTranslate
.getY());
913 OUString aText
= rTextSimplePortionPrimitive2D
.getText();
914 // TODO share code with sax_fastparser::FastSaxSerializer::write().
915 rWriter
.attribute("text", aText
.replaceAll("\x01", "	"));
916 rWriter
.attribute("fontcolor", convertColorToString(
917 rTextSimplePortionPrimitive2D
.getFontColor()));
919 const drawinglayer::attribute::FontAttribute
& aFontAttribute
920 = rTextSimplePortionPrimitive2D
.getFontAttribute();
921 rWriter
.attribute("familyname", aFontAttribute
.getFamilyName());
922 const std::vector
<double> aDx
= rTextSimplePortionPrimitive2D
.getDXArray();
925 for (size_t iDx
= 0; iDx
< aDx
.size(); ++iDx
)
927 OString sName
= "dx" + OString::number(iDx
);
928 rWriter
.attribute(sName
, OUString::number(aDx
[iDx
]));
931 rWriter
.endElement();
935 case PRIMITIVE2D_ID_GROUPPRIMITIVE2D
:
937 const GroupPrimitive2D
& rGroupPrimitive2D
938 = dynamic_cast<const GroupPrimitive2D
&>(*pBasePrimitive
);
939 rWriter
.startElement("group");
940 decomposeAndWrite(rGroupPrimitive2D
.getChildren(), rWriter
);
941 rWriter
.endElement();
945 case PRIMITIVE2D_ID_MASKPRIMITIVE2D
:
947 const MaskPrimitive2D
& rMaskPrimitive2D
948 = dynamic_cast<const MaskPrimitive2D
&>(*pBasePrimitive
);
949 rWriter
.startElement("mask");
950 writePolyPolygon(rWriter
, rMaskPrimitive2D
.getMask());
951 decomposeAndWrite(rMaskPrimitive2D
.getChildren(), rWriter
);
952 rWriter
.endElement();
956 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D
:
958 const UnifiedTransparencePrimitive2D
& rUnifiedTransparencePrimitive2D
959 = dynamic_cast<const UnifiedTransparencePrimitive2D
&>(*pBasePrimitive
);
960 rWriter
.startElement("unifiedtransparence");
963 std::lround(100 * rUnifiedTransparencePrimitive2D
.getTransparence()));
964 decomposeAndWrite(rUnifiedTransparencePrimitive2D
.getChildren(), rWriter
);
965 rWriter
.endElement();
969 case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D
:
971 const ObjectInfoPrimitive2D
& rObjectInfoPrimitive2D
972 = dynamic_cast<const ObjectInfoPrimitive2D
&>(*pBasePrimitive
);
973 rWriter
.startElement("objectinfo");
975 decomposeAndWrite(rObjectInfoPrimitive2D
.getChildren(), rWriter
);
976 rWriter
.endElement();
980 case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D
:
982 const StructureTagPrimitive2D
& rStructureTagPrimitive2D
983 = dynamic_cast<const StructureTagPrimitive2D
&>(*pBasePrimitive
);
984 rWriter
.startElement("structuretag");
985 rWriter
.attribute("structureelement",
986 rStructureTagPrimitive2D
.getStructureElement());
988 decomposeAndWrite(rStructureTagPrimitive2D
.getChildren(), rWriter
);
989 rWriter
.endElement();
993 case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D
:
995 const SvgRadialGradientPrimitive2D
& rSvgRadialGradientPrimitive2D
996 = dynamic_cast<const SvgRadialGradientPrimitive2D
&>(*pBasePrimitive
);
997 rWriter
.startElement("svgradialgradient");
998 if (rSvgRadialGradientPrimitive2D
.isFocalSet())
1000 basegfx::B2DPoint aFocalAttribute
= rSvgRadialGradientPrimitive2D
.getFocal();
1001 rWriter
.attribute("focalx", aFocalAttribute
.getX());
1002 rWriter
.attribute("focaly", aFocalAttribute
.getY());
1005 basegfx::B2DPoint aStartPoint
= rSvgRadialGradientPrimitive2D
.getStart();
1006 rWriter
.attribute("startx", aStartPoint
.getX());
1007 rWriter
.attribute("starty", aStartPoint
.getY());
1008 rWriter
.attribute("radius",
1009 OString::number(rSvgRadialGradientPrimitive2D
.getRadius()));
1010 writeSpreadMethod(rWriter
, rSvgRadialGradientPrimitive2D
.getSpreadMethod());
1011 rWriter
.attributeDouble(
1013 rSvgRadialGradientPrimitive2D
.getGradientEntries().front().getOpacity());
1015 rWriter
.startElement("transform");
1016 writeMatrix(rWriter
, rSvgRadialGradientPrimitive2D
.getGradientTransform());
1017 rWriter
.endElement();
1019 writePolyPolygon(rWriter
, rSvgRadialGradientPrimitive2D
.getPolyPolygon());
1020 rWriter
.endElement();
1024 case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D
:
1026 const SvgLinearGradientPrimitive2D
& rSvgLinearGradientPrimitive2D
1027 = dynamic_cast<const SvgLinearGradientPrimitive2D
&>(*pBasePrimitive
);
1028 rWriter
.startElement("svglineargradient");
1029 basegfx::B2DPoint aStartAttribute
= rSvgLinearGradientPrimitive2D
.getStart();
1030 basegfx::B2DPoint aEndAttribute
= rSvgLinearGradientPrimitive2D
.getEnd();
1032 rWriter
.attribute("startx", aStartAttribute
.getX());
1033 rWriter
.attribute("starty", aStartAttribute
.getY());
1034 rWriter
.attribute("endx", aEndAttribute
.getX());
1035 rWriter
.attribute("endy", aEndAttribute
.getY());
1036 writeSpreadMethod(rWriter
, rSvgLinearGradientPrimitive2D
.getSpreadMethod());
1037 rWriter
.attributeDouble(
1039 rSvgLinearGradientPrimitive2D
.getGradientEntries().front().getOpacity());
1041 rWriter
.startElement("transform");
1042 writeMatrix(rWriter
, rSvgLinearGradientPrimitive2D
.getGradientTransform());
1043 rWriter
.endElement();
1045 writePolyPolygon(rWriter
, rSvgLinearGradientPrimitive2D
.getPolyPolygon());
1047 rWriter
.endElement();
1051 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D
:
1053 const MetafilePrimitive2D
& rMetafilePrimitive2D
1054 = dynamic_cast<const MetafilePrimitive2D
&>(*pBasePrimitive
);
1055 rWriter
.startElement("metafile");
1056 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1057 // since the graphic is not rendered in a document, we do not need a concrete view information
1058 rMetafilePrimitive2D
.get2DDecomposition(
1059 aPrimitiveContainer
, drawinglayer::geometry::ViewInformation2D());
1060 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1061 rWriter
.endElement();
1066 case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
:
1068 // SdrRectanglePrimitive2D is private to us.
1069 rWriter
.startElement("sdrrectangle");
1070 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1071 pBasePrimitive
->get2DDecomposition(aPrimitiveContainer
,
1072 drawinglayer::geometry::ViewInformation2D());
1073 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1074 rWriter
.endElement();
1078 case PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D
:
1080 // SdrBlockTextPrimitive2D is private to us.
1081 rWriter
.startElement("sdrblocktext");
1082 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1083 pBasePrimitive
->get2DDecomposition(aPrimitiveContainer
,
1084 drawinglayer::geometry::ViewInformation2D());
1085 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1086 rWriter
.endElement();
1090 case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D
:
1092 // TextHierarchyBlockPrimitive2D.
1093 rWriter
.startElement("texthierarchyblock");
1094 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1095 pBasePrimitive
->get2DDecomposition(aPrimitiveContainer
,
1096 drawinglayer::geometry::ViewInformation2D());
1097 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1098 rWriter
.endElement();
1102 case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D
:
1104 // TextHierarchyParagraphPrimitive2D.
1105 rWriter
.startElement("texthierarchyparagraph");
1106 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1107 pBasePrimitive
->get2DDecomposition(aPrimitiveContainer
,
1108 drawinglayer::geometry::ViewInformation2D());
1109 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1110 rWriter
.endElement();
1114 case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D
:
1116 // TextHierarchyLinePrimitive2D.
1117 rWriter
.startElement("texthierarchyline");
1118 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1119 pBasePrimitive
->get2DDecomposition(aPrimitiveContainer
,
1120 drawinglayer::geometry::ViewInformation2D());
1121 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1122 rWriter
.endElement();
1126 case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D
:
1128 // ShadowPrimitive2D.
1129 const ShadowPrimitive2D
& rShadowPrimitive2D
1130 = dynamic_cast<const ShadowPrimitive2D
&>(*pBasePrimitive
);
1131 rWriter
.startElement("shadow");
1132 rWriter
.attribute("color",
1133 convertColorToString(rShadowPrimitive2D
.getShadowColor()));
1134 rWriter
.attributeDouble("blur", rShadowPrimitive2D
.getShadowBlur());
1136 rWriter
.startElement("transform");
1137 writeMatrix(rWriter
, rShadowPrimitive2D
.getShadowTransform());
1138 rWriter
.endElement();
1140 rWriter
.endElement();
1144 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D
:
1146 // ModifiedColorPrimitive2D.
1147 const ModifiedColorPrimitive2D
& rModifiedColorPrimitive2D
1148 = dynamic_cast<const ModifiedColorPrimitive2D
&>(*pBasePrimitive
);
1149 rWriter
.startElement("modifiedColor");
1150 const basegfx::BColorModifierSharedPtr
& aColorModifier
1151 = rModifiedColorPrimitive2D
.getColorModifier();
1152 rWriter
.attribute("modifier", aColorModifier
->getModifierName());
1154 decomposeAndWrite(rModifiedColorPrimitive2D
.getChildren(), rWriter
);
1155 rWriter
.endElement();
1158 case PRIMITIVE2D_ID_SOFTEDGEPRIMITIVE2D
:
1160 // SoftEdgePrimitive2D.
1161 const SoftEdgePrimitive2D
& rSoftEdgePrimitive2D
1162 = dynamic_cast<const SoftEdgePrimitive2D
&>(*pBasePrimitive
);
1163 rWriter
.startElement("softedge");
1164 rWriter
.attribute("radius", OUString::number(rSoftEdgePrimitive2D
.getRadius()));
1166 decomposeAndWrite(rSoftEdgePrimitive2D
.getChildren(), rWriter
);
1167 rWriter
.endElement();
1171 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D
:
1173 const auto& rScenePrimitive2D
1174 = dynamic_cast<const drawinglayer::primitive2d::ScenePrimitive2D
&>(
1176 rWriter
.startElement("scene");
1178 auto const& rSceneAttribute
= rScenePrimitive2D
.getSdrSceneAttribute();
1180 rWriter
.attribute("shadowSlant", rSceneAttribute
.getShadowSlant());
1181 rWriter
.attribute("isTwoSidedLighting",
1182 sal_Int32(rSceneAttribute
.getTwoSidedLighting()));
1183 writeShadeMode(rWriter
, rSceneAttribute
.getShadeMode());
1184 writeProjectionMode(rWriter
, rSceneAttribute
.getProjectionMode());
1186 auto const& rLightingAttribute
= rScenePrimitive2D
.getSdrLightingAttribute();
1187 rWriter
.attribute("ambientLightColor",
1188 convertColorToString(rLightingAttribute
.getAmbientLightColor()));
1189 rWriter
.startElement("lights");
1190 for (auto const& rLight
: rLightingAttribute
.getLightVector())
1192 rWriter
.startElement("light");
1193 rWriter
.attribute("color", convertColorToString(rLight
.getColor()));
1194 rWriter
.attribute("directionVectorX", rLight
.getDirection().getX());
1195 rWriter
.attribute("directionVectorY", rLight
.getDirection().getY());
1196 rWriter
.attribute("specular", sal_Int32(rLight
.getSpecular()));
1197 rWriter
.endElement();
1199 rWriter
.endElement();
1201 Primitive3DXmlDump aPrimitive3DXmlDump
;
1202 aPrimitive3DXmlDump
.decomposeAndWrite(rScenePrimitive2D
.getChildren3D(), rWriter
);
1204 rWriter
.endElement();
1210 OString
aName("unhandled");
1213 case PRIMITIVE2D_ID_RANGE_SVX
| 14: // PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D
1219 rWriter
.startElement(aName
);
1220 rWriter
.attribute("id",
1221 OUStringToOString(sCurrentElementTag
, RTL_TEXTENCODING_UTF8
));
1222 rWriter
.attribute("idNumber", nId
);
1224 auto pBufferedDecomposition
1225 = dynamic_cast<const BufferedDecompositionPrimitive2D
*>(pBasePrimitive
);
1226 if (pBufferedDecomposition
)
1229 "transparenceForShadow",
1230 OString::number(pBufferedDecomposition
->getTransparenceForShadow()));
1233 drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer
;
1234 pBasePrimitive
->get2DDecomposition(aPrimitiveContainer
,
1235 drawinglayer::geometry::ViewInformation2D());
1236 decomposeAndWrite(aPrimitiveContainer
, rWriter
);
1237 rWriter
.endElement();
1244 } // end namespace drawinglayer
1246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */