[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - oox/source sd/qa

Tamás Zolnai tamas.zolnai at collabora.com
Mon Feb 6 12:18:14 UTC 2017


 oox/source/ppt/slidepersist.cxx     |    5 ++++-
 sd/qa/unit/data/pptx/tdf105739.pptx |binary
 sd/qa/unit/export-tests.cxx         |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit 92da1a25b5dd59c99d07b6639a36f4dd3cfe3c3e
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Mon Feb 6 13:13:55 2017 +0100

    tdf#31488: Background fill changes its color when saving a PPTX file to ODP
    
    For a gradient fill we need to generate a name because
    ODP export works with this name.
    In case of shapes it works because when fill attribute
    changes some internal name generation is triggered.
    The same thing doesn't work for slide background
    so generate this name explicitely in oox code.
    
    Reviewed-on: https://gerrit.libreoffice.org/33937
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit aeece6f198685b96579bdbd1409b3535fb5f09d1)
    
    Change-Id: Ic6ebf37ef3d66a9c274747ca04653363b1fe6d02

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index f527868..e11a534 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -168,7 +168,10 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
     {
         sal_Int32 nPhClr = mpBackgroundPropertiesPtr->getBestSolidColor().getColor( rFilterBase.getGraphicHelper() );
 
-        ::oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );
+        std::vector<sal_Int32> aPropertyIds = (oox::drawingml::ShapePropertyInfo::DEFAULT).maPropertyIds;
+        aPropertyIds[oox::drawingml::ShapePropertyId::SHAPEPROP_FillGradient] = PROP_FillGradientName;
+        oox::drawingml::ShapePropertyInfo aPropInfo( aPropertyIds.data(), true, false, true, false );
+        oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper(), aPropInfo );
         mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr );
         PropertySet( mxPage ).setProperty( PROP_Background, aPropMap.makePropertySet() );
     }
diff --git a/sd/qa/unit/data/pptx/tdf105739.pptx b/sd/qa/unit/data/pptx/tdf105739.pptx
new file mode 100755
index 0000000..08e26f5
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf105739.pptx differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 1065760..927aef8 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -146,6 +146,7 @@ public:
     void testTdf80224();
     void testTdf92527();
     void testTdf99224();
+    void testTdf105739();
 
     CPPUNIT_TEST_SUITE(SdExportTest);
     CPPUNIT_TEST(testFdo90607);
@@ -191,6 +192,7 @@ public:
     CPPUNIT_TEST(testExportTransitionsPPTX);
     CPPUNIT_TEST(testTdf92527);
     CPPUNIT_TEST(testTdf99224);
+    CPPUNIT_TEST(testTdf105739);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1515,6 +1517,38 @@ void SdExportTest::testTdf99224()
     xShell->DoClose();
 }
 
+void SdExportTest::testTdf105739()
+{
+    // Gradient was lost during saving to ODP
+    sd::DrawDocShellRef xShell = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/tdf105739.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xShell = saveAndReload(xShell.get(), ODP, &tempFile);
+    uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
+    uno::Reference<beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
+    uno::Any aAny = xPropSet->getPropertyValue("Background");
+    CPPUNIT_ASSERT(aAny.hasValue());
+    if (aAny.hasValue())
+    {
+        uno::Reference< beans::XPropertySet > aXBackgroundPropSet;
+        aAny >>= aXBackgroundPropSet;
+
+        // Test fill type
+        drawing::FillStyle aFillStyle(drawing::FillStyle_NONE);
+        aXBackgroundPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, aFillStyle);
+
+        // Test gradient properties
+        com::sun::star::awt::Gradient aFillGradient;
+        aXBackgroundPropSet->getPropertyValue("FillGradient") >>= aFillGradient;
+        CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aFillGradient.Style);
+        CPPUNIT_ASSERT_EQUAL(util::Color(0xff0000), aFillGradient.StartColor);
+        CPPUNIT_ASSERT_EQUAL(util::Color(0x00b050), aFillGradient.EndColor);
+    }
+
+    xShell->DoClose();
+}
+
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list