Kaydet (Commit) cc94996d authored tarafından Markus Mohrhard's avatar Markus Mohrhard

autofill increment needs a bit more tolerance, fdo#37424

üst bc16be3e
...@@ -263,6 +263,19 @@ inline bool approxEqual(double a, double b) ...@@ -263,6 +263,19 @@ inline bool approxEqual(double a, double b)
< ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0))); < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
} }
/** Test equality of two values with an accuracy defined by nPrec
@attention
approxEqual( value!=0.0, 0.0 ) _never_ yields true.
*/
inline bool approxEqual(double a, double b, sal_Int16 nPrec)
{
if ( a == b )
return true;
double x = a - b;
return (x < 0.0 ? -x : x)
< ((a < 0.0 ? -a : a) * (1.0 / (pow(2, nPrec))));
}
/** Add two values. /** Add two values.
If signs differ and the absolute values are equal according to approxEqual() If signs differ and the absolute values are equal according to approxEqual()
......
...@@ -324,7 +324,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ...@@ -324,7 +324,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
{ {
nVal2 = ((ScValueCell*)pCell)->GetValue(); nVal2 = ((ScValueCell*)pCell)->GetValue();
double nDiff = nVal2 - nVal1; double nDiff = nVal2 - nVal1;
if ( !::rtl::math::approxEqual( nDiff, rInc ) ) if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
bVal = false; bVal = false;
nVal1 = nVal2; nVal1 = nVal2;
} }
...@@ -395,7 +395,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ...@@ -395,7 +395,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
if ( nFlag1 == nFlag2 ) if ( nFlag1 == nFlag2 )
{ {
double nDiff = (double)nVal2 - (double)nVal1; double nDiff = (double)nVal2 - (double)nVal1;
if ( !::rtl::math::approxEqual( nDiff, rInc ) ) if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
bVal = false; bVal = false;
nVal1 = nVal2; nVal1 = nVal2;
} }
......
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