sw/qa/extras/rtfimport/data/fdo84679.rtf | 12 ++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 11 +++++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 +++++---- 3 files changed, 28 insertions(+), 4 deletions(-)
New commits: commit e34906d20c9febc420b115fa2a8b171826dea0be Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 10 16:21:29 2014 +0200 fdo#84679 RTF import: fix paragraph spacing handling in tables Regression from commit 1be0a3fa9ebb22b607c54b47739d4467acfed259 (n#825305: writerfilter RTF import: override style properties like Word, 2014-06-17), we failed to do the proper deduplication in buffered content, like tables. Fix this by adapting RTFDocumentImpl::replayBuffer() to RTFDocumentImpl::checkNeedPap(), which already did the proper deduplication. To be fair, the inconsistency was there earlier since 9f5263c477b82fef5aa9c3e79fb6af92aa049e24 (fdo#44736 RTF import: ignore direct formatting which equals to style, 2012-11-25), but it caused no real harm earlier. Change-Id: I0673408088d9d83768f0780ea92ece87913d03f3 diff --git a/sw/qa/extras/rtfimport/data/fdo84679.rtf b/sw/qa/extras/rtfimport/data/fdo84679.rtf new file mode 100644 index 0000000..64611be --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo84679.rtf @@ -0,0 +1,12 @@ +{\rtf1 +{\stylesheet +{\ql \sa160\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 +\af31507\afs28\alang1054 \ltrch\fcs0 \fs22\lang1033\langfe2052\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp2052 \snext0 \sqformat \spriority0 Normal;} +} +\pard\plain\par +\trowd +\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10\cellx3121 +\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10\cellx6238 +A1\cell A2\cell \row +\pard\plain\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index a61d62f..57717b7 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1952,6 +1952,17 @@ DECLARE_RTFIMPORT_TEST(testFdo44984, "fdo44984.rtf") CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStartEnd"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1), "TextPortionType")); } +DECLARE_RTFIMPORT_TEST(testFdo84679, "fdo84679.rtf") +{ + // The problem was that the paragraph in A1 had some bottom margin, but it should not. + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + // This was 282. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin")); +} + 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 2fbf983..83084d3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -440,7 +440,9 @@ void RTFDocumentImpl::setNeedSect(bool bNeedSect) writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RTFSprms& rAttributes, RTFSprms& rSprms) { - int nStyle = m_aStates.top().nCurrentStyleIndex; + int nStyle = 0; + if (!m_aStates.empty()) + nStyle = m_aStates.top().nCurrentStyleIndex; RTFReferenceTable::Entries_t::iterator it = m_aStyleTableEntries.find(nStyle); if (it != m_aStyleTableEntries.end()) { @@ -1434,10 +1436,9 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, rBuffer.pop_front(); if (boost::get<0>(aTuple) == BUFFER_PROPS) { + // Construct properties via getProperties() and not directly, to take care of deduplication. writerfilter::Reference<Properties>::Pointer_t const pProp( - new RTFReferenceProperties( - boost::get<1>(aTuple)->getAttributes(), - boost::get<1>(aTuple)->getSprms()) + getProperties(boost::get<1>(aTuple)->getAttributes(), boost::get<1>(aTuple)->getSprms()) ); Mapper().props(pProp); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits