diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-02-18 11:22:52 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-18 11:26:34 +0000 |
commit | 34de0b64b9184a85cd7fb65d0e811b435e90fe24 (patch) | |
tree | 6ccd949e711e266b2d99d364c5235aa66d13c32b /writerfilter | |
parent | 0d70adef01e50f2b1b27faa8f18294e72406b84d (diff) |
rhbz#1065629: RTF import: don't drop nested cells if not enough \cellx
In this document written by "XMLmind XSL-FO Converter" there are less
\cellx than \cell and thus when reading \nestrow/\row a whole buffered
nested table \cell is lost and then subsequently the rest of the nested
table too. Try to fix that by counting both \cell and \cellx and
replaying until the maximum of those.
Cannot count \intbl since we synthesize that in various places.
(regression in LO 3.5)
Change-Id: I3b64ad94af842e076611418589a0c83bd18841c6
(cherry picked from commit 07ef4cf096015f0e427ffd17cd26bb6837e75481)
Reviewed-on: https://gerrit.libreoffice.org/8100
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 7f3e25353665..ef7117e0dd10 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1867,6 +1867,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) RTFValue::Pointer_t pValue; m_aTableBuffer.push_back(make_pair(BUFFER_CELLEND, pValue)); m_bNeedPap = true; + m_aStates.top().nCellEnds++; } break; case RTF_ROW: @@ -1899,6 +1900,17 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) m_aStates.top().aTableCellsAttributes.pop_front(); replayBuffer(m_aTableBuffer); } + for (int i = 0; i < m_aStates.top().nCellEnds - m_aStates.top().nCells; ++i) + { + replayBuffer(m_aTableBuffer); + } + for (size_t i = 0; i < m_aTableBuffer.size(); ++i) + { + SAL_WARN_IF(BUFFER_CELLEND == m_aTableBuffer[i].first, + "writerfilter.rtf", "dropping table cell!"); + } + assert(0 == m_aStates.top().aTableCellsSprms.size()); + assert(0 == m_aStates.top().aTableCellsAttributes.size()); m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms; m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes; @@ -1951,6 +1963,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) m_bNeedFinalPar = true; m_aTableBuffer.clear(); m_aStates.top().nCells = 0; + m_aStates.top().nCellEnds = 0; m_aStates.top().aTableCellsSprms.clear(); m_aStates.top().aTableCellsAttributes.clear(); } @@ -4877,6 +4890,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl) nCellX(0), nCells(0), nInheritingCells(0), + nCellEnds(0), bIsCjk(false), nYear(0), nMonth(0), diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index eada5faf0092..e61b4153ef19 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -236,6 +236,7 @@ namespace writerfilter { int nCellX; int nCells; int nInheritingCells; + int nCellEnds; /// CJK or CTL? bool bIsCjk; |