oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx |binary oox/qa/unit/vml.cxx | 18 +++++++++++ oox/source/vml/vmlshape.cxx | 7 ++-- 3 files changed, 22 insertions(+), 3 deletions(-)
New commits: commit 2598f40521c6a8dee6d59ca41c3e58e65a98b17f Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Thu Feb 2 15:22:52 2023 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Thu Feb 2 16:53:49 2023 +0000 tdf#153258 VML import improve WordArt detection There exists WordArt types whose internal name do not start with 'fontwork', e.g. mso_sptTextDeflateInflateDeflate has 'mso-spt167'. The fix uses the MSO_SPT enum directly. Change-Id: Idb32b3ef9957bef5d948e1d86507d71fef006e91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146503 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx b/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx new file mode 100644 index 000000000000..15944490e9ed Binary files /dev/null and b/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx differ diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx index be99a281af04..c46475efe418 100644 --- a/oox/qa/unit/vml.cxx +++ b/oox/qa/unit/vml.cxx @@ -224,6 +224,24 @@ CPPUNIT_TEST_FIXTURE(OoxVmlTest, testWriterFontworkTrimTrue) CPPUNIT_ASSERT_DOUBLES_EQUAL(4999, aSize.Height, 2); } +CPPUNIT_TEST_FIXTURE(OoxVmlTest, testVMLDetectWordArtOnImport) +{ + // The document contains a WordArt shape with type other than "fontwork-foo". Error was that + // WordArt was not detected and thus shrinking shape to text content was not prevented. + loadFromURL(u"tdf153258_VML_import_WordArt_detection.docx"); + + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(xDrawPageSupplier->getDrawPage()->getByIndex(0), + uno::UNO_QUERY); + + // Make sure the shape width and height is not changed. + awt::Size aSize = xShape->getSize(); + // Without the fix the test would have failed with expected 7514 actual 1453. + CPPUNIT_ASSERT_DOUBLES_EQUAL(7514, aSize.Width, 2); + // Without the fix the test would have failed with expected 4540 actual 309. + CPPUNIT_ASSERT_DOUBLES_EQUAL(4540, aSize.Height, 2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index abbf4fd7f9d6..bdbea0c86fc4 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -63,7 +63,7 @@ #include <oox/vml/vmltextbox.hxx> #include <oox/core/xmlfilterbase.hxx> #include <oox/helper/containerhelper.hxx> -#include <svx/EnhancedCustomShapeTypeNames.hxx> +#include <svx/msdffdef.hxx> #include <svx/sdtagitm.hxx> #include <svx/svdobj.hxx> #include <comphelper/sequence.hxx> @@ -716,10 +716,11 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes SdrObject* pShape = SdrObject::getSdrObjectFromXShape(xShape); if( pShape && getShapeType() >= 0 ) { - OUString aShapeType = EnhancedCustomShapeTypeNames::Get( static_cast< MSO_SPT >(getShapeType()) ); //The resize autoshape to fit text attr of FontWork/Word-Art should always be false //for the fallback geometry. - if(aShapeType.startsWith("fontwork")) + sal_Int32 nType = getShapeType(); + if((mso_sptTextSimple <= nType && nType <= mso_sptTextOnRing) + || (mso_sptTextPlainText <= nType && nType <= mso_sptTextCanDown)) { pShape->SetMergedItem(makeSdrTextAutoGrowHeightItem(false)); pShape->SetMergedItem(makeSdrTextAutoGrowWidthItem(false));