[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - oox/qa oox/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 17 12:58:24 UTC 2020


 oox/qa/unit/drawingml.cxx       |   38 +++++++++++++++++++++++++++-----------
 oox/source/export/drawingml.cxx |   13 ++++++++++++-
 oox/source/export/shapes.cxx    |    4 +++-
 3 files changed, 42 insertions(+), 13 deletions(-)

New commits:
commit dbd0fd75c86983d88f4f62c680deeaa845358c8a
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Dec 16 14:19:16 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Dec 17 13:57:51 2020 +0100

    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)
    
    Change-Id: Icf0b90c5b44e3d9c4115c9f3b0d56ba0852ab640
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107865
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

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<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 918d212cac12..9eeacf4d2b19 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4048,7 +4048,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),
@@ -4198,6 +4199,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)
@@ -4220,6 +4226,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)
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 );


More information about the Libreoffice-commits mailing list