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

panoskorovesis (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 9 13:49:49 UTC 2021


 vcl/qa/cppunit/svm/data/gradientex.svm |binary
 vcl/qa/cppunit/svm/svmtest.cxx         |  105 ++++++++++++++++++++++++++++++++-
 vcl/source/gdi/mtfxmldump.cxx          |   30 ++++++++-
 3 files changed, 131 insertions(+), 4 deletions(-)

New commits:
commit dbd86edb55de543d9b0b88bca1d43676da88215a
Author:     panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Wed Jun 9 10:32:25 2021 +0300
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 9 15:49:06 2021 +0200

    Add GradientEx cppunit test to vcl
    
    The test creates two GradientEx and checks
    their attributes. In mtfxmldump.cxx the
    case regarding GradientEx was completed
    
    Change-Id: I52f2303fa3123b97fb8a4b0783610c0bae300fc8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116819
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/qa/cppunit/svm/data/gradientex.svm b/vcl/qa/cppunit/svm/data/gradientex.svm
new file mode 100644
index 000000000000..6a83d078cd2c
Binary files /dev/null and b/vcl/qa/cppunit/svm/data/gradientex.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 0331502d1041..844a12bd1214 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -116,7 +116,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools
     void checkGradient(const GDIMetaFile& rMetaFile);
     void testGradient();
 
-    //void checkGradientEx(const GDIMetaFile& rMetaFile);
+    void checkGradientEx(const GDIMetaFile& rMetaFile);
     void testGradientEx();
 
     void checkHatch(const GDIMetaFile& rMetaFile);
@@ -1254,8 +1254,109 @@ void SvmTest::testGradient()
     checkGradient(readFile(u"gradient.svm"));
 }
 
+void SvmTest::checkGradientEx(const GDIMetaFile& rMetaFile)
+{
+    xmlDocUniquePtr pDoc = dumpMeta(rMetaFile);
+
+    assertXPathAttrs(pDoc, "/metafile/gradientex[1]", {
+        {"style", "Linear"},
+        {"startcolor", "#ffffff"},
+        {"endcolor", "#000000"},
+        {"angle", "0"},
+        {"border", "0"},
+        {"offsetx", "50"},
+        {"offsety", "50"},
+        {"startintensity", "100"},
+        {"endintensity", "100"},
+        {"steps", "0"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[1]/polygon/point[1]", {
+        {"x", "1"},
+        {"y", "8"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[1]/polygon/point[2]", {
+        {"x", "2"},
+        {"y", "7"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[1]/polygon/point[3]", {
+        {"x", "3"},
+        {"y", "6"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[2]", {
+        {"style", "Axial"},
+        {"startcolor", "#ff00ff"},
+        {"endcolor", "#008080"},
+        {"angle", "55"},
+        {"border", "10"},
+        {"offsetx", "22"},
+        {"offsety", "24"},
+        {"startintensity", "4"},
+        {"endintensity", "14"},
+        {"steps", "64"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[1]/point[1]", {
+        {"x", "1"},
+        {"y", "2"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[1]/point[2]", {
+        {"x", "3"},
+        {"y", "4"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[2]/point[1]", {
+        {"x", "8"},
+        {"y", "9"}
+    });
+    assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[2]/point[2]", {
+        {"x", "6"},
+        {"y", "7"}
+    });
+}
+
 void SvmTest::testGradientEx()
-{}
+{
+    GDIMetaFile aGDIMetaFile;
+    ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
+    setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
+
+    tools::Polygon aPolygon(3);
+    aPolygon.SetPoint(Point(1, 8), 0);
+    aPolygon.SetPoint(Point(2, 7), 1);
+    aPolygon.SetPoint(Point(3, 6), 2);
+
+    tools::PolyPolygon aPolyPolygon(1);
+    aPolyPolygon.Insert(aPolygon);
+
+    Gradient aGradient(GradientStyle::Linear, COL_WHITE, COL_BLACK);
+    pVirtualDev->DrawGradient(aPolyPolygon, aGradient);
+
+    tools::Polygon aPolygon2(2);
+    aPolygon2.SetPoint(Point(1, 2), 0);
+    aPolygon2.SetPoint(Point(3, 4), 1);
+
+    tools::Polygon aPolygon3(2);
+    aPolygon3.SetPoint(Point(8, 9), 0);
+    aPolygon3.SetPoint(Point(6, 7), 1);
+
+    tools::PolyPolygon aPolyPolygon2(1);
+    aPolyPolygon2.Insert(aPolygon2);
+    aPolyPolygon2.Insert(aPolygon3);
+
+    Gradient aGradient2;
+    aGradient2.SetStyle(GradientStyle::Axial);
+    aGradient2.SetStartColor(COL_LIGHTMAGENTA);
+    aGradient2.SetEndColor(COL_CYAN);
+    aGradient2.SetAngle(Degree10(55));
+    aGradient2.SetBorder(10);
+    aGradient2.SetOfsX(22);
+    aGradient2.SetOfsY(24);
+    aGradient2.SetStartIntensity(4);
+    aGradient2.SetEndIntensity(14);
+    aGradient2.SetSteps(64);
+    pVirtualDev->DrawGradient(aPolyPolygon2, aGradient2);
+
+    checkGradientEx(writeAndReadStream(aGDIMetaFile));
+    checkGradientEx(readFile(u"gradientex.svm"));
+}
 
 void SvmTest::checkHatch(const GDIMetaFile& rMetaFile)
 {
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index d612898e6c8c..8bd21b9d7460 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -722,7 +722,6 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
                     }
                     rWriter.endElement();
                 }
-
                 rWriter.endElement();
             }
             break;
@@ -1273,7 +1272,34 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
             }
             break;
 
-            //case MetaActionType::GRADIENTEX:
+            case MetaActionType::GRADIENTEX:
+            {
+                const MetaGradientExAction* pMetaGradientExAction = static_cast<MetaGradientExAction*>(pAction);
+
+                rWriter.startElement(sCurrentElementTag);
+                writeGradient(rWriter, pMetaGradientExAction->GetGradient());
+
+                tools::PolyPolygon const& rPolyPolygon(pMetaGradientExAction->GetPolyPolygon());
+                for (sal_uInt16 j = 0; j < rPolyPolygon.Count(); ++j)
+                {
+                    rWriter.startElement("polygon");
+                    tools::Polygon const& rPolygon = rPolyPolygon[j];
+                    bool bFlags = rPolygon.HasFlags();
+                    for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
+                    {
+                        rWriter.startElement("point");
+                        writePoint(rWriter, rPolygon[i]);
+                        if (bFlags)
+                            rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
+                        rWriter.endElement();
+                    }
+                    rWriter.endElement();
+                }
+
+                rWriter.endElement();
+            }
+            break;
+
             //case MetaActionType::LAYOUTMODE:
             //case MetaActionType::TEXTLANGUAGE:
 


More information about the Libreoffice-commits mailing list