tdf#48083 Import mso_fillBackground from ppt
Change-Id: Ic60fbc5fcfd7b38e7dd594690e5cfe784061a3d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156517
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 8d6f902..bc28e62 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -74,6 +74,7 @@
#include <sfx2/fcontnr.hxx>
#include <svx/xbtmpit.hxx>
#include <svx/xsflclit.hxx>
#include <svx/xfilluseslidebackgrounditem.hxx>
#include <svx/xflgrit.hxx>
#include <svx/xflftrit.hxx>
#include <svx/sdgcpitm.hxx>
@@ -1338,6 +1339,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
if ( nFillFlags & 0x10 )
{
auto eMSO_FillType = GetPropertyValue(DFF_Prop_fillType, mso_fillSolid);
bool bUseSlideBackground = false;
drawing::FillStyle eXFill = drawing::FillStyle_NONE;
switch( eMSO_FillType )
{
@@ -1366,7 +1368,10 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
case mso_fillShadeTitle : // special type - shade to title --- for PP
eXFill = drawing::FillStyle_GRADIENT;
break;
// case mso_fillBackground : // Use the background fill color/pattern
case mso_fillBackground : // Use the background fill color/pattern
eXFill = drawing::FillStyle_NONE;
bUseSlideBackground = true;
break;
default: break;
}
rSet.Put( XFillStyleItem( eXFill ) );
@@ -1466,6 +1471,12 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
}
}
}
else if (eXFill == drawing::FillStyle_BITMAP && bUseSlideBackground)
{
rSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
XFillUseSlideBackgroundItem aFillBgItem(true);
rSet.Put(aFillBgItem);
}
}
else
rSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index fa4c9c5..a4442cf 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -53,6 +53,7 @@
#include <svx/svdopath.hxx>
#include <svx/svdotable.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xfilluseslidebackgrounditem.hxx>
#include <svx/xflbstit.hxx>
#include <svx/xflbmtit.hxx>
#include <svx/xflclit.hxx>
@@ -2930,17 +2931,13 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
{
if (!aProcessData.aBackgroundColoredObjects.empty())
{
if (!rSlidePersist.pBObj)
for (auto const & pObject : aProcessData.aBackgroundColoredObjects)
{
for (auto const & pObject : aProcessData.aBackgroundColoredObjects)
{
// The shape wants a background, but the slide doesn't have
// one: default to white.
SfxItemSet aNewSet(*pObject->GetMergedItemSet().GetPool());
aNewSet.Put(XFillStyleItem(css::drawing::FillStyle_SOLID));
aNewSet.Put(XFillColorItem(OUString(), COL_WHITE));
pObject->SetMergedItemSet(aNewSet);
}
SfxItemSet aNewSet(*pObject->GetMergedItemSet().GetPool());
aNewSet.Put(XFillStyleItem(css::drawing::FillStyle_NONE));
XFillUseSlideBackgroundItem aFillBgItem(true);
aNewSet.Put(aFillBgItem);
pObject->SetMergedItemSet(aNewSet);
}
}
}
diff --git a/sd/qa/unit/data/ppt/tdf48083.ppt b/sd/qa/unit/data/ppt/tdf48083.ppt
new file mode 100644
index 0000000..97ca371
--- /dev/null
+++ b/sd/qa/unit/data/ppt/tdf48083.ppt
Binary files differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 7702e27..525177b 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -581,7 +581,9 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf105150PPT)
// This was drawing::FillStyle_NONE, the shape's mso_fillBackground was
// ignored when the slide didn't have an explicit background fill.
auto& rFillStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue());
auto& rFillBackgroundItem = pObj->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND);
CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem.GetValue());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf104445)
@@ -1488,6 +1490,18 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf127964)
}
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf48083)
{
createSdImpressDoc("ppt/tdf48083.ppt");
const SdrPage* pPage = GetPage(1);
CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
const SdrObject* pObj = pPage->GetObj(1);
auto& rFillStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue());
auto& rFillBackgroundItem = pObj->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND);
CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem.GetValue());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf106638)
{
createSdImpressDoc("pptx/tdf106638.pptx");