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 a8bba60e8b655167ad91edcd0c2d1723d525b546 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Fri May 17 20:03:10 2019 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sat May 18 12:41:09 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. Change-Id: I32617c1a11cf3bafb142f7c8839b498aaac49aa0 Reviewed-on: https://gerrit.libreoffice.org/72500 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@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 e7cf6ffb0511..5fc2e802f82b 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -161,7 +161,7 @@ static void ResolveTextFields( XmlFilterBase const & rFilter ) } void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, - const OUString& sTheme) + sal_Int32 nThemeIdx) { if (!pThemePtr) return; @@ -199,8 +199,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; @@ -279,10 +282,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_SET_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 ); @@ -312,7 +322,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 ba6bd727845c..3fd98f4b99bb 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -200,6 +200,8 @@ public: void testPotxExport(); void testTdf44223(); void testSmartArtPreserve(); + void testTdf125346(); + void testTdf125346_2(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -282,6 +284,8 @@ public: CPPUNIT_TEST(testPotxExport); CPPUNIT_TEST(testTdf44223); CPPUNIT_TEST(testSmartArtPreserve); + CPPUNIT_TEST(testTdf125346); + CPPUNIT_TEST(testTdf125346_2); CPPUNIT_TEST_SUITE_END(); @@ -2167,6 +2171,77 @@ void SdOOXMLExportTest2::testSmartArtPreserve() 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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits