From 39d4246652fd678ea47b315f433f279f08d61318 Mon Sep 17 00:00:00 2001 From: Vasily Melenchuk Date: Sun, 20 Mar 2022 08:48:17 +0300 Subject: [PATCH] tdf#131234: RTF import: extend default char props list There are much more character attributes should be applied wth default values if style contain them, but they were not mentioned in current run. These are obviously not a complete set yet, but most common ones are included. Change-Id: Ide52245bc98628febc2f3bd2e25166f0dcdf35cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131853 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit 494020efe6d29bc319c3abcd3245425e394674ec) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131857 Reviewed-by: Xisco Fauli --- sw/qa/extras/rtfexport/data/tdf131234.rtf | 12 ++++++++++++ sw/qa/extras/rtfexport/rtfexport5.cxx | 17 +++++++++++++++++ writerfilter/source/rtftok/rtfsprm.cxx | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 sw/qa/extras/rtfexport/data/tdf131234.rtf diff --git a/sw/qa/extras/rtfexport/data/tdf131234.rtf b/sw/qa/extras/rtfexport/data/tdf131234.rtf new file mode 100644 index 000000000000..976987bee113 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf131234.rtf @@ -0,0 +1,12 @@ +{\rtf1\ansi +{\fonttbl +{\f3 Tahoma;} +} +{\colortbl;\red123\green0\blue0;\red0\green0\blue255;} +{\stylesheet +{\s1\f3\fs64\cf2\b1\i1\ul1 Test112;} +} + +\s1 Hello\par + +} diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 28daa538f677..b9a7321d724b 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include #include #include @@ -1307,6 +1310,20 @@ DECLARE_RTFEXPORT_TEST(testTdf144437, "tdf144437.odt") CPPUNIT_ASSERT_MESSAGE("Bookmark start & end are wrong", nBmkEndPos > nBmkStartPos); } +DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf") +{ + uno::Reference xRun = getRun(getParagraph(1), 1, OUString(u"Hello")); + + // Ensure that text has default font attrs in spite of style referenced + // E.g. 12pt, Times New Roman, black, no bold, no italic, no underline + CPPUNIT_ASSERT_EQUAL(12.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xRun, "CharColor")); + CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty(xRun, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty(xRun, "CharWeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, getProperty(xRun, "CharUnderline")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index 8c54fe95e345..04df49bc0287 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -163,8 +163,20 @@ static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id nStyleType) { switch (id) { + case NS_ooxml::LN_EG_RPrBase_szCs: + case NS_ooxml::LN_EG_RPrBase_sz: + return new RTFValue(24); + case NS_ooxml::LN_CT_Color_val: + return new RTFValue(0); case NS_ooxml::LN_EG_RPrBase_b: + case NS_ooxml::LN_EG_RPrBase_i: return new RTFValue(0); + case NS_ooxml::LN_CT_Underline_val: + return new RTFValue(NS_ooxml::LN_Value_ST_Underline_none); + case NS_ooxml::LN_CT_Fonts_ascii: + case NS_ooxml::LN_CT_Fonts_eastAsia: + case NS_ooxml::LN_CT_Fonts_cs: + return new RTFValue("Times New Roman"); default: break; } -- 2.11.4.GIT