summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-08-08 18:04:47 +0200
committerLászló Németh <nemeth@numbertext.org>2019-08-24 11:37:51 +0200
commit24b04db5a63b57a74e58a7616091437ad68548ac (patch)
tree7aa22bbc24efacfc854231664077e8f8143bda8e /sw
parentf693d23170036bd6116458e655c2f3b34b3cd926 (diff)
tdf#123703 RTF import: fix length of space character sequence
A default RTF space character is longer by an extra six-per-em space in a space sequence. To get the same layout of documents formatted with consecutive spaces, insert six-per-em space before every space in a space sequence. Extra spaces are removed during the RTF export. Note: This is a workaround to get the same layout in documents based on RTF templates, often used for example by bussiness applications. Instead of adding a new RTF specific core/text layout feature, with this workaround the layout will be compatible with ODT and DOCX documents, too. (In contrast, MSO's DOCX export messes up the document layout silently, shortening the length of the space sequence.) Change-Id: I620807e1d4497e86c18732e5aa3131cf817ed94a Reviewed-on: https://gerrit.libreoffice.org/77172 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/tdf123703.rtf31
-rw-r--r--sw/qa/extras/rtfexport/rtfexport3.cxx11
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx11
3 files changed, 53 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf123703.rtf b/sw/qa/extras/rtfexport/data/tdf123703.rtf
new file mode 100644
index 000000000000..f657da198c70
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf123703.rtf
@@ -0,0 +1,31 @@
+{\rtf1
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+word word2\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index abdda750ba22..8845e893472b 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -254,6 +254,17 @@ DECLARE_RTFEXPORT_TEST(testTabs, "tabs.rtf")
CPPUNIT_ASSERT_EQUAL(style::TabAlign_DECIMAL, rTabStop.Alignment);
}
+DECLARE_RTFEXPORT_TEST(testTdf123703, "tdf123703.rtf")
+{
+#if !defined(MACOSX)
+ // This was 1, because of normal space character width in consecutive spaces
+ CPPUNIT_ASSERT_EQUAL(2, getPages());
+#else
+ // still 1 here
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+#endif
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index e215420eb8ca..7336d8566d87 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1706,6 +1706,17 @@ OUString SwWW8AttrIter::GetSnippet(const OUString &rStr, sal_Int32 nCurrentPos,
aSnippet = aSnippet.replace(CHAR_HARDHYPHEN, 0x1e);
aSnippet = aSnippet.replace(CHAR_SOFTHYPHEN, 0x1f);
+ // tdf#123703 revert import workaround for longer space characters in consecutive spaces
+ sal_Int32 nPos;
+ if ((nPos = aSnippet.indexOf(0x2006)) > -1)
+ {
+ const sal_Unicode aExtraSpace[5] = { 0x2006, 0x20, 0x2006, 0x20, 0 };
+ const sal_Unicode aExtraSpace2[4] = { 0x20, 0x2006, 0x20, 0 };
+ OUString sDoubleSpace(" ");
+ aSnippet = aSnippet.replaceAll(aExtraSpace, sDoubleSpace, nPos)
+ .replaceAll(aExtraSpace2, sDoubleSpace);
+ }
+
m_rExport.m_aCurrentCharPropStarts.push( nCurrentPos );
const SfxPoolItem &rItem = GetItem(RES_CHRATR_CASEMAP);