La biblioteca ScriptForge
      
  
    
    Abra  y seleccione el contenedor .
 
   
 
    Las bibliotecas de ScriptForge constituyen una amplia colección de recursos de programación para LibreOffice que pueden invocarse desde macros escritas en BASIC o secuencias de órdenes escritas en Python.
  
    
• Para cargar la biblioteca  ScriptForge que necesitan las macros de Basic se debe usar la siguiente declaración:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
• Los scripts de Python necesitan importar el módulo scriptforge:
from scriptforge import CreateScriptService
 
  
  
  Invocar los servicios de ScriptForge
  Los módulos y las clases descritos se invocan desde secuencias de usuario como «servicios». En cada lenguaje existe un constructor genérico de estos servicios con el propósito de efectuar dicha invocación.
  El método Dispose está disponible en todos los servicios y debe llamarse para liberar recursos después de su uso:
  
  
    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Set oSvc = CreateScriptService("servicename"[, arg0, arg1, ...])
    ' ...
    oSvc.Dispose()
  
    from scriptforge import CreateScriptService
    svc = CreateScriptService('servicename'[, arg0, arg1, ...])
    # ...
    svc.Dispose()
  
Servicios que ofrece la biblioteca ScriptForge
  
    
      
  
  
  Facilita una colección de métodos para manipular y transformar formaciones de una dimensión (vectores) y de dos (matrices). La colección incluye operaciones de conjunto, ordenación, importación y exportación a partir de archivos de texto.
  Las matrices con más de dos dimensiones no pueden utilizarse con los métodos de este servicio, siendo la única excepción el método CountDims, que acepta matrices con cualquier número de dimensiones.
 
    
    
      
  
  
  El servicio Base proporciona diversos métodos y propiedades que facilitan la gestión y la manipulación de los documentos de LibreOffice Base.
  Este servicio está estrechamente relacionado con el servicio Document, que brinda métodos genéricos para manipular documentos de LibreOffice, incluidos los de Base. De ahí que el servicio Base amplíe Document y ofrezca métodos adicionales específicos para los documentos de Base, permitiendo a los usuarios:
  
    - 
        Obtener acceso a la base de datos contenida en un documento de Base. 
- 
        Abrir los documentos de formulario almacenados en un documento de Base. 
- 
        Comprobar si un formulario de un documento de Base se encuentra cargado. 
 
    
    
      
    
  El servicio ScriptForge.Basic ofrece una colección de métodos de LibreOffice BASIC que ejecutar en un contexto Python. Los métodos del servicio Basic reproducen con exactitud la sintaxis y el comportamiento de las funciones incorporadas de BASIC.
 
    
    
      
    
    The SFDocuments shared library provides a number of methods and properties to facilitate the management and handling of LibreOffice documents.
    The SFDocuments.Calc service is a subclass of the SFDocuments.Document service. All methods and properties defined for the Document service can also be accessed using a Calc service instance.
    The Calc service is focused on:
    
        - 
            Handling sheets within a Calc document (copy, insert, move, etc) 
- 
            Exchanging data between Basic data structures and Calc ranges 
- 
            Copying and importing massive amounts of data 
 
    
    
      
    
    The Chart service provides a set of properties and methods to handle charts in Calc documents. With this service it is possible to:
    
      - 
        Acceder a los objetos de gráfico en los documentos de Calc y manipular sus propiedades. 
- 
        Crear e insertar gráficos nuevos en un documento de Calc. 
- 
        Exportar los gráficos como archivos de imagen. 
 
    
    
      
    
    The Database service provides access to databases either embedded or described in Base documents. This service provides methods to:
    
      - 
        Get access to data in database tables. 
- 
        Run SELECT queries and perform aggregate functions. 
