sw/qa/extras/htmlimport/data/tdf153341.html | 13 +++++++++++++ sw/qa/extras/htmlimport/htmlimport.cxx | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+)
New commits: commit cc685e16b5325384268ddd52f24293b6e4bf3502 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Feb 10 13:46:40 2023 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Feb 10 14:57:43 2023 +0000 tdf#153341: sw_htmlimport: Add unittest Change-Id: I048a95a3bb36981f5f2d3d243021952b34529075 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146753 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/htmlimport/data/tdf153341.html b/sw/qa/extras/htmlimport/data/tdf153341.html new file mode 100644 index 000000000000..dc69feb73b70 --- /dev/null +++ b/sw/qa/extras/htmlimport/data/tdf153341.html @@ -0,0 +1,13 @@ +<!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> + diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 0bb761647904..fe062f5c83fd 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -574,6 +574,27 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testRGBAColor) CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<Color>(xRun, "CharBackColor")); } +CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf153341) +{ + createSwWebDoc("tdf153341.html"); + + const uno::Reference<text::XTextRange> xPara1 = getParagraph(1); + const uno::Reference<beans::XPropertySet> xRun1(getRun(xPara1,1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x00, 0xFF, 0x00, 0x00), getProperty<Color>(xRun1, "CharColor")); + + const uno::Reference<text::XTextRange> xPara2 = getParagraph(2); + const uno::Reference<beans::XPropertySet> xRun2(getRun(xPara2,1), uno::UNO_QUERY); + + // Without the fix in place, this test would have failed with + // - Expected: rgba[ff00007f] + // - Actual : rgba[ff0000ff] + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x80, 0xFF, 0x00, 0x00), getProperty<Color>(xRun2, "CharColor")); + + const uno::Reference<text::XTextRange> xPara3 = getParagraph(3); + const uno::Reference<beans::XPropertySet> xRun3(getRun(xPara3,1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xB3, 0xFF, 0x00, 0x00), getProperty<Color>(xRun3, "CharColor")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */