Change type argument to cell range

This commit is contained in:
El Mau 2022-02-07 23:44:53 -06:00
parent a83b338a50
commit d27630c7df
4 changed files with 37 additions and 33 deletions

Binary file not shown.

View File

@ -2,6 +2,8 @@
#define __net_elmau_zaz_functions_idl__
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/table/XCellRange.idl>
module net { module elmau { module zaz { module functions {
@ -11,8 +13,8 @@ module net { module elmau { module zaz { module functions {
any zeval([in] string value);
sequence< sequence< any > > zxlookup(
[in] any lookup_value,
[in] any lookup_array,
[in] any return_array,
[in] com::sun::star::table::XCellRange lookup_array,
[in] com::sun::star::table::XCellRange return_array,
[in] any if_not_found,
[in] any match_mode,
[in] any search_mode);

Binary file not shown.

View File

@ -24,42 +24,44 @@ class ZAZFunctions(unohelper.Base, XZAZFunctions):
def zxlookup(self, lookup_value, lookup_array, return_array, if_not_found,
match_mode, search_mode):
# The python default value not set in custom functions
if match_mode is None:
match_mode = 0
else:
match_mode = int(match_mode)
if search_mode is None:
search_mode = 1
value = None
horizontal = False
if len(lookup_array[0]) == 1:
source = [r[0] for r in lookup_array]
else:
horizontal = True
source = lookup_array[0]
# The python default value not set in custom functions
if lookup_value in source:
index = source.index(lookup_value)
if horizontal:
value = ((return_array[0][index],),)
else:
value = (return_array[index],)
source = lookup_array.DataArray
target = return_array.DataArray
if value is None:
if match_mode == -1:
index = bisect.bisect_right(source, lookup_value)
value = (return_array[index - 1],)
elif match_mode == 1:
index = bisect.bisect_left(source, lookup_value)
value = (return_array[index],)
elif match_mode == 2:
pass
index = next((i for i, v in enumerate(source) if v[0] == lookup_value), None)
if value is None and not if_not_found is None:
value = ((if_not_found,),)
if index:
value = (target[index],)
# ~ horizontal = False
# ~ if len(source[0]) == 1:
# ~ source = [r[0] for r in source]
# ~ else:
# ~ horizontal = True
# ~ source = source[0]
# ~ if lookup_value in source:
# ~ index = source.index(lookup_value)
# ~ if horizontal:
# ~ value = ((return_array[0][index],),)
# ~ else:
# ~ value = (return_array[index],)
# ~ if value is None:
# ~ if match_mode == -1:
# ~ index = bisect.bisect_right(source, lookup_value)
# ~ value = (return_array[index - 1],)
# ~ elif match_mode == 1:
# ~ index = bisect.bisect_left(source, lookup_value)
# ~ value = (return_array[index],)
# ~ elif match_mode == 2:
# ~ pass
# ~ if value is None and not if_not_found is None:
# ~ value = ((if_not_found,),)
return value