[Libreoffice-commits] core.git: vcl/qa vcl/source
panoskorovesis (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 28 11:55:34 UTC 2021
vcl/qa/cppunit/svm/data/eps.svm |binary
vcl/qa/cppunit/svm/svmtest.cxx | 77 ++++++++++++++++++++++++++++++++++++++--
vcl/source/gdi/mtfxmldump.cxx | 59 ++++++++++++++++++++++++++++++
3 files changed, 133 insertions(+), 3 deletions(-)
New commits:
commit d1eb1e6e487fad489b7c80b68613290da6edfe8a
Author: panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Wed Jun 23 13:52:32 2021 +0300
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 28 13:55:01 2021 +0200
Add EPS cppunit test to vcl.
The test creates an EPS along with a second metafile and
tests their attributes. mtfxmldump.cxx was edited to support
EPS.
Change-Id: I43495304aaf191e1a8ad034b96ff59de085a0630
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117702
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/qa/cppunit/svm/data/eps.svm b/vcl/qa/cppunit/svm/data/eps.svm
new file mode 100644
index 000000000000..33b923a14adc
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/eps.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index c260a974282d..abe76a85e606 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -183,7 +183,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
//void checkFloatTransparent(const GDIMetaFile& rMetaFile);
void testFloatTransparent();
- //void checkEPS(const GDIMetaFile& rMetaFile);
+ void checkEPS(const GDIMetaFile& rMetaFile);
void testEPS();
void checkRefPoint(const GDIMetaFile& rMetaFile);
@@ -2035,8 +2035,81 @@ void SvmTest::testTransparent()
void SvmTest::testFloatTransparent()
{}
+void SvmTest::checkEPS(const GDIMetaFile& rMetaFile)
+{
+ xmlDocUniquePtr pDoc = dumpMeta(rMetaFile);
+
+ assertXPathAttrs(pDoc, "/metafile/eps[1]", {
+ {"x", "1"},
+ {"y", "8"},
+ {"width", "2"},
+ {"height", "7"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/eps[1]/gfxlink[1]", {
+ {"width", "3"},
+ {"height", "6"},
+ {"type", "EpsBuffer"},
+ {"userid", "12345"},
+ {"datasize", "3"},
+ {"data", "616263"},
+ {"native", "false"},
+ {"emf", "false"},
+ {"validmapmode", "true"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/eps[1]/gfxlink[1]/prefmapmode[1]", {
+ {"mapunit", "Map100thInch"},
+ {"x", "0"},
+ {"y", "1"},
+ {"scalex", "(1/2)"},
+ {"scaley", "(2/3)"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/eps[1]/metafile[1]/point[1]", {
+ {"x", "1"},
+ {"y", "8"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/eps[1]/metafile[1]/point[2]", {
+ {"x", "2"},
+ {"y", "7"}
+ });
+}
+
void SvmTest::testEPS()
-{}
+{
+ GDIMetaFile aGDIMetaFile;
+ ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+ setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
+
+ sal_uInt32 nDataSize = 3;
+ std::unique_ptr<sal_uInt8[]> pBuffer (new sal_uInt8[nDataSize]);
+ pBuffer[0] = 'a';
+ pBuffer[1] = 'b';
+ pBuffer[2] = 'c';
+
+ MapMode aMapMode1(MapUnit::Map100thInch);
+ aMapMode1.SetOrigin(Point(0, 1));
+ aMapMode1.SetScaleX(Fraction(1, 2));
+ aMapMode1.SetScaleY(Fraction(2, 3));
+
+ GDIMetaFile aGDIMetaFile1;
+ ScopedVclPtrInstance<VirtualDevice> pVirtualDev1;
+ setupBaseVirtualDevice(*pVirtualDev1, aGDIMetaFile1);
+
+ pVirtualDev1->DrawPixel(Point(1, 8));
+ pVirtualDev1->DrawPixel(Point(2, 7));
+
+ GfxLink aGfxLink(std::move(pBuffer), nDataSize, GfxLinkType::EpsBuffer);
+ aGfxLink.SetPrefMapMode(aMapMode1);
+ aGfxLink.SetUserId(12345);
+ aGfxLink.SetPrefSize(Size(3, 6));
+ pVirtualDev->DrawEPS(Point(1, 8), Size(2, 7), aGfxLink, &aGDIMetaFile1);
+
+ checkEPS(writeAndReadStream(aGDIMetaFile));
+ checkEPS(readFile(u"eps.svm"));
+}
void SvmTest::checkRefPoint(const GDIMetaFile& rMetaFile)
{
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 0b9ba2c2ef20..cccc64df808a 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -452,6 +452,27 @@ OUString convertComplexTestLayoutFlags(ComplexTextLayoutFlags eComplexTestLayout
}
}
+OUString convertGfxLinkTypeToString(GfxLinkType eGfxLinkType)
+{
+ switch(eGfxLinkType)
+ {
+ case GfxLinkType::EpsBuffer: return "EpsBuffer";
+ case GfxLinkType::NativeBmp: return "NativeBmp";
+ case GfxLinkType::NativeGif: return "NativeGif";
+ case GfxLinkType::NativeJpg: return "NativeJpg";
+ case GfxLinkType::NativeMet: return "NativeMet";
+ case GfxLinkType::NativeMov: return "NativeMov";
+ case GfxLinkType::NativePct: return "NativePct";
+ case GfxLinkType::NativePdf: return "NativePdf";
+ case GfxLinkType::NativePng: return "NativePng";
+ case GfxLinkType::NativeSvg: return "NativeSvg";
+ case GfxLinkType::NativeTif: return "NativeTif";
+ case GfxLinkType::NativeWmf: return "NativeWmf";
+ case GfxLinkType::NONE: return "None";
+ }
+ return OUString();
+}
+
OUString hex32(sal_uInt32 nNumber)
{
std::stringstream ss;
@@ -508,6 +529,14 @@ void writeRectangle(tools::XmlWriter& rWriter, tools::Rectangle const& rRectangl
rWriter.attribute("bottom", rRectangle.Bottom());
}
+void writeMapMode(tools::XmlWriter& rWriter, MapMode const& rMapMode)
+{
+ rWriter.attribute("mapunit", convertMapUnitToString( rMapMode.GetMapUnit() ));
+ writePoint(rWriter, rMapMode.GetOrigin());
+ rWriter.attribute("scalex", convertFractionToString(rMapMode.GetScaleX()));
+ rWriter.attribute("scaley", convertFractionToString(rMapMode.GetScaleY()));
+}
+
void writeLineInfo(tools::XmlWriter& rWriter, LineInfo const& rLineInfo)
{
rWriter.attribute("style", convertLineStyleToString(rLineInfo.GetStyle()));
@@ -1282,7 +1311,35 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
- //case MetaActionType::EPS:
+ case MetaActionType::EPS:
+ {
+ MetaEPSAction* pMetaEPSAction = static_cast<MetaEPSAction*>(pAction);
+ rWriter.startElement(sCurrentElementTag);
+
+ writePoint(rWriter, pMetaEPSAction->GetPoint());
+ writeSize(rWriter, pMetaEPSAction->GetSize());
+
+ rWriter.startElement("gfxlink");
+ writeSize(rWriter, pMetaEPSAction->GetLink().GetPrefSize());
+ rWriter.attribute("type", convertGfxLinkTypeToString(pMetaEPSAction->GetLink().GetType()));
+ rWriter.attribute("userid", pMetaEPSAction->GetLink().GetUserId());
+ rWriter.attribute("datasize", pMetaEPSAction->GetLink().GetDataSize());
+ rWriter.attribute("data", toHexString(pMetaEPSAction->GetLink().GetData(), pMetaEPSAction->GetLink().GetDataSize()));
+ rWriter.attribute("native", pMetaEPSAction->GetLink().IsNative() ? "true" : "false");
+ rWriter.attribute("emf", pMetaEPSAction->GetLink().IsEMF() ? "true" : "false");
+ rWriter.attribute("validmapmode", pMetaEPSAction->GetLink().IsPrefMapModeValid() ? "true" : "false");
+ rWriter.startElement("prefmapmode");
+ writeMapMode(rWriter, pMetaEPSAction->GetLink().GetPrefMapMode());
+ rWriter.endElement();
+ rWriter.endElement();
+
+ rWriter.startElement("metafile");
+ writeXml(pMetaEPSAction->GetSubstitute(), rWriter);
+ rWriter.endElement();
+
+ rWriter.endElement();
+ }
+ break;
case MetaActionType::REFPOINT:
{
More information about the Libreoffice-commits
mailing list