summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/compiler.hxx1
-rw-r--r--sc/source/core/tool/compiler.cxx37
2 files changed, 31 insertions, 7 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index b051f3ad4b4e..8ff420001d2b 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -344,6 +344,7 @@ private:
bool IsColRowName( const OUString& );
bool IsBoolean( const OUString& );
void AutoCorrectParsedSymbol();
+ const ScRangeData* GetRangeData( SCTAB& rSheet, const OUString& rUpperName ) const;
void AdjustSheetLocalNameRelReferences( SCTAB nDelta );
void SetRelNameReference();
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 274205f5734b..b2b008b13d55 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3093,7 +3093,24 @@ bool ScCompiler::IsValue( const OUString& rSym )
return false;
}
if (eStatus == rtl_math_ConversionStatus_OutOfRange)
+ {
+ // rtl::math::stringToDouble() recognizes XMLSchema-2 "INF" and
+ // "NaN" (case sensitive) that could be named expressions or DB
+ // areas as well.
+ // rSym is already upper so "NaN" is not possible here.
+ if (!std::isfinite(fVal) && rSym == "INF")
+ {
+ SCTAB nSheet = -1;
+ if (GetRangeData( nSheet, rSym))
+ return false;
+ if (rDoc.GetDBCollection()->getNamedDBs().findByUpperName(rSym))
+ return false;
+ }
+ /* TODO: is there a specific reason why we don't accept an infinity
+ * value that would raise an error in the interpreter, instead of
+ * setting the hard error at the token array already? */
SetError( FormulaError::IllegalArgument );
+ }
maRawToken.SetDouble( fVal );
return true;
}
@@ -3511,13 +3528,11 @@ bool ScCompiler::IsMacro( const OUString& rName )
#endif
}
-bool ScCompiler::IsNamedRange( const OUString& rUpperName )
+const ScRangeData* ScCompiler::GetRangeData( SCTAB& rSheet, const OUString& rUpperName ) const
{
- // IsNamedRange is called only from NextNewToken, with an upper-case string
-
// try local names first
- sal_Int16 nSheet = aPos.Tab();
- ScRangeName* pRangeName = rDoc.GetRangeName(nSheet);
+ rSheet = aPos.Tab();
+ const ScRangeName* pRangeName = rDoc.GetRangeName(rSheet);
const ScRangeData* pData = nullptr;
if (pRangeName)
pData = pRangeName->findByUpperName(rUpperName);
@@ -3527,9 +3542,17 @@ bool ScCompiler::IsNamedRange( const OUString& rUpperName )
if (pRangeName)
pData = pRangeName->findByUpperName(rUpperName);
if (pData)
- nSheet = -1;
+ rSheet = -1;
}
+ return pData;
+}
+
+bool ScCompiler::IsNamedRange( const OUString& rUpperName )
+{
+ // IsNamedRange is called only from NextNewToken, with an upper-case string
+ SCTAB nSheet = -1;
+ const ScRangeData* pData = GetRangeData( nSheet, rUpperName);
if (pData)
{
maRawToken.SetName( nSheet, pData->GetIndex());
@@ -3540,7 +3563,7 @@ bool ScCompiler::IsNamedRange( const OUString& rUpperName )
if (mnCurrentSheetEndPos > 0 && mnCurrentSheetTab >= 0)
{
OUString aName( rUpperName.copy( mnCurrentSheetEndPos));
- pRangeName = rDoc.GetRangeName( mnCurrentSheetTab);
+ const ScRangeName* pRangeName = rDoc.GetRangeName( mnCurrentSheetTab);
if (pRangeName)
{
pData = pRangeName->findByUpperName(aName);