diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-12-27 23:37:35 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-12-28 13:10:04 +0100 |
commit | c3b0f13546b30e5db3aecd311c7178e4e0933208 (patch) | |
tree | 23d7c8502d041b61b9131866d89ea35f649a84ef /writerfilter | |
parent | 45a85b5af82d130bb3eea2b6a168f4ceaff9975d (diff) |
fdo#45183 fix RTF import of tables with different row widths
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 13 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsprm.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsprm.hxx | 2 |
4 files changed, 23 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index b4e262e896f6..2344bfdd487a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -277,7 +277,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_bNeedSect(true), m_bWasInFrame(false), m_bHadPicture(false), - m_bHadSect(false) + m_bHadSect(false), + m_nCellxMax(0) { OSL_ASSERT(xInputStream.is()); m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True)); @@ -1620,7 +1621,11 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) if (bNeedPap) runProps(); if (!m_pCurrentBuffer) + { parBreak(); + // Not in table? Reset max width. + m_nCellxMax = 0; + } else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT) { RTFValue::Pointer_t pValue; @@ -1684,6 +1689,11 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) case RTF_ROW: case RTF_NESTROW: { + // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic the WW8 import: add a fake cell. + RTFValue::Pointer_t pLastCellx = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblGridBase_gridCol, false); + if (pLastCellx.get() && pLastCellx->getInt() < m_nCellxMax) + dispatchValue(RTF_CELLX, m_nCellxMax); + if (m_aStates.top().nCells) { // Make a backup before we start popping elements @@ -2946,6 +2956,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes; // We assume text after a row definition always belongs to the table, to handle text before the real INTBL token dispatchFlag(RTF_INTBL); + m_nCellxMax = std::max(m_nCellxMax, nParam); } break; case RTF_TRRH: diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 283faec9b531..d61efef493b7 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -592,6 +592,8 @@ namespace writerfilter { bool m_bHadPicture; /// The document has multiple sections. bool m_bHadSect; + /// Max width of the rows in the current table. + int m_nCellxMax; }; } // namespace rtftok } // namespace writerfilter diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index 2cbf6d620133..ed25dafe490f 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -98,12 +98,17 @@ std::string RTFSprm::toString() const return aBuf.makeStringAndClear().getStr(); } -RTFValue::Pointer_t RTFSprms::find(Id nKeyword) +RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst) { + RTFValue::Pointer_t pValue; for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i) if (i->first == nKeyword) - return i->second; - RTFValue::Pointer_t pValue; + { + if (bFirst) + return i->second; + else + pValue = i->second; + } return pValue; } diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx index 5f7a793cb28a..58955c4cd339 100644 --- a/writerfilter/source/rtftok/rtfsprm.hxx +++ b/writerfilter/source/rtftok/rtfsprm.hxx @@ -65,7 +65,7 @@ namespace writerfilter { RTFSprms(const RTFSprms& rSprms); ~RTFSprms(); RTFSprms& operator=(const RTFSprms& rOther); - RTFValue::Pointer_t find(Id nKeyword); + RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true); /// Does the same as ->push_back(), except that it can overwrite existing entries. void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true); bool erase(Id nKeyword); |