[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu May 15 04:46:20 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 | 12 ++++++++++-
5 files changed, 55 insertions(+), 1 deletion(-)
New commits:
commit c0fee7f70f4c7d97cd911c987d0b6dd57c6795e5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Mar 3 18:54:01 2014 +0100
fdo#78313 RTF import: retain font colors
This is a cherry-pick of two master commits:
RTFValue::equals: consider the number of attributes/sprms as well
(cherry picked from commit 4452fa9a2e741834a19c9b322fc8d9c8b06450de)
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.
(cherry picked from commit 8e8f9388c323ad3c32cef3f91609ad19386b7d56)
Conflicts:
writerfilter/source/rtftok/rtfsprm.hxx
Change-Id: I351de414b6734336b31c1334dbd2349072f16002
Reviewed-on: https://gerrit.libreoffice.org/9316
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
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 908178f..562b9df 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1635,6 +1635,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 c6d9172..c79c6e2 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -143,6 +143,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 19f0514..a889207 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -60,6 +60,7 @@ namespace writerfilter {
Iterator_t begin() { return m_pSprms->begin(); }
Iterator_t end() { 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 7af638f..132233c 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -210,7 +210,17 @@ RTFValue* RTFValue::Clone()
bool RTFValue::equals(RTFValue& rOther)
{
- return m_nValue == rOther.m_nValue;
+ if (m_nValue != rOther.m_nValue)
+ 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;
}
RTFSprms& RTFValue::getAttributes()
More information about the Libreoffice-commits
mailing list