Bug 165359 - FILESAVE DOCX Document with content control fails to open in Word after roundtrip in Writer
Summary: FILESAVE DOCX Document with content control fails to open in Word after round...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
24.2.0.3 release
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:26.8.0 target:26.2.1
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Corrupted DOCX-Content_Control
  Show dependency treegraph
 
Reported: 2025-02-20 17:40 UTC by Aron Budea
Modified: 2026-01-28 15:39 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
forum-mso-en-3967.docx (27.69 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-02-20 17:40 UTC, Aron Budea
Details
forum-mso-en-2219.docx (59.61 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-02-20 17:40 UTC, Aron Budea
Details
forum-mso-en-2220.docx (61.86 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-02-20 17:41 UTC, Aron Budea
Details
plainTextSDT_containingAlternateContent.docx: not reported as corrupt in MS Word (22.84 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2026-01-28 15:23 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2025-02-20 17:40:24 UTC
Created attachment 199355 [details]
forum-mso-en-3967.docx

Open and save the attached DOCX files back as DOCX in Writer, then try opening the result in Word.

-> Word fails to open the file.

Looking at one of the samples, forum-mso-en-3967.docx, and document.xml in the result, it seems the problem is related to moving one of the drawings to be within sdt and sdtContent.

There is grouping around the content controls, if the grouping is removed in Word, the roundtripped file can be opened in Word again. Not sure if that is directly related to the bug or not.

Observed using LO 25.8.0.0.alpha0+ (41ab24cecd6ad74312843f113d2faa13259cdb7d) / Windows.

Regression is from the following range, which is a single commit in 24.2 Windows bibisect repo:
https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=5dff1f3a995a8e78a156214fd9c32b1005337183..a0b003257aa87d34a4403531798d0074e19a18ac
https://git.libreoffice.org/core/+log/5dff1f3a995a8e78a156214fd9c32b1005337183..a0b003257aa87d34a4403531798d0074e19a18ac
The commit is almost certainly the following, it can be verified in Linux if someone wants to (it also fixed bug 148035):
https://cgit.freedesktop.org/libreoffice/core/commit/?id=5082d50d24c3fec4487c724a15eb0d54a82ecd0d
https://git.libreoffice.org/core/commit/5082d50d24c3fec4487c724a15eb0d54a82ecd0d
author		Jaume Pujantell <jaume.pujantell@collabora.com>	2023-09-13 08:58:21 +0200
committer	Jaume Pujantell <jaume.pujantell@collabora.com>	2023-10-11 15:19:58 +0200

writerfilter: use content controls for text in block SDTs
Comment 1 Aron Budea 2025-02-20 17:40:51 UTC
Created attachment 199356 [details]
forum-mso-en-2219.docx
Comment 2 Aron Budea 2025-02-20 17:41:24 UTC
Created attachment 199357 [details]
forum-mso-en-2220.docx
Comment 3 Justin L 2026-01-16 20:42:22 UTC
Almost certainly, this will be related to this being a plainText control (instead of a richText control).  Removing the <w:text/> from the control 'fixes' the problem for MS Word 2010.

I tested forum-mso-en-3967.docx.
Comment 4 Justin L 2026-01-23 18:41:15 UTC
(In reply to Justin L from comment #3)
> Almost certainly, this will be related to this being a plainText control
Yup. forum-mso-en-2219 and forum-mso-en-2220 have been fixed by
commit 2eed35dcb721ebce08460b0e72a770336baf806d
Author: Justin Luth on Sat Jan 17 02:06:57 2026 +0100
    tdf#170322 writerfilter: import fields into richText, not plainText
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197300

forum-mso-en-3967.docx is still corrupt though...
Comment 5 Commit Notification 2026-01-24 03:03:40 UTC Comment hidden (obsolete)
Comment 6 Commit Notification 2026-01-24 21:59:08 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#165359 writerfilter: import graphic into richText, not plainText

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-01-27 17:05:05 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/09558848c5b5b26e167dd85512935309d5d67723

tdf#165359 writerfilter: import graphic into richText, not plainText

It will be available in 26.2.1.

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 Justin L 2026-01-28 15:23:42 UTC
Created attachment 205227 [details]
plainTextSDT_containingAlternateContent.docx: not reported as corrupt in MS Word

My theory that plainText controls simply cannot contain any graphics at all is not entirely accurate. I'm not sure what conditions are necessary to consider it as corrupt.

However, the patch in general should still be fine (since an undefined SDT really should be considered richText until proven otherwise).