Commit Graph
51 Commits
Author SHA1 Message Date
Caolán McNamara ac0514fb3d cid#1555415 COPY_INSTEAD_OF_MOVE
and

cid#1555430 COPY_INSTEAD_OF_MOVE
cid#1555497 COPY_INSTEAD_OF_MOVE
cid#1555542 COPY_INSTEAD_OF_MOVE
cid#1555543 COPY_INSTEAD_OF_MOVE
cid#1555564 COPY_INSTEAD_OF_MOVE
cid#1555593 COPY_INSTEAD_OF_MOVE
cid#1555602 COPY_INSTEAD_OF_MOVE
cid#1555610 COPY_INSTEAD_OF_MOVE
cid#1555667 COPY_INSTEAD_OF_MOVE
cid#1555693 COPY_INSTEAD_OF_MOVE
cid#1555719 COPY_INSTEAD_OF_MOVE
cid#1555757 COPY_INSTEAD_OF_MOVE
cid#1555795 COPY_INSTEAD_OF_MOVE
cid#1555826 COPY_INSTEAD_OF_MOVE
cid#1555847 COPY_INSTEAD_OF_MOVE
cid#1555851 COPY_INSTEAD_OF_MOVE
cid#1555863 COPY_INSTEAD_OF_MOVE
cid#1555865 COPY_INSTEAD_OF_MOVE
cid#1555867 COPY_INSTEAD_OF_MOVE
cid#1555869 COPY_INSTEAD_OF_MOVE
cid#1555879 COPY_INSTEAD_OF_MOVE
cid#1555890 COPY_INSTEAD_OF_MOVE
cid#1555893 COPY_INSTEAD_OF_MOVE
cid#1555900 COPY_INSTEAD_OF_MOVE
cid#1555922 COPY_INSTEAD_OF_MOVE
cid#1555925 COPY_INSTEAD_OF_MOVE

Change-Id: I5d362a09e80eecd282e63c745bfe26eac2631a0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171492
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-08-06 09:13:52 +02:00
Caolán McNamara 4177e553e0 cid#1555587 COPY_INSTEAD_OF_MOVE
and

cid#1555589 COPY_INSTEAD_OF_MOVE
cid#1555593 COPY_INSTEAD_OF_MOVE
cid#1555596 COPY_INSTEAD_OF_MOVE
cid#1555602 COPY_INSTEAD_OF_MOVE
cid#1555608 COPY_INSTEAD_OF_MOVE
cid#1555610 COPY_INSTEAD_OF_MOVE
cid#1555620 COPY_INSTEAD_OF_MOVE
cid#1555623 COPY_INSTEAD_OF_MOVE
cid#1555625 COPY_INSTEAD_OF_MOVE
cid#1555626 COPY_INSTEAD_OF_MOVE
cid#1555634 COPY_INSTEAD_OF_MOVE
cid#1555638 COPY_INSTEAD_OF_MOVE
cid#1555667 COPY_INSTEAD_OF_MOVE
cid#1555682 COPY_INSTEAD_OF_MOVE
cid#1555686 COPY_INSTEAD_OF_MOVE
cid#1555702 COPY_INSTEAD_OF_MOVE
cid#1555710 COPY_INSTEAD_OF_MOVE
cid#1555750 COPY_INSTEAD_OF_MOVE
cid#1555752 COPY_INSTEAD_OF_MOVE
cid#1555761 COPY_INSTEAD_OF_MOVE
cid#1555762 COPY_INSTEAD_OF_MOVE
cid#1555771 COPY_INSTEAD_OF_MOVE
cid#1555772 COPY_INSTEAD_OF_MOVE
cid#1555784 COPY_INSTEAD_OF_MOVE
cid#1555785 COPY_INSTEAD_OF_MOVE

Change-Id: Ib9724230c05b2027b4edf64e6a0bb5e22a270a88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171274
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-07-31 17:37:14 +02:00
Caolán McNamara 329e913b0b cid#1556624 COPY_INSTEAD_OF_MOVE
and

