Bug 128752 - FILEOPEN DOCX Paragraph in table gets extra 0.35 cm spacing after
Summary: FILEOPEN DOCX Paragraph in table gets extra 0.35 cm spacing after
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: László Németh
URL:
Whiteboard: target:6.5.0 target:6.4.0.1 target:7.0.0
Keywords: filter:docx
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2019-11-12 14:49 UTC by NISZ LibreOffice Team
Modified: 2020-05-10 11:53 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Screenshot of the original document side by side in Word and Writer (152.20 KB, image/png)
2019-11-12 14:50 UTC, NISZ LibreOffice Team
Details
Paragraph styles get extra or modified style settings in table cells (13.57 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-13 11:47 UTC, László Németh
Details
screen shot of the previous test file in Word (9.27 KB, image/png)
2019-11-13 11:49 UTC, László Németh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2019-11-12 14:49:41 UTC
Description:
In attachment  #129129 [details] the first two paragraphs in the table cells get a 0.35 cm spacing after in the Default style, while in Word it was 0.

Steps to Reproduce:
1.	Open attachment  #129129 [details] and check the paragraph settings of the first paragraph in the cells. Compare to Word.

Actual Results:
Spacing After is 0.35 cm.

Expected Results:
Spacing After is 0.


Reproducible: Always


User Profile Reset: No



Additional Info:
LibreOffice details:
Version: 6.4.0.0.alpha1+ (x86)
Build ID: f0340d58cc0f2808ce8003099ff2a0495360f267
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win; 
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: CL
Comment 1 NISZ LibreOffice Team 2019-11-12 14:50:03 UTC
Created attachment 155753 [details]
Screenshot of the original document side by side in Word and Writer
Comment 2 Regina Henschel 2019-11-13 00:28:04 UTC
I think, it is an error in Word. The paragraph has a direct setting <w:spacing before="5.5pt">. A value for 'after' is not specified. So the rule "If this attribute is omitted on a given paragraph, the value of the setting it represents is the value previously set in the style hierarchy." (ISO/IEC 29500-1:2016, page 249). Looking into the style hierarchy, you find a value in the element docDefaults, it is 'after="10pt"'. Because of vertical space collapsing of paragraphs, the effective distance is 10pt. And that is the 3.53mm, that LibreOffice renders. If the direct setting has an attribute 'after="0pt"', then LibreOffice takes it, and renders the 5.5pt from the next paragraph.

That is the formal part. Of cause a user has a different view on the problem, and we need to decide, whether we will follow the bug of Word to please the customer. And how to do it in that case. Perhaps yet another compatibility option?
Comment 3 NISZ LibreOffice Team 2019-11-13 08:13:07 UTC
(In reply to Regina Henschel from comment #2)
> I think, it is an error in Word. The paragraph has a direct setting
> <w:spacing before="5.5pt">. A value for 'after' is not specified. So the
> rule "If this attribute is omitted on a given paragraph, the value of the
> setting it represents is the value previously set in the style hierarchy."
> (ISO/IEC 29500-1:2016, page 249). Looking into the style hierarchy, you find
> a value in the element docDefaults, it is 'after="10pt"'. Because of
> vertical space collapsing of paragraphs, the effective distance is 10pt. And
> that is the 3.53mm, that LibreOffice renders. If the direct setting has an
> attribute 'after="0pt"', then LibreOffice takes it, and renders the 5.5pt
> from the next paragraph.
> 
> That is the formal part. Of cause a user has a different view on the
> problem, and we need to decide, whether we will follow the bug of Word to
> please the customer. And how to do it in that case. Perhaps yet another
> compatibility option?

Thanks for the detailed analysis. 
I guess then this belongs to the family of bug #117982 which is about the crazy handling of spacing in docx tables.
Comment 4 László Németh 2019-11-13 11:44:55 UTC
It seems, in Word there is a multiple inheritance within tables: paragraphs get the settings (with higher priority) of the Table Grid paragraph style. In the case of the Normal style, this is visible on the UI, too, but not in the case of the other paragraph styles. See the attached test file. The blue color comes from the Table Grid style.
Comment 5 László Németh 2019-11-13 11:47:29 UTC
Created attachment 155781 [details]
Paragraph styles get extra or modified style settings in table cells

(Multiple or modified style inheritance in MSO...)
Comment 6 László Németh 2019-11-13 11:49:04 UTC
Created attachment 155784 [details]
screen shot of the previous test file in Word
Comment 7 László Németh 2019-11-13 12:05:47 UTC
It seems, there is no multiple inheritance or wrong style hierarchy. Table styles overwrite the docDefault style:

http://officeopenxml.com/WPstyles.php

In this case, where <w:spacing w:after="200"> was defined.
Comment 8 László Németh 2019-11-13 12:09:49 UTC
But thanks to this behavior, a text with same paragraph style can have different formatting within a table cell and outside a table...
Comment 9 Commit Notification 2019-11-15 13:27:00 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

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

tdf#128752 DOCX: fix partial direct paragraph spacing in tables

It will be available in 6.5.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 László Németh 2019-11-15 13:51:37 UTC
tdf#128752 DOCX: fix partial direct paragraph spacing in tables

When direct formatting of a table paragraph set only top margin,
but not the bottom margin, also there was no paragraph style setting
for the bottom margin, the paragraph was imported using docDefault
bottom spacing instead of the table style bottom spacing.
Comment 11 Commit Notification 2019-11-18 14:07:39 UTC
László Németh committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/28444a2cf7ac637a0161733121c59de82bc7e4db

tdf#128752 DOCX: fix partial direct paragraph spacing in tables

It will be available in 6.4.0.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 12 Commit Notification 2019-12-02 10:01:22 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/749fd6508504cf3b2e3822eca52a67fa36d75fb8

revert obsolete writerfilter hacks for tdf#119054 and tdf#128752

It will be available in 6.5.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 13 Commit Notification 2020-02-12 11:54:48 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

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

Revert "revert obsolete writerfilter hacks for tdf#119054 and tdf#128752"

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.
Comment 14 BogdanB 2020-05-10 11:53:07 UTC
Everything ok.

Verified on
Version: 6.4.3.2
Build ID: libreoffice-6.4.3.2-snap1
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: ro-RO (ro_RO.UTF-8); UI-Language: en-US
Calc: threaded

And also on

Version: 7.0.0.0.alpha1
Build ID: 6a03b2a54143a9bc0c6d4c7f1...
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded