From 560f9bac4c1ee1b044efc55af8d532e9efefd313 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 5 Feb 2021 21:19:32 +0100 Subject: oox: prefix VML shapetype ids with _x0000_t Word 2013 refuses to even load a file that has a on some form control shape, reporting a misleading error in a location far later when the top-level w:tbl that contains the shape ends. Using id="_x0000_t75" appears to work, so let's do that then. Couldn't find any documentation on why this is so. Change-Id: Ie22bb04244e24b00a1880544872ae8e281422405 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110493 Tested-by: Jenkins Reviewed-by: Michael Stahl --- oox/source/vml/vmlshape.cxx | 4 ++++ oox/source/vml/vmlshapecontext.cxx | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'oox/source/vml') diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 32c1ec93ed49..b6caaa0f3214 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -312,9 +312,13 @@ void ShapeBase::finalizeFragmentImport() // Temporary fix, shapetype not found if referenced from different substream // FIXME: extend scope of ShapeContainer to store all shapetypes from the document const OUString sShapeTypePrefix = "shapetype_"; + OUString tmp; if (aType.startsWith(sShapeTypePrefix)) { maTypeModel.moShapeType = aType.copy(sShapeTypePrefix.getLength()).toInt32(); } + else if (aType.startsWith("_x0000_t", &tmp)) { + maTypeModel.moShapeType = tmp.toInt32(); + } } } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index e1b87a603173..0d0c00b61d8c 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -295,11 +295,17 @@ ShapeTypeContext::ShapeTypeContext(ContextHandler2Helper const & rParent, mrTypeModel.maShapeName = rAttribs.getXString( XML_id, OUString() ); // get ShapeType and ShapeId from name for compatibility static constexpr OUStringLiteral sShapeTypePrefix = u"shapetype_"; + OUString tmp; if( mrTypeModel.maShapeName.startsWith( sShapeTypePrefix ) ) { mrTypeModel.maShapeId = mrTypeModel.maShapeName; mrTypeModel.moShapeType = mrTypeModel.maShapeName.copy(sShapeTypePrefix.getLength()).toInt32(); } + else if (mrTypeModel.maShapeName.startsWith("_x0000_t", &tmp)) + { + mrTypeModel.maShapeId = mrTypeModel.maShapeName; + mrTypeModel.moShapeType = tmp.toInt32(); + } } // coordinate system position/size, CSS style -- cgit