cid#1556622 COPY_INSTEAD_OF_MOVE
cid#1556629 COPY_INSTEAD_OF_MOVE
cid#1556632 COPY_INSTEAD_OF_MOVE
cid#1556634 COPY_INSTEAD_OF_MOVE
cid#1556642 COPY_INSTEAD_OF_MOVE
cid#1556644 COPY_INSTEAD_OF_MOVE
cid#1556663 COPY_INSTEAD_OF_MOVE
cid#1556674 COPY_INSTEAD_OF_MOVE
cid#1556682 COPY_INSTEAD_OF_MOVE
cid#1556683 COPY_INSTEAD_OF_MOVE
cid#1556685 COPY_INSTEAD_OF_MOVE
cid#1556694 COPY_INSTEAD_OF_MOVE
cid#1556708 COPY_INSTEAD_OF_MOVE
cid#1556711 COPY_INSTEAD_OF_MOVE
cid#1556712 COPY_INSTEAD_OF_MOVE
cid#1556714 COPY_INSTEAD_OF_MOVE
cid#1556719 COPY_INSTEAD_OF_MOVE
cid#1556727 COPY_INSTEAD_OF_MOVE
cid#1556744 COPY_INSTEAD_OF_MOVE
cid#1556757 COPY_INSTEAD_OF_MOVE
cid#1556782 COPY_INSTEAD_OF_MOVE
cid#1556784 COPY_INSTEAD_OF_MOVE

Change-Id: I5d5bc884cd7351a81c18b35aaf4e304256242988
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171128
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-07-28 18:36:01 +02:00
Caolán McNamara 5c783662b9 cid#1556239 Use of auto that causes a copy
and

cid#1557287 Use of auto that causes a copy
cid#1558003 Use of auto that causes a copy
cid#1557568 Use of auto that causes a copy
cid#1556546 Use of auto that causes a copy
cid#1557377 Use of auto that causes a copy
cid#1608325 Use of auto that causes a copy

Change-Id: I84e59d2b14bb1e5856f9cac521ad6542b1784243
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170821
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-07-21 22:40:30 +02:00
Mike Kaganski 68a96f7473 Use IsRunningUnitTest / IsRunningUITest consistently
The functions are moved to o3tl as inline functions.

Change-Id: Ief7d7e292ef15e055ad04ab5707e5e6a2a05b916
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170636
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-07-17 19:15:31 +02:00
Noel Grandin 69e7000ed4 Simplify checking for "running under unit/ui test"
In various places, the code checks if we are running as a unit test or a
UI test. This code grew organically, and is most re-using environment
variables that were designed for narrower purposes.

Rather than being clever, just add two new explicit and simple
environment variables in the natural place (the command that runs them),
and check for those variables in the code.

Change-Id: Icce0997914fa0be30a5ac1f29bd870bdb5893a8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170618
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-07-17 15:21:57 +02:00
Balazs Varga 46d55cf796 tdf#161964 - sc Fix Lookup functions error with only-row reference
as a lookup_array parameter. ($1:$1)

