Bug 131098

Summary: OOXML .docx Image Fill Not Imported
Product: LibreOffice Reporter: Luke <lukebenes>
Component: WriterAssignee: Justin L <jluth>
Status: RESOLVED FIXED    
Severity: normal CC: aron.budea, jluth, rb.henschel, serval2412, xiscofauli
Priority: medium Keywords: filter:docx
Version: 3.5.0 release   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=124013
Whiteboard: target:24.8.0
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 94774, 108230    
Attachments: OOXML docx with Both Pictures Missing Area Fill
MS binary .doc correctly imported
Similar Line Border Correctly imported in OOXML
Screenshot Comparison of Word vs Writer
OOXML .pptx Files correctly import Area Atrribute
Similar Line Border effect Correctly imported in OOXML .docx

Description Luke 2020-03-03 15:52:15 UTC
Created attachment 158340 [details]
OOXML docx with Both Pictures Missing Area Fill

The background fill of MSO images in OOXML documents is lost on import. 

Steps to reproduce:
1. In Word insert image
2. Format Picture -> Solid Fill
3. Save
4. Open in Writer
5. Right click on Image -> Properties -> Area

Expected Results
1. The fill color from Word

Actual Results
1. No fill


Note that the .doc format correctly imports this attribute.
Comment 1 Luke 2020-03-03 15:54:37 UTC
Created attachment 158341 [details]
MS binary .doc correctly imported
Comment 2 Luke 2020-03-03 15:55:59 UTC Comment hidden (obsolete)
Comment 3 Luke 2020-03-03 16:00:52 UTC
Created attachment 158343 [details]
Screenshot Comparison of Word vs Writer
Comment 4 Luke 2020-03-03 16:06:10 UTC
Created attachment 158344 [details]
OOXML .pptx Files correctly import Area Atrribute

Oddly, this is a Writer specific OOXML issue
Comment 5 Julien Nabet 2020-03-03 21:36:25 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
I noticed these logs:
warn:xmloff:7570:7570:sax/source/fastparser/fastparser.cxx:1267: unknown element xsi:type http://www.w3.org/2001/XMLSchema-instance
warn:xmloff:7570:7570:sax/source/fastparser/fastparser.cxx:1267: unknown element xsi:type http://www.w3.org/2001/XMLSchema-instance
warn:oox:7570:7570:oox/source/docprop/docprophandler.cxx:321: OOXMLDocPropHandler::startFastElement: unknown element 5621
warn:oox:7570:7570:oox/source/docprop/docprophandler.cxx:321: OOXMLDocPropHandler::startFastElement: unknown element 3198
warn:oox:7570:7570:oox/source/docprop/docprophandler.cxx:321: OOXMLDocPropHandler::startFastElement: unknown element 5621
warn:oox:7570:7570:oox/source/docprop/docprophandler.cxx:321: OOXMLDocPropHandler::startFastElement: unknown element 2749
warn:oox:7570:7570:oox/source/docprop/docprophandler.cxx:321: OOXMLDocPropHandler::startFastElement: unknown element 3198
warn:xmloff:7570:7570:sax/source/fastparser/fastparser.cxx:1267: unknown element w15:val http://schemas.microsoft.com/office/word/2012/wordml
warn:xmloff:7570:7570:sax/source/fastparser/fastparser.cxx:1195: unknown attribute vid={4A3C46E8-61CC-4603-A589-7422A47A8E4A}
warn:xmloff:7570:7570:sax/source/fastparser/fastparser.cxx:1267: unknown element wp14:editId http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing
warn:oox:7570:7570:oox/source/drawingml/shapecontext.cxx:130: ShapeContext::onCreateContext: unhandled element: 3973
warn:writerfilter:7570:7570:writerfilter/source/dmapper/WrapPolygonHandler.cxx:171: WrapPolygonHandler::lcl_attribute: unhandled token: 91309
warn:xmloff:7570:7570:sax/source/fastparser/fastparser.cxx:1267: unknown element wp14:editId http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing
warn:oox:7570:7570:oox/source/drawingml/shapecontext.cxx:130: ShapeContext::onCreateContext: unhandled element: 3973
warn:writerfilter:7570:7570:writerfilter/source/dmapper/WrapPolygonHandler.cxx:171: WrapPolygonHandler::lcl_attribute: unhandled token: 91309
warn:legacy.osl:7570:7570:oox/source/helper/storagebase.cxx:67: StorageBase::StorageBase - missing base input stream
warn:sfx.view:7570:7570:sfx2/source/view/viewfrm.cxx:3210: SID_SIDEBAR state requested, but no task pane child window exists for this ID!
warn:sfx.view:7570:7570:sfx2/source/view/viewfrm.cxx:3210: SID_SIDEBAR state requested, but no task pane child window exists for this ID!

