[Libreoffice-commits] core.git: schema/libreoffice sd/qa

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu May 7 17:25:27 UTC 2020


 schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng |   24 +++++
 sd/qa/unit/data/odg/glow.odg                                |binary
 sd/qa/unit/export-tests.cxx                                 |   50 ++++++++++++
 3 files changed, 74 insertions(+)

New commits:
commit 5ac2075d56cfff57f2254e4e5bd5a1e3a3579f83
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu May 7 14:24:44 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu May 7 19:24:52 2020 +0200

    tdf#101181: unit test for glow attributes in ODF
    
    Tests loext:glow,
          loext:glow-radius,
          loext:glow-color,
          loext:glow-transparency
    
    There's original decision to keep EMUs in GlowEffectRad property,
    which makes this to be stored as hundreds of cm in ODF. I suppose
    we should change this in a follow-up to use mm100s instead.
    
    Change-Id: I47bf6530799ed16a55d58d0be5a8a7c3446d2df9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93633
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index a61f6da11f71..5e1a587fda74 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -920,6 +920,30 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
             <rng:ref name="boolean"/>
           </rng:attribute>
         </rng:optional>
+        <!-- TODO: no proposal for loext:glow* -->
+        <rng:optional>
+          <rng:attribute name="loext:glow">
+            <rng:choice>
+              <rng:value>visible</rng:value>
+              <rng:value>hidden</rng:value>
+            </rng:choice>
+          </rng:attribute>
+        </rng:optional>
+        <rng:optional>
+          <rng:attribute name="loext:glow-radius">
+            <rng:ref name="length"/>
+          </rng:attribute>
+        </rng:optional>
+        <rng:optional>
+          <rng:attribute name="loext:glow-color">
+            <rng:ref name="color"/>
+          </rng:attribute>
+        </rng:optional>
+        <rng:optional>
+          <rng:attribute name="loext:glow-transparency">
+            <rng:ref name="zeroToHundredPercent"/>
+          </rng:attribute>
+        </rng:optional>
       </rng:interleave>
     </rng:define>
 
diff --git a/sd/qa/unit/data/odg/glow.odg b/sd/qa/unit/data/odg/glow.odg
new file mode 100644
index 000000000000..11d697c491da
Binary files /dev/null and b/sd/qa/unit/data/odg/glow.odg differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 285294bca8ea..de092590f2cd 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -74,6 +74,7 @@ public:
     void testTdf123557();
     void testTdf113822();
     void testTdf126761();
+    void testGlow();
 
     CPPUNIT_TEST_SUITE(SdExportTest);
 
@@ -108,6 +109,7 @@ public:
     CPPUNIT_TEST(testTdf123557);
     CPPUNIT_TEST(testTdf113822);
     CPPUNIT_TEST(testTdf126761);
+    CPPUNIT_TEST(testGlow);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1257,6 +1259,54 @@ void SdExportTest::testTdf126761()
     xDocShRef->DoClose();
 }
 
+void SdExportTest::testGlow()
+{
+    auto xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odg/glow.odg"), ODG);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), ODG, &tempFile);
+    uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
+
+    // Check glow properties
+    bool bGlowEffect = false;
+    CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffect") >>= bGlowEffect);
+    CPPUNIT_ASSERT(bGlowEffect);
+    sal_Int32 nGlowEffectRad = 0;
+    CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectRad") >>= nGlowEffectRad);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(190500), nGlowEffectRad); // 15 pt = 190500 EMU
+    sal_Int32 nGlowEffectColor = 0;
+    CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectColor") >>= nGlowEffectColor);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF4000), nGlowEffectColor); // "Brick"
+    sal_Int16 nGlowEffectTransparency = 0;
+    CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectTransparency") >>= nGlowEffectTransparency);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nGlowEffectTransparency); // 60%
+
+    // Test ODF element
+    xmlDocPtr pXmlDoc = parseExport(tempFile, "content.xml");
+
+    // check that we actually test graphic style
+    assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]",
+                "family", "graphic");
+    // check loext graphic attributes
+    assertXPath(
+        pXmlDoc,
+        "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
+        "glow", "visible");
+    assertXPath(
+        pXmlDoc,
+        "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
+        "glow-radius", "190.5cm"); // ???
+    assertXPath(
+        pXmlDoc,
+        "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
+        "glow-color", "#ff4000");
+    assertXPath(
+        pXmlDoc,
+        "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
+        "glow-transparency", "60%");
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list