[Libreoffice-commits] core.git: vcl/qa vcl/source

panoskorovesis (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 23 06:57:46 UTC 2021


 vcl/qa/cppunit/svm/data/layoutmode.svm |binary
 vcl/qa/cppunit/svm/svmtest.cxx         |   27 +++++++++++++++++++++++++--
 vcl/source/gdi/mtfxmldump.cxx          |   26 +++++++++++++++++++++++++-
 3 files changed, 50 insertions(+), 3 deletions(-)

New commits:
commit bc4cea4943c9189b92f51aacf097549023398b2e
Author:     panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Mon Jun 21 14:40:08 2021 +0300
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 23 08:57:09 2021 +0200

    Add LayoutMode cppunit test to vcl.
    
    The test sets two LayoutModes (using ComplexTextLayoutFlags)
    and checks their attributes.
    
    Change-Id: Id765c150485c6f06c1326498a7f1b40b8f9c12fa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117575
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/qa/cppunit/svm/data/layoutmode.svm b/vcl/qa/cppunit/svm/data/layoutmode.svm
new file mode 100644
index 000000000000..d12f09d663aa
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/layoutmode.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index a8244ff2f25b..a95c249c96bf 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -190,7 +190,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
     void checkComment(const GDIMetaFile& rMetaFile);
     void testComment();
 
-    //void checkLayoutMode(const GDIMetaFile& rMetaFile);
+    void checkLayoutMode(const GDIMetaFile& rMetaFile);
     void testLayoutMode();
 
     void checkTextLanguage(const GDIMetaFile& rMetaFile);
@@ -2108,8 +2108,31 @@ void SvmTest::testComment()
     checkComment(readFile(u"comment.svm"));
 }
 
+void SvmTest::checkLayoutMode(const GDIMetaFile& rMetaFile)
+{
+    xmlDocUniquePtr pDoc = dumpMeta(rMetaFile);
+
+    assertXPathAttrs(pDoc, "/metafile/layoutmode[1]", {
+        {"textlayout", "#0004"}
+    });
+
+    assertXPathAttrs(pDoc, "/metafile/layoutmode[2]", {
+        {"textlayout", "#0001"}
+    });
+}
+
 void SvmTest::testLayoutMode()
-{}
+{
+    GDIMetaFile aGDIMetaFile;
+    ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+    setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
+
+    pVirtualDev->SetLayoutMode(ComplexTextLayoutFlags::TextOriginLeft);
+    pVirtualDev->SetLayoutMode(ComplexTextLayoutFlags::BiDiRtl);
+
+    checkLayoutMode(writeAndReadStream(aGDIMetaFile));
+    checkLayoutMode(readFile(u"layoutmode.svm"));
+}
 
 void SvmTest::checkTextLanguage(const GDIMetaFile& rMetaFile)
 {
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 901edde87437..0b9ba2c2ef20 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -439,6 +439,19 @@ OUString convertPixelFormatToString(vcl::PixelFormat ePixelFormat)
     return OUString();
 }
 
+OUString convertComplexTestLayoutFlags(ComplexTextLayoutFlags eComplexTestLayoutFlags)
+{
+    switch(eComplexTestLayoutFlags)
+    {
+        default:
+        case ComplexTextLayoutFlags::Default: return "#0000";
+        case ComplexTextLayoutFlags::BiDiRtl: return "#0001";
+        case ComplexTextLayoutFlags::BiDiStrong: return "#0002";
+        case ComplexTextLayoutFlags::TextOriginLeft: return "#0004";
+        case ComplexTextLayoutFlags::TextOriginRight: return "#0008";
+    }
+}
+
 OUString hex32(sal_uInt32 nNumber)
 {
     std::stringstream ss;
@@ -1351,7 +1364,18 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
             }
             break;
 
-            //case MetaActionType::LAYOUTMODE:
+            case MetaActionType::LAYOUTMODE:
+            {
+                const MetaLayoutModeAction* pMetaLayoutModeAction = static_cast<MetaLayoutModeAction*>(pAction);
+
+                rWriter.startElement(sCurrentElementTag);
+
+                rWriter.attribute("textlayout", convertComplexTestLayoutFlags(pMetaLayoutModeAction->GetLayoutMode()));
+
+                rWriter.endElement();
+            }
+            break;
+
             case MetaActionType::TEXTLANGUAGE:
             {
                 const MetaTextLanguageAction* pMetaTextLanguageAction = static_cast<MetaTextLanguageAction*>(pAction);


More information about the Libreoffice-commits mailing list