Kaydet (Commit) d91236ad authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#115180: take table base width into account

Change-Id: I4238e6c757499e289193efa3498fb1e68d5f3e9c
Reviewed-on: https://gerrit.libreoffice.org/48501Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst da7c0245
......@@ -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: */
......@@ -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 );
......
......@@ -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)));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment