summaryrefslogtreecommitdiff
path: root/sc/inc/document.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2018-11-07 16:01:30 +0100
committerLuboš Luňák <l.lunak@collabora.com>2018-11-14 16:05:55 +0100
commit2dbda86cca1301b81a4232a6f0c03559da5ed7f4 (patch)
tree7c1506c668939cb2b0f003bdc8e64012a0ea9a7e /sc/inc/document.hxx
parent698942ac73b8502eb1957b70dd165023e8d54c82 (diff)
make ScInterpreterContext also accessible without passing it around
E.g. ScModelObj::GetFormatter() can be rather deep in the call chain and it just doesn't make sense to pass ScInterpreterContext* to all the relevant places (and it's a question if it makes sense to pass it around at all, googling shows that thread_local is not really _that_ slow). Change-Id: I9114ef8a10d82a10968391718099edccde7a2663 Reviewed-on: https://gerrit.libreoffice.org/63184 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/inc/document.hxx')
-rw-r--r--sc/inc/document.hxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6fe442954901..22ce96e010ef 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -275,9 +275,11 @@ const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink()
struct ScDocumentThreadSpecific
{
ScRecursionHelper* pRecursionHelper; // information for recursive and iterative cell formulas
+ ScInterpreterContext* pContext; // references the context passed around for easier access
- ScDocumentThreadSpecific() :
- pRecursionHelper(nullptr)
+ ScDocumentThreadSpecific()
+ : pRecursionHelper(nullptr)
+ , pContext(nullptr)
{
}
@@ -582,6 +584,11 @@ public:
maInterpreterContext.mpFormatter = GetFormatTable();
return maInterpreterContext;
}
+ // Uses thread_local.
+ ScInterpreterContext& GetThreadedContext() const
+ {
+ return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
+ }
void SetupFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
void MergeBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }