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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri May 8 12:38:32 UTC 2020


 oox/source/export/drawingml.cxx       |   18 ++++++++++++++++--
 sd/qa/unit/data/pptx/effectOrder.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx    |   21 +++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit c94d7b8a9aafc51ce33e74c6102c9b54a07a6b16
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri May 8 11:47:42 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri May 8 14:37:51 2020 +0200

    tdf#132201: use proper sequence order of effects per spec
    
    See CT_EffectList in ECMA-376
    
    Change-Id: Ib0605f1e4a0795d2bfdbb6b7451a902c67ea504d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93717
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index aebd6901c864..e2149b648f84 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3742,6 +3742,9 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
         }
     }
 
+    // tdf#132201: the order of effects is important. Effects order (CT_EffectList in ECMA-376):
+    // blur -> fillOverlay -> glow -> innerShdw -> outerShdw -> prstShdw -> reflection -> softEdge
+
     if( !aEffects.hasElements() )
     {
         bool bHasShadow = false;
@@ -3755,6 +3758,7 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
         if( bHasShadow || bHasGlow )
         {
             mpFS->startElementNS(XML_a, XML_effectLst);
+            WriteGlowEffect(rXPropSet);
             if( bHasShadow )
             {
                 Sequence< PropertyValue > aShadowGrabBag( 3 );
@@ -3778,7 +3782,6 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
 
                 WriteShapeEffect( "outerShdw", aShadowGrabBag );
             }
-            WriteGlowEffect(rXPropSet);
             mpFS->endElementNS(XML_a, XML_effectLst);
         }
     }
@@ -3820,8 +3823,18 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
         }
 
         mpFS->startElementNS(XML_a, XML_effectLst);
+        bool bGlowWritten = false;
         for( const auto& rEffect : std::as_const(aEffects) )
         {
+            if (!bGlowWritten
+                && (rEffect.Name == "innerShdw" || rEffect.Name == "outerShdw"
+                    || rEffect.Name == "prstShdw" || rEffect.Name == "reflection"
+                    || rEffect.Name == "softEdge"))
+            {
+                WriteGlowEffect(rXPropSet);
+                bGlowWritten = true;
+            }
+
             if( rEffect.Name == "outerShdw" )
             {
                 WriteShapeEffect( rEffect.Name, aOuterShdwProps );
@@ -3833,7 +3846,8 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
                 WriteShapeEffect( rEffect.Name, aEffectProps );
             }
         }
-        WriteGlowEffect(rXPropSet);
+        if (!bGlowWritten)
+            WriteGlowEffect(rXPropSet);
 
         mpFS->endElementNS(XML_a, XML_effectLst);
     }
diff --git a/sd/qa/unit/data/pptx/effectOrder.pptx b/sd/qa/unit/data/pptx/effectOrder.pptx
new file mode 100644
index 000000000000..7f913b3726f8
Binary files /dev/null and b/sd/qa/unit/data/pptx/effectOrder.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 6bb672641d56..645c3cb4f388 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -195,6 +195,7 @@ public:
     void testTdf119087();
     void testTdf131554();
     void testTdf132282();
+    void testTdf132201EffectOrder();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -307,6 +308,7 @@ public:
     CPPUNIT_TEST(testTdf119087);
     CPPUNIT_TEST(testTdf131554);
     CPPUNIT_TEST(testTdf132282);
+    CPPUNIT_TEST(testTdf132201EffectOrder);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2894,6 +2896,25 @@ void SdOOXMLExportTest2::testTdf132282()
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2604), xShape->getSize().Height);
 }
 
+void SdOOXMLExportTest2::testTdf132201EffectOrder()
+{
+    auto xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/effectOrder.pptx"),
+                             PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+    xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
+    assertXPathChildren(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:effectLst", 2);
+    // The relative order of effects is important: glow must be before shadow
+    CPPUNIT_ASSERT_EQUAL(0, getXPathPosition(pXmlDocContent,
+                                             "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:effectLst",
+                                             "glow"));
+    CPPUNIT_ASSERT_EQUAL(1, getXPathPosition(pXmlDocContent,
+                                             "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:effectLst",
+                                             "outerShdw"));
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list