Specify names of documents loaded as private:stream?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
juergenk
Posts: 1
Joined: Tue Jun 03, 2014 10:53 am

Specify names of documents loaded as private:stream?

Post by juergenk »

I load documents from streams using the URL "private:stream":

Code: Select all

XComponentLoader xLoader = ...;
byte[] bytes = ...;
ByteArrayToXInputStreamAdapter batxisa = new ByteArrayToXInputStreamAdapter(bytes);
PropertyValue[] properties = new PropertyValue[2];
properties[0] = new PropertyValue();
properties[0].Name = "InputStream";
properties[0].Value = batxisa;
		
properties[1] = new PropertyValue();
properties[1].Name = "FilterName";
properties[1].Value = "writer8"; 
xComponent = xLoader.loadComponentFromURL("private:stream", "some XFrame name", com.sun.star.frame.FrameSearchFlag.CHILDREN, someProperties);
...
Unfortuanately, these documents are not represented with sensible 'names' in the GUI.
In File -> Recent Documents they are shown as 'private:' and in the Windows menu an empty row is shown.

Is it possible to specify a more meaningful name for the document, e.g. in analogy to documents loaded from the file system?

Thanks
LibreOffice 4.1, Windows 8.1
kwalcock
Posts: 24
Joined: Thu Oct 09, 2014 11:54 am

Re: Specify names of documents loaded as private:stream?

Post by kwalcock »

If you figured this out, please share your wisdom. I'm trying to do the same thing with loadComponentFromURL and private:factory/swriter to get an empty document that I would like to name in advance. I've tried adding properties of "DocumentTitle", "FileName", and "URL" before the load as well as adding to the URL and setting the Name of the frame and title of the window. Whatever I do, various parts of the UI display "Untitled" or "Untitled2" or "Untitled 2" for the properties or when I try to close with unsaved modifications. I can't figure out where these are coming from and how to automatically set them to my name in advance.
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
kwalcock
Posts: 24
Joined: Thu Oct 09, 2014 11:54 am

Re: Specify names of documents loaded as private:stream?

Post by kwalcock »

If loadFromURL returns Reference<XComponent> xComponent,

then in C++ do this to it:

Reference<XModel> xModel(xComponent, UNO_QUERY);
Reference<XTitle> xTitle(xModel, UNO_QUERY);
xTitle->setTitle(constOUString("Title"));

This will get "Title" into some of the dialogs, although not yet into the Properties dialog.
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
Post Reply