From b217fa8647fb8f435f481e4f987933ab908710c7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 24 Nov 2025 21:59:22 +0200 Subject: [PATCH] officeotron: fix use of path attribute in vml export which is only valid for v:shape elements Change-Id: If650f3073ff4687bcb90791bc8b15bf009d9c71b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194483 Reviewed-by: Noel Grandin Tested-by: Jenkins --- include/oox/export/vmlexport.hxx | 3 +++ oox/source/export/vmlexport.cxx | 17 ++++++++++------- sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 3 --- sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 3 --- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx index 92ccaaa133cc..3df20ea2dee9 100644 --- a/include/oox/export/vmlexport.hxx +++ b/include/oox/export/vmlexport.hxx @@ -90,6 +90,9 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx /// Remember the shape type. sal_uInt32 m_nShapeType; + /// Remember the value of the path attribute for the shape xml element. + OString m_ShapePath; + /// Remember the shape flags. ShapeFlag m_nShapeFlags; diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 3fe320726136..5800219fa47a 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -103,6 +103,7 @@ void VMLExport::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance ) // opening a shape container SAL_WARN_IF(m_nShapeType != ESCHER_ShpInst_Nil, "oox.vml", "opening shape inside of a shape!"); m_nShapeType = ESCHER_ShpInst_Nil; + m_ShapePath.clear(); m_pShapeAttrList = FastSerializerHelper::createAttrList(); m_ShapeStyle.setLength(0); @@ -127,6 +128,7 @@ void VMLExport::CloseContainer() // cleanup m_nShapeType = ESCHER_ShpInst_Nil; m_pShapeAttrList = nullptr; + m_ShapePath.clear(); } EscherEx::CloseContainer(); @@ -650,13 +652,10 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& break; } } - // path attribute not valid for v:rect - if ( m_nShapeType != ESCHER_ShpInst_Rectangle ) - { - OString pathString = aPath.makeStringAndClear(); - if ( !pathString.isEmpty() && pathString != "xe" ) - m_pShapeAttrList->add( XML_path, pathString ); - } + // We set the path attribute in StartShape() because only then do we know what shape we are writing. + OString pathString = aPath.makeStringAndClear(); + if ( !pathString.isEmpty() && pathString != "xe" ) + m_ShapePath = std::move(pathString); } else SAL_WARN("oox.vml", "unhandled shape path, missing either pVertices or pSegmentInfo."); @@ -1473,6 +1472,10 @@ sal_Int32 VMLExport::StartShape() "_x0000_t" + OString::number( m_nShapeType ) ); } + // path attribute only valid for v:shape + if ( nShapeElement == XML_shape && !m_ShapePath.isEmpty()) + m_pShapeAttrList->add( XML_path, m_ShapePath ); + // allow legacy id (which in form controls and textboxes // by definition seems to have this otherwise illegal name). m_pSerializer->setAllowXEscape(!m_sShapeIDPrefix.startsWith("_x0000_")); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 564b0a5fe2c9..936c07ef350f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -168,9 +168,6 @@ CPPUNIT_TEST_FIXTURE(Test, testShapeEffectPreservation) { createSwDoc("shape-effect-preservation.docx"); - //FIXME: validation error in OOXML export: Errors: 7 - skipValidation(); - save(TestFilter::DOCX); xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 6c1ea023a780..7ed052daf2c3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -730,9 +730,6 @@ CPPUNIT_TEST_FIXTURE(Test, testfdo82492) { createSwDoc("fdo82492.docx"); - // FIXME: validation error in OOXML export: Errors: 1 - skipValidation(); - saveAndReload(TestFilter::DOCX); xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);