[Solved] Changing Window Title

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ip0010
Posts: 3
Joined: Fri Jan 14, 2011 6:16 pm

[Solved] Changing Window Title

Post by ip0010 »

Hi.
I'm trying to change the window title to an specific name. In OpenOffice 2.4.1 I have done this via

Code: Select all

XPropertySet xFramePropertyAccess = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xFrame);
xFramePropertyAccess.setPropertyValue("Title", title);
XModifiable xModifiable = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, xcomponent);
But this is not working anymore. As well

Code: Select all

XDocumentInfoSupplier xDocInfoSupplier = (XDocumentInfoSupplier) UnoRuntime.queryInterface(XDocumentInfoSupplier.class,xcomponent);
XDocumentInfo docInfo = xDocInfoSupplier.getDocumentInfo();
XPropertySet xproperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,docInfo);
xproperties.setPropertyValue("Title", title);
has no effect. The windowtitle and the taskrow-entry is just empty when i create a new document via a template. It's very hard to stay organized if you open several documents like this.
Is there any way to change the window title?
Cheers, Ingo
Last edited by Hagar Delest on Mon Feb 14, 2011 3:37 pm, edited 1 time in total.
Reason: tagged Solved.
OpenOffice 3.2.1 on Windows 7 / OpenOffice 3.2.1 on OpenSuse 11.x
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Changing Window Title

Post by hanya »

How did you make your document frame? If you make it through desktop, its title can be changed through the following interface:
http://api.openoffice.org/docs/common/r ... Title.html
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
ip0010
Posts: 3
Joined: Fri Jan 14, 2011 6:16 pm

Re: Changing Window Title

Post by ip0010 »

Hi.
I'm loading a component through the Desktop but I have created the frame before and I pass the name of the frame to the loadComponentFromURL()-method. And if i do this in this way the XTitle.setTitle()-method is not working.
I create the Frame by my own to have an handle to the frame of my loaded component. Unfortunately I can't get the frame from the componetn if I let the Desktop create the frame for me. I just get the component back :-(

Any ideas?
OpenOffice 3.2.1 on Windows 7 / OpenOffice 3.2.1 on OpenSuse 11.x
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Changing Window Title

Post by hanya »

You need to create new frame through css.frame.TaskCreator service in this case. Here is an example written in python.

Code: Select all

# written in Python
	# create window and frame
	#NamedValue('MakeVisible', False), 
	#NamedValue('CreateTopWindow', True), 
	#NamedValue('SupportPersistentWindowState', False), 
	#NamedValue('EnableTitleBarUpdate', True)
	self.frame = smgr.createInstanceWithContext(
		'com.sun.star.frame.TaskCreator', ctx).createInstanceWithArguments(
		(NamedValue('FrameName', MRINAME), 
		NamedValue('PosSize', Rectangle(ps[0], ps[1], ps[2], ps[3]))))
If you want to know well about it, read the following code:
http://svn.services.openoffice.org/open ... rv.cxx#132
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
ip0010
Posts: 3
Joined: Fri Jan 14, 2011 6:16 pm

Re: Changing Window Title

Post by ip0010 »

That's quite the way I made it. But I couldn't change the title than. My code:

Code: Select all

		XToolkit xtoolkit =(XToolkit)UnoRuntime.queryInterface(XToolkit.class,mxServiceManager.createInstance("com.sun.star.awt.Toolkit") );
		WindowDescriptor aDescriptor = new WindowDescriptor();
		aDescriptor.Type = com.sun.star.awt.WindowClass.TOP;
		aDescriptor.WindowServiceName = "window";
		aDescriptor.ParentIndex = -1;
		aDescriptor.Parent = null;
		aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0,0,0,0);
		aDescriptor.WindowAttributes = WindowAttribute.CLOSEABLE |
		WindowAttribute.BORDER |
		WindowAttribute.MOVEABLE |
		WindowAttribute.SIZEABLE ;
		XWindowPeer xpeer = xtoolkit.createWindow( aDescriptor );
		xWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class,xpeer);
		xFrame = (XFrame)UnoRuntime.queryInterface(XFrame.class, mxServiceManager.createInstance("com.sun.star.frame.Frame"));
		xFrame.initialize(xWindow);
		XFramesSupplier xTreeRoot = (XFramesSupplier)UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop);
		xTreeRoot.getFrames().append(xFrame);
		xFrame.setName("PMOpenOfficeFrame" + System.currentTimeMillis());
But it's fine now, when I create a new frame via loading a template and get the frame from the model:

Code: Select all

PropertyValue[] loadProps = new PropertyValue[3];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "AsTemplate";
loadProps[0].Value = new Boolean(true);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "Hidden";
loadProps[1].Value = new Boolean(false);
loadProps[2] = new PropertyValue();
loadProps[2].Name = "ReadOnly";
loadProps[2].Value = new Boolean(true);
xcomponent = xcomponentloader.loadComponentFromURL("file:///" + destination,"_blank", FrameSearchFlag.ALL, loadProps);
XModel xModel = (XModel) UnoRuntime.queryInterface (XModel.class, xcomponent);
xFrame = xModel.getCurrentController().getFrame();
xWindow = xFrame.getComponentWindow();
But it's still interesting why I can't change the frame title if I create the frame by my self.

Cheers, Ingo
OpenOffice 3.2.1 on Windows 7 / OpenOffice 3.2.1 on OpenSuse 11.x
Post Reply