summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-12-27 23:37:35 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-12-28 13:43:45 +0100
commit1d7287f8d7984eae98a577f60a8bc0a740fc5e9e (patch)
tree3c3c4fb09e6e7a9efad4bc1c8e4a987715613b98 /writerfilter/source
parentd7223549a5ee1b7900b6db33c116ababd8db63e8 (diff)
fdo#45183 fix RTF import of tables with different row widths
(cherry picked from commit c3b0f13546b30e5db3aecd311c7178e4e0933208)
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx13
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfsprm.hxx2
4 files changed, 23 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 0de85f61bb45..378e9f57067c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -276,7 +276,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));
@@ -1619,7 +1620,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;
@@ -1683,6 +1688,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
@@ -2945,6 +2955,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);