sc/qa/unit/data/functions/spreadsheet/fods/xlookup.fods | 79 +++++------ sc/source/core/tool/interpr1.cxx | 107 ++++++++++------ 2 files changed, 108 insertions(+), 78 deletions(-)
New commits: commit 41192a36796155f8cd6ac733f5ef84767edf300f Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Fri Feb 9 00:07:41 2024 +0100 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Fri Feb 9 13:23:51 2024 +0100 Related: tdf#127293 Fix function XLOOKUP with nested XLOOKUP functions to return reference of cells what other functions can use (e.g.:SUM): =SUM(XLOOKUP(B3,B6:B10,E6:E10):XLOOKUP(C3,B6:B10,E6:E10)) XLOOKUP function returns a reference to a range of cell(s). Change-Id: I06007aba7017315fc02a92b120f842244b7cc3c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163129 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/xlookup.fods b/sc/qa/unit/data/functions/spreadsheet/fods/xlookup.fods index 49ecf573b50c..fb464e08d008 100644 --- a/sc/qa/unit/data/functions/spreadsheet/fods/xlookup.fods +++ b/sc/qa/unit/data/functions/spreadsheet/fods/xlookup.fods @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/200 4/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns :css3t="http://www.w3.org/TR/css3-text/" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.spreadsheet"> - <office:meta><meta:creation-date>2024-01-16T18:30:06.278000000</meta:creation-date><meta:editing-duration>PT1H12M</meta:editing-duration><meta:editing-cycles>22</meta:editing-cycles><meta:generator>LibreOfficeDev/24.8.0.0.alpha0$Windows_X86_64 LibreOffice_project/2b1f5fa987f02ec8014dbf6837c6b090faf11f2d</meta:generator><dc:date>2024-02-01T11:50:13.789000000</dc:date><meta:document-statistic meta:table-count="2" meta:cell-count="858" meta:object-count="0"/></office:meta> + <office:meta><meta:creation-date>2024-01-16T18:30:06.278000000</meta:creation-date><meta:editing-duration>PT1H14M20S</meta:editing-duration><meta:editing-cycles>23</meta:editing-cycles><meta:generator>LibreOfficeDev/24.8.0.0.alpha0$Windows_X86_64 LibreOffice_project/578d9be50413a4bdc809f8b5f58cc177458f8325</meta:generator><dc:date>2024-02-08T21:37:48.969000000</dc:date><meta:document-statistic meta:table-count="2" meta:cell-count="858" meta:object-count="0"/></office:meta> <office:settings> <config:config-item-set config:name="ooo:view-settings"> <config:config-item config:name="VisibleAreaTop" config:type="int">0</config:config-item> @@ -13,8 +13,8 @@ <config:config-item config:name="ViewId" config:type="string">view1</config:config-item> <config:config-item-map-named config:name="Tables"> <config:config-item-map-entry config:name="Sheet1"> - <config:config-item config:name="CursorPositionX" config:type="int">2</config:config-item> - <config:config-item config:name="CursorPositionY" config:type="int">0</config:config-item> + <config:config-item config:name="CursorPositionX" config:type="int">4</config:config-item> + <config:config-item config:name="CursorPositionY" config:type="int">17</config:config-item> <config:config-item config:name="ActiveSplitRange" config:type="short">2</config:config-item> <config:config-item config:name="PositionLeft" config:type="int">0</config:config-item> <config:config-item config:name="PositionRight" config:type="int">0</config:config-item> @@ -30,13 +30,13 @@ <config:config-item config:name="IgnoreBreakAfterMultilineField" config:type="boolean">false</config:config-item> </config:config-item-map-entry> <config:config-item-map-entry config:name="Sheet2"> - <config:config-item config:name="CursorPositionX" config:type="int">1</config:config-item> - <config:config-item config:name="CursorPositionY" config:type="int">115</config:config-item> + <config:config-item config:name="CursorPositionX" config:type="int">4</config:config-item> + <config:config-item config:name="CursorPositionY" config:type="int">43</config:config-item> <config:config-item config:name="ActiveSplitRange" config:type="short">2</config:config-item> <config:config-item config:name="PositionLeft" config:type="int">0</config:config-item> <config:config-item config:name="PositionRight" config:type="int">0</config:config-item> <config:config-item config:name="PositionTop" config:type="int">0</config:config-item> - <config:config-item config:name="PositionBottom" config:type="int">0</config:config-item> + <config:config-item config:name="PositionBottom" config:type="int">24</config:config-item> <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> <config:config-item config:name="ZoomValue" config:type="int">65</config:config-item> <config:config-item config:name="PageViewZoomValue" config:type="int">60</config:config-item> @@ -48,7 +48,7 @@ </config:config-item-map-entry> </config:config-item-map-named> <config:config-item config:name="ActiveTable" config:type="string">Sheet1</config:config-item> - <config:config-item config:name="HorizontalScrollbarWidth" config:type="int">1837</config:config-item> + <config:config-item config:name="HorizontalScrollbarWidth" config:type="int">1851</config:config-item> <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> <config:config-item config:name="ZoomValue" config:type="int">65</config:config-item> <config:config-item config:name="PageViewZoomValue" config:type="int">60</config:config-item> @@ -126,7 +126,7 @@ <config:config-item config:name="UpdateFromTemplate" config:type="boolean">true</config:config-item> <config:config-item-map-named config:name="ScriptConfiguration"> <config:config-item-map-entry config:name="Sheet1"> - <config:config-item config:name="CodeName" config:type="string">Munkalap1</config:config-item> + <config:config-item config:name="CodeName" config:type="string">Sheet1</config:config-item> </config:config-item-map-entry> <config:config-item-map-entry config:name="Sheet2"> <config:config-item config:name="CodeName" config:type="string">Sheet2</config:config-item> @@ -1612,9 +1612,6 @@ <style:style style:name="ro4" style:family="table-row"> <style:table-row-properties style:row-height="0.529cm" fo:break-before="auto" style:use-optimal-row-height="true"/> </style:style> - <style:style style:name="ro5" style:family="table-row"> - <style:table-row-properties style:row-height="1.632cm" fo:break-before="auto" style:use-optimal-row-height="true"/> - </style:style> <style:style style:name="ta1" style:family="table" style:master-page-name="Default"> <style:table-properties table:display="true" style:writing-mode="lr-tb"/> </style:style> @@ -1719,7 +1716,7 @@ <text:p><text:sheet-name>???</text:sheet-name><text:s/>(<text:title>???</text:title>)</text:p> </style:region-left> <style:region-right> - <text:p><text:date style:data-style-name="N2" text:date-value="2024-02-01">0000.00.00</text:date>, <text:time style:data-style-name="N2" text:time-value="14:12:01.197000000">00:00:00</text:time></text:p> + <text:p><text:date style:data-style-name="N2" text:date-value="2024-02-08">0000.00.00</text:date>, <text:time style:data-style-name="N2" text:time-value="21:35:29.191000000">00:00:00</text:time></text:p> </style:region-right> </style:header> <style:header-left style:display="false"/> @@ -1998,10 +1995,10 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("Ireland";[.H2:.H11];[.J2:.J11])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:formula="of:=#N/A" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:style-name="ce18" table:formula="of:=ISNA([.A5])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> <text:p>IGAZ</text:p> @@ -2161,10 +2158,10 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("";[.H2:.H11];[.J2:.J11])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:formula="of:=#N/A" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:style-name="ce18" table:formula="of:=ISNA([.A9])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> <text:p>IGAZ</text:p> @@ -2509,10 +2506,10 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:number-matrix-columns-spanned="1" table:number-matrix-rows-spanned="2" table:formula="of:=COM.MICROSOFT.XLOOKUP("";[.I14:.R14];[.I15:.R16])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:formula="of:=#N/A" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:style-name="ce18" table:formula="of:=ISNA([.A20])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> <text:p>IGAZ</text:p> @@ -2524,10 +2521,10 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:formula="of:=#N/A" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell table:style-name="ce18" table:formula="of:=ISNA([.A21])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> <text:p>IGAZ</text:p> @@ -2712,7 +2709,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP([.G29];[.I30:.I35];[.H30:.H35];;2;2)" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>#N/A</text:p> @@ -3059,20 +3056,20 @@ <table:table-cell table:style-name="ce18"/> <table:table-cell table:number-columns-repeated="17"/> </table:table-row> - <table:table-row table:style-name="ro5"> - <table:table-cell table:formula="of:=SUM(COM.MICROSOFT.XLOOKUP([.G44];[.H45:.H49];[.K45:.K49]):COM.MICROSOFT.XLOOKUP([.G45];[.H45:.H49];[.K45:.K49]))" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>Hiba:502</text:p> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=SUM(COM.MICROSOFT.XLOOKUP([.G44];[.H45:.H49];[.K45:.K49]):COM.MICROSOFT.XLOOKUP([.G45];[.H45:.H49];[.K45:.K49]))" office:value-type="float" office:value="110.56" calcext:value-type="float"> + <text:p>110,56</text:p> </table:table-cell> - <table:table-cell office:value-type="float" office:value="11070" calcext:value-type="float"> - <text:p>11070</text:p> + <table:table-cell office:value-type="float" office:value="110.56" calcext:value-type="float"> + <text:p>110,56</text:p> </table:table-cell> - <table:table-cell table:style-name="ce18"/> - <table:table-cell table:formula="of:=FORMULA([.A44])" office:value-type="string" office:string-value="=SZUM(XLOOKUP(G44;H45:H49;K45:K49):XLOOKUP(G45;H45:H49;K45:K49))" calcext:value-type="string"> - <text:p>=SZUM(XLOOKUP(G44;H45:H49;K45:K49):XLOOKUP(G45;H45:H49;K45:K49))</text:p> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A44]=[.B44]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>IGAZ</text:p> </table:table-cell> - <table:table-cell table:style-name="ce12" office:value-type="string" calcext:value-type="string"> - <text:p>XLOOKUP should (in this case) return a range (TODO: Missing feature from Calc: Evaluate Formula)</text:p> + <table:table-cell table:formula="of:=FORMULA([.A44])" office:value-type="string" office:string-value="=SUM(XLOOKUP(G44;H45:H49;K45:K49):XLOOKUP(G45;H45:H49;K45:K49))" calcext:value-type="string"> + <text:p>=SUM(XLOOKUP(G44;H45:H49;K45:K49):XLOOKUP(G45;H45:H49;K45:K49))</text:p> </table:table-cell> + <table:table-cell table:style-name="ce12"/> <table:table-cell/> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>Grape</text:p> @@ -3191,7 +3188,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("B";[.H51:.H53];[.K51:.K52])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>Hiba:504</text:p> + <text:p>Err:504</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>err:504</text:p> @@ -3224,7 +3221,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("C";[.H51:.H53];[.K51:.K52])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>Hiba:504</text:p> + <text:p>Err:504</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>err:504</text:p> @@ -3257,7 +3254,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("E";[.H51:.I53];[.K51:.L53])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>Hiba:504</text:p> + <text:p>Err:504</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>err:504</text:p> @@ -3290,7 +3287,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("E";[.H51:.I53];[.K51:.K53])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>Hiba:504</text:p> + <text:p>Err:504</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>err:504</text:p> @@ -3309,7 +3306,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("C";[.H51:.I53];[.K51:.K53])" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>Hiba:504</text:p> + <text:p>Err:504</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>err:504</text:p> @@ -4321,7 +4318,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("C?";[.H$95:.L$95];[.H$96:.L$96];;2;1)" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>#N/A</text:p> @@ -4470,7 +4467,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP("f?";[.I$79:.I$83];[.L$79:.L$83];;2;1)" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>#N/A</text:p> @@ -4639,7 +4636,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP([.M1];[.K$1:.K$12];[.I$1:.I$12];;0;2)" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>#N/A</text:p> @@ -4659,7 +4656,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP([.$O$1];[.P$1:.P$11];[.T$1:.T$11];;0;2)" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>#N/A</text:p> @@ -4754,7 +4751,7 @@ </table:table-row> <table:table-row table:style-name="ro2"> <table:table-cell table:formula="of:=COM.MICROSOFT.XLOOKUP([.$O$1];[.R$1:.R$11];[.T$1:.T$11];;0;-2)" office:value-type="string" office:string-value="" calcext:value-type="error"> - <text:p>#HIÁNYZIK</text:p> + <text:p>#N/A</text:p> </table:table-cell> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>#N/A</text:p> diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 22fc30c23976..960516d787ea 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -7674,24 +7674,51 @@ void ScInterpreter::ScXLookup() // 3rd argument is return value array ScMatrixRef prMat = nullptr; + SCCOL nSearchCol1 = 0; + SCROW nSearchRow1 = 0; + SCTAB nSearchTab1 = 0; + SCCOL nSearchCol2 = 0; + SCROW nSearchRow2 = 0; + SCTAB nSearchTab2 = 0; SCSIZE nrC = 0, nrR = 0; - StackVar eType = GetStackType(); - switch ( eType ) + + switch ( GetStackType() ) { - case svDoubleRef : case svSingleRef : - case svExternalDoubleRef : - case svExternalSingleRef : + PopSingleRef(nSearchCol1, nSearchRow1, nSearchTab1); + nSearchCol2 = nSearchCol1; + nSearchRow2 = nSearchRow1; + nrC = nSearchCol2 - nSearchCol1 + 1; + nrR = nSearchRow2 - nSearchRow1 + 1; + break; + case svDoubleRef: + { + PopDoubleRef(nSearchCol1, nSearchRow1, nSearchTab1, nSearchCol2, nSearchRow2, nSearchTab2); + if (nSearchTab1 != nSearchTab2) + { + PushIllegalParameter(); + return; + } + nrC = nSearchCol2 - nSearchCol1 + 1; + nrR = nSearchRow2 - nSearchRow1 + 1; + } + break; case svMatrix : - prMat = GetMatrix(); - if ( prMat ) - prMat->GetDimensions( nrC, nrR ); + case svExternalDoubleRef : + { + if (GetStackType() == svMatrix) + prMat = PopMatrix(); else + PopExternalDoubleRef(prMat); + + if (!prMat) { PushIllegalParameter(); return; } - break; + prMat->GetDimensions(nrC, nrR); + } + break; default : PushIllegalParameter(); @@ -7857,50 +7884,56 @@ void ScInterpreter::ScXLookup() nResCols = 1; nResRows = nrR; } - // if result matrix has more than one row or column push matrix else push single value + // if result has more than one row or column push double ref or matrix, else push single ref if ( nResCols > 1 || nResRows > 1 ) { - // result is matrix, make/fill matrix with output and push that - ScMatrixRef pResMat = GetNewMat( nResCols, nResRows, /*bEmpty*/true ); - if ( pResMat ) + if (prMat) { - for ( SCSIZE i = 0; i < nResCols; i++ ) + // result is matrix, make / fill matrix with output and push that + ScMatrixRef pResMat = GetNewMat(nResCols, nResRows, /*bEmpty*/true); + if (pResMat) { - for ( SCSIZE j = 0; j < nResRows; j++ ) + for (SCSIZE i = 0; i < nResCols; i++) { - SCSIZE ri; - SCSIZE rj; - if ( vsa.bVLookup ) - { - ri = nX + i; - rj = nY; - } - else + for (SCSIZE j = 0; j < nResRows; j++) { - ri = nX; - rj = nY + j; + SCSIZE ri; + SCSIZE rj; + if (vsa.bVLookup) + { + ri = nX + i; + rj = nY; + } + else + { + ri = nX; + rj = nY + j; + } + if (prMat->IsStringOrEmpty(ri, rj)) + pResMat->PutString(prMat->GetString(ri, rj), i, j); + else + pResMat->PutDouble(prMat->GetDouble(ri, rj), i, j); } - if ( prMat->IsStringOrEmpty( ri, rj ) ) - pResMat->PutString( prMat->GetString( ri, rj ), i, j ); - else - pResMat->PutDouble( prMat->GetDouble( ri, rj ), i, j ); } + PushMatrix(pResMat); + } + else + { + PushIllegalParameter(); + return; } - PushMatrix( pResMat ); } else { - PushIllegalParameter(); - return; + // result is a double ref + PushDoubleRef(nSearchCol1 + nX, nSearchRow1 + nY, nSearchTab1, + nSearchCol1 + (nResCols - 1) + nX, nSearchRow1 + (nResRows - 1) + nY, nSearchTab1); } } else { - // result is a single value - if ( prMat->IsStringOrEmpty( nX, nY) ) - PushString( prMat->GetString( nX, nY ).getString() ); - else - PushDouble( prMat->GetDouble( nX, nY ) ); + // result is a single ref + PushSingleRef(nSearchCol1 + nX, nSearchRow1 + nY, nSearchTab1); } } else