Bug 155901 - MCGR: Adding gradient to user palette or setting a border changes last stop offset to 1
Summary: MCGR: Adding gradient to user palette or setting a border changes last stop o...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Regina Henschel
URL:
Whiteboard: target:24.2.0 target:7.6.0.0.beta2
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-17 18:37 UTC by Regina Henschel
Modified: 2023-06-27 20:55 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Gradient with last stop at offset 0.69 (20.47 KB, application/vnd.oasis.opendocument.graphics)
2023-06-17 18:37 UTC, Regina Henschel
Details
left original, right after using Area dialog (201.28 KB, image/png)
2023-06-19 10:07 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2023-06-17 18:37:13 UTC
Created attachment 187965 [details]
Gradient with last stop at offset 0.69

(1) Open attached document. Select the shape and open Area-dialog from the context menu of the shape. Click 'Add' button to add the gradient to the user gradient palette. Enter a name. OK. Notice that the offset of the last color stop has changed.
Or
(2) Open attached document. Select the shape and open Area-dialog from the context menu of the shape. Change the value of the 'Transition start' field to a different value. Click into any other field to update the setting. Notice that the offset of the last color stop has changed.

The changed offset is already visible in the preview in the dialog.

Hi Armin, do you have a code pointer for me, where this change might happen?
Comment 1 Heiko Tietze 2023-06-19 06:57:21 UTC
Don't see an issue on Linux/kf5.
Comment 2 Regina Henschel 2023-06-19 10:07:28 UTC
Created attachment 187984 [details]
left original, right after using Area dialog

The left side is a screen shot of the original shape. The right side is a screen shot after changing the transition start from 20% to 22%. Notice that the center of the arc is now blue instead of white.
Comment 3 Stéphane Guillou (stragu) 2023-06-19 12:05:18 UTC
Reproduced in:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: ec60d354359067f8c5c686ef2239ee705916de43
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Centre offset is lost as soon as any gradient setting is changed (or saving it as a preset).
Comment 4 Regina Henschel 2023-06-19 20:38:33 UTC
While working on problems with the 'Increment' setting in die Gradient dialog (e.g. bug 107787) I stumble across a possible for this issue.

The member m_aColorStops of SvxGradientTabPage is used so that it only carries the inner stops of a multicolor gradient. When building a basegfx::BGradient, then the first and last color is taken from the color fields of the dialog and forced to offset 0 and 1 respectively and only the intermediate stops are taken from m_aColorStops. That is likely a leftover. With current implementation basegfx::BGradient is used in the first place, and start and end color are derived from it.

The relevant locations are in the various versions of createColorStops() method. For example from tpgradnt.cxx:
640  basegfx::BColorStops SvxGradientTabPage::createColorStops()
641  {
642      basegfx::BColorStops aColorStops;
643  
644      aColorStops.emplace_back(0.0, m_xLbColorFrom->GetSelectEntryColor().getBColor());
645  
646      if(!m_aColorStops.empty())
647      {
648          aColorStops.insert(aColorStops.begin(), m_aColorStops.begin(), m_aColorStops.end());
649      }
650  
651      aColorStops.emplace_back(1.0, m_xLbColorTo->GetSelectEntryColor().getBColor());
652  
653      return aColorStops;
654  }

All uses of m_aColorStops have to be changed so that is contains the entire gradient. The dialog fields are only relevant for the color of the first and last stops, but not for their offsets.

Armin, is my observation correct?
Comment 5 Commit Notification 2023-06-23 08:54:59 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

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

tdf#155901 MCGR: preserve first and last gradient stop too

It will be available in 24.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 6 Regina Henschel 2023-06-25 12:07:54 UTC
This needs the additional patch https://gerrit.libreoffice.org/c/core/+/153555 if backporting to Lo 7.6.
Comment 8 Commit Notification 2023-06-27 20:55:20 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/4eb813aaabd88a13172effc467259b60d1831543

tdf#155901 MCGR: preserve first and last gradient stop too

It will be available in 7.6.0.0.beta2.

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.