[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/oox oox/source sd/qa

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Sun May 19 19:20:32 UTC 2019


 include/oox/ppt/presentationfragmenthandler.hxx |    2 
 oox/source/ppt/presentationfragmenthandler.cxx  |   20 ++++--
 sd/qa/unit/data/pptx/tdf125346.pptx             |binary
 sd/qa/unit/data/pptx/tdf125346_2.pptx           |binary
 sd/qa/unit/export-tests-ooxml2.cxx              |   75 ++++++++++++++++++++++++
 5 files changed, 91 insertions(+), 6 deletions(-)

New commits:
commit 2506c835834acfdc344227a82f407e3b818db321
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat May 18 15:13:59 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sun May 19 21:20:11 2019 +0200

    tdf#125346: PPTX export: Shape has wrong fill color comming from theme
    
    Write the correct theme path to the InteropGrabBag, the same path
    what is generated and checked in the export code.
    
    Reviewed-on: https://gerrit.libreoffice.org/72500
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit a8bba60e8b655167ad91edcd0c2d1723d525b546)
    
    Change-Id: I32617c1a11cf3bafb142f7c8839b498aaac49aa0
    Reviewed-on: https://gerrit.libreoffice.org/72521
    Tested-by: Jenkins
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/oox/ppt/presentationfragmenthandler.hxx b/include/oox/ppt/presentationfragmenthandler.hxx
index ab24a8262fae..bb9166e24afc 100644
--- a/include/oox/ppt/presentationfragmenthandler.hxx
+++ b/include/oox/ppt/presentationfragmenthandler.hxx
@@ -50,7 +50,7 @@ private:
     void importSlide( const ::oox::core::FragmentHandlerRef& rSlideFragmentHandler,
                         const oox::ppt::SlidePersistPtr& rPersist );
     void importSlide(sal_uInt32 nSlide, bool bFirstSlide, bool bImportNotes);
-    void saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, const OUString& sTheme);
+    void saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, sal_Int32 nThemeIdx);
 
     std::vector< OUString > maSlideMasterVector;
     std::vector< OUString > maSlidesVector;
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index f2477b2cef6e..13bba2da95a3 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -160,7 +160,7 @@ static void ResolveTextFields( XmlFilterBase const & rFilter )
 }
 
 void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr,
-                                                     const OUString& sTheme)
+                                                     sal_Int32 nThemeIdx)
 {
     if (!pThemePtr)
         return;
@@ -198,8 +198,11 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::Theme
                     aCurrentTheme[nId].Value = rColor;
                 }
 
+
                 // add new theme to the sequence
-                aTheme[0].Name = sTheme;
+                // Export code uses the master slide's index to find the right theme
+                // so use the same index in the grabbag.
+                aTheme[0].Name = "ppt/theme/theme" + OUString::number(nThemeIdx) + ".xml";
                 const uno::Any& rCurrentTheme = makeAny(aCurrentTheme);
                 aTheme[0].Value = rCurrentTheme;
 
@@ -273,10 +276,17 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage
                         Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW );
                         Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW );
 
+                        sal_Int32 nIndex;
                         if( rFilter.getMasterPages().empty() )
-                            xMasterPages->getByIndex( 0 ) >>= xMasterPage;
+                        {
+                            nIndex = 0;
+                            xMasterPages->getByIndex( nIndex ) >>= xMasterPage;
+                        }
                         else
-                            xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() );
+                        {
+                            nIndex = xMasterPages->getCount();
+                            xMasterPage = xMasterPages->insertNewByIndex( nIndex );
+                        }
 
                         pMasterPersistPtr = std::make_shared<SlidePersist>( rFilter, true, false, xMasterPage,
                             ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle );
@@ -306,7 +316,7 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage
                                         UNO_QUERY_THROW));
                                 rThemes[ aThemeFragmentPath ] = pThemePtr;
                                 pThemePtr->setFragment(xDoc);
-                                saveThemeToGrabBag(pThemePtr, aThemeFragmentPath);
+                                saveThemeToGrabBag(pThemePtr, nIndex + 1);
                             }
                             else
                             {
diff --git a/sd/qa/unit/data/pptx/tdf125346.pptx b/sd/qa/unit/data/pptx/tdf125346.pptx
new file mode 100644
index 000000000000..32fbbdf52e96
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf125346.pptx differ
diff --git a/sd/qa/unit/data/pptx/tdf125346_2.pptx b/sd/qa/unit/data/pptx/tdf125346_2.pptx
new file mode 100644
index 000000000000..53225581026e
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf125346_2.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 62014c9ee7a0..b712a7d26769 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -196,6 +196,8 @@ public:
     void testTdf118825();
     void testTdf119118();
     void testTdf99213();
+    void testTdf125346();
+    void testTdf125346_2();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -275,6 +277,8 @@ public:
     CPPUNIT_TEST(testTdf118825);
     CPPUNIT_TEST(testTdf119118);
     CPPUNIT_TEST(testTdf99213);
+    CPPUNIT_TEST(testTdf125346);
+    CPPUNIT_TEST(testTdf125346_2);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2043,6 +2047,77 @@ void SdOOXMLExportTest2::testTdf99213()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testTdf125346()
+{
+    // There are two themes in the test document, make sure we use the right theme
+    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125346.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+    uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+    uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_SET_THROW );
+
+    drawing::FillStyle aFillStyle( drawing::FillStyle_NONE );
+    xPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, aFillStyle);
+
+    sal_Int32 nFillColor;
+    xPropSet->getPropertyValue("FillColor") >>= nFillColor;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x90C226), nFillColor);
+
+    xDocShRef->DoClose();
+}
+
+void SdOOXMLExportTest2::testTdf125346_2()
+{
+    // There are two themes in the test document, make sure we use the right theme
+    // Test more slides with different themes
+    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125346_2.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+    {
+        uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+        uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_SET_THROW );
+
+        drawing::FillStyle aFillStyle( drawing::FillStyle_NONE );
+        xPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, aFillStyle);
+
+        sal_Int32 nFillColor;
+        xPropSet->getPropertyValue("FillColor") >>= nFillColor;
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x90C226), nFillColor);
+    }
+
+    {
+        uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 1, xDocShRef ) );
+        uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_SET_THROW );
+
+        drawing::FillStyle aFillStyle( drawing::FillStyle_NONE );
+        xPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, aFillStyle);
+
+        sal_Int32 nFillColor;
+        xPropSet->getPropertyValue("FillColor") >>= nFillColor;
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x052F61), nFillColor);
+    }
+
+    {
+        uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 2, xDocShRef ) );
+        uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_SET_THROW );
+
+        drawing::FillStyle aFillStyle( drawing::FillStyle_NONE );
+        xPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, aFillStyle);
+
+        sal_Int32 nFillColor;
+        xPropSet->getPropertyValue("FillColor") >>= nFillColor;
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x90C226), nFillColor);
+    }
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list