[Libreoffice-commits] core.git: vcl/qa vcl/source
panoskorovesis (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 23 06:56:53 UTC 2021
vcl/qa/cppunit/svm/data/textlanguage.svm |binary
vcl/qa/cppunit/svm/svmtest.cxx | 27 +++++++++++++++++++++++++--
vcl/source/gdi/mtfxmldump.cxx | 19 ++++++++++++++++++-
3 files changed, 43 insertions(+), 3 deletions(-)
New commits:
commit 659c6af5338e1a6d6ff7715f20fa992b62c48ce5
Author: panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Fri Jun 18 09:40:58 2021 +0300
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 23 08:56:09 2021 +0200
Add TextLanguage cppunit test to vcl.
The test sets two languages for the metafile and checks their attributes.
Change-Id: Ibb23c03af48af5c40ea65593917a40a928fd1280
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117368
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/qa/cppunit/svm/data/textlanguage.svm b/vcl/qa/cppunit/svm/data/textlanguage.svm
new file mode 100644
index 000000000000..2e930d27e55e
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/textlanguage.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 605a8f5c8afd..a8244ff2f25b 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -193,7 +193,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
//void checkLayoutMode(const GDIMetaFile& rMetaFile);
void testLayoutMode();
- //void checkTextLanguage(const GDIMetaFile& rMetaFile);
+ void checkTextLanguage(const GDIMetaFile& rMetaFile);
void testTextLanguage();
public:
@@ -2111,8 +2111,31 @@ void SvmTest::testComment()
void SvmTest::testLayoutMode()
{}
+void SvmTest::checkTextLanguage(const GDIMetaFile& rMetaFile)
+{
+ xmlDocUniquePtr pDoc = dumpMeta(rMetaFile);
+
+ assertXPathAttrs(pDoc, "/metafile/textlanguage[1]", {
+ {"language", "#0408"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/textlanguage[2]", {
+ {"language", "#00ff"}
+ });
+}
+
void SvmTest::testTextLanguage()
-{}
+{
+ GDIMetaFile aGDIMetaFile;
+ ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+ setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
+
+ pVirtualDev->SetDigitLanguage(LANGUAGE_GREEK);
+ pVirtualDev->SetDigitLanguage(LANGUAGE_NONE);
+
+ checkTextLanguage(writeAndReadStream(aGDIMetaFile));
+ checkTextLanguage(readFile(u"textlanguage.svm"));
+}
CPPUNIT_TEST_SUITE_REGISTRATION(SvmTest);
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 84c280c2eaae..901edde87437 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -398,6 +398,13 @@ OUString convertHatchStyle(HatchStyle eStyle)
return OUString();
}
+OUString convertLanguageTypeToString(LanguageType rLanguageType)
+{
+ std::stringstream ss;
+ ss << std::hex << std::setfill ('0') << std::setw(4) << rLanguageType.get();
+ return "#" + OUString::createFromAscii(ss.str().c_str());
+}
+
OUString convertWallpaperStyleToString(WallpaperStyle eWallpaperStyle)
{
switch (eWallpaperStyle)
@@ -1345,7 +1352,17 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
break;
//case MetaActionType::LAYOUTMODE:
- //case MetaActionType::TEXTLANGUAGE:
+ case MetaActionType::TEXTLANGUAGE:
+ {
+ const MetaTextLanguageAction* pMetaTextLanguageAction = static_cast<MetaTextLanguageAction*>(pAction);
+
+ rWriter.startElement(sCurrentElementTag);
+
+ rWriter.attribute("language", convertLanguageTypeToString(pMetaTextLanguageAction->GetTextLanguage()));
+
+ rWriter.endElement();
+ }
+ break;
case MetaActionType::OVERLINECOLOR:
{
More information about the Libreoffice-commits
mailing list