[Libreoffice-commits] core.git: vcl/CppunitTest_vcl_svm_test.mk vcl/qa vcl/source
panoskorovesis (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 23 06:55:33 UTC 2021
vcl/CppunitTest_vcl_svm_test.mk | 1
vcl/qa/cppunit/svm/data/comment.svm |binary
vcl/qa/cppunit/svm/svmtest.cxx | 46 ++++++++++++++++++++++++++++++++++--
vcl/source/gdi/mtfxmldump.cxx | 15 ++++++++++-
4 files changed, 59 insertions(+), 3 deletions(-)
New commits:
commit e10df88b8ae4138862d4dd25c221189878641aa4
Author: panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Tue Jun 15 14:32:00 2021 +0300
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 23 08:54:52 2021 +0200
Add Comment cppunit test to vcl.
The test creates two MetaCommentActions from the GDIMetafile and
checks their attributes and contents.
Change-Id: I748a6fa5dcf0dc09359fb48ea0bf3d7ceef3dbcf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117245
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/CppunitTest_vcl_svm_test.mk b/vcl/CppunitTest_vcl_svm_test.mk
index 5d8071c42ff3..727ed121e3f6 100644
--- a/vcl/CppunitTest_vcl_svm_test.mk
+++ b/vcl/CppunitTest_vcl_svm_test.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_libraries,vcl_svm_test, \
cppu \
cppuhelper \
sal \
+ salhelper \
svt \
test \
tl \
diff --git a/vcl/qa/cppunit/svm/data/comment.svm b/vcl/qa/cppunit/svm/data/comment.svm
new file mode 100644
index 000000000000..0e2a0f2295d9
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/comment.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 76725de14603..de0e93363c84 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -21,6 +21,8 @@
#include <vcl/virdev.hxx>
#include <vcl/pngwrite.hxx>
#include <tools/fract.hxx>
+#include <vcl/metaact.hxx>
+#include <salhelper/simplereferenceobject.hxx>
#include <bitmap/BitmapWriteAccess.hxx>
@@ -185,7 +187,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
void checkRefPoint(const GDIMetaFile& rMetaFile);
void testRefPoint();
- //void checkComment(const GDIMetaFile& rMetaFile);
+ void checkComment(const GDIMetaFile& rMetaFile);
void testComment();
//void checkLayoutMode(const GDIMetaFile& rMetaFile);
@@ -2027,8 +2029,48 @@ void SvmTest::testRefPoint()
checkRefPoint(readFile(u"refpoint.svm"));
}
+void SvmTest::checkComment(const GDIMetaFile& rMetafile)
+{
+ xmlDocUniquePtr pDoc = dumpMeta(rMetafile);
+
+ assertXPathAttrs(pDoc, "/metafile/comment[1]", {
+ {"value", "0"}
+ });
+
+ assertXPathContent(pDoc, "/metafile/comment[1]/comment[1]", "Test comment");
+
+ assertXPathAttrs(pDoc, "/metafile/comment[2]", {
+ {"datasize", "48"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/comment[2]", {
+ {"data", "540068006500730065002000610072006500200073006f006d0065002000740065007300740020006400610074006100"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/comment[2]", {
+ {"value", "4"}
+ });
+
+ assertXPathContent(pDoc, "/metafile/comment[2]/comment[1]", "This is a test comment");
+}
+
void SvmTest::testComment()
-{}
+{
+ GDIMetaFile aGDIMetaFile;
+ ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+ setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
+
+ aGDIMetaFile.AddAction(new MetaCommentAction("Test comment"));
+
+ OUString aString = "These are some test data";
+ aGDIMetaFile.AddAction(new MetaCommentAction("This is a test comment", \
+ 4, \
+ reinterpret_cast<const sal_uInt8*>(aString.getStr()), \
+ 2*aString.getLength() ));
+
+ checkComment(writeAndReadStream(aGDIMetaFile));
+ checkComment(readFile(u"comment.svm"));
+}
void SvmTest::testLayoutMode()
{}
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index e5651906ed57..84c280c2eaae 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -439,6 +439,17 @@ OUString hex32(sal_uInt32 nNumber)
return OUString::createFromAscii(ss.str().c_str());
}
+OUString toHexString(const sal_uInt8* nData, sal_uInt32 nDataSize){
+
+ std::stringstream aStrm;
+ for (sal_uInt32 i = 0; i < nDataSize; i++)
+ {
+ aStrm << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(nData[i]);
+ }
+
+ return OUString::createFromAscii(aStrm.str().c_str());
+}
+
void writePoint(tools::XmlWriter& rWriter, Point const& rPoint)
{
rWriter.attribute("x", rPoint.X());
@@ -1353,14 +1364,16 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
if (pMetaCommentAction->GetDataSize() > 0)
{
rWriter.attribute("datasize", pMetaCommentAction->GetDataSize());
+ rWriter.attribute("data", toHexString(pMetaCommentAction->GetData(), pMetaCommentAction->GetDataSize()));
}
+ rWriter.attribute("value", pMetaCommentAction->GetValue());
+
if (!pMetaCommentAction->GetComment().isEmpty())
{
rWriter.startElement("comment");
rWriter.content(pMetaCommentAction->GetComment());
rWriter.endElement();
}
-
rWriter.endElement();
}
break;
More information about the Libreoffice-commits
mailing list