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 <vcl/mtfxmldump.hxx>
11 #include <tools/XmlWriter.hxx>
12 #include <tools/fract.hxx>
14 #include <vcl/metaact.hxx>
15 #include <vcl/outdev.hxx>
16 #include <vcl/bitmap.hxx>
17 #include <vcl/BitmapReadAccess.hxx>
19 #include <rtl/string.hxx>
20 #include <rtl/ustrbuf.hxx>
22 #include <comphelper/hash.hxx>
29 OUString
collectPushFlags(vcl::PushFlags nFlags
)
31 if ((nFlags
& vcl::PushFlags::ALL
) == vcl::PushFlags::ALL
)
32 return u
"PushAll"_ustr
;
33 else if ((nFlags
& PUSH_ALLFONT
) == PUSH_ALLFONT
)
34 return u
"PushAllFont"_ustr
;
36 std::vector
<std::u16string_view
> aStrings
;
38 if (nFlags
& vcl::PushFlags::LINECOLOR
)
39 aStrings
.emplace_back(u
"PushLineColor");
40 if (nFlags
& vcl::PushFlags::FILLCOLOR
)
41 aStrings
.emplace_back(u
"PushFillColor");
42 if (nFlags
& vcl::PushFlags::FONT
)
43 aStrings
.emplace_back(u
"PushFont");
44 if (nFlags
& vcl::PushFlags::TEXTCOLOR
)
45 aStrings
.emplace_back(u
"PushTextColor");
46 if (nFlags
& vcl::PushFlags::MAPMODE
)
47 aStrings
.emplace_back(u
"PushMapMode");
48 if (nFlags
& vcl::PushFlags::CLIPREGION
)
49 aStrings
.emplace_back(u
"PushClipRegion");
50 if (nFlags
& vcl::PushFlags::RASTEROP
)
51 aStrings
.emplace_back(u
"PushRasterOp");
52 if (nFlags
& vcl::PushFlags::TEXTFILLCOLOR
)
53 aStrings
.emplace_back(u
"PushTextFillColor");
54 if (nFlags
& vcl::PushFlags::TEXTALIGN
)
55 aStrings
.emplace_back(u
"PushTextAlign");
56 if (nFlags
& vcl::PushFlags::REFPOINT
)
57 aStrings
.emplace_back(u
"PushRefPoint");
58 if (nFlags
& vcl::PushFlags::TEXTLINECOLOR
)
59 aStrings
.emplace_back(u
"PushTextLineColor");
60 if (nFlags
& vcl::PushFlags::TEXTLAYOUTMODE
)
61 aStrings
.emplace_back(u
"PushTextLayoutMode");
62 if (nFlags
& vcl::PushFlags::TEXTLANGUAGE
)
63 aStrings
.emplace_back(u
"PushTextLanguage");
64 if (nFlags
& vcl::PushFlags::OVERLINECOLOR
)
65 aStrings
.emplace_back(u
"PushOverlineColor");
68 return EMPTY_OUSTRING
;
70 OUStringBuffer aStringBuffer
;
72 aStringBuffer
.append(aStrings
[0]);
73 for (size_t i
= 1; i
< aStrings
.size(); ++i
)
75 aStringBuffer
.append(u
", "_ustr
+ aStrings
[i
]);
77 return aStringBuffer
.makeStringAndClear();
80 OUString
convertDrawTextFlagsToString(DrawTextFlags eDrawTextFlags
)
82 std::vector
<std::u16string_view
> aStrings
;
83 if (eDrawTextFlags
& DrawTextFlags::Disable
)
84 aStrings
.emplace_back(u
"Disable");
85 if (eDrawTextFlags
& DrawTextFlags::Mnemonic
)
86 aStrings
.emplace_back(u
"Mnemonic");
87 if (eDrawTextFlags
& DrawTextFlags::Mono
)
88 aStrings
.emplace_back(u
"Mono");
89 if (eDrawTextFlags
& DrawTextFlags::Clip
)
90 aStrings
.emplace_back(u
"Clip");
91 if (eDrawTextFlags
& DrawTextFlags::Left
)
92 aStrings
.emplace_back(u
"Left");
93 if (eDrawTextFlags
& DrawTextFlags::Center
)
94 aStrings
.emplace_back(u
"Center");
95 if (eDrawTextFlags
& DrawTextFlags::Right
)
96 aStrings
.emplace_back(u
"Right");
97 if (eDrawTextFlags
& DrawTextFlags::Top
)
98 aStrings
.emplace_back(u
"Top");
99 if (eDrawTextFlags
& DrawTextFlags::VCenter
)
100 aStrings
.emplace_back(u
"VCenter");
101 if (eDrawTextFlags
& DrawTextFlags::Bottom
)
102 aStrings
.emplace_back(u
"Bottom");
103 if (eDrawTextFlags
& DrawTextFlags::EndEllipsis
)
104 aStrings
.emplace_back(u
"EndEllipsis");
105 if (eDrawTextFlags
& DrawTextFlags::PathEllipsis
)
106 aStrings
.emplace_back(u
"PathEllipsis");
107 if (eDrawTextFlags
& DrawTextFlags::MultiLine
)
108 aStrings
.emplace_back(u
"MultiLine");
109 if (eDrawTextFlags
& DrawTextFlags::WordBreak
)
110 aStrings
.emplace_back(u
"WordBreak");
111 if (eDrawTextFlags
& DrawTextFlags::NewsEllipsis
)
112 aStrings
.emplace_back(u
"NewsEllipsis");
113 if (eDrawTextFlags
& DrawTextFlags::WordBreakHyphenation
)
114 aStrings
.emplace_back(u
"WordBreakHyphenation");
115 if (eDrawTextFlags
& DrawTextFlags::CenterEllipsis
)
116 aStrings
.emplace_back(u
"CenterEllipsis");
118 if (aStrings
.empty())
121 OUStringBuffer aStringBuffer
;
123 aStringBuffer
.append(aStrings
[0]);
124 for (size_t i
= 1; i
< aStrings
.size(); ++i
)
126 aStringBuffer
.append(u
" "_ustr
+ aStrings
[i
]);
128 return aStringBuffer
.makeStringAndClear();
131 OUString
convertRopToString(RasterOp eRop
)
135 case RasterOp::OverPaint
: return u
"overpaint"_ustr
;
136 case RasterOp::Xor
: return u
"xor"_ustr
;
137 case RasterOp::N0
: return u
"0"_ustr
;
138 case RasterOp::N1
: return u
"1"_ustr
;
139 case RasterOp::Invert
: return u
"invert"_ustr
;
144 OUString
convertTextAlignToString(TextAlign eAlign
)
148 case ALIGN_BASELINE
: return u
"baseline"_ustr
;
149 case ALIGN_BOTTOM
: return u
"bottom"_ustr
;
150 case ALIGN_TOP
: return u
"top"_ustr
;
151 case TextAlign_FORCE_EQUAL_SIZE
: return u
"equalsize"_ustr
;
156 OUString
convertColorToString(Color aColor
)
158 OUString aRGBString
= aColor
.AsRGBHexString();
159 return "#" + aRGBString
;
162 OUString
convertLineStyleToString(LineStyle eAlign
)
166 case LineStyle::NONE
: return u
"none"_ustr
;
167 case LineStyle::Solid
: return u
"solid"_ustr
;
168 case LineStyle::Dash
: return u
"dash"_ustr
;
174 OUString
convertLineJoinToString(basegfx::B2DLineJoin eJoin
)
179 case basegfx::B2DLineJoin::NONE
: return u
"none"_ustr
;
180 case basegfx::B2DLineJoin::Bevel
: return u
"bevel"_ustr
;
181 case basegfx::B2DLineJoin::Miter
: return u
"miter"_ustr
;
182 case basegfx::B2DLineJoin::Round
: return u
"round"_ustr
;
186 OUString
convertLineCapToString(css::drawing::LineCap eCap
)
191 case css::drawing::LineCap_BUTT
: return u
"butt"_ustr
;
192 case css::drawing::LineCap_ROUND
: return u
"round"_ustr
;
193 case css::drawing::LineCap_SQUARE
: return u
"square"_ustr
;
197 OUString
convertPolygonFlags(PolyFlags eFlags
)
202 case PolyFlags::Normal
: return u
"normal"_ustr
;
203 case PolyFlags::Control
: return u
"control"_ustr
;
204 case PolyFlags::Smooth
: return u
"smooth"_ustr
;
205 case PolyFlags::Symmetric
: return u
"symmetric"_ustr
;
209 OUString
convertFontWeightToString(FontWeight eFontWeight
)
213 case WEIGHT_DONTKNOW
: return u
"unknown"_ustr
;
214 case WEIGHT_THIN
: return u
"thin"_ustr
;
215 case WEIGHT_ULTRALIGHT
: return u
"ultralight"_ustr
;
216 case WEIGHT_LIGHT
: return u
"light"_ustr
;
217 case WEIGHT_SEMILIGHT
: return u
"semilight"_ustr
;
218 case WEIGHT_NORMAL
: return u
"normal"_ustr
;
219 case WEIGHT_MEDIUM
: return u
"medium"_ustr
;
220 case WEIGHT_SEMIBOLD
: return u
"semibold"_ustr
;
221 case WEIGHT_BOLD
: return u
"bold"_ustr
;
222 case WEIGHT_ULTRABOLD
: return u
"ultrabold"_ustr
;
223 case WEIGHT_BLACK
: return u
"black"_ustr
;
224 case FontWeight_FORCE_EQUAL_SIZE
: return u
"equalsize"_ustr
;
229 OUString
convertFontStrikeoutToString(FontStrikeout eFontStrikeout
)
231 switch (eFontStrikeout
)
233 case STRIKEOUT_NONE
: return u
"none"_ustr
;
234 case STRIKEOUT_SINGLE
: return u
"single"_ustr
;
235 case STRIKEOUT_DOUBLE
: return u
"double"_ustr
;
236 case STRIKEOUT_DONTKNOW
: return u
"dontknow"_ustr
;
237 case STRIKEOUT_BOLD
: return u
"bold"_ustr
;
238 case STRIKEOUT_SLASH
: return u
"slash"_ustr
;
239 case STRIKEOUT_X
: return u
"x"_ustr
;
240 case FontStrikeout_FORCE_EQUAL_SIZE
: return u
"equalsize"_ustr
;
245 OUString
convertFontLineStyleToString(FontLineStyle eFontLineStyle
)
247 switch (eFontLineStyle
)
249 case LINESTYLE_NONE
: return u
"none"_ustr
;
250 case LINESTYLE_SINGLE
: return u
"single"_ustr
;
251 case LINESTYLE_DOUBLE
: return u
"double"_ustr
;
252 case LINESTYLE_DOTTED
: return u
"dotted"_ustr
;
253 case LINESTYLE_DONTKNOW
: return u
"dontknow"_ustr
;
254 case LINESTYLE_DASH
: return u
"dash"_ustr
;
255 case LINESTYLE_LONGDASH
: return u
"longdash"_ustr
;
256 case LINESTYLE_DASHDOT
: return u
"dashdot"_ustr
;
257 case LINESTYLE_DASHDOTDOT
: return u
"dashdotdot"_ustr
;
258 case LINESTYLE_SMALLWAVE
: return u
"smallwave"_ustr
;
259 case LINESTYLE_WAVE
: return u
"wave"_ustr
;
260 case LINESTYLE_DOUBLEWAVE
: return u
"doublewave"_ustr
;
261 case LINESTYLE_BOLD
: return u
"bold"_ustr
;
262 case LINESTYLE_BOLDDOTTED
: return u
"bolddotted"_ustr
;
263 case LINESTYLE_BOLDDASH
: return u
"bolddash"_ustr
;
264 case LINESTYLE_BOLDLONGDASH
: return u
"boldlongdash"_ustr
;
265 case LINESTYLE_BOLDDASHDOT
: return u
"bolddashdot"_ustr
;
266 case LINESTYLE_BOLDDASHDOTDOT
: return u
"bolddashdotdot"_ustr
;
267 case LINESTYLE_BOLDWAVE
: return u
"boldwave"_ustr
;
268 case FontLineStyle_FORCE_EQUAL_SIZE
: return u
"equalsize"_ustr
;
273 OString
convertLineStyleToString(const MetaActionType nActionType
)
277 case MetaActionType::NONE
: return "null"_ostr
;
278 case MetaActionType::PIXEL
: return "pixel"_ostr
;
279 case MetaActionType::POINT
: return "point"_ostr
;
280 case MetaActionType::LINE
: return "line"_ostr
;
281 case MetaActionType::RECT
: return "rect"_ostr
;
282 case MetaActionType::ROUNDRECT
: return "roundrect"_ostr
;
283 case MetaActionType::ELLIPSE
: return "ellipse"_ostr
;
284 case MetaActionType::ARC
: return "arc"_ostr
;
285 case MetaActionType::PIE
: return "pie"_ostr
;
286 case MetaActionType::CHORD
: return "chord"_ostr
;
287 case MetaActionType::POLYLINE
: return "polyline"_ostr
;
288 case MetaActionType::POLYGON
: return "polygon"_ostr
;
289 case MetaActionType::POLYPOLYGON
: return "polypolygon"_ostr
;
290 case MetaActionType::TEXT
: return "text"_ostr
;
291 case MetaActionType::TEXTARRAY
: return "textarray"_ostr
;
292 case MetaActionType::STRETCHTEXT
: return "stretchtext"_ostr
;
293 case MetaActionType::TEXTRECT
: return "textrect"_ostr
;
294 case MetaActionType::TEXTLINE
: return "textline"_ostr
;
295 case MetaActionType::BMP
: return "bmp"_ostr
;
296 case MetaActionType::BMPSCALE
: return "bmpscale"_ostr
;
297 case MetaActionType::BMPSCALEPART
: return "bmpscalepart"_ostr
;
298 case MetaActionType::BMPEX
: return "bmpex"_ostr
;
299 case MetaActionType::BMPEXSCALE
: return "bmpexscale"_ostr
;
300 case MetaActionType::BMPEXSCALEPART
: return "bmpexscalepart"_ostr
;
301 case MetaActionType::MASK
: return "mask"_ostr
;
302 case MetaActionType::MASKSCALE
: return "maskscale"_ostr
;
303 case MetaActionType::MASKSCALEPART
: return "maskscalepart"_ostr
;
304 case MetaActionType::GRADIENT
: return "gradient"_ostr
;
305 case MetaActionType::GRADIENTEX
: return "gradientex"_ostr
;
306 case MetaActionType::HATCH
: return "hatch"_ostr
;
307 case MetaActionType::WALLPAPER
: return "wallpaper"_ostr
;
308 case MetaActionType::CLIPREGION
: return "clipregion"_ostr
;
309 case MetaActionType::ISECTRECTCLIPREGION
: return "sectrectclipregion"_ostr
;
310 case MetaActionType::ISECTREGIONCLIPREGION
: return "sectregionclipregion"_ostr
;
311 case MetaActionType::MOVECLIPREGION
: return "moveclipregion"_ostr
;
312 case MetaActionType::LINECOLOR
: return "linecolor"_ostr
;
313 case MetaActionType::FILLCOLOR
: return "fillcolor"_ostr
;
314 case MetaActionType::TEXTCOLOR
: return "textcolor"_ostr
;
315 case MetaActionType::TEXTFILLCOLOR
: return "textfillcolor"_ostr
;
316 case MetaActionType::TEXTLINECOLOR
: return "textlinecolor"_ostr
;
317 case MetaActionType::OVERLINECOLOR
: return "overlinecolor"_ostr
;
318 case MetaActionType::TEXTALIGN
: return "textalign"_ostr
;
319 case MetaActionType::MAPMODE
: return "mapmode"_ostr
;
320 case MetaActionType::FONT
: return "font"_ostr
;
321 case MetaActionType::PUSH
: return "push"_ostr
;
322 case MetaActionType::POP
: return "pop"_ostr
;
323 case MetaActionType::RASTEROP
: return "rasterop"_ostr
;
324 case MetaActionType::Transparent
: return "transparent"_ostr
;
325 case MetaActionType::FLOATTRANSPARENT
: return "floattransparent"_ostr
;
326 case MetaActionType::EPS
: return "eps"_ostr
;
327 case MetaActionType::REFPOINT
: return "refpoint"_ostr
;
328 case MetaActionType::COMMENT
: return "comment"_ostr
;
329 case MetaActionType::LAYOUTMODE
: return "layoutmode"_ostr
;
330 case MetaActionType::TEXTLANGUAGE
: return "textlanguage"_ostr
;
335 OUString
convertBitmapExTransparentType(BitmapEx
const & rBitmapEx
)
337 if (rBitmapEx
.IsAlpha())
338 return u
"bitmap"_ustr
;
343 OUString
convertMapUnitToString(MapUnit eUnit
)
348 case MapUnit::LASTENUMDUMMY
: return u
"LASTENUMDUMMY"_ustr
;
349 case MapUnit::Map1000thInch
: return u
"Map1000thInch"_ustr
;
350 case MapUnit::Map100thInch
: return u
"Map100thInch"_ustr
;
351 case MapUnit::Map100thMM
: return u
"Map100thMM"_ustr
;
352 case MapUnit::Map10thInch
: return u
"Map10thInch"_ustr
;
353 case MapUnit::Map10thMM
: return u
"Map10thMM"_ustr
;
354 case MapUnit::MapAppFont
: return u
"MapAppFont"_ustr
;
355 case MapUnit::MapCM
: return u
"MapCM"_ustr
;
356 case MapUnit::MapInch
: return u
"MapInch"_ustr
;
357 case MapUnit::MapMM
: return u
"MapMM"_ustr
;
358 case MapUnit::MapPixel
: return u
"MapPixel"_ustr
;
359 case MapUnit::MapPoint
: return u
"MapPoint"_ustr
;
360 case MapUnit::MapRelative
: return u
"MapRelative"_ustr
;
361 case MapUnit::MapSysFont
: return u
"MapSysFont"_ustr
;
362 case MapUnit::MapTwip
: return u
"MapTwip"_ustr
;
366 OUString
convertFractionToString(const Fraction
& aFraction
)
368 std::stringstream ss
;
372 return OUString::createFromAscii(ss
.str());
375 OUString
convertGradientStyleToOUString(css::awt::GradientStyle eStyle
)
379 case css::awt::GradientStyle_LINEAR
: return u
"Linear"_ustr
;
380 case css::awt::GradientStyle_AXIAL
: return u
"Axial"_ustr
;
381 case css::awt::GradientStyle_RADIAL
: return u
"Radial"_ustr
;
382 case css::awt::GradientStyle_ELLIPTICAL
: return u
"Elliptical"_ustr
;
383 case css::awt::GradientStyle_SQUARE
: return u
"Square"_ustr
;
384 case css::awt::GradientStyle_RECT
: return u
"Rect"_ustr
;
385 case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE
: return u
"ForceEqualSize"_ustr
;
390 OUString
convertHatchStyle(HatchStyle eStyle
)
394 case HatchStyle::Single
: return u
"Single"_ustr
;
395 case HatchStyle::Double
: return u
"Double"_ustr
;
396 case HatchStyle::Triple
: return u
"Triple"_ustr
;
397 case HatchStyle::FORCE_EQUAL_SIZE
: return u
"ForceEqualSize"_ustr
;
402 OUString
convertLanguageTypeToString(LanguageType rLanguageType
)
404 std::stringstream ss
;
405 ss
<< std::hex
<< std::setfill ('0') << std::setw(4) << rLanguageType
.get();
406 return "#" + OUString::createFromAscii(ss
.str());
409 OUString
convertWallpaperStyleToString(WallpaperStyle eWallpaperStyle
)
411 switch (eWallpaperStyle
)
413 case WallpaperStyle::NONE
: return u
"NONE"_ustr
;
414 case WallpaperStyle::Tile
: return u
"Tile"_ustr
;
415 case WallpaperStyle::Center
: return u
"Center"_ustr
;
416 case WallpaperStyle::Scale
: return u
"Scale"_ustr
;
417 case WallpaperStyle::TopLeft
: return u
"TopLeft"_ustr
;
418 case WallpaperStyle::Top
: return u
"Top"_ustr
;
419 case WallpaperStyle::TopRight
: return u
"TopRight"_ustr
;
420 case WallpaperStyle::Left
: return u
"Left"_ustr
;
421 case WallpaperStyle::Right
: return u
"Right"_ustr
;
422 case WallpaperStyle::BottomLeft
: return u
"BottomLeft"_ustr
;
423 case WallpaperStyle::Bottom
: return u
"Bottom"_ustr
;
424 case WallpaperStyle::BottomRight
: return u
"BottomRight"_ustr
;
425 case WallpaperStyle::ApplicationGradient
: return u
"ApplicationGradient"_ustr
;
430 OUString
convertPixelFormatToString(vcl::PixelFormat ePixelFormat
)
432 switch (ePixelFormat
)
434 case vcl::PixelFormat::INVALID
: return u
"INVALID"_ustr
;
435 case vcl::PixelFormat::N8_BPP
: return u
"8BPP"_ustr
;
436 case vcl::PixelFormat::N24_BPP
: return u
"24BPP"_ustr
;
437 case vcl::PixelFormat::N32_BPP
: return u
"32BPP"_ustr
;
442 OUString
convertComplexTestLayoutFlags(vcl::text::ComplexTextLayoutFlags nFlags
)
444 if (nFlags
== vcl::text::ComplexTextLayoutFlags::Default
)
445 return u
"Default"_ustr
;
447 std::vector
<std::u16string_view
> aStrings
;
449 if (nFlags
& vcl::text::ComplexTextLayoutFlags::BiDiRtl
)
450 aStrings
.emplace_back(u
"BiDiRtl");
451 if (nFlags
& vcl::text::ComplexTextLayoutFlags::BiDiStrong
)
452 aStrings
.emplace_back(u
"BiDiStrong");
453 if (nFlags
& vcl::text::ComplexTextLayoutFlags::TextOriginLeft
)
454 aStrings
.emplace_back(u
"TextOriginLeft");
455 if (nFlags
& vcl::text::ComplexTextLayoutFlags::TextOriginRight
)
456 aStrings
.emplace_back(u
"TextOriginRight");
458 if (aStrings
.empty())
459 return EMPTY_OUSTRING
;
461 OUStringBuffer aStringBuffer
;
463 aStringBuffer
.append(aStrings
[0]);
464 for (size_t i
= 1; i
< aStrings
.size(); ++i
)
466 aStringBuffer
.append(u
", "_ustr
+ aStrings
[i
]);
468 return aStringBuffer
.makeStringAndClear();
471 OUString
convertGfxLinkTypeToString(GfxLinkType eGfxLinkType
)
475 case GfxLinkType::EpsBuffer
: return u
"EpsBuffer"_ustr
;
476 case GfxLinkType::NativeBmp
: return u
"NativeBmp"_ustr
;
477 case GfxLinkType::NativeGif
: return u
"NativeGif"_ustr
;
478 case GfxLinkType::NativeJpg
: return u
"NativeJpg"_ustr
;
479 case GfxLinkType::NativeMet
: return u
"NativeMet"_ustr
;
480 case GfxLinkType::NativeMov
: return u
"NativeMov"_ustr
;
481 case GfxLinkType::NativePct
: return u
"NativePct"_ustr
;
482 case GfxLinkType::NativePdf
: return u
"NativePdf"_ustr
;
483 case GfxLinkType::NativePng
: return u
"NativePng"_ustr
;
484 case GfxLinkType::NativeSvg
: return u
"NativeSvg"_ustr
;
485 case GfxLinkType::NativeTif
: return u
"NativeTif"_ustr
;
486 case GfxLinkType::NativeWmf
: return u
"NativeWmf"_ustr
;
487 case GfxLinkType::NativeWebp
: return u
"NativeWebp"_ustr
;
488 case GfxLinkType::NONE
: return u
"None"_ustr
;
493 OUString
hex32(sal_uInt32 nNumber
)
495 std::stringstream ss
;
496 ss
<< std::hex
<< std::setfill('0') << std::setw(8) << nNumber
;
497 return OUString::createFromAscii(ss
.str());
500 OUString
toHexString(const sal_uInt8
* nData
, sal_uInt32 nDataSize
){
502 std::stringstream aStrm
;
503 for (sal_uInt32 i
= 0; i
< nDataSize
; i
++)
505 aStrm
<< std::setw(2) << std::setfill('0') << std::hex
<< static_cast<int>(nData
[i
]);
508 return OUString::createFromAscii(aStrm
.str());
511 void writePoint(tools::XmlWriter
& rWriter
, Point
const& rPoint
)
513 rWriter
.attribute("x", rPoint
.X());
514 rWriter
.attribute("y", rPoint
.Y());
517 void writeStartPoint(tools::XmlWriter
& rWriter
, Point
const& rPoint
)
519 rWriter
.attribute("startx", rPoint
.X());
520 rWriter
.attribute("starty", rPoint
.Y());
523 void writeEndPoint(tools::XmlWriter
& rWriter
, Point
const& rPoint
)
525 rWriter
.attribute("endx", rPoint
.X());
526 rWriter
.attribute("endy", rPoint
.Y());
529 void writeSize(tools::XmlWriter
& rWriter
, Size
const& rSize
)
531 rWriter
.attribute("width", rSize
.Width());
532 rWriter
.attribute("height", rSize
.Height());
535 void writeRectangle(tools::XmlWriter
& rWriter
, tools::Rectangle
const& rRectangle
)
537 rWriter
.attribute("left", rRectangle
.Left());
538 rWriter
.attribute("top", rRectangle
.Top());
539 if (rRectangle
.IsWidthEmpty())
540 rWriter
.attribute("right", "empty"_ostr
);
542 rWriter
.attribute("right", rRectangle
.Right());
543 if (rRectangle
.IsHeightEmpty())
544 rWriter
.attribute("bottom", "empty"_ostr
);
546 rWriter
.attribute("bottom", rRectangle
.Bottom());
549 void writeMapMode(tools::XmlWriter
& rWriter
, MapMode
const& rMapMode
)
551 rWriter
.attribute("mapunit", convertMapUnitToString( rMapMode
.GetMapUnit() ));
552 writePoint(rWriter
, rMapMode
.GetOrigin());
553 rWriter
.attribute("scalex", convertFractionToString(rMapMode
.GetScaleX()));
554 rWriter
.attribute("scaley", convertFractionToString(rMapMode
.GetScaleY()));
557 void writeLineInfo(tools::XmlWriter
& rWriter
, LineInfo
const& rLineInfo
)
559 rWriter
.attribute("style", convertLineStyleToString(rLineInfo
.GetStyle()));
560 rWriter
.attribute("width", rLineInfo
.GetWidth());
561 rWriter
.attribute("dashlen", rLineInfo
.GetDashLen());
562 rWriter
.attribute("dashcount", rLineInfo
.GetDashCount());
563 rWriter
.attribute("dotlen", rLineInfo
.GetDotLen());
564 rWriter
.attribute("dotcount", rLineInfo
.GetDotCount());
565 rWriter
.attribute("distance", rLineInfo
.GetDistance());
566 rWriter
.attribute("join", convertLineJoinToString(rLineInfo
.GetLineJoin()));
567 rWriter
.attribute("cap", convertLineCapToString(rLineInfo
.GetLineCap()));
570 void writeGradient(tools::XmlWriter
& rWriter
, Gradient
const& rGradient
)
572 rWriter
.attribute("style", convertGradientStyleToOUString(rGradient
.GetStyle()));
573 rWriter
.attribute("startcolor", convertColorToString(rGradient
.GetStartColor()));
574 rWriter
.attribute("endcolor", convertColorToString(rGradient
.GetEndColor()));
575 rWriter
.attribute("angle", rGradient
.GetAngle().get());
576 rWriter
.attribute("border", rGradient
.GetBorder());
577 rWriter
.attribute("offsetx", rGradient
.GetOfsX());
578 rWriter
.attribute("offsety", rGradient
.GetOfsY());
579 rWriter
.attribute("startintensity", rGradient
.GetStartIntensity());
580 rWriter
.attribute("endintensity", rGradient
.GetEndIntensity());
581 rWriter
.attribute("steps", rGradient
.GetSteps());
584 OString
toHexString(const std::vector
<unsigned char>& a
)
586 std::stringstream aStrm
;
589 aStrm
<< std::setw(2) << std::setfill('0') << std::hex
<< static_cast<int>(i
);
592 return OString(aStrm
.str());
595 void writeBitmapContentChecksum(tools::XmlWriter
& rWriter
, Bitmap
const& rBitmap
)
597 const Bitmap
& aBitmap(rBitmap
);
599 comphelper::Hash
aHashEngine(comphelper::HashType::SHA1
);
600 BitmapScopedReadAccess
pReadAccess(aBitmap
);
603 for (tools::Long y
= 0 ; y
< pReadAccess
->Height() ; ++y
)
605 for (tools::Long x
= 0 ; x
< pReadAccess
->Width() ; ++x
)
607 BitmapColor aColor
= pReadAccess
->GetColor(y
, x
);
608 sal_uInt8 r
= aColor
.GetRed();
609 sal_uInt8 g
= aColor
.GetGreen();
610 sal_uInt8 b
= aColor
.GetBlue();
611 sal_uInt8 a
= aColor
.GetAlpha();
612 aHashEngine
.update(&r
, 1);
613 aHashEngine
.update(&g
, 1);
614 aHashEngine
.update(&b
, 1);
615 aHashEngine
.update(&a
, 1);
618 std::vector
<unsigned char> aVector
= aHashEngine
.finalize();
619 rWriter
.attribute("contentchecksum", toHexString(aVector
));
622 void writeBitmap(tools::XmlWriter
& rWriter
, Bitmap
const& rBitmap
)
624 writeBitmapContentChecksum(rWriter
, rBitmap
);
625 rWriter
.attribute("bitmapwidth", rBitmap
.GetSizePixel().Width());
626 rWriter
.attribute("bitmapheight", rBitmap
.GetSizePixel().Height());
627 rWriter
.attribute("pixelformat", convertPixelFormatToString(rBitmap
.getPixelFormat()));
628 rWriter
.attribute("crc", hex32(rBitmap
.GetChecksum()));
631 } // anonymous namespace
633 MetafileXmlDump::MetafileXmlDump()
635 maFilter
.fill(false);
638 void MetafileXmlDump::filterActionType(const MetaActionType nActionType
, bool bShouldFilter
)
640 maFilter
[nActionType
] = bShouldFilter
;
643 void MetafileXmlDump::filterAllActionTypes()
648 void MetafileXmlDump::dump(const GDIMetaFile
& rMetaFile
, SvStream
& rStream
)
650 tools::XmlWriter
aWriter(&rStream
);
651 aWriter
.startDocument();
652 aWriter
.startElement("metafile");
654 writeXml(rMetaFile
, aWriter
);
656 aWriter
.endElement();
657 aWriter
.endDocument();
660 void MetafileXmlDump::writeXml(const GDIMetaFile
& rMetaFile
, tools::XmlWriter
& rWriter
)
662 const MapMode
& aMtfMapMode
= rMetaFile
.GetPrefMapMode();
663 rWriter
.attribute("mapunit", convertMapUnitToString(aMtfMapMode
.GetMapUnit()));
664 writePoint(rWriter
, aMtfMapMode
.GetOrigin());
665 rWriter
.attribute("scalex", convertFractionToString(aMtfMapMode
.GetScaleX()));
666 rWriter
.attribute("scaley", convertFractionToString(aMtfMapMode
.GetScaleY()));
668 Size aMtfSize
= rMetaFile
.GetPrefSize();
669 writeSize(rWriter
, aMtfSize
);
671 for(size_t nAction
= 0; nAction
< rMetaFile
.GetActionSize(); ++nAction
)
673 MetaAction
* pAction
= rMetaFile
.GetAction(nAction
);
674 const MetaActionType nActionType
= pAction
->GetType();
675 if (maFilter
[nActionType
])
678 OString sCurrentElementTag
= convertLineStyleToString(nActionType
);
682 case MetaActionType::NONE
:
684 rWriter
.startElement(sCurrentElementTag
);
685 rWriter
.endElement();
689 case MetaActionType::PIXEL
:
691 auto* pMetaAction
= static_cast<MetaPixelAction
*>(pAction
);
692 rWriter
.startElement(sCurrentElementTag
);
693 writePoint(rWriter
, pMetaAction
->GetPoint());
694 rWriter
.attribute("color", convertColorToString(pMetaAction
->GetColor()));
695 rWriter
.endElement();
699 case MetaActionType::POINT
:
701 auto* pMetaAction
= static_cast<MetaPointAction
*>(pAction
);
702 rWriter
.startElement(sCurrentElementTag
);
703 writePoint(rWriter
, pMetaAction
->GetPoint());
704 rWriter
.endElement();
708 case MetaActionType::LINE
:
710 MetaLineAction
* pMetaLineAction
= static_cast<MetaLineAction
*>(pAction
);
711 rWriter
.startElement(sCurrentElementTag
);
712 writeStartPoint(rWriter
, pMetaLineAction
->GetStartPoint());
713 writeEndPoint(rWriter
, pMetaLineAction
->GetEndPoint());
715 writeLineInfo(rWriter
, pMetaLineAction
->GetLineInfo());
716 rWriter
.endElement();
720 case MetaActionType::RECT
:
722 MetaRectAction
* pMetaAction
= static_cast<MetaRectAction
*>(pAction
);
723 rWriter
.startElement(sCurrentElementTag
);
724 writeRectangle(rWriter
, pMetaAction
->GetRect());
725 rWriter
.endElement();
729 case MetaActionType::ROUNDRECT
:
731 auto pMetaAction
= static_cast<MetaRoundRectAction
*>(pAction
);
732 rWriter
.startElement(sCurrentElementTag
);
733 writeRectangle(rWriter
, pMetaAction
->GetRect());
734 rWriter
.attribute("horizontalround", pMetaAction
->GetHorzRound());
735 rWriter
.attribute("verticalround", pMetaAction
->GetVertRound());
736 rWriter
.endElement();
740 case MetaActionType::ELLIPSE
:
742 auto pMetaAction
= static_cast<MetaEllipseAction
*>(pAction
);
743 rWriter
.startElement(sCurrentElementTag
);
744 writeRectangle(rWriter
, pMetaAction
->GetRect());
745 rWriter
.endElement();
749 case MetaActionType::ARC
:
751 auto pMetaAction
= static_cast<MetaArcAction
*>(pAction
);
752 rWriter
.startElement(sCurrentElementTag
);
753 writeRectangle(rWriter
, pMetaAction
->GetRect());
754 writeStartPoint(rWriter
, pMetaAction
->GetStartPoint());
755 writeEndPoint(rWriter
, pMetaAction
->GetEndPoint());
756 rWriter
.endElement();
760 case MetaActionType::PIE
:
762 auto pMetaAction
= static_cast<MetaPieAction
*>(pAction
);
763 rWriter
.startElement(sCurrentElementTag
);
764 writeRectangle(rWriter
, pMetaAction
->GetRect());
765 writeStartPoint(rWriter
, pMetaAction
->GetStartPoint());
766 writeEndPoint(rWriter
, pMetaAction
->GetEndPoint());
767 rWriter
.endElement();
771 case MetaActionType::CHORD
:
773 auto pMetaAction
= static_cast<MetaChordAction
*>(pAction
);
774 rWriter
.startElement(sCurrentElementTag
);
775 writeRectangle(rWriter
, pMetaAction
->GetRect());
776 writeStartPoint(rWriter
, pMetaAction
->GetStartPoint());
777 writeEndPoint(rWriter
, pMetaAction
->GetEndPoint());
778 rWriter
.endElement();
782 case MetaActionType::POLYLINE
:
784 MetaPolyLineAction
* pMetaPolyLineAction
= static_cast<MetaPolyLineAction
*>(pAction
);
785 rWriter
.startElement(sCurrentElementTag
);
787 writeLineInfo(rWriter
, pMetaPolyLineAction
->GetLineInfo());
789 tools::Polygon aPolygon
= pMetaPolyLineAction
->GetPolygon();
790 bool bFlags
= aPolygon
.HasFlags();
791 for (sal_uInt16 i
= 0; i
< aPolygon
.GetSize(); i
++)
793 rWriter
.startElement("point");
794 writePoint(rWriter
, aPolygon
[i
]);
796 rWriter
.attribute("flags", convertPolygonFlags(aPolygon
.GetFlags(i
)));
797 rWriter
.endElement();
800 rWriter
.endElement();
804 case MetaActionType::POLYGON
:
806 MetaPolygonAction
* pMetaPolygonAction
= static_cast<MetaPolygonAction
*>(pAction
);
807 rWriter
.startElement(sCurrentElementTag
);
809 tools::Polygon aPolygon
= pMetaPolygonAction
->GetPolygon();
810 bool bFlags
= aPolygon
.HasFlags();
811 for (sal_uInt16 i
= 0; i
< aPolygon
.GetSize(); i
++)
813 rWriter
.startElement("point");
814 writePoint(rWriter
, aPolygon
[i
]);
816 rWriter
.attribute("flags", convertPolygonFlags(aPolygon
.GetFlags(i
)));
817 rWriter
.endElement();
820 rWriter
.endElement();
824 case MetaActionType::POLYPOLYGON
:
826 MetaPolyPolygonAction
*const pMetaPolyPolygonAction
= static_cast<MetaPolyPolygonAction
*>(pAction
);
827 rWriter
.startElement(sCurrentElementTag
);
829 tools::PolyPolygon
const& rPolyPolygon(pMetaPolyPolygonAction
->GetPolyPolygon());
831 for (sal_uInt16 j
= 0; j
< rPolyPolygon
.Count(); ++j
)
833 rWriter
.startElement("polygon");
834 tools::Polygon
const& rPolygon
= rPolyPolygon
[j
];
835 bool bFlags
= rPolygon
.HasFlags();
836 for (sal_uInt16 i
= 0; i
< rPolygon
.GetSize(); ++i
)
838 rWriter
.startElement("point");
839 writePoint(rWriter
, rPolygon
[i
]);
841 rWriter
.attribute("flags", convertPolygonFlags(rPolygon
.GetFlags(i
)));
842 rWriter
.endElement();
844 rWriter
.endElement();
846 rWriter
.endElement();
850 case MetaActionType::TEXT
:
852 auto* pMeta
= static_cast<MetaTextAction
*>(pAction
);
853 rWriter
.startElement(sCurrentElementTag
);
854 writePoint(rWriter
, pMeta
->GetPoint());
855 rWriter
.attribute("index", pMeta
->GetIndex());
856 rWriter
.attribute("length", pMeta
->GetLen());
857 rWriter
.startElement("textcontent");
858 rWriter
.content(pMeta
->GetText());
859 rWriter
.endElement();
861 rWriter
.endElement();
865 case MetaActionType::TEXTARRAY
:
867 MetaTextArrayAction
* pMetaTextArrayAction
= static_cast<MetaTextArrayAction
*>(pAction
);
868 rWriter
.startElement(sCurrentElementTag
);
870 sal_Int32 aIndex
= pMetaTextArrayAction
->GetIndex();
871 sal_Int32 aLength
= pMetaTextArrayAction
->GetLen();
873 writePoint(rWriter
, pMetaTextArrayAction
->GetPoint());
874 rWriter
.attribute("index", aIndex
);
875 rWriter
.attribute("length", aLength
);
877 if (pMetaTextArrayAction
->GetLayoutContextIndex() >= 0)
879 rWriter
.attribute("layoutcontextindex",
880 pMetaTextArrayAction
->GetLayoutContextIndex());
881 rWriter
.attribute("layoutcontextlength",
882 pMetaTextArrayAction
->GetLayoutContextLen());
885 if (!pMetaTextArrayAction
->GetDXArray().empty())
887 auto & rArray
= pMetaTextArrayAction
->GetDXArray();
888 rWriter
.startElement("dxarray");
889 if (aIndex
< o3tl::narrowing
<sal_Int32
>(rArray
.size()))
890 rWriter
.attribute("first", rArray
[aIndex
]);
891 if (aIndex
+ aLength
- 1 < o3tl::narrowing
<sal_Int32
>(rArray
.size()))
892 rWriter
.attribute("last", rArray
[aIndex
+ aLength
- 1]);
893 OUStringBuffer
sDxLengthString(std::max((aLength
- aIndex
) * 4, sal_Int32(0)));
894 for (sal_Int32 i
= 0; i
< aLength
- aIndex
; ++i
)
896 sDxLengthString
.append(OUString::number(rArray
[aIndex
+ i
]) + " ");
898 rWriter
.content(sDxLengthString
);
899 rWriter
.endElement();
902 rWriter
.startElement("text");
904 const OUString
& rStr
= pMetaTextArrayAction
->GetText();
905 // fix bad XML dump by removing forbidden 0x01
906 // FIXME: expand footnote anchor point 0x01 instead of this
907 if ( rStr
.indexOf(0x01) > -1 )
908 rWriter
.content(rStr
.replaceAll("\001", ""));
910 rWriter
.content(rStr
);
912 rWriter
.endElement();
914 rWriter
.endElement();
918 case MetaActionType::STRETCHTEXT
:
920 auto* pMeta
= static_cast<MetaStretchTextAction
*>(pAction
);
921 rWriter
.startElement(sCurrentElementTag
);
923 writePoint(rWriter
, pMeta
->GetPoint());
924 rWriter
.attribute("index", pMeta
->GetIndex());
925 rWriter
.attribute("length", pMeta
->GetLen());
926 rWriter
.attribute("width", pMeta
->GetWidth());
928 rWriter
.startElement("textcontent");
929 rWriter
.content(pMeta
->GetText());
930 rWriter
.endElement();
932 rWriter
.endElement();
936 case MetaActionType::TEXTRECT
:
938 auto* pMeta
= static_cast<MetaTextRectAction
*>(pAction
);
939 rWriter
.startElement(sCurrentElementTag
);
940 writeRectangle(rWriter
, pMeta
->GetRect());
941 rWriter
.startElement("textcontent");
942 rWriter
.content(pMeta
->GetText());
943 rWriter
.endElement();
945 rWriter
.startElement("style");
946 rWriter
.content(convertDrawTextFlagsToString(pMeta
->GetStyle()));
947 rWriter
.endElement();
949 rWriter
.endElement();
953 case MetaActionType::BMP
:
955 auto pMeta
= static_cast<MetaBmpAction
*>(pAction
);
956 Bitmap aBitmap
= pMeta
->GetBitmap();
957 rWriter
.startElement(sCurrentElementTag
);
958 writePoint(rWriter
, pMeta
->GetPoint());
959 writeBitmap(rWriter
, aBitmap
);
960 rWriter
.endElement();
964 case MetaActionType::BMPSCALE
:
966 auto pMeta
= static_cast<MetaBmpScaleAction
*>(pAction
);
967 Bitmap aBitmap
= pMeta
->GetBitmap();
968 rWriter
.startElement(sCurrentElementTag
);
969 writePoint(rWriter
, pMeta
->GetPoint());
970 writeSize(rWriter
, pMeta
->GetSize());
971 writeBitmap(rWriter
, aBitmap
);
972 rWriter
.endElement();
976 case MetaActionType::BMPSCALEPART
:
978 auto pMeta
= static_cast<MetaBmpScalePartAction
*>(pAction
);
979 Bitmap aBitmap
= pMeta
->GetBitmap();
980 rWriter
.startElement(sCurrentElementTag
);
981 rWriter
.attribute("destx", pMeta
->GetDestPoint().X());
982 rWriter
.attribute("desty", pMeta
->GetDestPoint().Y());
983 rWriter
.attribute("destwidth", pMeta
->GetDestSize().Width());
984 rWriter
.attribute("destheight", pMeta
->GetDestSize().Height());
985 rWriter
.attribute("srcx", pMeta
->GetSrcPoint().X());
986 rWriter
.attribute("srcy", pMeta
->GetSrcPoint().Y());
987 rWriter
.attribute("srcwidth", pMeta
->GetSrcSize().Width());
988 rWriter
.attribute("srcheight", pMeta
->GetSrcSize().Height());
989 writeBitmap(rWriter
, aBitmap
);
990 rWriter
.endElement();
994 case MetaActionType::BMPEX
:
996 auto pMeta
= static_cast<MetaBmpExAction
*>(pAction
);
997 rWriter
.startElement(sCurrentElementTag
);
998 writePoint(rWriter
, pMeta
->GetPoint());
999 Bitmap aBitmap
= pMeta
->GetBitmapEx().GetBitmap();
1000 rWriter
.attribute("transparenttype", convertBitmapExTransparentType(pMeta
->GetBitmapEx()));
1001 writeBitmap(rWriter
, aBitmap
);
1002 rWriter
.endElement();
1006 case MetaActionType::BMPEXSCALE
:
1008 auto pMeta
= static_cast<MetaBmpExScaleAction
*>(pAction
);
1009 rWriter
.startElement(sCurrentElementTag
);
1010 writePoint(rWriter
, pMeta
->GetPoint());
1011 writeSize(rWriter
, pMeta
->GetSize());
1012 Bitmap aBitmap
= pMeta
->GetBitmapEx().GetBitmap();
1013 rWriter
.attribute("transparenttype", convertBitmapExTransparentType(pMeta
->GetBitmapEx()));
1014 writeBitmap(rWriter
, aBitmap
);
1015 rWriter
.endElement();
1019 case MetaActionType::BMPEXSCALEPART
:
1021 auto pMeta
= static_cast<MetaBmpExScalePartAction
*>(pAction
);
1022 Bitmap aBitmap
= pMeta
->GetBitmapEx().GetBitmap();
1023 rWriter
.startElement(sCurrentElementTag
);
1024 rWriter
.attribute("destx", pMeta
->GetDestPoint().X());
1025 rWriter
.attribute("desty", pMeta
->GetDestPoint().Y());
1026 rWriter
.attribute("destwidth", pMeta
->GetDestSize().Width());
1027 rWriter
.attribute("destheight", pMeta
->GetDestSize().Height());
1028 rWriter
.attribute("srcx", pMeta
->GetSrcPoint().X());
1029 rWriter
.attribute("srcy", pMeta
->GetSrcPoint().Y());
1030 rWriter
.attribute("srcwidth", pMeta
->GetSrcSize().Width());
1031 rWriter
.attribute("srcheight", pMeta
->GetSrcSize().Height());
1032 rWriter
.attribute("transparenttype", convertBitmapExTransparentType(pMeta
->GetBitmapEx()));
1033 writeBitmap(rWriter
, aBitmap
);
1034 rWriter
.endElement();
1038 case MetaActionType::MASK
:
1040 auto pMeta
= static_cast<MetaMaskAction
*>(pAction
);
1041 rWriter
.startElement(sCurrentElementTag
);
1042 writePoint(rWriter
, pMeta
->GetPoint());
1043 rWriter
.attribute("crc", hex32(pMeta
->GetBitmap().GetChecksum()));
1044 rWriter
.attribute("color", convertColorToString(pMeta
->GetColor()));
1045 rWriter
.endElement();
1049 case MetaActionType::MASKSCALE
:
1051 auto pMeta
= static_cast<MetaMaskScaleAction
*>(pAction
);
1052 rWriter
.startElement(sCurrentElementTag
);
1053 writePoint(rWriter
, pMeta
->GetPoint());
1054 writeSize(rWriter
, pMeta
->GetSize());
1055 rWriter
.attribute("crc", hex32(pMeta
->GetBitmap().GetChecksum()));
1056 rWriter
.attribute("color", convertColorToString(pMeta
->GetColor()));
1057 rWriter
.endElement();
1061 case MetaActionType::MASKSCALEPART
:
1063 auto pMeta
= static_cast<MetaMaskScalePartAction
*>(pAction
);
1064 rWriter
.startElement(sCurrentElementTag
);
1065 rWriter
.attribute("destx", pMeta
->GetDestPoint().X());
1066 rWriter
.attribute("desty", pMeta
->GetDestPoint().Y());
1067 rWriter
.attribute("destwidth", pMeta
->GetDestSize().Width());
1068 rWriter
.attribute("destheight", pMeta
->GetDestSize().Height());
1069 rWriter
.attribute("srcx", pMeta
->GetSrcPoint().X());
1070 rWriter
.attribute("srcy", pMeta
->GetSrcPoint().Y());
1071 rWriter
.attribute("srcwidth", pMeta
->GetSrcSize().Width());
1072 rWriter
.attribute("srcheight", pMeta
->GetSrcSize().Height());
1073 rWriter
.attribute("crc", hex32(pMeta
->GetBitmap().GetChecksum()));
1074 rWriter
.attribute("color", convertColorToString(pMeta
->GetColor()));
1075 rWriter
.endElement();
1079 case MetaActionType::GRADIENT
:
1081 const MetaGradientAction
* pMeta
= static_cast<MetaGradientAction
*>(pAction
);
1083 rWriter
.startElement(sCurrentElementTag
);
1084 writeGradient(rWriter
, pMeta
->GetGradient());
1086 rWriter
.startElement("rectangle");
1087 writeRectangle(rWriter
, pMeta
->GetRect());
1088 rWriter
.endElement();
1090 rWriter
.endElement();
1094 case MetaActionType::HATCH
:
1096 auto* const pMetaHatchAction
= static_cast<MetaHatchAction
*>(pAction
);
1097 rWriter
.startElement(sCurrentElementTag
);
1099 tools::PolyPolygon
const& rPolyPolygon(pMetaHatchAction
->GetPolyPolygon());
1101 for (sal_uInt16 j
= 0; j
< rPolyPolygon
.Count(); ++j
)
1103 rWriter
.startElement("polygon");
1104 tools::Polygon
const& rPolygon
= rPolyPolygon
[j
];
1105 bool bFlags
= rPolygon
.HasFlags();
1106 for (sal_uInt16 i
= 0; i
< rPolygon
.GetSize(); ++i
)
1108 rWriter
.startElement("point");
1109 writePoint(rWriter
, rPolygon
[i
]);
1111 rWriter
.attribute("flags", convertPolygonFlags(rPolygon
.GetFlags(i
)));
1112 rWriter
.endElement();
1114 rWriter
.endElement();
1117 rWriter
.startElement("hatch");
1118 const auto& rHatch
= pMetaHatchAction
->GetHatch();
1119 rWriter
.attribute("style", convertHatchStyle(rHatch
.GetStyle()));
1120 rWriter
.attribute("color", convertColorToString(rHatch
.GetColor()));
1121 rWriter
.attribute("distance", sal_Int32(rHatch
.GetDistance()));
1122 rWriter
.attribute("angle", sal_Int32(rHatch
.GetAngle().get()));
1123 rWriter
.endElement();
1125 rWriter
.endElement();
1129 case MetaActionType::WALLPAPER
:
1131 const auto* pMetaAction
= static_cast<const MetaWallpaperAction
*>(pAction
);
1132 rWriter
.startElement(sCurrentElementTag
);
1134 writeRectangle(rWriter
, pMetaAction
->GetRect());
1136 rWriter
.startElement("wallpaper");
1137 const auto& rWallpaper
= pMetaAction
->GetWallpaper();
1139 rWriter
.attribute("color", convertColorToString(rWallpaper
.GetColor()));
1141 WallpaperStyle eStyle
= rWallpaper
.GetStyle();
1142 rWriter
.attribute("style", convertWallpaperStyleToString(eStyle
));
1144 if (rWallpaper
.IsBitmap())
1146 rWriter
.startElement("bitmap");
1147 BitmapEx
const & rBitmapEx
= rWallpaper
.GetBitmap();
1148 rWriter
.attribute("crc", hex32(rBitmapEx
.GetChecksum()));
1149 rWriter
.attribute("transparenttype", convertBitmapExTransparentType(rBitmapEx
));
1150 rWriter
.attribute("pixelformat", convertPixelFormatToString(rBitmapEx
.GetBitmap().getPixelFormat()));
1151 rWriter
.attribute("width", hex32(rBitmapEx
.GetSizePixel().Width()));
1152 rWriter
.attribute("height", hex32(rBitmapEx
.GetSizePixel().Height()));
1153 rWriter
.endElement();
1156 if (rWallpaper
.IsGradient())
1158 rWriter
.startElement("gradient");
1159 Gradient aGradient
= rWallpaper
.GetGradient();
1160 writeGradient(rWriter
, aGradient
);
1161 rWriter
.endElement();
1164 if (rWallpaper
.IsRect())
1166 tools::Rectangle aRect
= rWallpaper
.GetRect();
1167 rWriter
.startElement("rectangle");
1168 writeRectangle(rWriter
, aRect
);
1169 rWriter
.endElement();
1172 rWriter
.attribute("fixed", rWallpaper
.IsFixed() ? "true" : "false");
1173 rWriter
.attribute("scrollable", rWallpaper
.IsScrollable() ? "true" : "false");
1175 rWriter
.endElement();
1177 rWriter
.endElement();
1181 case MetaActionType::CLIPREGION
:
1183 const auto* pMetaClipRegionAction
= static_cast<const MetaClipRegionAction
*>(pAction
);
1184 rWriter
.startElement(sCurrentElementTag
);
1186 tools::Rectangle aRectangle
= pMetaClipRegionAction
->GetRegion().GetBoundRect();
1187 writeRectangle(rWriter
, aRectangle
);
1189 vcl::Region aRegion
= pMetaClipRegionAction
->GetRegion();
1191 if (aRegion
.HasPolyPolygonOrB2DPolyPolygon())
1193 tools::PolyPolygon aPolyPolygon
= aRegion
.GetAsPolyPolygon();
1195 for (sal_uInt16 j
= 0; j
< aPolyPolygon
.Count(); ++j
)
1197 rWriter
.startElement("polygon");
1198 tools::Polygon
const& rPolygon
= aPolyPolygon
[j
];
1199 bool bFlags
= rPolygon
.HasFlags();
1200 for (sal_uInt16 i
= 0; i
< rPolygon
.GetSize(); ++i
)
1202 rWriter
.startElement("point");
1203 writePoint(rWriter
, rPolygon
[i
]);
1205 rWriter
.attribute("flags", convertPolygonFlags(rPolygon
.GetFlags(i
)));
1206 rWriter
.endElement();
1208 rWriter
.endElement();
1212 rWriter
.endElement();
1216 case MetaActionType::ISECTRECTCLIPREGION
:
1218 MetaISectRectClipRegionAction
* pMetaISectRectClipRegionAction
= static_cast<MetaISectRectClipRegionAction
*>(pAction
);
1219 rWriter
.startElement(sCurrentElementTag
);
1221 tools::Rectangle aRectangle
= pMetaISectRectClipRegionAction
->GetRect();
1222 writeRectangle(rWriter
, aRectangle
);
1223 rWriter
.endElement();
1227 case MetaActionType::ISECTREGIONCLIPREGION
:
1229 MetaISectRegionClipRegionAction
* pMetaISectRegionClipRegionAction
= static_cast<MetaISectRegionClipRegionAction
*>(pAction
);
1230 rWriter
.startElement(sCurrentElementTag
);
1232 // FIXME for now we dump only the bounding box; this is
1233 // enough for the tests we have, but may need extending to
1234 // dumping the real polypolygon in the future
1235 tools::Rectangle aRectangle
= pMetaISectRegionClipRegionAction
->GetRegion().GetBoundRect();
1236 writeRectangle(rWriter
, aRectangle
);
1237 rWriter
.endElement();
1241 case MetaActionType::MOVECLIPREGION
:
1243 const auto* pMetaMoveClipRegionAction
= static_cast<MetaMoveClipRegionAction
*>(pAction
);
1244 rWriter
.startElement(sCurrentElementTag
);
1246 rWriter
.attribute("horzmove", pMetaMoveClipRegionAction
->GetHorzMove());
1247 rWriter
.attribute("vertmove", pMetaMoveClipRegionAction
->GetVertMove());
1248 rWriter
.endElement();
1252 case MetaActionType::LINECOLOR
:
1254 MetaLineColorAction
* pMetaLineColorAction
= static_cast<MetaLineColorAction
*>(pAction
);
1255 rWriter
.startElement(sCurrentElementTag
);
1257 rWriter
.attribute("color", convertColorToString(pMetaLineColorAction
->GetColor()));
1258 rWriter
.endElement();
1262 case MetaActionType::FILLCOLOR
:
1264 MetaFillColorAction
* pMetaFillColorAction
= static_cast<MetaFillColorAction
*>(pAction
);
1265 rWriter
.startElement(sCurrentElementTag
);
1267 rWriter
.attribute("color", convertColorToString(pMetaFillColorAction
->GetColor()));
1268 rWriter
.endElement();
1272 case MetaActionType::TEXTCOLOR
:
1274 MetaTextColorAction
* pMetaTextColorAction
= static_cast<MetaTextColorAction
*>(pAction
);
1275 rWriter
.startElement(sCurrentElementTag
);
1277 rWriter
.attribute("color", convertColorToString(pMetaTextColorAction
->GetColor()));
1278 rWriter
.endElement();
1282 case MetaActionType::TEXTFILLCOLOR
:
1284 MetaTextFillColorAction
* pMetaTextFillColorAction
= static_cast<MetaTextFillColorAction
*>(pAction
);
1285 rWriter
.startElement(sCurrentElementTag
);
1287 rWriter
.attribute("color", convertColorToString(pMetaTextFillColorAction
->GetColor()));
1289 if (pMetaTextFillColorAction
->IsSetting())
1290 rWriter
.attribute("setting", u
"true");
1292 rWriter
.endElement();
1296 case MetaActionType::TEXTALIGN
:
1298 MetaTextAlignAction
* pMetaTextAlignAction
= static_cast<MetaTextAlignAction
*>(pAction
);
1299 rWriter
.startElement(sCurrentElementTag
);
1300 OUString sAlign
= convertTextAlignToString(pMetaTextAlignAction
->GetTextAlign());
1301 if (!sAlign
.isEmpty())
1302 rWriter
.attribute("align", sAlign
);
1303 rWriter
.endElement();
1307 case MetaActionType::MAPMODE
:
1309 const MetaMapModeAction
* pMeta
= static_cast<MetaMapModeAction
*>(pAction
);
1310 MapMode aMapMode
= pMeta
->GetMapMode();
1311 rWriter
.startElement(sCurrentElementTag
);
1312 rWriter
.attribute("mapunit", convertMapUnitToString( aMapMode
.GetMapUnit() ));
1313 writePoint(rWriter
, aMapMode
.GetOrigin());
1314 rWriter
.attribute("scalex", convertFractionToString(aMapMode
.GetScaleX()));
1315 rWriter
.attribute("scaley", convertFractionToString(aMapMode
.GetScaleY()));
1316 rWriter
.endElement();
1320 case MetaActionType::FONT
:
1322 MetaFontAction
* pMetaFontAction
= static_cast<MetaFontAction
*>(pAction
);
1323 rWriter
.startElement(sCurrentElementTag
);
1325 vcl::Font aFont
= pMetaFontAction
->GetFont();
1327 rWriter
.attribute("color", convertColorToString(aFont
.GetColor()));
1328 rWriter
.attribute("fillcolor", convertColorToString(aFont
.GetFillColor()));
1329 rWriter
.attribute("name", aFont
.GetFamilyName());
1330 rWriter
.attribute("stylename", aFont
.GetStyleName());
1331 rWriter
.attribute("width", aFont
.GetFontSize().Width());
1332 rWriter
.attribute("height", aFont
.GetFontSize().Height());
1333 rWriter
.attribute("orientation", aFont
.GetOrientation().get());
1334 rWriter
.attribute("weight", convertFontWeightToString(aFont
.GetWeight()));
1335 rWriter
.attribute("vertical", aFont
.IsVertical() ? "true" : "false");
1336 rWriter
.attribute("emphasis", aFont
.GetEmphasisMark() != FontEmphasisMark::NONE
? "true" : "false");
1337 rWriter
.attribute("shadow", aFont
.IsShadow() ? "true" : "false");
1338 rWriter
.attribute("wordunderline", aFont
.IsWordLineMode() ? "true" : "false");
1339 rWriter
.attribute("outline", aFont
.IsOutline() ? "true" : "false");
1341 rWriter
.endElement();
1345 case MetaActionType::PUSH
:
1347 MetaPushAction
* pMetaPushAction
= static_cast<MetaPushAction
*>(pAction
);
1348 rWriter
.startElement(sCurrentElementTag
);
1350 rWriter
.attribute("flags", collectPushFlags(pMetaPushAction
->GetFlags()));
1354 case MetaActionType::POP
:
1356 rWriter
.endElement();
1360 case MetaActionType::RASTEROP
:
1362 MetaRasterOpAction
* pMetaRasterOpAction
= static_cast<MetaRasterOpAction
*>(pAction
);
1363 rWriter
.startElement(sCurrentElementTag
);
1365 if (pMetaRasterOpAction
->GetRasterOp() != RasterOp::OverPaint
)
1367 rWriter
.attribute("operation", convertRopToString(pMetaRasterOpAction
->GetRasterOp()));
1369 rWriter
.endElement();
1373 case MetaActionType::Transparent
:
1375 const MetaTransparentAction
* pMeta
= static_cast<MetaTransparentAction
*>(pAction
);
1377 rWriter
.startElement(sCurrentElementTag
);
1378 rWriter
.attribute("transparence", pMeta
->GetTransparence());
1380 tools::PolyPolygon
const& rPolyPolygon(pMeta
->GetPolyPolygon());
1382 for (sal_uInt16 j
= 0; j
< rPolyPolygon
.Count(); ++j
)
1384 rWriter
.startElement("polygon");
1385 tools::Polygon
const& rPolygon
= rPolyPolygon
[j
];
1386 bool bFlags
= rPolygon
.HasFlags();
1387 for (sal_uInt16 i
= 0; i
< rPolygon
.GetSize(); ++i
)
1389 rWriter
.startElement("point");
1390 writePoint(rWriter
, rPolygon
[i
]);
1392 rWriter
.attribute("flags", convertPolygonFlags(rPolygon
.GetFlags(i
)));
1393 rWriter
.endElement();
1395 rWriter
.endElement();
1398 rWriter
.endElement();
1402 case MetaActionType::EPS
:
1404 MetaEPSAction
* pMetaEPSAction
= static_cast<MetaEPSAction
*>(pAction
);
1405 rWriter
.startElement(sCurrentElementTag
);
1407 writePoint(rWriter
, pMetaEPSAction
->GetPoint());
1408 writeSize(rWriter
, pMetaEPSAction
->GetSize());
1410 rWriter
.startElement("gfxlink");
1411 writeSize(rWriter
, pMetaEPSAction
->GetLink().GetPrefSize());
1412 rWriter
.attribute("type", convertGfxLinkTypeToString(pMetaEPSAction
->GetLink().GetType()));
1413 rWriter
.attribute("userid", pMetaEPSAction
->GetLink().GetUserId());
1414 rWriter
.attribute("datasize", pMetaEPSAction
->GetLink().GetDataSize());
1415 rWriter
.attribute("data", toHexString(pMetaEPSAction
->GetLink().GetData(), pMetaEPSAction
->GetLink().GetDataSize()));
1416 rWriter
.attribute("native", pMetaEPSAction
->GetLink().IsNative() ? "true" : "false");
1417 rWriter
.attribute("emf", pMetaEPSAction
->GetLink().IsEMF() ? "true" : "false");
1418 rWriter
.attribute("validmapmode", pMetaEPSAction
->GetLink().IsPrefMapModeValid() ? "true" : "false");
1419 rWriter
.startElement("prefmapmode");
1420 writeMapMode(rWriter
, pMetaEPSAction
->GetLink().GetPrefMapMode());
1421 rWriter
.endElement();
1422 rWriter
.endElement();
1424 rWriter
.startElement("metafile");
1425 writeXml(pMetaEPSAction
->GetSubstitute(), rWriter
);
1426 rWriter
.endElement();
1428 rWriter
.endElement();
1432 case MetaActionType::REFPOINT
:
1434 auto* pMeta
= static_cast<MetaRefPointAction
*>(pAction
);
1435 rWriter
.startElement(sCurrentElementTag
);
1436 writePoint(rWriter
, pMeta
->GetRefPoint());
1437 rWriter
.attribute("set", pMeta
->IsSetting() ? "true" : "false");
1438 rWriter
.endElement();
1442 case MetaActionType::TEXTLINECOLOR
:
1444 auto* pMeta
= static_cast<MetaTextLineColorAction
*>(pAction
);
1445 rWriter
.startElement(sCurrentElementTag
);
1446 rWriter
.attribute("color", convertColorToString(pMeta
->GetColor()));
1447 rWriter
.endElement();
1451 case MetaActionType::TEXTLINE
:
1453 auto* pMeta
= static_cast<MetaTextLineAction
*>(pAction
);
1454 rWriter
.startElement(sCurrentElementTag
);
1455 writePoint(rWriter
, pMeta
->GetStartPoint());
1456 rWriter
.attribute("width", pMeta
->GetWidth());
1457 rWriter
.attribute("strikeout", convertFontStrikeoutToString(pMeta
->GetStrikeout()));
1458 rWriter
.attribute("underline", convertFontLineStyleToString(pMeta
->GetUnderline()));
1459 rWriter
.attribute("overline", convertFontLineStyleToString(pMeta
->GetOverline()));
1460 rWriter
.endElement();
1464 case MetaActionType::FLOATTRANSPARENT
:
1466 const auto* pMeta
= static_cast<MetaFloatTransparentAction
*>(pAction
);
1467 rWriter
.startElement(sCurrentElementTag
);
1468 writePoint(rWriter
, pMeta
->GetPoint());
1469 writeSize(rWriter
, pMeta
->GetSize());
1470 rWriter
.attribute("transparent", pMeta
->IsTransparent() ? "true" : "false");
1472 rWriter
.startElement("gradient");
1473 writeGradient(rWriter
, pMeta
->GetGradient());
1474 rWriter
.endElement();
1476 rWriter
.startElement("metafile");
1477 writeXml(pMeta
->GetGDIMetaFile(), rWriter
);
1478 rWriter
.endElement();
1480 rWriter
.endElement();
1484 case MetaActionType::GRADIENTEX
:
1486 const MetaGradientExAction
* pMetaGradientExAction
= static_cast<MetaGradientExAction
*>(pAction
);
1488 rWriter
.startElement(sCurrentElementTag
);
1489 writeGradient(rWriter
, pMetaGradientExAction
->GetGradient());
1491 tools::PolyPolygon
const& rPolyPolygon(pMetaGradientExAction
->GetPolyPolygon());
1492 for (sal_uInt16 j
= 0; j
< rPolyPolygon
.Count(); ++j
)
1494 rWriter
.startElement("polygon");
1495 tools::Polygon
const& rPolygon
= rPolyPolygon
[j
];
1496 bool bFlags
= rPolygon
.HasFlags();
1497 for (sal_uInt16 i
= 0; i
< rPolygon
.GetSize(); ++i
)
1499 rWriter
.startElement("point");
1500 writePoint(rWriter
, rPolygon
[i
]);
1502 rWriter
.attribute("flags", convertPolygonFlags(rPolygon
.GetFlags(i
)));
1503 rWriter
.endElement();
1505 rWriter
.endElement();
1508 rWriter
.endElement();
1512 case MetaActionType::LAYOUTMODE
:
1514 const MetaLayoutModeAction
* pMetaLayoutModeAction
= static_cast<MetaLayoutModeAction
*>(pAction
);
1516 rWriter
.startElement(sCurrentElementTag
);
1518 rWriter
.attribute("textlayout", convertComplexTestLayoutFlags(pMetaLayoutModeAction
->GetLayoutMode()));
1520 rWriter
.endElement();
1524 case MetaActionType::TEXTLANGUAGE
:
1526 const MetaTextLanguageAction
* pMetaTextLanguageAction
= static_cast<MetaTextLanguageAction
*>(pAction
);
1528 rWriter
.startElement(sCurrentElementTag
);
1530 rWriter
.attribute("language", convertLanguageTypeToString(pMetaTextLanguageAction
->GetTextLanguage()));
1532 rWriter
.endElement();
1536 case MetaActionType::OVERLINECOLOR
:
1538 const auto* pMetaAction
= static_cast<MetaOverlineColorAction
*>(pAction
);
1539 rWriter
.startElement(sCurrentElementTag
);
1540 rWriter
.attribute("color", convertColorToString(pMetaAction
->GetColor()));
1541 rWriter
.endElement();
1545 case MetaActionType::COMMENT
:
1547 MetaCommentAction
* pMetaCommentAction
= static_cast<MetaCommentAction
*>(pAction
);
1548 rWriter
.startElement(sCurrentElementTag
);
1550 if (pMetaCommentAction
->GetDataSize() > 0)
1552 rWriter
.attribute("datasize", pMetaCommentAction
->GetDataSize());
1553 rWriter
.attribute("data", toHexString(pMetaCommentAction
->GetData(), pMetaCommentAction
->GetDataSize()));
1555 rWriter
.attribute("value", pMetaCommentAction
->GetValue());
1557 if (!pMetaCommentAction
->GetComment().isEmpty())
1559 rWriter
.startElement("comment");
1560 rWriter
.content(pMetaCommentAction
->GetComment());
1561 rWriter
.endElement();
1563 rWriter
.endElement();
1569 rWriter
.startElement(sCurrentElementTag
);
1570 rWriter
.attribute("note", "not implemented in xml dump"_ostr
);
1571 rWriter
.endElement();
1578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */