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

Tamás Zolnai tamas.zolnai at collabora.com
Tue Feb 27 10:07:33 UTC 2018


 oox/source/export/drawingml.cxx     |   28 +++++++++++++------------
 oox/source/export/shapes.cxx        |    1 
 sd/qa/unit/data/pptx/tdf111789.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   39 ++++++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 13 deletions(-)

New commits:
commit f41a08183504a59d6ffc7a00ed7f24e6b19995ab
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Tue Feb 27 06:54:16 2018 +0100

    tdf#111789: TextBox shadow propeties are not saved to PPTX
    
    Change-Id: I0c858676e1fc02a72b4b6bfd10f512d8e9166061
    Reviewed-on: https://gerrit.libreoffice.org/50402
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 987533e186b2..9cc62a072abc 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3413,31 +3413,33 @@ sal_Int32 lcl_CalculateDir(const double dX, const double dY)
 
 void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
 {
-    if( !GetProperty( rXPropSet, "InteropGrabBag" ) )
-        return;
-
     Sequence< PropertyValue > aGrabBag, aEffects, aOuterShdwProps;
-    mAny >>= aGrabBag;
-    for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
+    if( GetProperty( rXPropSet, "InteropGrabBag" ) )
     {
-        if( aGrabBag[i].Name == "EffectProperties" )
+        mAny >>= aGrabBag;
+        for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
         {
-            aGrabBag[i].Value >>= aEffects;
-            for( sal_Int32 j=0; j < aEffects.getLength(); ++j )
+            if( aGrabBag[i].Name == "EffectProperties" )
             {
-                if( aEffects[j].Name == "outerShdw" )
+                aGrabBag[i].Value >>= aEffects;
+                for( sal_Int32 j=0; j < aEffects.getLength(); ++j )
                 {
-                    aEffects[j].Value >>= aOuterShdwProps;
-                    break;
+                    if( aEffects[j].Name == "outerShdw" )
+                    {
+                        aEffects[j].Value >>= aOuterShdwProps;
+                        break;
+                    }
                 }
+                break;
             }
-            break;
         }
     }
+
     if( aEffects.getLength() == 0 )
     {
         bool bHasShadow = false;
-        rXPropSet->getPropertyValue( "Shadow" ) >>= bHasShadow;
+        if( GetProperty( rXPropSet, "Shadow" ) )
+            mAny >>= bHasShadow;
         if( bHasShadow )
         {
             Sequence< PropertyValue > aShadowGrabBag( 3 );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index b9a19bf506b4..83b9ae72aeeb 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1866,6 +1866,7 @@ ShapeExport& ShapeExport::WriteTextShape( const Reference< XShape >& xShape )
     uno::Reference<beans::XPropertySet> xPropertySet(xShape, UNO_QUERY);
     WriteBlipOrNormalFill(xPropertySet, "Graphic");
     WriteOutline(xPropertySet);
+    WriteShapeEffects(xPropertySet);
     pFS->endElementNS( mnXmlNamespace, XML_spPr );
 
     WriteTextBox( xShape, mnXmlNamespace );
diff --git a/sd/qa/unit/data/pptx/tdf111789.pptx b/sd/qa/unit/data/pptx/tdf111789.pptx
new file mode 100755
index 000000000000..32d7d754a0c2
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf111789.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index ed282a6e787b..9fb9d4ab6ff0 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -132,6 +132,7 @@ public:
     void testTdf115394();
     void testTdf115394Zero();
     void testBulletsAsImage();
+    void testTdf111789();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -189,6 +190,7 @@ public:
     CPPUNIT_TEST(testTdf115394);
     CPPUNIT_TEST(testTdf115394Zero);
     CPPUNIT_TEST(testBulletsAsImage);
+    CPPUNIT_TEST(testTdf111789);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1499,6 +1501,43 @@ void SdOOXMLExportTest2::testBulletsAsImage()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testTdf111789()
+{
+    // Shadow properties were not exported for text shapes.
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf111789.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+    // First text shape has some shadow
+    {
+        uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+        bool bHasShadow = false;
+        xShape->getPropertyValue("Shadow") >>= bHasShadow;
+        CPPUNIT_ASSERT(bHasShadow);
+        double fShadowDist = 0.0;
+        xShape->getPropertyValue("ShadowXDistance") >>= fShadowDist;
+        CPPUNIT_ASSERT_EQUAL(static_cast<double>(273), fShadowDist);
+        xShape->getPropertyValue("ShadowYDistance") >>= fShadowDist;
+        CPPUNIT_ASSERT_EQUAL(static_cast<double>(273), fShadowDist);
+        sal_Int32 nColor = 0;
+        xShape->getPropertyValue("ShadowColor") >>= nColor;
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xFF0000), nColor);
+        sal_Int32 nTransparency = 0;
+        xShape->getPropertyValue("ShadowTransparence") >>= nTransparency;
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7), nTransparency);
+    }
+
+    // Second text shape has no shadow
+    {
+        uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, xDocShRef ) );
+        bool bHasShadow = false;
+        xShape->getPropertyValue("Shadow") >>= bHasShadow;
+        CPPUNIT_ASSERT(!bHasShadow);
+    }
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list