[Libreoffice-commits] core.git: vcl/qa vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jan 25 23:37:08 UTC 2019
vcl/qa/cppunit/svm/svmtest.cxx | 42 +++++++++++++++++++++++++++++++++++++++
vcl/source/gdi/mtfxmldump.cxx | 44 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 85 insertions(+), 1 deletion(-)
New commits:
commit 3a4d46c586352939a37e3b07fa74cbce81abd722
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jan 25 14:24:11 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Jan 26 00:36:42 2019 +0100
vcl: test gradient draw into a metafile, extend the dumper
Change-Id: I87600c8cb648686b80092a9526a07ed71b324907
Reviewed-on: https://gerrit.libreoffice.org/66918
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 3de88cec4a18..55bdfc365c73 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -103,6 +103,9 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
void checkTextLineColor(const GDIMetaFile& rMetaFile);
void testTextLineColor();
+ void checkGradient(const GDIMetaFile& rMetaFile);
+ void testGradient();
+
public:
SvmTest()
: BootstrapFixture(true, false)
@@ -134,6 +137,7 @@ public:
CPPUNIT_TEST(testTextColor);
CPPUNIT_TEST(testTextFillColor);
CPPUNIT_TEST(testTextLineColor);
+ CPPUNIT_TEST(testGradient);
CPPUNIT_TEST_SUITE_END();
};
@@ -1024,6 +1028,44 @@ void SvmTest::testTextLineColor()
checkTextLineColor(writeAndRead(aGDIMetaFile, "textlinecolor.svm"));
}
+void SvmTest::checkGradient(const GDIMetaFile& rMetaFile)
+{
+ xmlDocPtr pDoc = dumpMeta(rMetaFile);
+
+ assertXPathAttrs(pDoc, "/metafile/gradient[1]", {
+ {"style", "Linear"},
+ {"startcolor", "#ffffff"},
+ {"endcolor", "#000000"},
+ {"angle", "0"},
+ {"border", "0"},
+ {"offsetx", "50"},
+ {"offsety", "50"},
+ {"startintensity", "100"},
+ {"endintensity", "100"},
+ {"steps", "0"},
+ });
+ assertXPathAttrs(pDoc, "/metafile/gradient[1]/rectangle", {
+ {"left", "1"},
+ {"top", "2"},
+ {"right", "4"},
+ {"bottom", "6"},
+ });
+}
+
+void SvmTest::testGradient()
+{
+ GDIMetaFile aGDIMetaFile;
+ ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+ setupBaseVirtualDevice(*pVirtualDev.get(), aGDIMetaFile);
+
+ tools::Rectangle aRectangle(Point(1, 2), Size(4,5));
+
+ Gradient aGradient(GradientStyle::Linear, COL_WHITE, COL_BLACK);
+ pVirtualDev->DrawGradient(aRectangle, aGradient);
+
+ checkGradient(writeAndRead(aGDIMetaFile, "gradient.svm"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SvmTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 2666ddd55d78..f5a25690b743 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -376,6 +376,20 @@ OUString convertFractionToString(const Fraction& aFraction)
return OUString::createFromAscii(ss.str().c_str());
}
+OUString convertGradientStyle(GradientStyle eStyle)
+{
+ switch (eStyle)
+ {
+ case GradientStyle::Linear: return OUString("Linear");
+ case GradientStyle::Axial: return OUString("Axial");
+ case GradientStyle::Radial: return OUString("Radial");
+ case GradientStyle::Elliptical: return OUString("Elliptical");
+ case GradientStyle::Square: return OUString("Square");
+ case GradientStyle::Rect: return OUString("Rect");
+ case GradientStyle::FORCE_EQUAL_SIZE: return OUString("ForceEqualSize");
+ }
+ return OUString();
+}
OUString hex32(sal_uInt32 nNumber)
{
@@ -1037,9 +1051,37 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
}
break;
+ case MetaActionType::GRADIENT:
+ {
+ const MetaGradientAction* pMeta = static_cast<MetaGradientAction*>(pAction);
+ tools::Rectangle aRectangle = pMeta->GetRect();
+ Gradient aGradient = pMeta->GetGradient();
+
+ 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.endElement();
+
+ rWriter.endElement();
+ }
+ break;
+
default:
{
- rWriter.element(sCurrentElementTag);
+ rWriter.startElement(sCurrentElementTag);
+ rWriter.attribute("note", OString("not implemented in xml dump"));
+ rWriter.endElement();
}
break;
}
More information about the Libreoffice-commits
mailing list