Kaydet (Commit) a8bba60e authored tarafından Tamás Zolnai's avatar Tamás Zolnai

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: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst 3c3a371c
......@@ -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;
......
......@@ -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
{
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment