diff options
author | László Németh <nemeth@numbertext.org> | 2020-09-03 12:17:46 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-09-04 14:24:39 +0200 |
commit | 7dbd1cd44918c50f2540955f908cd0a96fce024c (patch) | |
tree | 199d8a778c69b9e5349d74b0e2604897f23aa2e4 /sw/inc/calc.hxx | |
parent | bcb415d56de44246eea8c9de45e7f9f91b9d6570 (diff) |
tdf#136404 DOCX import: ignore NaN cells in table formula
Ignore empty cells or cells with text content in data range
of AVERAGE, COUNT and PRODUCT (the new interoperability
functions in Writer), like MSO does, instead of using
NaN data as zeroes here.
Add AVERAGE, as a new function instead of alias of MEAN
to return error message instead of zero for NaN-only
arguments, like Calc does (Note: also MSO gives empty
result instead of zero).
Change-Id: I5e18f3e2b16cb0621dad2bba141ae63fb5edd241
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102012
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/inc/calc.hxx')
-rw-r--r-- | sw/inc/calc.hxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx index 99c024bcac35..b7bb83af26a8 100644 --- a/sw/inc/calc.hxx +++ b/sw/inc/calc.hxx @@ -98,6 +98,7 @@ extern const char sCalc_Abs[]; enum class SwCalcError { NONE=0, + NaN, // not a number (not an error, used for interoperability) Syntax, // syntax error DivByZero, // division by zero FaultyBrackets, // faulty brackets @@ -204,6 +205,7 @@ class SwCalc CharClass* m_pCharClass; sal_uInt16 m_nListPor; + bool m_bHasNumber; // fix COUNT() and AVERAGE(), if all cells are NaN SwCalcOper m_eCurrOper; SwCalcOper m_eCurrListOper; SwCalcError m_eError; @@ -240,7 +242,8 @@ public: CharClass* GetCharClass(); void SetCalcError( SwCalcError eErr ) { m_eError = eErr; } - bool IsCalcError() const { return SwCalcError::NONE != m_eError; } + bool IsCalcError() const { return SwCalcError::NONE != m_eError && SwCalcError::NaN != m_eError; } + bool IsCalcNotANumber() const { return SwCalcError::NaN == m_eError; } static bool Str2Double( const OUString& rStr, sal_Int32& rPos, double& rVal ); |