diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-12-16 14:19:16 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-12-17 16:51:44 +0100 |
commit | fe8f2b23beff1e886e1b0be9b95260f58be1e742 (patch) | |
tree | c90208e0c824174297b478c306f228dd65d2847f | |
parent | 6f45e70aadcfb1930a0955c140e1811689b28be6 (diff) |
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.
(cherry picked from commit 252cdd5f43d65095543e317d37e1a0ea4fd839e0)
Conflicts:
oox/source/export/drawingml.cxx
Change-Id: Icf0b90c5b44e3d9c4115c9f3b0d56ba0852ab640
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107881
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 38 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 3 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 4 |
3 files changed, 32 insertions, 13 deletions
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index b86e5ad2e665..a5be52f66c9e 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -301,21 +301,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(); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 94e7da1f2aa7..db2cb733bebc 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3818,7 +3818,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), diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 8e3305800c78..60b88181b5dc 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1639,7 +1639,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 ); |