Could anybody help me with the java calls needed to find out the window handle of a document, starting from an XSpreadsheetDocument object ?
I use Open Office 3.3 on Windows XP SP3 and Java 1.6.0_26.
Thanks in advance !
[Solved] Get the Window Handle of a document ?
[Solved] Get the Window Handle of a document ?
Last edited by Hagar Delest on Thu Sep 08, 2011 5:32 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 3.3 on Windows XP SP3
Re: Get the Window Handle of a document ?
If the Spreadsheet document is loaded in OpenOffice it has a CurrentController property. Which in turn has a ApplicatonMainWindow, ComponentWindow and/or a Frame. Check the UNO API on SpreadsheetDocuments or use a object inspection tool like MRI (can be found amoung the OOo extensions).
In any case though the ComponentWindow and ApplicatonMainWindow are shown as type awt.XWindow they are still UNO objects and not Java Windowing Toolkit objects. So I have my doubts, that they would let you access their window handle.
In any case though the ComponentWindow and ApplicatonMainWindow are shown as type awt.XWindow they are still UNO objects and not Java Windowing Toolkit objects. So I have my doubts, that they would let you access their window handle.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Re: Get the Window Handle of a document ?
Thank you for your reply !
Here is a possible solution:
Here is a possible solution:
Code: Select all
XModel model = (XModel) UnoRuntime.queryInterface(XModel.class, xSpreadsheetDocument);
XController c = model.getCurrentController();
XFrame frame = c.getFrame();
XWindow window = frame.getContainerWindow();
XSystemDependentWindowPeer xWindowPeer = (XSystemDependentWindowPeer) UnoRuntime.queryInterface(XSystemDependentWindowPeer.class, window);
int handle = (Integer) xWindowPeer.getWindowHandle("".getBytes(), SystemDependent.SYSTEM_WIN32);
OpenOffice 3.3 on Windows XP SP3