summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/interpretercontext.hxx11
-rw-r--r--sc/source/core/data/dociter.cxx2
-rw-r--r--sc/source/core/data/document.cxx2
-rw-r--r--sc/source/core/tool/interpr4.cxx2
-rw-r--r--sc/source/core/tool/interpr6.cxx2
-rw-r--r--sc/source/core/tool/interpretercontext.cxx19
6 files changed, 34 insertions, 4 deletions
diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index b46a23f4e6a0..4ed6b3c66c4a 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -25,6 +25,7 @@ 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
@@ -34,6 +35,13 @@ struct DelayedSetNumberFormat
sal_uInt32 mnNumberFormat;
};
+struct NFIndexAndFmtType
+{
+ sal_uInt32 nIndex;
+ SvNumFormatType eType : 16;
+ bool bIsValid : 1;
+};
+
class ScInterpreterContextPool;
struct ScInterpreterContext
@@ -69,6 +77,8 @@ struct ScInterpreterContext
return mpFormatter;
}
+ SvNumFormatType GetNumberFormatType(sal_uInt32 nFIndex) const;
+
private:
friend class ScInterpreterContextPool;
void ResetTokens();
@@ -77,6 +87,7 @@ private:
void ClearLookupCache();
void initFormatTable();
SvNumberFormatter* mpFormatter;
+ mutable NFIndexAndFmtType maNFTypeCache;
};
class ScThreadedInterpreterContextGetterGuard;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 70362f342b21..3c8e369a575a 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -273,7 +273,7 @@ void ScValueIterator::GetCurNumFmtInfo( const ScInterpreterContext& rContext, Sv
SCROW nCurRow = GetRow();
const ScColumn* pCol = &(pDoc->maTabs[mnTab])->aCol[mnCol];
nNumFmtIndex = pCol->GetNumberFormat(rContext, nCurRow);
- nNumFmtType = rContext.GetFormatTable()->GetType( nNumFmtIndex );
+ nNumFmtType = rContext.GetNumberFormatType( nNumFmtIndex );
bNumValid = true;
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index cc961b20b1a4..82224b23ecb3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3692,7 +3692,7 @@ void ScDocument::GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNu
if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
{
nIndex = maTabs[nTab]->GetNumberFormat( rContext, rPos );
- nType = rContext.GetFormatTable()->GetType( nIndex );
+ nType = rContext.GetNumberFormatType( nIndex );
}
else
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 544a9ab11d0a..fc419d4a5935 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -223,7 +223,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue&
{
fValue = rCell.mfValue;
nCurFmtIndex = pDok->GetNumberFormat( mrContext, rPos );
- nCurFmtType = pFormatter->GetType( nCurFmtIndex );
+ nCurFmtType = mrContext.GetNumberFormatType( nCurFmtIndex );
if ( bCalcAsShown && fValue != 0.0 )
fValue = pDok->RoundValueAsShown( fValue, nCurFmtIndex, &mrContext );
}
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 3a77be206acc..c2655fceb3d7 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -850,7 +850,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
nFuncFmtIndex = aAction.getNumberFormat();
}
- nFuncFmtType = mrContext.GetFormatTable()->GetType( nFuncFmtIndex );
+ nFuncFmtType = mrContext.GetNumberFormatType( nFuncFmtIndex );
}
else
{
diff --git a/sc/source/core/tool/interpretercontext.cxx b/sc/source/core/tool/interpretercontext.cxx
index b997effe13c4..77d2feadce6a 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -18,6 +18,7 @@
*/
#include <interpretercontext.hxx>
+#include <svl/zforlist.hxx>
#include <document.hxx>
#include <formula/token.hxx>
@@ -68,6 +69,24 @@ void ScInterpreterContext::ClearLookupCache()
mScLookupCache = nullptr;
}
+SvNumFormatType ScInterpreterContext::GetNumberFormatType(sal_uInt32 nFIndex) const
+{
+ if (!mpDoc->IsThreadedGroupCalcInProgress())
+ {
+ return mpFormatter->GetType(nFIndex);
+ }
+
+ if (maNFTypeCache.bIsValid && maNFTypeCache.nIndex == nFIndex)
+ {
+ return maNFTypeCache.eType;
+ }
+
+ maNFTypeCache.nIndex = nFIndex;
+ maNFTypeCache.eType = mpFormatter->GetType(nFIndex);
+ maNFTypeCache.bIsValid = true;
+ return maNFTypeCache.eType;
+}
+
/* ScInterpreterContextPool */
// Threaded version