LibreOffice Module vcl (master) 1
mtfxmldump.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include <vcl/mtfxmldump.hxx>
11#include <tools/XmlWriter.hxx>
12#include <tools/fract.hxx>
13
14#include <vcl/metaact.hxx>
15#include <vcl/outdev.hxx>
16#include <vcl/bitmap.hxx>
18
19#include <rtl/string.hxx>
20#include <rtl/ustrbuf.hxx>
21
22#include <comphelper/hash.hxx>
23
24#include <sstream>
25
26namespace
27{
28
29OUString collectPushFlags(vcl::PushFlags nFlags)
30{
32 return "PushAll";
33 else if ((nFlags & PUSH_ALLFONT) == PUSH_ALLFONT)
34 return "PushAllFont";
35
36 std::vector<OUString> aStrings;
37
38 if (nFlags & vcl::PushFlags::LINECOLOR)
39 aStrings.emplace_back("PushLineColor");
40 if (nFlags & vcl::PushFlags::FILLCOLOR)
41 aStrings.emplace_back("PushFillColor");
42 if (nFlags & vcl::PushFlags::FONT)
43 aStrings.emplace_back("PushFont");
44 if (nFlags & vcl::PushFlags::TEXTCOLOR)
45 aStrings.emplace_back("PushTextColor");
46 if (nFlags & vcl::PushFlags::MAPMODE)
47 aStrings.emplace_back("PushMapMode");
48 if (nFlags & vcl::PushFlags::CLIPREGION)
49 aStrings.emplace_back("PushClipRegion");
50 if (nFlags & vcl::PushFlags::RASTEROP)
51 aStrings.emplace_back("PushRasterOp");
53 aStrings.emplace_back("PushTextFillColor");
54 if (nFlags & vcl::PushFlags::TEXTALIGN)
55 aStrings.emplace_back("PushTextAlign");
56 if (nFlags & vcl::PushFlags::REFPOINT)
57 aStrings.emplace_back("PushRefPoint");
59 aStrings.emplace_back("PushTextLineColor");
61 aStrings.emplace_back("PushTextLayoutMode");
63 aStrings.emplace_back("PushTextLanguage");
65 aStrings.emplace_back("PushOverlineColor");
66
67 OUString aString;
68
69 if (aStrings.empty())
70 return aString;
71
72 aString = aStrings[0];
73 for (size_t i = 1; i < aStrings.size(); ++i)
74 {
75 aString += ", " + aStrings[i];
76 }
77 return aString;
78}
79
80OUString convertDrawTextFlagsToString(DrawTextFlags eDrawTextFlags)
81{
82 std::vector<OUString> aStrings;
83 if (eDrawTextFlags & DrawTextFlags::Disable)
84 aStrings.emplace_back("Disable");
85 if (eDrawTextFlags & DrawTextFlags::Mnemonic)
86 aStrings.emplace_back("Mnemonic");
87 if (eDrawTextFlags & DrawTextFlags::Mono)
88 aStrings.emplace_back("Mono");
89 if (eDrawTextFlags & DrawTextFlags::Clip)
90 aStrings.emplace_back("Clip");
91 if (eDrawTextFlags & DrawTextFlags::Left)
92 aStrings.emplace_back("Left");
93 if (eDrawTextFlags & DrawTextFlags::Center)
94 aStrings.emplace_back("Center");
95 if (eDrawTextFlags & DrawTextFlags::Right)
96 aStrings.emplace_back("Right");
97 if (eDrawTextFlags & DrawTextFlags::Top)
98 aStrings.emplace_back("Top");
99 if (eDrawTextFlags & DrawTextFlags::VCenter)
100 aStrings.emplace_back("VCenter");
101 if (eDrawTextFlags & DrawTextFlags::Bottom)
102 aStrings.emplace_back("Bottom");
103 if (eDrawTextFlags & DrawTextFlags::EndEllipsis)
104 aStrings.emplace_back("EndEllipsis");
105 if (eDrawTextFlags & DrawTextFlags::PathEllipsis)
106 aStrings.emplace_back("PathEllipsis");
107 if (eDrawTextFlags & DrawTextFlags::MultiLine)
108 aStrings.emplace_back("MultiLine");
109 if (eDrawTextFlags & DrawTextFlags::WordBreak)
110 aStrings.emplace_back("WordBreak");
111 if (eDrawTextFlags & DrawTextFlags::NewsEllipsis)
112 aStrings.emplace_back("NewsEllipsis");
113 if (eDrawTextFlags & DrawTextFlags::WordBreakHyphenation)
114 aStrings.emplace_back("WordBreakHyphenation");
115 if (eDrawTextFlags & DrawTextFlags::CenterEllipsis)
116 aStrings.emplace_back("CenterEllipsis");
117
118 OUString aString;
119
120 if (aStrings.empty())
121 return "None";
122
123 aString = aStrings[0];
124 for (size_t i = 1; i < aStrings.size(); ++i)
125 {
126 aString += " " + aStrings[i];
127 }
128 return aString;
129};
130
131OUString convertRopToString(RasterOp eRop)
132{
133 switch (eRop)
134 {
135 case RasterOp::OverPaint: return "overpaint";
136 case RasterOp::Xor: return "xor";
137 case RasterOp::N0: return "0";
138 case RasterOp::N1: return "1";
139 case RasterOp::Invert: return "invert";
140 }
141 return OUString();
142}
143
144OUString convertTextAlignToString(TextAlign eAlign)
145{
146 switch (eAlign)
147 {
148 case ALIGN_BASELINE: return "baseline";
149 case ALIGN_BOTTOM: return "bottom";
150 case ALIGN_TOP: return "top";
151 case TextAlign_FORCE_EQUAL_SIZE: return "equalsize";
152 }
153 return OUString();
154}
155
156OUString convertColorToString(Color aColor)
157{
158 OUString aRGBString = aColor.AsRGBHexString();
159 return "#" + aRGBString;
160}
161
162OUString convertLineStyleToString(LineStyle eAlign)
163{
164 switch (eAlign)
165 {
166 case LineStyle::NONE: return "none";
167 case LineStyle::Solid: return "solid";
168 case LineStyle::Dash: return "dash";
169 default: break;
170 }
171 return OUString();
172}
173
174OUString convertLineJoinToString(basegfx::B2DLineJoin eJoin)
175{
176 switch (eJoin)
177 {
178 default:
179 case basegfx::B2DLineJoin::NONE: return "none";
180 case basegfx::B2DLineJoin::Bevel: return "bevel";
181 case basegfx::B2DLineJoin::Miter: return "miter";
182 case basegfx::B2DLineJoin::Round: return "round";
183 }
184}
185
186OUString convertLineCapToString(css::drawing::LineCap eCap)
187{
188 switch (eCap)
189 {
190 default:
191 case css::drawing::LineCap_BUTT: return "butt";
192 case css::drawing::LineCap_ROUND: return "round";
193 case css::drawing::LineCap_SQUARE: return "square";
194 }
195}
196
197OUString convertPolygonFlags(PolyFlags eFlags)
198{
199 switch (eFlags)
200 {
201 default:
202 case PolyFlags::Normal: return "normal";
203 case PolyFlags::Control: return "control";
204 case PolyFlags::Smooth: return "smooth";
205 case PolyFlags::Symmetric: return "symmetric";
206 }
207}
208
209OUString convertFontWeightToString(FontWeight eFontWeight)
210{
211 switch (eFontWeight)
212 {
213 case WEIGHT_DONTKNOW: return "unknown";
214 case WEIGHT_THIN: return "thin";
215 case WEIGHT_ULTRALIGHT: return "ultralight";
216 case WEIGHT_LIGHT: return "light";
217 case WEIGHT_SEMILIGHT: return "semilight";
218 case WEIGHT_NORMAL: return "normal";
219 case WEIGHT_MEDIUM: return "medium";
220 case WEIGHT_SEMIBOLD: return "semibold";
221 case WEIGHT_BOLD: return "bold";
222 case WEIGHT_ULTRABOLD: return "ultrabold";
223 case WEIGHT_BLACK: return "black";
224 case FontWeight_FORCE_EQUAL_SIZE: return "equalsize";
225 }
226 return OUString();
227}
228
229OUString convertFontStrikeoutToString(FontStrikeout eFontStrikeout)
230{
231 switch (eFontStrikeout)
232 {
233 case STRIKEOUT_NONE: return "none";
234 case STRIKEOUT_SINGLE: return "single";
235 case STRIKEOUT_DOUBLE: return "double";
236 case STRIKEOUT_DONTKNOW: return "dontknow";
237 case STRIKEOUT_BOLD: return "bold";
238 case STRIKEOUT_SLASH: return "slash";
239 case STRIKEOUT_X: return "x";
240 case FontStrikeout_FORCE_EQUAL_SIZE: return "equalsize";
241 }
242 return OUString();
243}
244
245OUString convertFontLineStyleToString(FontLineStyle eFontLineStyle)
246{
247 switch (eFontLineStyle)
248 {
249 case LINESTYLE_NONE: return "none";
250 case LINESTYLE_SINGLE: return "single";
251 case LINESTYLE_DOUBLE: return "double";
252 case LINESTYLE_DOTTED: return "dotted";
253 case LINESTYLE_DONTKNOW: return "dontknow";
254 case LINESTYLE_DASH: return "dash";
255 case LINESTYLE_LONGDASH: return "longdash";
256 case LINESTYLE_DASHDOT: return "dashdot";
257 case LINESTYLE_DASHDOTDOT: return "dashdotdot";
258 case LINESTYLE_SMALLWAVE: return "smallwave";
259 case LINESTYLE_WAVE: return "wave";
260 case LINESTYLE_DOUBLEWAVE: return "doublewave";
261 case LINESTYLE_BOLD: return "bold";
262 case LINESTYLE_BOLDDOTTED: return "bolddotted";
263 case LINESTYLE_BOLDDASH: return "bolddash";
264 case LINESTYLE_BOLDLONGDASH: return "boldlongdash";
265 case LINESTYLE_BOLDDASHDOT: return "bolddashdot";
266 case LINESTYLE_BOLDDASHDOTDOT: return "bolddashdotdot";
267 case LINESTYLE_BOLDWAVE: return "boldwave";
268 case FontLineStyle_FORCE_EQUAL_SIZE: return "equalsize";
269 }
270 return OUString();
271}
272
273OString convertLineStyleToString(const MetaActionType nActionType)
274{
275 switch (nActionType)
276 {
277 case MetaActionType::NONE: return "null";
278 case MetaActionType::PIXEL: return "pixel";
279 case MetaActionType::POINT: return "point";
280 case MetaActionType::LINE: return "line";
281 case MetaActionType::RECT: return "rect";
282 case MetaActionType::ROUNDRECT: return "roundrect";
283 case MetaActionType::ELLIPSE: return "ellipse";
284 case MetaActionType::ARC: return "arc";
285 case MetaActionType::PIE: return "pie";
286 case MetaActionType::CHORD: return "chord";
287 case MetaActionType::POLYLINE: return "polyline";
288 case MetaActionType::POLYGON: return "polygon";
289 case MetaActionType::POLYPOLYGON: return "polypolygon";
290 case MetaActionType::TEXT: return "text";
291 case MetaActionType::TEXTARRAY: return "textarray";
292 case MetaActionType::STRETCHTEXT: return "stretchtext";
293 case MetaActionType::TEXTRECT: return "textrect";
294 case MetaActionType::TEXTLINE: return "textline";
295 case MetaActionType::BMP: return "bmp";
296 case MetaActionType::BMPSCALE: return "bmpscale";
297 case MetaActionType::BMPSCALEPART: return "bmpscalepart";
298 case MetaActionType::BMPEX: return "bmpex";
299 case MetaActionType::BMPEXSCALE: return "bmpexscale";
300 case MetaActionType::BMPEXSCALEPART: return "bmpexscalepart";
301 case MetaActionType::MASK: return "mask";
302 case MetaActionType::MASKSCALE: return "maskscale";
303 case MetaActionType::MASKSCALEPART: return "maskscalepart";
304 case MetaActionType::GRADIENT: return "gradient";
305 case MetaActionType::GRADIENTEX: return "gradientex";
306 case MetaActionType::HATCH: return "hatch";
307 case MetaActionType::WALLPAPER: return "wallpaper";
308 case MetaActionType::CLIPREGION: return "clipregion";
309 case MetaActionType::ISECTRECTCLIPREGION: return "sectrectclipregion";
310 case MetaActionType::ISECTREGIONCLIPREGION: return "sectregionclipregion";
311 case MetaActionType::MOVECLIPREGION: return "moveclipregion";
312 case MetaActionType::LINECOLOR: return "linecolor";
313 case MetaActionType::FILLCOLOR: return "fillcolor";
314 case MetaActionType::TEXTCOLOR: return "textcolor";
315 case MetaActionType::TEXTFILLCOLOR: return "textfillcolor";
316 case MetaActionType::TEXTLINECOLOR: return "textlinecolor";
317 case MetaActionType::OVERLINECOLOR: return "overlinecolor";
318 case MetaActionType::TEXTALIGN: return "textalign";
319 case MetaActionType::MAPMODE: return "mapmode";
320 case MetaActionType::FONT: return "font";
321 case MetaActionType::PUSH: return "push";
322 case MetaActionType::POP: return "pop";
323 case MetaActionType::RASTEROP: return "rasterop";
324 case MetaActionType::Transparent: return "transparent";
325 case MetaActionType::FLOATTRANSPARENT: return "floattransparent";
326 case MetaActionType::EPS: return "eps";
327 case MetaActionType::REFPOINT: return "refpoint";
328 case MetaActionType::COMMENT: return "comment";
329 case MetaActionType::LAYOUTMODE: return "layoutmode";
330 case MetaActionType::TEXTLANGUAGE: return "textlanguage";
331 }
332 return "";
333}
334
335OUString convertBitmapExTransparentType(BitmapEx const & rBitmapEx)
336{
337 if (rBitmapEx.IsAlpha())
338 return "bitmap";
339 else
340 return "none";
341}
342
343OUString convertMapUnitToString(MapUnit eUnit)
344{
345 switch (eUnit)
346 {
347 default:
348 case MapUnit::LASTENUMDUMMY: return "LASTENUMDUMMY";
349 case MapUnit::Map1000thInch: return "Map1000thInch";
350 case MapUnit::Map100thInch: return "Map100thInch";
351 case MapUnit::Map100thMM: return "Map100thMM";
352 case MapUnit::Map10thInch: return "Map10thInch";
353 case MapUnit::Map10thMM: return "Map10thMM";
354 case MapUnit::MapAppFont: return "MapAppFont";
355 case MapUnit::MapCM: return "MapCM";
356 case MapUnit::MapInch: return "MapInch";
357 case MapUnit::MapMM: return "MapMM";
358 case MapUnit::MapPixel: return "MapPixel";
359 case MapUnit::MapPoint: return "MapPoint";
360 case MapUnit::MapRelative: return "MapRelative";
361 case MapUnit::MapSysFont: return "MapSysFont";
362 case MapUnit::MapTwip: return "MapTwip";
363 }
364}
365
366OUString convertFractionToString(const Fraction& aFraction)
367{
368 std::stringstream ss;
369
370 ss << aFraction;
371
372 return OUString::createFromAscii(ss.str());
373}
374
375OUString convertGradientStyleToOUString(css::awt::GradientStyle eStyle)
376{
377 switch (eStyle)
378 {
379 case css::awt::GradientStyle_LINEAR: return "Linear";
380 case css::awt::GradientStyle_AXIAL: return "Axial";
381 case css::awt::GradientStyle_RADIAL: return "Radial";
382 case css::awt::GradientStyle_ELLIPTICAL: return "Elliptical";
383 case css::awt::GradientStyle_SQUARE: return "Square";
384 case css::awt::GradientStyle_RECT: return "Rect";
385 case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE: return "ForceEqualSize";
386 }
387 return OUString();
388}
389
390OUString convertHatchStyle(HatchStyle eStyle)
391{
392 switch (eStyle)
393 {
394 case HatchStyle::Single: return "Single";
395 case HatchStyle::Double: return "Double";
396 case HatchStyle::Triple: return "Triple";
397 case HatchStyle::FORCE_EQUAL_SIZE: return "ForceEqualSize";
398 }
399 return OUString();
400}
401
402OUString convertLanguageTypeToString(LanguageType rLanguageType)
403{
404 std::stringstream ss;
405 ss << std::hex << std::setfill ('0') << std::setw(4) << rLanguageType.get();
406 return "#" + OUString::createFromAscii(ss.str());
407}
408
409OUString convertWallpaperStyleToString(WallpaperStyle eWallpaperStyle)
410{
411 switch (eWallpaperStyle)
412 {
413 case WallpaperStyle::NONE: return "NONE";
414 case WallpaperStyle::Tile: return "Tile";
415 case WallpaperStyle::Center: return "Center";
416 case WallpaperStyle::Scale: return "Scale";
417 case WallpaperStyle::TopLeft: return "TopLeft";
418 case WallpaperStyle::Top: return "Top";
419 case WallpaperStyle::TopRight: return "TopRight";
420 case WallpaperStyle::Left: return "Left";
421 case WallpaperStyle::Right: return "Right";
422 case WallpaperStyle::BottomLeft: return "BottomLeft";
423 case WallpaperStyle::Bottom: return "Bottom";
424 case WallpaperStyle::BottomRight: return "BottomRight";
425 case WallpaperStyle::ApplicationGradient: return "ApplicationGradient";
426 }
427 return OUString();
428}
429
430OUString convertPixelFormatToString(vcl::PixelFormat ePixelFormat)
431{
432 switch (ePixelFormat)
433 {
434 case vcl::PixelFormat::INVALID: return "INVALID";
435 case vcl::PixelFormat::N8_BPP: return "8BPP";
436 case vcl::PixelFormat::N24_BPP: return "24BPP";
437 case vcl::PixelFormat::N32_BPP: return "32BPP";
438 }
439 return OUString();
440}
441
442OUString convertComplexTestLayoutFlags(vcl::text::ComplexTextLayoutFlags eComplexTestLayoutFlags)
443{
444 switch(eComplexTestLayoutFlags)
445 {
446 default:
452 }
453}
454
455OUString convertGfxLinkTypeToString(GfxLinkType eGfxLinkType)
456{
457 switch(eGfxLinkType)
458 {
459 case GfxLinkType::EpsBuffer: return "EpsBuffer";
460 case GfxLinkType::NativeBmp: return "NativeBmp";
461 case GfxLinkType::NativeGif: return "NativeGif";
462 case GfxLinkType::NativeJpg: return "NativeJpg";
463 case GfxLinkType::NativeMet: return "NativeMet";
464 case GfxLinkType::NativeMov: return "NativeMov";
465 case GfxLinkType::NativePct: return "NativePct";
466 case GfxLinkType::NativePdf: return "NativePdf";
467 case GfxLinkType::NativePng: return "NativePng";
468 case GfxLinkType::NativeSvg: return "NativeSvg";
469 case GfxLinkType::NativeTif: return "NativeTif";
470 case GfxLinkType::NativeWmf: return "NativeWmf";
471 case GfxLinkType::NativeWebp: return "NativeWebp";
472 case GfxLinkType::NONE: return "None";
473 }
474 return OUString();
475}
476
477OUString hex32(sal_uInt32 nNumber)
478{
479 std::stringstream ss;
480 ss << std::hex << std::setfill('0') << std::setw(8) << nNumber;
481 return OUString::createFromAscii(ss.str());
482}
483
484OUString toHexString(const sal_uInt8* nData, sal_uInt32 nDataSize){
485
486 std::stringstream aStrm;
487 for (sal_uInt32 i = 0; i < nDataSize; i++)
488 {
489 aStrm << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(nData[i]);
490 }
491
492 return OUString::createFromAscii(aStrm.str());
493}
494
495void writePoint(tools::XmlWriter& rWriter, Point const& rPoint)
496{
497 rWriter.attribute("x", rPoint.X());
498 rWriter.attribute("y", rPoint.Y());
499}
500
501void writeStartPoint(tools::XmlWriter& rWriter, Point const& rPoint)
502{
503 rWriter.attribute("startx", rPoint.X());
504 rWriter.attribute("starty", rPoint.Y());
505}
506
507void writeEndPoint(tools::XmlWriter& rWriter, Point const& rPoint)
508{
509 rWriter.attribute("endx", rPoint.X());
510 rWriter.attribute("endy", rPoint.Y());
511}
512
513void writeSize(tools::XmlWriter& rWriter, Size const& rSize)
514{
515 rWriter.attribute("width", rSize.Width());
516 rWriter.attribute("height", rSize.Height());
517}
518
519void writeRectangle(tools::XmlWriter& rWriter, tools::Rectangle const& rRectangle)
520{
521 rWriter.attribute("left", rRectangle.Left());
522 rWriter.attribute("top", rRectangle.Top());
523 if (rRectangle.IsWidthEmpty())
524 rWriter.attribute("right", OString("empty"));
525 else
526 rWriter.attribute("right", rRectangle.Right());
527 if (rRectangle.IsHeightEmpty())
528 rWriter.attribute("bottom", OString("empty"));
529 else
530 rWriter.attribute("bottom", rRectangle.Bottom());
531}
532
533void writeMapMode(tools::XmlWriter& rWriter, MapMode const& rMapMode)
534{
535 rWriter.attribute("mapunit", convertMapUnitToString( rMapMode.GetMapUnit() ));
536 writePoint(rWriter, rMapMode.GetOrigin());
537 rWriter.attribute("scalex", convertFractionToString(rMapMode.GetScaleX()));
538 rWriter.attribute("scaley", convertFractionToString(rMapMode.GetScaleY()));
539}
540
541void writeLineInfo(tools::XmlWriter& rWriter, LineInfo const& rLineInfo)
542{
543 rWriter.attribute("style", convertLineStyleToString(rLineInfo.GetStyle()));
544 rWriter.attribute("width", rLineInfo.GetWidth());
545 rWriter.attribute("dashlen", rLineInfo.GetDashLen());
546 rWriter.attribute("dashcount", rLineInfo.GetDashCount());
547 rWriter.attribute("dotlen", rLineInfo.GetDotLen());
548 rWriter.attribute("dotcount", rLineInfo.GetDotCount());
549 rWriter.attribute("distance", rLineInfo.GetDistance());
550 rWriter.attribute("join", convertLineJoinToString(rLineInfo.GetLineJoin()));
551 rWriter.attribute("cap", convertLineCapToString(rLineInfo.GetLineCap()));
552}
553
554void writeGradient(tools::XmlWriter& rWriter, Gradient const& rGradient)
555{
556 rWriter.attribute("style", convertGradientStyleToOUString(rGradient.GetStyle()));
557 rWriter.attribute("startcolor", convertColorToString(rGradient.GetStartColor()));
558 rWriter.attribute("endcolor", convertColorToString(rGradient.GetEndColor()));
559 rWriter.attribute("angle", rGradient.GetAngle().get());
560 rWriter.attribute("border", rGradient.GetBorder());
561 rWriter.attribute("offsetx", rGradient.GetOfsX());
562 rWriter.attribute("offsety", rGradient.GetOfsY());
563 rWriter.attribute("startintensity", rGradient.GetStartIntensity());
564 rWriter.attribute("endintensity", rGradient.GetEndIntensity());
565 rWriter.attribute("steps", rGradient.GetSteps());
566}
567
568OString toHexString(const std::vector<unsigned char>& a)
569{
570 std::stringstream aStrm;
571 for (auto& i : a)
572 {
573 aStrm << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(i);
574 }
575
576 return OString(aStrm.str());
577}
578
579void writeBitmapContentChecksum(tools::XmlWriter& rWriter, Bitmap const& rBitmap)
580{
581 Bitmap aBitmap(rBitmap);
582
584 Bitmap::ScopedReadAccess pReadAccess(aBitmap);
585 assert(pReadAccess);
586
587 for (tools::Long y = 0 ; y < pReadAccess->Height() ; ++y)
588 {
589 for (tools::Long x = 0 ; x < pReadAccess->Width() ; ++x)
590 {
591 BitmapColor aColor = pReadAccess->GetColor(y, x);
592 sal_uInt8 r = aColor.GetRed();
593 sal_uInt8 g = aColor.GetGreen();
594 sal_uInt8 b = aColor.GetBlue();
595 sal_uInt8 a = aColor.GetAlpha();
596 aHashEngine.update(&r, 1);
597 aHashEngine.update(&g, 1);
598 aHashEngine.update(&b, 1);
599 aHashEngine.update(&a, 1);
600 }
601 }
602 std::vector<unsigned char> aVector = aHashEngine.finalize();
603 rWriter.attribute("contentchecksum", toHexString(aVector));
604}
605
606void writeBitmap(tools::XmlWriter& rWriter, Bitmap const& rBitmap)
607{
608 writeBitmapContentChecksum(rWriter, rBitmap);
609 rWriter.attribute("bitmapwidth", rBitmap.GetSizePixel().Width());
610 rWriter.attribute("bitmapheight", rBitmap.GetSizePixel().Height());
611 rWriter.attribute("pixelformat", convertPixelFormatToString(rBitmap.getPixelFormat()));
612 rWriter.attribute("crc", hex32(rBitmap.GetChecksum()));
613}
614
615} // anonymous namespace
616
618{
619 maFilter.fill(false);
620}
621
622void MetafileXmlDump::filterActionType(const MetaActionType nActionType, bool bShouldFilter)
623{
624 maFilter[nActionType] = bShouldFilter;
625}
626
628{
629 maFilter.fill(true);
630}
631
632void MetafileXmlDump::dump(const GDIMetaFile& rMetaFile, SvStream& rStream)
633{
634 tools::XmlWriter aWriter(&rStream);
635 aWriter.startDocument();
636 aWriter.startElement("metafile");
637
638 writeXml(rMetaFile, aWriter);
639
640 aWriter.endElement();
641 aWriter.endDocument();
642}
643
645{
646 MapMode aMtfMapMode = rMetaFile.GetPrefMapMode();
647 rWriter.attribute("mapunit", convertMapUnitToString(aMtfMapMode.GetMapUnit()));
648 writePoint(rWriter, aMtfMapMode.GetOrigin());
649 rWriter.attribute("scalex", convertFractionToString(aMtfMapMode.GetScaleX()));
650 rWriter.attribute("scaley", convertFractionToString(aMtfMapMode.GetScaleY()));
651
652 Size aMtfSize = rMetaFile.GetPrefSize();
653 writeSize(rWriter, aMtfSize);
654
655 for(size_t nAction = 0; nAction < rMetaFile.GetActionSize(); ++nAction)
656 {
657 MetaAction* pAction = rMetaFile.GetAction(nAction);
658 const MetaActionType nActionType = pAction->GetType();
659 if (maFilter[nActionType])
660 continue;
661
662 OString sCurrentElementTag = convertLineStyleToString(nActionType);
663
664 switch (nActionType)
665 {
667 {
668 rWriter.startElement(sCurrentElementTag);
669 rWriter.endElement();
670 }
671 break;
672
674 {
675 auto* pMetaAction = static_cast<MetaPixelAction*>(pAction);
676 rWriter.startElement(sCurrentElementTag);
677 writePoint(rWriter, pMetaAction->GetPoint());
678 rWriter.attribute("color", convertColorToString(pMetaAction->GetColor()));
679 rWriter.endElement();
680 }
681 break;
682
684 {
685 auto* pMetaAction = static_cast<MetaPointAction*>(pAction);
686 rWriter.startElement(sCurrentElementTag);
687 writePoint(rWriter, pMetaAction->GetPoint());
688 rWriter.endElement();
689 }
690 break;
691
693 {
694 MetaLineAction* pMetaLineAction = static_cast<MetaLineAction*>(pAction);
695 rWriter.startElement(sCurrentElementTag);
696 writeStartPoint(rWriter, pMetaLineAction->GetStartPoint());
697 writeEndPoint(rWriter, pMetaLineAction->GetEndPoint());
698
699 writeLineInfo(rWriter, pMetaLineAction->GetLineInfo());
700 rWriter.endElement();
701 }
702 break;
703
705 {
706 MetaRectAction* pMetaAction = static_cast<MetaRectAction*>(pAction);
707 rWriter.startElement(sCurrentElementTag);
708 writeRectangle(rWriter, pMetaAction->GetRect());
709 rWriter.endElement();
710 }
711 break;
712
714 {
715 auto pMetaAction = static_cast<MetaRoundRectAction*>(pAction);
716 rWriter.startElement(sCurrentElementTag);
717 writeRectangle(rWriter, pMetaAction->GetRect());
718 rWriter.attribute("horizontalround", pMetaAction->GetHorzRound());
719 rWriter.attribute("verticalround", pMetaAction->GetVertRound());
720 rWriter.endElement();
721 }
722 break;
723
725 {
726 auto pMetaAction = static_cast<MetaEllipseAction*>(pAction);
727 rWriter.startElement(sCurrentElementTag);
728 writeRectangle(rWriter, pMetaAction->GetRect());
729 rWriter.endElement();
730 }
731 break;
732
734 {
735 auto pMetaAction = static_cast<MetaArcAction*>(pAction);
736 rWriter.startElement(sCurrentElementTag);
737 writeRectangle(rWriter, pMetaAction->GetRect());
738 writeStartPoint(rWriter, pMetaAction->GetStartPoint());
739 writeEndPoint(rWriter, pMetaAction->GetEndPoint());
740 rWriter.endElement();
741 }
742 break;
743
745 {
746 auto pMetaAction = static_cast<MetaPieAction*>(pAction);
747 rWriter.startElement(sCurrentElementTag);
748 writeRectangle(rWriter, pMetaAction->GetRect());
749 writeStartPoint(rWriter, pMetaAction->GetStartPoint());
750 writeEndPoint(rWriter, pMetaAction->GetEndPoint());
751 rWriter.endElement();
752 }
753 break;
754
756 {
757 auto pMetaAction = static_cast<MetaChordAction*>(pAction);
758 rWriter.startElement(sCurrentElementTag);
759 writeRectangle(rWriter, pMetaAction->GetRect());
760 writeStartPoint(rWriter, pMetaAction->GetStartPoint());
761 writeEndPoint(rWriter, pMetaAction->GetEndPoint());
762 rWriter.endElement();
763 }
764 break;
765
767 {
768 MetaPolyLineAction* pMetaPolyLineAction = static_cast<MetaPolyLineAction*>(pAction);
769 rWriter.startElement(sCurrentElementTag);
770
771 writeLineInfo(rWriter, pMetaPolyLineAction->GetLineInfo());
772
773 tools::Polygon aPolygon = pMetaPolyLineAction->GetPolygon();
774 bool bFlags = aPolygon.HasFlags();
775 for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++)
776 {
777 rWriter.startElement("point");
778 writePoint(rWriter, aPolygon[i]);
779 if (bFlags)
780 rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i)));
781 rWriter.endElement();
782 }
783
784 rWriter.endElement();
785 }
786 break;
787
789 {
790 MetaPolygonAction* pMetaPolygonAction = static_cast<MetaPolygonAction*>(pAction);
791 rWriter.startElement(sCurrentElementTag);
792
793 tools::Polygon aPolygon = pMetaPolygonAction->GetPolygon();
794 bool bFlags = aPolygon.HasFlags();
795 for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++)
796 {
797 rWriter.startElement("point");
798 writePoint(rWriter, aPolygon[i]);
799 if (bFlags)
800 rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i)));
801 rWriter.endElement();
802 }
803
804 rWriter.endElement();
805 }
806 break;
807
809 {
810 MetaPolyPolygonAction *const pMetaPolyPolygonAction = static_cast<MetaPolyPolygonAction*>(pAction);
811 rWriter.startElement(sCurrentElementTag);
812
813 tools::PolyPolygon const& rPolyPolygon(pMetaPolyPolygonAction->GetPolyPolygon());
814
815 for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
816 {
817 rWriter.startElement("polygon");
818 tools::Polygon const& rPolygon = rPolyPolygon[j];
819 bool bFlags = rPolygon.HasFlags();
820 for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
821 {
822 rWriter.startElement("point");
823 writePoint(rWriter, rPolygon[i]);
824 if (bFlags)
825 rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
826 rWriter.endElement();
827 }
828 rWriter.endElement();
829 }
830 rWriter.endElement();
831 }
832 break;
833
835 {
836 auto* pMeta = static_cast<MetaTextAction*>(pAction);
837 rWriter.startElement(sCurrentElementTag);
838 writePoint(rWriter, pMeta->GetPoint());
839 rWriter.attribute("index", pMeta->GetIndex());
840 rWriter.attribute("length", pMeta->GetLen());
841 rWriter.startElement("textcontent");
842 rWriter.content(pMeta->GetText());
843 rWriter.endElement();
844
845 rWriter.endElement();
846 }
847 break;
848
850 {
851 MetaTextArrayAction* pMetaTextArrayAction = static_cast<MetaTextArrayAction*>(pAction);
852 rWriter.startElement(sCurrentElementTag);
853
854 sal_Int32 aIndex = pMetaTextArrayAction->GetIndex();
855 sal_Int32 aLength = pMetaTextArrayAction->GetLen();
856
857 writePoint(rWriter, pMetaTextArrayAction->GetPoint());
858 rWriter.attribute("index", aIndex);
859 rWriter.attribute("length", aLength);
860
861 if (!pMetaTextArrayAction->GetDXArray().empty())
862 {
863 auto & rArray = pMetaTextArrayAction->GetDXArray();
864 rWriter.startElement("dxarray");
865 if (aIndex < o3tl::narrowing<sal_Int32>(rArray.size()))
866 rWriter.attribute("first", rArray[aIndex]);
867 if (aIndex + aLength - 1 < o3tl::narrowing<sal_Int32>(rArray.size()))
868 rWriter.attribute("last", rArray[aIndex + aLength - 1]);
869 OUStringBuffer sDxLengthString(std::max((aLength - aIndex) * 4, sal_Int32(0)));
870 for (sal_Int32 i = 0; i < aLength - aIndex; ++i)
871 {
872 sDxLengthString.append(OUString::number(rArray[aIndex + i]) + " ");
873 }
874 rWriter.content(sDxLengthString);
875 rWriter.endElement();
876 }
877
878 rWriter.startElement("text");
879
880 const OUString& rStr = pMetaTextArrayAction->GetText();
881 // fix bad XML dump by removing forbidden 0x01
882 // FIXME: expand footnote anchor point 0x01 instead of this
883 if ( rStr.indexOf(0x01) > -1 )
884 rWriter.content(rStr.replaceAll("\001", ""));
885 else
886 rWriter.content(rStr);
887
888 rWriter.endElement();
889
890 rWriter.endElement();
891 }
892 break;
893
895 {
896 auto* pMeta = static_cast<MetaStretchTextAction*>(pAction);
897 rWriter.startElement(sCurrentElementTag);
898
899 writePoint(rWriter, pMeta->GetPoint());
900 rWriter.attribute("index", pMeta->GetIndex());
901 rWriter.attribute("length", pMeta->GetLen());
902 rWriter.attribute("width", pMeta->GetWidth());
903
904 rWriter.startElement("textcontent");
905 rWriter.content(pMeta->GetText());
906 rWriter.endElement();
907
908 rWriter.endElement();
909 }
910 break;
911
913 {
914 auto* pMeta = static_cast<MetaTextRectAction*>(pAction);
915 rWriter.startElement(sCurrentElementTag);
916 writeRectangle(rWriter, pMeta->GetRect());
917 rWriter.startElement("textcontent");
918 rWriter.content(pMeta->GetText());
919 rWriter.endElement();
920
921 rWriter.startElement("style");
922 rWriter.content(convertDrawTextFlagsToString(pMeta->GetStyle()));
923 rWriter.endElement();
924
925 rWriter.endElement();
926 }
927 break;
928
930 {
931 auto pMeta = static_cast<MetaBmpAction*>(pAction);
932 Bitmap aBitmap = pMeta->GetBitmap();
933 rWriter.startElement(sCurrentElementTag);
934 writePoint(rWriter, pMeta->GetPoint());
935 writeBitmap(rWriter, aBitmap);
936 rWriter.endElement();
937 }
938 break;
939
941 {
942 auto pMeta = static_cast<MetaBmpScaleAction*>(pAction);
943 Bitmap aBitmap = pMeta->GetBitmap();
944 rWriter.startElement(sCurrentElementTag);
945 writePoint(rWriter, pMeta->GetPoint());
946 writeSize(rWriter, pMeta->GetSize());
947 writeBitmap(rWriter, aBitmap);
948 rWriter.endElement();
949 }
950 break;
951
953 {
954 auto pMeta = static_cast<MetaBmpScalePartAction*>(pAction);
955 Bitmap aBitmap = pMeta->GetBitmap();
956 rWriter.startElement(sCurrentElementTag);
957 rWriter.attribute("destx", pMeta->GetDestPoint().X());
958 rWriter.attribute("desty", pMeta->GetDestPoint().Y());
959 rWriter.attribute("destwidth", pMeta->GetDestSize().Width());
960 rWriter.attribute("destheight", pMeta->GetDestSize().Height());
961 rWriter.attribute("srcx", pMeta->GetSrcPoint().X());
962 rWriter.attribute("srcy", pMeta->GetSrcPoint().Y());
963 rWriter.attribute("srcwidth", pMeta->GetSrcSize().Width());
964 rWriter.attribute("srcheight", pMeta->GetSrcSize().Height());
965 writeBitmap(rWriter, aBitmap);
966 rWriter.endElement();
967 }
968 break;
969
971 {
972 auto pMeta = static_cast<MetaBmpExAction*>(pAction);
973 rWriter.startElement(sCurrentElementTag);
974 writePoint(rWriter, pMeta->GetPoint());
975 Bitmap aBitmap = pMeta->GetBitmapEx().GetBitmap();
976 rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx()));
977 writeBitmap(rWriter, aBitmap);
978 rWriter.endElement();
979 }
980 break;
981
983 {
984 auto pMeta = static_cast<MetaBmpExScaleAction*>(pAction);
985 rWriter.startElement(sCurrentElementTag);
986 writePoint(rWriter, pMeta->GetPoint());
987 writeSize(rWriter, pMeta->GetSize());
988 Bitmap aBitmap = pMeta->GetBitmapEx().GetBitmap();
989 rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx()));
990 writeBitmap(rWriter, aBitmap);
991 rWriter.endElement();
992 }
993 break;
994
996 {
997 auto pMeta = static_cast<MetaBmpExScalePartAction*>(pAction);
998 Bitmap aBitmap = pMeta->GetBitmapEx().GetBitmap();
999 rWriter.startElement(sCurrentElementTag);
1000 rWriter.attribute("destx", pMeta->GetDestPoint().X());
1001 rWriter.attribute("desty", pMeta->GetDestPoint().Y());
1002 rWriter.attribute("destwidth", pMeta->GetDestSize().Width());
1003 rWriter.attribute("destheight", pMeta->GetDestSize().Height());
1004 rWriter.attribute("srcx", pMeta->GetSrcPoint().X());
1005 rWriter.attribute("srcy", pMeta->GetSrcPoint().Y());
1006 rWriter.attribute("srcwidth", pMeta->GetSrcSize().Width());
1007 rWriter.attribute("srcheight", pMeta->GetSrcSize().Height());
1008 rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx()));
1009 writeBitmap(rWriter, aBitmap);
1010 rWriter.endElement();
1011 }
1012 break;
1013
1015 {
1016 auto pMeta = static_cast<MetaMaskAction*>(pAction);
1017 rWriter.startElement(sCurrentElementTag);
1018 writePoint(rWriter, pMeta->GetPoint());
1019 rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
1020 rWriter.attribute("color", convertColorToString(pMeta->GetColor()));
1021 rWriter.endElement();
1022 }
1023 break;
1024
1026 {
1027 auto pMeta = static_cast<MetaMaskScaleAction*>(pAction);
1028 rWriter.startElement(sCurrentElementTag);
1029 writePoint(rWriter, pMeta->GetPoint());
1030 writeSize(rWriter, pMeta->GetSize());
1031 rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
1032 rWriter.attribute("color", convertColorToString(pMeta->GetColor()));
1033 rWriter.endElement();
1034 }
1035 break;
1036
1038 {
1039 auto pMeta = static_cast<MetaMaskScalePartAction*>(pAction);
1040 rWriter.startElement(sCurrentElementTag);
1041 rWriter.attribute("destx", pMeta->GetDestPoint().X());
1042 rWriter.attribute("desty", pMeta->GetDestPoint().Y());
1043 rWriter.attribute("destwidth", pMeta->GetDestSize().Width());
1044 rWriter.attribute("destheight", pMeta->GetDestSize().Height());
1045 rWriter.attribute("srcx", pMeta->GetSrcPoint().X());
1046 rWriter.attribute("srcy", pMeta->GetSrcPoint().Y());
1047 rWriter.attribute("srcwidth", pMeta->GetSrcSize().Width());
1048 rWriter.attribute("srcheight", pMeta->GetSrcSize().Height());
1049 rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
1050 rWriter.attribute("color", convertColorToString(pMeta->GetColor()));
1051 rWriter.endElement();
1052 }
1053 break;
1054
1056 {
1057 const MetaGradientAction* pMeta = static_cast<MetaGradientAction*>(pAction);
1058
1059 rWriter.startElement(sCurrentElementTag);
1060 writeGradient(rWriter, pMeta->GetGradient());
1061
1062 rWriter.startElement("rectangle");
1063 writeRectangle(rWriter, pMeta->GetRect());
1064 rWriter.endElement();
1065
1066 rWriter.endElement();
1067 }
1068 break;
1069
1071 {
1072 auto* const pMetaHatchAction = static_cast<MetaHatchAction*>(pAction);
1073 rWriter.startElement(sCurrentElementTag);
1074
1075 tools::PolyPolygon const& rPolyPolygon(pMetaHatchAction->GetPolyPolygon());
1076
1077 for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
1078 {
1079 rWriter.startElement("polygon");
1080 tools::Polygon const& rPolygon = rPolyPolygon[j];
1081 bool bFlags = rPolygon.HasFlags();
1082 for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
1083 {
1084 rWriter.startElement("point");
1085 writePoint(rWriter, rPolygon[i]);
1086 if (bFlags)
1087 rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
1088 rWriter.endElement();
1089 }
1090 rWriter.endElement();
1091 }
1092
1093 rWriter.startElement("hatch");
1094 const auto& rHatch = pMetaHatchAction->GetHatch();
1095 rWriter.attribute("style", convertHatchStyle(rHatch.GetStyle()));
1096 rWriter.attribute("color", convertColorToString(rHatch.GetColor()));
1097 rWriter.attribute("distance", sal_Int32(rHatch.GetDistance()));
1098 rWriter.attribute("angle", sal_Int32(rHatch.GetAngle().get()));
1099 rWriter.endElement();
1100
1101 rWriter.endElement();
1102 }
1103 break;
1104
1106 {
1107 const auto* pMetaAction = static_cast<const MetaWallpaperAction*>(pAction);
1108 rWriter.startElement(sCurrentElementTag);
1109
1110 writeRectangle(rWriter, pMetaAction->GetRect());
1111
1112 rWriter.startElement("wallpaper");
1113 const auto& rWallpaper = pMetaAction->GetWallpaper();
1114
1115 rWriter.attribute("color", convertColorToString(rWallpaper.GetColor()));
1116
1117 WallpaperStyle eStyle = rWallpaper.GetStyle();
1118 rWriter.attribute("style", convertWallpaperStyleToString(eStyle));
1119
1120 if (rWallpaper.IsBitmap())
1121 {
1122 rWriter.startElement("bitmap");
1123 BitmapEx const & rBitmapEx = rWallpaper.GetBitmap();
1124 rWriter.attribute("crc", hex32(rBitmapEx.GetChecksum()));
1125 rWriter.attribute("transparenttype", convertBitmapExTransparentType(rBitmapEx));
1126 rWriter.attribute("pixelformat", convertPixelFormatToString(rBitmapEx.GetBitmap().getPixelFormat()));
1127 rWriter.attribute("width", hex32(rBitmapEx.GetSizePixel().Width()));
1128 rWriter.attribute("height", hex32(rBitmapEx.GetSizePixel().Height()));
1129 rWriter.endElement();
1130 }
1131
1132 if (rWallpaper.IsGradient())
1133 {
1134 rWriter.startElement("gradient");
1135 Gradient aGradient = rWallpaper.GetGradient();
1136 writeGradient(rWriter, aGradient);
1137 rWriter.endElement();
1138 }
1139
1140 if (rWallpaper.IsRect())
1141 {
1142 tools::Rectangle aRect = rWallpaper.GetRect();
1143 rWriter.startElement("rectangle");
1144 writeRectangle(rWriter, aRect);
1145 rWriter.endElement();
1146 }
1147
1148 rWriter.attribute("fixed", rWallpaper.IsFixed() ? "true" : "false");
1149 rWriter.attribute("scrollable", rWallpaper.IsScrollable() ? "true" : "false");
1150
1151 rWriter.endElement();
1152
1153 rWriter.endElement();
1154 }
1155 break;
1156
1158 {
1159 const auto* pMetaClipRegionAction = static_cast<const MetaClipRegionAction*>(pAction);
1160 rWriter.startElement(sCurrentElementTag);
1161
1162 tools::Rectangle aRectangle = pMetaClipRegionAction->GetRegion().GetBoundRect();
1163 writeRectangle(rWriter, aRectangle);
1164
1165 vcl::Region aRegion = pMetaClipRegionAction->GetRegion();
1166
1167 if (aRegion.HasPolyPolygonOrB2DPolyPolygon())
1168 {
1169 tools::PolyPolygon aPolyPolygon = aRegion.GetAsPolyPolygon();
1170
1171 for (sal_uInt16 j = 0; j < aPolyPolygon.Count(); ++j)
1172 {
1173 rWriter.startElement("polygon");
1174 tools::Polygon const& rPolygon = aPolyPolygon[j];
1175 bool bFlags = rPolygon.HasFlags();
1176 for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
1177 {
1178 rWriter.startElement("point");
1179 writePoint(rWriter, rPolygon[i]);
1180 if (bFlags)
1181 rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
1182 rWriter.endElement();
1183 }
1184 rWriter.endElement();
1185 }
1186 }
1187
1188 rWriter.endElement();
1189 }
1190 break;
1191
1193 {
1194 MetaISectRectClipRegionAction* pMetaISectRectClipRegionAction = static_cast<MetaISectRectClipRegionAction*>(pAction);
1195 rWriter.startElement(sCurrentElementTag);
1196
1197 tools::Rectangle aRectangle = pMetaISectRectClipRegionAction->GetRect();
1198 writeRectangle(rWriter, aRectangle);
1199 rWriter.endElement();
1200 }
1201 break;
1202
1204 {
1205 MetaISectRegionClipRegionAction* pMetaISectRegionClipRegionAction = static_cast<MetaISectRegionClipRegionAction*>(pAction);
1206 rWriter.startElement(sCurrentElementTag);
1207
1208 // FIXME for now we dump only the bounding box; this is
1209 // enough for the tests we have, but may need extending to
1210 // dumping the real polypolygon in the future
1211 tools::Rectangle aRectangle = pMetaISectRegionClipRegionAction->GetRegion().GetBoundRect();
1212 writeRectangle(rWriter, aRectangle);
1213 rWriter.endElement();
1214 }
1215 break;
1216
1218 {
1219 const auto* pMetaMoveClipRegionAction = static_cast<MetaMoveClipRegionAction*>(pAction);
1220 rWriter.startElement(sCurrentElementTag);
1221
1222 rWriter.attribute("horzmove", pMetaMoveClipRegionAction->GetHorzMove());
1223 rWriter.attribute("vertmove", pMetaMoveClipRegionAction->GetVertMove());
1224 rWriter.endElement();
1225 }
1226 break;
1227
1229 {
1230 MetaLineColorAction* pMetaLineColorAction = static_cast<MetaLineColorAction*>(pAction);
1231 rWriter.startElement(sCurrentElementTag);
1232
1233 rWriter.attribute("color", convertColorToString(pMetaLineColorAction->GetColor()));
1234 rWriter.endElement();
1235 }
1236 break;
1237
1239 {
1240 MetaFillColorAction* pMetaFillColorAction = static_cast<MetaFillColorAction*>(pAction);
1241 rWriter.startElement(sCurrentElementTag);
1242
1243 rWriter.attribute("color", convertColorToString(pMetaFillColorAction->GetColor()));
1244 rWriter.endElement();
1245 }
1246 break;
1247
1249 {
1250 MetaTextColorAction* pMetaTextColorAction = static_cast<MetaTextColorAction*>(pAction);
1251 rWriter.startElement(sCurrentElementTag);
1252
1253 rWriter.attribute("color", convertColorToString(pMetaTextColorAction->GetColor()));
1254 rWriter.endElement();
1255 }
1256 break;
1257
1259 {
1260 MetaTextFillColorAction* pMetaTextFillColorAction = static_cast<MetaTextFillColorAction*>(pAction);
1261 rWriter.startElement(sCurrentElementTag);
1262
1263 rWriter.attribute("color", convertColorToString(pMetaTextFillColorAction->GetColor()));
1264
1265 if (pMetaTextFillColorAction->IsSetting())
1266 rWriter.attribute("setting", u"true");
1267
1268 rWriter.endElement();
1269 }
1270 break;
1271
1273 {
1274 MetaTextAlignAction* pMetaTextAlignAction = static_cast<MetaTextAlignAction*>(pAction);
1275 rWriter.startElement(sCurrentElementTag);
1276 OUString sAlign = convertTextAlignToString(pMetaTextAlignAction->GetTextAlign());
1277 if (!sAlign.isEmpty())
1278 rWriter.attribute("align", sAlign);
1279 rWriter.endElement();
1280 }
1281 break;
1282
1284 {
1285 const MetaMapModeAction* pMeta = static_cast<MetaMapModeAction*>(pAction);
1286 MapMode aMapMode = pMeta->GetMapMode();
1287 rWriter.startElement(sCurrentElementTag);
1288 rWriter.attribute("mapunit", convertMapUnitToString( aMapMode.GetMapUnit() ));
1289 writePoint(rWriter, aMapMode.GetOrigin());
1290 rWriter.attribute("scalex", convertFractionToString(aMapMode.GetScaleX()));
1291 rWriter.attribute("scaley", convertFractionToString(aMapMode.GetScaleY()));
1292 rWriter.endElement();
1293 }
1294 break;
1295
1297 {
1298 MetaFontAction* pMetaFontAction = static_cast<MetaFontAction*>(pAction);
1299 rWriter.startElement(sCurrentElementTag);
1300
1301 vcl::Font aFont = pMetaFontAction->GetFont();
1302
1303 rWriter.attribute("color", convertColorToString(aFont.GetColor()));
1304 rWriter.attribute("fillcolor", convertColorToString(aFont.GetFillColor()));
1305 rWriter.attribute("name", aFont.GetFamilyName());
1306 rWriter.attribute("stylename", aFont.GetStyleName());
1307 rWriter.attribute("width", aFont.GetFontSize().Width());
1308 rWriter.attribute("height", aFont.GetFontSize().Height());
1309 rWriter.attribute("orientation", aFont.GetOrientation().get());
1310 rWriter.attribute("weight", convertFontWeightToString(aFont.GetWeight()));
1311 rWriter.attribute("vertical", aFont.IsVertical() ? "true" : "false");
1312
1313 rWriter.endElement();
1314 }
1315 break;
1316
1318 {
1319 MetaPushAction* pMetaPushAction = static_cast<MetaPushAction*>(pAction);
1320 rWriter.startElement(sCurrentElementTag);
1321
1322 rWriter.attribute("flags", collectPushFlags(pMetaPushAction->GetFlags()));
1323 }
1324 break;
1325
1327 {
1328 rWriter.endElement();
1329 }
1330 break;
1331
1333 {
1334 MetaRasterOpAction* pMetaRasterOpAction = static_cast<MetaRasterOpAction*>(pAction);
1335 rWriter.startElement(sCurrentElementTag);
1336
1337 if (pMetaRasterOpAction->GetRasterOp() != RasterOp::OverPaint)
1338 {
1339 rWriter.attribute("operation", convertRopToString(pMetaRasterOpAction->GetRasterOp()));
1340 }
1341 rWriter.endElement();
1342 }
1343 break;
1344
1346 {
1347 const MetaTransparentAction* pMeta = static_cast<MetaTransparentAction*>(pAction);
1348
1349 rWriter.startElement(sCurrentElementTag);
1350 rWriter.attribute("transparence", pMeta->GetTransparence());
1351
1352 tools::PolyPolygon const& rPolyPolygon(pMeta->GetPolyPolygon());
1353
1354 for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
1355 {
1356 rWriter.startElement("polygon");
1357 tools::Polygon const& rPolygon = rPolyPolygon[j];
1358 bool bFlags = rPolygon.HasFlags();
1359 for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
1360 {
1361 rWriter.startElement("point");
1362 writePoint(rWriter, rPolygon[i]);
1363 if (bFlags)
1364 rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
1365 rWriter.endElement();
1366 }
1367 rWriter.endElement();
1368 }
1369
1370 rWriter.endElement();
1371 }
1372 break;
1373
1375 {
1376 MetaEPSAction* pMetaEPSAction = static_cast<MetaEPSAction*>(pAction);
1377 rWriter.startElement(sCurrentElementTag);
1378
1379 writePoint(rWriter, pMetaEPSAction->GetPoint());
1380 writeSize(rWriter, pMetaEPSAction->GetSize());
1381
1382 rWriter.startElement("gfxlink");
1383 writeSize(rWriter, pMetaEPSAction->GetLink().GetPrefSize());
1384 rWriter.attribute("type", convertGfxLinkTypeToString(pMetaEPSAction->GetLink().GetType()));
1385 rWriter.attribute("userid", pMetaEPSAction->GetLink().GetUserId());
1386 rWriter.attribute("datasize", pMetaEPSAction->GetLink().GetDataSize());
1387 rWriter.attribute("data", toHexString(pMetaEPSAction->GetLink().GetData(), pMetaEPSAction->GetLink().GetDataSize()));
1388 rWriter.attribute("native", pMetaEPSAction->GetLink().IsNative() ? "true" : "false");
1389 rWriter.attribute("emf", pMetaEPSAction->GetLink().IsEMF() ? "true" : "false");
1390 rWriter.attribute("validmapmode", pMetaEPSAction->GetLink().IsPrefMapModeValid() ? "true" : "false");
1391 rWriter.startElement("prefmapmode");
1392 writeMapMode(rWriter, pMetaEPSAction->GetLink().GetPrefMapMode());
1393 rWriter.endElement();
1394 rWriter.endElement();
1395
1396 rWriter.startElement("metafile");
1397 writeXml(pMetaEPSAction->GetSubstitute(), rWriter);
1398 rWriter.endElement();
1399
1400 rWriter.endElement();
1401 }
1402 break;
1403
1405 {
1406 auto* pMeta = static_cast<MetaRefPointAction*>(pAction);
1407 rWriter.startElement(sCurrentElementTag);
1408 writePoint(rWriter, pMeta->GetRefPoint());
1409 rWriter.attribute("set", pMeta->IsSetting() ? "true" : "false");
1410 rWriter.endElement();
1411 }
1412 break;
1413
1415 {
1416 auto* pMeta = static_cast<MetaTextLineColorAction*>(pAction);
1417 rWriter.startElement(sCurrentElementTag);
1418 rWriter.attribute("color", convertColorToString(pMeta->GetColor()));
1419 rWriter.endElement();
1420 }
1421 break;
1422
1424 {
1425 auto* pMeta = static_cast<MetaTextLineAction*>(pAction);
1426 rWriter.startElement(sCurrentElementTag);
1427 writePoint(rWriter, pMeta->GetStartPoint());
1428 rWriter.attribute("width", pMeta->GetWidth());
1429 rWriter.attribute("strikeout", convertFontStrikeoutToString(pMeta->GetStrikeout()));
1430 rWriter.attribute("underline", convertFontLineStyleToString(pMeta->GetUnderline()));
1431 rWriter.attribute("overline", convertFontLineStyleToString(pMeta->GetOverline()));
1432 rWriter.endElement();
1433 }
1434 break;
1435
1437 {
1438 const auto* pMeta = static_cast<MetaFloatTransparentAction*>(pAction);
1439 rWriter.startElement(sCurrentElementTag);
1440 writePoint(rWriter, pMeta->GetPoint());
1441 writeSize(rWriter, pMeta->GetSize());
1442 rWriter.attribute("transparent", pMeta->IsTransparent() ? "true" : "false");
1443
1444 rWriter.startElement("gradient");
1445 writeGradient(rWriter, pMeta->GetGradient());
1446 rWriter.endElement();
1447
1448 rWriter.startElement("metafile");
1449 writeXml(pMeta->GetGDIMetaFile(), rWriter);
1450 rWriter.endElement();
1451
1452 rWriter.endElement();
1453 }
1454 break;
1455
1457 {
1458 const MetaGradientExAction* pMetaGradientExAction = static_cast<MetaGradientExAction*>(pAction);
1459
1460 rWriter.startElement(sCurrentElementTag);
1461 writeGradient(rWriter, pMetaGradientExAction->GetGradient());
1462
1463 tools::PolyPolygon const& rPolyPolygon(pMetaGradientExAction->GetPolyPolygon());
1464 for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
1465 {
1466 rWriter.startElement("polygon");
1467 tools::Polygon const& rPolygon = rPolyPolygon[j];
1468 bool bFlags = rPolygon.HasFlags();
1469 for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
1470 {
1471 rWriter.startElement("point");
1472 writePoint(rWriter, rPolygon[i]);
1473 if (bFlags)
1474 rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
1475 rWriter.endElement();
1476 }
1477 rWriter.endElement();
1478 }
1479
1480 rWriter.endElement();
1481 }
1482 break;
1483
1485 {
1486 const MetaLayoutModeAction* pMetaLayoutModeAction = static_cast<MetaLayoutModeAction*>(pAction);
1487
1488 rWriter.startElement(sCurrentElementTag);
1489
1490 rWriter.attribute("textlayout", convertComplexTestLayoutFlags(pMetaLayoutModeAction->GetLayoutMode()));
1491
1492 rWriter.endElement();
1493 }
1494 break;
1495
1497 {
1498 const MetaTextLanguageAction* pMetaTextLanguageAction = static_cast<MetaTextLanguageAction*>(pAction);
1499
1500 rWriter.startElement(sCurrentElementTag);
1501
1502 rWriter.attribute("language", convertLanguageTypeToString(pMetaTextLanguageAction->GetTextLanguage()));
1503
1504 rWriter.endElement();
1505 }
1506 break;
1507
1509 {
1510 const auto* pMetaAction = static_cast<MetaOverlineColorAction*>(pAction);
1511 rWriter.startElement(sCurrentElementTag);
1512 rWriter.attribute("color", convertColorToString(pMetaAction->GetColor()));
1513 rWriter.endElement();
1514 }
1515 break;
1516
1518 {
1519 MetaCommentAction* pMetaCommentAction = static_cast<MetaCommentAction*>(pAction);
1520 rWriter.startElement(sCurrentElementTag);
1521
1522 if (pMetaCommentAction->GetDataSize() > 0)
1523 {
1524 rWriter.attribute("datasize", pMetaCommentAction->GetDataSize());
1525 rWriter.attribute("data", toHexString(pMetaCommentAction->GetData(), pMetaCommentAction->GetDataSize()));
1526 }
1527 rWriter.attribute("value", pMetaCommentAction->GetValue());
1528
1529 if (!pMetaCommentAction->GetComment().isEmpty())
1530 {
1531 rWriter.startElement("comment");
1532 rWriter.content(pMetaCommentAction->GetComment());
1533 rWriter.endElement();
1534 }
1535 rWriter.endElement();
1536 }
1537 break;
1538
1539 default:
1540 {
1541 rWriter.startElement(sCurrentElementTag);
1542 rWriter.attribute("note", OString("not implemented in xml dump"));
1543 rWriter.endElement();
1544 }
1545 break;
1546 }
1547 }
1548}
1549
1550/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawTextFlags
RasterOp
Definition: RasterOp.hxx:23
#define PUSH_ALLFONT
Definition: State.hxx:66
bool IsAlpha() const
Definition: BitmapEx.cxx:207
BitmapChecksum GetChecksum() const
Definition: BitmapEx.cxx:239
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:217
const Size & GetSizePixel() const
Definition: bitmapex.hxx:73
BitmapChecksum GetChecksum() const
Size GetSizePixel() const
vcl::PixelFormat getPixelFormat() const
sal_uInt8 GetBlue() const
OUString AsRGBHexString() const
sal_uInt8 GetAlpha() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
size_t GetActionSize() const
Definition: gdimtf.cxx:181
const Size & GetPrefSize() const
Definition: gdimtf.hxx:176
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:186
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:179
sal_uInt16 GetStartIntensity() const
Degree10 GetAngle() const
sal_uInt16 GetEndIntensity() const
sal_uInt16 GetOfsX() const
sal_uInt16 GetBorder() const
const Color & GetEndColor() const
sal_uInt16 GetOfsY() const
const Color & GetStartColor() const
css::awt::GradientStyle GetStyle() const
sal_uInt16 GetSteps() const
bool empty() const
Definition: kernarray.hxx:74
const Fraction & GetScaleX() const
Definition: mapmod.cxx:185
MapUnit GetMapUnit() const
Definition: mapmod.cxx:181
const Point & GetOrigin() const
Definition: mapmod.cxx:183
const Fraction & GetScaleY() const
Definition: mapmod.cxx:187
MetaActionType GetType() const
Definition: metaact.hxx:96
sal_Int32 GetValue() const
Definition: metaact.hxx:1710
const sal_uInt8 * GetData() const
Definition: metaact.hxx:1712
const OString & GetComment() const
Definition: metaact.hxx:1709
sal_uInt32 GetDataSize() const
Definition: metaact.hxx:1711
const GDIMetaFile & GetSubstitute() const
Definition: metaact.hxx:1647
const Point & GetPoint() const
Definition: metaact.hxx:1648
const Size & GetSize() const
Definition: metaact.hxx:1649
const GfxLink & GetLink() const
Definition: metaact.hxx:1646
const Color & GetColor() const
Definition: metaact.hxx:1279
const vcl::Font & GetFont() const
Definition: metaact.hxx:1472
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1022
const Gradient & GetGradient() const
Definition: metaact.hxx:1023
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1052
const Gradient & GetGradient() const
Definition: metaact.hxx:1053
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1171
const vcl::Region & GetRegion() const
Definition: metaact.hxx:1198
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
Definition: metaact.hxx:1739
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:187
const Point & GetEndPoint() const
Definition: metaact.hxx:186
const Point & GetStartPoint() const
Definition: metaact.hxx:185
const Color & GetColor() const
Definition: metaact.hxx:1252
const MapMode & GetMapMode() const
Definition: metaact.hxx:1438
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:409
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:408
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:464
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:437
vcl::PushFlags GetFlags() const
Definition: metaact.hxx:1497
RasterOp GetRasterOp() const
Definition: metaact.hxx:1537
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:216
TextAlign GetTextAlign() const
Definition: metaact.hxx:1412
sal_Int32 GetIndex() const
Definition: metaact.hxx:541
const KernArray & GetDXArray() const
Definition: metaact.hxx:543
sal_Int32 GetLen() const
Definition: metaact.hxx:542
const OUString & GetText() const
Definition: metaact.hxx:540
const Point & GetPoint() const
Definition: metaact.hxx:539
const Color & GetColor() const
Definition: metaact.hxx:1306
bool IsSetting() const
Definition: metaact.hxx:1334
const Color & GetColor() const
Definition: metaact.hxx:1331
LanguageType GetTextLanguage() const
Definition: metaact.hxx:1763
sal_uInt16 GetTransparence() const
Definition: metaact.hxx:1566
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1565
void filterAllActionTypes()
Definition: mtfxmldump.cxx:627
void writeXml(const GDIMetaFile &rMetaFile, tools::XmlWriter &rWriter)
Definition: mtfxmldump.cxx:644
void dump(const GDIMetaFile &rMetaFile, SvStream &rStream)
The actual result that will be used for testing.
Definition: mtfxmldump.cxx:632
o3tl::enumarray< MetaActionType, bool > maFilter
Definition: mtfxmldump.hxx:46
void filterActionType(const MetaActionType nActionType, bool bShouldFilter)
Definition: mtfxmldump.cxx:622
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void fill(V val)
sal_uInt16 Count() const
PolyFlags GetFlags(sal_uInt16 nPos) const
bool HasFlags() const
sal_uInt16 GetSize() const
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr bool IsWidthEmpty() const
constexpr bool IsHeightEmpty() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
void content(const OString &sValue)
bool startDocument(sal_Int32 nIndent=2, bool bWriteXmlHeader=true)
void attribute(const char *sTagName, const OString &aValue)
void startElement(const char *sName)
const OUString & GetStyleName() const
Definition: font/font.cxx:905
const OUString & GetFamilyName() const
Definition: font/font.cxx:904
const Size & GetFontSize() const
Definition: font/font.cxx:907
const Color & GetColor() const
Definition: font/font.cxx:898
FontWeight GetWeight()
Definition: font/font.cxx:925
bool IsVertical() const
Definition: font/font.cxx:921
Degree10 GetOrientation() const
Definition: font/font.cxx:920
const Color & GetFillColor() const
Definition: font/font.cxx:899
tools::PolyPolygon GetAsPolyPolygon() const
Definition: region.cxx:1266
bool HasPolyPolygonOrB2DPolyPolygon() const
Definition: region.hxx:107
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1219
float u
float y
float x
std::deque< AttacherIndex_Impl > aIndex
FontLineStyle
LINESTYLE_BOLDDASHDOT
LINESTYLE_BOLDDASHDOTDOT
LINESTYLE_SINGLE
LINESTYLE_BOLDLONGDASH
LINESTYLE_BOLDWAVE
LINESTYLE_DASHDOTDOT
LINESTYLE_BOLDDASH
LINESTYLE_BOLDDOTTED
LINESTYLE_DOUBLEWAVE
LINESTYLE_DOUBLE
LINESTYLE_NONE
LINESTYLE_DASH
LINESTYLE_DONTKNOW
LINESTYLE_SMALLWAVE
LINESTYLE_DASHDOT
LINESTYLE_DOTTED
LINESTYLE_WAVE
LINESTYLE_LONGDASH
FontLineStyle_FORCE_EQUAL_SIZE
LINESTYLE_BOLD
FontStrikeout
STRIKEOUT_BOLD
STRIKEOUT_DOUBLE
STRIKEOUT_SINGLE
STRIKEOUT_X
STRIKEOUT_SLASH
FontStrikeout_FORCE_EQUAL_SIZE
STRIKEOUT_NONE
STRIKEOUT_DONTKNOW
TextAlign_FORCE_EQUAL_SIZE
ALIGN_BOTTOM
ALIGN_TOP
ALIGN_BASELINE
WEIGHT_ULTRALIGHT
WEIGHT_ULTRABOLD
WEIGHT_THIN
WEIGHT_BOLD
WEIGHT_NORMAL
WEIGHT_LIGHT
WEIGHT_DONTKNOW
WEIGHT_SEMIBOLD
WEIGHT_SEMILIGHT
FontWeight_FORCE_EQUAL_SIZE
WEIGHT_MEDIUM
WEIGHT_BLACK
uno_Any a
MapUnit
MetaActionType
HatchStyle
int i
TextAlign
FontWeight
long Long
ComplexTextLayoutFlags
Definition: State.hxx:76
PushFlags
Definition: State.hxx:40
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:20
PolyFlags
UNDERLYING_TYPE get() const
unsigned char sal_uInt8
LineStyle
Definition: vclenum.hxx:153
WallpaperStyle
Definition: wall.hxx:35