sw/qa/extras/rtfimport/data/hexcrlf.rtf | 4 ++++ sw/qa/extras/rtfimport/rtfimport.cxx | 10 ++++++++++ sw/source/core/unocore/unotext.cxx | 2 ++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 14 +++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-)
New commits: commit f1bd815f60c78495259ae19ea68eacdb8b43a9e8 Author: Michael Stahl <mst...@redhat.com> Date: Thu Feb 23 16:07:18 2017 +0100 sw: fix cursor backup in SwXText::insertTextPortion() If the inserted string contains "\r", such as when importing lp556169-2.rtf before the previous fix, the given cursor has one of its positions mangled because its nNode will be on the new node, but the nContent that is restored here is on the old node. The invalid cursor causes an assert in the subsequent SetPropertyValues. Change-Id: I73a2e6ecd02ccf75f7b9ffd89d90ae1e3a93ceb2 diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index f32836a..78cce48 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1352,10 +1352,12 @@ SwXText::insertTextPortion( if (!rText.isEmpty()) { + SwNodeIndex const nodeIndex(rCursor.GetPoint()->nNode, -1); const sal_Int32 nContentPos = rCursor.GetPoint()->nContent.GetIndex(); SwUnoCursorHelper::DocInsertStringSplitCR( *m_pImpl->m_pDoc, rCursor, rText, false); SwUnoCursorHelper::SelectPam(rCursor, true); + rCursor.GetPoint()->nNode = SwNodeIndex(nodeIndex, +1); rCursor.GetPoint()->nContent = nContentPos; } commit 10e733908038407791f9c14af2a86417cc4a653c Author: Michael Stahl <mst...@redhat.com> Date: Thu Feb 23 15:33:55 2017 +0100 writerfilter: RTF import: hex-escaped \r and \n create paragraph break ... in Word 2010, while the spec doesn't say what they do. So just handle \'0d and \'0a like \par. This fixes an assert failure on importing lp556169-2.rtf, where insertTextPortion was called with a string containing "\r", which split the paragraph and that messed up the SwPaM. Change-Id: Iee8b5b47e15d18232de841adfbc9c6498727c384 diff --git a/sw/qa/extras/rtfimport/data/hexcrlf.rtf b/sw/qa/extras/rtfimport/data/hexcrlf.rtf new file mode 100644 index 0000000..7c7ed1a --- /dev/null +++ b/sw/qa/extras/rtfimport/data/hexcrlf.rtf @@ -0,0 +1,4 @@ +{\rtf1 +foo\'0dba +r\'0abaz\'0d\'0aquux +\par } diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 855b2da..64a6dc9 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1101,6 +1101,16 @@ DECLARE_RTFIMPORT_TEST(testFdo59419, "fdo59419.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); } +DECLARE_RTFIMPORT_TEST(testHexCRLF, "hexcrlf.rtf") +{ + // hex-escaped \r and \n should create a paragraph break + getParagraph(1, "foo"); + getParagraph(2, "bar"); + getParagraph(3, "baz"); + getParagraph(4, ""); + getParagraph(5, "quux"); +} + DECLARE_RTFIMPORT_TEST(testFdo58076_2, "fdo58076-2.rtf") { // Position of the picture wasn't correct. diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index a42b528..ef5e086 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1120,7 +1120,19 @@ RTFError RTFDocumentImpl::resolveChars(char ch) if (m_aStates.top().nInternalState == RTFInternalState::HEX && m_aStates.top().eDestination != Destination::LEVELNUMBERS) { if (!bSkipped) - m_aHexBuffer.append(ch); + { + // note: apparently \'0d\'0a is interpreted as 2 breaks, not 1 + if (m_aStates.top().eDestination != Destination::DOCCOMM + && (ch == '\r' || ch == '\n')) + { + checkUnicode(/*bUnicode =*/ false, /*bHex =*/ true); + dispatchSymbol(RTF_PAR); + } + else + { + m_aHexBuffer.append(ch); + } + } return RTFError::OK; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits