summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-06 08:16:37 +0200
committerCaolán McNamara <caolanm@redhat.com>2016-09-09 10:50:29 +0000
commit246df61b34e1ff5b5d7ecf7e46f04bb677548c9a (patch)
tree9356485c425f99c253e3d77de0097a18f9fb2a8b /writerfilter
parent08f79e4686b97b8dae4acf0a804b8bbd1c29dd34 (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. (cherry picked from commit 0f2d5db38bac64b665c6e4a127bbbd63a7ed9af5) Change-Id: Id7ff43fa9e9bcd05b13d187623d39fb072758057 Reviewed-on: https://gerrit.libreoffice.org/28748 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchsymbol.cxx10
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx8
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx3
4 files changed, 23 insertions, 1 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index e33d1408c787..2529492494d7 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 dfd9dff99d06..b6672901742c 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1402,6 +1402,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 93f120718685..53f3fc26ab33 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3054,6 +3054,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;
}
@@ -3222,7 +3227,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 1663b90550c6..32bbe4ab7b15 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -313,6 +313,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[].