FtBGr‖

jy6GG‖CreateUnoServiceWithArguments Function

hpwH8‖Instantiates a UNO service with the ProcessServiceManager, including supplemental optional arguments.

FVEx2‖Syntax:


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

F22EU‖UNO services that can be used with CreateUnoServiceWithArguments function are identifiable with method names that follow a createInstanceWith.. or createWith.. naming pattern.


WADQ4‖Parameters:

GzWhN‖ServiceName: The UNO service name to be created.

WiMhH‖Arguments: 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.

GePPP‖Return value:

HzdPA‖An instance of the given UNO service name, otherwise Null value.

note

J5VwA‖For a list of available services, visit the com::sun::star Module reference page.


EFSA4‖Example:

kC6BC‖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
  

rkBMa‖File dialogs - such as Open, Save As and the like - are available in two different ways:

TWsL9‖Use - LibreOfficeDev - General to shift from one to the other.

tip

Br5yC‖UNO services have an extensive online documentation in the api.libreoffice.org website. Visit the FilePicker Service reference page to learn more about the methods provided by the service used in the example above.


EFSA4‖Example:

3HnqR‖

qboA2‖The following code uses the service com.sun.star.security.DocumentDigitalSignatures to sign the current document:


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

Gx523‖CreateWithVersion and createWithVersionAndValidSignature constructor methods in com.sun.star.security.DocumentDigitalSignatures UNO service indicate two different ways of instantiating this service with CreateUnoServiceWithArguments function.