Bug 150786 - Exporting form controls to PDF gives different results depending on system dark mode
Summary: Exporting form controls to PDF gives different results depending on system da...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.5.0 target:7.4.3
Keywords:
: 144863 (view as bug list)
Depends on:
Blocks: PDF-Export
  Show dependency treegraph
 
Reported: 2022-09-05 07:54 UTC by Mike Kaganski
Modified: 2023-03-21 13:45 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-09-05 07:54:58 UTC
Using Version: 7.4.1.1 (x64) / LibreOffice Community
Build ID: 0a046a10cbf1679eea5538bd3ab63156caa3a036
CPU threads: 12; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: CL

1. Enable experimental features (Options->LibreOffice->Advanced) to enable system dark mode support implemented in bug 118320.
2. Use system light mode.
3. Open vcl/qa/cppunit/pdfexport/data/form-font-name.odt.
4. Export to PDF.
5. Use system dark mode.
6. Export to another PDF (can be done even without reloading the document). Note that Writer displays the form control with black background BTW.

Comparing the two resulting PDFs shows that they have different control backgrounds.

Respective unit test fails on master with system dark mode with:

C:/lo/src/core/vcl/qa/cppunit/pdfexport/pdfexport.cxx(2656) : error : Assertion
Test name: `anonymous namespace'::testFormFontName::TestBody
equality assertion failed
- Expected: 0 0 0 rg /TiRo 12 Tf
- Actual  : 1 1 1 rg /TiRo 12 Tf
Comment 1 ⁨خالد حسني⁩ 2022-09-05 14:40:17 UTC
This happens for me without even enabling experimental features, using dark theme from the system seems to be the default.
Comment 2 Caolán McNamara 2022-09-05 14:47:10 UTC
In toolkit/source/awt/vclxwindow.cxx we set EnableNativeWidget(false) when drawing things like this, so possibly either that code path isn't used in this case or something similar should do the same, or it doesn't work fully.
Comment 3 Commit Notification 2022-09-08 11:08:56 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9f682acf75d56c82b40114bb9fceb29d837de2dd

Related: tdf#150786 workaround unit test failure

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 Timur 2022-09-28 14:36:11 UTC
Can this be changed to All OS or is implementation different for Win and Lin?
Comment 5 Mike Kaganski 2022-09-28 18:43:27 UTC
Also repro on Ubuntu. Indeed, All.
Comment 6 Caolán McNamara 2022-10-02 19:30:13 UTC
turns out this is PDFWriterImpl::createDefaultEditAppearance and similar in vcl/source/gdi/pdfwriter_impl.cxx where we have stuff like

setFillColor( rWidget.Background ? replaceColor( rWidget.BackgroundColor, rSettings.GetFieldColor() ) : COL_TRANSPARENT );

which sets the background to the current theme background. I'm not sure why we replaceColor at all, but at the least I guess we should not use the current theme here, but some "preset for pdf" colors which we can base on the current gen (light) theme for consistency regardless of the current UI theme
Comment 7 Commit Notification 2022-10-03 08:54:58 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

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

tdf#150786 use the same colors for pdf widgets regardless of 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 8 Caolán McNamara 2022-10-03 09:54:30 UTC
lets try that then, backport to 7-4 in gerrit
Comment 9 Timur 2022-10-03 11:35:25 UTC
Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: a0bc0cc81b597aa81189355a8125753d6b873cce
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3

1. With dark theme, I still see black form, and I think it should not be black.
2. Export to PDF with "Create form" checked is OK.
3. Export to PDF without "Create form" checked is NOK, bug 150886.
Comment 10 Commit Notification 2022-10-03 13:50:07 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/da42c917c49940b3507b72fcd8f603331d922244

tdf#150786 use the same colors for pdf widgets regardless of theme

It will be available in 7.4.3.

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 11 Caolán McNamara 2022-10-04 15:26:42 UTC
proposed solution for bug 150886 addresses point 1 as a side effect: https://gerrit.libreoffice.org/c/core/+/140942/2
Comment 12 Commit Notification 2022-10-04 19:18:08 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

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

tdf#150786 use a 'standard' theme for form controls

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 13 Caolán McNamara 2022-11-07 16:27:58 UTC
*** Bug 144863 has been marked as a duplicate of this bug. ***
Comment 14 tobyps 2022-11-07 17:44:07 UTC
(In reply to Commit Notification from comment #12)
> Caolán McNamara committed a patch related to this issue.
> It has been pushed to "master":

> 
> Affected users are encouraged to test the fix and report feedback.

Works great in Daily 7.4.4 and 7.5

Tested with Win10 and exporting a fillable pdf from Writer.
Comment 15 Buovjaga 2022-11-08 07:32:49 UTC
*** Bug 144863 has been marked as a duplicate of this bug. ***