diff options
-rw-r--r-- | include/oox/ppt/presentationfragmenthandler.hxx | 2 | ||||
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 20 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf125346.pptx | bin | 0 -> 22079 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf125346_2.pptx | bin | 0 -> 24482 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 75 |
5 files changed, 91 insertions, 6 deletions
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 Binary files differnew file mode 100644 index 000000000000..32fbbdf52e96 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf125346.pptx diff --git a/sd/qa/unit/data/pptx/tdf125346_2.pptx b/sd/qa/unit/data/pptx/tdf125346_2.pptx Binary files differnew file mode 100644 index 000000000000..53225581026e --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf125346_2.pptx 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(); |