Bug 159626 - FILEOPEN DOCX: VML pattern image needs to be inverted
Summary: FILEOPEN DOCX: VML pattern image needs to be inverted
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:24.8.0
Keywords: filter:docx, notBibisectable
Depends on:
Blocks: Object-Fill-Pattern 126533
  Show dependency treegraph
 
Reported: 2024-02-07 18:41 UTC by Justin L
Modified: 2024-02-21 15:08 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
fdo77725_mso2003.pdf: printed to PDF using word 2003 (7.89 KB, application/pdf)
2024-02-07 18:41 UTC, Justin L
Details
159626_textbox_fill_pattern.docx: a textbox example (72.65 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-02-07 18:52 UTC, Justin L
Details
fdo79131_mso2010.pdf: word-art with a mostly yellow pattern fill: how it looks in MSO 2010 (89.87 KB, application/pdf)
2024-02-21 15:01 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2024-02-07 18:41:13 UTC
Created attachment 192456 [details]
fdo77725_mso2003.pdf: printed to PDF using word 2003

Using sw/qa/extras/ooxmlexport/data/fdo77725.docx as the example file, prior to 7.0 we only imported a (wrong) black background for the textbox, and after that it was black with white dots.  It should be white with black dots.

The pattern was imported since commit 9283cd9e13cd3e0dd7d6b831d930128931862a40
Author: Attila Bakos on Wed Apr 8 14:50:07 2020 +0200
    tdf#78749 DOCX: import VML background image
Comment 1 Justin L 2024-02-07 18:52:49 UTC
Created attachment 192457 [details]
159626_textbox_fill_pattern.docx: a textbox example

Sorry - I'm confusing myself. Comment 0 indicates the problem I am describing, but it is for the page background (which is not yet importing). So I'm including the sample file I created that shows the same problem in a textbox.

Fixing one should fix the other.
I'm not sure if patterns work anywhere else. They don't seem to apply to paragraphs or characters, and are not supported yet by Tables. I'm a bit surprised though that no one else has yet reported this ImplementationError.
Comment 2 Justin L 2024-02-07 20:12:13 UTC
Current theory: the parameters all import correctly, but it is the image itself that is the problem. It is a tiny image (8*8) that is almost all black in comment 0 and comment 1. I take it that black is meant to represent where the background color is applied, and white represents what should be the foreground color. Apparently we treat it the exact opposite way. (We also don't apply the imported colors at all.)

Note that this is VML (created in Word <= 2007 for textboxes I assume). Word 2010 uses DrawingML for textboxes which we import (and export) fine.

The problem is that for page background, VML is always used, even by Word 2019. So the importance is still relatively high.
Comment 3 Justin L 2024-02-08 13:41:22 UTC
(In reply to Justin L from comment #2)
> (We also don't apply the imported colors at all.)
sw/qa/core/data/ooxml/pass/fdo79131.docx is a nice example of a shape ("Inline") with a coloured pattern fill.
Comment 4 Justin L 2024-02-09 21:04:16 UTC
(In reply to Justin L from comment #2)
> Current theory:  it is the image itself that is the problem.
> black is meant to represent where the background color is applied,
> and white represents what should be the foreground color. 
Correct. LO does it totally different internally.

https://gerrit.libreoffice.org/c/core/+/163106 takes care of import.
Comment 5 Justin L 2024-02-20 14:57:22 UTC
Now I'm really confusing myself. Comment 0's PDF (and MSO itself) does NOT show a pattern background (even though it is defined). It is only when you go into the page background properties that the definition is noticed, and when applied takes effect.

fdo77725 is a minimized version of chart2's PieChartDataLabels.docx, which also does NOT show the pattern background.
Comment 6 Commit Notification 2024-02-21 07:47:05 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/07521972bcd1cfbbd15b2f60ada84ffc69f8f997

tdf#159626 vml pattern import: add color, fix back/foreground

It will be available in 24.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 7 Justin L 2024-02-21 15:01:04 UTC
Created attachment 192690 [details]
fdo79131_mso2010.pdf: word-art with a mostly yellow pattern fill: how it looks in MSO 2010

So, in the end comment 0's example was a very "good" one, even if not at all visually impressive. It prevented me from making a bad mistake.

A much more visually appealing example is sw/qa/core/data/ooxml/pass/fdo79131.docx