Don't know if it may be a dup.
At least, I found a similar bug on xlsx
Comment 6 Julien Nabet 2020-03-03 21:47:36 UTC Comment hidden (obsolete)
Comment 7 Luke 2020-03-03 22:05:45 UTC
Created attachment 158356 [details]
Similar Line Border effect Correctly imported in OOXML .docx

Unlike the Area Effect, the Line Effect is correctly imported in OOXML.
Comment 8 Xisco Faulí 2020-09-29 12:37:12 UTC Comment hidden (obsolete)
Comment 9 Stéphane Guillou (stragu) 2021-06-14 13:16:03 UTC
Reproduced in:

Version: 7.2.0.0.alpha1+ / LibreOffice Community
Build ID: bb54d6d8241a06a6772052b77b67d6a4f686426c
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2021-06-11_20:14:38
Calc: threaded
Comment 10 Aron Budea 2022-09-30 10:22:28 UTC
Already in 3.5.0.3.
Comment 11 Justin L 2023-06-04 00:49:39 UTC
repro 7.6+
We do read case A_TOKEN(srgbClr):, but it gets lost somewhere...
I think we always assign transparent white b/c nFillColor is only -1
xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_BACK_COLOR ),
                uno::Any( GraphicImport_Impl::nFillColor ));
Comment 12 Regina Henschel 2023-06-04 17:52:24 UTC
Reading the fill from the source in oox is correct. It gets lost in writerfilter/source/dmapper/GraphicImport.cxx

If I add the following in https://opengrok.libreoffice.org/xref/core/writerfilter/source/dmapper/GraphicImport.cxx?r=3eb90b33#865
and the needed #include <com/sun/star/drawing/FillStyle.hpp> at the top,
then I get the shape fill color. But this is not a complete solution, because it does not consider FillGradient, FillTransparenceGradient, FillTransparence and not theme colors. But is shows that GraphicImport.cxx is likely the correct place to fix the error.

drawing::FillStyle eFillStyle;
aAny = xSourceGraphProps->getPropertyValue("FillStyle");
if ((aAny >>= eFillStyle) && drawing::FillStyle_SOLID == eFillStyle)
{
    util::Color aFillColor;
    aAny = xSourceGraphProps->getPropertyValue("FillColor");
    if (aAny >>= aFillColor)
    {
        xGraphProps->setPropertyValue("FillStyle", uno::Any(drawing::FillStyle_SOLID));
        xGraphProps->setPropertyValue("BackColor", aAny);
        xGraphProps->setPropertyValue("FillColor", aAny);
    }
}

Another question is, why xGraphProps do not have these properties from the beginning.
Comment 13 Justin L 2024-05-28 13:06:27 UTC
proposed patch at https://gerrit.libreoffice.org/c/core/+/168134
Comment 14 Commit Notification 2024-05-29 23:20:28 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2862f1989591f4666ed0f7b994c80a0d0fd8ae52

tdf#131098 oox import: apply fill properties to graphic

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 15 Commit Notification 2024-05-29 23:22:31 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#131098 docx export: write fill property of graphic

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.