Kaydet (Commit) 29cbbad6 authored tarafından Miklos Vajna's avatar Miklos Vajna

DOCX import: fix rounding error in table cell widths

Change-Id: I733fd4b998ba4d0bde2f91f2b3d76205f0dc8020
üst 8b8b0dfa
......@@ -295,7 +295,7 @@ DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6137), getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
}
DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx")
......
......@@ -2391,6 +2391,12 @@ static OString dateTimeToString( const util::DateTime& dt )
return DateTimeToOString( DateTime( Date( dt.Day, dt.Month, dt.Year ), tools::Time( dt.Hours, dt.Minutes, dt.Seconds )));
}
DECLARE_OOXMLIMPORT_TEST(testTcwRounding, "tcw-rounding.docx")
{
// Width of the A1 cell in twips was 3200, due to a rounding error.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3201), parseDump("/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32());
}
DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
{
CPPUNIT_ASSERT_EQUAL( OUString( "TITLE" ), getRun( getParagraph( 1 ), 1 )->getString());
......
......@@ -34,6 +34,7 @@
#include <ooxml/resourceids.hxx>
#include <dmapperLoggers.hxx>
#include <dmapper/DomainMapper.hxx>
#include <rtl/math.hxx>
namespace writerfilter {
namespace dmapper {
......@@ -745,8 +746,7 @@ void DomainMapperTableManager::endOfRowAction()
for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount )
fGridWidth += (*pTableGrid.get())[nBorderGridIndex++];
sal_Int16 nRelPos =
sal::static_int_cast< sal_Int16 >((fGridWidth * 10000) / nFullWidthRelative);
sal_Int16 nRelPos = rtl::math::round((fGridWidth * 10000) / nFullWidthRelative);
pSeparators[nBorder].Position = nRelPos + nLastRelPos;
pSeparators[nBorder].IsVisible = sal_True;
......
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