如何以编程方式获取Openoffice编写器上的默认模板

时间:2013-04-02 07:38:33

标签: c# default openoffice.org openoffice-writer

如何以编程方式获取openoffice writer的默认模板?

与openoffice的以下代码相同:

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

1 个答案:

答案 0 :(得分:0)

我能做到这一点的唯一方法是创建一个新的空白文档然后读取用于创建它的模板,虽然我期望在应用程序级别上有这样的属性,希望这有助于其他人:

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;