[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - filter/source sw/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 17 15:52:50 UTC 2020


 filter/source/msfilter/eschesdo.cxx       |   37 +++++++++++++++++++++++-------
 sw/qa/extras/ww8export/data/tdf128501.doc |binary
 sw/qa/extras/ww8export/ww8export3.cxx     |   17 +++++++++++++
 3 files changed, 46 insertions(+), 8 deletions(-)

New commits:
commit 33d85de4b964638192eabdb5753a5ca87d6892b7
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Dec 1 19:17:24 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Dec 17 16:52:15 2020 +0100

    tdf#128501: DOC export: fix lost bitmap fill for OOXML custom shapes
    
    this fix is based on 7032be2e9edd82dad2d67f1582aaa57676bda4a1
    which fixes the same problem for PPT filter
    
    Change-Id: Id62c29892dd3fce42d27e2e46a7933154cb973f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107003
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit 2f9325b270fab10f6900aec30ca27135363c4c69)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107094
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx
index efe3c908b6b4..1443b46702c6 100644
--- a/filter/source/msfilter/eschesdo.cxx
+++ b/filter/source/msfilter/eschesdo.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/drawing/CircleKind.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <comphelper/extract.hxx>
 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
 #include <basegfx/matrix/b2dhommatrix.hxx>
@@ -263,15 +264,35 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj,
             }
             else
             {
-                addShape(sal::static_int_cast< sal_uInt16 >(eShapeType),
-                         nMirrorFlags | ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor);
-                aPropOpt.CreateCustomShapeProperties( eShapeType, rObj.GetShapeRef() );
-                aPropOpt.CreateFillProperties( rObj.mXPropSet, true );
-                if ( rObj.ImplGetText() )
+                const Reference< XPropertySet > xPropSet = rObj.mXPropSet;
+                drawing::FillStyle eFS = drawing::FillStyle_NONE;
+                if(xPropSet.is())
+                {
+                    uno::Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
+                    if ( xPropInfo.is() && xPropInfo->hasPropertyByName("FillStyle"))
+                        xPropSet->getPropertyValue("FillStyle") >>= eFS;
+                }
+
+                if (eFS == drawing::FillStyle_BITMAP && eShapeType == mso_sptMax)
+                {
+                    // We can't map this custom shape to a DOC preset and it has a bitmap fill.
+                    // Make sure that at least the bitmap fill is not lost.
+                    addShape( ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor );
+                    if ( aPropOpt.CreateGraphicProperties( rObj.mXPropSet, "Bitmap", false, true, true, bOOxmlExport ) )
+                        aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
+                }
+                else
                 {
-                    if ( !aPropOpt.IsFontWork() )
-                        aPropOpt.CreateTextProperties( rObj.mXPropSet, mpEscherEx->QueryTextID(
-                            rObj.GetShapeRef(), rObj.GetShapeId() ), true, false );
+                    addShape(sal::static_int_cast< sal_uInt16 >(eShapeType),
+                             nMirrorFlags | ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor);
+                    aPropOpt.CreateCustomShapeProperties( eShapeType, rObj.GetShapeRef() );
+                    aPropOpt.CreateFillProperties( rObj.mXPropSet, true );
+                    if ( rObj.ImplGetText() )
+                    {
+                        if ( !aPropOpt.IsFontWork() )
+                            aPropOpt.CreateTextProperties( rObj.mXPropSet, mpEscherEx->QueryTextID(
+                                rObj.GetShapeRef(), rObj.GetShapeId() ), true, false );
+                    }
                 }
             }
         }
diff --git a/sw/qa/extras/ww8export/data/tdf128501.doc b/sw/qa/extras/ww8export/data/tdf128501.doc
new file mode 100644
index 000000000000..3313e397a961
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf128501.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index a663a034074b..7d8756fbe6cb 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -71,6 +71,23 @@ DECLARE_WW8EXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc")
                          aMap["NumberingType"].get<sal_uInt16>());
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf128501, "tdf128501.doc")
+{
+    if (!mbExported)
+    {
+        uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = getShape(1);
+        CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShapeDescriptor->getShapeType());
+    }
+    else
+    {
+        uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = getShape(1);
+        // Without the fix in place, this test would have failed with
+        // - Expected: FrameShape
+        // - Actual  : com.sun.star.drawing.CustomShape
+        CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType());
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(SwModelTestBase, testArabicZeroNumberingFootnote)
 {
     // Create a document, set footnote numbering type to ARABIC_ZERO.


More information about the Libreoffice-commits mailing list