Bug 104354 - FILEOPEN DOCX: Paragraph spacing "auto" is imported as 0.49 cm
Summary: FILEOPEN DOCX: Paragraph spacing "auto" is imported as 0.49 cm
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
4.1.0.4 release
Hardware: All All
: medium normal
Assignee: László Németh
URL:
Whiteboard: target:6.2.0
Keywords: filter:docx
: 114962 (view as bug list)
Depends on:
Blocks: DOCX-Paragraph 82006 107480
  Show dependency treegraph
 
Reported: 2016-12-02 12:29 UTC by Gabor Kelemen
Modified: 2020-10-21 14:03 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
The problematic document (243.97 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-12-02 12:29 UTC, Gabor Kelemen
Details
Screenshot of the document in the current master build (171.67 KB, image/png)
2016-12-02 12:29 UTC, Gabor Kelemen
Details
The document in Word 2013 (93.34 KB, image/png)
2016-12-02 12:31 UTC, Gabor Kelemen
Details
test case with text box only (15.27 KB, application/vnd.openxmlformats-officedocument.wordprocessingml)
2016-12-06 14:07 UTC, Timur
Details
Similar test file in DOC format (64.00 KB, application/msword)
2017-11-09 09:15 UTC, Gabor Kelemen
Details
The example doc in Word 2013 and LO 5.4.2 (216.19 KB, image/png)
2017-11-09 09:16 UTC, Gabor Kelemen
Details
DOCX version of the second test file (20.18 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-07-13 20:15 UTC, László Németh
Details
tdf104354-2b.docx: regression exposed by this document (14.86 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-08-28 09:37 UTC, Justin L
Details
firstParaInSection_auto.docx: proof that footnotes don't have zero-first autospacing (6.67 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-08-31 09:46 UTC, Justin L
Details
test case with text box compared MSO LO6.1 LO6.3+ (74.86 KB, image/jpeg)
2018-12-27 13:18 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen 2016-12-02 12:29:10 UTC
Created attachment 129246 [details]
The problematic document

Attached document has a paragraph in a text box (the one above the bottom image) with spacing set as "auto".

This is imported in current master Writer as a fixed 0.49 cm spacing, making the paragraph text ("A projekt azonosító száma") invisible as the spacing is bigger than the text box itself.
Comment 1 Gabor Kelemen 2016-12-02 12:29:41 UTC
Created attachment 129247 [details]
Screenshot of the document in the current master build
Comment 2 Gabor Kelemen 2016-12-02 12:31:12 UTC
Created attachment 129248 [details]
The document in Word 2013
Comment 3 Xisco Faulí 2016-12-06 12:31:30 UTC

*** This bug has been marked as a duplicate of bug 102264 ***
Comment 4 Timur 2016-12-06 14:03:13 UTC
Bug 102264 is poorly triaged, and I don't see this one as a duplicate of that one.
I confirm the behavior. It can be seen from 4.1 and it worse before, not likely a regression.
There was similar Bug 95031 which I add to CC, but only inside numbering.
Comment 5 Timur 2016-12-06 14:07:38 UTC
Created attachment 129350 [details]
test case with text box only
Comment 6 Gabor Kelemen 2017-11-09 09:15:34 UTC
Created attachment 137631 [details]
Similar test file in DOC format

This also happens in DOC format: spacing is auto in Word, 0,49cm in Writer.

Version: 5.4.2.2
Build ID: 22b09f6418e8c2d508a9eaf86b2399209b0990f4
CPU threads: 4; OS: Windows 6.2; UI render: default; 
Locale: hu-HU (hu_HU); Calc: group
Comment 7 Gabor Kelemen 2017-11-09 09:16:07 UTC
Created attachment 137632 [details]
The example doc in Word 2013 and LO 5.4.2
Comment 8 László Németh 2018-06-29 09:42:29 UTC
OpenDocument/document model of LibreOffice has no such feature, as beforeAutospacing/afterAutospacing of OOXML, so it only stores these attributes for OOXML export/import, keeping the original document layout only in MSO after modification in LibreOffice, too.

Possible solutions: adding this feature to OpenDocument or search some workaround for the corner cases: text boxes and table rows, keeping the original layout of the document in LibreOffice, too.
Comment 9 Gabor Kelemen 2018-06-29 10:35:41 UTC
(In reply to László Németh from comment #8)
> Possible solutions: adding this feature to OpenDocument or search some
> workaround for the corner cases: text boxes and table rows, keeping the
> original layout of the document in LibreOffice, too.

How about adding a compatibility option to Options - Writer - Compatibility ?
Comment 10 László Németh 2018-06-29 11:00:19 UTC
> How about adding a compatibility option to Options - Writer - Compatibility ?

@Gábor, it seems, we could have a workaround, because this bad 14pt (~ 0.49cm) caused by the following workaround, see 280 TWIPS values in it: https://cgit.freedesktop.org/libreoffice/core/commit/?id=68e538ea6d6b2308de7c9390116fa06cd8c02d18
Comment 11 László Németh 2018-07-13 20:15:04 UTC
Created attachment 143540 [details]
DOCX version of the second test file
Comment 12 László Németh 2018-07-13 20:23:25 UTC
@Gábor: I have attached the DOCX version of the second test file. I suggest to file a new issue for the original DOC.

The suggested fix for this DOCX and for similar table importing problems: 

https://gerrit.libreoffice.org/#/c/57352/

Description:

Top margin of first paragraph of a table cell with auto spacing, and bottom margin of last paragraph of a table cell with auto spacing are zero (except in numbered last paragraphs), but LibreOffice set 14pt instead of them, resulting much longer tables. Following cases needed special handling:

- auto spacing in style
- direct top and bottom auto spacing
- direct top and bottom margins
- footnotes in cell paragraphs
Comment 13 Commit Notification 2018-07-17 10:00:31 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5c6bce38a01b21403a603acd3148cf3bbb4c685f

tdf#104354 DOCX import: fix paragraph auto spacing in tables

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Justin L 2018-08-28 09:37:07 UTC
Created attachment 144499 [details]
tdf104354-2b.docx: regression exposed by this document
Comment 15 Justin L 2018-08-31 09:46:21 UTC
Created attachment 144571 [details]
firstParaInSection_auto.docx: proof that footnotes don't have zero-first autospacing

I have proposed a complete re-write of the autospacing code at https://gerrit.libreoffice.org/59705

So, we also have to ensure that footnotes are not counted as "firstParaInSection". https://gerrit.libreoffice.org/59858

This unit test also proves that inherited autospacing is not over-ridden by a more-closely-inherited top-margin.  That is good - otherwise things would really get complicated if we had layers of inheritance comparison.

Comments have no paragraph formatting, so they should be unaffected by this either way.

Another interesting thing is that if you disable autospacing on this document, it looks terrible in Word, but I'm not exactly sure why.
Comment 16 Commit Notification 2018-09-02 13:09:03 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=61821277ed4974debd05af89cb7284602512088f

tdf#104354 writerfilter: rewrite Autospacing

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Commit Notification 2018-09-03 05:44:02 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=dff829e863fd05bedd5bcb713cd80c10fa582932

tdf#104354 writerfilter: not FirstParaInSection if InFootOrEndnote

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 Timur 2018-12-27 13:18:55 UTC
Created attachment 147857 [details]
test case with text box compared MSO LO6.1 LO6.3+
Comment 19 Timur 2018-12-27 14:16:15 UTC
From what I see, auto spacing is fixed for DOCX examples. 
I don't see that new issue was filed for the original DOC so I'll do and CC it.
Comment 20 Timur 2020-10-21 14:03:43 UTC
*** Bug 114962 has been marked as a duplicate of this bug. ***