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