I am trying to generate Typescript definitions from the LibreOffice IDL (via Doxygen-generated XML).
The XMultiServiceFactory interface has two methods for creating instances: createInstance
and createInstanceWithArguments
. However, I can't seem to find which types require arguments and what they are, and should be instantiated with createInstanceWithArguments
; and which types don't require arguments, and should be instantiated with createInstance
.
Being able to define overloads based on the string parameter passed to the method would enable static typing based on those overloads:
// automatically typed as com.sun.star.frame.Desktop
let desktop = objServiceManager.createInstance('com.sun.star.frame.Desktop');
otherwise the result would have to be explicitly typed:
let desktop = objServiceManager.createInstance('com.sun.star.frame.Desktop')
as com.sun.star.frame.Desktop;
How can I know from the documentation whether a given type needs arguments or not, and what those arguments are?
(LibreOffice 5.3.5 / Windows 10 64-bit)
(Originally posted at ask.libreoffice, with no answer.)
According to the Service Manager dev guide:
I take this to mean that the IDL files should tell what if any arguments are needed. For example, in the source code file
/offapi/com/sun/star/configuration/ConfigurationProvider.idl
, there is a detailed description of arguments, and the comments state that it is also possible to create an instance without any arguments. (The code does not show the arguments however; it's explained only in comments).It looks like all the relevant information from that file has been included in the online documentation for ConfigurationProvider, so there is no need to actually look at the IDL files.
Contrast that with com.sun.star.frame.Desktop, which does not take arguments, as shown in the example at https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Using_the_Desktop.