29 #include <rtl/character.hxx>
30 #include <rtl/math.hxx>
35 #include <compiler.hxx>
60 aStatement (r.aStatement),
175 bEqual = bEqual && (pDataAreas !=
nullptr) && (r.
pDataAreas !=
nullptr);
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 = OUString::Concat(
"'") + rFileName;
329 while( (nPos = aDocTab.indexOf(
'\'', nPos )) != -1 )
331 aDocTab = aDocTab.replaceAt( nPos, 0,
u"\\" );
341 bool isEmptyString(
const OUString& rStr )
345 else if (rStr[0] ==
' ')
348 const sal_Unicode*
const pStop = p - 1 + rStr.getLength();
349 while (p < pStop && *p ==
' ')
366 if (nStringNoValueError == FormulaError::CellNoValue)
369 rError = nStringNoValueError;
376 rError = nStringNoValueError;
390 if (isEmptyString( rStr))
395 goto Label_fallback_to_unambiguous;
397 sal_uInt32 nFIndex = 0;
400 rError = nStringNoValueError;
407 Label_fallback_to_unambiguous:
411 if (isEmptyString( rStr))
413 rError = nStringNoValueError;
422 rtl_math_ConversionStatus eStatus;
426 fValue = ::rtl::math::stringToDouble( rStr, 0, 0, &eStatus, &nParseEnd);
427 sal_Int32 nLen = rStr.getLength();
428 if (eStatus == rtl_math_ConversionStatus_Ok && nParseEnd < nLen)
438 while (p < pStop && *p ==
' ')
441 rError = nStringNoValueError;
446 bool bDate = (*(p-1) ==
'-');
448 sal_Int32 nUnit[done] = {0,0,0,0,0,0,0};
449 const sal_Int32 nLimit[done] = {0,12,31,0,59,59,0};
451 rCurFmtType = (bDate ? SvNumFormatType::DATE : SvNumFormatType::TIME);
452 nUnit[eState-1] =
o3tl::toInt32(rStr.subView( 0, nParseEnd));
458 while (p < pStop && *p ==
' ')
460 if (p < pStop && !rtl::isAsciiDigit(*p))
461 rError = nStringNoValueError;
463 while (p < pStop && rError == FormulaError::NONE && eState < blank)
465 if (eState == minute)
466 rCurFmtType |= SvNumFormatType::TIME;
467 if (rtl::isAsciiDigit(*p))
470 if (p - pLastStart >= 2 && eState != fraction)
471 rError = nStringNoValueError;
473 else if (p > pLastStart)
478 nUnit[eState] =
o3tl::toInt32(rStr.subView( pLastStart - pStart, p - pLastStart));
479 if (nLimit[eState] && nLimit[eState] < nUnit[eState])
480 rError = nStringNoValueError;
490 if (*p !=
'-' || (p+1 == pStop))
491 rError = nStringNoValueError;
494 if ((*p !=
'T' || (p+1 == pStop)) && *p !=
' ')
495 rError = nStringNoValueError;
502 if (*p !=
':' || (p+1 == pStop))
503 rError = nStringNoValueError;
506 if ((*p !=
':' || (p+1 == pStop)) && *p !=
' ')
507 rError = nStringNoValueError;
512 if (((*p !=
',' && *p !=
'.') || (p+1 == pStop)) && *p !=
' ')
513 rError = nStringNoValueError;
521 rError = nStringNoValueError;
524 eState =
static_cast<State>(eState + 1);
527 rError = nStringNoValueError;
532 while (p < pStop && *p ==
' ')
535 rError = nStringNoValueError;
540 if (eState ==
month || (eState ==
day && p <= pLastStart) ||
541 eState == hour || (eState == minute && p <= pLastStart))
542 rError = nStringNoValueError;
544 if (rError == FormulaError::NONE)
547 if (p > pLastStart && eState < done)
549 nUnit[eState] =
o3tl::toInt32(rStr.subView( pLastStart - pStart, p - pLastStart));
550 if (nLimit[eState] && nLimit[eState] < nUnit[eState])
551 rError = nStringNoValueError;
553 if (bDate && nUnit[hour] > 23)
554 rError = nStringNoValueError;
555 if (rError == FormulaError::NONE)
557 if (bDate && nUnit[
day] == 0)
559 double fFraction = (nUnit[fraction] <= 0 ? 0.0 :
560 ::rtl::math::pow10Exp( nUnit[fraction],
561 static_cast<int>( -ceil( log10( static_cast<double>( nUnit[fraction]))))));
567 sal::static_int_cast<sal_Int16>(nUnit[
day]),
568 sal::static_int_cast<sal_Int16>(nUnit[
month]),
569 sal::static_int_cast<sal_Int16>(nUnit[
year]));
571 rError = nStringNoValueError;
578 SAL_WARN(
"sc.core",
"ScGlobal::ConvertStringToValue - fixed null date");
579 static Date aDefaultNullDate( 30, 12, 1899);
580 fValue = aDate - aDefaultNullDate;
584 fValue += ((nUnit[hour] * 3600) + (nUnit[minute] * 60) + nUnit[second] + fFraction) / 86400.0;
590 rError = nStringNoValueError;
592 if (rError != FormulaError::NONE)
bool operator==(const ScImportParam &r) const
=1+"1" gives 2, but =1+"1.000" or =1+"x" give VALUE!
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
void SetAreas(std::unique_ptr< ScArea[]> pAreas, sal_uInt16 nCount)
sal_uInt16 nDataAreaCount
static double ConvertStringToValue(const OUString &rStr, const ScCalcConfig &rConfig, FormulaError &rError, FormulaError nStringNoValueError, SvNumberFormatter *pFormatter, SvNumFormatType &rCurFmtType)
Convert string content to numeric value.
std::unique_ptr< ScArea[]> pDataAreas
bool operator==(const ScTabOpParam &r) const
ScImportParam & operator=(const ScImportParam &r)
StringConversion meStringConversion
bool operator==(const ScSolveParam &r) const
ScAddress aRefVariableCell
std::optional< OUString > pStrTargetVal
bool operator==(const ScConsolidateParam &r) const
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
Parameter for data table aka multiple operations.
=1+"1.000" may be 2 or 1001 ... =1+"x" gives VALUE!
ScRefAddress aRefFormulaCell
ScSolveParam & operator=(const ScSolveParam &r)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
ScTabOpParam & operator=(const ScTabOpParam &r)
Configuration options for formula interpreter.
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static SC_DLLPUBLIC OUString GetDocTabName(std::u16string_view rFileName, std::u16string_view rTabName)
const INetURLObject & GetURLObject() const
#define SC_COMPILER_FILE_TAB_SEP
ScAddress aRefFormulaCell
=1+"1" or =1+"x" give VALUE!
#define SAL_WARN(area, stream)
ScRefAddress aRefFormulaEnd
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
ScConsolidateParam & operator=(const ScConsolidateParam &r)
bool m_bDetectedRangeSegmentation false
SfxMedium * GetMedium() const