[Solved] Get the Window Handle of a document ?

The Application Programming Interface and the OASIS Open Document Format

[Solved] Get the Window Handle of a document ?

Postby bcris » Wed Aug 24, 2011 10:49 am

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 !
Last edited by Hagar Delest on Thu Sep 08, 2011 5:32 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.3 on Windows XP SP3
bcris
 
Posts: 21
Joined: Wed Aug 17, 2011 3:51 pm

Re: Get the Window Handle of a document ?

Postby rudolfo » Wed Aug 24, 2011 10:10 pm

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.
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.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Get the Window Handle of a document ?

Postby bcris » Mon Aug 29, 2011 10:30 am

Thank you for your reply !

Here is a possible solution:

Code: Select all   Expand viewCollapse view
        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
bcris
 
Posts: 21
Joined: Wed Aug 17, 2011 3:51 pm

Re: Get the Window Handle of a document ?

Postby bcris » Thu Sep 08, 2011 4:02 pm

Solved.
OpenOffice 3.3 on Windows XP SP3
bcris
 
Posts: 21
Joined: Wed Aug 17, 2011 3:51 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests