1

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

openoffice的以下代码等效于什么:

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

1 回答 1

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;
于 2013-04-05T07:44:31.120 回答