ScriptForge.Services zerbitzua

ScriptForge liburutegia "zerbitzuak" deitutako bilduma hedagarri baten gainean eraikita dago.
Bilduma hori Basic liburutegien edo Python moduluen kategoria gisa inplementatzen da:

  1. LibreOffice aplikazioarekin banatutako ScriptForge liburutegia

  2. LibreOffice aplikazioarekin ere banatutako liburutegi "elkartuen" multzo bat

  3. any user/contributor LibreOffice extension wanting to fit into the same framework

Zerbitzu bat propietateen eta metodoen multzo bat da, zerbitzu hori inplementatzen dutenak.

tip

Erabiltzaile-script baten egilearentzat, zerbitzu bat izan daiteke bai liburutegi bateko modulu bat, bai klase-modulu bateko instantzia bat.


An event manager is a script contained in a library which binds an event triggering a macro - usually defined by the Tools - Customize menu - to the concerned service instance.

tip

As an example, if several documents trigger the same macro when they are loaded, it might be useful to know which document triggered the macro this time. That's where an event manager plays its role.


The following methods make up the kernel of the ScriptForge framework:

tip

Conventionally, the String, Array and Exception services may be invoked directly respectively as SF_String, SF_Array and SF_Exception.


Services zerbitzuaren metodoen zerrenda

CreateScriptService

RegisterScriptServices
RegisterService

RegisterEventManager


CreateScriptService

Gain access to one of the services of a library for the benefit of a user script.
The returned value is a Basic object or Nothing if an error occurred.

Zerbitzu bat honakoetako bat izan daiteke:

Sintaxia:


       CreateScriptService(Service As String, [arg0, ...] As Variant) As Variant
      

Parametroak:

Service: The name of the service identified as "library.service".
The library is a Basic library that must exist in the GlobalScope. The default value is "ScriptForge".
The service is one of the services registered by the library via the RegisterScriptServices() method.

arg0, ...: A list of arguments required by the invoked service.
If the first argument refers to an event manager, then arg0 is mandatory and must be the UNO object representing the event provided as argument to the user macro.

Adibidea:


        GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
        ' Behin bakarrik egingo da
        Dim svc As Object
        Set svc = CreateScriptService("Array")
        ' Refers to the "ScriptForge.Array" service or SF_Array
        Set svc = CreateScriptService("ScriptForge.Dictionary")
        ' Returns a new empty dictionary class instance; "ScriptForge." is optional
        Set svc = CreateScriptService("SFDocuments.Calc")
        ' Refers to the Calc service, implemented in the associated SFDocuments library
        Set svc = CreateScriptService("Timer", True)
        ' Returns a Timer class instance starting immediately
        Set svc = CreateScriptService("SFDocuments.DocumentEvent", oEvent)
        ' Refers to the DocumentEvent service implemented in the associated SFDocuments library
        ' Returns the instance of the Document class that fired the event
     

RegisterScriptServices

By executing a series of invocations of RegisterService() and RegisterEventManager(), the RegisterScriptServices() method incorporates a library into the ScriptForge framework.
Each library pertaining to the framework must implement its own version of this method.

warning

Metodoa Basic modulu estandar batean biltegiratu behar da, klase-moduluen kasuan ez bezala.


Zerbitzu bat honakoetako bat izan daiteke:


          EsparruGlobala.LiburutegiIzena.ModuluIzena ' Objektua
          "LiburutegiIzena.ModuluIzena.FuntzioIzena" ' Katea
   

Adibidea:


      Public Sub RegisterScriptServices()
      ' To be stored in library = myLibrary
          With GlobalScope.ScriptForge.SF_Services
              .RegisterService("myService1", GlobalScope.myLibrary.myModule)
              ' Zerbitzua metodoen multzo gisa inplementatzen duen Basic modulu estandar baten erreferentzia
              .RegisterService("myService2", "myLibrary.someModule.someFunction")
              ' Funtzioak zerbitzua inplementatzen duen Basic objektu-klase baten instantzia bat itzuli beharko luke
              ' ...
          End With
      End Sub
   

Erabiltzaile-script batek honako instrukzio bat duenean:

Set myServ = CreateScriptService("myLibrary.myService1")


ScriptForge liburutegiak honako zereginak betetzen ditu:

  1. myLibrary liburutegia kargatzea, beharrezkoa denean

  2. RegisterScriptServices metodoari deitzea myLibrary liburutegiko zerbitzuen zerrenda memorian kargatzeko

  3. myServ aldagaia hasieratzea emandako zerbitzuarekin

RegisterService

Metodoak True itzultzen du argumentu gisa emandako izena-balioa bikotea ongi erregistratu bada.

Sintaxia:


      GlobalScope.ScriptForge.SF_Services.RegisterService(ServiceName As String, ServiceReference As Variant) As Boolean
   

Parametroak:

ServiceName: Zerbitzuaren izena, maiuskulak/minuskulak bereizten ez dituen kate gisa. Izenak bakarra izan behar du.

ServiceReference: Zerbitzu-erreferentzia bat honakoetako bat da:


          EsparruGlobala.LiburutegiIzena.ModuluIzena ' Objektua
          "LiburutegiIzena.ModuluIzena.FuntzioIzena" ' Katea
   

Adibidea:


          With GlobalScope.ScriptForge.SF_Services
              .RegisterService("myService1", GlobalScope.myLibrary.myModule)
              ' Zerbitzua metodoen multzo gisa inplementatzen duen Basic modulu estandar baten erreferentzia
              .RegisterService("myService2", "myLibrary.someModule.someFunction")
              ' Funtzioak zerbitzua inplementatzen duen Basic objektu-klase baten instantzia bat itzuli beharko luke
              ' ...
          End With
   

RegisterEventManager

Metodoak True itzuliko du argumentu gisa emandako izena-balioa parea ongi erregistratu ahal bada.

Sintaxia:


      GlobalScope.ScriptForge.SF_Services.RegisterEventManager(ServiceName As String, ServiceReference As String) As Boolean
   

Parametroak:

ServiceName: Zerbitzuaren izena maiuskulak/minuskulak bereizi gabeko kate gisa. Izenak bakarra izan behar du.

ServiceReference: A string designating the function to execute to get an instance of the service. It is in fact the function containing the New keyword of a Set statement creating the instance.:

    "LibraryName.ModuleName.FunctionName" ' String

Adibidea:


          With GlobalScope.ScriptForge.SF_Services
              .RegisterEventManager("myEventMgr", "myLibrary.someModule.someFunction")
              ' Funtzioak zerbitzua inplementatzen duen Basic objektu-klase baten instantzia bat itzuli behar du
              ' ...
          End With
  
warning

Aurrizki gisa azpimarra bat ("_") duten ScriptForge Basic errutina edo identifikatzaile guztiak barneko erabilerarako erreserbatuta daude. Ez daude Basic makroetan erabiltzeko pentsatuta.