Bug 168977 - FILESAVE DOCX Document with chart in footer can't be opened in Word after roundtrip
Summary: FILESAVE DOCX Document with chart in footer can't be opened in Word after rou...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
7.2.0.4 release
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:26.8.0 target:26.2.0.2
Keywords: bibisected, bisected, regression
: 169198 (view as bug list)
Depends on:
Blocks: DOCX-Header-Footer DOCX-Corrupted
  Show dependency treegraph
 
Reported: 2025-10-21 08:00 UTC by Aron Budea
Modified: 2026-01-12 17:43 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2025-10-21 08:00:08 UTC
Open attachment 96041 [details] from bug 76356 (in other name, fdo76356-1.docx), a DOCX, save it back to DOCX format, and try opening it in Word.

=> Word can't open the file cleanly.

If one:
- unzips the saved DOCX,
- executes the following command (can be done in Linux/Cygwin, needs xmllint installed): find . \( -name "*.xml" -o -name "*.rels" \) -type f -exec xmllint --output '{}' --format '{}' \;
- rezips the files with DOCX extension,

Word points to line 37 in word/document.xml, which is this line:
<w:footerReference w:type="first" r:id="rId7"/>
(rId7 refers to footer3.xml)

Observed with LO 26.2.0.0.alpha0+ (8ea8e254a3151f5390f3a10ff156fcaf8e7c5d5c), 7.2.0.4 / Windows.

This is a regression/implementation error from the following commit in 7.2, before that only a single header/footer XML was exported:
author		Daniel Arato (NISZ) <arato.daniel@nisz.hu>	Fri Feb 05 12:07:48 2021 +0100
committer	László Németh <nemeth@numbertext.org>	Tue May 04 19:14:22 2021 +0200

tdf#69635 DOCX: export hidden (shared) headers/footers
Comment 1 Justin L 2026-01-08 15:42:08 UTC
The problem here seems to be that both chart1 and chart2 refer to the exact same ../embedding file. Although one would think that is exactly what the point of having these things be as separate entries, apparently that is not good?

(So I tried this in Word 2024 - I copied the OLE footer object into a "first page" - just like the RT does. It did indeed create two identical embeddings...)

In any case, I could manually solve this by copying to 'Microsoft_Excel_Macro-Enabled_Worksheet2.xlsm', then pointing to this file in charts/_rels, and adding a corresponding entry to [Content Types].xml
Comment 2 Justin L 2026-01-08 18:06:48 UTC
AFAICS, we only round-trip OOEmbeddings. On import, we seem to look to see if they are actually referenced, and if so, then we dump them into UNO_NAME_MISC_OBJ_INTEROPGRABBAG, and at export time we just WriteEmbeddings and simply dump them out again.

So then the key seems to be to simply avoid creating a
 <c:externalData>
when we duplicate a chart
Comment 3 Justin L 2026-01-08 18:24:49 UTC
*** Bug 169198 has been marked as a duplicate of this bug. ***
Comment 4 Commit Notification 2026-01-09 19:11:11 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/81a1539bf2e197de1275af762b26e98652551a8a

tdf#168977 docx export: prevent multiple chart rels to embeddings/file

It will be available in 26.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.
Comment 5 Commit Notification 2026-01-12 17:43:27 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/19a96b19444a69cb36251e682c87322b1169a98f

tdf#168977 docx export: prevent multiple chart rels to embeddings/file

It will be available in 26.2.0.2.

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.