sc/source/core/tool/interpr1.cxx |   52 +++++++++++++--------------------------
 1 file changed, 18 insertions(+), 34 deletions(-)

New commits:
commit 28c01fa9093667114448238cb09ae8c57661fbae
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Jan 16 12:59:09 2025 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jan 16 15:06:25 2025 +0100

    sc: fix some checks
    
    See 
https://gerrit.libreoffice.org/c/core/+/180245/comment/59cd8c41_737390e6/
    After
    commit ee05b94e713adbc7af3e29ac6018c5e825511c96
    Author: Xisco Fauli <xiscofa...@libreoffice.org>
    Date:   Tue Jan 14 16:19:06 2025 +0100
    
        tdf#150879: Add support for TOCOL function
    
    and
    
    commit c1565b8b94548ef85508b0302ef9299f18ff09be
    Author: Balazs Varga <balazs.varga.ext...@allotropia.de>
    Date:   Fri May 10 17:06:39 2024 +0200
    
        tdf#126573 Add Excel2021 array function UNIQUE to Calc
    
    Change-Id: I277cb1e998d1ef33f319beec42c990bc8effefe9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180346
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index fe0cc47d9e87..ddf58c111cd9 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8879,19 +8879,18 @@ void ScInterpreter::ScToCol()
     // No result
     if (aResPos.size() == 0)
     {
-        if (nGlobalError != FormulaError::NONE)
-        {
-            PushIllegalArgument();
-        }
-        else
-        {
-            PushNA();
-        }
+        PushNA();
         return;
     }
 
-    // fill result matrix to the same column
     ScMatrixRef pResMat = GetNewMat(1, aResPos.size(), /*bEmpty*/true);
+    if (!pResMat)
+    {
+        PushIllegalArgument();
+        return;
+    }
+
+    // fill result matrix to the same column
     for (SCSIZE iPos = 0; iPos < aResPos.size(); ++iPos)
     {
         if (pMatSource->IsEmptyCell(aResPos[iPos].first, aResPos[iPos].second))
@@ -8908,14 +8907,7 @@ void ScInterpreter::ScToCol()
         }
     }
 
-    if (!pResMat)
-    {
-        PushIllegalArgument();
-    }
-    else
-    {
-        PushMatrix(pResMat);
-    }
+    PushMatrix(pResMat);
 }
 
 void ScInterpreter::ScToRow()
@@ -9116,19 +9108,18 @@ void ScInterpreter::ScUnique()
     // No result
     if (aResPos.size() == 0)
     {
-        if (nGlobalError != FormulaError::NONE)
-        {
-            PushIllegalArgument();
-        }
-        else
-        {
-            PushNA();
-        }
+        PushNA();
         return;
     }
-    // fill result matrix with unique values
+
     ScMatrixRef pResMat = bByRow ? GetNewMat(nsC, aResPos.size(), 
/*bEmpty*/true) :
         GetNewMat(aResPos.size(), nsR, /*bEmpty*/true);
+    if (!pResMat)
+    {
+        PushIllegalArgument();
+        return;
+    }
+    // fill result matrix with unique values
     for (SCSIZE iPos = 0; iPos < aResPos.size(); iPos++)
     {
         if (bByRow)
@@ -9169,14 +9160,7 @@ void ScInterpreter::ScUnique()
         }
     }
 
-    if (!pResMat)
-    {
-        PushIllegalArgument();
-    }
-    else
-    {
-        PushMatrix(pResMat);
-    }
+    PushMatrix(pResMat);
 }
 
 void ScInterpreter::getTokensAtParameter( std::unique_ptr<ScTokenArray>& 
pTokens, short nPos )

Reply via email to