Resolves: tdf#152014 When reusing interpreter context slot clear lookup cache

... if different doc

As is, unthreaded the same slot gets reused for every calculation.
That could benefit from keeping 2-3 documents cached to not throw
away the lookup cache each time when alternating between
documents.

Change-Id: Id024333f72bcdcd6109042dec1104f3029955d3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142639
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit f86a0666ac337363b470c9c67fa0970a330b26a2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142631
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sc/source/core/tool/interpretercontext.cxx b/sc/source/core/tool/interpretercontext.cxx
index 0df4a84..e66a8b9 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -53,7 +53,11 @@ void ScInterpreterContext::ResetTokens()

void ScInterpreterContext::SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* pFormatter)
{
    mpDoc = &rDoc;
    if (mpDoc != &rDoc)
    {
        mxScLookupCache.reset();
        mpDoc = &rDoc;
    }
    mpFormatter = pFormatter;
}