diff --git a/CHANGELOG b/CHANGELOG
index 507ee82..0e4469a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,8 @@
+v 0.2.0 [03-oct-2021]
+ - Add function `zxlookup`
+
+
v 0.1.0 [27-jun-2021]
- Initial version
- - Function `reverse`
- - Function `eval`
+ - Function `zreverse`
+ - Function `zeval`
diff --git a/VERSION b/VERSION
index 6c6aa7c..341cf11 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.0
\ No newline at end of file
+0.2.0
\ No newline at end of file
diff --git a/conf.py b/conf.py
index 1e7af85..e3f61e3 100644
--- a/conf.py
+++ b/conf.py
@@ -29,7 +29,7 @@ TYPE_EXTENSION = 3
NAME = 'ZAZFunctions'
# ~ https://semver.org/
-VERSION = '0.1.0'
+VERSION = '0.2.0'
# ~ Should be unique, used URL inverse
@@ -80,13 +80,13 @@ LICENSE_ES = LICENSE_EN
INFO = {
'en': {
- 'display_name': 'My first extension',
- 'description': 'My great extension',
+ 'display_name': 'ZAZ Functions',
+ 'description': 'Utils functions for Calc',
'license': LICENSE_EN,
},
'es': {
- 'display_name': 'Mi primer extensión',
- 'description': 'Mi gran extensión',
+ 'display_name': 'ZAZ Funciones',
+ 'description': 'Funciones utiles para Calc',
'license': LICENSE_ES,
},
}
@@ -156,6 +156,56 @@ FUNCTIONS = {
},
},
},
+ 'zxlookup': {
+ 'displayname': {'en': 'zxlookup', 'es': 'zbuscarx'},
+ 'description': {'en': 'Find things in a range by row', 'es': 'Buscar en un rango por fila'},
+ 'parameters': {
+ 'lookup_value': {
+ 'displayname': {'en': 'lookup_value', 'es': 'valor_buscado'},
+ 'description': {'en': 'Value to search', 'es': 'Valor buscado'},
+ },
+ 'lookup_array': {
+ 'displayname': {'en': 'lookup_array', 'es': 'buscar_en'},
+ 'description': {'en': 'Range to search', 'es': 'Rango en donde buscar'},
+ },
+ 'return_array': {
+ 'displayname': {'en': 'return_array', 'es': 'devolver_desde'},
+ 'description': {'en': 'Range to return', 'es': 'Rango a devolver'},
+ },
+ 'if_not_found': {
+ 'displayname': {'en': 'if_not_found', 'es': 'si_no_se_encuentra'},
+ 'description': {'en': 'Return if not found', 'es': 'Valor devuelto si no se encuentra'},
+ },
+ 'match_mode': {
+ 'displayname': {'en': 'match_mode', 'es': 'tipo_busqueda'},
+ 'description': {'en': 'The macht type', 'es': 'El tipo de búsqueda'},
+ },
+ 'search_mode': {
+ 'displayname': {'en': 'search_mode', 'es': 'mode_de_busqueda'},
+ 'description': {'en': 'The search mode', 'es': 'El modo de búsqueda'},
+ },
+ },
+ },
+ 'zxylookup': {
+ 'displayname': {'en': 'zxylookup', 'es': 'zbuscarxy'},
+ 'description': {
+ 'en': 'Find things in a range in first row and first column, get intersection',
+ 'es': 'Busca en un rango en la primer fila y columna y devuelve la intersección'},
+ 'parameters': {
+ 'lookup_value_x': {
+ 'displayname': {'en': 'lookup_value_x', 'es': 'valor_buscado_x'},
+ 'description': {'en': 'Value to search in first row', 'es': 'Valor buscado en la primer fila'},
+ },
+ 'lookup_value_y': {
+ 'displayname': {'en': 'lookup_value_y', 'es': 'valor_buscado_y'},
+ 'description': {'en': 'Value to search in first column', 'es': 'Valor buscado en la primer columna'},
+ },
+ 'return_array': {
+ 'displayname': {'en': 'return_array', 'es': 'devolver_desde'},
+ 'description': {'en': 'Range to return', 'es': 'Rango a devolver'},
+ },
+ },
+ },
}
# ~ FUNCTIONS = {}
@@ -176,7 +226,7 @@ DIRS = {
'description': 'description',
'images': 'images',
'registration': 'registration',
- 'files': 'files',
+ 'files': 'extension',
'office': 'Office',
'locales': PATH_LOCALES,
'pythonpath': True,
@@ -209,7 +259,7 @@ URL_OXT = ''
# ~ Default program for test: --calc, --writer, --draw
PROGRAM = '--calc'
# ~ Path to file for test
-FILE_TEST = ''
+FILE_TEST = '/home/mau/test_zfunctions.ods'
PATHS = {
'idlc': '/usr/lib/libreoffice/sdk/bin/idlc',
diff --git a/files/ZAZFunctions_v0.1.0.oxt b/extension/ZAZFunctions_v0.2.0.oxt
similarity index 91%
rename from files/ZAZFunctions_v0.1.0.oxt
rename to extension/ZAZFunctions_v0.2.0.oxt
index 6eea86d..40eca13 100644
Binary files a/files/ZAZFunctions_v0.1.0.oxt and b/extension/ZAZFunctions_v0.2.0.oxt differ
diff --git a/source/CalcAddIn.xcu b/source/CalcAddIn.xcu
index 663e079..b37e440 100644
--- a/source/CalcAddIn.xcu
+++ b/source/CalcAddIn.xcu
@@ -57,6 +57,123 @@
+
+
+ zxlookup
+ zbuscarx
+
+
+ Find things in a range by row
+ Buscar en un rango por fila
+
+
+ Add-In
+
+
+ AutoAddIn.zxlookup
+
+
+
+
+ lookup_value
+ valor_buscado
+
+
+ Value to search
+ Valor buscado
+
+
+
+ lookup_array
+ buscar_en
+
+
+ Range to search
+ Rango en donde buscar
+
+
+
+ return_array
+ devolver_desde
+
+
+ Range to return
+ Rango a devolver
+
+
+
+ if_not_found
+ si_no_se_encuentra
+
+
+ Return if not found
+ Valor devuelto si no se encuentra
+
+
+
+ match_mode
+ tipo_busqueda
+
+
+ The macht type
+ El tipo de búsqueda
+
+
+
+ search_mode
+ mode_de_busqueda
+
+
+ The search mode
+ El modo de búsqueda
+
+
+
+
+
+ zxylookup
+ zbuscarxy
+
+
+ Find things in a range in first row and first column, get intersection
+ Busca en un rango en la primer fila y columna y devuelve la intersección
+
+
+ Add-In
+
+
+ AutoAddIn.zxylookup
+
+
+
+
+ lookup_value_x
+ valor_buscado_x
+
+
+ Value to search in first row
+ Valor buscado en la primer fila
+
+
+
+ lookup_value_y
+ valor_buscado_y
+
+
+ Value to search in first column
+ Valor buscado en la primer columna
+
+
+
+ return_array
+ devolver_desde
+
+
+ Range to return
+ Rango a devolver
+
+
+
diff --git a/source/XZAZFunctions.idl b/source/XZAZFunctions.idl
index 7c76461..91bf78c 100644
--- a/source/XZAZFunctions.idl
+++ b/source/XZAZFunctions.idl
@@ -9,6 +9,18 @@ module net { module elmau { module zaz { module functions {
{
string zreverse([in] string value);
any zeval([in] string value);
+ sequence< sequence< any > > zxlookup(
+ [in] any lookup_value,
+ [in] any lookup_array,
+ [in] any return_array,
+ [in] any if_not_found,
+ [in] any match_mode,
+ [in] any search_mode);
+ any zxylookup(
+ [in] any lookup_value_x,
+ [in] any lookup_value_y,
+ [in] any return_array,
+ [in] any if_not_found);
};
service functions {
diff --git a/source/XZAZFunctions.rdb b/source/XZAZFunctions.rdb
index 3ef71ac..f87157b 100644
Binary files a/source/XZAZFunctions.rdb and b/source/XZAZFunctions.rdb differ
diff --git a/source/ZAZFunctions.py b/source/ZAZFunctions.py
index 6921502..847aa1a 100644
--- a/source/ZAZFunctions.py
+++ b/source/ZAZFunctions.py
@@ -1,3 +1,4 @@
+import bisect
import uno
import unohelper
from net.elmau.zaz.functions import XZAZFunctions
@@ -20,6 +21,46 @@ class ZAZFunctions(unohelper.Base, XZAZFunctions):
result = eval(value)
return result
+ def zxylookup(self, lookup_value_x, lookup_value_y, return_array, if_not_found):
+
+ return
+
+ def zxlookup(self, lookup_value, lookup_array, return_array, if_not_found,
+ match_mode, search_mode):
+
+ # The python default value not get 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
+ if len(lookup_array[0]) == 1:
+ source = [r[0] for r in lookup_array]
+ else:
+ source = lookup_array[0]
+
+ if lookup_value in source:
+ index = source.index(lookup_value)
+ value = (return_array[index],)
+
+ if value is None:
+ if match_mode == -1:
+ index = bisect.bisect_right(source, lookup_value)
+ value = (return_array[index],)
+ 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
+
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(ZAZFunctions, ID_EXTENSION, SERVICE)
diff --git a/source/description.xml b/source/description.xml
index 3c10a2f..efd4aed 100644
--- a/source/description.xml
+++ b/source/description.xml
@@ -1,10 +1,10 @@
-
+
- My first extension
- Mi primer extensión
+ ZAZ Functions
+ ZAZ Funciones
diff --git a/source/description/desc_en.txt b/source/description/desc_en.txt
index b667a4b..b76304a 100644
--- a/source/description/desc_en.txt
+++ b/source/description/desc_en.txt
@@ -1 +1 @@
-My great extension
\ No newline at end of file
+Utils functions for Calc
\ No newline at end of file
diff --git a/source/description/desc_es.txt b/source/description/desc_es.txt
index d8d8fdc..429acf5 100644
--- a/source/description/desc_es.txt
+++ b/source/description/desc_es.txt
@@ -1 +1 @@
-Mi gran extensión
\ No newline at end of file
+Funciones utiles para Calc
\ No newline at end of file