sc/source/core/tool/interpr1.cxx |   39 ++++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)

New commits:
commit b1740fba0d1e6e3d69c3781734509317f42a0e4f
Author: Winfried Donkers <winfrieddonk...@libreoffice.org>
Date:   Thu Jun 14 20:55:23 2018 +0200

    tdf#77517 make Calc function ROW accept external references.
    
    Change-Id: Ibd4f858abe825652c3df68ce7a21cbf16feea735
    Reviewed-on: https://gerrit.libreoffice.org/55824
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 712c0537e330..a04aadcc9cea 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4339,7 +4339,7 @@ void ScInterpreter::ScRow()
     sal_uInt8 nParamCount = GetByte();
     if ( MustHaveParamCount( nParamCount, 0, 1 ) )
     {
-        double nVal = 0;
+        double nVal = 0.0;
         if (nParamCount == 0)
         {
             nVal = aPos.Row() + 1;
@@ -4378,15 +4378,39 @@ void ScInterpreter::ScRow()
                     nVal = static_cast<double>(nRow1 + 1);
                 }
                 break;
+                case svExternalSingleRef :
+                {
+                    sal_uInt16 nFileId;
+                    OUString aTabName;
+                    ScSingleRefData aRef;
+                    PopExternalSingleRef( nFileId, aTabName, aRef );
+                    ScAddress aAbsRef = aRef.toAbs( aPos );
+                    nVal = static_cast<double>( aAbsRef.Row() + 1 );
+                }
+                break;
                 case svDoubleRef :
+                case svExternalDoubleRef :
                 {
-                    SCCOL nCol1;
                     SCROW nRow1;
-                    SCTAB nTab1;
-                    SCCOL nCol2;
                     SCROW nRow2;
-                    SCTAB nTab2;
-                    PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+                    if ( GetStackType() == svDoubleRef )
+                    {
+                        SCCOL nCol1;
+                        SCTAB nTab1;
+                        SCCOL nCol2;
+                        SCTAB nTab2;
+                        PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 
);
+                    }
+                    else
+                    {
+                        sal_uInt16 nFileId;
+                        OUString aTabName;
+                        ScComplexRefData aRef;
+                        PopExternalDoubleRef( nFileId, aTabName, aRef );
+                        ScRange aAbs = aRef.toAbs( aPos );
+                        nRow1 = aAbs.aStart.Row();
+                        nRow2 = aAbs.aEnd.Row();
+                    }
                     if (nRow2 > nRow1)
                     {
                         ScMatrixRef pResMat = GetNewMat( 1,
@@ -4399,8 +4423,6 @@ void ScInterpreter::ScRow()
                             PushMatrix(pResMat);
                             return;
                         }
-                        else
-                            nVal = 0.0;
                     }
                     else
                         nVal = static_cast<double>(nRow1 + 1);
@@ -4408,7 +4430,6 @@ void ScInterpreter::ScRow()
                 break;
                 default:
                     SetError( FormulaError::IllegalParameter );
-                    nVal = 0.0;
             }
         }
         PushDouble( nVal );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to