Work around assert() in circular reference within group calc, tdf#141146

Triggered by crash test loading document of
wget 'https://bz.apache.org/ooo/attachment.cgi?id=71756' -O ooo114587-1.ods

after

    commit 042dbf83122b14fd1dd32705c8f8b7d65c22f21b
    CommitDate: Thu Mar 25 16:31:29 2021 +0100

        Resolves: tdf#141146 Fix LOOKUP in array with result
        scalar / single reference

Though could happen any time whenever a shared formula group calc
attempts to obtain a result from an already running cell.

Change-Id: Id668b31a8d81389c593c6fd2191fd444efcdb70f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113494
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index ae889d7..28317d6 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -22,11 +22,13 @@
#include <memory>

#include <formula/tokenarray.hxx>
#include <formula/errorcodes.hxx>
#include <svl/listener.hxx>

#include "types.hxx"
#include "interpretercontext.hxx"
#include "document.hxx"
#include "docoptio.hxx"
#include "formulalogger.hxx"
#include "formularesult.hxx"

@@ -436,15 +438,25 @@ public:
        return (rDocument.GetAutoCalc() || (cMatrixFlag != ScMatrixMode::NONE));
    }

    bool MaybeInterpret()
    void MaybeInterpret()
    {
        if (NeedsInterpret())
        {
            assert(!rDocument.IsThreadedGroupCalcInProgress());
            Interpret();
            return true;
            if (bRunning && !rDocument.GetDocOptions().IsIter() && rDocument.IsThreadedGroupCalcInProgress())
            {
                // This is actually copied from Interpret()'s if(bRunning)
                // block that once caught this circular reference but now is
                // prepended with various threaded group calc things which the
                // assert() below is supposed to fail on when entering again.
                // Nevertheless, we need some state here the caller can obtain.
                aResult.SetResultError( FormulaError::CircularReference );
            }
            else
            {
                assert(!rDocument.IsThreadedGroupCalcInProgress());
                Interpret();
            }
        }
        return false;
    }

    /**