Close circle once in iterations only if not 'this'

... as 'this' was just appended hence calculated.
Question remains if there's any situation where the last cell
would not be 'this'.

Change-Id: I9cc1a7e38bdd6aca0e36a4cf1ef1b827003e72a9
Reviewed-on: https://gerrit.libreoffice.org/56412
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 462d098..edc8e00 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1613,10 +1613,15 @@ void ScFormulaCell::Interpret()
                    // Close circle once. If 'this' is self-referencing only
                    // (e.g. counter or self-adder) then it is already
                    // implicitly closed.
                    if (rRecursionHelper.GetList().size() > 1)
                    /* TODO: does this even make sense anymore? The last cell
                     * added above with rRecursionHelper.Insert() should always
                     * be 'this', shouldn't it? */
                    ScFormulaCell* pLastCell = nullptr;
                    if (rRecursionHelper.GetList().size() > 1 &&
                            ((pLastCell = rRecursionHelper.GetList().back().pCell) != this))
                    {
                        pDocument->IncInterpretLevel();
                        rRecursionHelper.GetList().back().pCell->InterpretTail(
                        pLastCell->InterpretTail(
                                pDocument->GetNonThreadedContext(), SCITP_CLOSE_ITERATION_CIRCLE);
                        pDocument->DecInterpretLevel();
                    }