summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-02-02 15:22:52 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-02-03 10:02:38 +0000
commit39eb3d9ab448722851d8ffca1061d3cefcb32d0e (patch)
tree91a63876a53b208f6392edab22301cc420f76088
parent1f8d118dd0ea63a73592a712efb364c343c71082 (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> (cherry picked from commit 2598f40521c6a8dee6d59ca41c3e58e65a98b17f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146517 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docxbin0 -> 51228 bytes
-rw-r--r--oox/qa/unit/vml.cxx18
-rw-r--r--oox/source/vml/vmlshape.cxx7
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
new file mode 100644
index 000000000000..15944490e9ed
--- /dev/null
+++ b/oox/qa/unit/data/tdf153258_VML_import_WordArt_detection.docx
Binary files 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));