[Libreoffice-commits] core.git: sw/qa sw/source

Mike Kaganski mike.kaganski at collabora.com
Thu Jan 25 11:57:55 UTC 2018


 sw/qa/extras/rtfexport/data/tdf115180.docx  |binary
 sw/qa/extras/rtfexport/rtfexport3.cxx       |   15 +++++++++++++++
 sw/source/filter/inc/wrtswtbl.hxx           |    1 +
 sw/source/filter/ww8/rtfattributeoutput.cxx |    4 +++-
 4 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit d91236ad8fc74e1ec15c39b90660717ebab013ac
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Jan 24 15:25:36 2018 +0300

    tdf#115180: take table base width into account
    
    Change-Id: I4238e6c757499e289193efa3498fb1e68d5f3e9c
    Reviewed-on: https://gerrit.libreoffice.org/48501
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

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
Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf115180.docx 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)));
     }
 }
 


More information about the Libreoffice-commits mailing list