'Módulo de Funciones Auxiliares

Option Explicit

'________________________________________________________________________________________________________________________________
Function getFunction(NombreFuncion As String, Datos())
Dim iSFA As Object

	iSFA = CreateUnoService("com.sun.star.sheet.FunctionAccess")
	getFunction = iSFA.CallFunction(NombreFuncion, Datos())

End Function
'________________________________________________________________________________________________________________________________
Function DoCmd(NombreComando As String, Argumentos())

'Esta función permite la ejecución de diversos comandos por medio del servicio del
'Dispatch. Los argumentos necesarios son: El Nombre del Comando y los argumentos complementarios
'para la ejecución del comando en forma de array.

'Estableciendo valores de variables
	iBk = ThisComponent()
	ControlMode = iBk.getCurrentController()
	iShts = iBk.getSheets()

'Creando el Dispatcher
	Dim iFrame As Object
	Dim Cmd As Object

		iFrame = ControlMode.Frame()
		Cmd = CreateUnoService("com.sun.star.frame.DispatchHelper")

'Ejecución del comando
	DoCmd = Cmd.ExecuteDispatch(iFrame, ".uno:" & NombreComando, "", 0, Argumentos())

End Function
'________________________________________________________________________________________________________________________________
Function isetSheet(iSheetName As String)

'Acceso los objetos del libro de trabajo
	Dim iBk As Object
	Dim iShts As Object

		iBk = ThisComponent()
		iShts = iBk.getSheets()

	isetSheet = iShts.getByName(iSheetName)

End Function
'________________________________________________________________________________________________________________________________
Function isetRange(iParentSheet As Object, RangeReference As String)

'Estableciendo la función
	isetRange = iParentSheet.getCellRangeByName(RangeReference)

End Function
'________________________________________________________________________________________________________________________________
Function iselectRange(iRange As Object)

'Acceso a los objetos del libro de trabajo
	Dim iBk As Object
	Dim iController As Object

		iBk = ThisComponent()
		iController = iBk.getCurrentController()

	iselectRange = iController.select(iRange)

End Function
'________________________________________________________________________________________________________________________________
Function LastRow(cCell As Object) As Long

	Dim cCursor As Object 'para manejar el cursor

		'se crea el cursor
		cCursor = cCell.getSpreadSheet().createCursorByRange(cCell)

		'se manda al cursor al final del rango
		cCursor.gotoEnd()

		'se captura la fila del cursor
		LastRow = cCursor.getRangeAddress().EndRow + 1

End Function
'________________________________________________________________________________________________________________________________