Regression from commit: 85f733a924
(Related: tdf#160725 - Add horizontal binary search mode for SortedCache)

Change-Id: I3ef7c612e7bc92ecab81a3e52aed9873da907f16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170221
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Tested-by: Jenkins
2024-07-10 08:47:16 +02:00
Balazs Varga f5f5ff719f Related: tdf#127293 Ignore 'search-criteria-must-apply-to-whole-cell'
dependency for XLOOKUP and XMATCH because of better compatibility.

The idea is to specify, that the global setting 'search-criteria-must-apply-to-whole-cell'
is ignored and XMATCH and XLOOKUP always behaves as if 'search-criteria-must-apply-to-whole-cell'=true.

That would affect exact search in Match_mode value 0. Users would need to use wildcard or regex
to get a match to part of the content. But removing dependency to the global setting increases
interoperability with MS Excel.

Also the ODF TC will follow that in the final specification of these functions:
https://issues.oasis-open.org/browse/OFFICE-4154

Follow-up commit: 17d578ba91
(Related: tdf#127293 Add new Match_mode option for XLOOKUP and XMATCH functions.)

Change-Id: I1317865631d2925eaff72e9c1425d93386c3d016
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169582
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Tested-by: Jenkins
2024-06-27 18:06:21 +02:00
Balazs Varga 85f733a924 Related: tdf#160725 - Add horizontal binary search mode for SortedCache
and ScSortedRangeCache classes to support binary search mode in case of
different columns. Which is used by the new XLOOKUP function from now on
in case of binary search mode.

Change-Id: Ibb2ae33670cbe9b47110de57afb6376cd829b465
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166758
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-05-01 20:32:17 +02:00
Balazs Varga e2c9d38d95 tdf#160725 - Fix XLOOKUP has different result for approximate
search than Excel.

Some rework for xlookup binary search in rows to get the correct results
when we are searching with binary mode in rows.

Change-Id: I7ef710c4ae638e2cf5d4bee45810cec7057f5d4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166451
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Tested-by: Jenkins
2024-04-30 23:32:49 +02:00
Rafał Dobrakowski 0fb98963c4 tdf#146619 Remove unused #includes from C/C++ files
'sc' module was cleaned.

Change-Id: Ia491d741a4c1c5314f35ebb4baa82dd516948ae7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165699
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2024-04-02 19:32:44 +02:00
Caolán McNamara b38974391e Related: tdf#160056 do calc NumberFormatting via ScInterpreterContext
and for the duration of Threaded calculation where there will be
no new formats required we can drive number formatting with the
unlocked RO policy.

Change-Id: Ic0e449acdcf834bc569d13b4a984f13c55316801
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165160
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-03-23 01:14:13 +01:00
Balazs Varga b36ecef07a tdf#128425 Add Excel2021 function XMATCH to Calc
https://issues.oasis-open.org/browse/OFFICE-4155

Change-Id: I7791ab873cf62ce882feba75dc0d722bc5990f9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163260
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-02-18 23:13:01 +01:00
Winfried Donkers 88ba9fab08 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 <balazs.varga.extern@allotropia.de>
2024-02-16 11:01:17 +01:00
Stephan Bergmann 3350552373 Explicitly instantiate templates
...that are used in inline functions in sc/inc/queryiter.hxx, but where the
template definition is only available in sc/source/core/data/queryiter.cxx, and
which had caused at least Clang PCH builds to now fail with

> ld.lld: error: undefined symbol: bool ScQueryCellIteratorAccessSpecific<(ScQueryCellIteratorAccess)1>::IncPosImpl<false>()
> >>> referenced by queryiter.hxx:111 (sc/inc/queryiter.hxx:111)
> >>>               workdir/CxxObject/sc/inc/pch/precompiled_sc.o:(ScQueryCellIteratorAccessSpecific<(ScQueryCellIteratorAccess)1>::IncPos())
>
> ld.lld: error: undefined symbol: bool ScQueryCellIteratorAccessSpecific<(ScQueryCellIteratorAccess)1>::IncPosImpl<true>()
> >>> referenced by queryiter.hxx:112 (sc/inc/queryiter.hxx:112)
> >>>               workdir/CxxObject/sc/inc/pch/precompiled_sc.o:(ScQueryCellIteratorAccessSpecific<(ScQueryCellIteratorAccess)1>::IncPosFast())
> clang++: error: linker command failed with exit code 1 (use -v to see invocation)
> make[1]: *** [sc/Library_sc.mk:10: instdir/program/libsclo.so] Error 1

Change-Id: If87b268a69e7acd411164ce53c549be32ded41cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163434
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-02-15 19:44:15 +01:00
Balazs Varga 68738bd0ac Related: tdf#127293 Fix function XLOOKUP binary search corner cases
Fix some binary search (vertical) corner cases in case of XLOOKUP
where we looking for the first matches.

Change-Id: I6cdc778350989e0802ffc54284fdab9b8a2bece4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162877
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-02-08 08:25:15 +01:00
Winfried DonkersandBalazs Varga f7039822c7 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 <balazs.varga.extern@allotropia.de>

Change-Id: I15fd4479b63ec13b093d269760d1bbb5957553e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131905
Tested-by: Jenkins
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-01-31 09:14:19 +01:00
Caolán McNamara 73038ec826 cid#1545764 COPY_INSTEAD_OF_MOVE
Change-Id: I5636f571b6c157b5b23d453d39f2c43eedc2e2a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160446
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-08 09:34:06 +01:00
Andrea Gelmini bcad9f53c8 Remove duplicated include
Change-Id: I01ff5b522433826f560c9adbe606393e449434ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152198
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2023-05-24 14:47:46 +02:00
Eike Rathke 9a555d79b3 Resolves: tdf#151958 Disable binary search on sorted cache for current releases
Temporary measure until the actual cause is fixed.
The by string query of binary search on sorted cache is broken for
mixed types like here the numeric date cells and text cells.

Change-Id: Icfe0b0c30987fcefdd6ed11066ea9113f3b4dabe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151074
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
2023-04-27 01:29:45 +02:00
Caolán McNamara 43e9582e01 crashtesting: assert on loading forum-mso-en4-144513.xls
the same case, though non-fatal in that instance, can be seen with
sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
with a maParam.nCol2 of 27, nFoundCol of 23, nCol of 28 so a nColDiff
of 5. rParam.nField was originally reduced from 27 to 22 with
-= nColDiff, while with this approach of restoring the original
position it is restored to the value of 23 it had before the
last call to GetNext()

Change-Id: Ia6ca73be03fe313c81a23f176a40a5e619a75d3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148415
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-03-13 09:18:23 +00:00
Caolán McNamara f60a48af7d these can be const
Change-Id: I8601beb007f1e0b043e2217e5dfe8b40925335ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148313
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-03-06 16:53:24 +00:00
Caolán McNamara 05dba1a123 cid#1509312 Unintentional integer overflow
Change-Id: I93ca395f6a74dd6c67d4388512b5de3441b362fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138476
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-18 15:08:51 +02:00
Luboš Luňák b55a0eea78 don't try to use self-referencing ScSortedRangeCache (tdf#149752)
Both the documents from the bugreport use COUNTIF where the range
includes the cell itself. So trying to create ScSortedRangeCache
for the range would try to read the values of the cells in the range
including the cell itself, which would try to interpret COUNTIF,
which would recurse and deadlock on the mutex.

Change-Id: I95c33d0b75015dcd1d628740ef52c2d680864791
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136581
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-06-28 21:19:15 +02:00
Luboš Luňák 423f277cc0 fix ByValue lookups with ScSortedRangeCache
My fix for tdf#149071 actually disabled the optimization for all
ByValue lookups, because in fact all such lookups have maString set.
So lookups where the cells are a mix of numeric and string values
need different handling. A simple solution is detecting such a mix
when collecting the values for ScSortedRangeCache and disabling
the optimization in such a case. But it turns out that queries
containing such a mix are not that rare, as documents may e.g.
do COUNTIF($C:$C) where the given column has numeric values that
start with a textual header. So bail out only if the string cell
actually could affect the numeric query.
Also fix ScSortedRangeCache usage depending on query parameters,
different instances are needed for e.g. different ScQueryOp,
because the ScQueryEvaluator functions may return different
results (isQueryByString() is automatically true for SC_EQUAL).

Change-Id: Ib4565cbf6194e7c525c4d10d00b1c31707952a79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136403
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-06-26 20:27:19 +02:00
Noel Grandin 20b8c7f38a create getter for ScCellValue::mpFormula
so we can assert that it has the correct tag type

Change-Id: Iab13a6d6ea1783c69395f06f28732769e5fe8b18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136059
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-06-18 08:23:06 +02:00
Noel Grandin c2518134a5 create getter for ScCellValue::mfValue
so we can assert that has the correct tag type

Change-Id: I0d626130cb014e19239e88a6988018c83d061f68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136001
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-06-16 20:39:23 +02:00
Noel Grandin 3d2e26d8b7 make meType in ScCellValue private
as a first step to wrapping up the internals of this class and adding
some asserts

Change-Id: Ic13ddd917948dbf3fd6d73f44b8efcc727726baf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135994
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-06-16 15:26:14 +02:00
Caolán McNamara 3d29f5860f cid#1504440 move Uninitialized scalar field annotation
Change-Id: Ia147241460c537abea7f6ef3cd32038551c45826
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134723
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-05-22 14:34:38 +02:00
Luboš Luňák 11a626139a silence coverity warnings
Those fields are meant to be uninitialized by the ctor. And if they get
used by mistake, I'd prefer to hear that from e.g. Valgrind rather
than cover it up with some dummy default value.

Change-Id: Ide57f84e9dc0fcc8c7395af99e216c7626d50913
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134512
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-18 15:17:29 +02:00
Luboš Luňák 8f61250bf9 no ScSortedRangeCache-based query for number-as-string (tdf#149071)
The comparison depends on the cell encountered, which makes it hard
to prepare the sorted data.

Change-Id: I22f55003acde7eedadb8a4c8d61390dd30b6ac8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134287
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-15 10:50:15 +02:00
Luboš Luňák 3165328258 ScSortedRangeCache-based query doesn't work with mbRangeLookup
Change-Id: I9ce8e3547fc261e92e1330df4c054c3efe532d61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134286
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-15 10:50:00 +02:00
Luboš Luňák e1f62d3c38 make ScSortedRangeCache-based queries work with mbMatchEmpty
Change-Id: Ifc8195222568184dc4f337b23f00e315e22febe2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134218
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-13 17:04:05 +02:00
Luboš Luňák 248e49d3f4 no PerformQuery() with ScSortedRangeCache if not needed (tdf#144777)
It should not be necessary in that case, since the rows are restricted
only to those that match, selected by BinarySearch(). Still at least
assert that, just in case I'm missing something (or BinarySearch()
doesn't quite match what validQuery() does).

Change-Id: Ie91d3ba997692e5b3650b1549e8a38b6c5f44c01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134130
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:51:38 +02:00
Luboš Luňák 4c8f4390c8 do not use ScSortedRangeCache inefficiently
If the amount of data or size of the formula group is small, the caching
is probably not worth it. And if rows are not absolute, then each
formula cell would use a different range instead of reusing the cache.

Change-Id: I42a82aaa5f4ffccc63e527793f46fc52fd539af6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134129
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:51:16 +02:00
Luboš Luňák 905475435c limit rows to ones having data when computing ScSortedRangeCache
Change-Id: I2de9ea4887b6101f10eb3b8da6f3596de0ea09eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134128
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:50:52 +02:00
Luboš Luňák 4db2b19fe8 avoid somewhat expensive mdds position() call if possible
Change-Id: I095f6285b9e1da5869ca08a0d8e6fae9ace40cfa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134126
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:49:48 +02:00
Luboš Luňák 5b189abc13 make ScSortedRangeCache work for also ScQueryEntry::ByString
Change-Id: Ifa769e20d91f7899fa81df537a7f3b7aeff52115
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134125
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:49:24 +02:00
Luboš Luňák 4794aa2958 make BinarySearch() do proper SC_EQUAL with ScQueryEntry::ByString
ScQueryEvaluator::isQueryByString() makes everything a string search
in this case, so this one should too.

Change-Id: Ic1ebd14515cfb7f253f022ca4f76699a6cb63468
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134137
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:49:01 +02:00
Luboš Luňák e98a22b4e4 use ScSortedRangeCache also for generic queries
This enables use for e.g. VLOOKUP or COUNTIFS (as COUNTIFS does
not use the specialized code for COUNTIF).

Change-Id: Idad7503750d421f3f1c9ac34dfe95393fa3ead15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134124
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:48:37 +02:00
Luboš Luňák 18eeb85d48 keep only a reference to a vector if equal to what's wanted
This avoids copying the data repeatedly.

Change-Id: Id3fadf8414c66143e12261a14b75b984415ed9a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134121
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:47:47 +02:00
Luboš Luňák 122e676ce3 introduce Calc cache for sorted handling of unsorted cells
The idea is that there's a cache for a given range, which keeps
a vector of SCROW items, sorted by values of those cells. This
allows some specific cases of e.g. COUNTIF to simply use
BinarySearch() to find the range that matches and work only with
that. This commit implements using this cache for COUNTIF.

Change-Id: I5b36b289b4aecb3b8245bbb447fbb299371262e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134120
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:46:30 +02:00
Luboš Luňák 976a07a1df make it obvious which column BinarySearch() operates on
It was setting the column to ScQueryParams.nCol1, which
was somewhat confusing.

Change-Id: I3ab2207f507a4dc3782ea78682dacb0b08c36b19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134123
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-11 11:45:52 +02:00
Luboš Luňák 1d8c31ea25 sort out query iterator's BinarySearch() corner cases handling
If the code detects the range is not actually properly sorted,
set position to the first row and return false to force
linear search. If the searched for value belongs before the first
item, do the same, in which case the linear search should see
that it is this case (before this case nRow was set to the first
row regardless of where the searched for value belonged).

Change-Id: I8ff346783d93d74ff409b19aea394e202885647d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134100
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-10 16:25:21 +02:00
Luboš Luňák e2f8e5cf7c make BinarySearch() work for SC_EQUAL, SC_LESS, SC_GREATER
Change-Id: I296686709688a9e3f2cda0864d73c79a17e33f49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134099
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-10 16:24:55 +02:00
Luboš Luňák 6a5464b800 make query iterator's BinarySearch() find the last matching item
If the code found a matching value, it didn't bother finding
the last one in the range if there were several adjacent ones.

Change-Id: Ie1f4c7bd3dcbd2aaf653f5b74e159902de4cf93d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134098
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-10 16:24:13 +02:00
Luboš Luňák 80606b89bb extend ScQueryCellIteratorBase for custom cell access
This moves code related to accessing cells to query to a template
base class. Creating more specialization of that class will allow
queries that use a cache of sort order for the cells.

Change-Id: I47d1bc2d038717ff64f1d11fa6c7dba2359fec11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134096
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-10 16:23:32 +02:00
Luboš Luňák 02c5ec92e3 assert pre-requisities of BinarySearch()
Change-Id: I090a6538628eb5337a311ed8aec3580901e957ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134095
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-10 16:22:43 +02:00
Luboš Luňák 4d2bd38683 BinarySearch() can be in ScQueryCellIteratorBase
Change-Id: I89d7e58a9706526aa2871dba1e4f922ff94562a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134094
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-05-10 16:22:26 +02:00
Luboš Luňák d5986d1c5f do not duplicate code for ScCountIfCellIterator
d468958331 improved COUNTIF performance
by copy&pasting the generic query iterator and then basically removing
what was not necessary. Which is in general a good way to improve
the performance, except for the copy&paste part, as the code has
already started to diverge (e.g. fc3b904b67).

So instead make the shared code into a template and reuse that from
specific code. This has exactly the same performance as the copy&paste
way.

Change-Id: I168319a1f4273bafc8c0742a114dafbf433968bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133324
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-04-22 18:16:48 +02:00