Question

How do i get the default template for openoffice writer programmatically?

What is the equivalent to the following code for openoffice:

var word = new Microsoft.Office.Interop.Word.Application();
string template = word.NormalTemplate.FullName;
Was it helpful?

Solution

The only way i could do that is by creating a new blank document then read its template that was used to create it, although i was expecting such a property on application level, hope this helps others:

private XComponentContext oStrap = uno.util.Bootstrap.bootstrap();    
XMultiServiceFactory oServMan = (XMultiServiceFactory) oStrap.getServiceManager();
XComponentLoader oDesk = (XComponentLoader) oServMan.createInstance("com.sun.star.frame.Desktop");
string url = @"private:factory/swriter";
PropertyValue[] propVals = new PropertyValue[0];
XComponent oDoc = oDesk.loadComponentFromURL(url, "_null", 0, propVals);
var DefaultTemplate = ((XDocumentPropertiesSupplier)oDoc).getDocumentProperties().TemplateURL;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top