diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index d666b3d332a7..c7e72d458194 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -293,21 +293,37 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testCameraRotationRevolution) CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTableShadow) { + auto verify = [](const uno::Reference& xComponent) { + uno::Reference xDrawPagesSupplier(xComponent, uno::UNO_QUERY); + uno::Reference xDrawPage( + xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + uno::Reference 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(0xff0000), nColor); + }; OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "table-shadow.pptx"; load(aURL); - uno::Reference xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); - uno::Reference xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), - uno::UNO_QUERY); - uno::Reference 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(0xff0000), nColor); + verify(getComponent()); + + uno::Reference 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(); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f291de8662ef..f073fd21f06e 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -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& rXPropSet) { + if (!rXPropSet->getPropertySetInfo()->hasPropertyByName("SoftEdgeRadius")) + { + return; + } + sal_Int32 nRad = 0; rXPropSet->getPropertyValue("SoftEdgeRadius") >>= nRad; if (!nRad) diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index a524d44c9ed4..aae5ed633d85 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -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 );