Bug 150886 - Text in Exported Writer Forms is Hidden/Light and Form dark if OS Dark mode
Summary: Text in Exported Writer Forms is Hidden/Light and Form dark if OS Dark mode
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.5.0
Keywords:
Depends on:
Blocks: Linux-Dark-Mode
  Show dependency treegraph
 
Reported: 2022-09-09 11:22 UTC by Marc Schreiber
Modified: 2022-10-04 19:20 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Document that can reproduce the bug (9.35 KB, application/vnd.oasis.opendocument.text)
2022-09-09 11:22 UTC, Marc Schreiber
Details
PDF export result in 7.4 (8.44 KB, application/pdf)
2022-09-09 11:36 UTC, Miklos Vajna
Details
Exported with LO 7.4 on Arch Linux (23.79 KB, application/pdf)
2022-09-09 11:58 UTC, Marc Schreiber
Details
A screencast that shows how to reproduce (2.16 MB, video/webm)
2022-09-21 19:18 UTC, Marc Schreiber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Schreiber 2022-09-09 11:22:33 UTC
Created attachment 182336 [details]
Document that can reproduce the bug

I started a little project (see https://gitlab.com/schrieveslaach/nextcloud-open-document-forms) in which I use the LibreOffice CPP API to generate a PDF document from a ODT document with form fields.

However, I my project the text is always hidden behind a white rectangle. The text seems to rendered behind the form outline.

To reproduce the issue: You can git clone the project, use setsdkenv_unix to set up the LibreOffice SDK and run cargo run (Rust toolchain required) to start an HTTP server. When you open the URL http://127.0.0.1:8000/, you can enter a name into the form and submit it. The resulting PDF will contain the entered name (use ctrl + a to select all text), but it will be invisible.

The same happens, when you export the attached ODT as PDF in LibreOffice Writer.
Comment 1 Miklos Vajna 2022-09-09 11:36:33 UTC
Created attachment 182337 [details]
PDF export result in 7.4

Hm, if I open your ODT in Writer, type "asdf" into the "text box" form shape and export to PDF, I get the attached. That looks reasonable to me: I can toggle in e.g. okular if I want to see the forms or not, and both the plain PDF view and the "show forms" one shows "asdf" to me.

Care to elaborate where is it missing? It may be a good idea to try at least 2 PDF viewers to make sure that the problem is with the PDF, not with the viewer.
Comment 2 Marc Schreiber 2022-09-09 11:58:59 UTC
Created attachment 182338 [details]
Exported with LO 7.4 on Arch Linux
Comment 3 Marc Schreiber 2022-09-09 12:01:06 UTC
The text in “PDF export result in 7.4” is visible to me as well so I won't suspect that the PDF viewer is to blame (tried multiple ones and all show the same result). I attached an exported PDF document that has been generated on my machine.
Comment 4 Miklos Vajna 2022-09-09 13:15:22 UTC
More detailed version info:

Version: 7.4.2.0.0+ / LibreOffice Community
Build ID: 7a7268be9cbeaf361cfa5a52ad8980214e958f2e
CPU threads: 8; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: hu-HU (hu_HU.UTF-8); UI: en-US
Calc: threaded

Can you provide your one from the about dialog? Perhaps we regressed in some older 7.4 and this got fixed?
Comment 5 Marc Schreiber 2022-09-12 16:03:32 UTC
Here are my version information.

Version: 7.4.0.3 / LibreOffice Community
Build ID: 40(Build:3)
CPU threads: 4; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: de-DE
7.4.0-3
Calc: threaded

Please note, that the issue was also present in 7.3.

I also unticked the box to generate a PDF form in the PDF export dialog so the text won't be editable. The attached document “PDF export result in 7.4” is a PDF form. Exporting PDF forms generates the same result on my system.
Comment 6 QA Administrators 2022-09-13 03:33:43 UTC Comment hidden (obsolete)
Comment 7 Timur 2022-09-13 07:08:04 UTC
I don't reproduce the bug. 
You were not precise, you attached ODT with empty form and say that it makes empty form, which it should. 
So far this seems more for support at ask.libreoffice.org then for bug report here. 
You may try with empty profile of LO user folder.
Comment 8 Marc Schreiber 2022-09-15 10:58:24 UTC
To reproduce with LO: Open “Document that can reproduce the bug” and enter a text into the text field. Go to file -> export as -> export as PDF and make sure that you do not check the box to export a PDF form. Then export. When you open up the exported PDF, you can mark the text with ctrl + A and copy/paste it into a text editor. This will copy “First name:” and the entered text. But that text is invisible in the PDF document.

Please note that my first comment included the instructions how to reproduce the bug with https://gitlab.com/schrieveslaach/nextcloud-open-document-forms
Comment 9 QA Administrators 2022-09-16 03:42:13 UTC Comment hidden (obsolete)
Comment 10 Timur 2022-09-16 11:34:59 UTC
We couldn't reproduce, meaning some detail is missing or you need to follow what's advised - You may try with empty profile of LO user folder.
Please do not set Unconfirmed indicating need for testing, unless you have more details, as test was done by 2 persons and it has no purpose staying like that.
Comment 11 Marc Schreiber 2022-09-21 19:18:39 UTC
Created attachment 182607 [details]
A screencast that shows how to reproduce

I made a screencast that show how I can reproduce the bug. The screencast also shows that I'm using a fresh profile folder (see soffice -env:UserInstallation=file:///tmp/test) and I opened the ODT from here (https://gitlab.com/schrieveslaach/nextcloud-open-document-forms/-/blob/main/example-docs/firstname.odt).

Copying the text from the exported PDF into a text editor shows that the text is there but invisible.
Comment 12 Marc Schreiber 2022-09-21 20:24:54 UTC
And I must apologize. My project did not initialize the LO backend so that it is reproducible because I wasn't aware that the LO API picks up the settings of my LO profile. The commit https://gitlab.com/schrieveslaach/nextcloud-open-document-forms/-/commit/46b0f2974d1044719a14bc764f52591bb19dce51 starts the backend now in the same way as in my screencast. So if you checkout the project and if you follow the instruction, test PDF should be generated in the same way.
Comment 13 QA Administrators 2022-09-22 03:56:31 UTC Comment hidden (obsolete)
Comment 14 Timur 2022-09-28 14:34:11 UTC
I may have an explanation: you are using German interface but English text so text is lost ? :) 

