Created attachment 200719 [details] Sample DOCX Open and save attached DOCX back to DOCX back in Writer, then try opening it in Word. => Word fails to open the file cleanly. This happens with some Word versions (eg. 2013), but not all. When attempting repairs, Word points at word/footer3.xml, and when investigating further, the problem is that there are multiple 'docPr' elements with the same 'id' attribute: - in word/footer2.xml: <wp:docPr id="6" name="Grafik 6" descr="" title=""/> - in word/footer3.xml: <wp:docPr id="6" name="Textfeld 5"/> Observed using LO 25.8.0.0.alpha0+ (736998ccef0bacdd2bbf038c98dacfbe654f1a4d) / Windows. The OOXML specification states this under docPr (Drawing Object Non-Visual Properties) for the 'id' attribute: "Specifies a unique identifier for the current DrawingML object within the current document." The original document only has one footer XML (word/footer1.xml), and the exported file started having multiples since the following commit in 24.2: https://git.libreoffice.org/core/commit/4b0fa253a4540f5461397815d290586f9ddabe61 https://cgit.freedesktop.org/libreoffice/core/commit/?id=4b0fa253a4540f5461397815d290586f9ddabe61 author Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Tue Nov 28 13:46:21 2023 +0900 committer Tomaž Vajngerl <quikee@gmail.com> Fri Dec 01 08:26:38 2023 +0100 "tdf#136472 adjust ooxml import to handle first header/footer" While the bug only comes up since the above commit, another change affected the numbering of the 'id' attributes in 7.6/7.5.4: https://git.libreoffice.org/core/commit/7460e4f4a7b15cc7984adf65bc17e3d580413224 https://cgit.freedesktop.org/libreoffice/core/commit/?id=7460e4f4a7b15cc7984adf65bc17e3d580413224 author Tünde Tóth <toth.tunde@nisz.hu> Wed Mar 29 15:09:11 2023 +0200 committer László Németh <nemeth@numbertext.org> Tue Apr 11 19:35:57 2023 +0200 "tdf#154469 DOCX export: fix hyperlink in group shape" From this commit, the following happens in a couple of places in sw/source/filter/ww8/docxattributeoutput.cxx: m_rExport.GetFilter().SetMaxDocId(m_anchorId + 1); ... (uses and increments m_anchorId) m_anchorId = m_rExport.GetFilter().GetMaxDocId(); The change isn't explained in the commit, and doesn't seem directly related to the fixed issue. However, cNvPr (Non-Visual Drawing Properties) also has an 'id' attribute, and both ids are identifiers for the current DrawingML object, and are supposed to be unique in the document. Perhaps the change is supposed to ensure that (m_anchorId becomes docPr's id, while MaxDocId is used as a counter for the id of eg. a shape's cNvPr), but can cause a clash of ids within docPr's.
Aron Budea committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/37e4623bfaad6bd9e74205f0040b68d92d976f1b tdf#166511 sw: unify export of DrawingML object IDs It will be available in 25.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.