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