Die Bibliothek ScriptForge

So greifen Sie auf diesen Befehl zu:

Wählen Sie Extras – Makros – LibreOffice Basic – Bearbeiten… und den Container LibreOffice-Makros.


ScriptForge-Bibliotheken bilden eine erweiterbare Sammlung an Makro-Skriptressourcen für LibreOffice, die von Basic-Makros oder Python-Skripten aufgerufen werden können.

note

• Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService


tip

Um mehr darüber zu erfahren, wie man Python-Skripte mit der Bibliothek ScriptForge erstellt und ausführt, lesen Sie die Hilfeseite Erstellen von Python-Skripten mit ScriptForge.


Aufrufen von ScriptForge-Diensten

Die beschriebenen Module und Klassen werden von Benutzerskripten als "Dienste" aufgerufen. Zu diesem Zweck wurde für jede Sprache ein generischer Konstruktor für diese Dienste entwickelt:


    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Set oSvc = CreateScriptService("servicename"[, arg0, arg1, ...])
    ' ...
    oSvc.Dispose()
  

    from scriptforge import CreateScriptService
    svc = CreateScriptService('servicename'[, arg0, arg1, ...])
    # ...
    svc.Dispose()
  

Die Methode Dispose ist in allen Diensten verfügbar und sollte aufgerufen werden, um Ressourcen nach der Verwendung freizugeben.

Von der Bibliothek ScriptForge bereitgestellte Dienste

Kategorie

Dienste

LibreOffice Basic

Array
Dictionary
Exception

FileSystem
String
TextStream

Dokumentinhalt

Base
Calc
Chart

Database
Document

Benutzeroberfläche

Dialog
DialogControl
Form

FormControl
PopupMenu
UI

Dienstprogramme

Basic
L10N
Platform

Services
Session
Timer


ScriptForge.Array -Service

Stellt eine Sammlung von Methoden zum Bearbeiten und Transformieren von Matrizen mit einer Dimension (Vektoren) und mit zwei Dimensionen bereit. Dazu gehören Set-Operationen, Sortieren, Importieren in und Exportieren aus Textdateien.

Matrizen mit mehr als zwei Dimensionen können mit den Methoden in diesem Dienst nicht verwendet werden, die einzige Ausnahme ist die Methode CountDims, die Matrizen mit einer beliebigen Anzahl von Dimensionen akzeptiert.

Dienst SFDocuments.Base

Der Dienst Base bietet eine Reihe von Methoden und Eigenschaften, um die Verwaltung und Handhabung von LibreOffice Base-Dokumenten zu erleichtern.

Dieser Dienst ist eng mit dem Dienst Document verbunden, der generische Methoden zur Handhabung von LibreOffice-Dokumenten, einschließlich Basisdokumenten, bereitstellt. Daher erweitert der Dienst Base den Dienst Document und stellt zusätzliche Methoden bereit, die spezifisch für Base-Dokumente sind und Benutzern Folgendes ermöglichen:

Dienst ScriptForge.Basic

Der Dienst ScriptForge.Basic schlägt eine Sammlung von LibreOffice Basic-Methoden vor, die in einem Python-Kontext ausgeführt werden können. Die Methoden des Dienstes Basic reproduzieren die genaue Syntax und das Verhalten der integrierten Basic-Funktionen.

Dienst SFDocuments.Calc

Die gemeinsam genutzte Bibliothek SFDocuments bietet eine Reihe von Methoden und Eigenschaften, um die Verwaltung und Handhabung von LibreOffice-Dokumenten zu erleichtern.

Der Dienst SFDocuments.Calc ist eine Unterklasse de Dienstes SFDocuments.Document. Auf alle für den Dienst Document definierten Methoden und Eigenschaften kann auch über eine Dienstinstanz Calc zugegriffen werden.

Der Dienst Calc konzentriert sich auf:

Dienst ScriptForge.Chart

Der Dienst Chart bietet eine Reihe von Eigenschaften und Methoden zur Handhabung von Diagrammen in Calc-Dokumenten. Mit diesem Service ist es möglich:

Dienst SFDatabases.Database

Der Dienst Database bietet Zugriff auf Datenbanken, die entweder eingebettet oder in Basisdokumenten beschrieben sind. Dieser Dienst bietet Methoden für Folgendes:

SFDialogs.Dialog service

The Dialog service contributes to the management of dialogs created with the Basic Dialog Editor. Each instance of the current class represents a single dialog box displayed to the user.

SFDialogs.DialogControl service

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.

ScriptForge.Dictionary service

A dictionary is a collection of key-item pairs

SFDocuments.Document service

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:

ScriptForge.Exception service

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.

ScriptForge.FileSystem service

The FileSystem service includes routines to handle files and folders. Next are some examples of the features provided by this service:

SFDocuments.Form service

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:

SFDocuments.FormControl service

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:

ScriptForge.L10N service

This service provides a number of methods related to the translation of strings with minimal impact on the program's source code. The methods provided by the L10N service can be used mainly to:

ScriptForge.Platform service

The Platform service provides a collection of properties about the current execution environment and context, such as:

ScriptForge.PopupMenu service

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:

ScriptForge.Services service

The main purpose of the Services module is to provide access to the CreateScriptService method, which can be called in user scripts to instantiate services that are implemented using the ScriptForge framework.

ScriptForge.Session service

The Session service gathers various general-purpose methods about:

ScriptForge.String service

The String service provides a collection of methods for string processing. These methods can be used to:

ScriptForge.TextStream service

The TextStream service is used to sequentially read from and write to files opened or created using the ScriptForge.FileSystem service.

The methods OpenTextFile and CreateTextFile from the FileSystem service return an instance of the TextStream service.

ScriptForge.Timer service

The Timer service measures the amount of time it takes to run user scripts.

A Timer measures durations. It can be:

ScriptForge.UI service

The UI (User Interface) service simplifies the identification and the manipulation of the different windows composing the whole LibreOffice application:

Hinweis: Andere unbeschriebene ScriptForge-Module sind für die interne Verwendung reserviert. Ihr Inhalt kann ohne vorherige Ankündigung geändert werden.

warning

Alle ScriptForge Basic-Routinen oder Bezeichner, denen ein Unterstrich "_" vorangestellt ist, sind für den internen Gebrauch reserviert. Sie sind nicht für die Verwendung in Basic-Makros oder Python-Skripten vorgesehen.