summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapperTableManager.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-01-14 12:56:54 +0100
committerLászló Németh <nemeth@numbertext.org>2020-01-15 22:26:32 +0100
commit62d084d50c0e6c90918f687251ffbb15264d7317 (patch)
tree73f7580bb61c2f7260f9d59fb420cf31305664a7 /writerfilter/source/dmapper/DomainMapperTableManager.cxx
parent32c8e953662fa2cdbcf2a43f7c217f75b5a808c8 (diff)
tdf#94801 DOCX import: fix table width loss by rounding
up the converted sum of table grid values. Small table width loss (< 1/100 mm) could result big layout differences, based on different line breaking etc. When table width is calculated by sum of table grid widths, now there is only a single conversion to 1/100 mm at the end, with rounding up the width instead of rounding down. Preventing regressions, both grid and cell width values are stored in the original twip now, instead of converting them to 1/100 mm one by one. Change-Id: I6f0755b6604f4976b8ecb25255c76fe6afd5e35b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86718 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableManager.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index b8fd339f0752..79a9a25f0ea0 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -256,7 +256,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
if (nIntValue == -1)
getCurrentGrid()->clear();
else
- getCurrentGrid()->push_back( ConversionHelper::convertTwipToMM100( nIntValue ) );
+ getCurrentGrid()->push_back( nIntValue );
}
break;
case NS_ooxml::LN_CT_TcPrBase_vMerge : //vertical merge
@@ -330,7 +330,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
if (sal::static_int_cast<Id>(pMeasureHandler->getUnit()) == NS_ooxml::LN_Value_ST_TblWidth_auto)
getCurrentCellWidths()->push_back(sal_Int32(-1));
else
- getCurrentCellWidths()->push_back(pMeasureHandler->getMeasureValue());
+ // store the original value to limit rounding mistakes, if it's there in a recognized measure (twip)
+ getCurrentCellWidths()->push_back(pMeasureHandler->getMeasureValue() ? pMeasureHandler->getValue() : sal_Int32(0));
if (getTableDepthDifference() > 0)
m_bPushCurrentWidth = true;
}
@@ -587,6 +588,9 @@ void DomainMapperTableManager::endOfRowAction()
m_nTableWidth = o3tl::saturating_add(m_nTableWidth, rCell);
}
+ if (m_nTableWidth)
+ // convert sum of grid twip values to 1/100 mm with rounding up to avoid table width loss
+ m_nTableWidth = static_cast<sal_Int32>(ceil(ConversionHelper::convertTwipToMM100Double(m_nTableWidth)));
if (m_nTableWidth > 0 && !m_bTableSizeTypeInserted)
{