[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Apr 22 04:11:24 PDT 2014


 sw/qa/extras/rtfimport/data/font-override.rtf |   28 ++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx          |    6 +++++
 writerfilter/source/rtftok/rtfsprm.cxx        |    9 ++++++++
 writerfilter/source/rtftok/rtfsprm.hxx        |    1 
 writerfilter/source/rtftok/rtfvalue.cxx       |    4 +++
 5 files changed, 48 insertions(+)

New commits:
commit 8e8f9388c323ad3c32cef3f91609ad19386b7d56
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Apr 22 12:53:24 2014 +0200

    Related: fdo#77600 RTF import: RTFValue::equals: compare attribute content
    
    Previously only the number of nested sprms / attributes was compared.
    With this, the font of the bugdoc is correctly Arial, not Times.
    
    Change-Id: I351de414b6734336b31c1334dbd2349072f16002

diff --git a/sw/qa/extras/rtfimport/data/font-override.rtf b/sw/qa/extras/rtfimport/data/font-override.rtf
new file mode 100644
index 0000000..a41d2ab
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/font-override.rtf
@@ -0,0 +1,28 @@
+{\rtf1\ansi\deff4\adeflang1025
+{\fonttbl
+{\f0\froman\fprq2\fcharset0 Times New Roman;}
+{\f1\froman\fprq2\fcharset2 Symbol;}
+{\f2\fswiss\fprq2\fcharset0 Arial;}
+{\f3\froman\fprq2\fcharset0 Liberation Serif
+{\*\falt Times New Roman}
+;}
+{\f4\froman\fprq2\fcharset0 Times New Roman;}
+{\f5\fswiss\fprq2\fcharset0 Liberation Sans
+{\*\falt Arial}
+;}
+{\f6\froman\fprq2\fcharset0 Tahoma;}
+{\f7\froman\fprq2\fcharset0 Arial;}
+{\f8\fnil\fprq2\fcharset0 Droid Sans Fallback;}
+{\f9\fnil\fprq2\fcharset0 Lucida Sans;}
+{\f10\fswiss\fprq0\fcharset1 Lucida Sans;}
+{\f11\fnil\fprq2\fcharset0 Arial;}
+}
+{\colortbl;\red0\green0\blue0;\red5\green99\blue193;\red128\green128\blue128;\red0\green0\blue10;}
+{\stylesheet
+{\s0\snext0\ql\widctlpar\ltrpar
+\cf0\kerning1\dbch\af12\langfe1033\dbch\af12\afs20\alang1025\fs24\loch\f4\lang1033 Normal;}
+}
+\pard\plain\s0
+{\af11\f7
+This should be Arial.}
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 1e3ad95..5445002 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1663,6 +1663,12 @@ DECLARE_RTFIMPORT_TEST(testFdo75735, "fdo75735.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty< uno::Sequence<style::TabStop> >(getParagraph(2), "ParaTabStops").getLength());
 }
 
+DECLARE_RTFIMPORT_TEST(testFontOverride, "font-override.rtf")
+{
+    // This was "Times New Roman".
+    CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
+}
+
 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 e69f6ed..c6349cb 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -156,6 +156,15 @@ void RTFSprms::deduplicate(RTFSprms& rReference)
     }
 }
 
+bool RTFSprms::equals(RTFValue& rOther)
+{
+    RTFSprms::Iterator_t i = m_pSprms->begin();
+    while (i != m_pSprms->end())
+        if (!i->second->equals(rOther))
+            return false;
+    return true;
+}
+
 void RTFSprms::ensureCopyBeforeWrite()
 {
     if (m_pSprms->m_nRefCount > 1)
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index 9f811bd..f6c9f5b 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -90,6 +90,7 @@ public:
         return m_pSprms->end();
     }
     void clear();
+    bool equals(RTFValue& rOther);
 private:
     void ensureCopyBeforeWrite();
     boost::intrusive_ptr<RTFSprmsImpl> m_pSprms;
diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx
index 3ff04d7..430b049 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -227,8 +227,12 @@ bool RTFValue::equals(RTFValue& rOther)
         return false;
     if (m_pAttributes->size() != rOther.m_pAttributes->size())
         return false;
+    else if (!m_pAttributes->equals(rOther))
+        return false;
     if (m_pSprms->size() != rOther.m_pSprms->size())
         return false;
+    else if (!m_pSprms->equals(rOther))
+        return false;
     return true;
 }
 


More information about the Libreoffice-commits mailing list