sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 11 ++++++++++- sw/source/filter/ww8/docxsdrexport.cxx | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-)
New commits: commit b2700993fa4eb9c065a0f81470dfca4ecd60afda Author: [email protected] <[email protected]> AuthorDate: Tue Jan 20 17:41:15 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Thu Jan 22 14:10:44 2026 +0100 mso-test docx export: skip invalid when empty a:graphicData This focused on the document forum-mso-de-109776.docx. It was reported as corrupt by MS Word when LO round-tripped it as DOCX. This patch depends on the previous one: mso-test tdf#73254 xlsx export: invalid xdr:twoCellAnchor Unit test testTdf141173_missingFrames is interesting. Before (when we were exporting an empty graphicData) the import read the DML, saw an unusable graphic, and skipped it altogether. Now that is has to read a valid VML shape description, it creates the extra shape. So by not writing some shape data, we retain an extra shape. ake CppunitTest_sw_ooxmlexport16 CPPUNIT_TEST_NAME=testTdf148671 Change-Id: I9db23dba4b1298a8193461b5452af54d0ca946de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197705 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 9210da630603..266105b85de4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -484,6 +484,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf148671) // Preserve tag on SDT blocks. (Before the fix, these were all lost) xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:tag", 3); + + // Must not have an empty a:graphic a:graphicData. + // Header2 defines a simple (not visible) VML shape, + // which does not have a DML counterpart. + // Without the accompanying fix, an empty DML a:graphic was exported, + // which MS Word considered egregious enough to report it as corrupt. + xmlDocUniquePtr pXmlHeader = parseExport(u"word/header1.xml"_ustr); + assertXPath(pXmlHeader, "//mc:AlternateContent", 0); // no DML alternative + assertXPath(pXmlHeader, "//w:pict", 1); } DECLARE_OOXMLEXPORT_TEST(testTdf140668, "tdf140668.docx") @@ -592,7 +601,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141173_missingFrames) saveAndReload(TestFilter::DOCX); // Without the fix in place, almost all of the text and textboxes were missing. // Without the fix, there were only 2 shapes (mostly unseen). - CPPUNIT_ASSERT_EQUAL(13, getShapes()); + CPPUNIT_ASSERT_EQUAL(14, getShapes()); } DECLARE_OOXMLEXPORT_TEST(testTdf142404_tabSpacing, "tdf142404_tabSpacing.docx") diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 48b33f5efcec..13fe56ad7f24 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -21,6 +21,7 @@ #include <svx/svdobjkind.hxx> #include <svx/svditer.hxx> #include <svx/EnhancedCustomShape2d.hxx> +#include <oox/export/shapes.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/relationship.hxx> #include <textboxhelper.hxx> @@ -1596,6 +1597,9 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(const uno::Reference<drawing::XSha if (eFillStyle == css::drawing::FillStyle_BITMAP) return false; } + if (!oox::drawingml::ShapeExport::IsValidShape(xShape, drawingml::DOCUMENT_DOCX)) + return false; + return true; }
