29#include <rtl/character.hxx>
30#include <rtl/math.hxx>
35#include <compiler.hxx>
60 aStatement (r.aStatement),
197 : aRefFormulaCell ( r.aRefFormulaCell ),
198 aRefVariableCell( r.aRefVariableCell ),
199 pStrTargetVal ( r.pStrTargetVal )
205 const OUString& rTargetValStr )
206 : aRefFormulaCell ( rFormulaCell ),
207 aRefVariableCell( rVariableCell ),
208 pStrTargetVal ( rTargetValStr )
247 : aRefFormulaCell ( r.aRefFormulaCell ),
248 aRefFormulaEnd ( r.aRefFormulaEnd ),
249 aRefRowCell ( r.aRefRowCell ),
250 aRefColCell ( r.aRefColCell ),
260 : aRefFormulaCell ( rFormulaCell ),
261 aRefFormulaEnd ( rFormulaEnd ),
262 aRefRowCell ( rRowCell ),
263 aRefColCell ( rColCell ),
291 if (!pShell || !pShell->
HasName())
325 std::u16string_view rTabName )
327 OUString aDocTab(rFileName);
335bool isEmptyString(
const OUString& rStr )
339 else if (rStr[0] ==
' ')
342 const sal_Unicode*
const pStop =
p - 1 + rStr.getLength();
343 while (p < pStop && *p ==
' ')
360 if (nStringNoValueError == FormulaError::CellNoValue)
363 rError = nStringNoValueError;
370 rError = nStringNoValueError;
384 if (isEmptyString( rStr))
389 goto Label_fallback_to_unambiguous;
391 sal_uInt32 nFIndex = 0;
394 rError = nStringNoValueError;
401Label_fallback_to_unambiguous:
405 if (isEmptyString( rStr))
407 rError = nStringNoValueError;
416 rtl_math_ConversionStatus eStatus;
420 fValue = ::rtl::math::stringToDouble( rStr, 0, 0, &eStatus, &nParseEnd);
421 sal_Int32 nLen = rStr.getLength();
422 if (eStatus == rtl_math_ConversionStatus_Ok && nParseEnd < nLen)
432 while (
p < pStop && *
p ==
' ')
435 rError = nStringNoValueError;
440 bool bDate = (*(
p-1) ==
'-');
442 sal_Int32 nUnit[done] = {0,0,0,0,0,0,0};
443 const sal_Int32 nLimit[done] = {0,12,31,0,59,59,0};
445 rCurFmtType = (bDate ? SvNumFormatType::DATE : SvNumFormatType::TIME);
446 nUnit[eState-1] =
o3tl::toInt32(rStr.subView( 0, nParseEnd));
452 while (
p < pStop && *
p ==
' ')
454 if (
p < pStop && !rtl::isAsciiDigit(*
p))
455 rError = nStringNoValueError;
457 while (
p < pStop && rError == FormulaError::NONE && eState < blank)
459 if (eState == minute)
460 rCurFmtType |= SvNumFormatType::TIME;
461 if (rtl::isAsciiDigit(*
p))
464 if (
p - pLastStart >= 2 && eState != fraction)
465 rError = nStringNoValueError;
467 else if (
p > pLastStart)
472 nUnit[eState] =
o3tl::toInt32(rStr.subView( pLastStart - pStart,
p - pLastStart));
473 if (nLimit[eState] && nLimit[eState] < nUnit[eState])
474 rError = nStringNoValueError;
484 if (*
p !=
'-' || (
p+1 == pStop))
485 rError = nStringNoValueError;
488 if ((*
p !=
'T' || (
p+1 == pStop)) && *
p !=
' ')
489 rError = nStringNoValueError;
496 if (*
p !=
':' || (
p+1 == pStop))
497 rError = nStringNoValueError;
500 if ((*
p !=
':' || (
p+1 == pStop)) && *
p !=
' ')
501 rError = nStringNoValueError;
506 if (((*
p !=
',' && *
p !=
'.') || (
p+1 == pStop)) && *
p !=
' ')
507 rError = nStringNoValueError;
515 rError = nStringNoValueError;
518 eState =
static_cast<State>(eState + 1);
521 rError = nStringNoValueError;
526 while (
p < pStop && *
p ==
' ')
529 rError = nStringNoValueError;
534 if (eState ==
month || (eState ==
day &&
p <= pLastStart) ||
535 eState == hour || (eState == minute &&
p <= pLastStart))
536 rError = nStringNoValueError;
538 if (rError == FormulaError::NONE)
541 if (
p > pLastStart && eState < done)
543 nUnit[eState] =
o3tl::toInt32(rStr.subView( pLastStart - pStart,
p - pLastStart));
544 if (nLimit[eState] && nLimit[eState] < nUnit[eState])
545 rError = nStringNoValueError;
547 if (bDate && nUnit[hour] > 23)
548 rError = nStringNoValueError;
549 if (rError == FormulaError::NONE)
551 if (bDate && nUnit[
day] == 0)
553 double fFraction = (nUnit[fraction] <= 0 ? 0.0 :
554 ::rtl::math::pow10Exp( nUnit[fraction],
555 static_cast<int>( -ceil( log10(
static_cast<double>( nUnit[fraction]))))));
561 sal::static_int_cast<sal_Int16>(nUnit[
day]),
562 sal::static_int_cast<sal_Int16>(nUnit[
month]),
563 sal::static_int_cast<sal_Int16>(nUnit[
year]));
565 rError = nStringNoValueError;
572 SAL_WARN(
"sc.core",
"ScGlobal::ConvertStringToValue - fixed null date");
573 static Date aDefaultNullDate( 30, 12, 1899);
574 fValue = aDate - aDefaultNullDate;
578 fValue += ((nUnit[hour] * 3600) + (nUnit[minute] * 60) + nUnit[second] + fFraction) / 86400.0;
584 rError = nStringNoValueError;
586 if (rError != FormulaError::NONE)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
static SC_DLLPUBLIC OUString GetDocTabName(std::u16string_view rFileName, std::u16string_view rTabName)
static double ConvertStringToValue(const OUString &rStr, const ScCalcConfig &rConfig, FormulaError &rError, FormulaError nStringNoValueError, SvNumberFormatter *pFormatter, SvNumFormatType &rCurFmtType)
Convert string content to numeric value.
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
const INetURLObject & GetURLObject() const
SfxMedium * GetMedium() const
#define SC_COMPILER_FILE_TAB_SEP
#define SAL_WARN(area, stream)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
Configuration options for formula interpreter.
StringConversion meStringConversion
@ UNAMBIGUOUS
=1+"1" gives 2, but =1+"1.000" or =1+"x" give VALUE!
@ LOCALE
=1+"1.000" may be 2 or 1001 ... =1+"x" gives VALUE!
@ ILLEGAL
=1+"1" or =1+"x" give VALUE!
@ ZERO
=1+"1" or =1+"x" give 1
ScConsolidateParam & operator=(const ScConsolidateParam &r)
sal_uInt16 nDataAreaCount
bool operator==(const ScConsolidateParam &r) const
std::unique_ptr< ScArea[]> pDataAreas
void SetAreas(std::unique_ptr< ScArea[]> pAreas, sal_uInt16 nCount)
bool operator==(const ScImportParam &r) const
ScImportParam & operator=(const ScImportParam &r)
ScAddress aRefVariableCell
std::optional< OUString > pStrTargetVal
ScSolveParam & operator=(const ScSolveParam &r)
bool operator==(const ScSolveParam &r) const
ScAddress aRefFormulaCell
Parameter for data table aka multiple operations.
ScRefAddress aRefFormulaEnd
bool operator==(const ScTabOpParam &r) const
ScTabOpParam & operator=(const ScTabOpParam &r)
ScRefAddress aRefFormulaCell