summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-08-29 17:40:51 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-29 18:32:49 +0200
commit305ecd1848a802a6c43ecc6e76f4c6bc36a03418 (patch)
tree7bf27d03af9c4bc1ce4d28ed41d7560b5d7eed78
parent9f05a8709232bdce78760636c6f6f03bf588a1ec (diff)
fdo#79959 RTF import: trim whitespace around style names
Change-Id: Id23cbd62b057442c577fef124a5705e4d551076f
-rw-r--r--sw/qa/extras/rtfimport/data/fdo79959.rtf4
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx5
3 files changed, 13 insertions, 2 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo79959.rtf b/sw/qa/extras/rtfimport/data/fdo79959.rtf
new file mode 100644
index 000000000000..231f39a4e123
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo79959.rtf
@@ -0,0 +1,4 @@
+{\rtf1\ansi\ansicpg1251\deff0\deflang1049{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
+{\stylesheet{\s0 Test;}}
+\viewkind4\uc1\pard\s0\slmult1\lang9\f0\fs22 Hello world!\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 2231e1fa821e..64e2b046ac44 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1928,6 +1928,12 @@ DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
}
+DECLARE_RTFIMPORT_TEST(testFdo79959, "fdo79959.rtf")
+{
+ // This was false, as the style was imported as " Test", i.e. no whitespace stripping.
+ CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(getStyles("ParagraphStyles")->hasByName("Test")));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d0f88ec39b0b..244176223045 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1162,8 +1162,9 @@ void RTFDocumentImpl::text(OUString& rString)
case DESTINATION_STYLEENTRY:
if (m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type))
{
- m_aStyleNames[m_nCurrentStyleIndex] = aName;
- RTFValue::Pointer_t pValue(new RTFValue(aName));
+ // Word strips whitespace around style names.
+ m_aStyleNames[m_nCurrentStyleIndex] = aName.trim();
+ RTFValue::Pointer_t pValue(new RTFValue(aName.trim()));
m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_styleId, pValue);
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);