diff options
author | László Németh <nemeth@numbertext.org> | 2018-12-30 02:15:30 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-01-02 12:07:05 +0100 |
commit | c395e72aa330632428b194da96743aad20821676 (patch) | |
tree | 844a57a6d328b376b0927d2af5a1146a9bbd728d /writerfilter | |
parent | de2fca657c3cf31e1f9e21bbd50b887f7cca9216 (diff) |
tdf#121623 RTF import: keep table in multicolumn section
instead of losing columns when the section starts with that table.
Change-Id: I1c9d4eb03d24e54600956cb41b835c5e37bfdd8b
Reviewed-on: https://gerrit.libreoffice.org/65730
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 92863700cddb70b07e4722551b1f1db78c2474d3)
Reviewed-on: https://gerrit.libreoffice.org/65747
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtflookahead.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtflookahead.hxx | 2 |
4 files changed, 23 insertions, 3 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 0dd4b04d59a2..16b4b7cff5cd 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -43,6 +43,7 @@ #include "rtfreferenceproperties.hxx" #include "rtfskipdestination.hxx" #include "rtftokenizer.hxx" +#include "rtflookahead.hxx" using namespace com::sun::star; @@ -257,6 +258,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x , m_aDefaultState(this) , m_bSkipUnknown(false) , m_bFirstRun(true) + , m_bFirstRunException(false) , m_bNeedPap(true) , m_bNeedCr(false) , m_bNeedCrOrig(false) @@ -376,7 +378,7 @@ void RTFDocumentImpl::checkFirstRun() outputSettingsTable(); // start initial paragraph m_bFirstRun = false; - assert(!m_bNeedSect); + assert(!m_bNeedSect || m_bFirstRunException); setNeedSect(true); // first call that succeeds // set the requested default font, if there are none @@ -396,8 +398,18 @@ void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; } void RTFDocumentImpl::setNeedSect(bool bNeedSect) { + if (!m_bNeedSect && bNeedSect && m_bFirstRun) + { + RTFLookahead aLookahead(Strm(), m_pTokenizer->getGroupStart()); + if (aLookahead.hasTable() && aLookahead.hasColumns()) + { + m_bFirstRunException = true; + } + } + // ignore setting before checkFirstRun - every keyword calls setNeedSect! - if (!m_bNeedSect && bNeedSect && !m_bFirstRun) + // except the case of a table in a multicolumn section + if (!m_bNeedSect && bNeedSect && (!m_bFirstRun || m_bFirstRunException)) { if (!m_pSuperstream) // no sections in header/footer! { diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 1f45e9f99eec..6fe21351c5c8 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -570,7 +570,10 @@ private: std::map<int, Id> m_aStyleTypes; /// Color index <-> RGB color value map std::vector<Color> m_aColorTable; + /// to start initial paragraph / section after font/style tables bool m_bFirstRun; + /// except in the case of tables in initial multicolumn section (global for assertion) + bool m_bFirstRunException; /// If paragraph properties should be emitted on next run. bool m_bNeedPap; /// If we need to emit a CR at the end of substream. diff --git a/writerfilter/source/rtftok/rtflookahead.cxx b/writerfilter/source/rtftok/rtflookahead.cxx index 16ac509e0cde..d60057d52bb1 100644 --- a/writerfilter/source/rtftok/rtflookahead.cxx +++ b/writerfilter/source/rtftok/rtflookahead.cxx @@ -35,6 +35,7 @@ namespace rtftok RTFLookahead::RTFLookahead(SvStream& rStream, sal_uInt64 nGroupStart) : m_rStream(rStream) , m_bHasTable(false) + , m_bHasColumns(false) { sal_uInt64 const nPos = m_rStream.Tell(); m_rStream.Seek(nGroupStart); @@ -62,8 +63,10 @@ RTFError RTFLookahead::dispatchToggle(RTFKeyword /*nKeyword*/, bool /*bParam*/, return RTFError::OK; } -RTFError RTFLookahead::dispatchValue(RTFKeyword /*nKeyword*/, int /*nParam*/) +RTFError RTFLookahead::dispatchValue(RTFKeyword nKeyword, int nParam) { + if (nKeyword == RTF_COLS && nParam >= 2) + m_bHasColumns = true; return RTFError::OK; } diff --git a/writerfilter/source/rtftok/rtflookahead.hxx b/writerfilter/source/rtftok/rtflookahead.hxx index a5779fcc9dea..0a40d554c5e8 100644 --- a/writerfilter/source/rtftok/rtflookahead.hxx +++ b/writerfilter/source/rtftok/rtflookahead.hxx @@ -48,11 +48,13 @@ public: void finishSubstream() override; bool isSubstream() const override; bool hasTable() { return m_bHasTable; } + bool hasColumns() { return m_bHasColumns; } private: tools::SvRef<RTFTokenizer> m_pTokenizer; SvStream& m_rStream; bool m_bHasTable; + bool m_bHasColumns; }; } // namespace rtftok } // namespace writerfilter |