Bug 165059 - Saved DOCX does not open in MSO
Summary: Saved DOCX does not open in MSO
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:25.8.0 target:25.2.3
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Corrupted DOCX-Track-Changes DOCX-Grouped-Shapes
  Show dependency treegraph
 
Reported: 2025-02-05 15:18 UTC by Timur
Modified: 2025-03-27 16:02 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
ODT (54.18 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-02-05 15:18 UTC, Timur
Details
DOCX (73.39 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-02-06 06:25 UTC, Timur
Details
ODT (26.95 KB, application/vnd.oasis.opendocument.text)
2025-02-06 08:40 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timur 2025-02-05 15:18:47 UTC
Created attachment 198998 [details]
ODT

Open attached sample and save as DOCX and open in MSO - says corrupted.
Seen in 25.8+.
Started in 7.4 from:

commit 121cbc250b36290f0f8c7265fea57256dad69553	[log]
author	Attila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>	Thu Nov 11 14:02:12 2021 +0100
committer	László Németh <nemeth@numbertext.org>	Thu Jan 06 10:41:32 2022 +0100

tdf#66039 DOCX: import textboxes (with tables, images etc.) in group shapes

Text boxes in group shapes were imported as shapes, losing complex text content: tables (tdf#66039), colors (tdf#73022),
images (tdf#81958), lists, paragraph styles, hyperlinks (tdf#122960) and track changes.

Note: a few unit tests have been deactivated temporarily. Test document "groupshape-trackedchanges.docx" of testGroupshapeTrackedchanges is imported correctly now: with track changes, and the test was modified accordingly.

Follow-up to commit 2951cbdf3a6e2b62461665546b47e1d253fcb834 
"tdf#143574 OOXML export/import of textboxes in group shapes".
Comment 1 Regina Henschel 2025-02-06 00:13:05 UTC
When try to open the attached "ODT" in Word, Word will repair it. So that file is already broken. Was that file generated from an .odt document? If yes, could you please attach the original .odt document?
Comment 2 Timur 2025-02-06 06:02:19 UTC
ODT is stripped from large DOCX, where behavior is the same, opens in LO but repairs in MSO both original ODT and saved DOCX.
But we cannot say that ODT is broken because MSO repairs it, MSO is not a reference for ODT, and ODT opens normally in LO, so it should save DOCX. 
This looks like a bug like it is.
Comment 3 Aron Budea 2025-02-06 06:09:15 UTC
I think what Regina refers to is that the attachment named "ODT" is actually a DOCX file, the real ODT file isn't attached.
Comment 4 Timur 2025-02-06 06:25:07 UTC
Created attachment 199012 [details]
DOCX

There is no original ODT. This one was simplified from attached DOCX and that one from much larger DOCX who's origin is not known but was used in LO.
Comment 5 Aron Budea 2025-02-06 06:29:36 UTC
By original I mean a "good" reference. There is no ODT attachment, the attachment named as "ODT" is also a DOCX file.
Comment 6 Timur 2025-02-06 08:40:27 UTC
Created attachment 199014 [details]
ODT

Thanks, here is even more simplified ODT that does not open in MSO for me.
Comment 7 Regina Henschel 2025-02-06 13:27:05 UTC
LibreOffice writes for the deleted content w:moveFrom elements. Such element is only allowed inside a part marked with moveFromRangeStart to moveFromRangeEnd. These elements are not written and thus the moveFrom elements are non-conformant. See sections §17.13.5.21 and §17.13.5.22 in ISO_IEC_29500-1.

But these moveFrom elements must not be written at all, because it is not a move of a paragraph/run, but a deletion. So the to be used element is a w:del.

There exist the additional problems:
(1) A w:i element is duplicated.
(2) An unknown attribute ID is used.
But these problems do not produce the opening failure in Word.
Comment 8 Commit Notification 2025-03-07 16:31:52 UTC
Jaume Pujantell committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7b57004cf20ae1715eabd6623ad9007a68a0a32e

tdf#165059 sw fix not valid moveFrom/moveTo tag

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.
Comment 9 Commit Notification 2025-03-14 15:49:06 UTC
Jaume Pujantell committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/05f2cb64f690093172b5d0465936a78b46b3380e

tdf#165059 sw use delText inside all del tags

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.
Comment 10 Commit Notification 2025-03-15 16:55:06 UTC
Jaume Pujantell committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

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

tdf#165059 sw fix not valid moveFrom/moveTo tag

It will be available in 25.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.
Comment 11 Gabor Kelemen (allotropia) 2025-03-17 16:10:45 UTC
Checked in

Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 6e8a094a1a1d63ed2684900c5e0c4292f8d833a8
CPU threads: 14; OS: Windows 10 X86_64 (build 19045); UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: threaded

The exported docx now opens in Word 2016.
Only downside is that now the "Move" operation becomes "Delete" operation.
Comment 12 Commit Notification 2025-03-20 09:24:11 UTC
Jaume Pujantell committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/15ad5a1754d531948fe5fde2552f018463c41bce

tdf#165059 sw use delText inside all del tags

It will be available in 25.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.