Related: tdf#160056 do calc NumberFormatting via ScInterpreterContext
and for the duration of Threaded calculation where there will be
no new formats required we can drive number formatting with the
unlocked RO policy.
Change-Id: Ic0e449acdcf834bc569d13b4a984f13c55316801
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165160
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 7fb072e..a4a985e 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -23,10 +23,10 @@
#include <rtl/ustring.hxx>
#include <svl/sharedstring.hxx>
class SvNumberFormatter;
class Color;
class ScDocument;
class ScAddress;
class ScDocument;
struct ScInterpreterContext;
struct ScRefCellValue;
class SC_DLLPUBLIC ScCellFormat
@@ -35,25 +35,25 @@ public:
static OUString GetString(
const ScRefCellValue& rCell, sal_uInt32 nFormat,
const Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument& rDoc, bool bNullVals = true,
const Color** ppColor, ScInterpreterContext* pContext, const ScDocument& rDoc, bool bNullVals = true,
bool bFormula = false, bool bUseStarFormat = false );
static OUString GetString(
ScDocument& rDoc, const ScAddress& rPos, sal_uInt32 nFormat,
const Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
const Color** ppColor, ScInterpreterContext* pContext, bool bNullVals = true,
bool bFormula = false );
// Note that if pShared is set and a value is returned that way, the returned OUString is empty.
static OUString GetInputString(
const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter,
const ScRefCellValue& rCell, sal_uInt32 nFormat, ScInterpreterContext* pContext,
const ScDocument& rDoc, const svl::SharedString** pShared = nullptr, bool bFiltering = false,
bool bForceSystemLocale = false );
static OUString GetInputString(
const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter,
const ScRefCellValue& rCell, sal_uInt32 nFormat, ScInterpreterContext* pContext,
const ScDocument& rDoc, bool bFiltering, bool bForceSystemLocale = false )
{
return GetInputString( rCell, nFormat, rFormatter, rDoc, nullptr, bFiltering, bForceSystemLocale );
return GetInputString( rCell, nFormat, pContext, rDoc, nullptr, bFiltering, bForceSystemLocale );
}
static OUString GetOutputString(
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 0aa812f..bee7688 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -446,10 +446,10 @@ public:
void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
void SetError( SCROW nRow, const FormulaError nError);
OUString GetString( SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const
OUString GetString( SCROW nRow, ScInterpreterContext* pContext = nullptr ) const
{ return GetString( GetCellValue( nRow ), nRow, pContext ); }
OUString GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
const ScInterpreterContext* pContext = nullptr ) const
ScInterpreterContext* pContext = nullptr ) const
{ return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); }
double* GetValueCell( SCROW nRow );
// Note that if pShared is set and a value is returned that way, the returned OUString is empty.
@@ -831,7 +831,7 @@ private:
sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
OUString GetString( const ScRefCellValue& cell, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const;
OUString GetString( const ScRefCellValue& cell, SCROW nRow, ScInterpreterContext* pContext = nullptr ) const;
OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, bool bForceSystemLocale = false ) const;
/**
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index df2ad5e..af37910 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -274,8 +274,7 @@ private:
ScDocument& rDoc;
ScAddress aPos;
SvNumberFormatter* mpFormatter;
const ScInterpreterContext* mpInterpreterContext;
ScInterpreterContext& mrInterpreterContext;
SCTAB mnCurrentSheetTab; // indicates current sheet number parsed so far
sal_Int32 mnCurrentSheetEndPos; // position after current sheet name if parsed
@@ -384,22 +383,22 @@ public:
public:
ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr );
bool bComputeII = false, bool bMatrixFlag = false, ScInterpreterContext* pContext = nullptr );
/** If eGrammar == GRAM_UNSPECIFIED then the grammar of rDocument is used,
*/
SC_DLLPUBLIC ScCompiler( ScDocument& rDocument, const ScAddress&,
formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED,
bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr );
bool bComputeII = false, bool bMatrixFlag = false, ScInterpreterContext* pContext = nullptr );
SC_DLLPUBLIC ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr,
bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr );
bool bComputeII = false, bool bMatrixFlag = false, ScInterpreterContext* pContext = nullptr );
/** If eGrammar == GRAM_UNSPECIFIED then the grammar of rDocument is used,
*/
SC_DLLPUBLIC ScCompiler( ScDocument& rDocument, const ScAddress&, ScTokenArray& rArr,
formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED,
bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr );
bool bComputeII = false, bool bMatrixFlag = false, ScInterpreterContext* pContext = nullptr );
SC_DLLPUBLIC virtual ~ScCompiler() override;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ba507ff..593f3f4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1203,9 +1203,9 @@ public:
SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
const ScInterpreterContext* pContext = nullptr ) const;
ScInterpreterContext* pContext = nullptr ) const;
SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
const ScInterpreterContext* pContext = nullptr ) const;
ScInterpreterContext* pContext = nullptr ) const;
/**
* Return a pointer to the double value stored in value cell.
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 7db605b..ada1d7c 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -37,6 +37,7 @@ struct ScQueryParam;
class ScDPObject;
class ScDocument;
class SvNumberFormatter;
struct ScInterpreterContext;
enum class SvNumFormatType : sal_Int16;
@@ -138,11 +139,11 @@ public:
SCROW GetIdByItemData(tools::Long nDim, const ScDPItemData& rItem) const;
static sal_uInt32 GetLocaleIndependentFormat( SvNumberFormatter& rFormatter, sal_uInt32 nNumFormat );
static sal_uInt32 GetLocaleIndependentFormat( ScInterpreterContext& rContext, sal_uInt32 nNumFormat );
static OUString GetLocaleIndependentFormattedNumberString( double fValue );
static OUString GetLocaleIndependentFormattedString( double fValue, SvNumberFormatter& rFormatter, sal_uInt32 nNumFormat );
static OUString GetLocaleIndependentFormattedString( double fValue, ScInterpreterContext& rContext, sal_uInt32 nNumFormat );
SC_DLLPUBLIC OUString GetFormattedString(tools::Long nDim, const ScDPItemData& rItem, bool bLocaleIndependent) const;
SvNumberFormatter* GetNumberFormatter() const;
ScInterpreterContext& GetInterpreterContext() const;
tools::Long AppendGroupField();
void ResetGroupItems(tools::Long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType);
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 28a3ff9..c11fcea 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -229,8 +229,8 @@ public:
size_t GetHash() const;
SC_DLLPUBLIC OUString GetFormula( const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
const ScInterpreterContext* pContext = nullptr ) const;
SC_DLLPUBLIC OUString GetFormula( sc::CompileFormulaContext& rCxt, const ScInterpreterContext* pContext = nullptr ) const;
ScInterpreterContext* pContext = nullptr ) const;
SC_DLLPUBLIC OUString GetFormula( sc::CompileFormulaContext& rCxt, ScInterpreterContext* pContext = nullptr ) const;
SC_DLLPUBLIC void SetDirty( bool bDirtyFlag=true );
void SetDirtyVar();
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 535c919..5cb782a 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -482,6 +482,7 @@ class SfxItemPool;
class EditTextObject;
class SfxObjectShell;
class SvNumberFormatter;
struct ScInterpreterContext;
class ScUnitConverter;
class CharClass;
class LocaleDataWrapper;
@@ -583,7 +584,7 @@ public:
const SfxObjectShell* pShell );
SC_DLLPUBLIC static OUString GetDocTabName( std::u16string_view rFileName,
std::u16string_view rTabName );
SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, SvNumFormatType nType );
SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( ScInterpreterContext&, sal_uInt32 nFormat, SvNumFormatType nType );
SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
/// Horizontal pixel per twips factor.
@@ -823,7 +824,7 @@ public:
*/
static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
FormulaError & rError, FormulaError nStringNoValueError,
SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType );
ScInterpreterContext& rContext, SvNumFormatType & rCurFmtType );
/// Calc's threaded group calculation is in progress.
SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress;
diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index 1fd037a..2f89249 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -9,11 +9,12 @@
#pragma once
#include <array>
#include <memory>
#include <random>
#include <vector>
#include <i18nlangtag/lang.h>
#include <o3tl/sorted_vector.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <svl/numformat.hxx>
#include "types.hxx"
namespace formula
@@ -23,11 +24,10 @@ class FormulaToken;
#define TOKEN_CACHE_SIZE 8
class Color;
class ScDocument;
class SvNumberFormatter;
struct ScLookupCacheMap;
class ScInterpreter;
enum class SvNumFormatType : sal_Int16;
// SetNumberFormat() is not thread-safe, so calls to it need to be delayed to the main thread.
struct DelayedSetNumberFormat
@@ -65,9 +65,52 @@ struct ScInterpreterContext
return mpFormatter;
}
SvNumFormatType GetNumberFormatType(sal_uInt32 nFIndex) const;
SvNumFormatType NFGetType(sal_uInt32 nFIndex) const;
const SvNumberformat* NFGetFormatEntry(sal_uInt32 nKey) const;
sal_uInt32 NFGetFormatIndex(NfIndexTableOffset, LanguageType eLnge = LANGUAGE_DONTKNOW) const;
bool NFIsTextFormat(sal_uInt32 nFIndex) const;
sal_uInt32 NFGetTimeFormat(double fNumber, LanguageType eLnge, bool bForceDuration) const;
const Date& NFGetNullDate() const;
OUString NFGetFormatDecimalSep(sal_uInt32 nFormat) const;
sal_uInt16 NFGetFormatPrecision(sal_uInt32 nFormat) const;
sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge) const;
sal_uInt32 NFGetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge) const;
bool NFIsNumberFormat(const OUString& sString, sal_uInt32& F_Index, double& fOutNumber,
SvNumInputOptions eInputOptions = SvNumInputOptions::NONE);
void NFGetInputLineString(const double& fOutNumber, sal_uInt32 nFIndex, OUString& rOutString,
bool bFiltering = false, bool bForceSystemLocale = false) const;
void NFGetOutputString(const double& fOutNumber, sal_uInt32 nFIndex, OUString& sOutString,
const Color** ppColor, bool bUseStarFormat = false) const;
void NFGetOutputString(const OUString& sString, sal_uInt32 nFIndex, OUString& sOutString,
const Color** ppColor, bool bUseStarFormat = false) const;
sal_uInt32 NFGetStandardFormat(SvNumFormatType eType, LanguageType eLnge = LANGUAGE_DONTKNOW);
sal_uInt32 NFGetStandardFormat(sal_uInt32 nFIndex, SvNumFormatType eType, LanguageType eLnge);
sal_uInt32 NFGetStandardFormat(double fNumber, sal_uInt32 nFIndex, SvNumFormatType eType,
LanguageType eLnge);
bool NFGetPreviewString(const OUString& sFormatString, double fPreviewNumber,
OUString& sOutString, const Color** ppColor, LanguageType eLnge);
bool NFGetPreviewString(const OUString& sFormatString, const OUString& sPreviewString,
OUString& sOutString, const Color** ppColor,
LanguageType eLnge = LANGUAGE_DONTKNOW);
bool NFGetPreviewStringGuess(const OUString& sFormatString, double fPreviewNumber,
OUString& sOutString, const Color** ppColor,
LanguageType eLnge = LANGUAGE_DONTKNOW);
sal_uInt32 NFGetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW) const;
OUString NFGenerateFormat(sal_uInt32 nIndex, LanguageType eLnge = LANGUAGE_DONTKNOW,
bool bThousand = false, bool IsRed = false, sal_uInt16 nPrecision = 0,
sal_uInt16 nLeadingCnt = 1);
sal_uInt16 NFExpandTwoDigitYear(sal_uInt16 nYear) const;
OUString NFGetCalcCellReturn(sal_uInt32 nFormat) const;
private:
friend class ScInterpreterContextPool;
@@ -76,28 +119,44 @@ private:
void Cleanup();
void ClearLookupCache(const ScDocument* pDoc);
void initFormatTable();
SvNumberFormatter* mpFormatter;
template <typename T> struct CompareKey
{
bool operator()(const T& lhs, const T& rhs) const { return lhs.nKey < rhs.nKey; }
};
// During threaded calculation, where we don't need to add to the number
// format data, we can access the numbering data with a RO unlocked view of
// the NumberFormat's data and a throw-away object for currently used language
// This is essentially an exploded view of mpFormatter
std::unique_ptr<SvNFLanguageData> mxLanguageData;
const SvNFFormatData* mpFormatData;
SvNFEngine::Accessor maROPolicy;
struct NFType
{
sal_uInt32 nKey;
mutable SvNumFormatType eType;
};
// map from format index to type
mutable o3tl::sorted_vector<NFType, CompareKey<NFType>> maNFTypeCache;
// Some temp caches of the 4 most recent results from NumberFormatting
// lookups.
struct NFBuiltIn
{
sal_uInt64 nKey;
mutable sal_uInt32 nFormat;
sal_uInt32 nFormat;
NFBuiltIn()
: nKey(SAL_MAX_UINT64)
, nFormat(SAL_MAX_UINT32)
{
}
};
// map from format+lang to builtin format
mutable o3tl::sorted_vector<NFBuiltIn, CompareKey<NFBuiltIn>> maNFBuiltInCache;
// from format+lang to builtin format
mutable std::array<NFBuiltIn, 4> maNFBuiltInCache;
struct NFType
{
sal_uInt32 nKey;
SvNumFormatType eType;
NFType()
: nKey(SAL_MAX_UINT32)
, eType(SvNumFormatType::ALL)
{
}
};
// from format index to type
mutable std::array<NFType, 4> maNFTypeCache;
// Formatter used when non-nthreaded calculation
SvNumberFormatter* mpFormatter;
};
class ScThreadedInterpreterContextGetterGuard;
@@ -148,6 +207,8 @@ class ScInterpreterContextPool
public:
// Only to be used to clear lookup cache in all pool elements
static void ClearLookupCaches(const ScDocument* pDoc);
// Called from ScModule dtor, drop all resources
static void ModuleExiting();
};
class ScThreadedInterpreterContextGetterGuard
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index bbb55b5..7294ff1 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -241,6 +241,8 @@ public:
sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext ) const;
sal_uInt32 GetNumberFormat( SvNumberFormatter* pFormatter,
const SfxItemSet* pCondSet ) const;
sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext,
const SfxItemSet* pCondSet ) const;
Degree100 GetRotateVal( const SfxItemSet* pCondSet ) const;
ScRotateDir GetRotateDir( const SfxItemSet* pCondSet ) const;
diff --git a/sc/inc/queryevaluator.hxx b/sc/inc/queryevaluator.hxx
index f572408..351531b 100644
--- a/sc/inc/queryevaluator.hxx
+++ b/sc/inc/queryevaluator.hxx
@@ -56,7 +56,7 @@ class ScQueryEvaluator
CollatorWrapper* mpCollator;
const bool mbMatchWholeCell;
const bool mbCaseSensitive;
const ScInterpreterContext* mpContext;
ScInterpreterContext* mpContext;
const SCSIZE mnEntryCount;
bool* mpPasst;
@@ -108,8 +108,7 @@ class ScQueryEvaluator
public:
ScQueryEvaluator(ScDocument& rDoc, const ScTable& rTab, const ScQueryParam& rParam,
const ScInterpreterContext* pContext = nullptr,
bool* pTestEqualCondition = nullptr);
ScInterpreterContext* pContext = nullptr, bool* pTestEqualCondition = nullptr);
bool ValidQuery(SCROW nRow, const ScRefCellValue* pCell = nullptr,
sc::TableColumnBlockPositionSet* pBlockPos = nullptr);
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index e80cb86..dc38638 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -27,7 +27,7 @@
#include <vector>
#include <ostream>
class SvNumberFormatter;
struct ScInterpreterContext;
struct ScDBQueryParamInternal;
struct ScQueryEntry;
@@ -62,7 +62,7 @@ struct SAL_DLLPUBLIC_RTTI ScQueryParamBase
SC_DLLPUBLIC void RemoveAllEntriesByField(SCCOLROW nField);
void Resize(size_t nNew);
void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex,
SvNumberFormatter* pFormatter );
ScInterpreterContext* pContext );
protected:
typedef std::vector<ScQueryEntry> EntriesType;
diff --git a/sc/inc/rangeseq.hxx b/sc/inc/rangeseq.hxx
index 9f424d0..1657811 100644
--- a/sc/inc/rangeseq.hxx
+++ b/sc/inc/rangeseq.hxx
@@ -24,7 +24,7 @@
namespace com::sun::star::uno { class Any; }
class SvNumberFormatter;
struct ScInterpreterContext;
class ScDocument;
class ScMatrix;
class ScRange;
@@ -43,7 +43,7 @@ public:
static bool FillStringArray( css::uno::Any& rAny,
ScDocument& rDoc, const ScRange& rRange );
static bool FillStringArray( css::uno::Any& rAny,
const ScMatrix* pMatrix, SvNumberFormatter* pFormatter );
const ScMatrix* pMatrix, ScInterpreterContext& rContext );
static bool FillMixedArray( css::uno::Any& rAny,
ScDocument& rDoc, const ScRange& rRange,
bool bAllowNV = false );
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 1f36779..1594ca3 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -34,7 +34,7 @@
#define DEBUG_MATRIX 0
class ScInterpreter;
class SvNumberFormatter;
struct ScInterpreterContext;
class ScMatrixImpl;
enum class FormulaError : sal_uInt16;
@@ -314,7 +314,7 @@ public:
numerical value formatted as string, or in case of an error the error
string is returned; an empty string for empty, a "FALSE" string for
empty path. */
svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const ;
svl::SharedString GetString( ScInterpreterContext& rContext, SCSIZE nC, SCSIZE nR) const ;
/// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate
/// an empty string!
@@ -411,7 +411,7 @@ public:
EmptyOpFunction aEmptyFunc) const ;
void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2,
SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool) ;
ScInterpreterContext& rContext, svl::SharedStringPool& rPool) ;
/** Apply binary operation to values from two input matrices, storing result into this matrix. */
void ExecuteBinaryOp(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrix& rInputMat1, const ScMatrix& rInputMat2,
diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index 3d930dd..98159f0 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -128,6 +128,8 @@ struct ScInputStringType
SvNumFormatType mnFormatType;
};
struct ScInterpreterContext;
class ScStringUtil
{
public:
@@ -159,7 +161,7 @@ public:
static bool SC_DLLPUBLIC isMultiline( std::u16string_view rStr );
static ScInputStringType parseInputString(
SvNumberFormatter& rFormatter, const OUString& rStr, LanguageType eLang );
ScInterpreterContext& rContext, const OUString& rStr, LanguageType eLang );
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 1761d0c..846a9234 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -468,7 +468,7 @@ public:
bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
OUString GetString( SCCOL nCol, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const;
OUString GetString( SCCOL nCol, SCROW nRow, ScInterpreterContext* pContext = nullptr ) const;
double* GetValueCell( SCCOL nCol, SCROW nRow );
// Note that if pShared is set and a value is returned that way, the returned OUString is empty.
OUString GetInputString( SCCOL nCol, SCROW nRow, bool bForceSystemLocale = false ) const;
diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx
index 4c59144..3cb43be 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -34,9 +34,9 @@ inline OUString getConditionalFormatString(ScDocument* pDoc, SCCOL nCol, SCROW n
const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, nTab);
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet );
aString = ScCellFormat::GetString(*pDoc, ScAddress(nCol, nRow, nTab), nFormat, &pColor, *pFormatter);
ScInterpreterContext& rContext = pDoc->GetNonThreadedContext();
sal_uInt32 nFormat = pPattern->GetNumberFormat( rContext, pCondSet );
aString = ScCellFormat::GetString(*pDoc, ScAddress(nCol, nRow, nTab), nFormat, &pColor, &rContext);
return aString;
}
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index ae1aac3..c4ac17f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -162,8 +162,8 @@ tools::Long ScColumn::GetNeededSize(
else
bBreak = pPattern->GetItem(ATTR_LINEBREAK).GetValue();
SvNumberFormatter* pFormatter = rDocument.GetFormatTable();
sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet );
ScInterpreterContext& rContext = rDocument.GetNonThreadedContext();
sal_uInt32 nFormat = pPattern->GetNumberFormat( rContext, pCondSet );
// get "cell is value" flag
// Must be synchronized with ScOutputData::LayoutStrings()
@@ -186,7 +186,7 @@ tools::Long ScColumn::GetNeededSize(
}
// #i111387#, tdf#121040: disable automatic line breaks for all number formats
if (bBreak && bCellIsValue && (pFormatter->GetType(nFormat) == SvNumFormatType::NUMBER))
if (bBreak && bCellIsValue && (rContext.NFGetType(nFormat) == SvNumFormatType::NUMBER))
{
// If a formula cell needs to be interpreted during aCell.hasNumeric()
// to determine the type, the pattern may get invalidated because the
@@ -207,8 +207,8 @@ tools::Long ScColumn::GetNeededSize(
bBreak = false;
else
{
nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet );
if (pFormatter->GetType(nFormat) == SvNumFormatType::NUMBER)
nFormat = pPattern->GetNumberFormat( rContext, pCondSet );
if (rContext.NFGetType(nFormat) == SvNumFormatType::NUMBER)
bBreak = false;
}
}
@@ -301,7 +301,7 @@ tools::Long ScColumn::GetNeededSize(
{
const Color* pColor;
OUString aValStr = ScCellFormat::GetString(
aCell, nFormat, &pColor, *pFormatter, rDocument, true, rOptions.bFormula);
aCell, nFormat, &pColor, &rContext, rDocument, true, rOptions.bFormula);
if (!aValStr.isEmpty())
{
@@ -471,7 +471,7 @@ tools::Long ScColumn::GetNeededSize(
{
const Color* pColor;
OUString aString = ScCellFormat::GetString(
aCell, nFormat, &pColor, *pFormatter, rDocument, true,
aCell, nFormat, &pColor, &rContext, rDocument, true,
rOptions.bFormula);
if (!aString.isEmpty())
@@ -652,7 +652,7 @@ class MaxStrLenFinder
{
const Color* pColor;
OUString aValStr = ScCellFormat::GetString(
rCell, mnFormat, &pColor, *mrDoc.GetFormatTable(), mrDoc);
rCell, mnFormat, &pColor, nullptr, mrDoc);
if (aValStr.getLength() <= mnMaxLen)
return;
@@ -744,8 +744,8 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
static_cast<tools::Long>( pMargin->GetRightMargin() * nPPTX );
// Try to find the row that has the longest string, and measure the width of that string.
SvNumberFormatter* pFormatter = rDocument.GetFormatTable();
sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter );
ScInterpreterContext& rContext = rDocument.GetNonThreadedContext();
sal_uInt32 nFormat = pPattern->GetNumberFormat(rContext);
while ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && nRow <= 2)
{
// This is often used with CSV import or other data having a header
@@ -755,7 +755,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
// rows..
const ScPatternAttr* pNextPattern = GetPattern( ++nRow );
if (!ScPatternAttr::areSame(pNextPattern, pPattern))
nFormat = pNextPattern->GetNumberFormat( pFormatter );
nFormat = pNextPattern->GetNumberFormat(rContext);
}
OUString aLongStr;
const Color* pColor;
@@ -763,7 +763,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
{
ScRefCellValue aCell = GetCellValue(pParam->mnMaxTextRow);
aLongStr = ScCellFormat::GetString(
aCell, nFormat, &pColor, *pFormatter, rDocument);
aCell, nFormat, &pColor, &rContext, rDocument);
}
else
{
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index a03f3f1..76a8f7b 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -873,7 +873,7 @@ bool ScColumn::UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellSt
pPattern = GetPattern(nRow);
const Color* pColor;
sal_uInt32 nFormat = pPattern->GetNumberFormat(pFormatter, pCondSet);
OUString aStr = ScCellFormat::GetString(aCell, nFormat, &pColor, *pFormatter, rDocument);
OUString aStr = ScCellFormat::GetString(aCell, nFormat, &pColor, nullptr, rDocument);
// Store the real script type to the array.
rAttr.mnScriptType = rDocument.GetStringScriptType(aStr);
@@ -2569,9 +2569,9 @@ class FilterEntriesHandler
void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& rCell, bool bIsEmptyCell=false)
{
SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
sal_uInt32 nFormat = mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow);
OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, mrColumn.GetDoc(), mbFiltering);
ScInterpreterContext& rContext = mrColumn.GetDoc().GetNonThreadedContext();
sal_uInt32 nFormat = mrColumn.GetNumberFormat(rContext, nRow);
OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, &rContext, mrColumn.GetDoc(), mbFiltering);
// Colors
ScAddress aPos(rColumn.GetCol(), nRow, rColumn.GetTab());
@@ -2638,7 +2638,7 @@ class FilterEntriesHandler
;
}
SvNumFormatType nType = pFormatter->GetType(nFormat);
SvNumFormatType nType = rContext.NFGetType(nFormat);
bool bDate = false;
if ((nType & SvNumFormatType::DATE) && !(nType & SvNumFormatType::TIME))
{
@@ -2649,16 +2649,16 @@ class FilterEntriesHandler
bDate = true;
// Convert string representation to ISO 8601 date to eliminate
// locale dependent behaviour later when filtering for dates.
sal_uInt32 nIndex = pFormatter->GetFormatIndex( NF_DATE_DIN_YYYYMMDD);
pFormatter->GetInputLineString( fVal, nIndex, aStr);
sal_uInt32 nIndex = rContext.NFGetFormatIndex( NF_DATE_DIN_YYYYMMDD);
rContext.NFGetInputLineString( fVal, nIndex, aStr);
}
else if (nType == SvNumFormatType::DATETIME)
{
// special case for datetime values.
// Convert string representation to ISO 8601 (with blank instead of T) datetime
// to eliminate locale dependent behaviour later when filtering for datetimes.
sal_uInt32 nIndex = pFormatter->GetFormatIndex(NF_DATETIME_ISO_YYYYMMDD_HHMMSS);
pFormatter->GetInputLineString(fVal, nIndex, aStr);
sal_uInt32 nIndex = rContext.NFGetFormatIndex(NF_DATETIME_ISO_YYYYMMDD_HHMMSS);
rContext.NFGetInputLineString(fVal, nIndex, aStr);
}
// store the formatted/rounded value for filtering
if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0 && !bDate)
@@ -3132,7 +3132,7 @@ void ScColumn::SetValue(
BroadcastNewCell(nRow);
}
OUString ScColumn::GetString( const ScRefCellValue& aCell, SCROW nRow, const ScInterpreterContext* pContext ) const
OUString ScColumn::GetString( const ScRefCellValue& aCell, SCROW nRow, ScInterpreterContext* pContext ) const
{
// ugly hack for ordering problem with GetNumberFormat and missing inherited formats
if (aCell.getType() == CELLTYPE_FORMULA)
@@ -3140,8 +3140,7 @@ OUString ScColumn::GetString( const ScRefCellValue& aCell, SCROW nRow, const ScI
sal_uInt32 nFormat = GetNumberFormat( pContext ? *pContext : GetDoc().GetNonThreadedContext(), nRow);
const Color* pColor = nullptr;
return ScCellFormat::GetString(aCell, nFormat, &pColor,
pContext ? *(pContext->GetFormatTable()) : *(GetDoc().GetFormatTable()), GetDoc());
return ScCellFormat::GetString(aCell, nFormat, &pColor, pContext, GetDoc());
}
double* ScColumn::GetValueCell( SCROW nRow )
@@ -3160,7 +3159,7 @@ double* ScColumn::GetValueCell( SCROW nRow )
OUString ScColumn::GetInputString( const ScRefCellValue& aCell, SCROW nRow, bool bForceSystemLocale ) const
{
sal_uInt32 nFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow);
return ScCellFormat::GetInputString(aCell, nFormat, *(GetDoc().GetFormatTable()), GetDoc(), nullptr, false, bForceSystemLocale);
return ScCellFormat::GetInputString(aCell, nFormat, nullptr, GetDoc(), nullptr, false, bForceSystemLocale);
}
double ScColumn::GetValue( SCROW nRow ) const
@@ -3358,7 +3357,6 @@ class MaxStringLenHandler
{
sal_Int32 mnMaxLen;
const ScColumn& mrColumn;
SvNumberFormatter* mpFormatter;
rtl_TextEncoding meCharSet;
bool mbOctetEncoding;
@@ -3366,7 +3364,7 @@ class MaxStringLenHandler
{
const Color* pColor;
sal_uInt32 nFormat = mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
OUString aString = ScCellFormat::GetString(rCell, nFormat, &pColor, *mpFormatter, mrColumn.GetDoc());
OUString aString = ScCellFormat::GetString(rCell, nFormat, &pColor, nullptr, mrColumn.GetDoc());
sal_Int32 nLen = 0;
if (mbOctetEncoding)
{
@@ -3393,7 +3391,6 @@ public:
MaxStringLenHandler(const ScColumn& rColumn, rtl_TextEncoding eCharSet) :
mnMaxLen(0),
mrColumn(rColumn),
mpFormatter(rColumn.GetDoc().GetFormatTable()),
meCharSet(eCharSet),
mbOctetEncoding(rtl_isOctetTextEncoding(eCharSet))
{
@@ -3440,7 +3437,6 @@ namespace {
class MaxNumStringLenHandler
{
const ScColumn& mrColumn;
SvNumberFormatter* mpFormatter;
sal_Int32 mnMaxLen;
sal_uInt16 mnPrecision;
sal_uInt16 mnMaxGeneralPrecision;
@@ -3475,9 +3471,10 @@ class MaxNumStringLenHandler
mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
if (nFormat % SV_COUNTRY_LANGUAGE_OFFSET)
{
aSep = mpFormatter->GetFormatDecimalSep(nFormat);
aString = ScCellFormat::GetInputString(rCell, nFormat, *mpFormatter, mrColumn.GetDoc());
const SvNumberformat* pEntry = mpFormatter->GetEntry(nFormat);
ScInterpreterContext& rContext = mrColumn.GetDoc().GetNonThreadedContext();
aSep = rContext.NFGetFormatDecimalSep(nFormat);
aString = ScCellFormat::GetInputString(rCell, nFormat, &rContext, mrColumn.GetDoc());
const SvNumberformat* pEntry = rContext.NFGetFormatEntry(nFormat);
if (pEntry)
{
bool bThousand, bNegRed;
@@ -3485,7 +3482,7 @@ class MaxNumStringLenHandler
pEntry->GetFormatSpecialInfo(bThousand, bNegRed, nPrec, nLeading);
}
else
nPrec = mpFormatter->GetFormatPrecision(nFormat);
nPrec = rContext.NFGetFormatPrecision(nFormat);
}
else
{
@@ -3560,7 +3557,7 @@ class MaxNumStringLenHandler
public:
MaxNumStringLenHandler(const ScColumn& rColumn, sal_uInt16 nMaxGeneralPrecision) :
mrColumn(rColumn), mpFormatter(rColumn.GetDoc().GetFormatTable()),
mrColumn(rColumn),
mnMaxLen(0), mnPrecision(0), mnMaxGeneralPrecision(nMaxGeneralPrecision),
mbHaveSigned(false)
{
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 7b1299d..2f90021 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -1128,7 +1128,7 @@ class ScriptTypeUpdater
sc::CellTextAttrStoreType& mrTextAttrs;
sc::CellTextAttrStoreType::iterator miPosAttr;
ScConditionalFormatList* mpCFList;
SvNumberFormatter* mpFormatter;
ScInterpreterContext& mrContext;
ScAddress maPos;
bool mbUpdated;
@@ -1161,8 +1161,8 @@ private:
}
const Color* pColor;
sal_uInt32 nFormat = pPat->GetNumberFormat(mpFormatter, pCondSet);
OUString aStr = ScCellFormat::GetString(rCell, nFormat, &pColor, *mpFormatter, mrCol.GetDoc());
sal_uInt32 nFormat = pPat->GetNumberFormat(mrContext, pCondSet);
OUString aStr = ScCellFormat::GetString(rCell, nFormat, &pColor, &mrContext, mrCol.GetDoc());
rAttr.mnScriptType = mrCol.GetDoc().GetStringScriptType(aStr);
mbUpdated = true;
@@ -1174,7 +1174,7 @@ public:
mrTextAttrs(rCol.GetCellAttrStore()),
miPosAttr(mrTextAttrs.begin()),
mpCFList(rCol.GetDoc().GetCondFormList(rCol.GetTab())),
mpFormatter(rCol.GetDoc().GetFormatTable()),
mrContext(rCol.GetDoc().GetNonThreadedContext()),
maPos(rCol.GetCol(), 0, rCol.GetTab()),
mbUpdated(false)
{}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index bb4e77d..edecaa1 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -78,7 +78,10 @@ static void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrAr
nRowEnd = rDoc.MaxRow();
}
nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : rDoc.GetFormatTable() );
if (pContext)
nFormat = pPattern->GetNumberFormat(*pContext);
else
nFormat = pPattern->GetNumberFormat(rDoc.GetFormatTable());
rpArr = pNewArr;
nAttrEndRow = nRowEnd;
}
@@ -260,7 +263,7 @@ void ScValueIterator::GetCurNumFmtInfo( SvNumFormatType& nType, sal_uInt32& nInd
SCROW nCurRow = GetRow();
const ScColumn* pCol = &(mrDoc.maTabs[mnTab])->aCol[mnCol];
nNumFmtIndex = pCol->GetNumberFormat(mrContext, nCurRow);
nNumFmtType = mrContext.GetNumberFormatType( nNumFmtIndex );
nNumFmtType = mrContext.NFGetType(nNumFmtIndex);
bNumValid = true;
}
diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx
index 96c625e..ef13ecb 100644
--- a/sc/source/core/data/documen6.cxx
+++ b/sc/source/core/data/documen6.cxx
@@ -118,9 +118,9 @@ SvtScriptType ScDocument::GetCellScriptType( const ScAddress& rPos, sal_uInt32 n
const Color* pColor;
OUString aStr;
if( pCell )
aStr = ScCellFormat::GetString(*pCell, nNumberFormat, &pColor, *GetFormatTable(), *this);
aStr = ScCellFormat::GetString(*pCell, nNumberFormat, &pColor, nullptr, *this);
else
aStr = ScCellFormat::GetString(*this, rPos, nNumberFormat, &pColor, *GetFormatTable());
aStr = ScCellFormat::GetString(*this, rPos, nNumberFormat, &pColor, nullptr);
SvtScriptType nRet = GetStringScriptType( aStr );
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b9ef98c..17a3b72 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3547,14 +3547,14 @@ void ScDocument::SetValue( const ScAddress& rPos, double fVal )
pTab->SetValue(rPos.Col(), rPos.Row(), fVal);
}
OUString ScDocument::GetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext* pContext ) const
OUString ScDocument::GetString( SCCOL nCol, SCROW nRow, SCTAB nTab, ScInterpreterContext* pContext ) const
{
if (const ScTable* pTable = FetchTable(nTab))
return pTable->GetString(nCol, nRow, pContext);
return OUString();
}
OUString ScDocument::GetString( const ScAddress& rPos, const ScInterpreterContext* pContext ) const
OUString ScDocument::GetString( const ScAddress& rPos, ScInterpreterContext* pContext ) const
{
if (const ScTable* pTable = FetchTable(rPos.Tab()))
return pTable->GetString(rPos.Col(), rPos.Row(), pContext);
@@ -3739,7 +3739,7 @@ void ScDocument::GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNu
if (nTab < GetTableCount() && maTabs[nTab])
{
nIndex = maTabs[nTab]->GetNumberFormat( rContext, rPos );
nType = rContext.GetNumberFormatType( nIndex );
nType = rContext.NFGetType(nIndex);
}
else
{
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 52109c6..efc331e 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -658,8 +658,8 @@ bool ScDPCache::InitFromDataBase(DBConnector& rDB)
if (!aData.IsEmpty())
{
maEmptyRows.insert_back(nRow, nRow+1, false);
SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
rField.mnNumFormat = pFormatter ? pFormatter->GetStandardFormat(nFormatType) : 0;
ScInterpreterContext& rContext = mrDoc.GetNonThreadedContext();
rField.mnNumFormat = rContext.NFGetStandardFormat(nFormatType);
}
++nRow;
@@ -1068,11 +1068,8 @@ bool ScDPCache::IsDateDimension( tools::Long nDim ) const
if (nDim >= mnColumnCount)
return false;
SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
if (!pFormatter)
return false;
SvNumFormatType eType = pFormatter->GetType(maFields[nDim]->mnNumFormat);
ScInterpreterContext& rContext = mrDoc.GetNonThreadedContext();
SvNumFormatType eType = rContext.NFGetType(maFields[nDim]->mnNumFormat);
return (eType == SvNumFormatType::DATE) || (eType == SvNumFormatType::DATETIME);
}
@@ -1163,22 +1160,22 @@ SCROW ScDPCache::GetIdByItemData(tools::Long nDim, const ScDPItemData& rItem) co
}
// static
sal_uInt32 ScDPCache::GetLocaleIndependentFormat( SvNumberFormatter& rFormatter, sal_uInt32 nNumFormat )
sal_uInt32 ScDPCache::GetLocaleIndependentFormat(ScInterpreterContext& rContext, sal_uInt32 nNumFormat)
{
// For a date or date+time format use ISO format so it works across locales
// and can be matched against string based item queries. For time use 24h
// format. All others use General format, no currency, percent, ...
// Use en-US locale for all.
switch (rFormatter.GetType( nNumFormat))
switch (rContext.NFGetType(nNumFormat))
{
case SvNumFormatType::DATE:
return rFormatter.GetFormatIndex( NF_DATE_ISO_YYYYMMDD, LANGUAGE_ENGLISH_US);
return rContext.NFGetFormatIndex( NF_DATE_ISO_YYYYMMDD, LANGUAGE_ENGLISH_US);
case SvNumFormatType::TIME:
return rFormatter.GetFormatIndex( NF_TIME_HHMMSS, LANGUAGE_ENGLISH_US);
return rContext.NFGetFormatIndex( NF_TIME_HHMMSS, LANGUAGE_ENGLISH_US);
case SvNumFormatType::DATETIME:
return rFormatter.GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, LANGUAGE_ENGLISH_US);
return rContext.NFGetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, LANGUAGE_ENGLISH_US);
default:
return rFormatter.GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_ENGLISH_US);
return rContext.NFGetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_ENGLISH_US);
}
}
@@ -1190,15 +1187,15 @@ OUString ScDPCache::GetLocaleIndependentFormattedNumberString( double fValue )
// static
OUString ScDPCache::GetLocaleIndependentFormattedString( double fValue,
SvNumberFormatter& rFormatter, sal_uInt32 nNumFormat )
ScInterpreterContext& rContext, sal_uInt32 nNumFormat )
{
nNumFormat = GetLocaleIndependentFormat( rFormatter, nNumFormat);
nNumFormat = GetLocaleIndependentFormat( rContext, nNumFormat);
if ((nNumFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
return GetLocaleIndependentFormattedNumberString( fValue);
OUString aStr;
const Color* pColor = nullptr;
rFormatter.GetOutputString( fValue, nNumFormat, aStr, &pColor);
rContext.NFGetOutputString( fValue, nNumFormat, aStr, &pColor);
return aStr;
}
@@ -1211,21 +1208,15 @@ OUString ScDPCache::GetFormattedString(tools::Long nDim, const ScDPItemData& rIt
if (eType == ScDPItemData::Value)
{
// Format value using the stored number format.
SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
if (pFormatter)
{
sal_uInt32 nNumFormat = GetNumberFormat(nDim);
if (bLocaleIndependent)
return GetLocaleIndependentFormattedString( rItem.GetValue(), *pFormatter, nNumFormat);
ScInterpreterContext& rContext = mrDoc.GetNonThreadedContext();
sal_uInt32 nNumFormat = GetNumberFormat(nDim);
if (bLocaleIndependent)
return GetLocaleIndependentFormattedString( rItem.GetValue(), rContext, nNumFormat);
OUString aStr;
const Color* pColor = nullptr;
pFormatter->GetOutputString(rItem.GetValue(), nNumFormat, aStr, &pColor);
return aStr;
}
// Last resort...
return GetLocaleIndependentFormattedNumberString( rItem.GetValue());
OUString aStr;
const Color* pColor = nullptr;
rContext.NFGetOutputString(rItem.GetValue(), nNumFormat, aStr, &pColor);
return aStr;
}
if (eType == ScDPItemData::GroupValue)
@@ -1256,9 +1247,9 @@ OUString ScDPCache::GetFormattedString(tools::Long nDim, const ScDPItemData& rIt
return rItem.GetString();
}
SvNumberFormatter* ScDPCache::GetNumberFormatter() const
ScInterpreterContext& ScDPCache::GetInterpreterContext() const
{
return mrDoc.GetFormatTable();
return mrDoc.GetNonThreadedContext();
}
tools::Long ScDPCache::AppendGroupField()
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 1a9f595..63b7021 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1888,16 +1888,13 @@ bool ScDPObject::ParseFilters(
OUString aQueryValue = aQueryValueName;
if (mpTableData)
{
SvNumberFormatter* pFormatter = mpTableData->GetCacheTable().getCache().GetNumberFormatter();
if (pFormatter)
{
// Parse possible number from aQueryValueName and format
// locale independent as aQueryValue.
sal_uInt32 nNumFormat = 0;
double fValue;
if (pFormatter->IsNumberFormat( aQueryValueName, nNumFormat, fValue))
aQueryValue = ScDPCache::GetLocaleIndependentFormattedString( fValue, *pFormatter, nNumFormat);
}
ScInterpreterContext& rContext = mpTableData->GetCacheTable().getCache().GetInterpreterContext();
// Parse possible number from aQueryValueName and format
// locale independent as aQueryValue.
sal_uInt32 nNumFormat = 0;
double fValue;
if (rContext.NFIsNumberFormat(aQueryValueName, nNumFormat, fValue))
aQueryValue = ScDPCache::GetLocaleIndependentFormattedString(fValue, rContext, nNumFormat);
}
for ( SCSIZE nField=0; nField<nFieldCount; nField++ )
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index bcb0a8f..b2283f4 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -947,7 +947,7 @@ size_t ScFormulaCell::GetHash() const
return pCode->GetHash();
}
OUString ScFormulaCell::GetFormula( const FormulaGrammar::Grammar eGrammar, const ScInterpreterContext* pContext ) const
OUString ScFormulaCell::GetFormula( const FormulaGrammar::Grammar eGrammar, ScInterpreterContext* pContext ) const
{
if( pCode->GetCodeError() != FormulaError::NONE && !pCode->GetLen() )
{
@@ -1001,7 +1001,7 @@ OUString ScFormulaCell::GetFormula( const FormulaGrammar::Grammar eGrammar, cons
return buffer.makeStringAndClear();
}
OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt, const ScInterpreterContext* pContext ) const
OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt, ScInterpreterContext* pContext ) const
{
OUStringBuffer aBuf;
if (pCode->GetCodeError() != FormulaError::NONE && !pCode->GetLen())
@@ -2088,7 +2088,7 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
nFormatType = rContext.GetFormatTable()->GetType( nOldFormatIndex);
}
if (nOldFormatIndex !=
ScGlobal::GetStandardFormat( *rContext.GetFormatTable(), nOldFormatIndex, nFormatType))
ScGlobal::GetStandardFormat(rContext, nOldFormatIndex, nFormatType))
bForceNumberFormat = false;
}
}
@@ -2138,8 +2138,7 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
}
if (bSetFormat && (bForceNumberFormat || ((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0)))
nFormatIndex = ScGlobal::GetStandardFormat(*rContext.GetFormatTable(),
nFormatIndex, nFormatType);
nFormatIndex = ScGlobal::GetStandardFormat(rContext, nFormatIndex, nFormatType);
// Do not replace a General format (which was the reason why
// mbNeedsNumberFormat was set) with a General format.
@@ -2688,19 +2687,19 @@ void ScFormulaCell::GetURLResult( OUString& rURL, OUString& rCellText )
// Cell Text uses the Cell format while the URL uses
// the default format for the type.
const sal_uInt32 nCellFormat = rDocument.GetNumberFormat( aPos );
SvNumberFormatter* pFormatter = rDocument.GetFormatTable();
ScInterpreterContext& rContext = rDocument.GetNonThreadedContext();
const sal_uInt32 nURLFormat = ScGlobal::GetStandardFormat( *pFormatter, nCellFormat, SvNumFormatType::NUMBER);
const sal_uInt32 nURLFormat = ScGlobal::GetStandardFormat(rContext, nCellFormat, SvNumFormatType::NUMBER);
if ( IsValue() )
{
double fValue = GetValue();
pFormatter->GetOutputString( fValue, nCellFormat, rCellText, &pColor );
rContext.NFGetOutputString( fValue, nCellFormat, rCellText, &pColor );
}
else
{
aCellString = GetString().getString();
pFormatter->GetOutputString( aCellString, nCellFormat, rCellText, &pColor );
rContext.NFGetOutputString( aCellString, nCellFormat, rCellText, &pColor );
}
ScConstMatrixRef xMat( aResult.GetMatrix());
if (xMat)
@@ -2709,16 +2708,16 @@ void ScFormulaCell::GetURLResult( OUString& rURL, OUString& rCellText )
if (!xMat->IsValue(0, 1))
rURL = xMat->GetString(0, 1).getString();
else
pFormatter->GetOutputString(
rContext.NFGetOutputString(
xMat->GetDouble(0, 1), nURLFormat, rURL, &pColor);
}
if(rURL.isEmpty())
{
if(IsValue())
pFormatter->GetOutputString( GetValue(), nURLFormat, rURL, &pColor );
rContext.NFGetOutputString( GetValue(), nURLFormat, rURL, &pColor );
else
pFormatter->GetOutputString( aCellString, nURLFormat, rURL, &pColor );
rContext.NFGetOutputString( aCellString, nURLFormat, rURL, &pColor );
}
}
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 9443d6e..a46f46b 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -157,13 +157,12 @@ bool ScGlobal::HasAttrChanged( const SfxItemSet& rNewAttrs,
return bInvalidate;
}
sal_uInt32 ScGlobal::GetStandardFormat( SvNumberFormatter& rFormatter,
sal_uInt32 ScGlobal::GetStandardFormat( ScInterpreterContext& rContext,
sal_uInt32 nFormat, SvNumFormatType nType )
{
const SvNumberformat* pFormat = rFormatter.GetEntry( nFormat );
if ( pFormat )
return rFormatter.GetStandardFormat( nFormat, nType, pFormat->GetLanguage() );
return rFormatter.GetStandardFormat( nType, eLnge );
if (const SvNumberformat* pFormat = rContext.NFGetFormatEntry(nFormat))
return rContext.NFGetStandardFormat( nFormat, nType, pFormat->GetLanguage() );
return rContext.NFGetStandardFormat( nType, eLnge );
}
sal_uInt16 ScGlobal::GetStandardRowHeight()
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 60c0f02..4a9237a 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -35,6 +35,7 @@
#include <compiler.hxx>
#include <paramisc.hxx>
#include <calcconfig.hxx>
#include <interpretercontext.hxx>
// struct ScImportParam:
@@ -351,7 +352,7 @@ bool isEmptyString( const OUString& rStr )
double ScGlobal::ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
FormulaError & rError, FormulaError nStringNoValueError,
SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType )
ScInterpreterContext& rContext, SvNumFormatType & rCurFmtType )
{
// We keep ScCalcConfig::StringConversion::LOCALE default until
// we provide a friendly way to convert string numbers into numbers in the UI.
@@ -385,11 +386,8 @@ double ScGlobal::ConvertStringToValue( const OUString& rStr, const ScCalcConfig&
return fValue;
}
if (!pFormatter)
goto Label_fallback_to_unambiguous;
sal_uInt32 nFIndex = 0;
if (!pFormatter->IsNumberFormat(rStr, nFIndex, fValue))
if (!rContext.NFIsNumberFormat(rStr, nFIndex, fValue))
{
rError = nStringNoValueError;
fValue = 0.0;
@@ -398,7 +396,6 @@ double ScGlobal::ConvertStringToValue( const OUString& rStr, const ScCalcConfig&
}
break;
case ScCalcConfig::StringConversion::UNAMBIGUOUS:
Label_fallback_to_unambiguous:
{
if (!rConfig.mbEmptyStringAsZero)
{
@@ -565,14 +562,7 @@ Label_fallback_to_unambiguous:
rError = nStringNoValueError;
else
{
if (pFormatter)
fValue = aDate - pFormatter->GetNullDate();
else
{
SAL_WARN("sc.core","ScGlobal::ConvertStringToValue - fixed null date");
static Date aDefaultNullDate( 30, 12, 1899);
fValue = aDate - aDefaultNullDate;
}
fValue = aDate - rContext.NFGetNullDate();
}
}
fValue += ((nUnit[hour] * 3600) + (nUnit[minute] * 60) + nUnit[second] + fFraction) / 86400.0;
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index c847d4b..79d848f 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1659,7 +1659,7 @@ sal_uInt32 ScPatternAttr::GetNumberFormat( const ScInterpreterContext& rContext
if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM )
; // it remains as it is
else
nFormat = rContext.GetFormatForLanguageIfBuiltIn( nFormat, eLang );
nFormat = rContext.NFGetFormatForLanguageIfBuiltIn( nFormat, eLang );
return nFormat;
}
@@ -1693,6 +1693,33 @@ sal_uInt32 ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter,
return pFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLang);
}
sal_uInt32 ScPatternAttr::GetNumberFormat( const ScInterpreterContext& rContext,
const SfxItemSet* pCondSet ) const
{
if (!pCondSet)
return GetNumberFormat(rContext);
// Conditional format takes precedence over style and even hard format.
sal_uInt32 nFormat;
LanguageType eLang;
if (pCondSet->GetItemState(ATTR_VALUE_FORMAT) == SfxItemState::SET )
{
nFormat = getNumberFormatKey(*pCondSet);
if (pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT) == SfxItemState::SET)
eLang = getLanguageType(*pCondSet);
else
eLang = getLanguageType(GetItemSet());
}
else
{
nFormat = getNumberFormatKey(GetItemSet());
eLang = getLanguageType(GetItemSet());
}
return rContext.NFGetFormatForLanguageIfBuiltIn(nFormat, eLang);
}
const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
{
const SfxPoolItem* pCondItem;
diff --git a/sc/source/core/data/queryevaluator.cxx b/sc/source/core/data/queryevaluator.cxx
index 174e1e0..03d9d19 100644
--- a/sc/source/core/data/queryevaluator.cxx
+++ b/sc/source/core/data/queryevaluator.cxx
@@ -100,7 +100,7 @@ void ScQueryEvaluator::setupCollatorIfNeeded()
}
ScQueryEvaluator::ScQueryEvaluator(ScDocument& rDoc, const ScTable& rTab,
const ScQueryParam& rParam, const ScInterpreterContext* pContext,
const ScQueryParam& rParam, ScInterpreterContext* pContext,
bool* pTestEqualCondition)
: mrDoc(rDoc)
, mrStrPool(rDoc.GetSharedStringPool())
@@ -327,9 +327,7 @@ OUString ScQueryEvaluator::getCellString(const ScRefCellValue& rCell, SCROW nRow
sal_uInt32 nFormat
= mpContext ? mrTab.GetNumberFormat(*mpContext, ScAddress(nCol, nRow, mrTab.GetTab()))
: mrTab.GetNumberFormat(nCol, nRow);
SvNumberFormatter* pFormatter
= mpContext ? mpContext->GetFormatTable() : mrDoc.GetFormatTable();
return ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, mrDoc, sharedString, true);
return ScCellFormat::GetInputString(rCell, nFormat, mpContext, mrDoc, sharedString, true);
}
}
diff --git a/sc/source/core/data/queryiter.cxx b/sc/source/core/data/queryiter.cxx
index d931b94..e3db0ae 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -84,7 +84,7 @@ ScQueryCellIteratorBase< accessType, queryType >::ScQueryCellIteratorBase(ScDocu
ScQueryEntry& rEntry = maParam.GetEntry(i);
ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
sal_uInt32 nIndex = 0;
bool bNumber = mrContext.GetFormatTable()->IsNumberFormat(
bool bNumber = mrContext.NFIsNumberFormat(
rItem.maString.getString(), nIndex, rItem.mfVal);
rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
}
@@ -417,7 +417,6 @@ bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch( SCCOL col,
return false;
CollatorWrapper& rCollator = ScGlobal::GetCollator(maParam.bCaseSens);
SvNumberFormatter& rFormatter = *(mrContext.GetFormatTable());
const ScQueryEntry& rEntry = maParam.GetEntry(0);
const ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
bool bAscending = rEntry.eOp == SC_LESS || rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == SC_EQUAL;
@@ -437,7 +436,7 @@ bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch( SCCOL col,
{
ScRefCellValue aCell = sc::toRefCell(aPos.first, aPos.second);
sal_uInt32 nFormat = pCol->GetNumberFormat(mrContext, nRow);
OUString aCellStr = ScCellFormat::GetInputString(aCell, nFormat, rFormatter, rDoc);
OUString aCellStr = ScCellFormat::GetInputString(aCell, nFormat, &mrContext, rDoc);
sal_Int32 nTmp = rCollator.compareString(aCellStr, rEntry.GetQueryItem().maString.getString());
if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) ||
(rEntry.eOp == SC_GREATER_EQUAL && nTmp < 0) ||
@@ -492,7 +491,7 @@ bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch( SCCOL col,
if (bForceStr || aCell.hasString())
{
sal_uInt32 nFormat = pCol->GetNumberFormat(mrContext, aCellData.second);
aLastInRangeString = ScCellFormat::GetInputString(aCell, nFormat, rFormatter, rDoc);
aLastInRangeString = ScCellFormat::GetInputString(aCell, nFormat, &mrContext, rDoc);
}
else
{
@@ -588,7 +587,7 @@ bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch( SCCOL col,
else if (bStr && bByString)
{
sal_uInt32 nFormat = pCol->GetNumberFormat(mrContext, aCellData.second);
OUString aCellStr = ScCellFormat::GetInputString(aCell, nFormat, rFormatter, rDoc);
OUString aCellStr = ScCellFormat::GetInputString(aCell, nFormat, &mrContext, rDoc);
nRes = rCollator.compareString(aCellStr, rEntry.GetQueryItem().maString.getString());
if (nRes < 0 && bAscending)
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index b0f2fa1..7d03ef6 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -575,7 +575,7 @@ void ScTable::CopyStaticToDocument(
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
{
sal_uInt32 nNumFmt = aDefaultColData.GetPattern(nRow)->GetNumberFormat(
rDocument.GetNonThreadedContext().GetFormatTable());
rDocument.GetNonThreadedContext());
SvNumberFormatterMergeMap::const_iterator itNum = rMap.find(nNumFmt);
if (itNum != rMap.end())
nNumFmt = itNum->second;
@@ -1796,7 +1796,7 @@ void ScTable::SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rSt
CreateColumnIfNotExists(nCol).SetRawString(nRow, rStr);
}
OUString ScTable::GetString( SCCOL nCol, SCROW nRow, const ScInterpreterContext* pContext ) const
OUString ScTable::GetString( SCCOL nCol, SCROW nRow, ScInterpreterContext* pContext ) const
{
if (ValidColRow(nCol,nRow) && nCol < GetAllocatedColumnsCount())
return aCol[nCol].GetString( nRow, pContext );
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 3983746..408ca950 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1064,13 +1064,11 @@ Color ScTable::GetCellTextColor(ScAddress aPos) const
if (pPattern->GetItem(ATTR_VALUE_FORMAT).GetValue())
{
SvNumberFormatter* pNumberFormatter = GetDoc().GetFormatTable();
const SfxUInt32Item pItem = pPattern->GetItem(ATTR_VALUE_FORMAT);
auto& rDoc = const_cast<ScDocument&>(GetDoc());
const Color* pColor;
ScRefCellValue aCell(rDoc, aPos);
ScCellFormat::GetString(rDoc, aPos, pItem.GetValue(), &pColor, *pNumberFormatter, false,
false);
ScCellFormat::GetString(rDoc, aPos, pItem.GetValue(), &pColor, nullptr, false, false);
if (pColor)
return *pColor;
}
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index a5b25da..960390f 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -247,7 +247,6 @@ private:
ScJumpMatrix* pJumpMatrix; // currently active array condition, if any
ScTokenMatrixMap maTokenMatrixMap; // map FormulaToken* to formula::FormulaTokenRef if in array condition
ScFormulaCell* pMyFormulaCell; // the cell of this formula expression
SvNumberFormatter* pFormatter;
const formula::FormulaToken* pCur; // current token
ScTokenStack* pStackObj; // contains the stacks
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 9d1a731..875e3ac 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -29,23 +29,25 @@
#include <editutil.hxx>
OUString ScCellFormat::GetString( const ScRefCellValue& rCell, sal_uInt32 nFormat,
const Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument& rDoc,
const Color** ppColor, ScInterpreterContext* pContext, const ScDocument& rDoc,
bool bNullVals, bool bFormula, bool bUseStarFormat )
{
*ppColor = nullptr;
ScInterpreterContext& rContext = pContext ? *pContext : rDoc.GetNonThreadedContext();
switch (rCell.getType())
{
case CELLTYPE_STRING:
{
OUString str;
rFormatter.GetOutputString(rCell.getSharedString()->getString(), nFormat, str, ppColor, bUseStarFormat);
rContext.NFGetOutputString(rCell.getSharedString()->getString(), nFormat, str, ppColor, bUseStarFormat);
return str;
}
case CELLTYPE_EDIT:
{
OUString str;
rFormatter.GetOutputString(rCell.getString(&rDoc), nFormat, str, ppColor );
rContext.NFGetOutputString(rCell.getString(&rDoc), nFormat, str, ppColor );
return str;
}
case CELLTYPE_VALUE:
@@ -56,7 +58,7 @@ OUString ScCellFormat::GetString( const ScRefCellValue& rCell, sal_uInt32 nForma
else
{
OUString str;
rFormatter.GetOutputString( nValue, nFormat, str, ppColor, bUseStarFormat );
rContext.NFGetOutputString( nValue, nFormat, str, ppColor, bUseStarFormat );
return str;
}
}
@@ -97,14 +99,14 @@ OUString ScCellFormat::GetString( const ScRefCellValue& rCell, sal_uInt32 nForma
else
{
OUString str;
rFormatter.GetOutputString( fValue, nFormat, str, ppColor, bUseStarFormat );
rContext.NFGetOutputString( fValue, nFormat, str, ppColor, bUseStarFormat );
return str;
}
}
else
{
OUString str;
rFormatter.GetOutputString( pFCell->GetString().getString(),
rContext.NFGetOutputString( pFCell->GetString().getString(),
nFormat, str, ppColor, bUseStarFormat );
return str;
}
@@ -118,18 +120,20 @@ OUString ScCellFormat::GetString( const ScRefCellValue& rCell, sal_uInt32 nForma
OUString ScCellFormat::GetString(
ScDocument& rDoc, const ScAddress& rPos, sal_uInt32 nFormat, const Color** ppColor,
SvNumberFormatter& rFormatter, bool bNullVals, bool bFormula )
ScInterpreterContext* pContext, bool bNullVals, bool bFormula )
{
*ppColor = nullptr;
ScRefCellValue aCell(rDoc, rPos);
return GetString(aCell, nFormat, ppColor, rFormatter, rDoc, bNullVals, bFormula);
return GetString(aCell, nFormat, ppColor, pContext, rDoc, bNullVals, bFormula);
}
OUString ScCellFormat::GetInputString(
const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, const ScDocument& rDoc,
const ScRefCellValue& rCell, sal_uInt32 nFormat, ScInterpreterContext* pContext, const ScDocument& rDoc,
const svl::SharedString** pShared, bool bFiltering, bool bForceSystemLocale )
{
ScInterpreterContext& rContext = pContext ? *pContext : rDoc.GetNonThreadedContext();
if(pShared != nullptr)
*pShared = nullptr;
switch (rCell.getType())
@@ -140,7 +144,7 @@ OUString ScCellFormat::GetInputString(
case CELLTYPE_VALUE:
{
OUString str;
rFormatter.GetInputLineString(rCell.getDouble(), nFormat, str, bFiltering, bForceSystemLocale);
rContext.NFGetInputLineString(rCell.getDouble(), nFormat, str, bFiltering, bForceSystemLocale);
return str;
}
break;
@@ -153,7 +157,7 @@ OUString ScCellFormat::GetInputString(
else if (pFC->IsValue())
{
str.emplace();
rFormatter.GetInputLineString(pFC->GetValue(), nFormat, *str, bFiltering, bForceSystemLocale);
rContext.NFGetInputLineString(pFC->GetValue(), nFormat, *str, bFiltering, bForceSystemLocale);
}
else
{
@@ -210,7 +214,7 @@ OUString ScCellFormat::GetOutputString( ScDocument& rDoc, const ScAddress& rPos,
// like in GetString for document (column)
const Color* pColor;
sal_uInt32 nNumFmt = rDoc.GetNumberFormat(rPos);
return GetString(rCell, nNumFmt, &pColor, *rDoc.GetFormatTable(), rDoc);
return GetString(rCell, nNumFmt, &pColor, nullptr, rDoc);
}
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 152a75f..7b655d72 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1846,12 +1846,11 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
}
ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr,
bool bComputeII, bool bMatrixFlag, const ScInterpreterContext* pContext )
bool bComputeII, bool bMatrixFlag, ScInterpreterContext* pContext )
: FormulaCompiler(rArr, bComputeII, bMatrixFlag),
rDoc(rCxt.getDoc()),
aPos(rPos),
mpFormatter(pContext ? pContext->GetFormatTable() : rDoc.GetFormatTable()),
mpInterpreterContext(pContext),
mrInterpreterContext(pContext ? *pContext : rDoc.GetNonThreadedContext()),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
pCharClass(&ScGlobal::getCharClass()),
@@ -1870,12 +1869,11 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
ScCompiler::ScCompiler( ScDocument& rDocument, const ScAddress& rPos, ScTokenArray& rArr,
formula::FormulaGrammar::Grammar eGrammar,
bool bComputeII, bool bMatrixFlag, const ScInterpreterContext* pContext )
bool bComputeII, bool bMatrixFlag, ScInterpreterContext* pContext )
: FormulaCompiler(rArr, bComputeII, bMatrixFlag),
rDoc( rDocument ),
aPos( rPos ),
mpFormatter(pContext ? pContext->GetFormatTable() : rDoc.GetFormatTable()),
mpInterpreterContext(pContext),
mrInterpreterContext(pContext ? *pContext : rDoc.GetNonThreadedContext()),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
nSrcPos(0),
@@ -1895,12 +1893,11 @@ ScCompiler::ScCompiler( ScDocument& rDocument, const ScAddress& rPos, ScTokenArr
}
ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
bool bComputeII, bool bMatrixFlag, const ScInterpreterContext* pContext )
bool bComputeII, bool bMatrixFlag, ScInterpreterContext* pContext )
: FormulaCompiler(bComputeII, bMatrixFlag),
rDoc(rCxt.getDoc()),
aPos(rPos),
mpFormatter(pContext ? pContext->GetFormatTable() : rDoc.GetFormatTable()),
mpInterpreterContext(pContext),
mrInterpreterContext(pContext ? *pContext : rDoc.GetNonThreadedContext()),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
pCharClass(&ScGlobal::getCharClass()),
@@ -1919,12 +1916,11 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
ScCompiler::ScCompiler( ScDocument& rDocument, const ScAddress& rPos,
formula::FormulaGrammar::Grammar eGrammar,
bool bComputeII, bool bMatrixFlag, const ScInterpreterContext* pContext )
bool bComputeII, bool bMatrixFlag, ScInterpreterContext* pContext )
: FormulaCompiler(bComputeII, bMatrixFlag),
rDoc( rDocument ),
aPos( rPos ),
mpFormatter(pContext ? pContext->GetFormatTable() : rDoc.GetFormatTable()),
mpInterpreterContext(pContext),
mrInterpreterContext(pContext ? *pContext : rDoc.GetNonThreadedContext()),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
nSrcPos(0),
@@ -3168,12 +3164,12 @@ bool ScCompiler::ParseValue( const OUString& rSym )
}
double fVal;
sal_uInt32 nIndex = mxSymbols->isEnglishLocale() ? mpFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) : 0;
sal_uInt32 nIndex = mxSymbols->isEnglishLocale() ? mrInterpreterContext.NFGetStandardIndex(LANGUAGE_ENGLISH_US) : 0;
if (!mpFormatter->IsNumberFormat(rSym, nIndex, fVal))
if (!mrInterpreterContext.NFIsNumberFormat(rSym, nIndex, fVal))
return false;
SvNumFormatType nType = mpFormatter->GetType(nIndex);
SvNumFormatType nType = mrInterpreterContext.NFGetType(nIndex);
// Don't accept 3:3 as time, it is a reference to entire row 3 instead.
// Dates should never be entered directly and automatically converted
@@ -5358,7 +5354,7 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu
ScAddress aAbs = rRef.toAbs(rDoc, aPos);
if (rDoc.HasStringData(aAbs.Col(), aAbs.Row(), aAbs.Tab()))
{
OUString aStr = rDoc.GetString(aAbs, mpInterpreterContext);
OUString aStr = rDoc.GetString(aAbs, &mrInterpreterContext);
// Enquote to SingleQuoted.
aStr = aStr.replaceAll(u"'", u"''");
rBuffer.append('\'');
@@ -5387,7 +5383,7 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu
{
SAL_WARN("sc.core", "ScCompiler::CreateStringFromSingleRef - TableRef falling back to cell: " <<
aAbs.Format( ScRefFlags::VALID | ScRefFlags::TAB_3D, &rDoc));
aStr = rDoc.GetString(aAbs, mpInterpreterContext);
aStr = rDoc.GetString(aAbs, &mrInterpreterContext);
}
else
{
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1c85074..34aaba8 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2128,7 +2128,7 @@ void ScInterpreter::ScIsLogical()
if (aCell.hasNumeric())
{
sal_uInt32 nFormat = GetCellNumberFormat(aAdr, aCell);
bRes = (pFormatter->GetType(nFormat) == SvNumFormatType::LOGICAL);
bRes = (mrContext.NFGetType(nFormat) == SvNumFormatType::LOGICAL);
}
}
}
@@ -2176,7 +2176,7 @@ void ScInterpreter::ScType()
case CELLTYPE_VALUE :
{
sal_uInt32 nFormat = GetCellNumberFormat(aAdr, aCell);
if (pFormatter->GetType(nFormat) == SvNumFormatType::LOGICAL)
if (mrContext.NFGetType(nFormat) == SvNumFormatType::LOGICAL)
nType = 4;
else
nType = 1;
@@ -2244,9 +2244,9 @@ static bool lcl_FormatHasOpenPar( const SvNumberformat* pFormat )
namespace {
void getFormatString(const SvNumberFormatter* pFormatter, sal_uLong nFormat, OUString& rFmtStr)
void getFormatString(const ScInterpreterContext& rContext, sal_uLong nFormat, OUString& rFmtStr)
{
rFmtStr = pFormatter->GetCalcCellReturn( nFormat);
rFmtStr = rContext.NFGetCalcCellReturn(nFormat);
}
}
@@ -2459,17 +2459,17 @@ void ScInterpreter::ScCell()
{ // specific format code for standard formats
OUString aFuncResult;
sal_uInt32 nFormat = mrDoc.GetNumberFormat( aCellPos );
getFormatString(pFormatter, nFormat, aFuncResult);
getFormatString(mrContext, nFormat, aFuncResult);
PushString( aFuncResult );
}
else if( aInfoType == "COLOR" )
{ // 1 = negative values are colored, otherwise 0
const SvNumberformat* pFormat = pFormatter->GetEntry( mrDoc.GetNumberFormat( aCellPos ) );
const SvNumberformat* pFormat = mrContext.NFGetFormatEntry( mrDoc.GetNumberFormat( aCellPos ) );
PushInt( lcl_FormatHasNegColor( pFormat ) ? 1 : 0 );
}
else if( aInfoType == "PARENTHESES" )
{ // 1 = format string contains a '(' character, otherwise 0
const SvNumberformat* pFormat = pFormatter->GetEntry( mrDoc.GetNumberFormat( aCellPos ) );
const SvNumberformat* pFormat = mrContext.NFGetFormatEntry( mrDoc.GetNumberFormat( aCellPos ) );
PushInt( lcl_FormatHasOpenPar( pFormat ) ? 1 : 0 );
}
else
@@ -2607,7 +2607,7 @@ void ScInterpreter::ScCellExternal()
{
OUString aFmtStr;
sal_uLong nFmt = aFmt.mbIsSet ? aFmt.mnIndex : 0;
getFormatString(pFormatter, nFmt, aFmtStr);
getFormatString(mrContext, nFmt, aFmtStr);
PushString(aFmtStr);
}
else if ( aInfoType == "COLOR" )
@@ -2616,7 +2616,7 @@ void ScInterpreter::ScCellExternal()
int nVal = 0;
if (aFmt.mbIsSet)
{
const SvNumberformat* pFormat = pFormatter->GetEntry(aFmt.mnIndex);
const SvNumberformat* pFormat = mrContext.NFGetFormatEntry(aFmt.mnIndex);
nVal = lcl_FormatHasNegColor(pFormat) ? 1 : 0;
}
PushInt(nVal);
@@ -2627,7 +2627,7 @@ void ScInterpreter::ScCellExternal()
int nVal = 0;
if (aFmt.mbIsSet)
{
const SvNumberformat* pFormat = pFormatter->GetEntry(aFmt.mnIndex);
const SvNumberformat* pFormat = mrContext.NFGetFormatEntry(aFmt.mnIndex);
nVal = lcl_FormatHasOpenPar(pFormat) ? 1 : 0;
}
PushInt(nVal);
@@ -3410,7 +3410,7 @@ void ScInterpreter::ScValue()
}
sal_uInt32 nFIndex = 0; // 0 for default locale
if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal))
if (mrContext.NFIsNumberFormat(aInputString, nFIndex, fVal))
PushDouble(fVal);
else
PushIllegalArgument();
@@ -5636,7 +5636,7 @@ void ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc )
}
else
{
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, pFormatter);
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, &mrContext);
if (rItem.meType == ScQueryEntry::ByString)
rParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
}
@@ -5930,7 +5930,7 @@ void ScInterpreter::ScCountIf()
}
else
{
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, pFormatter);
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, &mrContext);
if (rItem.meType == ScQueryEntry::ByString)
rParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
}
@@ -6242,7 +6242,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
}
else
{
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, pFormatter);
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, &mrContext);
if (rItem.meType == ScQueryEntry::ByString)
rParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
}
@@ -8571,7 +8571,7 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi
ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
sal_uInt32 nIndex = 0;
OUString aQueryStr = rItem.maString.getString();
bool bNumber = pFormatter->IsNumberFormat(
bool bNumber = mrContext.NFIsNumberFormat(
aQueryStr, nIndex, rItem.mfVal);
rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
@@ -9668,18 +9668,18 @@ void ScInterpreter::ScCurrency()
const Color* pColor = nullptr;
if ( fDec < 0.0 )
fDec = 0.0;
sal_uLong nIndex = pFormatter->GetStandardFormat(
sal_uLong nIndex = mrContext.NFGetStandardFormat(
SvNumFormatType::CURRENCY,
ScGlobal::eLnge);
if ( static_cast<sal_uInt16>(fDec) != pFormatter->GetFormatPrecision( nIndex ) )
if ( static_cast<sal_uInt16>(fDec) != mrContext.NFGetFormatPrecision( nIndex ) )
{
OUString sFormatString = pFormatter->GenerateFormat(
OUString sFormatString = mrContext.NFGenerateFormat(
nIndex,
ScGlobal::eLnge,
true, // with thousands separator
false, // not red
static_cast<sal_uInt16>(fDec));// decimal places
if (!pFormatter->GetPreviewString(sFormatString,
static_cast<sal_uInt16>(fDec));// decimal places
if (!mrContext.NFGetPreviewString(sFormatString,
fVal,
aStr,
&pColor,
@@ -9688,7 +9688,7 @@ void ScInterpreter::ScCurrency()
}
else
{
pFormatter->GetOutputString(fVal, nIndex, aStr, &pColor);
mrContext.NFGetOutputString(fVal, nIndex, aStr, &pColor);
}
PushString(aStr);
}
@@ -9767,16 +9767,16 @@ void ScInterpreter::ScFixed()
const Color* pColor = nullptr;
if (fDec < 0.0)
fDec = 0.0;
sal_uLong nIndex = pFormatter->GetStandardFormat(
sal_uLong nIndex = mrContext.NFGetStandardFormat(
SvNumFormatType::NUMBER,
ScGlobal::eLnge);
OUString sFormatString = pFormatter->GenerateFormat(
OUString sFormatString = mrContext.NFGenerateFormat(
nIndex,
ScGlobal::eLnge,
bThousand, // with thousands separator
false, // not red
static_cast<sal_uInt16>(fDec));// decimal places
if (!pFormatter->GetPreviewString(sFormatString,
if (!mrContext.NFGetPreviewString(sFormatString,
fVal,
aStr,
&pColor,
@@ -10503,7 +10503,7 @@ void ScInterpreter::ScText()
eCellLang = ScGlobal::eLnge;
if (bString)
{
if (!pFormatter->GetPreviewString( sFormatString, aStr.getString(),
if (!mrContext.NFGetPreviewString( sFormatString, aStr.getString(),
aResult, &pColor, eCellLang))
PushIllegalArgument();
else
@@ -10511,7 +10511,7 @@ void ScInterpreter::ScText()
}
else
{
if (!pFormatter->GetPreviewStringGuess( sFormatString, fVal,
if (!mrContext.NFGetPreviewStringGuess( sFormatString, fVal,
aResult, &pColor, eCellLang))
PushIllegalArgument();
else
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 61f88d6..2d87abe 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -64,7 +64,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1
bool bStrict )
{
if ( nYear < 100 && !bStrict )
nYear = pFormatter->ExpandTwoDigitYear( nYear );
nYear = mrContext.NFExpandTwoDigitYear( nYear );
// Do not use a default Date ctor here because it asks system time with a
// performance penalty.
sal_Int16 nY, nM, nD;
@@ -92,7 +92,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1
if (!bStrict)
aDate.AddDays( nDay - 1 );
if (aDate.IsValidAndGregorian())
return static_cast<double>(aDate - pFormatter->GetNullDate());
return static_cast<double>(aDate - mrContext.NFGetNullDate());
else
{
SetError(FormulaError::NoValue);
@@ -104,7 +104,7 @@ void ScInterpreter::ScGetActDate()
{
nFuncFmtType = SvNumFormatType::DATE;
Date aActDate( Date::SYSTEM );
tools::Long nDiff = aActDate - pFormatter->GetNullDate();
tools::Long nDiff = aActDate - mrContext.NFGetNullDate();
PushDouble(static_cast<double>(nDiff));
}
@@ -112,7 +112,7 @@ void ScInterpreter::ScGetActTime()
{
nFuncFmtType = SvNumFormatType::DATETIME;
DateTime aActTime( DateTime::SYSTEM );
tools::Long nDiff = aActTime - pFormatter->GetNullDate();
tools::Long nDiff = aActTime - mrContext.NFGetNullDate();
double fTime = aActTime.GetHour() / static_cast<double>(::tools::Time::hourPerDay) +
aActTime.GetMin() / static_cast<double>(::tools::Time::minutePerDay) +
aActTime.GetSec() / static_cast<double>(::tools::Time::secondPerDay) +
@@ -122,21 +122,21 @@ void ScInterpreter::ScGetActTime()
void ScInterpreter::ScGetYear()
{
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
PushDouble( static_cast<double>(aDate.GetYear()) );
}
void ScInterpreter::ScGetMonth()
{
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
PushDouble( static_cast<double>(aDate.GetMonth()) );
}
void ScInterpreter::ScGetDay()
{
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
PushDouble(static_cast<double>(aDate.GetDay()));
}
@@ -173,9 +173,9 @@ void ScInterpreter::ScGetDateValue()
OUString aInputString = GetString().getString();
sal_uInt32 nFIndex = 0; // for a default country/language
double fVal;
if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal))
if (mrContext.NFIsNumberFormat(aInputString, nFIndex, fVal))
{
SvNumFormatType eType = pFormatter->GetType(nFIndex);
SvNumFormatType eType = mrContext.NFGetType(nFIndex);
if (eType == SvNumFormatType::DATE || eType == SvNumFormatType::DATETIME)
{
nFuncFmtType = SvNumFormatType::DATE;
@@ -200,7 +200,7 @@ void ScInterpreter::ScGetDayOfWeek()
else
nFlag = 1;
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
int nVal = static_cast<int>(aDate.GetDayOfWeek()); // MONDAY = 0
switch (nFlag)
@@ -241,7 +241,7 @@ void ScInterpreter::ScWeeknumOOo()
{
sal_Int16 nFlag = GetInt16();
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
PushInt( static_cast<int>(aDate.GetWeekOfYear( nFlag == 1 ? SUNDAY : MONDAY )));
}
@@ -255,7 +255,7 @@ void ScInterpreter::ScGetWeekOfYear()
sal_Int16 nFlag = ( nParamCount == 1 ) ? 1 : GetInt16();
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
sal_Int32 nMinimumNumberOfDaysInWeek;
@@ -297,7 +297,7 @@ void ScInterpreter::ScGetIsoWeekOfYear()
{
if ( MustHaveParamCount( GetByte(), 1 ) )
{
Date aDate = pFormatter->GetNullDate();
Date aDate = mrContext.NFGetNullDate();
aDate.AddDays( GetFloor32());
PushInt( static_cast<int>(aDate.GetWeekOfYear()) );
}
@@ -316,7 +316,7 @@ void ScInterpreter::ScEasterSunday()
return;
}
if ( nYear < 100 )
nYear = pFormatter->ExpandTwoDigitYear( nYear );
nYear = mrContext.NFExpandTwoDigitYear( nYear );
if (nYear < 1583 || nYear > 9956)
{
// Valid Gregorian and maximum year constraints not met.
@@ -508,7 +508,7 @@ void ScInterpreter::ScNetWorkdays( bool bOOXML_Version )
vector<double> nSortArray;
bool bWeekendMask[ 7 ];
const Date& rNullDate = pFormatter->GetNullDate();
const Date& rNullDate = mrContext.NFGetNullDate();
sal_uInt32 nNullDate = Date::DateToDays( rNullDate.GetDay(), rNullDate.GetMonth(), rNullDate.GetYear() );
FormulaError nErr;
if ( bOOXML_Version )
@@ -565,7 +565,7 @@ void ScInterpreter::ScWorkday_MS()
nFuncFmtType = SvNumFormatType::DATE;
vector<double> nSortArray;
bool bWeekendMask[ 7 ];
const Date& rNullDate = pFormatter->GetNullDate();
const Date& rNullDate = mrContext.NFGetNullDate();
sal_uInt32 nNullDate = Date::DateToDays( rNullDate.GetDay(), rNullDate.GetMonth(), rNullDate.GetYear() );
FormulaError nErr = GetWeekendAndHolidayMasks_MS( nParamCount, nNullDate,
nSortArray, bWeekendMask, true );
@@ -721,9 +721,9 @@ void ScInterpreter::ScGetDiffDate360()
}
else
nSign = 1;
Date aDate1 = pFormatter->GetNullDate();
Date aDate1 = mrContext.NFGetNullDate();
aDate1.AddDays( nDate1);
Date aDate2 = pFormatter->GetNullDate();
Date aDate2 = mrContext.NFGetNullDate();
aDate2.AddDays( nDate2);
if (aDate1.GetDay() == 31)
aDate1.AddDays( -1);
@@ -795,12 +795,12 @@ void ScInterpreter::ScGetDateDif()
// split dates in day, month, year for use with formats other than "d"
sal_uInt16 d1, m1, d2, m2;
sal_Int16 y1, y2;
Date aDate1( pFormatter->GetNullDate());
Date aDate1( mrContext.NFGetNullDate());
aDate1.AddDays( nDate1);
y1 = aDate1.GetYear();
m1 = aDate1.GetMonth();
d1 = aDate1.GetDay();
Date aDate2( pFormatter->GetNullDate());
Date aDate2( mrContext.NFGetNullDate());
aDate2.AddDays( nDate2);
y2 = aDate2.GetYear();
m2 = aDate2.GetMonth();
@@ -916,9 +916,9 @@ void ScInterpreter::ScGetTimeValue()
OUString aInputString = GetString().getString();
sal_uInt32 nFIndex = 0; // damit default Land/Spr.
double fVal;
if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal, SvNumInputOptions::LAX_TIME))
if (mrContext.NFIsNumberFormat(aInputString, nFIndex, fVal, SvNumInputOptions::LAX_TIME))
{
SvNumFormatType eType = pFormatter->GetType(nFIndex);
SvNumFormatType eType = mrContext.NFGetType(nFIndex);
if (eType == SvNumFormatType::TIME || eType == SvNumFormatType::DATETIME)
{
nFuncFmtType = SvNumFormatType::TIME;
@@ -3638,12 +3638,12 @@ void ScInterpreter::ScGetPivotData()
if (nCurFmtType == SvNumFormatType::UNDEFINED)
nNumFormat = 0;
else
nNumFormat = pFormatter->GetStandardFormat( nCurFmtType, ScGlobal::eLnge);
nNumFormat = mrContext.NFGetStandardFormat( nCurFmtType, ScGlobal::eLnge);
}
const Color* pColor;
pFormatter->GetOutputString( fDouble, nNumFormat, aFilters[i].MatchValueName, &pColor);
mrContext.NFGetOutputString( fDouble, nNumFormat, aFilters[i].MatchValueName, &pColor);
aFilters[i].MatchValue = ScDPCache::GetLocaleIndependentFormattedString(
fDouble, *pFormatter, nNumFormat);
fDouble, mrContext, nNumFormat);
}
else
{
@@ -3653,9 +3653,9 @@ void ScInterpreter::ScGetPivotData()
// locale independent as MatchValue.
sal_uInt32 nNumFormat = 0;
double fValue;
if (pFormatter->IsNumberFormat( aFilters[i].MatchValueName, nNumFormat, fValue))
if (mrContext.NFIsNumberFormat( aFilters[i].MatchValueName, nNumFormat, fValue))
aFilters[i].MatchValue = ScDPCache::GetLocaleIndependentFormattedString(
fValue, *pFormatter, nNumFormat);
fValue, mrContext, nNumFormat);
else
aFilters[i].MatchValue = aFilters[i].MatchValueName;
}
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index f31e3526..492ef24b 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -165,7 +165,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr )
{
FormulaError nError = FormulaError::NONE;
double fValue = ScGlobal::ConvertStringToValue( rStr, maCalcConfig, nError, mnStringNoValueError,
pFormatter, nCurFmtType);
mrContext, nCurFmtType);
if (nError != FormulaError::NONE)
SetError(nError);
return fValue;
@@ -173,7 +173,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr )
double ScInterpreter::ConvertStringToValue( const OUString& rStr, FormulaError& rError, SvNumFormatType& rCurFmtType )
{
return ScGlobal::ConvertStringToValue( rStr, maCalcConfig, rError, mnStringNoValueError, pFormatter, rCurFmtType);
return ScGlobal::ConvertStringToValue( rStr, maCalcConfig, rError, mnStringNoValueError, mrContext, rCurFmtType);
}
double ScInterpreter::GetCellValue( const ScAddress& rPos, ScRefCellValue& rCell )
@@ -223,7 +223,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue&
{
fValue = rCell.getDouble();
nCurFmtIndex = mrDoc.GetNumberFormat( mrContext, rPos );
nCurFmtType = mrContext.GetNumberFormatType( nCurFmtIndex );
nCurFmtType = mrContext.NFGetType(nCurFmtIndex);
if ( bCalcAsShown && fValue != 0.0 )
fValue = mrDoc.RoundValueAsShown( fValue, nCurFmtIndex, &mrContext );
}
@@ -2436,7 +2436,7 @@ svl::SharedString ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat)
; // nothing
else if ( !pJumpMatrix )
{
return pMat->GetString( *pFormatter, 0, 0);
return pMat->GetString( mrContext, 0, 0);
}
else
{
@@ -2445,7 +2445,7 @@ svl::SharedString ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat)
pJumpMatrix->GetPos( nC, nR);
// Use vector replication for single row/column arrays.
if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
return pMat->GetString( *pFormatter, nC, nR);
return pMat->GetString( mrContext, nC, nR);
SetError( FormulaError::NoValue);
}
@@ -2515,11 +2515,11 @@ ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix(
svl::SharedString ScInterpreter::GetStringFromDouble( double fVal )
{
sal_uLong nIndex = pFormatter->GetStandardFormat(
sal_uLong nIndex = mrContext.NFGetStandardFormat(
SvNumFormatType::NUMBER,
ScGlobal::eLnge);
OUString aStr;
pFormatter->GetInputLineString(fVal, nIndex, aStr);
mrContext.NFGetInputLineString(fVal, nIndex, aStr);
return mrStrPool.intern(aStr);
}
@@ -2907,7 +2907,7 @@ void ScInterpreter::ScExternal()
}
break;
case svMatrix:
if (!ScRangeToSequence::FillStringArray( aParam, PopMatrix().get(), pFormatter ))
if (!ScRangeToSequence::FillStringArray( aParam, PopMatrix().get(), mrContext ))
SetError(FormulaError::IllegalParameter);
break;
default:
@@ -3831,7 +3831,6 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument& rDoc, ScInterpre
, mrStrPool(rDoc.GetSharedStringPool())
, pJumpMatrix(nullptr)
, pMyFormulaCell(pCell)
, pFormatter(rContext.GetFormatTable())
, pCur(nullptr)
, nGlobalError(FormulaError::NONE)
, sp(0)
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index f091e72..1ee3b72 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1176,7 +1176,7 @@ ScMatrixRef ScInterpreter::MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef
ScMatrixRef xResMat = GetNewMat(nMinC, nMinR, /*bEmpty*/true);
if (xResMat)
{
xResMat->MatConcat(nMinC, nMinR, pMat1, pMat2, *pFormatter, mrDoc.GetSharedStringPool());
xResMat->MatConcat(nMinC, nMinR, pMat1, pMat2, mrContext, mrDoc.GetSharedStringPool());
}
return xResMat;
}
@@ -1420,7 +1420,7 @@ void ScInterpreter::ScAmpersand()
pResMat->PutError( nErr, i, j);
else
{
OUString aTmp = sStr + pMat->GetString(*pFormatter, i, j).getString();
OUString aTmp = sStr + pMat->GetString(mrContext, i, j).getString();
pResMat->PutString(mrStrPool.intern(aTmp), i, j);
}
}
@@ -1435,7 +1435,7 @@ void ScInterpreter::ScAmpersand()
pResMat->PutError( nErr, i, j);
else
{
OUString aTmp = pMat->GetString(*pFormatter, i, j).getString() + sStr;
OUString aTmp = pMat->GetString(mrContext, i, j).getString() + sStr;
pResMat->PutString(mrStrPool.intern(aTmp), i, j);
}
}
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 8c6cfb4..2d6a38a 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -779,7 +779,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
nFuncFmtIndex = aAction.getNumberFormat();
}
nFuncFmtType = mrContext.GetNumberFormatType( nFuncFmtIndex );
nFuncFmtType = mrContext.NFGetType(nFuncFmtIndex);
}
else
{
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index 8d3f7c2..1c53c7b 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -79,7 +79,7 @@ namespace {
class ScETSForecastCalculation
{
private:
SvNumberFormatter* mpFormatter;
const ScInterpreterContext& mrContext;
std::vector< DataPoint > maRange; // data (X, Y)
std::unique_ptr<double[]> mpBase; // calculated base value array
std::unique_ptr<double[]> mpTrend; // calculated trend factor array
@@ -121,7 +121,7 @@ private:
double convertXtoMonths( double x );
public:
ScETSForecastCalculation( SCSIZE nSize, SvNumberFormatter* pFormatter );
ScETSForecastCalculation( SCSIZE nSize, const ScInterpreterContext& rContext );
bool PreprocessDataRange( const ScMatrixRef& rMatX, const ScMatrixRef& rMatY, int nSmplInPrd,
bool bDataCompletion, int nAggregation, const ScMatrixRef& rTMat,
@@ -136,8 +136,8 @@ public:
}
ScETSForecastCalculation::ScETSForecastCalculation( SCSIZE nSize, SvNumberFormatter* pFormatter )
: mpFormatter(pFormatter)
ScETSForecastCalculation::ScETSForecastCalculation( SCSIZE nSize, const ScInterpreterContext& rContext )
: mrContext(rContext)
, mnSmplInPrd(0)
, mfStepSize(0.0)
, mfAlpha(0.0)
@@ -197,7 +197,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
// Method: assume there is an month interval and verify.
// If month interval is used, replace maRange.X with month values
// for ease of calculations.
Date aNullDate = mpFormatter->GetNullDate();
Date aNullDate = mrContext.NFGetNullDate();
Date aDate = aNullDate + static_cast< sal_Int32 >( maRange[ 0 ].X );
mnMonthDay = aDate.GetDay();
for ( SCSIZE i = 1; i < mnCount && mnMonthDay; i++ )
@@ -820,7 +820,7 @@ void ScETSForecastCalculation::refill()
double ScETSForecastCalculation::convertXtoMonths( double x )
{
Date aDate = mpFormatter->GetNullDate() + static_cast< sal_Int32 >( x );
Date aDate = mrContext.NFGetNullDate() + static_cast< sal_Int32 >( x );
int nYear = aDate.GetYear();
int nMonth = aDate.GetMonth();
double fMonthLength;
@@ -1310,7 +1310,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
}
}
ScETSForecastCalculation aETSCalc( pMatX->GetElementCount(), pFormatter );
ScETSForecastCalculation aETSCalc( pMatX->GetElementCount(), mrContext);
if ( !aETSCalc.PreprocessDataRange( pMatX, pMatY, nSmplInPrd, bDataCompletion,
nAggregation,
( eETSType != etsStatAdd && eETSType != etsStatMult ? pTMat : nullptr ),
@@ -1484,7 +1484,7 @@ void ScInterpreter::ScConcat_MS()
{
if ( pMat->IsValue( j, k ) )
{
OUString aStr = pMat->GetString( *pFormatter, j, k ).getString();
OUString aStr = pMat->GetString( mrContext, j, k ).getString();
if (CheckStringResultLen(aResBuf, aStr.getLength()))
aResBuf.append(aStr);
}
@@ -1602,7 +1602,7 @@ void ScInterpreter::ScTextJoin_MS()
else if (pMat->IsStringOrEmpty( j, k ))
aDelimiters.push_back( pMat->GetString( j, k ).getString() );
else if (pMat->IsValue( j, k ))
aDelimiters.push_back( pMat->GetString( *pFormatter, j, k ).getString() );
aDelimiters.push_back( pMat->GetString( mrContext, j, k ).getString() );
else
{
assert(!"should this really happen?");
@@ -1771,7 +1771,7 @@ void ScInterpreter::ScTextJoin_MS()
else if (pMat->IsStringOrEmpty( j, k ))
aStr = pMat->GetString( j, k ).getString();
else if (pMat->IsValue( j, k ))
aStr = pMat->GetString( *pFormatter, j, k ).getString();
aStr = pMat->GetString( mrContext, j, k ).getString();
else
{
assert(!"should this really happen?");
diff --git a/sc/source/core/tool/interpretercontext.cxx b/sc/source/core/tool/interpretercontext.cxx
index e39710c..6bd903d 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -41,6 +41,12 @@ ScInterpreterContext::ScInterpreterContext(const ScDocument& rDoc, SvNumberForma
, pInterpreter(nullptr)
, mpFormatter(pFormatter)
{
if (pFormatter)
{
mxLanguageData.reset(new SvNFLanguageData(pFormatter->GetROLanguageData()));
mpFormatData = &pFormatter->GetROFormatData();
maROPolicy = SvNFEngine::GetROPolicy(*mpFormatData);
}
}
ScInterpreterContext::~ScInterpreterContext() { ResetTokens(); }
@@ -64,16 +70,24 @@ void ScInterpreterContext::SetDocAndFormatter(const ScDocument& rDoc, SvNumberFo
}
if (mpFormatter != pFormatter)
{
maNFBuiltInCache.clear();
maNFTypeCache.clear();
// formatter has changed
mxLanguageData.reset(new SvNFLanguageData(pFormatter->GetROLanguageData()));
mpFormatData = &pFormatter->GetROFormatData();
maROPolicy = SvNFEngine::GetROPolicy(*mpFormatData);
mpFormatter = pFormatter;
// drop cache
std::fill(maNFBuiltInCache.begin(), maNFBuiltInCache.end(), NFBuiltIn());
std::fill(maNFTypeCache.begin(), maNFTypeCache.end(), NFType());
}
}
void ScInterpreterContext::initFormatTable()
{
assert(!mpFormatter && maNFBuiltInCache.empty() && maNFTypeCache.empty());
mpFormatter = mpDoc->GetFormatTable(); // will assert if not main thread
mpFormatData = &mpFormatter->GetROFormatData();
maROPolicy = SvNFEngine::GetROPolicy(*mpFormatData);
mxLanguageData.reset(new SvNFLanguageData(mpFormatter->GetROLanguageData()));
}
void ScInterpreterContext::Cleanup()
@@ -90,43 +104,236 @@ void ScInterpreterContext::ClearLookupCache(const ScDocument* pDoc)
mxScLookupCache.reset();
}
SvNumFormatType ScInterpreterContext::GetNumberFormatType(sal_uInt32 nFIndex) const
SvNumFormatType ScInterpreterContext::NFGetType(sal_uInt32 nFIndex) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return mpFormatter->GetType(nFIndex);
return GetFormatTable()->GetType(nFIndex);
// Search/update cache by attempting to find nFIndex by inserting a new entry
auto result = maNFTypeCache.insert(NFType{ nFIndex, SvNumFormatType::ALL });
if (!result.second) // already exists, so return that SvNumFormatType
return result.first->eType;
auto aFind = std::find_if(maNFTypeCache.begin(), maNFTypeCache.end(),
[nFIndex](const NFType& e) { return e.nKey == nFIndex; });
if (aFind != maNFTypeCache.end())
return aFind->eType;
// Didn't exist, overwrite the placeholder SvNumFormatType::ALL with the real type
SvNumFormatType eType = mpFormatter->GetType(nFIndex);
result.first->eType = eType;
SvNumFormatType eType = mpFormatData->GetType(nFIndex);
std::move_backward(maNFTypeCache.begin(),
std::next(maNFTypeCache.begin(), maNFTypeCache.size() - 1),
maNFTypeCache.end());
maNFTypeCache[0].nKey = nFIndex;
maNFTypeCache[0].eType = eType;
return eType;
}
sal_uInt32 ScInterpreterContext::GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat,
LanguageType eLnge) const
const SvNumberformat* ScInterpreterContext::NFGetFormatEntry(sal_uInt32 nKey) const
{
if (!mpFormatter)
return nFormat;
if (!mpDoc->IsThreadedGroupCalcInProgress())
return mpFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLnge);
return GetFormatTable()->GetEntry(nKey);
return mpFormatData->GetFormatEntry(nKey);
}
bool ScInterpreterContext::NFIsTextFormat(sal_uInt32 nFIndex) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->IsTextFormat(nFIndex);
return mpFormatData->IsTextFormat(nFIndex);
}
const Date& ScInterpreterContext::NFGetNullDate() const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetNullDate();
return mxLanguageData->GetNullDate();
}
sal_uInt32 ScInterpreterContext::NFGetTimeFormat(double fNumber, LanguageType eLnge,
bool bForceDuration) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetTimeFormat(fNumber, eLnge, bForceDuration);
return SvNFEngine::GetTimeFormat(*mxLanguageData, *mpFormatData, nullptr, maROPolicy, fNumber,
eLnge, bForceDuration);
}
sal_uInt32 ScInterpreterContext::NFGetFormatIndex(NfIndexTableOffset nTabOff,
LanguageType eLnge) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetFormatIndex(nTabOff, eLnge);
return SvNFEngine::GetFormatIndex(*mxLanguageData, maROPolicy, nullptr, nTabOff, eLnge);
}
OUString ScInterpreterContext::NFGetFormatDecimalSep(sal_uInt32 nFormat) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetFormatDecimalSep(nFormat);
return SvNFEngine::GetFormatDecimalSep(*mxLanguageData, *mpFormatData, nFormat);
}
sal_uInt16 ScInterpreterContext::NFGetFormatPrecision(sal_uInt32 nFormat) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetFormatPrecision(nFormat);
return SvNFEngine::GetFormatPrecision(*mxLanguageData, *mpFormatData, nFormat);
}
sal_uInt32 ScInterpreterContext::NFGetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat,
LanguageType eLnge) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetFormatForLanguageIfBuiltIn(nFormat, eLnge);
sal_uInt64 nKey = (static_cast<sal_uInt64>(nFormat) << 32) | eLnge.get();
// Search/update cache by attempting to find nFormat+eLnge by inserting a new entry
auto result = maNFBuiltInCache.insert(NFBuiltIn{ nKey, 0 });
if (!result.second) // already exists, so return that dest Format
return result.first->nFormat;
// Didn't exist, overwrite the placeholder zero with the real format
nFormat = mpFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLnge);
result.first->nFormat = nFormat;
auto aFind = std::find_if(maNFBuiltInCache.begin(), maNFBuiltInCache.end(),
[nKey](const NFBuiltIn& e) { return e.nKey == nKey; });
if (aFind != maNFBuiltInCache.end())
return aFind->nFormat;
nFormat = SvNFEngine::GetFormatForLanguageIfBuiltIn(*mxLanguageData, nullptr, maROPolicy,
nFormat, eLnge);
std::move_backward(maNFBuiltInCache.begin(),
std::next(maNFBuiltInCache.begin(), maNFBuiltInCache.size() - 1),
maNFBuiltInCache.end());
maNFBuiltInCache[0].nKey = nKey;
maNFBuiltInCache[0].nFormat = nFormat;
return nFormat;
}
sal_uInt32 ScInterpreterContext::NFGetStandardFormat(SvNumFormatType eType, LanguageType eLnge)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetStandardFormat(eType, eLnge);
return SvNFEngine::GetStandardFormat(*mxLanguageData, *mpFormatData, nullptr, maROPolicy, eType,
eLnge);
}
sal_uInt32 ScInterpreterContext::NFGetStandardFormat(sal_uInt32 nFIndex, SvNumFormatType eType,
LanguageType eLnge)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetStandardFormat(nFIndex, eType, eLnge);
return SvNFEngine::GetStandardFormat(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
nFIndex, eType, eLnge);
}
sal_uInt32 ScInterpreterContext::NFGetStandardFormat(double fNumber, sal_uInt32 nFIndex,
SvNumFormatType eType, LanguageType eLnge)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetStandardFormat(fNumber, nFIndex, eType, eLnge);
return SvNFEngine::GetStandardFormat(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
fNumber, nFIndex, eType, eLnge);
}
void ScInterpreterContext::NFGetInputLineString(const double& fOutNumber, sal_uInt32 nFIndex,
OUString& rOutString, bool bFiltering,
bool bForceSystemLocale) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetInputLineString(fOutNumber, nFIndex, rOutString, bFiltering,
bForceSystemLocale);
return SvNFEngine::GetInputLineString(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
fOutNumber, nFIndex, rOutString, bFiltering,
bForceSystemLocale);
}
void ScInterpreterContext::NFGetOutputString(const double& fOutNumber, sal_uInt32 nFIndex,
OUString& sOutString, const Color** ppColor,
bool bUseStarFormat) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetOutputString(fOutNumber, nFIndex, sOutString, ppColor,
bUseStarFormat);
return SvNFEngine::GetOutputString(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
fOutNumber, nFIndex, sOutString, ppColor, bUseStarFormat);
}
void ScInterpreterContext::NFGetOutputString(const OUString& sString, sal_uInt32 nFIndex,
OUString& sOutString, const Color** ppColor,
bool bUseStarFormat) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetOutputString(sString, nFIndex, sOutString, ppColor,
bUseStarFormat);
return SvNFEngine::GetOutputString(*mxLanguageData, *mpFormatData, sString, nFIndex, sOutString,
ppColor, bUseStarFormat);
}
sal_uInt32 ScInterpreterContext::NFGetStandardIndex(LanguageType eLnge) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetStandardIndex(eLnge);
return SvNFEngine::GetStandardIndex(*mxLanguageData, *mpFormatData, nullptr, maROPolicy, eLnge);
}
bool ScInterpreterContext::NFGetPreviewString(const OUString& sFormatString, double fPreviewNumber,
OUString& sOutString, const Color** ppColor,
LanguageType eLnge)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetPreviewString(sFormatString, fPreviewNumber, sOutString,
ppColor, eLnge);
return SvNFEngine::GetPreviewString(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
sFormatString, fPreviewNumber, sOutString, ppColor, eLnge,
false);
}
bool ScInterpreterContext::NFGetPreviewString(const OUString& sFormatString,
const OUString& sPreviewString, OUString& sOutString,
const Color** ppColor, LanguageType eLnge)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetPreviewString(sFormatString, sPreviewString, sOutString,
ppColor, eLnge);
return SvNFEngine::GetPreviewString(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
sFormatString, sPreviewString, sOutString, ppColor, eLnge);
}
bool ScInterpreterContext::NFGetPreviewStringGuess(const OUString& sFormatString,
double fPreviewNumber, OUString& sOutString,
const Color** ppColor, LanguageType eLnge)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetPreviewStringGuess(sFormatString, fPreviewNumber, sOutString,
ppColor, eLnge);
return SvNFEngine::GetPreviewStringGuess(*mxLanguageData, *mpFormatData, nullptr, maROPolicy,
sFormatString, fPreviewNumber, sOutString, ppColor,
eLnge);
}
OUString ScInterpreterContext::NFGenerateFormat(sal_uInt32 nIndex, LanguageType eLnge,
bool bThousand, bool bIsRed, sal_uInt16 nPrecision,
sal_uInt16 nLeadingCnt)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GenerateFormat(nIndex, eLnge, bThousand, bIsRed, nPrecision,
nLeadingCnt);
return SvNFEngine::GenerateFormat(*mxLanguageData, *mpFormatData, nullptr, maROPolicy, nIndex,
eLnge, bThousand, bIsRed, nPrecision, nLeadingCnt);
}
OUString ScInterpreterContext::NFGetCalcCellReturn(sal_uInt32 nFormat) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->GetCalcCellReturn(nFormat);
return mpFormatData->GetCalcCellReturn(nFormat);
}
sal_uInt16 ScInterpreterContext::NFExpandTwoDigitYear(sal_uInt16 nYear) const
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->ExpandTwoDigitYear(nYear);
return mxLanguageData->ExpandTwoDigitYear(nYear);
}
bool ScInterpreterContext::NFIsNumberFormat(const OUString& sString, sal_uInt32& F_Index,
double& fOutNumber, SvNumInputOptions eInputOptions)
{
if (!mpDoc->IsThreadedGroupCalcInProgress())
return GetFormatTable()->IsNumberFormat(sString, F_Index, fOutNumber, eInputOptions);
return SvNFEngine::IsNumberFormat(*mxLanguageData, *mpFormatData, nullptr, maROPolicy, sString,
F_Index, fOutNumber, eInputOptions);
}
/* ScInterpreterContextPool */
// Threaded version
@@ -202,6 +409,15 @@ void ScInterpreterContextPool::ClearLookupCaches(const ScDocument* pDoc)
rPtr->ClearLookupCache(pDoc);
}
// static
void ScInterpreterContextPool::ModuleExiting()
{
for (auto& rPtr : aThreadedInterpreterPool.maPool)
rPtr->mxLanguageData.reset();
for (auto& rPtr : aNonThreadedInterpreterPool.maPool)
rPtr->mxLanguageData.reset();
}
/* ScThreadedInterpreterContextGetterGuard */
ScThreadedInterpreterContextGetterGuard::ScThreadedInterpreterContextGetterGuard(
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 286a1ef..f270488 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -18,6 +18,7 @@
*/
#include <memory>
#include <interpretercontext.hxx>
#include <queryparam.hxx>
#include <queryentry.hxx>
#include <scmatrix.hxx>
@@ -202,7 +203,7 @@ void ScQueryParamBase::Resize(size_t nNew)
}
void ScQueryParamBase::FillInExcelSyntax(
svl::SharedStringPool& rPool, const OUString& rCellStr, SCSIZE nIndex, SvNumberFormatter* pFormatter )
svl::SharedStringPool& rPool, const OUString& rCellStr, SCSIZE nIndex, ScInterpreterContext* pContext )
{
if (nIndex >= m_Entries.size())
Resize(nIndex+1);
@@ -265,10 +266,10 @@ void ScQueryParamBase::FillInExcelSyntax(
}
}
if (!pFormatter)
if (!pContext)
return;
/* TODO: pFormatter currently is also used as a flag whether matching
/* TODO: pContext currently is also used as a flag whether matching
* empty cells with an empty string is triggered from the interpreter.
* This could be handled independently if all queries should support
* it, needs to be evaluated if that actually is desired. */
@@ -291,7 +292,7 @@ void ScQueryParamBase::FillInExcelSyntax(
else
{
sal_uInt32 nFormat = 0;
bool bNumber = pFormatter->IsNumberFormat( rItem.maString.getString(), nFormat, rItem.mfVal);
bool bNumber = pContext->NFIsNumberFormat( rItem.maString.getString(), nFormat, rItem.mfVal);
rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
}
}
diff --git a/sc/source/core/tool/rangecache.cxx b/sc/source/core/tool/rangecache.cxx
index f42d368..d588aaf 100644
--- a/sc/source/core/tool/rangecache.cxx
+++ b/sc/source/core/tool/rangecache.cxx
@@ -109,7 +109,7 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange,
return; // substring matching cannot be sorted
sal_uInt32 format = 0;
double value;
if (context->GetFormatTable()->IsNumberFormat(cell.getString(pDoc), format, value))
if (context->NFIsNumberFormat(cell.getString(pDoc), format, value))
return;
}
}
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 75652b7..bd71358 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -197,8 +197,7 @@ bool ScRangeToSequence::FillStringArray( uno::Any& rAny, ScDocument& rDoc, const
return !bHasErrors;
}
bool ScRangeToSequence::FillStringArray( uno::Any& rAny, const ScMatrix* pMatrix,
SvNumberFormatter* pFormatter )
bool ScRangeToSequence::FillStringArray(uno::Any& rAny, const ScMatrix* pMatrix, ScInterpreterContext& rContext)
{
if (!pMatrix)
return false;
@@ -221,11 +220,11 @@ bool ScRangeToSequence::FillStringArray( uno::Any& rAny, const ScMatrix* pMatrix
if ( !pMatrix->IsEmpty( nCol, nRow ) )
aStr = pMatrix->GetString(nCol, nRow).getString();
}
else if ( pFormatter )
else
{
double fVal = pMatrix->GetDouble( nCol, nRow );
const Color* pColor;
pFormatter->GetOutputString( fVal, 0, aStr, &pColor );
rContext.NFGetOutputString( fVal, 0, aStr, &pColor );
}
pColAry[nCol] = aStr;
}
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 698c06b..809fd49 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -278,7 +278,7 @@ public:
double GetDoubleWithStringConversion(SCSIZE nC, SCSIZE nR) const;
svl::SharedString GetString(SCSIZE nC, SCSIZE nR) const;
svl::SharedString GetString( SCSIZE nIndex) const;
svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const;
svl::SharedString GetString( ScInterpreterContext& rContext, SCSIZE nC, SCSIZE nR) const;
ScMatrixValue Get(SCSIZE nC, SCSIZE nR) const;
bool IsStringOrEmpty( SCSIZE nIndex ) const;
bool IsStringOrEmpty( SCSIZE nC, SCSIZE nR ) const;
@@ -339,7 +339,7 @@ public:
ScMatrix::IterateResultMultiple<tRes> ApplyCollectOperation(const std::vector<T>& aOp);
void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2,
SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool);
ScInterpreterContext& rContext, svl::SharedStringPool& rPool);
void ExecuteBinaryOp(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrix& rInputMat1, const ScMatrix& rInputMat2,
ScInterpreter* pInterpreter, const ScMatrix::CalculateOpFunction& op);
@@ -718,7 +718,7 @@ svl::SharedString ScMatrixImpl::GetString( SCSIZE nIndex) const
return GetString(nC, nR);
}
svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const
svl::SharedString ScMatrixImpl::GetString( ScInterpreterContext& rContext, SCSIZE nC, SCSIZE nR) const
{
if (!ValidColRowOrReplicated( nC, nR ))
{
@@ -739,11 +739,11 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE
return svl::SharedString::getEmptyString();
// result of empty FALSE jump path
sal_uInt32 nKey = rFormatter.GetStandardFormat( SvNumFormatType::LOGICAL,
sal_uInt32 nKey = rContext.NFGetStandardFormat( SvNumFormatType::LOGICAL,
ScGlobal::eLnge);
OUString aStr;
const Color* pColor = nullptr;
rFormatter.GetOutputString( 0.0, nKey, aStr, &pColor);
rContext.NFGetOutputString( 0.0, nKey, aStr, &pColor);
return svl::SharedString( aStr); // string not interned
}
case mdds::mtm::element_numeric:
@@ -761,10 +761,10 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE
return svl::SharedString( ScGlobal::GetErrorString( nError)); // string not interned
}
sal_uInt32 nKey = rFormatter.GetStandardFormat( SvNumFormatType::NUMBER,
sal_uInt32 nKey = rContext.NFGetStandardFormat( SvNumFormatType::NUMBER,
ScGlobal::eLnge);
OUString aStr;
rFormatter.GetInputLineString( fVal, nKey, aStr);
rContext.NFGetInputLineString( fVal, nKey, aStr);
return svl::SharedString( aStr); // string not interned
}
@@ -2676,14 +2676,14 @@ size_t get_index(SCSIZE nMaxRow, size_t nRow, size_t nCol, size_t nRowOffset, si
}
void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2,
SvNumberFormatter& rFormatter, svl::SharedStringPool& rStringPool)
ScInterpreterContext& rContext, svl::SharedStringPool& rStringPool)
{
SCSIZE nC1, nC2;
SCSIZE nR1, nR2;
xMat1->GetDimensions(nC1, nR1);
xMat2->GetDimensions(nC2, nR2);
sal_uInt32 nKey = rFormatter.GetStandardFormat( SvNumFormatType::NUMBER,
sal_uInt32 nKey = rContext.NFGetStandardFormat( SvNumFormatType::NUMBER,
ScGlobal::eLnge);
std::vector<OUString> aString(nMaxCol * nMaxRow);
@@ -2703,7 +2703,7 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef&
return;
}
OUString aStr;
rFormatter.GetInputLineString( nVal, nKey, aStr);
rContext.NFGetInputLineString( nVal, nKey, aStr);
aString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] = aString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] + aStr;
};
@@ -2711,7 +2711,7 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef&
[&](size_t nRow, size_t nCol, bool nVal)
{
OUString aStr;
rFormatter.GetInputLineString( nVal ? 1.0 : 0.0, nKey, aStr);
rContext.NFGetInputLineString( nVal ? 1.0 : 0.0, nKey, aStr);
aString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] = aString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] + aStr;
};
@@ -2765,7 +2765,7 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef&
return;
}
OUString aStr;
rFormatter.GetInputLineString( nVal, nKey, aStr);
rContext.NFGetInputLineString( nVal, nKey, aStr);
aSharedString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] = rStringPool.intern(aString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] + aStr);
};
@@ -2773,7 +2773,7 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef&
[&](size_t nRow, size_t nCol, bool nVal)
{
OUString aStr;
rFormatter.GetInputLineString( nVal ? 1.0 : 0.0, nKey, aStr);
rContext.NFGetInputLineString( nVal ? 1.0 : 0.0, nKey, aStr);
aSharedString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] = rStringPool.intern(aString[get_index(nMaxRow, nRow, nCol, nRowOffset, nColOffset)] + aStr);
};
@@ -3287,9 +3287,9 @@ svl::SharedString ScMatrix::GetString( SCSIZE nIndex) const
return pImpl->GetString(nIndex);
}
svl::SharedString ScMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const
svl::SharedString ScMatrix::GetString( ScInterpreterContext& rContext, SCSIZE nC, SCSIZE nR) const
{
return pImpl->GetString(rFormatter, nC, nR);
return pImpl->GetString(rContext, nC, nR);
}
ScMatrixValue ScMatrix::Get(SCSIZE nC, SCSIZE nR) const
@@ -3667,9 +3667,9 @@ void ScMatrix::Dump() const
#endif
void ScMatrix::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow,
const ScMatrixRef& xMat1, const ScMatrixRef& xMat2, SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool)
const ScMatrixRef& xMat1, const ScMatrixRef& xMat2, ScInterpreterContext& rContext, svl::SharedStringPool& rPool)
{
pImpl->MatConcat(nMaxCol, nMaxRow, xMat1, xMat2, rFormatter, rPool);
pImpl->MatConcat(nMaxCol, nMaxRow, xMat1, xMat2, rContext, rPool);
}
void ScMatrix::ExecuteBinaryOp(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrix& rInputMat1, const ScMatrix& rInputMat2,
diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index 8a43638..384a4ca 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <interpretercontext.hxx>
#include <stringutil.hxx>
#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
@@ -428,7 +429,7 @@ bool ScStringUtil::isMultiline( std::u16string_view rStr )
}
ScInputStringType ScStringUtil::parseInputString(
SvNumberFormatter& rFormatter, const OUString& rStr, LanguageType eLang )
ScInterpreterContext& rContext, const OUString& rStr, LanguageType eLang )
{
ScInputStringType aRet;
aRet.mnFormatType = SvNumFormatType::ALL;
@@ -449,12 +450,12 @@ ScInputStringType ScStringUtil::parseInputString(
}
else // test for English number format (only)
{
sal_uInt32 nNumFormat = rFormatter.GetStandardIndex(eLang);
sal_uInt32 nNumFormat = rContext.NFGetStandardIndex(eLang);
if (rFormatter.IsNumberFormat(rStr, nNumFormat, aRet.mfValue))
if (rContext.NFIsNumberFormat(rStr, nNumFormat, aRet.mfValue))
{
aRet.meType = ScInputStringType::Number;
aRet.mnFormatType = rFormatter.GetType(nNumFormat);
aRet.mnFormatType = rContext.NFGetType(nNumFormat);
}
else if (!rStr.isEmpty())
aRet.meType = ScInputStringType::Text;
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 1dc973f..a2862f7 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -166,10 +166,10 @@ void lclInsertUrl( XclImpRoot& rRoot, const OUString& rUrl, SCCOL nScCol, SCROW
case CELLTYPE_STRING:
case CELLTYPE_EDIT:
{
sal_uInt32 nNumFmt = rDoc.getDoc().GetNumberFormat(rDoc.getDoc().GetNonThreadedContext(), aScPos);
SvNumberFormatter* pFormatter = rDoc.getDoc().GetFormatTable();
ScInterpreterContext& rContext = rDoc.getDoc().GetNonThreadedContext();
sal_uInt32 nNumFmt = rDoc.getDoc().GetNumberFormat(rContext, aScPos);
const Color* pColor;
OUString aDisplText = ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, rDoc.getDoc());
OUString aDisplText = ScCellFormat::GetString(aCell, nNumFmt, &pColor, &rContext, rDoc.getDoc());
if (aDisplText.isEmpty())
aDisplText = rUrl;
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index a8e27a8..16031fd 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1313,7 +1313,7 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC
break;
[[fallthrough]];
default:
aStrOut = ScCellFormat::GetString(aCell, nFormat, &pColor, *pFormatter, *pDoc);
aStrOut = ScCellFormat::GetString(aCell, nFormat, &pColor, nullptr, *pDoc);
}
if ( !bFieldText )
diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx
index 7349aa6..cea6979 100644
--- a/sc/source/filter/rtf/rtfexp.cxx
+++ b/sc/source/filter/rtf/rtfexp.cxx
@@ -252,7 +252,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol )
bValueData = pDoc->HasValueData(aPos);
sal_uInt32 nFormat = pAttr->GetNumberFormat(pFormatter);
const Color* pColor;
aContent = ScCellFormat::GetString(*pDoc, aPos, nFormat, &pColor, *pFormatter);
aContent = ScCellFormat::GetString(*pDoc, aPos, nFormat, &pColor, nullptr);
}
}
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index c7d21df..5f6f5a5 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1299,7 +1299,7 @@ OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos )
// like in GetString for document (column)
const Color* pColor;
sal_uInt32 nNumFmt = pDoc->GetNumberFormat(aCellPos);
return ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pDoc->GetFormatTable(), *pDoc);
return ScCellFormat::GetString(aCell, nNumFmt, &pColor, nullptr, *pDoc);
}
}
}
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 4ec6ab6..abef939 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -223,10 +223,8 @@ OUString lcl_GetFormattedString(ScDocument* pDoc, const ScRefCellValue& rCell, c
case CELLTYPE_STRING:
{
const Color* pColor;
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
sal_uInt32 nFormat = pDoc->GetNumberFormat(rAddr);
return ScCellFormat::GetString(rCell, nFormat, &pColor, *pFormatter, *pDoc);
return ScCellFormat::GetString(rCell, nFormat, &pColor, nullptr, *pDoc);
}
case CELLTYPE_EDIT:
{
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 9a8614a..19b521f 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -171,6 +171,8 @@ ScModule::~ScModule()
ScGlobal::Clear(); // Also calls ScDocumentPool::DeleteVersionMaps();
ScInterpreterContextPool::ModuleExiting();
DeleteCfg(); // Called from Exit()
}
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index d604963..23278c0 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -323,11 +323,11 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt
}
else
{
SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
sal_uInt32 nNumFmt = pPattern->GetNumberFormat(pFormatter);
ScInterpreterContext& rContext = m_pDoc->GetNonThreadedContext();
sal_uInt32 nNumFmt = pPattern->GetNumberFormat(rContext);
const Color* pColor;
OUString aText
= ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, *m_pDoc);
= ScCellFormat::GetString(aCell, nNumFmt, &pColor, &rContext, *m_pDoc);
if (!aText.isEmpty())
aEngine.SetTextCurrentDefaults(aText);
}
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index ec174d9..bad24d1 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1274,7 +1274,7 @@ bool ScDocFunc::SetCellText(
pExtRefGuard.emplace(rDoc);
ScInputStringType aRes =
ScStringUtil::parseInputString(*rDoc.GetFormatTable(), rText, LANGUAGE_ENGLISH_US);
ScStringUtil::parseInputString(rDoc.GetNonThreadedContext(), rText, LANGUAGE_ENGLISH_US);
switch (aRes.meType)
{
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index c3dd185..e5d444d 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2115,7 +2115,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
SCROW nNextRow = nStartRow;
SCCOL nEmptyCol;
SCROW nEmptyRow;
SvNumberFormatter& rFormatter = *m_pDocument->GetFormatTable();
ScInterpreterContext& rContext = m_pDocument->GetNonThreadedContext();
ScHorizontalCellIterator aIter( *m_pDocument, nTab, nStartCol, nStartRow,
nEndCol, nEndRow );
@@ -2216,12 +2216,12 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
if ( bFixedWidth || bSaveAsShown )
{
const Color* pDummy;
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, *m_pDocument);
bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, &rContext, *m_pDocument);
bString = bSaveAsShown && rContext.NFIsTextFormat( nFormat);
}
else
{
aString = ScCellFormat::GetInputString(*pCell, nFormat, rFormatter, *m_pDocument);
aString = ScCellFormat::GetInputString(*pCell, nFormat, &rContext, *m_pDocument);
bString = bForceQuotes = !bSaveNumberAsSuch;
}
}
@@ -2231,7 +2231,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
{
sal_uInt32 nFormat = m_pDocument->GetNumberFormat(aPos);
const Color* pDummy;
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, *m_pDocument);
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, &rContext, *m_pDocument);
}
else
aString = pCell->getFormula()->GetString().getString();
@@ -2244,7 +2244,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
{
sal_uInt32 nFormat = m_pDocument->GetNumberFormat(aPos);
const Color* pDummy;
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, *m_pDocument);
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, &rContext, *m_pDocument);
}
else
aString = pCell->getSharedString()->getString();
@@ -2265,12 +2265,12 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
if ( bFixedWidth || bSaveAsShown )
{
const Color* pDummy;
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, *m_pDocument);
bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, &rContext, *m_pDocument);
bString = bSaveAsShown && rContext.NFIsTextFormat( nFormat);
}
else
{
aString = ScCellFormat::GetInputString(*pCell, nFormat, rFormatter, *m_pDocument);
aString = ScCellFormat::GetInputString(*pCell, nFormat, &rContext, *m_pDocument);
bString = bForceQuotes = !bSaveNumberAsSuch;
}
}
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 0d501a1..6d0da17 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -445,7 +445,7 @@ void lcl_GetColumnTypes(
sal_Int32* pColScales, bool& bHasMemo, rtl_TextEncoding eCharSet )
{
ScDocument& rDoc = rDocShell.GetDocument();
SvNumberFormatter* pNumFmt = rDoc.GetFormatTable();
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
SCTAB nTab = rDataRange.aStart.Tab();
SCCOL nFirstCol = rDataRange.aStart.Col();
@@ -573,7 +573,7 @@ void lcl_GetColumnTypes(
else
{
sal_uInt32 nFormat = rDoc.GetNumberFormat( nCol, nFirstDataRow, nTab );
switch ( pNumFmt->GetType( nFormat ) )
switch (rContext.NFGetType(nFormat))
{
case SvNumFormatType::LOGICAL :
nDbType = sdbc::DataType::BIT;
@@ -713,12 +713,12 @@ void lcl_getLongVarCharEditString( OUString& rString,
}
void lcl_getLongVarCharString(
OUString& rString, ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, SvNumberFormatter& rNumFmt )
OUString& rString, ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, ScInterpreterContext& rContext )
{
const Color* pColor;
ScAddress aPos(nCol, nRow, nTab);
sal_uInt32 nFormat = rDoc.GetNumberFormat(aPos);
rString = ScCellFormat::GetString(rDoc, aPos, nFormat, &pColor, rNumFmt);
rString = ScCellFormat::GetString(rDoc, aPos, nFormat, &pColor, &rContext);
}
}
@@ -751,7 +751,7 @@ ErrCodeMsg ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncod
nFirstRow = nLastRow;
ScProgress aProgress( this, ScResId( STR_SAVE_DOC ),
nLastRow - nFirstRow, true );
SvNumberFormatter* pNumFmt = m_pDocument->GetFormatTable();
ScInterpreterContext& rContext = m_pDocument->GetNonThreadedContext();
bool bHasFieldNames = true;
for ( SCCOL nDocCol = nFirstCol; nDocCol <= nLastCol && bHasFieldNames; nDocCol++ )
@@ -909,7 +909,7 @@ ErrCodeMsg ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncod
else
{
lcl_getLongVarCharString(
aString, *m_pDocument, nDocCol, nDocRow, nTab, *pNumFmt);
aString, *m_pDocument, nDocCol, nDocRow, nTab, rContext);
}
xRowUpdate->updateString( nCol+1, aString );
}
@@ -941,7 +941,7 @@ ErrCodeMsg ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncod
}
else
{
Date aDate = pNumFmt->GetNullDate(); // tools date
Date aDate = rContext.NFGetNullDate(); // tools date
aDate.AddDays(fVal); //! approxfloor?
xRowUpdate->updateDate( nCol+1, aDate.GetUNODate() );
}
@@ -1012,7 +1012,7 @@ ErrCodeMsg ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncod
lcl_getLongVarCharEditString(aString, *pCell, aEditEngine);
else
lcl_getLongVarCharString(
aString, *m_pDocument, nDocCol, nDocRow, nTab, *pNumFmt);
aString, *m_pDocument, nDocCol, nDocRow, nTab, rContext);
}
break;
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 6606f34..36110b1 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1947,7 +1947,7 @@ bool ScImportExport::Doc2Text( SvStream& rStrm )
{
ScAddress aPos(nCol, nRow, nStartTab);
sal_uInt32 nNumFmt = rDoc.GetNumberFormat(aPos);
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
ScRefCellValue aCell(rDoc, aPos, blockPos[ nCol - nStartCol ]);
switch (aCell.getType())
@@ -1965,7 +1965,7 @@ bool ScImportExport::Doc2Text( SvStream& rStrm )
else
{
const Color* pColor;
aCellStr = ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, rDoc);
aCellStr = ScCellFormat::GetString(aCell, nNumFmt, &pColor, &rContext, rDoc);
bool bMultiLineText = ( aCellStr.indexOf( '\n' ) != -1 );
if( bMultiLineText )
@@ -1989,7 +1989,7 @@ bool ScImportExport::Doc2Text( SvStream& rStrm )
case CELLTYPE_VALUE:
{
const Color* pColor;
aCellStr = ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, rDoc);
aCellStr = ScCellFormat::GetString(aCell, nNumFmt, &pColor, &rContext, rDoc);
rStrm.WriteUnicodeOrByteText(aCellStr);
}
break;
@@ -1998,7 +1998,7 @@ bool ScImportExport::Doc2Text( SvStream& rStrm )
default:
{
const Color* pColor;
aCellStr = ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, rDoc);
aCellStr = ScCellFormat::GetString(aCell, nNumFmt, &pColor, &rContext, rDoc);
bool bMultiLineText = ( aCellStr.indexOf( '\n' ) != -1 );
if( bMultiLineText )
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 38284c6..2e152b4 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1230,7 +1230,7 @@ static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
ScInputStringType aRes =
ScStringUtil::parseInputString(
*rDoc.GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
rDoc.GetNonThreadedContext(), aText, LANGUAGE_ENGLISH_US);
switch (aRes.meType)
{
case ScInputStringType::Formula:
@@ -1291,8 +1291,12 @@ static OUString lcl_GetInputString( ScDocument& rDoc, const ScAddress& rPos, boo
return pForm->GetFormula( formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
}
SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
rDoc.GetFormatTable();
// use an InterpreterContext, possibly with a different formatter, to uniformly use
// ScCellFormat::GetInputString everywhere
ScInterpreterContextGetterGuard aContextGetterGuard(rDoc, bEnglish ? ScGlobal::GetEnglishFormatter()
: rDoc.GetFormatTable());
ScInterpreterContext* pInterpreterContext = aContextGetterGuard.GetInterpreterContext();
// Since the English formatter was constructed with
// LANGUAGE_ENGLISH_US the "General" format has index key 0,
// we don't have to query.
@@ -1311,25 +1315,26 @@ static OUString lcl_GetInputString( ScDocument& rDoc, const ScAddress& rPos, boo
}
}
else
aVal = ScCellFormat::GetInputString(aCell, nNumFmt, *pFormatter, rDoc);
aVal = ScCellFormat::GetInputString(aCell, nNumFmt, pInterpreterContext, rDoc);
// if applicable, prepend ' like in ScTabViewShell::UpdateInputHandler
if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
{
double fDummy;
OUString aTempString = aVal;
bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
bool bIsNumberFormat(pInterpreterContext->NFIsNumberFormat(aTempString, nNumFmt, fDummy));
if ( bIsNumberFormat )
aTempString = "'" + aTempString;
else if ( aTempString.startsWith("'") )
{
// if the string starts with a "'", add another one because setFormula
// strips one (like text input, except for "text" number formats)
if ( bEnglish || ( pFormatter->GetType(nNumFmt) != SvNumFormatType::TEXT ) )
if ( bEnglish || ( pInterpreterContext->NFGetType(nNumFmt) != SvNumFormatType::TEXT ) )
aTempString = "'" + aTempString;
}
aVal = aTempString;
}
return aVal;
}
@@ -5863,9 +5868,9 @@ void ScCellObj::InputEnglishString( const OUString& rText )
return;
ScDocument& rDoc = pDocSh->GetDocument();
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
sal_uInt32 nOldFormat = rDoc.GetNumberFormat( aCellPos );
if (pFormatter->GetType(nOldFormat) == SvNumFormatType::TEXT)
if (rContext.NFGetType(nOldFormat) == SvNumFormatType::TEXT)
{
SetString_Impl(rText, false, false); // text cell
return;
@@ -5874,14 +5879,14 @@ void ScCellObj::InputEnglishString( const OUString& rText )
ScDocFunc &rFunc = pDocSh->GetDocFunc();
ScInputStringType aRes =
ScStringUtil::parseInputString(*pFormatter, rText, LANGUAGE_ENGLISH_US);
ScStringUtil::parseInputString(rContext, rText, LANGUAGE_ENGLISH_US);
if (aRes.meType != ScInputStringType::Unknown)
{
if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType != SvNumFormatType::ALL)
{
// apply a format for the recognized type and the old format's language
sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(rContext, nOldFormat, aRes.mnFormatType);
if (nNewFormat != nOldFormat)
{
ScPatternAttr aPattern(rDoc.getCellAttributeHelper());
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 20bfb13..01d25df 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -819,7 +819,7 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder()
else
{
sal_uInt32 nFormat = rDoc.GetNumberFormat(aCellPos);
OUString aText = ScCellFormat::GetInputString(aCell, nFormat, *rDoc.GetFormatTable(), rDoc);
OUString aText = ScCellFormat::GetInputString(aCell, nFormat, nullptr, rDoc);
if (!aText.isEmpty())
pEditEngine->SetTextNewDefaults(aText, aDefaults);
else
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 8a18ea0..1d68bb8 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -512,7 +512,7 @@ bool ScDrawStringsVars::SetText( const ScRefCellValue& rCell )
sal_uLong nFormat = nValueFormat;
aString = ScCellFormat::GetString( rCell,
nFormat, &pColor,
*pOutput->mpDoc->GetFormatTable(),
nullptr,
*pOutput->mpDoc,
pOutput->mbShowNullValues,
pOutput->mbShowFormulas,
@@ -2517,7 +2517,7 @@ bool ScOutputData::DrawEditParam::readCellContent(
const Color* pColor;
OUString aString = ScCellFormat::GetString( maCell,
nFormat, &pColor,
*pDoc->GetFormatTable(),
nullptr,
*pDoc,
bShowNullValues,
bShowFormulas);
@@ -4931,7 +4931,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
const Color* pColor;
OUString aString = ScCellFormat::GetString( aCell,
nFormat, &pColor,
*mpDoc->GetFormatTable(),
nullptr,
*mpDoc,
mbShowNullValues,
mbShowFormulas);
diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx
index 7fc859b..b7a3505 100644
--- a/sc/source/ui/view/spelleng.cxx
+++ b/sc/source/ui/view/spelleng.cxx
@@ -282,10 +282,9 @@ void ScConversionEngineBase::FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
{
case CELLTYPE_STRING:
{
SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
sal_uInt32 nNumFmt = mrDoc.GetNumberFormat(aPos);
const Color* pColor;
OUString aText = ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, mrDoc);
OUString aText = ScCellFormat::GetString(aCell, nNumFmt, &pColor, nullptr, mrDoc);
SetTextCurrentDefaults(aText);
}
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 931a818..32fb01f 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -139,7 +139,7 @@ bool ScTabViewShell::GetFunction( OUString& rFuncStr, FormulaError nErrCode )
else
{
// Number in the standard format, the other on the cursor position
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
sal_uInt32 nNumFmt = 0;
if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
{
@@ -152,15 +152,15 @@ bool ScTabViewShell::GetFunction( OUString& rFuncStr, FormulaError nErrCode )
// for a single date+time value.
if (nVal < 0.0 || nVal >= 1.0)
{
const SvNumberformat* pFormat = pFormatter->GetEntry(nNumFmt);
const SvNumberformat* pFormat = rContext.NFGetFormatEntry(nNumFmt);
if (pFormat && (pFormat->GetType() == SvNumFormatType::TIME))
nNumFmt = pFormatter->GetTimeFormat( nVal, pFormat->GetLanguage(), true);
nNumFmt = rContext.NFGetTimeFormat( nVal, pFormat->GetLanguage(), true);
}
}
OUString aValStr;
const Color* pDummy;
pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
rContext.NFGetOutputString( nVal, nNumFmt, aValStr, &pDummy );
aStr += aValStr;
}
}
@@ -755,10 +755,10 @@ void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bSt
}
else
{
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
sal_uInt32 nNumFmt = rDoc.GetNumberFormat( aPos );
aString = ScCellFormat::GetInputString( rCell, nNumFmt, *pFormatter, rDoc );
aString = ScCellFormat::GetInputString( rCell, nNumFmt, &rContext, rDoc );
if (rCell.getType() == CELLTYPE_STRING)
{
// Put a ' in front if necessary, so that the string is not
@@ -772,9 +772,9 @@ void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bSt
// removing one apostrophe.
// For number format Text IsNumberFormat() would never
// result in numeric anyway.
if (!pFormatter->IsTextFormat(nNumFmt) && (aString.startsWith("'")
if (!rContext.NFIsTextFormat(nNumFmt) && (aString.startsWith("'")
|| aString.startsWith("=") || aString.startsWith("+") || aString.startsWith("-")
|| pFormatter->IsNumberFormat(aString, nNumFmt, o3tl::temporary(double()))))
|| rContext.NFIsNumberFormat(aString, nNumFmt, o3tl::temporary(double()))))
aString = "'" + aString;
}
}
@@ -1632,9 +1632,9 @@ void ScTabViewShell::ExecuteStyleEditDialog(VclPtr<SfxAbstractTabDialog> pDlg,
sal_uLong nNewFormat = rNewSet.Get( ATTR_VALUE_FORMAT ).GetValue();
if ( nNewFormat != nOldFormat )
{
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat );
const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat );
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
const SvNumberformat* pOld = rContext.NFGetFormatEntry( nOldFormat );
const SvNumberformat* pNew = rContext.NFGetFormatEntry( nNewFormat );
if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() )
rNewSet.Put( SvxLanguageItem(
pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index c98f94a11..7d6edf7 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -3911,7 +3911,7 @@ namespace
sal_uInt32 SvNFEngine::GetCLOffsetRO(const SvNFFormatData& rFormatData, SvNFLanguageData&, const NativeNumberWrapper*, LanguageType eLnge)
{
sal_uInt32 nCLOffset = rFormatData.ImpGetCLOffset(eLnge);
assert(nCLOffset >= rFormatData.MaxCLOffset && "Language must have already been encountered");
assert(nCLOffset <= rFormatData.MaxCLOffset && "Language must have already been encountered");
return nCLOffset;
}