From c4696e7c0456df8d9466acbae3ea1fa9dcfa73f0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Feb 2013 20:46:19 +0100 Subject: [PATCH] RTF import: fix import of \line symbol "Required line break" was eaten by the newly added code in text() to ignore \'0a. (regression from f593a2e4179b05ae1019372cde612cb242d1d27f) Change-Id: Id32687c40a17ddb99196635cedfc850182705799 --- sw/qa/extras/rtfimport/data/fdo58646line.rtf | 1 + sw/qa/extras/rtfimport/rtfimport.cxx | 8 ++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 8 ++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/rtfimport/data/fdo58646line.rtf diff --git a/sw/qa/extras/rtfimport/data/fdo58646line.rtf b/sw/qa/extras/rtfimport/data/fdo58646line.rtf new file mode 100644 index 000000000000..63cf71dc6399 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo58646line.rtf @@ -0,0 +1 @@ +{\rtf1 foo\line bar} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index bf190184fdf3..a3a2f12e651a 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -138,6 +138,7 @@ public: void testFdo58933(); void testFdo44053(); void testFdo48440(); + void testFdo58646line(); void testFdo58646(); void testFdo59419(); void testFdo58076_2(); @@ -250,6 +251,7 @@ void Test::run() {"fdo58933.rtf", &Test::testFdo58933}, {"fdo44053.rtf", &Test::testFdo44053}, {"fdo48440.rtf", &Test::testFdo48440}, + {"fdo58646line.rtf", &Test::testFdo58646line}, {"fdo58646.rtf", &Test::testFdo58646}, {"fdo59419.rtf", &Test::testFdo59419}, {"fdo58076-2.rtf", &Test::testFdo58076_2}, @@ -1076,6 +1078,12 @@ void Test::testFdo48440() CPPUNIT_ASSERT_EQUAL(2, getPages()); } +void Test::testFdo58646line() +{ + // \line symbol was ignored + getParagraph(1, "foo\nbar"); +} + void Test::testFdo58646() { // Page break was ignored inside a continous section, on title page. diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 607d9553ef96..325ff4f6eb8c 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1605,12 +1605,16 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) checkUnicode(); setNeedSect(); RTFSkipDestination aSkip(*this); - sal_uInt8 cCh = 0; + if (RTF_LINE == nKeyword) + { // very special handling since text() will eat lone '\n' + singleChar('\n'); + return 0; + } // Trivial symbols + sal_uInt8 cCh = 0; switch (nKeyword) { - case RTF_LINE: cCh = '\n'; break; case RTF_TAB: cCh = '\t'; break; case RTF_BACKSLASH: cCh = '\\'; break; case RTF_LBRACE: cCh = '{'; break;