diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-08 22:47:26 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-08 23:07:28 +0100 |
commit | f4bb73164a51ec83fe1d5975b1232d35f8a9e88a (patch) | |
tree | a54be078b24e8c3ee7739ecd3979856d880c851e | |
parent | 5fea6b760df32297f225b72c9e2c30d975e9142a (diff) |
fdo#84645 RTF import: set DontBalanceTextColumns=true for the last section ...
... if it has multiple columns. See commit
d185204737031955c56a24356ed003d342548434 (DOCX import: set
DontBalanceTextColumns=true for the last section, 2014-07-17) for the
DOCX equivalent of this problem; this just adapts the RTF tokenizer to
dmapper.
Change-Id: Ib30f9b386e204b8b2987832ab17ee0cc53b3f0bc
-rw-r--r-- | sw/qa/extras/rtfimport/data/unbalanced-columns.rtf | 5 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 6 |
3 files changed, 19 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/unbalanced-columns.rtf b/sw/qa/extras/rtfimport/data/unbalanced-columns.rtf new file mode 100644 index 000000000000..aa57e382dc33 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/unbalanced-columns.rtf @@ -0,0 +1,5 @@ +{\rtf1 +\cols2 +\pard\plain First paragraph.\par +Second paragraph.\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 46e0843fe9ba..54334b3c900a 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2068,6 +2068,14 @@ DECLARE_RTFIMPORT_TEST(testFdo82512, "fdo82512.rtf") CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType")); } +DECLARE_RTFIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.rtf") +{ + uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + // This was false, last section was balanced, but it's unbalanced in Word. + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns")); +} + 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 3c7b5d3c8464..66b9eb3904b1 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -611,6 +611,12 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false) writerfilter::Reference<Properties>::Pointer_t const pProperties( new RTFReferenceProperties(aAttributes, aSprms) ); + + if (bFinal && !m_pSuperstream) + // This is the end of the document, not just the end of e.g. a header. + // This makes sure that dmapper can set DontBalanceTextColumns=true for this section if necessary. + Mapper().markLastSectionGroup(); + // The trick is that we send properties of the previous section right now, which will be exactly what dmapper expects. Mapper().props(pProperties); Mapper().endParagraphGroup(); |