Resolves: tdf#145085 HYPERLINK() do not force a 2nd row URL cell in array mode

... but fake a 1-row result dimension instead.

However, keep the behaviour that if a 2-rows array was entered the
2nd row displays the URL and not the repeated cell text.

Change-Id: I4800715a4028c647b763c6d729759ff4c099748f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123680
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 459f9de8a87373c826eadab142850cc3fa578fca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123635
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 0b8dfd9..5250e5e 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1101,6 +1101,13 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows )
        if (pMat)
        {
            pMat->GetDimensions( rCols, rRows );
            if (pCode->IsHyperLink())
            {
                // Row 2 element is the URL that is not to be displayed and the
                // result dimension not to be extended.
                assert(rRows == 2);
                rRows = 1;
            }
            return;
        }
    }
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 1e16518..2c79e14 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -3239,6 +3239,25 @@ void ScInterpreter::ScMatRef()
        pMat->GetDimensions( nCols, nRows );
        SCSIZE nC = static_cast<SCSIZE>(aPos.Col() - aAdr.Col());
        SCSIZE nR = static_cast<SCSIZE>(aPos.Row() - aAdr.Row());
#if 0
        // XXX: this could be an additional change for tdf#145085 to not
        // display the URL in a voluntary entered 2-rows array context.
        // However, that might as well be used on purpose to implement a check
        // on the URL, which existing documents may have done, the more that
        // before the accompanying change of
        // ScFormulaCell::GetResultDimensions() the cell array was forced to
        // two rows. Do not change without compelling reason. Note that this
        // repeating top cell is what Excel implements, but it has no
        // additional value so probably isn't used there. Exporting to and
        // using in Excel though will lose this capability.
        if (aCell.mpFormula->GetCode()->IsHyperLink())
        {
            // Row 2 element is the URL that is not to be displayed, fake a
            // 1-row cell-text-only matrix that is repeated.
            assert(nRows == 2);
            nR = 0;
        }
#endif
        if ((nCols <= nC && nCols != 1) || (nRows <= nR && nRows != 1))
            PushNA();
        else