Bug 151610 - Exporting charts (to PDF, but also to a unit test dump) gives different results depending on system dark mode
Summary: Exporting charts (to PDF, but also to a unit test dump) gives different resul...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Chart (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All Windows (All)
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.5.0 target:7.4.4
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-17 17:10 UTC by Mike Kaganski
Modified: 2022-11-09 12:06 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2022-10-17 17:10:24 UTC
1. Use system dark mode on Windows
2. Open chart2/qa/extras/xshape/data/xls/tdf150832.xls
=> the chart is shown on dark background, even though the cell grid background is white
3. Export to PDF
=> the chart background there is also dark, unlike when using light mode
4. Run the respective unit test:

> make CppunitTest_chart2_xshape CPPUNIT_TEST_NAME=Chart2XShapeTest::testTdf150832

=> error:

> C:/lo/src/core/test/source/diff/diff.cxx(265) : error : Assertion
> Test name: Chart2XShapeTest::testTdf150832
> double equality assertion failed
> - Expected: nan
> - Actual  : 202020
> - Delta   : 1e-08
> - Reference: C:/lo/src/core/chart2/qa/extras/xshape/data/reference/tdf150832.xml
> - Node: /XShapes/XShape[1]
> - Attr: fillColor
Comment 1 Caolán McNamara 2022-11-07 12:44:25 UTC
confirmed.

I think this is coming from
sc/source/filter/excel/xichart.cxx:509 with
aAreaFmt.maPattColor = ... rRoot.GetPalette().GetColor( rFmtInfo.mnAutoPattColorIdx )
ending up with
sc/source/filter/excel/xlstyle.cxx:154
and we use the system background color for the chart
Comment 2 Caolán McNamara 2022-11-07 12:57:46 UTC
https://gerrit.libreoffice.org/c/core/+/142383 if we wanted to just always have the same colors for imported-from-excel charts
Comment 3 Commit Notification 2022-11-07 23:07:10 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

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

tdf#151610 chart colors should be the same regardless of the desktop theme

It will be available in 7.5.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 4 Commit Notification 2022-11-09 12:06:48 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

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

tdf#151610 chart colors should be the same regardless of the desktop theme

It will be available in 7.4.4.

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.