summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-10 16:21:29 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-10-11 14:24:29 +0000
commita3cd122a8fbf5788d39491134c00e75149032783 (patch)
tree2e918d236dd4c6e8076468bd3799e2faecb244ec
parent9398fe153ae1a7a26d53424b98c2e8190f236890 (diff)
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. (cherry picked from commit e34906d20c9febc420b115fa2a8b171826dea0be) Change-Id: I0673408088d9d83768f0780ea92ece87913d03f3 Reviewed-on: https://gerrit.libreoffice.org/11914 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo84679.rtf12
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx9
3 files changed, 28 insertions, 4 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo84679.rtf b/sw/qa/extras/rtfimport/data/fdo84679.rtf
new file mode 100644
index 000000000000..64611be9878f
--- /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 12c6b521ff05..cc51a42184e4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1887,6 +1887,17 @@ DECLARE_RTFIMPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
}
+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 9f35f264e2d5..3fdc5ef275d0 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -445,7 +445,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())
{
@@ -1402,10 +1404,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);
}