core.git: sc/inc sc/source

2024-02-16 Thread Winfried Donkers (via logerrit)
 sc/inc/queryiter.hxx  |8 
 sc/source/core/data/queryiter.cxx |   27 +--
 sc/source/core/inc/interpre.hxx   |6 +++---
 sc/source/core/tool/interpr1.cxx  |   35 ++-
 4 files changed, 42 insertions(+), 34 deletions(-)

New commits:
commit 88ba9fab08514b96f458bb8c0ace175b2790638e
Author: Winfried Donkers 
AuthorDate: Sun Feb 11 16:18:44 2024 +0100
Commit: Balazs Varga 
CommitDate: Fri Feb 16 11:01:17 2024 +0100

Prepare search code for other functions than MATCH and XLOOKUP.

Purpose is to use one set of code for all similar lookup functions, as
they now each have their own code, which is largely identical.
Next steps will be to make the code used by XLOOKUP and MATCH work with
each similar lookup function.
This patch just changes the interface to accomodate other functions.

Change-Id: I6950aa69404f3eb8acbf2d55e247058f3e798814
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163230
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/sc/inc/queryiter.hxx b/sc/inc/queryiter.hxx
index 32fd1cb83898..f494b83d74a5 100644
--- a/sc/inc/queryiter.hxx
+++ b/sc/inc/queryiter.hxx
@@ -183,7 +183,7 @@ protected:
 sal_uInt8nSortedBinarySearch;
 boolbAdvanceQuery;
 boolbIgnoreMismatchOnLeadingStrings;
-boolbXLookUp;
+sal_uInt16  nSearchOpCode;
 SCCOL   nBestFitCol;
 SCROW   nBestFitRow;
 
@@ -276,8 +276,8 @@ public:
 nSearchbAscd : (nSearchMode == -2 ? 
nSearchbDesc : nBinarySearchDisabled));
 }
 
-voidSetXlookupMode( bool bVal )
-{ bXLookUp = bVal; }
+voidSetLookupMode( sal_uInt16 nVal )
+{ nSearchOpCode = nVal; }
 };
 
 
@@ -325,7 +325,7 @@ class ScQueryCellIterator
 using Base::getThisResult;
 using Base::nBestFitCol;
 using Base::nBestFitRow;
-using Base::bXLookUp;
+using Base::nSearchOpCode;
 
 bool GetThis();
 
diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index 56d4081e7255..8abaa2b93fdd 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -67,7 +67,7 @@ ScQueryCellIteratorBase< accessType, queryType 
>::ScQueryCellIteratorBase(ScDocu
 , nSortedBinarySearch( nBinarySearchDisabled )
 , bAdvanceQuery( false )
 , bIgnoreMismatchOnLeadingStrings( false )
-, bXLookUp( false )
+, nSearchOpCode( SC_OPCODE_NONE )
 , nBestFitCol(SCCOL_MAX)
 , nBestFitRow(SCROW_MAX)
 {
@@ -207,7 +207,8 @@ void ScQueryCellIteratorBase< accessType, queryType 
>::PerformQuery()
 return;
 
 // XLookUp: Forward/asc/backward/desc search for best fit 
value, except if we have an exact match
-if (bXLookUp && (rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == 
SC_GREATER_EQUAL) &&
+if (nSearchOpCode == SC_OPCODE_X_LOOKUP &&
+(rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == 
SC_GREATER_EQUAL) &&
 (nBestFitCol != nCol || nBestFitRow != nRow))
 {
 bool bNumSearch = rItem.meType == ScQueryEntry::ByValue && 
aCell.hasNumeric();
@@ -315,7 +316,7 @@ void ScQueryCellIteratorBase< accessType, queryType 
>::InitPos()
 // is the one after it.
 lastRow = nRow;
 // BinarySearch() looks for the first match for XLOOKUP
-if (!bXLookUp)
+if (nSearchOpCode != SC_OPCODE_X_LOOKUP)
 {
 ScQueryOp saveOp = op;
 op = SC_LESS;
@@ -341,7 +342,7 @@ void ScQueryCellIteratorBase< accessType, queryType 
>::InitPos()
 if( BinarySearch( nCol ))
 lastRow = nRow;
 }
-AccessBase::InitPosFinish(beforeRow, lastRow, bXLookUp);
+AccessBase::InitPosFinish(beforeRow, lastRow, (nSearchOpCode == 
SC_OPCODE_X_LOOKUP));
 }
 }
 
@@ -545,7 +546,9 @@ bool ScQueryCellIteratorBase< accessType, queryType 
>::BinarySearch( SCCOL col,
 {
 if (fLastInRangeValue <= nCellVal)
 {
-if (bXLookUp && nSortedBinarySearch != nSearchbDesc && 
fLastInRangeValue == nCellVal && aIndexer.getLowIndex() != i)
+if (nSearchOpCode  == SC_OPCODE_X_LOOKUP &&
+nSortedBinarySearch != nSearchbDesc &&
+fLastInRangeValue == nCellVal && 
aIndexer.getLowIndex() != i)
 bDone = true;
 else
 {
@@ -593,7 +596,9 @@ bool ScQueryCellIteratorBase< accessType, queryType 
>::BinarySearch( SCCOL col,
 aCellStr);
 if (nTmp <= 0)
 {
-  

core.git: formula/inc include/formula sc/inc sc/qa sc/README.md sc/source

2024-01-31 Thread Winfried Donkers (via logerrit)
 formula/inc/core_resource.hrc   |6 
 include/formula/compiler.hxx|2 
 include/formula/opcode.hxx  |2 
 sc/README.md|1 
 sc/inc/helpids.h|1 
 sc/inc/queryiter.hxx|   60 
 sc/inc/scfuncs.hrc  |   18 
 sc/qa/extras/scfunctionlistobj.cxx  |2 
 sc/qa/unit/data/functions/spreadsheet/fods/xlookup.fods | 4553 
 sc/qa/unit/ucalc.cxx|1 
 sc/qa/unit/ucalc_sort.cxx   |4 
 sc/source/core/data/funcdesc.cxx|1 
 sc/source/core/data/queryiter.cxx   |  184 
 sc/source/core/inc/interpre.hxx |   61 
 sc/source/core/tool/interpr1.cxx| 1232 +++-
 sc/source/core/tool/interpr4.cxx|1 
 sc/source/core/tool/parclass.cxx|1 
 sc/source/core/tool/token.cxx   |1 
 sc/source/filter/excel/xlformula.cxx|   13 
 sc/source/filter/oox/formulabase.cxx|   15 
 20 files changed, 5816 insertions(+), 343 deletions(-)

New commits:
commit f7039822c7ad3987326e1c20ea4a745c158f9682
Author: Winfried Donkers 
AuthorDate: Wed Jun 28 16:13:45 2023 +0200
Commit: Balazs Varga 
CommitDate: Wed Jan 31 09:14:19 2024 +0100

tdf#127293 Add Excel2021 function XLOOKUP to Calc

https://issues.oasis-open.org/browse/OFFICE-4154

What is working already: xlookup with normal forward,
backward search in columns/rows. Binary search in rows with
real binary search algorithm, in columns only works with linear search yet.
Linear forward backward wildcard/regex search in columns/rows.
Looking for the first smaller or greater value with linear and binary search
ALso all the combination of all these options. Except XLOOKUP
not supperted wildcard/regex search with binary search.

TODO in next patches:
- add the binary search option for searching in columns.
- Evaluate Formula calculation not working in general.

Co-authored-by: Balazs Varga 

Change-Id: I15fd4479b63ec13b093d269760d1bbb5957553e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131905
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Reviewed-by: Balazs Varga 

diff --git a/formula/inc/core_resource.hrc b/formula/inc/core_resource.hrc
index baed318f586e..835d928ea4a8 100644
--- a/formula/inc/core_resource.hrc
+++ b/formula/inc/core_resource.hrc
@@ -275,6 +275,7 @@ const std::pair 
RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF[] =
 { "COUNTIFS" , SC_OPCODE_COUNT_IFS },
 { "LOOKUP" , SC_OPCODE_LOOKUP },
 { "VLOOKUP" , SC_OPCODE_V_LOOKUP },
+{ "COM.MICROSOFT.XLOOKUP" , SC_OPCODE_X_LOOKUP },
 { "HLOOKUP" , SC_OPCODE_H_LOOKUP },
 { "ORG.OPENOFFICE.MULTIRANGE" , SC_OPCODE_MULTI_AREA }, // legacy for 
range list (union)
 { "OFFSET" , SC_OPCODE_OFFSET },
@@ -722,6 +723,7 @@ const std::pair 
RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML[] =
 { "COUNTIFS" , SC_OPCODE_COUNT_IFS },
 { "LOOKUP" , SC_OPCODE_LOOKUP },
 { "VLOOKUP" , SC_OPCODE_V_LOOKUP },
+{ "_xlfn.XLOOKUP" , SC_OPCODE_X_LOOKUP },
 { "HLOOKUP" , SC_OPCODE_H_LOOKUP },
 { "_xlfn.ORG.OPENOFFICE.MULTIRANGE" , SC_OPCODE_MULTI_AREA }, // legacy 
for range list (union)
 { "OFFSET" , SC_OPCODE_OFFSET },
@@ -1172,6 +1174,7 @@ const std::pair 
RID_STRLIST_FUNCTION_NAMES_ENGLISH_PODF[] =
 { "COUNTIFS" , SC_OPCODE_COUNT_IFS },
 { "LOOKUP" , SC_OPCODE_LOOKUP },
 { "VLOOKUP" , SC_OPCODE_V_LOOKUP },
+{ "XLOOKUP" , SC_OPCODE_X_LOOKUP },
 { "HLOOKUP" , SC_OPCODE_H_LOOKUP },
 { "MULTIRANGE" , SC_OPCODE_MULTI_AREA },// legacy for range list 
(union)
 { "OFFSET" , SC_OPCODE_OFFSET },
@@ -1623,6 +1626,7 @@ const std::pair 
RID_STRLIST_FUNCTION_NAMES_ENGLISH_API[] =
 { "COUNTIFS" , SC_OPCODE_COUNT_IFS },
 { "LOOKUP" , SC_OPCODE_LOOKUP },
 { "VLOOKUP" , SC_OPCODE_V_LOOKUP },
+{ "XLOOKUP" , SC_OPCODE_X_LOOKUP },
 { "HLOOKUP" , SC_OPCODE_H_LOOKUP },
 { "MULTIRANGE" , SC_OPCODE_MULTI_AREA },// legacy for range list 
(union)
 { "OFFSET" , SC_OPCODE_OFFSET },
@@ -2072,6 +2076,7 @@ const std::pair 
RID_STRLIST_FUNCTION_NAMES_ENGLISH[] =
 { "COUNTIFS" , SC_OPCODE_COUNT_IFS },
 { "LOOKUP" , SC_OPCODE_LOOKUP },
 { "VLOOKUP" , SC_OPCODE_V_LOOKUP },
+{ "XLOOKUP" , SC_OPCODE_X_LOOKUP },
 { "HLOOKUP" , SC_OPCODE_H_LOOKUP },
 { "MULTIRANGE" , SC_OPCODE_MULTI_AREA },
 { "OFFSET" , SC_OPCODE_OFFSET },
@@ -2502,6 +2507,7 @@ const std::pair 
RID_STRLIST_FUNCTION_NAMES[] =
 { NC_("RID_STRLIST_FUNCTION_NAMES", "COUNTIFS") , SC_OPCODE_COUNT_IFS },
 { NC_("RID_STRLIST_FUNCTION_NAMES", 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/qa sc/source

2023-01-16 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods |   41 --
 sc/qa/unit/data/functions/spreadsheet/fods/match.fods   |   46 ---
 sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods |   65 +++-
 sc/source/core/tool/interpr1.cxx|   23 -
 4 files changed, 152 insertions(+), 23 deletions(-)

New commits:
commit a5103adc413fb2cc8811c8691de5bfbe2df51961
Author: Winfried Donkers 
AuthorDate: Sat Dec 31 15:54:57 2022 +0100
Commit: Xisco Fauli 
CommitDate: Mon Jan 16 08:40:21 2023 +

tdf#152774 Fix incorrect result with MATCH, HLOOKUP and VLOOKUP.

 This is a combination of 2 commits.

tdf#152774 Fix incorrect result with MATCH.

Use case now complies with ODF 6.9.14 (MATCH).
Added use case to unit test.

xChange-Id: I749a979135fbc01a3bb1583092fb6d6a100e2d2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144883
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 0ce4c1e6898ba83d487f1b225dc9ee0bbc00d9fc)

tdf#152774 Fix incorrect result with HLOOKUP and VLOOKUP.

Use case now complies with ODF 6.9.5 (HLOOKUP) and 6.9.12 (VLOOKUP).
Added use case to unit test.

xChange-Id: I19df718b6446098f614136f462662c753a515036
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145514
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit bf432958c1d6d204511a6bb32e2c06161d811676)

Change-Id: I749a979135fbc01a3bb1583092fb6d6a100e2d2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145529
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
index e3b38cf6c85b..8e14a315ac2a 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
@@ -1304,10 +1304,41 @@
  
  
 
-
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=HLOOKUP(a,{1;3;b;d},1,1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=HLOOKUP(a,{1;3;b;d},1,0)
+ 
+ 
+  tdf152774
+ 
+ 
 
 
  
@@ -1391,4 +1422,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/match.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
index a050773c07e3..d5debd0d6339 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
@@ -5716,11 +5716,23 @@
  
  
 
-
- 
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=MATCH(a,{1,3,b,d},1)
+ 
+ 
+  Tdf#152774
+ 
+ 
  
   4
  
@@ -5731,11 +5743,23 @@
  
  
 
-
- 
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  =MATCH(4,{d,b,3,1},-1)
+ 
+ 
+  Tdf#152774
+ 
+ 
  
   3
  
@@ -6255,4 +6279,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
index 354aff0d763d..e0a0530a65e7 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
@@ -2559,8 +2559,67 @@
  
  
 
-
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=VLOOKUP(a,{1;3;b;d},1,1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=VLOOKUP(a,{1;3;b;d},1,0)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  c
+ 
+ 
+  c
+ 
+ 
+  TRUE
+ 
+ 
+  =VLOOKUP(3, 
{1,a,d;2,b,e;3,c,f},
 2, 1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+ 
+ 
+
+
+ 
 
 
  
@@ -2592,4 +2651,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 0785318da871..d82acb37494c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5052,7 +5052,11 @@ void ScInterpreter::ScMatch()
 
 if (nHitIndex > 0) // valid hit must be 2nd item or higher
 {
-PushDouble( nHitIndex); // non-exact match
+if ( ! ( rItem.meType == ScQueryEntry::ByString &&  
aMatAcc.IsValue( nHitIndex-1 ) ) &&
+ ! ( rItem.meType == ScQueryEntry::ByValue  && 
!aMatAcc.IsValue( nHitIndex-1 ) ) )
+   

[Libreoffice-commits] core.git: sc/qa sc/source

2023-01-15 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods |   41 --
 sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods |   65 +++-
 sc/source/core/tool/interpr1.cxx|   17 +++-
 3 files changed, 112 insertions(+), 11 deletions(-)

New commits:
commit bf432958c1d6d204511a6bb32e2c06161d811676
Author: Winfried Donkers 
AuthorDate: Sat Jan 14 18:01:12 2023 +0100
Commit: Eike Rathke 
CommitDate: Sun Jan 15 16:02:49 2023 +

tdf#152774 Fix incorrect result with HLOOKUP and VLOOKUP.

Use case now complies with ODF 6.9.5 (HLOOKUP) and 6.9.12 (VLOOKUP).
Added use case to unit test.

Change-Id: I19df718b6446098f614136f462662c753a515036
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145514
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
index e3b38cf6c85b..8e14a315ac2a 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
@@ -1304,10 +1304,41 @@
  
  
 
-
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=HLOOKUP(a,{1;3;b;d},1,1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=HLOOKUP(a,{1;3;b;d},1,0)
+ 
+ 
+  tdf152774
+ 
+ 
 
 
  
@@ -1391,4 +1422,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
index 354aff0d763d..e0a0530a65e7 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
@@ -2559,8 +2559,67 @@
  
  
 
-
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=VLOOKUP(a,{1;3;b;d},1,1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=VLOOKUP(a,{1;3;b;d},1,0)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  c
+ 
+ 
+  c
+ 
+ 
+  TRUE
+ 
+ 
+  =VLOOKUP(3, 
{1,a,d;2,b,e;3,c,f},
 2, 1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+ 
+ 
+
+
+ 
 
 
  
@@ -2592,4 +2651,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c47aec4b052c..d82acb37494c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5064,6 +5064,7 @@ void ScInterpreter::ScMatch()
 return;
 }
 
+// The source data is cell range.
 SCCOLROW nDelta = 0;
 if (nCol1 == nCol2)
 {   // search row in column
@@ -7508,16 +7509,26 @@ void ScInterpreter::CalculateLookup(bool bHLookup)
 {
 SCSIZE nX = static_cast(nSpIndex);
 SCSIZE nY = nDelta;
+SCSIZE nXs = 0;
+SCSIZE nYs = nY;
 if ( bHLookup )
 {
 nX = nDelta;
 nY = static_cast(nZIndex);
+nXs = nX;
+nYs = 0;
 }
 assert( nX < nC && nY < nR );
-if ( pMat->IsStringOrEmpty( nX, nY) )
-PushString(pMat->GetString( nX,nY).getString());
+if (!(rItem.meType == ScQueryEntry::ByString && pMat->IsValue( 
nXs, nYs)))
+{
+if (pMat->IsStringOrEmpty( nX, nY))
+PushString(pMat->GetString( nX, nY).getString());
+else
+PushDouble(pMat->GetDouble( nX, nY));
+}
 else
-PushDouble(pMat->GetDouble( nX,nY));
+PushNA();
+return;
 }
 else
 PushNA();


[Libreoffice-commits] core.git: sc/qa sc/source

2023-01-12 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/spreadsheet/fods/match.fods |   46 +-
 sc/source/core/tool/interpr1.cxx  |6 +-
 2 files changed, 40 insertions(+), 12 deletions(-)

New commits:
commit 0ce4c1e6898ba83d487f1b225dc9ee0bbc00d9fc
Author: Winfried Donkers 
AuthorDate: Sat Dec 31 15:54:57 2022 +0100
Commit: Eike Rathke 
CommitDate: Thu Jan 12 14:55:30 2023 +

tdf#152774 Fix incorrect result with MATCH.

Use case now complies with ODF 6.9.14 (MATCH).
Added use case to unit test.

Change-Id: I749a979135fbc01a3bb1583092fb6d6a100e2d2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144883
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/match.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
index a050773c07e3..d5debd0d6339 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
@@ -5716,11 +5716,23 @@
  
  
 
-
- 
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=MATCH(a,{1,3,b,d},1)
+ 
+ 
+  Tdf#152774
+ 
+ 
  
   4
  
@@ -5731,11 +5743,23 @@
  
  
 
-
- 
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  =MATCH(4,{d,b,3,1},-1)
+ 
+ 
+  Tdf#152774
+ 
+ 
  
   3
  
@@ -6255,4 +6279,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 0785318da871..c47aec4b052c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5052,7 +5052,11 @@ void ScInterpreter::ScMatch()
 
 if (nHitIndex > 0) // valid hit must be 2nd item or higher
 {
-PushDouble( nHitIndex); // non-exact match
+if ( ! ( rItem.meType == ScQueryEntry::ByString &&  
aMatAcc.IsValue( nHitIndex-1 ) ) &&
+ ! ( rItem.meType == ScQueryEntry::ByValue  && 
!aMatAcc.IsValue( nHitIndex-1 ) ) )
+PushDouble( nHitIndex); // non-exact match
+else
+PushNA();
 return;
 }
 


[Libreoffice-commits] core.git: sc/qa sc/source

2022-02-10 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/text/fods/clean.fods | 1085 ++---
 sc/source/core/tool/interpr1.cxx   |   19 
 2 files changed, 833 insertions(+), 271 deletions(-)

New commits:
commit 61f4250ee9f43902107e4d2e6322cbf54f52dd8e
Author: Winfried Donkers 
AuthorDate: Mon Jan 31 14:04:17 2022 +0100
Commit: Mike Kaganski 
CommitDate: Thu Feb 10 18:39:32 2022 +0100

Make CLEAN fully compliant woth ODFF v1.3

Not only check for characters of category Cc, but also for characters of
category Cn.
Use generic functions to check is characters belong to one of the above
categories.

Follow up of commit e38ebf0737297fe94e3128459fc25ef9259faa6b.

Change-Id: I97618dbf33db70b01b2833cf653988610b499333
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129222
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/functions/text/fods/clean.fods 
b/sc/qa/unit/data/functions/text/fods/clean.fods
index 0230953d00e5..c5531ad364d5 100644
--- a/sc/qa/unit/data/functions/text/fods/clean.fods
+++ b/sc/qa/unit/data/functions/text/fods/clean.fods
@@ -344,8 +344,8 @@
   

-
+   €
€
-   

   
   
@@ -2132,7 +2132,7 @@
   =CLEAN(J36)
  
  
-  Unicode Cn
+  Unicode Cc
  
  
  
@@ -2168,7 +2168,7 @@
   =CLEAN(J37)
  
  
-  Unicode Cn
+  Unicode Cc
  
  
  
@@ -2177,11 +2177,11 @@
  
   128
  
- 
-  €
+ 
+  €
  
- 
-  €Test text€
+ 
+  €Test text€
  
  
   Tdf#97706
@@ -2204,7 +2204,7 @@
   =CLEAN(J38)
  
  
-  Unicode Cn
+  Unicode Cc
  
  
  
@@ -2213,11 +2213,11 @@
  
   129
  
- 
-  
+ 
+  
  
- 
-  Test text
+ 
+  Test text
  
  
   Tdf#97706
@@ -2240,7 +2240,7 @@
   =CLEAN(J39)
  
  
-  Unicode Cn
+  Unicode Cc
  
  
  
@@ -2249,11 +2249,11 @@
  
   130
  
- 
-  ‚
+ 
+  ‚
  
- 
-  ‚Test text‚
+ 
+  ‚Test text‚
  
  
   Tdf#97706
@@ -2276,7 +2276,7 @@
   =CLEAN(J40)
  
  
-  Unicode Cn
+  Unicode Cc
  
  
  
@@ -2285,11 +2285,11 @@
  
   131
  
- 
-  ƒ
+ 
+  ƒ
  
- 
-  ƒTest textƒ
+ 
+  ƒTest textƒ
  
  
   Tdf#97706
@@ -2308,24 +2308,24 @@
  
   TRUE
  
- 
+ 
   =CLEAN(J41)
  
  
   Unicode Cn
  
  
- 
-  84
+ 
+  FFFE
  
- 
-  132
+ 
+  65534
  
- 
-  „
+ 
+  
  
- 
-  „Test text„
+ 
+  Test text
  
  
   Tdf#97706
@@ -2344,24 +2344,24 @@
  
   TRUE
  
- 
+ 
   =CLEAN(J42)
  
  
   Unicode Cn
  
  
- 
-  85
+ 
+  
  
- 
-  133
+ 
+  65535
  
- 
-  …
+ 
+  
  
- 
-  …Test text…
+ 
+  Test text
  
  
   Tdf#97706
@@ -2380,24 +2380,24 @@
  
   TRUE
  
- 
+ 
   =CLEAN(J43)
  
  
   Unicode Cn
  
  
- 
-  86
+ 
+  1FFFE
  
- 
-  134
+ 
+  131070
  
- 
-  †
+ 
+  🿾
  
- 
-  †Test text†
+ 
+  🿾Test text🿾
  
  
   Tdf#97706
@@ -2407,33 +2407,33 @@
  
 
 
- 
-  Test text
+ 
+  ïš“Test textïš“
  
- 
-  Test text
+ 
+  ïš“Test textïš“
  
  
   TRUE
  
- 
+ 
   =CLEAN(J44)
  
  
-  Unicode Cn
+  no clean
  
  
- 
-  87
+ 
+  F693
  
- 
-  135
+ 
+  63123
  
- 
-  ‡
+ 
+  ïš“
  
- 
-  ‡Test text‡
+ 
+  ïš“Test textïš“
  
  
   Tdf#97706
@@ -2443,33 +2443,33 @@
  
 
 
- 
-  Test text
+ 
+  Test text
  
- 
-  Test text
+ 
+  Test text
  
  
   TRUE
  
- 
+ 
   =CLEAN(J45)
  
  
-  Unicode Cn
+  no clean
  
  
- 
-  88
+ 
+  1F43C
  
- 
-  136
+ 
+  128060
  
- 
-  ˆ
+ 
+  
  
- 
-  ˆTest textˆ
+ 
+  Test text
  
  
   Tdf#97706
@@ -2479,33 +2479,33 @@
  
 
 
- 
-  Test text
+ 
+  �Test text�
  
- 
-  Test text
+ 
+  �Test text�
  
  
   TRUE
  
- 
+ 
   =CLEAN(J46)
  
  
-  Unicode Cn
+  no clean
  
  
- 
-  89
+ 
+  FFFD
  
- 
-  137
+ 
+  65533
  
- 
-  ‰
+ 
+  �
  
- 
-  ‰Test text‰
+ 
+  �Test text�
  
  
   Tdf#97706
@@ -2515,33 

[Libreoffice-commits] core.git: sc/qa sc/source

2022-01-24 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/text/fods/clean.fods | 3438 ++---
 sc/source/core/tool/interpr1.cxx   |3 
 2 files changed, 2532 insertions(+), 909 deletions(-)

New commits:
commit 34412339f863b35508842a3bf20fcc7341a006e7
Author: Winfried Donkers 
AuthorDate: Wed Jan 12 17:00:34 2022 +0100
Commit: Eike Rathke 
CommitDate: Mon Jan 24 23:42:05 2022 +0100

tdf#97706 CLEAN is neither ODFF nor OOXML conform.

Patch makes CLEAN 100% compliant with ODFF v1.3 and almost 100% compliant
with actual Excel results (just character 0x7F differs).

co-author: taylorlee...@gmail.com
Change-Id: Icc070ca2560b7ca7640128c5a538d1fbfa1193e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128350
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/functions/text/fods/clean.fods 
b/sc/qa/unit/data/functions/text/fods/clean.fods
index 58345a7f8ead..0230953d00e5 100644
--- a/sc/qa/unit/data/functions/text/fods/clean.fods
+++ b/sc/qa/unit/data/functions/text/fods/clean.fods
@@ -1,438 +1,440 @@
 
 
-http://www.w3.org/1999/xlink; 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation: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:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:scr
 ipt="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooo="http://openoffice.org/2004/office; 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:dom="http://www.w3.org/2001/xml-events; 
xmlns:xforms="http://www.w3.org/2002/xforms; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 
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:form
 x="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:css3t="http://www.w3.org/TR/css3-text/; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.spreadsheet">
+http://www.w3.org/TR/css3-text/; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:config="urn:oasis:nam
 es:tc:opendocument:xmlns:config:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:ooo="http://openoffice.org/2004/office; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events; 
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:fo
 rm:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:xforms="http://www.w3.org/2002/xforms; office:version="1.3" 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sc/qa sc/source

2021-12-10 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/database/fods/dcount.fods  |   21 +++
 sc/qa/unit/data/functions/database/fods/dcounta.fods |   21 +++
 sc/source/core/data/funcdesc.cxx |4 +--
 3 files changed, 36 insertions(+), 10 deletions(-)

New commits:
commit 1db4d3c869dbd4d68c0ab7b15c60bb2dad0a9f67
Author: Winfried Donkers 
AuthorDate: Thu Dec 9 17:39:58 2021 +0100
Commit: Xisco Fauli 
CommitDate: Fri Dec 10 13:52:37 2021 +0100

tdf#133353, Make 2nd argument optional for DCOUNT and DCOUNTA.

The functions accept empty second arguments, but the function
wizard and hints stated that it was required.

Change-Id: I74fcfcc31492ed776085d1bc6ee6a9ff22a87818
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126620
Tested-by: Eike Rathke 
Reviewed-by: Eike Rathke 
(cherry picked from commit 885465bc0ae6029d8adad57015fb0ff6c26a6ba6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126594
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/unit/data/functions/database/fods/dcount.fods 
b/sc/qa/unit/data/functions/database/fods/dcount.fods
index 392bc86d017d..4e2b792e08f2 100644
--- a/sc/qa/unit/data/functions/database/fods/dcount.fods
+++ b/sc/qa/unit/data/functions/database/fods/dcount.fods
@@ -2183,9 +2183,22 @@
  
 
 
- 
- 
- 
+ 
+  2
+ 
+ 
+  2
+ 
+ 
+  TRUE
+ 
+ 
+  =DCOUNT(J1:N11,,J41:N42)
+ 
+ 
+  Tdf#13353
+ 
+ 
  
   =I
  
@@ -2940,4 +2953,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/database/fods/dcounta.fods 
b/sc/qa/unit/data/functions/database/fods/dcounta.fods
index 1080e2cf64a5..c95c1472d713 100644
--- a/sc/qa/unit/data/functions/database/fods/dcounta.fods
+++ b/sc/qa/unit/data/functions/database/fods/dcounta.fods
@@ -864,9 +864,22 @@
  
 
 
- 
- 
- 
+ 
+  2
+ 
+ 
+  2
+ 
+ 
+  TRUE
+ 
+ 
+  =DCOUNTA(J1:N10,,J41:N42)
+ 
+ 
+  Tdf#13353
+ 
+ 
  
   Greta
  
@@ -1491,4 +1504,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 51f03a4e4bf4..01d8143a16f8 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -576,8 +576,8 @@ ScFunctionList::ScFunctionList()
 { SC_OPCODE_NOMINAL, ENTRY(SC_OPCODE_NOMINAL_ARY), 0, 
ID_FUNCTION_GRP_FINANCIAL, HID_FUNC_NOMINAL, 2, { 0, 0 }, 0 },
 { SC_OPCODE_SUB_TOTAL, ENTRY(SC_OPCODE_SUB_TOTAL_ARY), 0, 
ID_FUNCTION_GRP_MATH, HID_FUNC_TEILERGEBNIS, 2, { 0, 0 }, 0 },
 { SC_OPCODE_DB_SUM, ENTRY(SC_OPCODE_DB_SUM_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBSUMME, 3, { 0, 0, 0 }, 0 },
-{ SC_OPCODE_DB_COUNT, ENTRY(SC_OPCODE_DB_COUNT_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL, 3, { 0, 0, 0 }, 0 },
-{ SC_OPCODE_DB_COUNT_2, ENTRY(SC_OPCODE_DB_COUNT_2_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL2, 3, { 0, 0, 0 }, 0 },
+{ SC_OPCODE_DB_COUNT, ENTRY(SC_OPCODE_DB_COUNT_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL, 3, { 0, 1, 0 }, 0 },
+{ SC_OPCODE_DB_COUNT_2, ENTRY(SC_OPCODE_DB_COUNT_2_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL2, 3, { 0, 1, 0 }, 0 },
 { SC_OPCODE_DB_AVERAGE, ENTRY(SC_OPCODE_DB_AVERAGE_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBMITTELWERT, 3, { 0, 0, 0 }, 0 },
 { SC_OPCODE_DB_GET, ENTRY(SC_OPCODE_DB_GET_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBAUSZUG, 3, { 0, 0, 0 }, 0 },
 { SC_OPCODE_DB_MAX, ENTRY(SC_OPCODE_DB_MAX_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBMAX, 3, { 0, 0, 0 }, 0 },


[Libreoffice-commits] core.git: sc/qa sc/source

2021-12-09 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/database/fods/dcount.fods  |   21 +++
 sc/qa/unit/data/functions/database/fods/dcounta.fods |   21 +++
 sc/source/core/data/funcdesc.cxx |4 +--
 3 files changed, 36 insertions(+), 10 deletions(-)

New commits:
commit 885465bc0ae6029d8adad57015fb0ff6c26a6ba6
Author: Winfried Donkers 
AuthorDate: Thu Dec 9 17:39:58 2021 +0100
Commit: Eike Rathke 
CommitDate: Fri Dec 10 01:18:43 2021 +0100

tdf#133353, Make 2nd argument optional for DCOUNT and DCOUNTA.

The functions accept empty second arguments, but the function
wizard and hints stated that it was required.

Change-Id: I74fcfcc31492ed776085d1bc6ee6a9ff22a87818
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126620
Tested-by: Eike Rathke 
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/functions/database/fods/dcount.fods 
b/sc/qa/unit/data/functions/database/fods/dcount.fods
index 392bc86d017d..4e2b792e08f2 100644
--- a/sc/qa/unit/data/functions/database/fods/dcount.fods
+++ b/sc/qa/unit/data/functions/database/fods/dcount.fods
@@ -2183,9 +2183,22 @@
  
 
 
- 
- 
- 
+ 
+  2
+ 
+ 
+  2
+ 
+ 
+  TRUE
+ 
+ 
+  =DCOUNT(J1:N11,,J41:N42)
+ 
+ 
+  Tdf#13353
+ 
+ 
  
   =I
  
@@ -2940,4 +2953,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/database/fods/dcounta.fods 
b/sc/qa/unit/data/functions/database/fods/dcounta.fods
index 1080e2cf64a5..c95c1472d713 100644
--- a/sc/qa/unit/data/functions/database/fods/dcounta.fods
+++ b/sc/qa/unit/data/functions/database/fods/dcounta.fods
@@ -864,9 +864,22 @@
  
 
 
- 
- 
- 
+ 
+  2
+ 
+ 
+  2
+ 
+ 
+  TRUE
+ 
+ 
+  =DCOUNTA(J1:N10,,J41:N42)
+ 
+ 
+  Tdf#13353
+ 
+ 
  
   Greta
  
@@ -1491,4 +1504,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 51f03a4e4bf4..01d8143a16f8 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -576,8 +576,8 @@ ScFunctionList::ScFunctionList()
 { SC_OPCODE_NOMINAL, ENTRY(SC_OPCODE_NOMINAL_ARY), 0, 
ID_FUNCTION_GRP_FINANCIAL, HID_FUNC_NOMINAL, 2, { 0, 0 }, 0 },
 { SC_OPCODE_SUB_TOTAL, ENTRY(SC_OPCODE_SUB_TOTAL_ARY), 0, 
ID_FUNCTION_GRP_MATH, HID_FUNC_TEILERGEBNIS, 2, { 0, 0 }, 0 },
 { SC_OPCODE_DB_SUM, ENTRY(SC_OPCODE_DB_SUM_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBSUMME, 3, { 0, 0, 0 }, 0 },
-{ SC_OPCODE_DB_COUNT, ENTRY(SC_OPCODE_DB_COUNT_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL, 3, { 0, 0, 0 }, 0 },
-{ SC_OPCODE_DB_COUNT_2, ENTRY(SC_OPCODE_DB_COUNT_2_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL2, 3, { 0, 0, 0 }, 0 },
+{ SC_OPCODE_DB_COUNT, ENTRY(SC_OPCODE_DB_COUNT_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL, 3, { 0, 1, 0 }, 0 },
+{ SC_OPCODE_DB_COUNT_2, ENTRY(SC_OPCODE_DB_COUNT_2_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBANZAHL2, 3, { 0, 1, 0 }, 0 },
 { SC_OPCODE_DB_AVERAGE, ENTRY(SC_OPCODE_DB_AVERAGE_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBMITTELWERT, 3, { 0, 0, 0 }, 0 },
 { SC_OPCODE_DB_GET, ENTRY(SC_OPCODE_DB_GET_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBAUSZUG, 3, { 0, 0, 0 }, 0 },
 { SC_OPCODE_DB_MAX, ENTRY(SC_OPCODE_DB_MAX_ARY), 0, 
ID_FUNCTION_GRP_DATABASE, HID_FUNC_DBMAX, 3, { 0, 0, 0 }, 0 },


[Libreoffice-commits] core.git: scaddins/source sc/qa

2021-11-29 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/date_time/fods/weeks.fods |  652 +++-
 scaddins/source/datefunc/datefunc.cxx   |   71 --
 2 files changed, 659 insertions(+), 64 deletions(-)

New commits:
commit 105196aa00bc0d3e426796f6729a8e7e51271e56
Author: Winfried Donkers 
AuthorDate: Tue Nov 16 16:55:52 2021 +0100
Commit: Mike Kaganski 
CommitDate: Mon Nov 29 09:07:51 2021 +0100

tdf#145578, tdf#145587 revise calculations for WEEKS Add-In function

The calculations now follow the documentation for WEEKS in
https://wiki.documentfoundation.org/Documentation/Calc_Functions/WEEKS.

Change-Id: Ifede6e2ec2d9cfb7301fd5eb53bf7b6f187053bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125319
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/unit/data/functions/date_time/fods/weeks.fods 
b/sc/qa/unit/data/functions/date_time/fods/weeks.fods
index a0d596086220..f05803ea6684 100644
--- a/sc/qa/unit/data/functions/date_time/fods/weeks.fods
+++ b/sc/qa/unit/data/functions/date_time/fods/weeks.fods
@@ -1056,25 +1056,657 @@
  
 
 
- 
- 
- 
+ 
+  0
+ 
+ 
+  1
+ 
+ 
+  ONWAAR
+ 
+ 
+  =WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)
+ 
+ 
+  tdf#145578
+ 
+ 
  
   17
  
  
 
 
- 
- 
- 
- 
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  WAAR
+ 
+ 
+  =WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)
+ 
+ 
+  tdf#145578
+ 
+ 
  
  
-  12/01/2001
+  01-12-2001
  
  
 
+
+ 
+  0
+ 
+ 
+  -1
+ 
+ 
+  ONWAAR
+ 
+ 
+  =WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)
+ 
+ 
+  tdf#145578
+ 
+ 
+
+
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  WAAR
+ 
+ 
+  =WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)
+ 
+ 
+  tdf#145587
+ 
+ 
+
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  WAAR
+ 
+ 
+  =WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+ 
+
+
+ 
+  52
+ 
+ 
+  52
+ 
+ 
+  WAAR
+ 
+ 
+  =WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)
+ 
+ 
+  tdf#145578
+ 
+ 
+
+
+ 
+  -52
+ 
+ 
+  -52
+ 
+ 
+  WAAR
+ 
+ 
+  =WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)
+ 
+ 
+  tdf#145578
+ 
+ 
+
+
+ 
+  3
+ 
+ 
+  3
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS($K$19,$K$20,0)
+ 
+ 
+  tdf#145578
+ 
+ 
+ 
+  Sat -0001-11-27
+ 
+ 
+
+
+ 
+  4
+ 
+ 
+  4
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS($K$19,$K$20,1)
+ 
+ 
+  tdf#145578
+ 
+ 
+ 
+ 
+  Tue -0001-12-21
+ 
+ 
+
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J21,K21,M21)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  01/03/1
+ 
+ 
+  12/31/-1
+ 
+ 
+ 
+  0
+ 
+ 
+
+
+ 
+  -1
+ 
+ 
+  -1
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J22,K22,M22)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  01/03/1
+ 
+ 
+  12/31/-1
+ 
+ 
+ 
+  1
+ 
+ 
+
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J23,K23,M23)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  12/31/-1
+ 
+ 
+  01/03/1
+ 
+ 
+ 
+  0
+ 
+ 
+
+
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J24,K24,M24)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  12/31/-1
+ 
+ 
+  01/03/1
+ 
+ 
+ 
+  1
+ 
+ 
+
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J25,K25,M25)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  01/07/1
+ 
+ 
+  01/10/1
+ 
+ 
+ 
+  0
+ 
+ 
+
+
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J26,K26,M26)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  01/07/1
+ 
+ 
+  01/10/1
+ 
+ 
+ 
+  1
+ 
+ 
+
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J27,K27,M27)
+ 
+ 
+  tdf#145587
+ 
+ 
+ 
+  12/24/-1
+ 
+ 
+  12/27/-1
+ 
+ 
+ 
+  0
+ 
+ 
+
+
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  TRUE
+ 
+ 
+  =WEEKS(J28,K28,M28)
+ 
+ 
+  tdf#145587
+ 
+ 
+  

[Libreoffice-commits] core.git: chart2/Library_chartcore.mk chart2/source officecfg/registry

2019-05-20 Thread Winfried Donkers (via logerrit)
 chart2/Library_chartcore.mk   |3 
 chart2/source/view/charttypes/AreaChart.cxx   |   27 +-
 chart2/source/view/charttypes/ConfigAccess.cxx|   80 ++
 chart2/source/view/charttypes/VSeriesPlotter.cxx  |  161 ++
 chart2/source/view/inc/ConfigAccess.hxx   |   40 +++
 chart2/source/view/inc/VSeriesPlotter.hxx |   15 +
 officecfg/registry/schema/org/openoffice/Office/Chart.xcs |   13 +
 7 files changed, 333 insertions(+), 6 deletions(-)

New commits:
commit f6f27ae31a26bf6cecbf9205ef28a6bad3d06864
Author: Winfried Donkers 
AuthorDate: Sat Feb 2 13:05:03 2019 +0100
Commit: Eike Rathke 
CommitDate: Mon May 20 12:58:31 2019 +0200

tdf#90180 Add option to show errors as rectangles in diagrams with error 
bars.

The option is saved in registrymodifications.xcu, not yet in the document.

(cherry picked from commit 0fc471e8218b53b8b9e505d2af3e015abf3910f3)

Change-Id: I6facc8d6e456046003f2c38ce79a1fcfc712d027
Reviewed-on: https://gerrit.libreoffice.org/67280
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 86eae1a11941..e671110a753f 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -91,6 +91,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
 chart2/source/view/charttypes/BubbleChart \
 chart2/source/view/charttypes/CandleStickChart \
 chart2/source/view/charttypes/CategoryPositionHelper \
+chart2/source/view/charttypes/ConfigAccess \
 chart2/source/view/charttypes/NetChart \
 chart2/source/view/charttypes/PieChart \
 chart2/source/view/charttypes/Splines \
@@ -237,5 +238,5 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
 chart2/source/tools/WrappedPropertySet \
 chart2/source/tools/XMLRangeHelper \
 ))
- 
+
 # vim: set noet sw=4 ts=4:
diff --git a/chart2/source/view/charttypes/AreaChart.cxx 
b/chart2/source/view/charttypes/AreaChart.cxx
index 2fa4f4e66dd0..2699121ed357 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -873,12 +874,28 @@ void AreaChart::createShapes()
 //@todo other symbol styles
 }
 }
-//create error bars
-if (bCreateXErrorBar)
-createErrorBar_X( aUnscaledLogicPosition, 
*pSeries, nIndex, m_xErrorBarTarget );
+//create error bars or rectangles, depending on 
configuration
+if ( ConfigAccess::getUseErrorRectangle() )
+{
+if ( bCreateXErrorBar || bCreateYErrorBar )
+{
+createErrorRectangle(
+  aUnscaledLogicPosition,
+  *pSeries,
+  nIndex,
+  m_xErrorBarTarget,
+  bCreateXErrorBar,
+  bCreateYErrorBar );
+}
+}
+else
+{
+if (bCreateXErrorBar)
+createErrorBar_X( aUnscaledLogicPosition, 
*pSeries, nIndex, m_xErrorBarTarget );
 
-if (bCreateYErrorBar)
-createErrorBar_Y( aUnscaledLogicPosition, 
*pSeries, nIndex, m_xErrorBarTarget, nullptr );
+if (bCreateYErrorBar)
+createErrorBar_Y( aUnscaledLogicPosition, 
*pSeries, nIndex, m_xErrorBarTarget, nullptr );
+}
 
 //create data point label
 if( pSeries->getDataPointLabelIfLabel(nIndex) )
diff --git a/chart2/source/view/charttypes/ConfigAccess.cxx 
b/chart2/source/view/charttypes/ConfigAccess.cxx
new file mode 100644
index ..bca2b6dd99ef
--- /dev/null
+++ b/chart2/source/view/charttypes/ConfigAccess.cxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional 

[Libreoffice-commits] core.git: sc/qa sc/source

2019-03-28 Thread Winfried Donkers (via logerrit)
 sc/qa/unit/data/functions/mathematical/fods/rounddown.fods |   19 ++
 sc/qa/unit/data/functions/mathematical/fods/roundup.fods   |   19 ++
 sc/source/core/inc/interpre.hxx|1 
 sc/source/core/tool/interpr2.cxx   |   37 ++---
 4 files changed, 66 insertions(+), 10 deletions(-)

New commits:
commit edcbe8c4e02a67c74ec6f85f28899431dbfa0765
Author: Winfried Donkers 
AuthorDate: Tue Mar 26 16:27:09 2019 +0100
Commit: Eike Rathke 
CommitDate: Thu Mar 28 23:18:37 2019 +0100

tdf#124286 fix annoying rounding error.

In case of ROUNDDOWN and ROUNDUP, it is possible that seemingly clear 
decimal
values are rounded unexpectedly (from the user's POV). This is caused by 
the i
decimal to binary to decimal conversions.
By rounding to 12 significanr digits before calling the round-down of -up
function, most of these unexpected roundings are eliminated.

Change-Id: Ia19181383b77e1ff40a067c4a1cea1ece0955871
Reviewed-on: https://gerrit.libreoffice.org/69762
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/functions/mathematical/fods/rounddown.fods 
b/sc/qa/unit/data/functions/mathematical/fods/rounddown.fods
index 5726eea4c9d5..0389f6348ef1 100644
--- a/sc/qa/unit/data/functions/mathematical/fods/rounddown.fods
+++ b/sc/qa/unit/data/functions/mathematical/fods/rounddown.fods
@@ -2123,6 +2123,23 @@
  
 
 
+ 
+  0.940
+ 
+ 
+  0.94
+ 
+ 
+  TRUE
+ 
+ 
+  =ROUNDDOWN(31415.92654, 3)
+ 
+ 
+ 
+ 
+
+
  
  
  
@@ -2408,4 +2425,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/mathematical/fods/roundup.fods 
b/sc/qa/unit/data/functions/mathematical/fods/roundup.fods
index d1a56f7491cf..3fa289d4a2fc 100644
--- a/sc/qa/unit/data/functions/mathematical/fods/roundup.fods
+++ b/sc/qa/unit/data/functions/mathematical/fods/roundup.fods
@@ -2075,6 +2075,23 @@
  
 
 
+ 
+  0.060
+ 
+ 
+  0.06
+ 
+ 
+  TRUE
+ 
+ 
+  =ROUNDUP(8.06-8,2)
+ 
+ 
+ 
+ 
+
+
  
  
  
@@ -2360,4 +2377,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 3fd3dcf7668c..398fe707f86f 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -776,6 +776,7 @@ private:
 void ScConvertOOo();
 void ScEuroConvert();
 void ScRoundSignificant();
+static void RoundSignificant( double fX, double fDigits, double  );
 
 // financial functions
 void ScNPV();
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index b47acaddaf72..b8e4baef418f 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -983,10 +983,25 @@ void ScInterpreter::RoundNumber( rtl_math_RoundingMode 
eMode )
 else
 {
 sal_Int16 nDec = GetInt16();
+double fX = GetDouble();
 if ( nGlobalError != FormulaError::NONE || nDec < -20 || nDec > 20 
)
 PushIllegalArgument();
 else
-fVal = ::rtl::math::round( GetDouble(), nDec, eMode );
+{
+if ( ( eMode == rtl_math_RoundingMode_Down ||
+   eMode == rtl_math_RoundingMode_Up ) &&
+ nDec < 12 && fmod( fX, 1.0 ) != 0.0 )
+{
+// tdf124286 : round to 12 significant digits before 
rounding
+// down or up to avoid unexpected rounding 
errors
+// caused by decimal -> binary -> decimal 
conversion
+double fRes;
+RoundSignificant( fX, 12, fRes );
+fVal = ::rtl::math::round( fRes, nDec, eMode );
+}
+else
+fVal = ::rtl::math::round( fX, nDec, eMode );
+}
 }
 PushDouble(fVal);
 }
@@ -1007,6 +1022,17 @@ void ScInterpreter::ScRoundUp()
 RoundNumber( rtl_math_RoundingMode_Up );
 }
 
+void ScInterpreter::RoundSignificant( double fX, double fDigits, double  )
+{
+bool bNegVal = ( fX < 0 );
+if ( bNegVal )
+fX *= -1.0;
+double fTemp = ::rtl::math::approxFloor( log10( fX ) ) + 1.0 - fDigits;
+fRes = ::rtl::math::round( pow(10.0, -fTemp ) * fX ) * pow( 10.0, fTemp );
+if ( bNegVal )
+fRes *= -1.0;
+}
+
 // tdf#106931
 void ScInterpreter::ScRoundSignificant()
 {
@@ -1024,13 +1050,8 @@ void ScInterpreter::ScRoundSignificant()
 PushDouble( 0.0 );
 else
 {
-bool bNegVal = ( fX < 0 );
-if ( bNegVal )
-fX *= -1.0;
-double fTemp = ::rtl::math::approxFloor( log10( fX ) ) + 1.0 - 
fDigits;
-double fRes =