tdf#129961 oox: add PPTX export for table shadow as direct format
Custom shapes export shadow as part of WriteShapeEffects(), so use the same for table shapes as well. This needs fixing the effect export up a bit, because table shapes have no interop grab-bag, glow or soft edge properties, but the rest of the code can be shared. Change-Id: Icf0b90c5b44e3d9c4115c9f3b0d56ba0852ab640 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107836 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
+27
-11
@@ -293,21 +293,37 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testCameraRotationRevolution)
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTableShadow)
|
||||
{
|
||||
auto verify = [](const uno::Reference<lang::XComponent>& xComponent) {
|
||||
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
|
||||
uno::Reference<drawing::XDrawPage> xDrawPage(
|
||||
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
|
||||
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
|
||||
bool bShadow = false;
|
||||
CPPUNIT_ASSERT(xShape->getPropertyValue("Shadow") >>= bShadow);
|
||||
|
||||
CPPUNIT_ASSERT(bShadow);
|
||||
sal_Int32 nColor = 0;
|
||||
CPPUNIT_ASSERT(xShape->getPropertyValue("ShadowColor") >>= nColor);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xff0000), nColor);
|
||||
};
|
||||
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "table-shadow.pptx";
|
||||
load(aURL);
|
||||
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
|
||||
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
|
||||
uno::UNO_QUERY);
|
||||
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
|
||||
bool bShadow = false;
|
||||
CPPUNIT_ASSERT(xShape->getPropertyValue("Shadow") >>= bShadow);
|
||||
|
||||
// Without the accompanying fix in place, this test would have failed, because shadow on a table
|
||||
// was lost on import.
|
||||
CPPUNIT_ASSERT(bShadow);
|
||||
sal_Int32 nColor = 0;
|
||||
CPPUNIT_ASSERT(xShape->getPropertyValue("ShadowColor") >>= nColor);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xff0000), nColor);
|
||||
verify(getComponent());
|
||||
|
||||
uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY);
|
||||
utl::MediaDescriptor aMediaDescriptor;
|
||||
aMediaDescriptor["FilterName"] <<= OUString("Impress Office Open XML");
|
||||
utl::TempFile aTempFile;
|
||||
aTempFile.EnableKillingFile();
|
||||
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
|
||||
getComponent()->dispose();
|
||||
validate(aTempFile.GetFileName(), test::OOXML);
|
||||
getComponent() = loadFromDesktop(aTempFile.GetURL());
|
||||
// Without the accompanying fix in place, this test would have failed, because shadow on a table
|
||||
// was lost on export.
|
||||
verify(getComponent());
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
@@ -4056,7 +4056,8 @@ static sal_Int32 lcl_CalculateDir(const double dX, const double dY)
|
||||
void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
|
||||
{
|
||||
Sequence< PropertyValue > aGrabBag, aEffects, aOuterShdwProps;
|
||||
if( GetProperty( rXPropSet, "InteropGrabBag" ) )
|
||||
bool bHasInteropGrabBag = rXPropSet->getPropertySetInfo()->hasPropertyByName("InteropGrabBag");
|
||||
if (bHasInteropGrabBag && GetProperty(rXPropSet, "InteropGrabBag"))
|
||||
{
|
||||
mAny >>= aGrabBag;
|
||||
auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
|
||||
@@ -4206,6 +4207,11 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
|
||||
|
||||
void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet)
|
||||
{
|
||||
if (!rXPropSet->getPropertySetInfo()->hasPropertyByName("GlowEffectRadius"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sal_Int32 nRad = 0;
|
||||
rXPropSet->getPropertyValue("GlowEffectRadius") >>= nRad;
|
||||
if (!nRad)
|
||||
@@ -4228,6 +4234,11 @@ void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet)
|
||||
|
||||
void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet)
|
||||
{
|
||||
if (!rXPropSet->getPropertySetInfo()->hasPropertyByName("SoftEdgeRadius"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sal_Int32 nRad = 0;
|
||||
rXPropSet->getPropertyValue("SoftEdgeRadius") >>= nRad;
|
||||
if (!nRad)
|
||||
|
||||
@@ -1590,7 +1590,9 @@ void ShapeExport::WriteTable( const Reference< XShape >& rXShape )
|
||||
if ( xPropSet.is() && ( xPropSet->getPropertyValue( "Model" ) >>= xTable ) )
|
||||
{
|
||||
mpFS->startElementNS(XML_a, XML_tbl);
|
||||
mpFS->singleElementNS(XML_a, XML_tblPr);
|
||||
mpFS->startElementNS(XML_a, XML_tblPr);
|
||||
WriteShapeEffects(xPropSet);
|
||||
mpFS->endElementNS(XML_a, XML_tblPr);
|
||||
|
||||
Reference< container::XIndexAccess > xColumns( xTable->getColumns(), UNO_QUERY_THROW );
|
||||
Reference< container::XIndexAccess > xRows( xTable->getRows(), UNO_QUERY_THROW );
|
||||
|
||||
Reference in New Issue
Block a user