createInstance vs createInstanceWithArguments

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 which types don’t require arguments.


This would be of great value in creating these definitions, because Typescript supports multiple overloads based on different values of string parameters. For example, given the following definitions:

namespace com.sun.star {
    namespace lang {
        interface ServiceManager extends XMultiServiceFactory { }
        interface XMultiServiceFactory {
            createInstance('com.sun.star.frame.theDesktop'): com.sun.star.frame.theDesktop;
        }
    ]
    namespace frame {
        interface theDesktop {
            // members defined here
        }
    }
}

// This is using the Automation bridge, but the definitions could be written just as easily
// for Javascript macros running via the Rhino interpreter
interface ActiveXObject {
    new(progid: 'com.sun.star.ServiceManager'): com.sun.star.lang.ServiceManager;
}

Typescript will recognize the appropriate types:

// automatically typed as com.sun.star.lang.ServiceManager
let objServiceManager = new ActiveXObject('com.sun.star.ServiceManager');

// automatically typed as com.sun.star.frame.theDesktop
let desktop = objServiceManager.createInstance('com.sun.star.frame.theDesktop');

and will issue errors when trying to use a method via desktop that isn’t available on the theDesktop singleton:

// will fail compilation
desktop.badMethod();

The alternative is to explicitly cast values to the appropriate type:

let desktop = objServiceManager.createInstance('com.sun.star.frame.theDesktop') as com.sun.star.frame.theDesktop;

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