Use cycle guard for calls to InterpretTail too

Some formula-groups even though a part of a cycle
may get skipped from getting flagged(mbPartOfCycle)
in the dependency calculator because it has other
problems like self references. Such FG's can be
caught when they through InterpretTail() by having
a cycle guard there.

Concretely it fixes a crash in the bugdoc of
tdf#94271-2.

Change-Id: I508df88804c7cd8dbbb6497188b1c9559bec3aa6
Reviewed-on: https://gerrit.libreoffice.org/57004
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 96aabc5..5c79b17 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1540,15 +1540,19 @@ void ScFormulaCell::Interpret()

#if DEBUG_CALCULATION
        aDC.enterGroup();
        bool bGroupInterpreted = InterpretFormulaGroup();
        aDC.leaveGroup();
        if (!bGroupInterpreted)
            InterpretTail( pDocument->GetNonThreadedContext(), SCITP_NORMAL);
#else
        if (!InterpretFormulaGroup())
            InterpretTail( pDocument->GetNonThreadedContext(), SCITP_NORMAL);
#endif

        bool bGroupInterpreted = InterpretFormulaGroup();

#if DEBUG_CALCULATION
        aDC.leaveGroup();
#endif
        if (!bGroupInterpreted)
        {
            ScFormulaGroupCycleCheckGuard aCycleCheckGuard(rRecursionHelper, mxGroup.get());
            InterpretTail( pDocument->GetNonThreadedContext(), SCITP_NORMAL);
        }

        pDocument->DecInterpretLevel();
    }

diff --git a/sc/source/core/tool/recursionhelper.cxx b/sc/source/core/tool/recursionhelper.cxx
index 0c185db..8cfef97 100644
--- a/sc/source/core/tool/recursionhelper.cxx
+++ b/sc/source/core/tool/recursionhelper.cxx
@@ -98,7 +98,9 @@ void ScRecursionHelper::Clear()

bool ScRecursionHelper::PushFormulaGroup(ScFormulaCellGroup* pGrp)
{
    assert(pGrp);
    if (!pGrp)
        return false;

    if (pGrp->mbSeenInPath)
    {
        // Found a simple cycle of formula-groups.