diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-01-30 09:18:53 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-01-30 15:24:43 +0000 |
commit | 2b95261bcc293b3adbebaa64764b91befc62fa30 (patch) | |
tree | 44c73359d68b25960408af59587617a2dfafcc8c /test | |
parent | 4a193d39fb785c75668c977cf6b40d11b0ef4afe (diff) |
expand SVM test (Mask, TextRect, TextLine) and mtfxmldump
Change-Id: I13e0882ac7093d6d3ab46914316f303e1ab01b93
Reviewed-on: https://gerrit.libreoffice.org/33686
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/mtfxmldump.cxx | 463 |
1 files changed, 292 insertions, 171 deletions
diff --git a/test/source/mtfxmldump.cxx b/test/source/mtfxmldump.cxx index ee2bd7a9d3ba..a59375a8c079 100644 --- a/test/source/mtfxmldump.cxx +++ b/test/source/mtfxmldump.cxx @@ -16,44 +16,11 @@ #include <rtl/strbuf.hxx> #include <memory> +#include <numeric> namespace { -OUString flagToString(PushFlags nFlag) -{ - if (nFlag & PushFlags::LINECOLOR) - return OUString("PushLineColor"); - else if (nFlag & PushFlags::FILLCOLOR) - return OUString("PushFillColor"); - else if (nFlag & PushFlags::FONT) - return OUString("PushFont"); - else if (nFlag & PushFlags::TEXTCOLOR) - return OUString("PushTextColor"); - else if (nFlag & PushFlags::MAPMODE) - return OUString("PushMapMode"); - else if (nFlag & PushFlags::CLIPREGION) - return OUString("PushClipRegion"); - else if (nFlag & PushFlags::RASTEROP) - return OUString("PushRasterOp"); - else if (nFlag & PushFlags::TEXTFILLCOLOR) - return OUString("PushTextFillColor"); - else if (nFlag & PushFlags::TEXTALIGN) - return OUString("PushTextAlign"); - else if (nFlag & PushFlags::REFPOINT) - return OUString("PushRefPoint"); - else if (nFlag & PushFlags::TEXTLINECOLOR) - return OUString("PushTextLineColor"); - else if (nFlag & PushFlags::TEXTLAYOUTMODE) - return OUString("PushTextLayoutMode"); - else if (nFlag & PushFlags::TEXTLANGUAGE) - return OUString("PushTextLanguage"); - else if (nFlag & PushFlags::OVERLINECOLOR) - return OUString("PushOverlineColor"); - - return OUString(); -} - OUString collectPushFlags(PushFlags nFlags) { if ((nFlags & PushFlags::ALL) == PushFlags::ALL) @@ -63,27 +30,103 @@ OUString collectPushFlags(PushFlags nFlags) else if ((nFlags & PUSH_ALLTEXT) == PUSH_ALLTEXT) return OUString("PushAllText"); - OUString sFlags; - - for (sal_uInt16 nFlag = 1; nFlag > 0; nFlag <<= 1) + std::vector<OUString> aStrings; + + if (nFlags & PushFlags::LINECOLOR) + aStrings.push_back("PushLineColor"); + if (nFlags & PushFlags::FILLCOLOR) + aStrings.push_back("PushFillColor"); + if (nFlags & PushFlags::FONT) + aStrings.push_back("PushFont"); + if (nFlags & PushFlags::TEXTCOLOR) + aStrings.push_back("PushTextColor"); + if (nFlags & PushFlags::MAPMODE) + aStrings.push_back("PushMapMode"); + if (nFlags & PushFlags::CLIPREGION) + aStrings.push_back("PushClipRegion"); + if (nFlags & PushFlags::RASTEROP) + aStrings.push_back("PushRasterOp"); + if (nFlags & PushFlags::TEXTFILLCOLOR) + aStrings.push_back("PushTextFillColor"); + if (nFlags & PushFlags::TEXTALIGN) + aStrings.push_back("PushTextAlign"); + if (nFlags & PushFlags::REFPOINT) + aStrings.push_back("PushRefPoint"); + if (nFlags & PushFlags::TEXTLINECOLOR) + aStrings.push_back("PushTextLineColor"); + if (nFlags & PushFlags::TEXTLAYOUTMODE) + aStrings.push_back("PushTextLayoutMode"); + if (nFlags & PushFlags::TEXTLANGUAGE) + aStrings.push_back("PushTextLanguage"); + if (nFlags & PushFlags::OVERLINECOLOR) + aStrings.push_back("PushOverlineColor"); + + OUString aString; + + if (aStrings.empty()) + return aString; + + aString = aStrings[0]; + for (size_t i = 1; i < aStrings.size(); ++i) { - if ((nFlag & sal_uInt16(nFlags)) == nFlag) - { - OUString sFlag = flagToString(static_cast<PushFlags>(nFlag)); - if (!sFlag.isEmpty()) - { - if (!sFlags.isEmpty()) - { - sFlags += ", "; - } - sFlags += flagToString(static_cast<PushFlags>(nFlag)); - } - } + aString = aString + ", " + aStrings[i]; } - - return sFlags; + return aString; } +OUString convertDrawTextFlagsToString(DrawTextFlags eDrawTextFlags) +{ + std::vector<OUString> aStrings; + if (eDrawTextFlags & DrawTextFlags::Disable) + aStrings.push_back("Disable"); + if (eDrawTextFlags & DrawTextFlags::Mnemonic) + aStrings.push_back("Mnemonic"); + if (eDrawTextFlags & DrawTextFlags::Mono) + aStrings.push_back("Mono"); + if (eDrawTextFlags & DrawTextFlags::Clip) + aStrings.push_back("Clip"); + if (eDrawTextFlags & DrawTextFlags::Left) + aStrings.push_back("Left"); + if (eDrawTextFlags & DrawTextFlags::Center) + aStrings.push_back("Center"); + if (eDrawTextFlags & DrawTextFlags::Right) + aStrings.push_back("Right"); + if (eDrawTextFlags & DrawTextFlags::Top) + aStrings.push_back("Top"); + if (eDrawTextFlags & DrawTextFlags::VCenter) + aStrings.push_back("VCenter"); + if (eDrawTextFlags & DrawTextFlags::Bottom) + aStrings.push_back("Bottom"); + if (eDrawTextFlags & DrawTextFlags::EndEllipsis) + aStrings.push_back("EndEllipsis"); + if (eDrawTextFlags & DrawTextFlags::PathEllipsis) + aStrings.push_back("PathEllipsis"); + if (eDrawTextFlags & DrawTextFlags::MultiLine) + aStrings.push_back("MultiLine"); + if (eDrawTextFlags & DrawTextFlags::WordBreak) + aStrings.push_back("WordBreak"); + if (eDrawTextFlags & DrawTextFlags::NewsEllipsis) + aStrings.push_back("NewsEllipsis"); + if (eDrawTextFlags & DrawTextFlags::WordBreakHyphenation) + aStrings.push_back("WordBreakHyphenation"); + if (eDrawTextFlags & DrawTextFlags::CenterEllipsis) + aStrings.push_back("CenterEllipsis"); + if (eDrawTextFlags & DrawTextFlags::HideMnemonic) + aStrings.push_back("HideMnemonic"); + + OUString aString; + + if (aStrings.empty()) + return OUString("None"); + + aString = aStrings[0]; + for (size_t i = 1; i < aStrings.size(); ++i) + { + aString = aString + " " + aStrings[i]; + } + return aString; +}; + OUString convertRopToString(RasterOp eRop) { switch (eRop) @@ -155,19 +198,15 @@ OUString convertPolygonFlags(PolyFlags eFlags) switch (eFlags) { default: - case PolyFlags::Normal: return OUString("normal"); - case PolyFlags::Control: return OUString("control"); - case PolyFlags::Smooth: return OUString("smooth"); - case PolyFlags::Symmetric: return OUString("symmetric"); + case PolyFlags::Normal: return OUString("normal"); + case PolyFlags::Control: return OUString("control"); + case PolyFlags::Smooth: return OUString("smooth"); + case PolyFlags::Symmetric: return OUString("symmetric"); } } OUString convertFontWeigthToString(FontWeight eFontWeight) { - enum FontWeight { WEIGHT_DONTKNOW, WEIGHT_THIN, WEIGHT_ULTRALIGHT, - WEIGHT_LIGHT, WEIGHT_SEMILIGHT, WEIGHT_NORMAL, - WEIGHT_MEDIUM, WEIGHT_SEMIBOLD, WEIGHT_BOLD, - WEIGHT_ULTRABOLD, WEIGHT_BLACK, FontWeight_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; switch (eFontWeight) { case WEIGHT_DONTKNOW: return OUString("unknown"); @@ -181,7 +220,51 @@ OUString convertFontWeigthToString(FontWeight eFontWeight) case WEIGHT_BOLD: return OUString("bold"); case WEIGHT_ULTRABOLD: return OUString("ultrabold"); case WEIGHT_BLACK: return OUString("black"); - case FontWeight_FORCE_EQUAL_SIZE: return OUString("equalsize"); + case FontWeight_FORCE_EQUAL_SIZE: return OUString("equalsize"); + } + return OUString(); +} + +OUString convertFontStrikeoutToString(FontStrikeout eFontStrikeout) +{ + switch (eFontStrikeout) + { + case STRIKEOUT_NONE: return OUString("none"); + case STRIKEOUT_SINGLE: return OUString("single"); + case STRIKEOUT_DOUBLE: return OUString("double"); + case STRIKEOUT_DONTKNOW: return OUString("dontknow"); + case STRIKEOUT_BOLD: return OUString("bold"); + case STRIKEOUT_SLASH: return OUString("slash"); + case STRIKEOUT_X: return OUString("x"); + case FontStrikeout_FORCE_EQUAL_SIZE: return OUString("equalsize"); + } + return OUString(); +} + +OUString convertFontLineStyleToString(FontLineStyle eFontLineStyle) +{ + switch (eFontLineStyle) + { + case LINESTYLE_NONE: return OUString("none"); + case LINESTYLE_SINGLE: return OUString("single"); + case LINESTYLE_DOUBLE: return OUString("double"); + case LINESTYLE_DOTTED: return OUString("dotted"); + case LINESTYLE_DONTKNOW: return OUString("dontknow"); + case LINESTYLE_DASH: return OUString("dash"); + case LINESTYLE_LONGDASH: return OUString("longdash"); + case LINESTYLE_DASHDOT: return OUString("dashdot"); + case LINESTYLE_DASHDOTDOT: return OUString("dashdotdot"); + case LINESTYLE_SMALLWAVE: return OUString("smallwave"); + case LINESTYLE_WAVE: return OUString("wave"); + case LINESTYLE_DOUBLEWAVE: return OUString("doublewave"); + case LINESTYLE_BOLD: return OUString("bold"); + case LINESTYLE_BOLDDOTTED: return OUString("bolddotted"); + case LINESTYLE_BOLDDASH: return OUString("bolddash"); + case LINESTYLE_BOLDLONGDASH: return OUString("boldlongdash"); + case LINESTYLE_BOLDDASHDOT: return OUString("bolddashdot"); + case LINESTYLE_BOLDDASHDOTDOT: return OUString("bolddashdotdot"); + case LINESTYLE_BOLDWAVE: return OUString("boldwave"); + case FontLineStyle_FORCE_EQUAL_SIZE: return OUString("equalsize"); } return OUString(); } @@ -267,6 +350,51 @@ OUString hex32(sal_uInt32 nNumber) return OUString::createFromAscii(ss.str().c_str()); } +void writePoint(XmlWriter& rWriter, Point const& rPoint) +{ + rWriter.attribute("x", rPoint.X()); + rWriter.attribute("y", rPoint.Y()); +} + +void writeStartPoint(XmlWriter& rWriter, Point const& rPoint) +{ + rWriter.attribute("startx", rPoint.X()); + rWriter.attribute("starty", rPoint.Y()); +} + +void writeEndPoint(XmlWriter& rWriter, Point const& rPoint) +{ + rWriter.attribute("endx", rPoint.X()); + rWriter.attribute("endy", rPoint.Y()); +} + +void writeSize(XmlWriter& rWriter, Size const& rSize) +{ + rWriter.attribute("width", rSize.Width()); + rWriter.attribute("height", rSize.Height()); +} + +void writeRectangle(XmlWriter& rWriter, Rectangle const& rRectangle) +{ + rWriter.attribute("left", rRectangle.Left()); + rWriter.attribute("top", rRectangle.Top()); + rWriter.attribute("right", rRectangle.Right()); + rWriter.attribute("bottom", rRectangle.Bottom()); +} + +void writeLineInfo(XmlWriter& rWriter, LineInfo const& rLineInfo) +{ + rWriter.attribute("style", convertLineStyleToString(rLineInfo.GetStyle())); + rWriter.attribute("width", rLineInfo.GetWidth()); + rWriter.attribute("dashlen", rLineInfo.GetDashLen()); + rWriter.attribute("dashcount", rLineInfo.GetDashCount()); + rWriter.attribute("dotlen", rLineInfo.GetDotLen()); + rWriter.attribute("dotcount", rLineInfo.GetDotCount()); + rWriter.attribute("distance", rLineInfo.GetDistance()); + rWriter.attribute("join", convertLineJoinToString(rLineInfo.GetLineJoin())); + rWriter.attribute("cap", convertLineCapToString(rLineInfo.GetLineCap())); +} + } // anonymous namespace MetafileXmlDump::MetafileXmlDump() @@ -329,8 +457,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto* pMetaAction = static_cast<MetaPixelAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMetaAction->GetPoint().X()); - rWriter.attribute("y", pMetaAction->GetPoint().Y()); + writePoint(rWriter, pMetaAction->GetPoint()); rWriter.attribute("color", convertColorToString(pMetaAction->GetColor())); rWriter.endElement(); } @@ -340,8 +467,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto* pMetaAction = static_cast<MetaPointAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMetaAction->GetPoint().X()); - rWriter.attribute("y", pMetaAction->GetPoint().Y()); + writePoint(rWriter, pMetaAction->GetPoint()); rWriter.endElement(); } break; @@ -350,10 +476,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { MetaRectAction* pMetaAction = static_cast<MetaRectAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("left", pMetaAction->GetRect().Left()); - rWriter.attribute("top", pMetaAction->GetRect().Top()); - rWriter.attribute("right", pMetaAction->GetRect().Right()); - rWriter.attribute("bottom", pMetaAction->GetRect().Bottom()); + writeRectangle(rWriter, pMetaAction->GetRect()); rWriter.endElement(); } break; @@ -362,10 +485,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMetaAction = static_cast<MetaRoundRectAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("left", pMetaAction->GetRect().Left()); - rWriter.attribute("top", pMetaAction->GetRect().Top()); - rWriter.attribute("right", pMetaAction->GetRect().Right()); - rWriter.attribute("bottom", pMetaAction->GetRect().Bottom()); + writeRectangle(rWriter, pMetaAction->GetRect()); rWriter.attribute("horizontalround", pMetaAction->GetHorzRound()); rWriter.attribute("verticalround", pMetaAction->GetVertRound()); rWriter.endElement(); @@ -376,10 +496,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMetaAction = static_cast<MetaEllipseAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("left", pMetaAction->GetRect().Left()); - rWriter.attribute("top", pMetaAction->GetRect().Top()); - rWriter.attribute("right", pMetaAction->GetRect().Right()); - rWriter.attribute("bottom", pMetaAction->GetRect().Bottom()); + writeRectangle(rWriter, pMetaAction->GetRect()); rWriter.endElement(); } break; @@ -388,16 +505,9 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMetaAction = static_cast<MetaArcAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("left", pMetaAction->GetRect().Left()); - rWriter.attribute("top", pMetaAction->GetRect().Top()); - rWriter.attribute("right", pMetaAction->GetRect().Right()); - rWriter.attribute("bottom", pMetaAction->GetRect().Bottom()); - - rWriter.attribute("startx", pMetaAction->GetStartPoint().X()); - rWriter.attribute("starty", pMetaAction->GetStartPoint().Y()); - rWriter.attribute("endx", pMetaAction->GetEndPoint().X()); - rWriter.attribute("endy", pMetaAction->GetEndPoint().Y()); - + writeRectangle(rWriter, pMetaAction->GetRect()); + writeStartPoint(rWriter, pMetaAction->GetStartPoint()); + writeEndPoint(rWriter, pMetaAction->GetEndPoint()); rWriter.endElement(); } break; @@ -406,16 +516,9 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMetaAction = static_cast<MetaPieAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("left", pMetaAction->GetRect().Left()); - rWriter.attribute("top", pMetaAction->GetRect().Top()); - rWriter.attribute("right", pMetaAction->GetRect().Right()); - rWriter.attribute("bottom", pMetaAction->GetRect().Bottom()); - - rWriter.attribute("startx", pMetaAction->GetStartPoint().X()); - rWriter.attribute("starty", pMetaAction->GetStartPoint().Y()); - rWriter.attribute("endx", pMetaAction->GetEndPoint().X()); - rWriter.attribute("endy", pMetaAction->GetEndPoint().Y()); - + writeRectangle(rWriter, pMetaAction->GetRect()); + writeStartPoint(rWriter, pMetaAction->GetStartPoint()); + writeEndPoint(rWriter, pMetaAction->GetEndPoint()); rWriter.endElement(); } break; @@ -424,16 +527,9 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMetaAction = static_cast<MetaChordAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("left", pMetaAction->GetRect().Left()); - rWriter.attribute("top", pMetaAction->GetRect().Top()); - rWriter.attribute("right", pMetaAction->GetRect().Right()); - rWriter.attribute("bottom", pMetaAction->GetRect().Bottom()); - - rWriter.attribute("startx", pMetaAction->GetStartPoint().X()); - rWriter.attribute("starty", pMetaAction->GetStartPoint().Y()); - rWriter.attribute("endx", pMetaAction->GetEndPoint().X()); - rWriter.attribute("endy", pMetaAction->GetEndPoint().Y()); - + writeRectangle(rWriter, pMetaAction->GetRect()); + writeStartPoint(rWriter, pMetaAction->GetStartPoint()); + writeEndPoint(rWriter, pMetaAction->GetEndPoint()); rWriter.endElement(); } break; @@ -442,22 +538,11 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { MetaLineAction* pMetaLineAction = static_cast<MetaLineAction*>(pAction); rWriter.startElement(sCurrentElementTag); - - rWriter.attribute("startx", pMetaLineAction->GetStartPoint().X()); - rWriter.attribute("starty", pMetaLineAction->GetStartPoint().Y()); - rWriter.attribute("endx", pMetaLineAction->GetEndPoint().X()); - rWriter.attribute("endy", pMetaLineAction->GetEndPoint().Y()); + writeStartPoint(rWriter, pMetaLineAction->GetStartPoint()); + writeEndPoint(rWriter, pMetaLineAction->GetEndPoint()); LineInfo aLineInfo = pMetaLineAction->GetLineInfo(); - rWriter.attribute("style", convertLineStyleToString(aLineInfo.GetStyle())); - rWriter.attribute("width", aLineInfo.GetWidth()); - rWriter.attribute("dashlen", aLineInfo.GetDashLen()); - rWriter.attribute("dashcount", aLineInfo.GetDashCount()); - rWriter.attribute("dotlen", aLineInfo.GetDotLen()); - rWriter.attribute("dotcount", aLineInfo.GetDotCount()); - rWriter.attribute("distance", aLineInfo.GetDistance()); - rWriter.attribute("join", convertLineJoinToString(aLineInfo.GetLineJoin())); - rWriter.attribute("cap", convertLineCapToString(aLineInfo.GetLineCap())); + writeLineInfo(rWriter, pMetaLineAction->GetLineInfo()); rWriter.endElement(); } break; @@ -559,12 +644,9 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto* pMeta = static_cast<MetaTextAction*>(pAction); rWriter.startElement(sCurrentElementTag); - - rWriter.attribute("x", pMeta->GetPoint().X()); - rWriter.attribute("y", pMeta->GetPoint().Y()); + writePoint(rWriter, pMeta->GetPoint()); rWriter.attribute("index", pMeta->GetIndex()); rWriter.attribute("length", pMeta->GetLen()); - rWriter.startElement("textcontent"); rWriter.content(pMeta->GetText()); rWriter.endElement(); @@ -581,8 +663,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) sal_Int32 aIndex = pMetaTextArrayAction->GetIndex(); sal_Int32 aLength = pMetaTextArrayAction->GetLen(); - rWriter.attribute("x", pMetaTextArrayAction->GetPoint().X()); - rWriter.attribute("y", pMetaTextArrayAction->GetPoint().Y()); + writePoint(rWriter, pMetaTextArrayAction->GetPoint()); rWriter.attribute("index", aIndex); rWriter.attribute("length", aLength); @@ -612,8 +693,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) auto* pMeta = static_cast<MetaStretchTextAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMeta->GetPoint().X()); - rWriter.attribute("y", pMeta->GetPoint().Y()); + writePoint(rWriter, pMeta->GetPoint()); rWriter.attribute("index", pMeta->GetIndex()); rWriter.attribute("length", pMeta->GetLen()); rWriter.attribute("width", pMeta->GetWidth()); @@ -626,6 +706,36 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) } break; + case MetaActionType::TEXTRECT: + { + auto* pMeta = static_cast<MetaTextRectAction*>(pAction); + rWriter.startElement(sCurrentElementTag); + writeRectangle(rWriter, pMeta->GetRect()); + rWriter.startElement("textcontent"); + rWriter.content(pMeta->GetText()); + rWriter.endElement(); + + rWriter.startElement("style"); + rWriter.content(convertDrawTextFlagsToString(pMeta->GetStyle())); + rWriter.endElement(); + + rWriter.endElement(); + } + break; + + case MetaActionType::TEXTLINE: + { + auto* pMeta = static_cast<MetaTextLineAction*>(pAction); + rWriter.startElement(sCurrentElementTag); + writePoint(rWriter, pMeta->GetStartPoint()); + rWriter.attribute("width", pMeta->GetWidth()); + rWriter.attribute("strikeout", convertFontStrikeoutToString(pMeta->GetStrikeout())); + rWriter.attribute("underline", convertFontLineStyleToString(pMeta->GetUnderline())); + rWriter.attribute("overline", convertFontLineStyleToString(pMeta->GetOverline())); + rWriter.endElement(); + } + break; + case MetaActionType::LINECOLOR: { MetaLineColorAction* pMetaLineColorAction = static_cast<MetaLineColorAction*>(pAction); @@ -655,11 +765,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) // enough for the tests we have, but may need extending to // dumping the real polypolygon in the future Rectangle aRectangle = pA->GetRegion().GetBoundRect(); - rWriter.attribute("top", aRectangle.Top()); - rWriter.attribute("left", aRectangle.Left()); - rWriter.attribute("bottom", aRectangle.Bottom()); - rWriter.attribute("right", aRectangle.Right()); - + writeRectangle(rWriter, aRectangle); rWriter.endElement(); } break; @@ -670,11 +776,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) rWriter.startElement(sCurrentElementTag); Rectangle aRectangle = pMetaISectRectClipRegionAction->GetRect(); - rWriter.attribute("top", aRectangle.Top()); - rWriter.attribute("left", aRectangle.Left()); - rWriter.attribute("bottom", aRectangle.Bottom()); - rWriter.attribute("right", aRectangle.Right()); - + writeRectangle(rWriter, aRectangle); rWriter.endElement(); } break; @@ -688,11 +790,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) // enough for the tests we have, but may need extending to // dumping the real polypolygon in the future Rectangle aRectangle = pMetaISectRegionClipRegionAction->GetRegion().GetBoundRect(); - rWriter.attribute("top", aRectangle.Top()); - rWriter.attribute("left", aRectangle.Left()); - rWriter.attribute("bottom", aRectangle.Bottom()); - rWriter.attribute("right", aRectangle.Right()); - + writeRectangle(rWriter, aRectangle); rWriter.endElement(); } break; @@ -702,24 +800,14 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) MetaPolyLineAction* pMetaPolyLineAction = static_cast<MetaPolyLineAction*>(pAction); rWriter.startElement(sCurrentElementTag); - LineInfo aLineInfo = pMetaPolyLineAction->GetLineInfo(); - rWriter.attribute("style", convertLineStyleToString(aLineInfo.GetStyle())); - rWriter.attribute("width", aLineInfo.GetWidth()); - rWriter.attribute("dashlen", aLineInfo.GetDashLen()); - rWriter.attribute("dashcount", aLineInfo.GetDashCount()); - rWriter.attribute("dotlen", aLineInfo.GetDotLen()); - rWriter.attribute("dotcount", aLineInfo.GetDotCount()); - rWriter.attribute("distance", aLineInfo.GetDistance()); - rWriter.attribute("join", convertLineJoinToString(aLineInfo.GetLineJoin())); - rWriter.attribute("cap", convertLineCapToString(aLineInfo.GetLineCap())); + writeLineInfo(rWriter, pMetaPolyLineAction->GetLineInfo()); tools::Polygon aPolygon = pMetaPolyLineAction->GetPolygon(); bool bFlags = aPolygon.HasFlags(); for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++) { rWriter.startElement("point"); - rWriter.attribute("x", aPolygon[i].X()); - rWriter.attribute("y", aPolygon[i].Y()); + writePoint(rWriter, aPolygon[i]); if (bFlags) rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i))); rWriter.endElement(); @@ -739,8 +827,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++) { rWriter.startElement("point"); - rWriter.attribute("x", aPolygon[i].X()); - rWriter.attribute("y", aPolygon[i].Y()); + writePoint(rWriter, aPolygon[i]); if (bFlags) rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i))); rWriter.endElement(); @@ -765,8 +852,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i) { rWriter.startElement("point"); - rWriter.attribute("x", rPolygon[i].X()); - rWriter.attribute("y", rPolygon[i].Y()); + writePoint(rWriter, rPolygon[i]); if (bFlags) rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i))); rWriter.endElement(); @@ -802,8 +888,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMeta = static_cast<MetaBmpAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMeta->GetPoint().X()); - rWriter.attribute("y", pMeta->GetPoint().Y()); + writePoint(rWriter, pMeta->GetPoint()); rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum())); rWriter.endElement(); } @@ -813,10 +898,8 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMeta = static_cast<MetaBmpScaleAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMeta->GetPoint().X()); - rWriter.attribute("y", pMeta->GetPoint().Y()); - rWriter.attribute("width", pMeta->GetSize().Width()); - rWriter.attribute("height", pMeta->GetSize().Height()); + writePoint(rWriter, pMeta->GetPoint()); + writeSize(rWriter, pMeta->GetSize()); rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum())); rWriter.endElement(); } @@ -843,8 +926,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMeta = static_cast<MetaBmpExAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMeta->GetPoint().X()); - rWriter.attribute("y", pMeta->GetPoint().Y()); + writePoint(rWriter, pMeta->GetPoint()); rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum())); rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType())); rWriter.endElement(); @@ -855,10 +937,8 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) { auto pMeta = static_cast<MetaBmpExScaleAction*>(pAction); rWriter.startElement(sCurrentElementTag); - rWriter.attribute("x", pMeta->GetPoint().X()); - rWriter.attribute("y", pMeta->GetPoint().Y()); - rWriter.attribute("width", pMeta->GetSize().Width()); - rWriter.attribute("height", pMeta->GetSize().Height()); + writePoint(rWriter, pMeta->GetPoint()); + writeSize(rWriter, pMeta->GetSize()); rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum())); rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType())); rWriter.endElement(); @@ -883,6 +963,47 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter) } break; + case MetaActionType::MASK: + { + auto pMeta = static_cast<MetaMaskAction*>(pAction); + rWriter.startElement(sCurrentElementTag); + writePoint(rWriter, pMeta->GetPoint()); + rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum())); + rWriter.attribute("color", convertColorToString(pMeta->GetColor())); + rWriter.endElement(); + } + break; + + case MetaActionType::MASKSCALE: + { + auto pMeta = static_cast<MetaMaskScaleAction*>(pAction); + rWriter.startElement(sCurrentElementTag); + writePoint(rWriter, pMeta->GetPoint()); + writeSize(rWriter, pMeta->GetSize()); + rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum())); + rWriter.attribute("color", convertColorToString(pMeta->GetColor())); + rWriter.endElement(); + } + break; + + case MetaActionType::MASKSCALEPART: + { + auto pMeta = static_cast<MetaMaskScalePartAction*>(pAction); + rWriter.startElement(sCurrentElementTag); + rWriter.attribute("destx", pMeta->GetDestPoint().X()); + rWriter.attribute("desty", pMeta->GetDestPoint().Y()); + rWriter.attribute("destwidth", pMeta->GetDestSize().Width()); + rWriter.attribute("destheight", pMeta->GetDestSize().Height()); + rWriter.attribute("srcx", pMeta->GetSrcPoint().X()); + rWriter.attribute("srcy", pMeta->GetSrcPoint().Y()); + rWriter.attribute("srcwidth", pMeta->GetSrcSize().Width()); + rWriter.attribute("srcheight", pMeta->GetSrcSize().Height()); + rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum())); + rWriter.attribute("color", convertColorToString(pMeta->GetColor())); + rWriter.endElement(); + } + break; + default: { rWriter.element(sCurrentElementTag); |