summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorGuillaume Smaha <guillaume.smaha@gmail.com>2016-01-12 17:00:39 +0100
committerjan iversen <jani@documentfoundation.org>2016-01-15 07:34:29 +0000
commit6f2ce5c31708e5914d6d17d69b45f15a4429f8e3 (patch)
tree8886c07fd0976c071c2d9e2ac2427bd8ab2d5114 /writerfilter
parentb7612e44e1f8dae66a8e64e69079e26e5eaacef2 (diff)
Fix tdf#97035 - FILEOPEN: RTF wrong cell width
Change-Id: Ifd31ab1672261644a00a32f3a8632dd0dcb33825 Reviewed-on: https://gerrit.libreoffice.org/21382 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org> Tested-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx10
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx14
-rw-r--r--writerfilter/source/rtftok/rtfsprm.hxx2
3 files changed, 24 insertions, 2 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 938e92aa3cd0..9bd58a77a415 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2273,10 +2273,16 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
bRestored = true;
}
- // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic WW8TabDesc::CalcDefaults(): add a fake cell.
+ // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic WW8TabDesc::CalcDefaults(): resize the last cell
const int MINLAY = 23; // sw/inc/swtypes.hxx, minimal possible size of frames.
if ((m_nCellxMax - m_nTopLevelCurrentCellX) >= MINLAY)
- dispatchValue(RTF_CELLX, m_nCellxMax);
+ {
+ auto pXValueLast = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblGridBase_gridCol, false);
+ auto pXValue = std::make_shared<RTFValue>(pXValueLast->getInt() + m_nCellxMax - m_nTopLevelCurrentCellX);
+ m_aStates.top().aTableRowSprms.eraseLast(NS_ooxml::LN_CT_TblGridBase_gridCol);
+ m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, RTFOverwrite::NO_APPEND);
+ m_nTopLevelCurrentCellX = m_nCellxMax;
+ }
if (m_nTopLevelCells)
{
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 4e8768bf77e3..e19d27e7b0ec 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -124,6 +124,20 @@ bool RTFSprms::erase(Id nKeyword)
return false;
}
+bool RTFSprms::eraseLast(Id nKeyword)
+{
+ ensureCopyBeforeWrite();
+ for (RTFSprms::ReverseIterator_t i = m_pSprms->rbegin(); i != m_pSprms->rend(); ++i)
+ {
+ if (i->first == nKeyword)
+ {
+ m_pSprms->erase(std::next(i).base());
+ return true;
+ }
+ }
+ return false;
+}
+
static RTFValue::Pointer_t getDefaultSPRM(Id const id)
{
switch (id)
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index e05ef7834ac2..79b6b38a83e8 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -56,6 +56,7 @@ public:
typedef ::std::shared_ptr<RTFSprms> Pointer_t;
typedef std::pair<Id, RTFValue::Pointer_t> Entry_t;
typedef std::vector<Entry_t>::iterator Iterator_t;
+ typedef std::vector<Entry_t>::reverse_iterator ReverseIterator_t;
RTFSprms();
RTFSprms(const RTFSprms& rSprms);
~RTFSprms();
@@ -64,6 +65,7 @@ public:
/// Does the same as ->push_back(), except that it can overwrite or ignore existing entries.
void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = RTFOverwrite::YES);
bool erase(Id nKeyword);
+ bool eraseLast(Id nKeyword);
/// Removes elements which are already in the reference set.
/// Also insert default values to override attributes of style
/// (yes, really; that's what Word does).