Kaydet (Commit) c807d4d7 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

update Metafile dumper and change the order of MetaActions

Change-Id: Ib851156da20528e7df5197ba96c35727af7bdbb6
Reviewed-on: https://gerrit.libreoffice.org/71492
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 8f03bdee
......@@ -391,10 +391,43 @@ OUString convertGradientStyle(GradientStyle eStyle)
return OUString();
}
OUString convertHatchStyle(HatchStyle eStyle)
{
switch (eStyle)
{
case HatchStyle::Single: return OUString("Single");
case HatchStyle::Double: return OUString("Double");
case HatchStyle::Triple: return OUString("Triple");
case HatchStyle::FORCE_EQUAL_SIZE: return OUString("ForceEqualSize");
}
return OUString();
}
OUString convertWallpaperStyleToString(WallpaperStyle eWallpaperStyle)
{
switch (eWallpaperStyle)
{
case WallpaperStyle::NONE: return OUString("NONE");
case WallpaperStyle::Tile: return OUString("Tile");
case WallpaperStyle::Center: return OUString("Center");
case WallpaperStyle::Scale: return OUString("Scale");
case WallpaperStyle::TopLeft: return OUString("TopLeft");
case WallpaperStyle::Top: return OUString("Top");
case WallpaperStyle::TopRight: return OUString("TopRight");
case WallpaperStyle::Left: return OUString("Left");
case WallpaperStyle::Right: return OUString("Right");
case WallpaperStyle::BottomLeft: return OUString("BottomLeft");
case WallpaperStyle::Bottom: return OUString("Bottom");
case WallpaperStyle::BottomRight: return OUString("BottomRight");
case WallpaperStyle::ApplicationGradient: return OUString("ApplicationGradient");
}
return OUString();
}
OUString hex32(sal_uInt32 nNumber)
{
std::stringstream ss;
ss << std::hex << std::setfill ('0') << std::setw(8) << nNumber;
ss << std::hex << std::setfill('0') << std::setw(8) << nNumber;
return OUString::createFromAscii(ss.str().c_str());
}
......@@ -443,6 +476,20 @@ void writeLineInfo(tools::XmlWriter& rWriter, LineInfo const& rLineInfo)
rWriter.attribute("cap", convertLineCapToString(rLineInfo.GetLineCap()));
}
void writeGradient(tools::XmlWriter& rWriter, Gradient const& rGradient)
{
rWriter.attribute("style", convertGradientStyle(rGradient.GetStyle()));
rWriter.attribute("startcolor", convertColorToString(rGradient.GetStartColor()));
rWriter.attribute("endcolor", convertColorToString(rGradient.GetEndColor()));
rWriter.attribute("angle", rGradient.GetAngle());
rWriter.attribute("border", rGradient.GetBorder());
rWriter.attribute("offsetx", rGradient.GetOfsX());
rWriter.attribute("offsety", rGradient.GetOfsY());
rWriter.attribute("startintensity", rGradient.GetStartIntensity());
rWriter.attribute("endintensity", rGradient.GetEndIntensity());
rWriter.attribute("steps", rGradient.GetSteps());
}
} // anonymous namespace
MetafileXmlDump::MetafileXmlDump()
......@@ -488,6 +535,13 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
switch (nActionType)
{
case MetaActionType::NONE:
{
rWriter.startElement(sCurrentElementTag);
rWriter.endElement();
}
break;
case MetaActionType::PIXEL:
{
auto* pMetaAction = static_cast<MetaPixelAction*>(pAction);
......@@ -507,6 +561,18 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
case MetaActionType::LINE:
{
MetaLineAction* pMetaLineAction = static_cast<MetaLineAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writeStartPoint(rWriter, pMetaLineAction->GetStartPoint());
writeEndPoint(rWriter, pMetaLineAction->GetEndPoint());
writeLineInfo(rWriter, pMetaLineAction->GetLineInfo());
rWriter.endElement();
}
break;
case MetaActionType::RECT:
{
MetaRectAction* pMetaAction = static_cast<MetaRectAction*>(pAction);
......@@ -569,107 +635,71 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
case MetaActionType::LINE:
{
MetaLineAction* pMetaLineAction = static_cast<MetaLineAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writeStartPoint(rWriter, pMetaLineAction->GetStartPoint());
writeEndPoint(rWriter, pMetaLineAction->GetEndPoint());
writeLineInfo(rWriter, pMetaLineAction->GetLineInfo());
rWriter.endElement();
}
break;
case MetaActionType::PUSH:
case MetaActionType::POLYLINE:
{
MetaPushAction* pMetaPushAction = static_cast<MetaPushAction*>(pAction);
MetaPolyLineAction* pMetaPolyLineAction = static_cast<MetaPolyLineAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("flags", collectPushFlags(pMetaPushAction->GetFlags()));
}
break;
case MetaActionType::POP:
{
rWriter.endElement();
}
break;
case MetaActionType::RASTEROP:
{
MetaRasterOpAction* pMetaRasterOpAction = static_cast<MetaRasterOpAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writeLineInfo(rWriter, pMetaPolyLineAction->GetLineInfo());
if (pMetaRasterOpAction->GetRasterOp() != RasterOp::OverPaint)
tools::Polygon aPolygon = pMetaPolyLineAction->GetPolygon();
bool bFlags = aPolygon.HasFlags();
for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++)
{
rWriter.attribute("operation", convertRopToString(pMetaRasterOpAction->GetRasterOp()));
rWriter.startElement("point");
writePoint(rWriter, aPolygon[i]);
if (bFlags)
rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i)));
rWriter.endElement();
}
rWriter.endElement();
}
break;
case MetaActionType::TEXTLINECOLOR:
{
MetaTextLineColorAction* pMetaTextLineColorAction = static_cast<MetaTextLineColorAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("color", convertColorToString(pMetaTextLineColorAction->GetColor()));
rWriter.endElement();
}
break;
case MetaActionType::TEXTFILLCOLOR:
case MetaActionType::POLYGON:
{
MetaTextFillColorAction* pMetaTextFillColorAction = static_cast<MetaTextFillColorAction*>(pAction);
MetaPolygonAction* pMetaPolygonAction = static_cast<MetaPolygonAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("color", convertColorToString(pMetaTextFillColorAction->GetColor()));
if (pMetaTextFillColorAction->IsSetting())
rWriter.attribute("setting", OUString("true"));
tools::Polygon aPolygon = pMetaPolygonAction->GetPolygon();
bool bFlags = aPolygon.HasFlags();
for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++)
{
rWriter.startElement("point");
writePoint(rWriter, aPolygon[i]);
if (bFlags)
rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i)));
rWriter.endElement();
}
rWriter.endElement();
}
break;
case MetaActionType::FONT:
case MetaActionType::POLYPOLYGON:
{
MetaFontAction* pMetaFontAction = static_cast<MetaFontAction*>(pAction);
MetaPolyPolygonAction *const pMetaPolyPolygonAction = static_cast<MetaPolyPolygonAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
vcl::Font aFont = pMetaFontAction->GetFont();
rWriter.attribute("color", convertColorToString(aFont.GetColor()));
rWriter.attribute("fillcolor", convertColorToString(aFont.GetFillColor()));
rWriter.attribute("name", aFont.GetFamilyName());
rWriter.attribute("stylename", aFont.GetStyleName());
rWriter.attribute("width", aFont.GetFontSize().Width());
rWriter.attribute("height", aFont.GetFontSize().Height());
rWriter.attribute("orientation", aFont.GetOrientation());
rWriter.attribute("weight", convertFontWeigthToString(aFont.GetWeight()));
rWriter.endElement();
}
break;
case MetaActionType::TEXTALIGN:
{
MetaTextAlignAction* pMetaTextAlignAction = static_cast<MetaTextAlignAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
OUString sAlign = convertTextAlignToString(pMetaTextAlignAction->GetTextAlign());
if (!sAlign.isEmpty())
rWriter.attribute("align", sAlign);
rWriter.endElement();
}
break;
tools::PolyPolygon const& rPolyPolygon(pMetaPolyPolygonAction->GetPolyPolygon());
case MetaActionType::TEXTCOLOR:
{
MetaTextColorAction* pMetaTextColorAction = static_cast<MetaTextColorAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
{
rWriter.startElement("polygon");
tools::Polygon const& rPolygon = rPolyPolygon[j];
bool bFlags = rPolygon.HasFlags();
for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
{
rWriter.startElement("point");
writePoint(rWriter, rPolygon[i]);
if (bFlags)
rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
rWriter.endElement();
}
rWriter.endElement();
}
rWriter.attribute("color", convertColorToString(pMetaTextColorAction->GetColor()));
rWriter.endElement();
}
break;
......@@ -757,126 +787,147 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
case MetaActionType::TEXTLINE:
case MetaActionType::BMP:
{
auto* pMeta = static_cast<MetaTextLineAction*>(pAction);
auto pMeta = static_cast<MetaBmpAction*>(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()));
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
rWriter.endElement();
}
break;
case MetaActionType::LINECOLOR:
case MetaActionType::BMPSCALE:
{
MetaLineColorAction* pMetaLineColorAction = static_cast<MetaLineColorAction*>(pAction);
auto pMeta = static_cast<MetaBmpScaleAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("color", convertColorToString(pMetaLineColorAction->GetColor()));
writePoint(rWriter, pMeta->GetPoint());
writeSize(rWriter, pMeta->GetSize());
rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
rWriter.endElement();
}
break;
case MetaActionType::FILLCOLOR:
case MetaActionType::BMPSCALEPART:
{
MetaFillColorAction* pMetaFillColorAction = static_cast<MetaFillColorAction*>(pAction);
auto pMeta = static_cast<MetaBmpScalePartAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("color", convertColorToString(pMetaFillColorAction->GetColor()));
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.endElement();
}
break;
case MetaActionType::CLIPREGION:
case MetaActionType::BMPEX:
{
const MetaClipRegionAction* pA = static_cast< const MetaClipRegionAction* >(pAction);
auto pMeta = static_cast<MetaBmpExAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
// FIXME for now we dump only the bounding box; this is
// enough for the tests we have, but may need extending to
// dumping the real polypolygon in the future
tools::Rectangle aRectangle = pA->GetRegion().GetBoundRect();
writeRectangle(rWriter, aRectangle);
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum()));
rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
rWriter.endElement();
}
break;
case MetaActionType::ISECTRECTCLIPREGION:
case MetaActionType::BMPEXSCALE:
{
MetaISectRectClipRegionAction* pMetaISectRectClipRegionAction = static_cast<MetaISectRectClipRegionAction*>(pAction);
auto pMeta = static_cast<MetaBmpExScaleAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
tools::Rectangle aRectangle = pMetaISectRectClipRegionAction->GetRect();
writeRectangle(rWriter, aRectangle);
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();
}
break;
case MetaActionType::ISECTREGIONCLIPREGION:
case MetaActionType::BMPEXSCALEPART:
{
MetaISectRegionClipRegionAction* pMetaISectRegionClipRegionAction = static_cast<MetaISectRegionClipRegionAction*>(pAction);
auto pMeta = static_cast<MetaBmpExScalePartAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
// FIXME for now we dump only the bounding box; this is
// enough for the tests we have, but may need extending to
// dumping the real polypolygon in the future
tools::Rectangle aRectangle = pMetaISectRegionClipRegionAction->GetRegion().GetBoundRect();
writeRectangle(rWriter, aRectangle);
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->GetBitmapEx().GetBitmap().GetChecksum()));
rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
rWriter.endElement();
}
break;
case MetaActionType::POLYLINE:
case MetaActionType::MASK:
{
MetaPolyLineAction* pMetaPolyLineAction = static_cast<MetaPolyLineAction*>(pAction);
auto pMeta = static_cast<MetaMaskAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
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");
writePoint(rWriter, aPolygon[i]);
if (bFlags)
rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i)));
rWriter.endElement();
}
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
rWriter.attribute("color", convertColorToString(pMeta->GetColor()));
rWriter.endElement();
}
break;
case MetaActionType::POLYGON:
case MetaActionType::MASKSCALE:
{
MetaPolygonAction* pMetaPolygonAction = static_cast<MetaPolygonAction*>(pAction);
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;
tools::Polygon aPolygon = pMetaPolygonAction->GetPolygon();
bool bFlags = aPolygon.HasFlags();
for (sal_uInt16 i = 0; i < aPolygon.GetSize(); i++)
{
rWriter.startElement("point");
writePoint(rWriter, aPolygon[i]);
if (bFlags)
rWriter.attribute("flags", convertPolygonFlags(aPolygon.GetFlags(i)));
rWriter.endElement();
}
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;
case MetaActionType::POLYPOLYGON:
case MetaActionType::GRADIENT:
{
MetaPolyPolygonAction *const pMetaPolyPolygonAction = static_cast<MetaPolyPolygonAction*>(pAction);
const MetaGradientAction* pMeta = static_cast<MetaGradientAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writeGradient(rWriter, pMeta->GetGradient());
tools::PolyPolygon const& rPolyPolygon(pMetaPolyPolygonAction->GetPolyPolygon());
rWriter.startElement("rectangle");
writeRectangle(rWriter, pMeta->GetRect());
rWriter.endElement();
rWriter.endElement();
}
break;
case MetaActionType::HATCH:
{
auto* const pMetaHatchAction = static_cast<MetaHatchAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
tools::PolyPolygon const& rPolyPolygon(pMetaHatchAction->GetPolyPolygon());
for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
{
......@@ -894,146 +945,162 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
rWriter.endElement();
}
rWriter.startElement("hatch");
const auto& rHatch = pMetaHatchAction->GetHatch();
rWriter.attribute("style", convertHatchStyle(rHatch.GetStyle()));
rWriter.attribute("color", convertColorToString(rHatch.GetColor()));
rWriter.attribute("distance", sal_Int32(rHatch.GetDistance()));
rWriter.attribute("angle", sal_Int32(rHatch.GetAngle()));
rWriter.endElement();
rWriter.endElement();
}
break;
case MetaActionType::COMMENT:
case MetaActionType::WALLPAPER:
{
MetaCommentAction* pMetaCommentAction = static_cast<MetaCommentAction*>(pAction);
const auto* pMetaAction = static_cast<const MetaWallpaperAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
if (pMetaCommentAction->GetDataSize() > 0)
writeRectangle(rWriter, pMetaAction->GetRect());
rWriter.startElement("wallpaper");
const auto& rWallpaper = pMetaAction->GetWallpaper();
rWriter.attribute("color", convertColorToString(rWallpaper.GetColor()));
WallpaperStyle eStyle = rWallpaper.GetStyle();
rWriter.attribute("style", convertWallpaperStyleToString(eStyle));
if (rWallpaper.IsBitmap())
{
rWriter.attribute("datasize", pMetaCommentAction->GetDataSize());
rWriter.startElement("bitmap");
BitmapEx const & rBitmapEx = rWallpaper.GetBitmap();
rWriter.attribute("crc", hex32(rBitmapEx.GetChecksum()));
rWriter.attribute("transparenttype", convertBitmapExTransparentType(rBitmapEx.GetTransparentType()));
rWriter.attribute("bitcount", hex32(rBitmapEx.GetBitmap().GetBitCount()));
rWriter.attribute("width", hex32(rBitmapEx.GetSizePixel().Width()));
rWriter.attribute("height", hex32(rBitmapEx.GetSizePixel().Height()));
rWriter.endElement();
}
if (!pMetaCommentAction->GetComment().isEmpty())
if (rWallpaper.IsGradient())
{
rWriter.startElement("comment");
rWriter.content(pMetaCommentAction->GetComment());
rWriter.startElement("gradient");
Gradient aGradient = rWallpaper.GetGradient();
writeGradient(rWriter, aGradient);
rWriter.endElement();
}
if (rWallpaper.IsRect())
{
tools::Rectangle aRect = rWallpaper.GetRect();
rWriter.startElement("rectangle");
writeRectangle(rWriter, aRect);
rWriter.endElement();
}
rWriter.attribute("fixed", rWallpaper.IsFixed() ? "true" : "false");
rWriter.attribute("scrollable", rWallpaper.IsScrollable() ? "true" : "false");
rWriter.endElement();
}
break;
case MetaActionType::BMP:
{
auto pMeta = static_cast<MetaBmpAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
rWriter.endElement();
}
break;
case MetaActionType::BMPSCALE:
case MetaActionType::CLIPREGION:
{
auto pMeta = static_cast<MetaBmpScaleAction*>(pAction);
const auto* pMetaClipRegionAction = static_cast<const MetaClipRegionAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writePoint(rWriter, pMeta->GetPoint());
writeSize(rWriter, pMeta->GetSize());
rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
// FIXME for now we dump only the bounding box; this is
// enough for the tests we have, but may need extending to
// dumping the real polypolygon in the future
tools::Rectangle aRectangle = pMetaClipRegionAction->GetRegion().GetBoundRect();
writeRectangle(rWriter, aRectangle);
rWriter.endElement();
}
break;
case MetaActionType::BMPSCALEPART:
case MetaActionType::ISECTRECTCLIPREGION:
{
auto pMeta = static_cast<MetaBmpScalePartAction*>(pAction);
MetaISectRectClipRegionAction* pMetaISectRectClipRegionAction = static_cast<MetaISectRectClipRegionAction*>(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()));
tools::Rectangle aRectangle = pMetaISectRectClipRegionAction->GetRect();
writeRectangle(rWriter, aRectangle);
rWriter.endElement();
}
break;
case MetaActionType::BMPEX:
case MetaActionType::ISECTREGIONCLIPREGION:
{
auto pMeta = static_cast<MetaBmpExAction*>(pAction);
MetaISectRegionClipRegionAction* pMetaISectRegionClipRegionAction = static_cast<MetaISectRegionClipRegionAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum()));
rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
// FIXME for now we dump only the bounding box; this is
// enough for the tests we have, but may need extending to
// dumping the real polypolygon in the future
tools::Rectangle aRectangle = pMetaISectRegionClipRegionAction->GetRegion().GetBoundRect();
writeRectangle(rWriter, aRectangle);
rWriter.endElement();
}
break;
case MetaActionType::BMPEXSCALE:
// case MetaActionType::MOVECLIPREGION:
case MetaActionType::LINECOLOR:
{
auto pMeta = static_cast<MetaBmpExScaleAction*>(pAction);
MetaLineColorAction* pMetaLineColorAction = static_cast<MetaLineColorAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writePoint(rWriter, pMeta->GetPoint());
writeSize(rWriter, pMeta->GetSize());
rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum()));
rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
rWriter.attribute("color", convertColorToString(pMetaLineColorAction->GetColor()));
rWriter.endElement();
}
break;
case MetaActionType::BMPEXSCALEPART:
case MetaActionType::FILLCOLOR:
{
auto pMeta = static_cast<MetaBmpExScalePartAction*>(pAction);
MetaFillColorAction* pMetaFillColorAction = static_cast<MetaFillColorAction*>(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->GetBitmapEx().GetBitmap().GetChecksum()));
rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
rWriter.attribute("color", convertColorToString(pMetaFillColorAction->GetColor()));
rWriter.endElement();
}
break;
case MetaActionType::MASK:
case MetaActionType::TEXTCOLOR:
{
auto pMeta = static_cast<MetaMaskAction*>(pAction);
MetaTextColorAction* pMetaTextColorAction = static_cast<MetaTextColorAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmap().GetChecksum()));
rWriter.attribute("color", convertColorToString(pMeta->GetColor()));
rWriter.attribute("color", convertColorToString(pMetaTextColorAction->GetColor()));
rWriter.endElement();
}
break;
case MetaActionType::MASKSCALE:
case MetaActionType::TEXTFILLCOLOR:
{
auto pMeta = static_cast<MetaMaskScaleAction*>(pAction);
MetaTextFillColorAction* pMetaTextFillColorAction = static_cast<MetaTextFillColorAction*>(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.attribute("color", convertColorToString(pMetaTextFillColorAction->GetColor()));
if (pMetaTextFillColorAction->IsSetting())
rWriter.attribute("setting", OUString("true"));
rWriter.endElement();
}
break;
case MetaActionType::MASKSCALEPART:
case MetaActionType::TEXTALIGN:
{
auto pMeta = static_cast<MetaMaskScalePartAction*>(pAction);
MetaTextAlignAction* pMetaTextAlignAction = static_cast<MetaTextAlignAction*>(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()));
OUString sAlign = convertTextAlignToString(pMetaTextAlignAction->GetTextAlign());
if (!sAlign.isEmpty())
rWriter.attribute("align", sAlign);
rWriter.endElement();
}
break;
......@@ -1051,28 +1118,50 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
case MetaActionType::GRADIENT:
case MetaActionType::FONT:
{
const MetaGradientAction* pMeta = static_cast<MetaGradientAction*>(pAction);
tools::Rectangle aRectangle = pMeta->GetRect();
Gradient aGradient = pMeta->GetGradient();
MetaFontAction* pMetaFontAction = static_cast<MetaFontAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
vcl::Font aFont = pMetaFontAction->GetFont();
rWriter.attribute("color", convertColorToString(aFont.GetColor()));
rWriter.attribute("fillcolor", convertColorToString(aFont.GetFillColor()));
rWriter.attribute("name", aFont.GetFamilyName());
rWriter.attribute("stylename", aFont.GetStyleName());
rWriter.attribute("width", aFont.GetFontSize().Width());
rWriter.attribute("height", aFont.GetFontSize().Height());
rWriter.attribute("orientation", aFont.GetOrientation());
rWriter.attribute("weight", convertFontWeigthToString(aFont.GetWeight()));
rWriter.endElement();
}
break;
case MetaActionType::PUSH:
{
MetaPushAction* pMetaPushAction = static_cast<MetaPushAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("style", convertGradientStyle(aGradient.GetStyle()));
rWriter.attribute("startcolor", convertColorToString(aGradient.GetStartColor()));
rWriter.attribute("endcolor", convertColorToString(aGradient.GetEndColor()));
rWriter.attribute("angle", aGradient.GetAngle());
rWriter.attribute("border", aGradient.GetBorder());
rWriter.attribute("offsetx", aGradient.GetOfsX());
rWriter.attribute("offsety", aGradient.GetOfsY());
rWriter.attribute("startintensity", aGradient.GetStartIntensity());
rWriter.attribute("endintensity", aGradient.GetEndIntensity());
rWriter.attribute("steps", aGradient.GetSteps());
rWriter.startElement("rectangle");
writeRectangle(rWriter, aRectangle);
rWriter.attribute("flags", collectPushFlags(pMetaPushAction->GetFlags()));
}
break;
case MetaActionType::POP:
{
rWriter.endElement();
}
break;
case MetaActionType::RASTEROP:
{
MetaRasterOpAction* pMetaRasterOpAction = static_cast<MetaRasterOpAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
if (pMetaRasterOpAction->GetRasterOp() != RasterOp::OverPaint)
{
rWriter.attribute("operation", convertRopToString(pMetaRasterOpAction->GetRasterOp()));
}
rWriter.endElement();
}
break;
......@@ -1106,6 +1195,66 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
//case MetaActionType::EPS:
//case MetaActionType::REFPOINT:
case MetaActionType::TEXTLINECOLOR:
{
MetaTextLineColorAction* pMetaTextLineColorAction = static_cast<MetaTextLineColorAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("color", convertColorToString(pMetaTextLineColorAction->GetColor()));
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::FLOATTRANSPARENT:
//case MetaActionType::GRADIENTEX:
//case MetaActionType::LAYOUTMODE:
//case MetaActionType::TEXTLANGUAGE:
case MetaActionType::OVERLINECOLOR:
{
const auto* pMetaAction = static_cast<MetaOverlineColorAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
rWriter.attribute("color", convertColorToString(pMetaAction->GetColor()));
rWriter.endElement();
}
break;
case MetaActionType::COMMENT:
{
MetaCommentAction* pMetaCommentAction = static_cast<MetaCommentAction*>(pAction);
rWriter.startElement(sCurrentElementTag);
if (pMetaCommentAction->GetDataSize() > 0)
{
rWriter.attribute("datasize", pMetaCommentAction->GetDataSize());
}
if (!pMetaCommentAction->GetComment().isEmpty())
{
rWriter.startElement("comment");
rWriter.content(pMetaCommentAction->GetComment());
rWriter.endElement();
}
rWriter.endElement();
}
break;
default:
{
rWriter.startElement(sCurrentElementTag);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment