[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Tue Jun 19 23:39:12 UTC 2018


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

New commits:
commit d5c8199a94d0e2f722fff6637b930205a6641adf
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Mon Jun 18 19:31:47 2018 +0200

    tdf#77517 make Calc function COLUMN accept external references.
    
    Change-Id: Ife00755586be9a42ac5cf1f9b3debb396db1b45f
    Reviewed-on: https://gerrit.libreoffice.org/56055
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 28f3e44e99283ede636c28c68bffb2b9df0bbcf8)
    Reviewed-on: https://gerrit.libreoffice.org/56128

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 712c0537e330..e87e28d9c4db 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4258,7 +4258,7 @@ void ScInterpreter::ScColumn()
     sal_uInt8 nParamCount = GetByte();
     if ( MustHaveParamCount( nParamCount, 0, 1 ) )
     {
-        double nVal = 0;
+        double nVal = 0.0;
         if (nParamCount == 0)
         {
             nVal = aPos.Col() + 1;
@@ -4297,15 +4297,40 @@ void ScInterpreter::ScColumn()
                     nVal = static_cast<double>(nCol1 + 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.Col() + 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 )
+                    {
+                        SCROW nRow1;
+                        SCTAB nTab1;
+                        SCROW nRow2;
+                        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 );
+                        nCol1 = aAbs.aStart.Col();
+                        nCol2 = aAbs.aEnd.Col();
+                    }
                     if (nCol2 > nCol1)
                     {
                         ScMatrixRef pResMat = GetNewMat(
@@ -4318,8 +4343,6 @@ void ScInterpreter::ScColumn()
                             PushMatrix(pResMat);
                             return;
                         }
-                        else
-                            nVal = 0.0;
                     }
                     else
                         nVal = static_cast<double>(nCol1 + 1);
@@ -4327,7 +4350,6 @@ void ScInterpreter::ScColumn()
                 break;
                 default:
                     SetError( FormulaError::IllegalParameter );
-                    nVal = 0.0;
             }
         }
         PushDouble( nVal );


More information about the Libreoffice-commits mailing list