From 33d85de4b964638192eabdb5753a5ca87d6892b7 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 1 Dec 2020 19:17:24 +0100 Subject: 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 (cherry picked from commit 2f9325b270fab10f6900aec30ca27135363c4c69) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107094 Reviewed-by: Miklos Vajna --- filter/source/msfilter/eschesdo.cxx | 37 +++++++++++++++++++++++------- sw/qa/extras/ww8export/data/tdf128501.doc | Bin 0 -> 16587 bytes sw/qa/extras/ww8export/ww8export3.cxx | 17 ++++++++++++++ 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 sw/qa/extras/ww8export/data/tdf128501.doc 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 #include #include +#include #include #include #include @@ -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()); } +DECLARE_WW8EXPORT_TEST(testTdf128501, "tdf128501.doc") +{ + if (!mbExported) + { + uno::Reference xShapeDescriptor = getShape(1); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShapeDescriptor->getShapeType()); + } + else + { + uno::Reference 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. -- cgit v1.2.3