diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-06 08:16:37 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-06 12:13:48 +0000 |
commit | 0f2d5db38bac64b665c6e4a127bbbd63a7ed9af5 (patch) | |
tree | cab1afbb409dfc73bf30d24ad087ba66e32c278b /writerfilter | |
parent | cb970f2d3d4241ce209b84518ac798598fd0dc39 (diff) |
tdf#44986 RTF import: handle \trwWidthA by faking cells
The DOCX import handles this at a tokenizer level, so let's do the same
in the RTF case as well.
Change-Id: Id7ff43fa9e9bcd05b13d187623d39fb072758057
Reviewed-on: https://gerrit.libreoffice.org/28679
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchsymbol.cxx | 10 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 |
4 files changed, 23 insertions, 1 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx index 218810b9ad3d..2a4154bd4df1 100644 --- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx +++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx @@ -229,6 +229,16 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) break; case RTF_ROW: { + if (m_aStates.top().nTableRowWidthAfter > 0) + { + // Add fake cellx / cell, RTF equivalent of + // OOXMLFastContextHandlerTextTableRow::handleGridAfter(). + auto pXValue = std::make_shared<RTFValue>(m_aStates.top().nTableRowWidthAfter); + m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, RTFOverwrite::NO_APPEND); + dispatchSymbol(RTF_CELL); + m_aStates.top().nTableRowWidthAfter = 0; + } + bool bRestored = false; // Ending a row, but no cells defined? // See if there was an invalid table row reset, so we can restore cell infos to help invalid documents. diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index 30621f9afeeb..0a77075a8f7c 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -1403,6 +1403,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_DIBITMAP: m_aStates.top().aPicture.eStyle = RTFBmpStyle::DIBITMAP; break; + case RTF_TRWWIDTHA: + m_aStates.top().nTableRowWidthAfter = nParam; + break; default: { SAL_INFO("writerfilter", "TODO handle value '" << keywordToString(nKeyword) << "'"); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index b01137383c5a..0dd4fc90990a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3057,6 +3057,11 @@ RTFError RTFDocumentImpl::popState() replayBuffer(m_aSuperBuffer, nullptr, nullptr); } + if (!m_aStates.empty() && m_aStates.top().nTableRowWidthAfter > 0 && aState.nTableRowWidthAfter == 0) + // An RTF_ROW in the inner group already parsed nTableRowWidthAfter, + // don't do it again in the outer state later. + m_aStates.top().nTableRowWidthAfter = 0; + return RTFError::OK; } @@ -3225,7 +3230,8 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl) bInShapeGroup(false), bInShape(false), bCreatedShapeGroup(false), - bStartedTrackchange(false) + bStartedTrackchange(false), + nTableRowWidthAfter(0) { } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 50fc2986a019..f2294aa7ae74 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -314,6 +314,9 @@ public: OUString aPropName; /// User-defined property: value type. css::uno::Type aPropType; + + /// Width of invisible cell at the end of the row. + int nTableRowWidthAfter; }; /// An RTF stack is similar to std::stack, except that it has an operator[]. |