Bug 69654 - FILEOPEN: DOCX import renders the text-box's gradient color flipped
Summary: FILEOPEN: DOCX import renders the text-box's gradient color flipped
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha0+ Master
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
: 73553 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-09-21 17:04 UTC by Adam CloudOn
Modified: 2014-07-20 08:30 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
DOCX containing formatted text-box with a gradient background (14.90 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2013-09-21 17:04 UTC, Adam CloudOn
Details
Screenshot comparison between MS Word and LibreOffice (97.58 KB, image/png)
2013-09-21 17:05 UTC, Adam CloudOn
Details
screenshot in 4.2.5.2 (6.68 KB, image/png)
2014-07-17 12:07 UTC, tommy27
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam CloudOn 2013-09-21 17:04:51 UTC
Created attachment 86273 [details]
DOCX containing formatted text-box with a gradient background

Problem description: 
LO loads the attached DOCX and does renders the gradient color of the text-box mirrored than like in MS Word (see comparison screenshot).

Steps to reproduce:
1. Load the attached DOCX
2. The gradient background of the text-box is incorrect

Current behavior:
LO doesn't import and render the text-box's gradient background correctly

Expected behavior:
LO should import and render the text-box's gradient background correctly
              
Operating System: All
Version: 4.2.0.0.alpha0+ Master
Comment 1 Adam CloudOn 2013-09-21 17:05:19 UTC
Created attachment 86274 [details]
Screenshot comparison between MS Word and LibreOffice
Comment 2 Thomas van der Meulen [retired] 2013-09-29 07:01:59 UTC
Thank you for your bug report,
I can reproduce this bug running LibreOffice: 
Version: 4.2.0.0.alpha0+
Build ID: 164b6ce7b27c0a9ec19019e7b078b9f8f382007d
TinderBox: Win-x86@39, Branch:master, Time: 2013-09-28_16:39:4
And Mircosoft Word 2007
Comment 3 tommy27 2014-02-16 07:25:12 UTC
*** Bug 73553 has been marked as a duplicate of this bug. ***
Comment 4 tommy27 2014-02-16 07:38:19 UTC
I repost here an interesting observation from Bug 73553

....................................................

Jacobo Aragunde Pérez  2014-01-13 13:12:15 UTC 
Created attachment 91944 [details]
Test case

Compare the colors of the shape contained in the attached document when you open it with MS Office and LibreOffice: the order of the first and second colors is swapped.

Check the OOXML definition of the gradient with the definition of a document exported from LibO:

Original document, see how the second and the third colors are equal:
<a:gradFill>
  <a:gsLst>
    <a:gs pos="0">
      <a:schemeClr val="accent5"/>
    </a:gs>
    <a:gs pos="50000">
      <a:schemeClr val="accent1">
        <a:tint val="44500"/>
        <a:satMod val="160000"/>
      </a:schemeClr>
    </a:gs>
    <a:gs pos="100000">
      <a:schemeClr val="accent1"/>
    </a:gs>
  </a:gsLst>
  <a:lin ang="5400000" scaled="0"/>
</a:gradFill>

Exported document, see how the first and the third colors are equal now:
<a:gradFill>
  <a:gsLst>
    <a:gs pos="0">
      <a:srgbClr val="ff388c"/>
    </a:gs>
    <a:gs pos="50000">
      <a:srgbClr val="005bd3"/>
    </a:gs>
    <a:gs pos="100000">
      <a:srgbClr val="ff388c"/>
    </a:gs>
  </a:gsLst>
  <a:lin ang="5400000"/>
</a:gradFill>
Comment 5 Jacobo Aragunde Pérez 2014-02-17 10:37:17 UTC
I could add more details now :)

The reason why the gradient changes is because we don't support gradients with more than two colors in LibreOffice. You can check the API of the Gradient structure at [1], there are only two colors in it. If you check the code at [2], you will see how a gradient with >2 stops is transformed by the importer.

To sum up, a proper fix for this bug would imply the implementation of a new feature: support of gradients with any number of color stops. Right now, the code in master (4.3) is able to preserve the original gradient when exporting back to .docx but it's yet unable to render the gradient correctly.

[1] http://api.libreoffice.org/docs/idl/ref/structcom_1_1sun_1_1star_1_1awt_1_1Gradient.html

[2] http://opengrok.libreoffice.org/xref/core/oox/source/drawingml/fillproperties.cxx#368
Comment 6 How can I remove my account? 2014-07-17 11:48:23 UTC
The rendering of the gradient has improved a bit now after commit f4a2f1e647354efb75be8c90384d6cd3e5f9b9bd (in master) and its follow-up fixes for pre-C++11 and the sd import unit test, which have been cherry-picked to the 4.3 and 4.2 branches, too. LibreOffice still has gradients with only two stops (start and end), but the OOXML import code now tries to be more clever in deciding how to map a multi-stop OOXML gradient to a LibreOffice gradient.

Possibly this bug can now be resolved, or should it be kept open until LibreOffice gets proper support for gradients with an arbitrary number of stops?
Comment 7 tommy27 2014-07-17 12:07:46 UTC
Created attachment 102981 [details]
screenshot in 4.2.5.2

here's a screenshot of the test file like is shown in LibO 4.2.5.2

it looks to me that the improvement in substantial.

i suggest to mark it FIXED and if necessary open a followup bug report about residual issues.
Comment 8 tommy27 2014-07-20 08:30:21 UTC
I mark this as FIXED since the most obvious issue about the flipped gradient which was the focus of this report is gone.