From 71d8e5770a332c8ba26048b69dd172704fb703df Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 18 Mar 2014 18:57:05 +0100 Subject: workaround for rounding errors when handling merged cells (fdo#38414) Change-Id: I4d36e4b86c77a7356a8c221cbfc5735e925392ba Reviewed-on: https://gerrit.libreoffice.org/8648 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- sw/source/core/table/swnewtable.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index c41aedfbc288..34b9c38c2c26 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -200,10 +200,20 @@ static SwTableBox* lcl_LeftBorder2Box( long nLeft, const SwTableLine* pLine ) { SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox]; OSL_ENSURE( pBox, "Missing table box" ); - if( nCurrLeft >= nLeft && pBox->GetFrmFmt()->GetFrmSize().GetWidth() ) + if( pBox->GetFrmFmt()->GetFrmSize().GetWidth() ) { - OSL_ENSURE( nCurrLeft == nLeft, "Wrong box found" ); - return pBox; + if( nCurrLeft == nLeft ) + return pBox; + // HACK: It appears that rounding errors may result in positions not matching + // exactly, so allow a little tolerance. This happens at least with merged cells + // in the doc from fdo#38414 . + if( abs( nCurrLeft - nLeft ) <= ( nLeft / 1000 )) + return pBox; + if( nCurrLeft >= nLeft ) + { + SAL_WARN( "sw.core", "Possibly wrong box found" ); + return pBox; + } } nCurrLeft += pBox->GetFrmFmt()->GetFrmSize().GetWidth(); } -- cgit v1.2.3