- 
        Run SQL action statements such as INSERT, UPDATE, DELETE, etc. 
 
    
    
      
    
    The Dataset service is used to represent tabular data produced by a database. With this service it is possible to:
    
   
    
    
      
  
  
  The Datasheet service allows to visualize the contents of database tables as well as the results of queries and SQL statements using Base's Data View. Additionally, this service allows to:
  
    - 
        Add custom menus to the data view. 
- 
        Access values in specific positions of the data view. 
- 
        Position the cursor in a specific cell of the data view. 
 
    
    
      
  
  The Dialog service contributes to the management of dialogs created with the Basic Dialog Editor or dialogs created on-the-fly. Each instance of the current class represents a single dialog box displayed to the user.
 
    
    
      
   
  
  The DialogControl service manages the controls belonging to a dialog defined with the Basic Dialog Editor. Each instance of the current service represents a single control within a dialog box.
  
  The focus is set on getting and setting the values displayed by the controls of the dialog box. Formatting is accessible via the XControlModel and XControlView properties.
  Note that the unique DialogControl.Value property content varies according to the control type.
  A special attention is given to controls of type tree control. It is easy to populate a tree, either branch by branch, or with a set of branches at once. Populating a tree control can be performed statically or dynamically.
 
    
    
      
  
  
  A dictionary is a collection of key-item pairs
  
 
    
    
      
    
  The SFDocuments library provides methods and properties to facilitate the management and manipulation of LibreOffice documents.
  Methods that are applicable for all types of documents (Text Documents, Sheets, Presentations, etc) are provided by the SFDocuments.Document service. Some examples are:
  
  - 
    Abrir, cerrar y guardar documentos 
- 
    Acceder a propiedades estándares o personalizadas de los documentos 
 
    
    
      
  
  
  The Exception service is a collection of methods to assist in code debugging in Basic and Python scripts and in error handling in Basic scripts.
  In Basic scripts, when a run-time error occurs, the methods and properties of the Exception service help identify the error context and allow to handle it.
 
    
    
      
  
  The FileSystem service includes routines to handle files and folders. Next are some examples of the features provided by this service:
  
    - 
      Verify whether a file or folder exists. 
- 
      Create and delete folders and files. 
- 
      Launch dialog boxes to open/save files. 
- 
      Access the list of files in a folder, etc. 
 
    
    
      
  
  The Form service provides methods and properties to manage forms in LibreOffice documents. This service supports forms in Base, Calc and Writer documents and allows to:
  
    - 
        Open and activate forms. 
- 
        Navigate through records shown by the form. 
- 
        Get access to the controls inside the form. 
- 
        Get access to subforms of a parent form. 
 
    
    
      
  
  The FormControl service provides access to the controls that belong to a form, a subform or a table control of a FormDocument. Each instance of the FormControl service refers to a single control in the form. This service allows users to:
  
    - 
        Get and set the properties of the control represented by the FormControl instance. 
- 
        Access the current value displayed by the control. 
- 
        Set the focus on the desired control. 
 
    
    
      
    
    The FormDocument service allows to access form documents stored in LibreOffice Base documents.
    In a Base document, existing form documents can be viewed by selecting  in the user interface. Each form document may be composed of one or more forms, including the main form and other sub-forms.
   
    
    
      
    
    Este servicio proporciona una serie de métodos relacionados con la traducción de cadenas con un impacto mínimo en el código fuente del programa. Los métodos proporcionados por el servicio L10N pueden utilizarse principalmente para:
    
 
    
    
      
    
    The Menu service can be used to create and remove menus from the menubar of a LibreOffice document window. Each menu entry can be associated with a script or with a UNO command. This service provides the following capabilities:
    
      - 
        Creation of menus with custom entries, checkboxes, radio buttons and separators. 
- 
        Decoration of menu items with icons and tooltips. 
 
    
    
      
    
  El servicio Platform ofrece una colección de propiedades sobre el entorno y el contexto de ejecución actuales, tales como:
  
      - 
          La plataforma de hárdwer (arquitectura, número de CPU, tipo de equipo, etc.) 
