From 68738bd0ac262819b13ea7e11af67ee493b9b3e1 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Thu, 1 Feb 2024 14:36:24 +0100 Subject: 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 --- sc/inc/queryiter.hxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'sc/inc/queryiter.hxx') diff --git a/sc/inc/queryiter.hxx b/sc/inc/queryiter.hxx index e34a7be20e13..662fe8a9cf35 100644 --- a/sc/inc/queryiter.hxx +++ b/sc/inc/queryiter.hxx @@ -171,8 +171,16 @@ protected: nTestEqualConditionFulfilled = nTestEqualConditionEnabled | nTestEqualConditionMatched }; + enum SortedBinarySearchBits + { + nBinarySearchDisabled = 0x00, + nSearchbAscd = 0x01, + nSearchbDesc = 0x02, + }; + sal_uInt8 nStopOnMismatch; sal_uInt8 nTestEqualCondition; + sal_uInt8 nSortedBinarySearch; bool bAdvanceQuery; bool bIgnoreMismatchOnLeadingStrings; bool bSortedBinarySearch; @@ -263,8 +271,11 @@ public: { bAdvanceQuery = bVal; } void AdvanceQueryParamEntryField(); - void SetSortedBinarySearchMode( bool bVal ) - { bSortedBinarySearch = bVal; } + void SetSortedBinarySearchMode( sal_Int8 nSearchMode ) + { + nSortedBinarySearch = sal::static_int_cast(nSearchMode == 2 ? + nSearchbAscd : (nSearchMode == -2 ? nSearchbDesc : nBinarySearchDisabled)); + } void SetXlookupMode( bool bVal ) { bXLookUp = bVal; } @@ -309,11 +320,12 @@ class ScQueryCellIterator using Base::nStopOnMismatchEnabled; using Base::nTestEqualCondition; using Base::nTestEqualConditionEnabled; + using Base::nSortedBinarySearch; + using Base::nBinarySearchDisabled; using Base::PerformQuery; using Base::getThisResult; using Base::nBestFitCol; using Base::nBestFitRow; - using Base::bSortedBinarySearch; using Base::bXLookUp; bool GetThis(); -- cgit