Bug 115558 - FILESAVE DOCX Charts in footnotes in DOCX documents created with Word cause broken file when saved
Summary: FILESAVE DOCX Charts in footnotes in DOCX documents created with Word cause b...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.1.0.3 release
Hardware: All Windows (All)
: medium normal
Assignee: Aron Budea
URL:
Whiteboard: target:26.8.0 target:26.2.3
Keywords: filter:docx
Depends on:
Blocks: OOXML-Chart DOCX-Corrupted DOCX-Footnote-Endnote
  Show dependency treegraph
 
Reported: 2018-02-08 18:09 UTC by Gabor Kelemen (Collabora)
Modified: 2026-03-13 00:28 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file saved by Word 2013 (34.12 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-02-08 18:09 UTC, Gabor Kelemen (Collabora)
Details
The example file exported by LO 5.4 (21.85 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-02-08 18:09 UTC, Gabor Kelemen (Collabora)
Details
Error message when trying to open the exported file (8.38 KB, image/png)
2018-02-08 18:10 UTC, Gabor Kelemen (Collabora)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (Collabora) 2018-02-08 18:09:04 UTC
Created attachment 139707 [details]
Example file saved by Word 2013

If we create a document with a chart in a footnote in Word, and save it as DOCX, then reopen the file in LibreOffice, and save it again, it causes a broken file and Word is unable open it. 

Steps to reproduce:
1. Create a new document in Microsoft Word.
2. Create a short text with multiple footnotes.
3. Insert a chart in one of the footnotes.
4. Save the document as DOCX and close Word.
5. Open the file in LibreOffice, and save it again with a different filename as DOCX.
6. Attempt to open the file created with LibreOffice in Microsoft Word.

Actual results:
Charts multiply every time we save the file in Writer as DOCX and reopen it, and Microsoft Word is unable to open this DOCX file.

Expected results:
Charts shouldn't multiply, and Word should be able to open the file.
Comment 1 Gabor Kelemen (Collabora) 2018-02-08 18:09:35 UTC
Created attachment 139708 [details]
The example file exported by LO 5.4
Comment 2 Gabor Kelemen (Collabora) 2018-02-08 18:10:16 UTC
Created attachment 139709 [details]
Error message when trying to open the exported file
Comment 3 Timur 2018-02-12 08:50:43 UTC
Repro 5.1 and 6.1+. With 5.0 chart wasn't seen on fileopen.
Comment 4 László Németh 2019-05-27 14:26:59 UTC
Fixed in the commit associated to Bug 115557.
Comment 5 Aron Budea 2025-12-11 15:34:47 UTC
I went back to the commit after the mentioned fix, and checked with a current version, but the result still doesn't open in Word for me. Unzipping the file reveals that 'word/embeddings/Microsoft_Excel_Worksheet1.xlsx' is missing from the archive, while it is referenced in 'word/charts/_rels/chart1.xml.rels', but there seem to be other issues as well, as copying this file over from the original and rezipping the archive doesn't work as a manual fix.
Comment 6 Justin L 2026-03-05 19:12:54 UTC
@Aron, I see your bug 170015 and confirm that one. But at that same point (in LO 7.2) the round-tripped document became openable in MS Word (tested 2024 and 2010). Yet in bug 170015 you say that you still see round-tripping problems using MS Word. I can't confirm.

After round-tripping with both 7.2 and in 26.2/26.8, MS Word doesn't report any corruption opening the round-tripped file.

The problem that you are seeing in 7.1 (if not fixed elsewhere) should be fixed by bug 143269.
Comment 7 Aron Budea 2026-03-05 22:48:18 UTC
(In reply to Justin L from comment #6)
> @Aron, I see your bug 170015 and confirm that one. But at that same point
> (in LO 7.2) the round-tripped document became openable in MS Word (tested
> 2024 and 2010). Yet in bug 170015 you say that you still see round-tripping
> problems using MS Word. I can't confirm.
I forgot to add that I've been testing this on Windows, have you checked using a Windows build? I can still reproduce the issue with a ~week old build.

> The problem that you are seeing in 7.1 (if not fixed elsewhere) should be
> fixed by bug 143269.
Which problem are you referring to? I can't find myself mentioning 7.1.
Comment 8 Justin L 2026-03-05 23:18:35 UTC
(In reply to Aron Budea from comment #7)
> have you checked using a Windows build? 

No, I don't have easy access to Windows builds to check this. Puzzling that the OS would matter here...
Comment 9 Aron Budea 2026-03-07 18:44:10 UTC
At least part of the problem is related to substreams, footnote in this case. The code collects embeddings related to each stream in their own list (mxEmbeddingsList):
https://github.com/LibreOffice/core/blob/ab6f22b162377272a7996402ea7b2e69f753af47/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx#L803

Then in the end the document's embedding list is added to the grabbag, but the footnote ones contain the reference to the XLSX. Looking at the code, transferring those from one place to the other isn't straightforward.
A smaller problem is that in the footnote case, because there are 3 footnotes, the embedding reference is also stored 3 times, there should be a duplicate check.

Roundtripping embedded XLSX files was implemented in bug 72520, but that doesn't handle the above case.
Comment 10 Commit Notification 2026-03-11 04:37:23 UTC
Aron Budea committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/eeffa8b835ed8c734c5ee30f9b380c9db927d6ab

tdf#115558 sw: export embedded XLSX in chart in footnote

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 11 Aron Budea 2026-03-11 09:31:16 UTC
This is fixed, at least on Windows. On Linux it's affected by bug 170015 (perhaps by something else as well, hard to say), but at least the fix here should be general, and once the other issue is fixed, this is going to be OK on Linux, too.

The test is disabled on Linux for now.
Comment 12 Commit Notification 2026-03-13 00:28:37 UTC
Aron Budea committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/c770439941e3eec2fe1a2599858b8dcefe178305

tdf#115558 sw: export embedded XLSX in chart in footnote

It will be available in 26.2.3.

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.