Bug 137683 - TABLE FORMATTING: DOCX, Paragraph background color set to 'No Fill' not persisted on save
Summary: TABLE FORMATTING: DOCX, Paragraph background color set to 'No Fill' not persi...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Master old -3.6
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:7.2.0
Keywords:
Depends on:
Blocks: DOCX-Tables DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2020-10-22 14:55 UTC by 4layq596ovwv
Modified: 2021-01-23 10:39 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Docx file that triggers the issue. (16.68 KB, application/wps-office.docx)
2020-10-22 14:56 UTC, 4layq596ovwv
Details
Expected Rendering (6.15 KB, image/png)
2020-10-22 15:01 UTC, 4layq596ovwv
Details
Actual rendering on libreoffice 6.4.6.2 (17.30 KB, image/png)
2020-10-22 15:02 UTC, 4layq596ovwv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 4layq596ovwv 2020-10-22 14:55:33 UTC
Description:
The No fill setting seems to not be taken into account with the following docx (it was generated from WPS office).

The expected behavior is to have white text on a purple background.

In libreoffice, the text is white and with a white highlight, making the text unreadable.

Steps to Reproduce:
Open the attachment

Actual Results:
The text is white with a white highlight

Expected Results:
The text should be white on a purple background


Reproducible: Always


User Profile Reset: No



Additional Info:
$ libreoffice6.4 --version
LibreOffice 6.4.6.2 0ce51a4fd21bff07a5c061082cc82c5ed232f115
Comment 1 4layq596ovwv 2020-10-22 14:56:10 UTC
Created attachment 166633 [details]
Docx file that triggers the issue.
Comment 2 4layq596ovwv 2020-10-22 14:56:42 UTC
This seems to be related to this : https://bugs.documentfoundation.org/show_bug.cgi?id=91292
Comment 3 4layq596ovwv 2020-10-22 14:57:42 UTC
I've just tried to open the same document with libreoffice 7.0 and I see the same bug.
Comment 4 4layq596ovwv 2020-10-22 15:01:40 UTC
Created attachment 166634 [details]
Expected Rendering
Comment 5 4layq596ovwv 2020-10-22 15:02:24 UTC
Created attachment 166635 [details]
Actual rendering on libreoffice 6.4.6.2
Comment 6 Dieter 2020-10-23 05:54:40 UTC
I confirm it with

Version: 7.0.2.2 (x64)
Build ID: 8349ace3c3162073abd90d81fd06dcfb6b36b994
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: he-IL (de_DE); UI: en-GB
Calc: threaded

Steps to reproduce
1. Open attacment from comment 1
2. Change text highlight from white to no fill.
3. Save as docx
4. Reopen

Actual result:
Text is again highlighted in white.
Comment 7 Justin L 2020-11-18 16:07:20 UTC
Be warned: any work done here is DANGEROUS!!! See bug 125268.

The relevant parts from document.xml should be these.
<w:tc>
  <w:tcPr>
    <w:shd w:val="clear" w:color="auto" w:fill="7C26FF"/>
  </w:tcPr>
  <w:p>
    <w:pPr>
      <w:rPr>
        <w:color w:val="FFFFFF" w:themeColor="background1"/>
        <w:highlight w:val="none"/>
      </w:rPr>
    </w:pPr>
    <w:r>
      <w:rPr>
        <w:color w:val="FFFFFF" w:themeColor="background1"/>
      <w:highlight w:val="none"/>
      </w:rPr>
      <w:t>ABC</w:t>
    </w:r>
  </w:p>
</w:tc>

It looks like we don't handle LN_Value_ST_HighlightColor_none in DomainMapper.cxx, nor do we export COL_AUTO in docx/doc/rtf.

This issue will need some research, because there seem to be two settings that configure the same thing. RES_CHRATR_HIGHLIGHT and RES_CHRATR_BACKGROUND. Is it safe to assume that LO has the same priority as DOCX?

There is also a user setting option that supposedly defines whether to export as background or highlight. It probably needs some fixing too.

The initial commits to make the distinction and user setting can be found at https://cgit.freedesktop.org/libreoffice/core/log/?qt=grep&q=Char+highlight%3A

and it all starts with https://cgit.freedesktop.org/libreoffice/core/commit/?id=8b949134441056a1455d67ddfdd7e0bc5f2ee682

MS Documentation for DOCX: 17.3.2.15 (Text Highlighting)
This element specifies a highlighting color which is applied as a background behind the contents of this run. If this run has any background shading specified using the shd element (ยง17.3.2.32), then the background shading shall be superseded by the highlighting color when the contents of this run are displayed. If this element is not present, the default value is to leave the formatting applied at previous level in the style hierarchy. If this element is never applied in the style hierarchy, then text highlighting shall not be applied to the contents of this run.

Required reading is http://zolnaitamas.blogspot.com/2015/03/word-compatible-text-highlighting-in.html
Comment 8 Justin L 2020-11-20 12:53:04 UTC
The definitive bug report to look at might be bug 64490.
I have started an information gathering wiki page for char highlighting at https://wiki.documentfoundation.org/Documentation/CharHighlight.

The root of the problem for this report is that the default para-style defines a white colour highlight, which needs to be cancelled everywhere. Unbelievable.

<w:style w:type="paragraph" w:default="1" w:styleId="1">
  <w:name w:val="Normal"/>
  <w:rPr>
    <w:highlight w:val="white"/>

This means we need to import AND export none highlighting. Great.
Comment 9 Justin L 2020-11-21 14:09:45 UTC
Patches that get us there are:
-http://gerrit.libreoffice.org/c/core/+/106314 tdf#137683 writerfilter Char highlight: import "none"
-http://gerrit.libreoffice.org/c/core/+/106315 tdf#137683 DOCX/RTF Char highlight: export "none"
-http://gerrit.libreoffice.org/c/core/+/106316 tdf#137683 DOC: Char highlight: export "none" 

However, it will probably be a while before I propose them - since I don't want to spam unnecessary w:highlight w:val="none" entries, and I don't know how to avoid that yet.
Comment 10 Commit Notification 2020-11-30 10:01:32 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/81ecdd52ef2f3d390327a0bf6b6fa906805843f7

tdf#137683 writerfilter Char highlight: import "none"

It will be available in 7.2.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 11 Commit Notification 2020-12-01 09:53:11 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2622cd9c31a5db423c6f878f990a41191d0079af

tdf#137683 sw ms formats Char highlight: export "none"

It will be available in 7.2.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 12 Dieter 2021-01-23 10:39:29 UTC
VERIFIED FIXED with

Version: 7.2.0.0.alpha0+ (x64)
Build ID: 9f9798f07f0b56ae474f31ded671cc8da598d244
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: threaded