Библиотеката ScriptForge
      
  
    
    Отворете  и изберете контейнера .
 
   
 
    Библиотеките ScriptForge представляват разширяем набор от ресурси за скриптиране на макроси за LibreOffice, които могат да бъдат използвани от макроси на Basic или скриптове на Python.
  
    
• Макросите на Basic изискват зареждане на библиотеката ScriptForge чрез следния оператор:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
• Скриптовете на Python изискват импортиране от модула scriptforge:
from scriptforge import CreateScriptService
 
  
  
  Обръщения към услуги на ScriptForge
  Описаните модули и класове се извикват от потребителски скриптове като „Услуги“. За тази цел за всеки език е проектиран общ конструктор на тези услуги.
  Методът Dispose е наличен във всички услуги и трябва да бъде извикван, за да се освободят ресурсите след употреба:
  
  
    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Set oSvc = CreateScriptService("servicename"[, arg0, arg1, ...])
    ' ...
    oSvc.Dispose()
  
    from scriptforge import CreateScriptService
    svc = CreateScriptService('servicename'[, arg0, arg1, ...])
    # ...
    svc.Dispose()
  
Услуги, предоставяни от библиотеката ScriptForge
  
    
      
  
  
  Предоставя набор от методи за манипулиране и трансформиране на едномерни масиви (вектори) и двумерни масиви (матрици). Това включва операции с множества, сортиране, импортиране от и експортиране към текстови файлове.
  Масиви с повече от две измерения не могат да се използват с методите в тази услуга, с изключение само на метода CountDims, който приема масиви с произволен брой измерения.
 
    
    
      
  
  
  Услугата Base предоставя методи и свойства за управление и работа с документи на LibreOffice Base.
  Тази услуга е тясно свързана с услугата Document, която предоставя общи методи за работа с документи на LibreOffice, включително такива на Base. Следователно услугата Base разширява Document и предлага допълнителни методи, специфични за документите на Base, като позволява на потребителите:
  
    - 
        да получават достъп до базата от данни, която се съдържа в документ на Base; 
- 
        да отварят документи с формуляри, съхранявани в документ на Base; 
- 
        да проверяват дали в момента е зареден документ с формуляри от документ на Base. 
 
    
    
      
    
  Услугата ScriptForge предоставя съвкупност от методи на LibreOffice Basic за изпълнение в контекст на Python. Методите на услугата Basic възпроизвеждат точния синтаксис и поведение на вградените функции на Basic.
 
    
    
      
    
    Споделената библиотека SFDocuments предлага набор от методи и свойства за улесняване управлението и боравенето с документи на LibreOffice.
    Услугата SFDocuments.Calc е подклас на услугата SFDocuments.Document. Всички методи и свойства, дефинирани за услугата Document, са достъпни и през екземпляр на услугата Calc.
    Услугата Calc е предназначена основно за:
    
        - 
            боравене с листове в документ на Calc (копиране, вмъкване, преместване и т.н.) 
- 
            обмен на данни между структури от данни на Basic и диапазони на Calc 
- 
            копиране и импортиране на големи количества данни. 
 
    
    
      
    
    Услугата Chart предоставя набор от свойства и методи за боравене с диаграми в документи на Calc. С тази услуга е възможно:
    
      - 
        да се осъществява достъп до обекти диаграми в документи на Calc и да се променят свойствата им; 
- 
        да се създават и вмъкват нови диаграми в документ на Calc; 
- 
        да се експортират диаграми като файлове с изображения. 
 
    
    
      
    
    Услугата Database предоставя достъп до вградени или описани в документи на Base бази от данни. Тази услуга предлага методи за:
    
      - 
        получаване на достъп до таблици в база от данни 
- 
        стартиране на заявки SELECT и изчисляване на агрегатни функции 
- 
        изпълнение на оператори за действия на SQL като INSERT, UPDATE, DELETE и т.н. 
 
    
    
      
  
  
  Услугата Datasheet позволява визуализиране съдържанието на таблици в база от данни, както и резултатите от заявки и оператори на SQL, посредством прозореца „Изглед с данни“ на Base. Освен това чрез нея е възможно:
  
    - 
        да се добавят потребителски менюта в изгледа с данни 
- 
        да се осъществява достъп до данните в конкретни позиции от изгледа с данни 
- 
        да се позиционира курсора в зададена клетка от изгледа с данни. 
 
    
    
      
  
  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.
 
    
    
      
   
  
  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:
  
 
    
    
      
  
  
  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. 
 
    
    
      
    
    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:
    
 
    
    
      
    
    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. 
 
    
    
      
    
  The Platform service provides a collection of properties about the current execution environment and context, such as:
  
      - 
          The hardware platform (architecture, CPU count, machine type, etc) 
- 
          Operating system information (OS type, release, version, etc) 
- 
          The LibreOffice version 
- 
          The current user name 
 
    
    
      
    
    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:
  
    - 
      Accessing locale and region-dependent settings such as number formatting, currency and timezones. 
- 
      Converting timezones and calculate Daylight Saving Time (DST) offsets. 
- 
      Transforming numbers into text in any supported language. 
 
    
    
      
  
  
  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.
 
    
    
      
    
    
    The Session service gathers various general-purpose methods about:
    
   
    
    
      
  
  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 
- 
      Use regular expressions to search and replace substrings 
- 
      Apply hash algorithms on strings, etc. 
 
    
    
      
  
  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.
 
    
    
      
  
  The Timer service measures the amount of time it takes to run user scripts.
  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 UI (User Interface) service simplifies the identification and the manipulation of the different windows composing the whole LibreOffice application:
   - 
      Windows selection 
- 
      Windows moving and resizing 
- 
      Statusbar settings 
- 
      Display of a floating progress bar 
- 
      Creation of new windows 
- 
      Access to the underlying "documents" 
 
    
    
      
  
  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.
    
 
    
    
    Бележка: други, неописани модули на ScriptForge са запазени за вътрешна употреба. Съдържанието им подлежи на промяна без предизвестие.
    
      
В ScriptForge всички подпрограми или идентификатори на Basic с префикс „_“ са запазени за вътрешна употреба. Те не са предназначени за използване в макроси на Basic.