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(+)

New commits:
commit 494020efe6d29bc319c3abcd3245425e394674ec
Author:     Vasily Melenchuk <vasily.melenc...@cib.de>
AuthorDate: Sun Mar 20 08:48:17 2022 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Mar 21 08:36:40 2022 +0100

    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 <vmik...@collabora.com>

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 c7aa87f7838d..6ff7136a81ce 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -29,6 +29,9 @@
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
 
 #include <tools/UnitConversion.hxx>
 #include <vcl/svapp.hxx>
@@ -1331,6 +1334,20 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf144437)
     CPPUNIT_ASSERT_MESSAGE("Bookmark start & end are wrong", nBmkEndPos > 
nBmkStartPos);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf")
+{
+    uno::Reference<text::XTextRange> 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<float>(xRun, "CharHeight"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, 
"CharColor"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), 
getProperty<OUString>(xRun, "CharFontName"));
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xRun, 
"CharWeight"));
+    CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, 
getProperty<sal_Int16>(xRun, "CharUnderline"));
+    CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, 
getProperty<awt::FontSlant>(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;
         }

Reply via email to