Funkce CreateUnoServiceWithArguments

Vytvoří instanci služby UNO se službou ProcessServiceManager, a to včetně dodatečných volitelných argumentů.

Syntaxe:


    CreateUnoServiceWithArguments(ServiceName As String, Arguments() As Variant) As Object
  
tip

Služby UNO, které je možné používat s funkcí CreateUnoServiceWithArguments, lze identifikovat pomocí názvů metod začínajících řetězci createInstanceWith.. nebo createWith...


Návratová hodnota:

Instance služby UNO zadaného názvu, případně hodnota Null.

note

Seznam dostupných služeb naleznete na stránce s popisem modulu com::sun::star.


Parametry:

Name

Type

Description

ServiceName

String

The UNO service name to be created.

Arguments

Variant

One to many arguments that specify the instance of the service. Arguments are stored as a one dimensional array, according to their positions in the constructor method definition.


Příklad:

The com.sun.star.ui.dialogs.FilePicker example below displays a built-in LibreOfficeDev Save As dialog with two extra controls: a listbox and a checkbox.


    Sub FileSaveAsDialog()
       td = com.sun.star.ui.dialogs.TemplateDescription
       options = td.FILESAVE_AUTOEXTENSION_TEMPLATE
       dlg = CreateUnoServiceWithArguments( _
          "com.sun.star.ui.dialogs.FilePicker", _
          Array(options))
       dlg.execute()
    End Sub ' FileSaveAsDialog
  

Souborové dialogy - například Otevřít, Uložit jako - jsou k dispozici ve dvou podobách:

Z jedné podoby na druhou se přepnete pomocí - LibreOfficeDev - Obecné.

tip

Služby UNO mají obsáhlou dokumentaci online na stránce api.libreoffice.org. Další informace o metodách služby použité v předchozím příkladu naleznete na stránce FilePicker Service.


Příklad:

Následující kód využívá službu com.sun.star.security.DocumentDigitalSignatures pro podepsání aktuálního dokumentu:


Sub  SignCurrentDocDialog
   Dim pv(0) as new com.sun.star.beans.PropertyValue
   pv(0).Name  = "StorageFormat"
   pv(0).Value = "ZipFormat"
   mode = com.sun.star.embed.ElementModes
   sf = CreateUnoService("com.sun.star.embed.StorageFactory")
   storage = sf.createInstanceWithArguments(Array(ThisComponent.URL, mode.WRITE, pv))
   dds = CreateUnoServiceWithArguments( _
      "com.sun.star.security.DocumentDigitalSignatures", _
      Array("1.2", True)) 
   dds.signDocumentContent(storage, Null)
End Sub ' SignCurrentDocDialog

Konstruktory CreateWithVersion a createWithVersionAndValidSignature služby UNO com.sun.star.security.DocumentDigitalSignatures představují dva různé způsoby vytvoření instance této služby pomocí funkce CreateUnoServiceWithArguments.