- 
          Información sobre el sistema operativo (tipo de SO, versión, etc.) 
- 
          La versión de LibreOffice 
- 
          El nombre de usuario actual 
 
    
    
      
    
    The PopupMenu service can be used to create popup menus that can be associated with events or executed by scripts. This service provides the following capabilities:
    
      - 
        Creation of popup menus with custom entries, checkboxes and radio buttons. 
- 
        Decoration of menu items with icons and tooltips. 
 
    
    
      
  
  The Region service provides a collection of properties and methods to handle locale and region-related aspects of programming, such as:
  
    - 
      Acceder a parámetros dependientes de la configuración regional, tales como el formato numérico, la moneda y los husos horarios. 
- 
      Convertir husos horarios y calcular diferencias respecto a horarios de verano. 
- 
      Transformación de números en texto en cualquier idioma compatible. 
 
    
    
      
  
  
  El propósito principal del módulo Servicios es proporcionar acceso al método CreateScriptService, que puede ser llamado en los scripts de usuario para instanciar los servicios que se implementan utilizando el marco ScriptForge.
 
    
    
      
    
    
    El servicio Session reúne varios métodos de uso general relativos a:
    
   
    
    
      
  
  The String service provides a collection of methods for string processing. These methods can be used to:
  
    - 
      Validate the contents of strings 
- 
      Format strings by trimming, justifying or wrapping their contents 
- 
      Utilizar expresiones regulares para encontrar y sustituir subcadenas 
- 
      Apply hash algorithms on strings, etc. 
 
    
    
      
  
  El servicio TextStream se utiliza para leer y escribir secuencialmente archivos abiertos mediante el servicio ScriptForge.FileSystem.
  Los métodos OpenTextFile y CreateTextFile del servicio FileSystem devuelven una ocurrencia del servicio TextStream.
 
    
    
      
  
  El servicio Timer mide el intervalo de tiempo necesario para ejecutar secuencias de órdenes de usuario.
  A Timer measures durations. It can be:
  
    - 
      Started, to indicate when to start measuring time. 
- 
      Suspended, to pause measuring running time. 
- 
      Resumed, to continue tracking running time after the Timer has been suspended. 
- 
      Restarted, which will cancel previous measurements and start the Timer at zero. 
 
    
    
      
    
    The Toolbar service allows to retrieve information related to the toolbars available for a specific document window. With this service it is possible to:
    
   
    
    
      
    
    The ToolbarButton service allows to retrieve information related to the toolbar buttons available in a given toolbar. With this service it is possible to:
    
   
    
    
      
   
El servicio UI (del inglés, interfaz de usuario) simplifica la identificación y la manipulación de las diferentes ventanas que componen la aplicación LibreOffice en su conjunto:
   - 
      Selección de ventanas 
- 
      Redimensionamiento y traslado de ventanas 
- 
      Configuración de la barra de estado 
- 
      Presentación de una barra de progreso flotante 
- 
      Creación de ventanas nuevas 
- 
      Acceso a los «documentos» subyacentes 
 
    
    
      
  
  The UnitTest service provides a framework for automating unit tests using the Basic language, including the ability to:
  
    - 
      Aggregate test cases into test suites and unit tests. 
- 
      Share setup and shutdown code among test cases. 
- 
      Report test results using the Console. 
 
    
    
      
    
    The SFDocuments shared library provides a number of methods and properties to facilitate the management and handling of LibreOffice documents.
    Some methods are generic for all types of documents and are inherited from the SF_Document module, whereas other methods that are specific for Writer documents are defined in the SF_Writer module.
    
 
    
    
    Nota: los otros módulos de ScriptForge que no se describen aquí están reservados para uso interno. Su contenido está sujeto a cambios sin previo aviso.
    
      
Todas las rutinas o identificadores BASIC de ScriptForge precedidas por guion bajo «_» están reservadas para uso interno. No deben utilizarse en macros BASIC o secuencias Python.