summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-01-24 15:25:36 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-01-25 12:57:32 +0100
commitd91236ad8fc74e1ec15c39b90660717ebab013ac (patch)
tree953d4e1729b6ba729e6e91bf62378934ae0a7d67
parentda7c0245bf0fd6cca7a589f7cf7e0b39412aa577 (diff)
tdf#115180: take table base width into account
Change-Id: I4238e6c757499e289193efa3498fb1e68d5f3e9c Reviewed-on: https://gerrit.libreoffice.org/48501 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/rtfexport/data/tdf115180.docxbin0 -> 10151 bytes
-rw-r--r--sw/qa/extras/rtfexport/rtfexport3.cxx15
-rw-r--r--sw/source/filter/inc/wrtswtbl.hxx1
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx4
4 files changed, 19 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf115180.docx b/sw/qa/extras/rtfexport/data/tdf115180.docx
new file mode 100644
index 000000000000..2e41c7a24a1d
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf115180.docx
Binary files differ
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index c8941ed26633..870650ab9b88 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -80,6 +80,21 @@ DECLARE_RTFEXPORT_TEST(testTdf114333, "tdf114333.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(8498), getProperty<sal_Int32>(xTable, "Width"));
}
+DECLARE_RTFEXPORT_TEST(testTdf115180, "tdf115180.docx")
+{
+ // On export to RTF, column separator positions were written without taking base width
+ // into account and then arrived huge, ~64000, which resulted in wrong table and cell widths
+
+ sal_Int32 rowWidth = parseDump("/root/page/body/tab/row/infos/bounds", "width").toInt32();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Row width", sal_Int32(9360), rowWidth);
+ sal_Int32 cell1Width
+ = parseDump("/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("First cell width", sal_Int32(9142), cell1Width);
+ sal_Int32 cell2Width
+ = parseDump("/root/page/body/tab/row/cell[2]/infos/bounds", "width").toInt32();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("First cell width", sal_Int32(218), cell2Width);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx
index ee1cbd771537..20b9554c582a 100644
--- a/sw/source/filter/inc/wrtswtbl.hxx
+++ b/sw/source/filter/inc/wrtswtbl.hxx
@@ -286,6 +286,7 @@ public:
long GetAbsHeight(long nRawWidth, size_t nRow, sal_uInt16 nRowSpan) const;
+ double GetAbsWidthRatio() const { return m_nTabWidth == m_nBaseWidth ? 1.0 : double(m_nTabWidth) / m_nBaseWidth; }
protected:
long GetLineHeight( const SwTableLine *pLine );
static long GetLineHeight( const SwTableBox *pBox );
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 770ae936c824..8e15fe6c9aed 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -721,6 +721,7 @@ void RtfAttributeOutput::TableDefinition(
}
// The cell-dependent properties
+ const double fWidthRatio = m_pTableWrt->GetAbsWidthRatio();
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
SwTwips nSz = 0;
@@ -740,7 +741,8 @@ void RtfAttributeOutput::TableDefinition(
// value of nSz is needed.
nSz += pCellFormat->GetFrameSize().GetWidth();
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX);
- m_aRowDefs.append(static_cast<sal_Int32>(pFormat->GetLRSpace().GetLeft() + nSz));
+ m_aRowDefs.append(static_cast<sal_Int32>(pFormat->GetLRSpace().GetLeft()
+ + rtl::math::round(nSz * fWidthRatio)));
}
}