diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-02-05 21:19:32 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-02-08 11:47:51 +0100 |
commit | 560f9bac4c1ee1b044efc55af8d532e9efefd313 (patch) | |
tree | 5e7e3e4abdc3049e46e6e7729833aafe729ee1b6 /oox | |
parent | 63d3bf99101e2138a21a74a3d717d4f25d3d242f (diff) |
oox: prefix VML shapetype ids with _x0000_t
Word 2013 refuses to even load a file that has a <v:shapetype
id="shapetype_75"> 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 <michael.stahl@allotropia.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/preset-definitions-to-shape-types.pl | 2 | ||||
-rw-r--r-- | oox/source/export/vmlexport.cxx | 6 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 4 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 6 |
4 files changed, 14 insertions, 4 deletions
diff --git a/oox/source/export/preset-definitions-to-shape-types.pl b/oox/source/export/preset-definitions-to-shape-types.pl index f6bd260f7cde..5760a8609070 100644 --- a/oox/source/export/preset-definitions-to-shape-types.pl +++ b/oox/source/export/preset-definitions-to-shape-types.pl @@ -985,7 +985,7 @@ sub end_element( $ ) $state = ""; # shape path - my $out = "<v:shapetype id=\"shapetype___ID__\" coordsize=\"21600,21600\" o:spt=\"__ID__\" "; + my $out = "<v:shapetype id=\"_x0000_t__ID__\" coordsize=\"21600,21600\" o:spt=\"__ID__\" "; if ( $adjust ne "" ) { $out .= "adj=\"$adjust\" "; } diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 16635228e93a..9aa51f583bd4 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1232,7 +1232,7 @@ OString VMLExport::GetVMLShapeTypeDefinition( if ( !bIsPictureFrame ) // We don't have a shape definition for host control in presetShapeDefinitions.xml // So use a definition copied from DOCX file created with MSO - sShapeType = OString::Concat("<v:shapetype id=\"shapetype_") + sShapeID + + sShapeType = OString::Concat("<v:shapetype id=\"_x0000_t") + sShapeID + "\" coordsize=\"21600,21600\" o:spt=\"" + sShapeID + "\" path=\"m,l,21600l21600,21600l21600,xe\">\n" "<v:stroke joinstyle=\"miter\"/>\n" @@ -1242,7 +1242,7 @@ OString VMLExport::GetVMLShapeTypeDefinition( else // We don't have a shape definition for picture frame in presetShapeDefinitions.xml // So use a definition copied from DOCX file created with MSO - sShapeType = OString::Concat("<v:shapetype id=\"shapetype_") + sShapeID + + sShapeType = OString::Concat("<v:shapetype id=\"_x0000_t") + sShapeID + "\" coordsize=\"21600,21600\" o:spt=\"" + sShapeID + "\" o:preferrelative=\"t\" path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">\n" "<v:stroke joinstyle=\"miter\"/>\n" @@ -1414,7 +1414,7 @@ sal_Int32 VMLExport::StartShape() if (m_bUseHashMarkForType) sTypeBuffer.append("#"); m_pShapeAttrList->add( XML_type, sTypeBuffer - .append( "shapetype_" ).append( sal_Int32( m_nShapeType ) ) + .append( "_x0000_t" ).append( sal_Int32( m_nShapeType ) ) .makeStringAndClear() ); } 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 |