I have found something strange that I could not find here in this forum, even after spending the last 2 days looking.
I will be glad to delete this if someone can refer me to a post handling this problem that I haven't found yet.
First off, here's my code:
Code: Select all
private unoidl.com.sun.star.sheet.XSpreadsheetDocument GetSpreadSheetTemplate(string filename)
{
// If filename is empty create a new sheet.
string loadUrl = "";
if (string.IsNullOrEmpty(filename))
loadUrl = "private:factory/scalc";
else
loadUrl = "file:///" + filename;
// set load property
unoidl.com.sun.star.beans.PropertyValue[] loadProps = new unoidl.com.sun.star.beans.PropertyValue[1];
loadProps[0] = new unoidl.com.sun.star.beans.PropertyValue();
loadProps[0].Name = "AsTemplate";
loadProps[0].Value = new uno.Any(false);
XComponentLoader aLoader = (XComponentLoader)mXMSFactory.createInstance("com.sun.star.frame.Desktop");
XComponent xComponent = aLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps);
// return Spreadsheet Document
return (unoidl.com.sun.star.sheet.XSpreadsheetDocument)xComponent;
}
This doesn't work at all UNLESS I have an instance of LibreOffice running with this document already opened in it or I use a blank filename to get the generic calc template. In that case a second window is opened with this document in read only mode.
Setting "AsTemplate" to true opens a second window with a this document as a new unnamed document that can be edited. That's part of what I want however ...
What I want is to open the document even when LO is NOT running. I only want to use this file as a template so that I only have set headers/footers, etc. in the template.
In fact, I thought after borrowing much of the above code in many other blog entries that this would work just fine.
What am I doing wrong here???