diff --git a/CHANGELOG b/CHANGELOG
index 0e4469a..c4ad37e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,5 @@
-v 0.2.0 [03-oct-2021]
- - Add function `zxlookup`
-
+v 0.2.0 [12-jul-2023]
+ - Add function `zstrip`
v 0.1.0 [27-jun-2021]
- Initial version
diff --git a/README.md b/README.md
index c327edb..1ea43e1 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,9 @@ LibreOffice Calc Add-in
## Functions
-* `zreverse` - Get reverse string
-* `zeval` - Parse and execute expresions
+* `zreverse` - Get reverse string.
+* `zeval` - Parse and execute expresions.
+* `zstrip` - Remove extra spaces or characteres. [Look](https://docs.python.org/3/library/stdtypes.html#str.strip)
![Image](https://git.cuates.net/elmau/zaz-functions/raw/commit/b0e0a93a8ef27523cd3e0e17ec2df1d085881e60/images/image1.png "Functions")
diff --git a/conf.py b/conf.py
index a267b61..5fb55ff 100644
--- a/conf.py
+++ b/conf.py
@@ -142,7 +142,7 @@ FUNCTIONS = {
'parameters': {
'value': {
'displayname': {'en': 'string', 'es': 'texto'},
- 'description': {'en': 'The string', 'es': 'El cadena'},
+ 'description': {'en': 'The string', 'es': 'La cadena'},
},
},
},
@@ -156,33 +156,17 @@ FUNCTIONS = {
},
},
},
- 'zxlookup': {
- 'displayname': {'en': 'zxlookup', 'es': 'zbuscarx'},
- 'description': {'en': 'Find things in a range by row', 'es': 'Buscar en un rango por fila'},
+ 'zstrip': {
+ 'displayname': {'en': 'zstrip', 'es': 'zstrip'},
+ 'description': {'en': 'Remove spaces at the beginning and at the end of the string.', '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'},
+ 'value': {
+ 'displayname': {'en': 'string', 'es': 'texto'},
+ 'description': {'en': 'Value to trim', 'es': 'Valor a limpiar'},
},
- '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'},
+ 'characters': {
+ 'displayname': {'en': 'characters', 'es': 'caracteres'},
+ 'description': {'en': 'A set of characters to remove as leading/trailing characters', 'es': 'Caracteres a elmininar de la cadena'},
},
},
},
@@ -239,7 +223,7 @@ URL_OXT = ''
# ~ Default program for test: --calc, --writer, --draw
PROGRAM = '--calc'
# ~ Path to file for test
-FILE_TEST = '/home/mau/test_zfunctions.ods'
+FILE_TEST = '/home/elmau/Projects/libre_office/examples/zutil_functions.ods'
PATHS = {
'idlc': '/usr/lib/libreoffice/sdk/bin/idlc',
diff --git a/extension/ZAZFunctions_v0.2.0.oxt b/extension/ZAZFunctions_v0.2.0.oxt
index 648882b..4473990 100644
Binary files a/extension/ZAZFunctions_v0.2.0.oxt and b/extension/ZAZFunctions_v0.2.0.oxt differ
diff --git a/source/CalcAddIn.xcu b/source/CalcAddIn.xcu
index d5789c9..f4a9cca 100644
--- a/source/CalcAddIn.xcu
+++ b/source/CalcAddIn.xcu
@@ -26,7 +26,7 @@
The string
- El cadena
+ La cadena
@@ -57,75 +57,39 @@
-
+
- zxlookup
- zbuscarx
+ zstrip
+ zstrip
- Find things in a range by row
+ Remove spaces at the beginning and at the end of the string.
Buscar en un rango por fila
Add-In
- AutoAddIn.zxlookup
+ AutoAddIn.zstrip
-
+
- lookup_value
- valor_buscado
+ string
+ texto
- Value to search
- Valor buscado
+ Value to trim
+ Valor a limpiar
-
+
- lookup_array
- buscar_en
+ characters
+ caracteres
- 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
+ A set of characters to remove as leading/trailing characters
+ Caracteres a elmininar de la cadena
diff --git a/source/XZAZFunctions.idl b/source/XZAZFunctions.idl
index 0d79147..d943aca 100644
--- a/source/XZAZFunctions.idl
+++ b/source/XZAZFunctions.idl
@@ -2,7 +2,6 @@
#define __net_elmau_zaz_functions_idl__
#include
-#include
module net { module elmau { module zaz { module functions {
@@ -11,13 +10,7 @@ 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] 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);
+ string zstrip([in] string value, [in] any characters);
};
service functions {
diff --git a/source/XZAZFunctions.rdb b/source/XZAZFunctions.rdb
index d7d9d67..3b5fa51 100644
Binary files a/source/XZAZFunctions.rdb and b/source/XZAZFunctions.rdb differ
diff --git a/source/ZAZFunctions.py b/source/ZAZFunctions.py
index b1de2ab..46c6c45 100644
--- a/source/ZAZFunctions.py
+++ b/source/ZAZFunctions.py
@@ -1,4 +1,3 @@
-import bisect
import uno
import unohelper
from net.elmau.zaz.functions import XZAZFunctions
@@ -21,50 +20,12 @@ class ZAZFunctions(unohelper.Base, XZAZFunctions):
result = eval(value)
return result
- 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
- if search_mode is None:
- search_mode = 1
-
- value = None
-
- source = lookup_array.DataArray
- target = return_array.DataArray
-
- horizontal = False
- if lookup_array.Columns.Count == 1:
- source = tuple(map(lambda x: x[0], source))
- else:
- horizontal = True
- source = source[0]
- target = target[0]
-
- if search_mode == -1:
- source = tuple(reversed(source))
-
- index = next((i for i, v in enumerate(source) if v == lookup_value), None)
-
- if index is None:
- if match_mode == -1:
- index = bisect.bisect_right(source, lookup_value)
- value = (target[index - 1],)
- elif match_mode == 1:
- index = bisect.bisect_left(source, lookup_value)
- value = (target[index],)
- else:
- if horizontal:
- value = ((target[index],),)
- else:
- value = (target[index],)
-
- if value is None and if_not_found:
- value = ((if_not_found,),)
-
- return value
+ def zstrip(self, value, characters=''):
+ options = ' '
+ if not characters is None:
+ options = characters
+ result = value.strip(options)
+ return result
g_ImplementationHelper = unohelper.ImplementationHelper()