Or another one: you are using dark mode in Linux. It was some detail..
If form is not exported, it's content is light or not seen on white background. 
If form is exported, it's dark with light text. 

Could be a dupe of bug 150786, but so far let's keep that one Win and this one Lin.
Comment 15 Mike Kaganski 2022-09-28 18:45:48 UTC
(In reply to Timur from comment #14)
> Could be a dupe of bug 150786

While difference in control background is indeed bug 150786, the problem here is that the text has the same color. But I can't repro this last piece on my Ubuntu system: the text is white on black when I set system to dark mode.
Comment 16 Mike Kaganski 2022-09-28 19:09:23 UTC
(In reply to Mike Kaganski from comment #15)
> I can't repro this last piece on my Ubuntu system:
> the text is white on black when I set system to dark mode.

Ah, sorry - yes, exporting with disabled creation of PDF form in dark mode gives slightly grey text on white control area.

But I'm unsure if it's related to bug 150786.
Comment 17 Caolán McNamara 2022-10-03 15:38:14 UTC
This one hits Edit::Draw so putting a breakpoint there shows how it gets called, which is from VclMetafileProcessor2D::processControlPrimitive2D etc.

Ideally I think we would distinguish a form control hosted in a document as different to one hosted in, say a dialog, but its not entirely clear to me where the right place would be for that distinction to be made.
Comment 18 Caolán McNamara 2022-10-04 11:44:32 UTC
we have an existing "NativeWidgetLook" property so maybe we can leverage its absence to force 'standard' colors for UnoControl::draw
Comment 19 Caolán McNamara 2022-10-04 19:20:59 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.