Description: Hello, copying-and-pasting HTML text whose inline style contains color into LibreOffice Writer does not work properly, as the pasted text will not always show its actual color. When the rgb(r g b / a) CSS notation is used, the alpha channel is ignored and rgb(r, g, b) is used instead. When the rgba(r, g, b, a) CSS format is used, the color is ignored entirely. Only text using the rgb(r, g, b) CSS format (without an alpha channel) will show the correct color in LibreOffice writer. Steps to Reproduce: 1. Copy this HTML markup inside a file: <!DOCTYPE html> <html lang=""> <head> <meta charset="utf-8"> <title>Color test</title> </head> <body> <p style="color: rgb(255, 0, 0)">1) This text is pasted with color</p> <p style="color: rgb(255 0 0 / 50%)">2) This text is also pasted with color, but the text pasted has a color which ignores the alpha channel</p> <p style="color: rgba(255, 0, 0, 0.3)">3) This text is pasted without color</p> </body> </html> 2. Open the created HTML file with a web browser 3. Copy the three lines of text into the clipboard 4. Paste the clipboard into LibreOffice Writer Actual Results: Pasting line 1) (which uses the rgb(r, g, b) format) into LibreOffice Writer will show the right color. Pasting line 2) (which used the rgb(r g b / a) format) into LibreOffice Writer will show a wrong color (in this case, rgb(r, g, b) without the alpha channel). Pasting line 3) into LibreOffice Writer will not show any color. Expected Results: All three lines should show the correct color. Reproducible: Always User Profile Reset: No Additional Info: Please note that an alpha channel is not needed to show rgba text. The algorithm in https://marcodiiga.github.io/rgba-to-rgb-conversion can be used to turn a RGBA color into RGB. So, from my example, rgba(255, 0, 0, 0.3) can be rendered as: rgb(255,179,179) by setting white as the background color.
On pc Debian x86-64 with master sources updated today, I could reproduce this. I gave a try with https://gerrit.libreoffice.org/c/core/+/146546
Julien Nabet committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/a21aad5e084e3901a1e216ef9006b0f8b6132c39 tdf#153341: try to parse alpha value when copying HTML text It will be available in 7.6.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.
Cherry-pick for 7.5 waiting for review here: https://gerrit.libreoffice.org/c/core/+/146524
Julien Nabet committed a patch related to this issue. It has been pushed to "libreoffice-7-5": https://git.libreoffice.org/core/commit/879db444dbc072a43fa0df460b48558ea4d9def5 tdf#153341: try to parse alpha value when copying HTML text It will be available in 7.5.1. 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.
Verified in Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 00b9b33334791079c2dc26b1ed4c123450cabf7d CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3 Locale: es-ES (es_ES.UTF-8); UI: en-US Calc: threaded @Julien, thanks for fixing this issue!!
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/cc685e16b5325384268ddd52f24293b6e4bf3502 tdf#153341: sw_htmlimport: Add unittest It will be available in 7.6.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.