Bug 118242 - DOCX EXPORT: anchor of text frame is wrong + MSO can't open the file
Summary: DOCX EXPORT: anchor of text frame is wrong + MSO can't open the file
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.0.0
Keywords: filter:docx
Depends on:
Blocks: DOCX-Frames DOCX-Corrupted
  Show dependency treegraph
 
Reported: 2018-06-19 15:37 UTC by Patrick Jaap
Modified: 2020-05-19 18:17 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
ODT file cauing the bug (32.00 KB, application/vnd.oasis.opendocument.text)
2018-06-19 15:37 UTC, Patrick Jaap
Details
DOCX export of the sample file (24.06 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-06-19 15:38 UTC, Patrick Jaap
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Jaap 2018-06-19 15:37:09 UTC
Description:
Exporting the attached file (from odt) to docx sets the anchor of the text frame in the header to the body and additionally, MSO (2013) cannot open the file at all (displaying an import error)

A related regression was just fixed, see tdf#117805.

Steps to Reproduce:
1. Open Frames.odt in Writer
2. Export to docx
3. Open the docx in Writer/MSO

Actual Results:
Frame in header is now in body + Import error at MSO 2013

Expected Results:
Frame stays where it belongs and the file is not corrupted (for MSO)


Reproducible: Always


User Profile Reset: No



Additional Info:
You need a fresh master build from at least 19 July 2018 to reproduce
Comment 1 Patrick Jaap 2018-06-19 15:37:44 UTC
Created attachment 142920 [details]
ODT file cauing the bug
Comment 2 Patrick Jaap 2018-06-19 15:38:53 UTC
Created attachment 142921 [details]
DOCX export of the sample file
Comment 3 Xisco Faulí 2018-06-19 18:46:10 UTC Comment hidden (obsolete)
Comment 4 Patrick Jaap 2018-06-20 07:52:37 UTC
Hi Xisco!

I would not consider this as a regression. Commit 
 853350787df9a8d92c269ef1b6e764863e74ec2a

from Miklos (from yesterday) fixes the related bug 

https://bugs.documentfoundation.org/show_bug.cgi?id=117805

where there was no header at all in the same document export. The bug here is that the Writer export filter creates a corrupt docx file with a misplaced textframe. It seems this was never working correctly and it was "hidden" by the missing header.
Comment 5 Miklos Vajna 2018-06-20 12:44:13 UTC
Yes, basically there are 3 states:

- baseline: well-formed but not invalid output (but Writer can see the header)
- my earlier patch: valid output, but loosing header content
- my recent patch: restoring the header content

I agree with Patrick that exporting the header content in a valid way didn't work in the past either (for this situation).
Comment 6 Patrick Jaap 2018-06-26 08:15:47 UTC
I think the bug is caused by a missing header reference in the document.xml file. This should by the reason why Word refuses to open the file. The header reference (and the header file) are indeed created in sw/source/filter/ww8/docxexport.cxx:780.

But when the section properties are written in sw/source/filter/ww8/wrt8sty.cxx:1513 (called by sw/source/filter/ww8/docxattributeoutput.cxx:5900) the header reference is not present. 

Miklos gave me a hint that is has to do with postponing the output of the section properties in docxattributeoutput.cxx:5910. But I wasn't able to follow that trace. I think I am missing some background knowledge on this topic.
Comment 7 QA Administrators 2019-06-27 02:53:39 UTC Comment hidden (obsolete)
Comment 8 Patrick Jaap 2019-06-28 13:19:15 UTC
Situation is unchanged in current master
Comment 9 NISZ LibreOffice Team 2020-05-19 11:44:45 UTC
Exported docx can be opened since:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=0dd48d1a9a716456ff1ebe67e19881ad2f56939b

author	Michael Stahl <Michael.Stahl@cib.de>	2020-03-31 14:37:14 +0200
committer	Michael Stahl <michael.stahl@cib.de>	2020-03-31 15:44:56 +0200

sw: DOCX export: avoid section breaks in text frames
Comment 10 Commit Notification 2020-05-19 18:17:26 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

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

tdf#118242: sw: Add unittest

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