diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2023-02-02 15:22:52 +0100 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2023-02-02 16:53:49 +0000 |
commit | 2598f40521c6a8dee6d59ca41c3e58e65a98b17f (patch) | |
tree | 707e23733d823acac8d292d5a8697cedde4c6a2e /oox | |
parent | 333183d9a72d1e2b7ae65145092efec5e357ad14 (diff) |
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.henschel@t-online.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx | bin | 0 -> 51228 bytes | |||
-rw-r--r-- | oox/qa/unit/vml.cxx | 18 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 7 |
3 files changed, 22 insertions, 3 deletions
diff --git a/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx b/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx Binary files differnew file mode 100644 index 000000000000..15944490e9ed --- /dev/null +++ b/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx 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)); |