Bug 170516 - FILESAVE DOCX: corrupt document (sometimes) reported by MS Word when plainText Sdt contains drawing
Summary: FILESAVE DOCX: corrupt document (sometimes) reported by MS Word when plainTex...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:26.8.0
Keywords: bisected, filter:docx
Depends on:
Blocks: DOCX-Corrupted
  Show dependency treegraph
 
Reported: 2026-01-28 15:39 UTC by Justin L
Modified: 2026-02-27 13:50 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
forum-mso-en-16671.docx: example document (65.21 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2026-01-28 15:39 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2026-01-28 15:39:53 UTC
Created attachment 205228 [details]
forum-mso-en-16671.docx: example document

MS Word generally doesn't like complex content inside of a plainText content control. Although bug 165359 shows us that it IS possible to have graphics and shapes inside a plainText control, under some circumstances it can be reported as corrupt (where it is not corrupt if the control has the <w:text/> marker removed).

Steps to reproduce:
-open forum-mso-en-16671.docx in LO and resave it.
-open the resaved file in Microsoft Word  (file reported as broken)

I bisected this back to 7.6 commit c804c5354855188b5a37219cfe11dc079dc235f4
Author: Miklos Vajna on Fri Mar 10 17:32:07 2023 +0000
    sw content control: fix lost properties on copy&paste
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148613

However, his commit just restored the missing SdtPr values (including the w:text), so it just exposed an existing weakness.

In this case, the floating graphics are anchored at the start of the paragraph. Normally the code writes the graphics first (1), in a separate run. But in this case, because this is all in a floating table, that code path was not followed, and the SDT was started before the graphics were written out.

(1) flies processed first/text postponed with
commit 80fd9fb7209cfd5c0622ee99d59e42e6db32f021
Author:     Umesh Kadam on Thu May 22 02:31:53 2014 -0500
    fdo#78333 : SdtContent and a Shape overlapping causes corruption
    Reviewed-on: https://gerrit.libreoffice.org/9374
Comment 1 Commit Notification 2026-02-05 13:50:59 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2298be1d34f4bfd21c2d4278b1bd64541a8199c7

tdf#170516 docx export: write flies before w:sdt starts

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 2 Commit Notification 2026-02-05 13:52:02 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#170516 docx export: (almost) always write flies in separate w:r

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 3 Commit Notification 2026-02-05 13:52:04 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#170516 docx export: always write flies in separate w:r

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 4 Commit Notification 2026-02-05 13:52:07 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1a7ed0d623dee1907530e72f2d1748eab0c6a77b

NFC tdf#170516 cleanup: remove unused bPostponeWritingText

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-02-05 13:52:10 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1dfaa049a08c616feba2a744ec37614c46c945c1

NFC tdf#170516 cleanup: remove unused m_bAnchorLinkedToNode

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 6 Commit Notification 2026-02-05 13:53:13 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/84693c17d9081c3db662bb28534e8c2d3d2fedf9

NFC tdf#170516 cleanup: remove unused changes to nStateOfFlyFrame

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 7 Commit Notification 2026-02-05 13:53:15 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6441652a3ec925f850c41b4c1e49ad28f3de6c38

tdf#170516 docx export: remove unncessary m_nStateOfFlyFrame

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 8 Commit Notification 2026-02-06 17:55:43 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#170516 docx export: use ResetFlyProcessingFlag

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 9 Commit Notification 2026-02-10 20:50:08 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

NFC tdf#170516 cleanup: remove unused update to aSymbolFont

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 10 Commit Notification 2026-02-24 00:06:03 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/49dee0dd73be06af22cb7198ab80c3a7c377e352

tdf#170516 docx export: return proper StateOfFlyProcessing

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 Commit Notification 2026-02-27 13:50:42 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#170516 also always write ending flies in separate w:r

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.