XModel xModel = (XModel)
UnoRuntime.queryInterface(XModel.class, xSheetDoc);
System.out.println("Name: " + xModel.getCurrentController().getFrame().getName());
XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)tParam.getMSF(), xModel);
XAccessible xRoot = at.getAccessibleObject(xWindow);
at.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE );
XAccessibleComponent AccessibleSpreadsheet = (XAccessibleComponent) UnoRuntime.queryInterface(XAccessibleComponent.class,AccessibilityTools.SearchedContext);
log.println("Got " + util.utils.getImplName(AccessibleSpreadsheet));
Object toolkit = null;
try {
toolkit = ((XMultiServiceFactory)tParam.getMSF()).createInstance("com.sun.star.awt.Toolkit");
} catch (com.sun.star.uno.Exception e) {
log.println("Couldn't get toolkit");
e.printStackTrace(log);
throw new StatusException("Couldn't get toolkit", e);
}
XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(
XExtendedToolkit.class, toolkit);
XTopWindow tw = null;
int k = tk.getTopWindowCount();
for (int i=0;i<k;i++) {
try {
XTopWindow tw_temp = tk.getTopWindow(i);
XAccessible xacc = (XAccessible) UnoRuntime.queryInterface(XAccessible.class, tw_temp);
if (xacc != null) {
if (xacc.getAccessibleContext().getAccessibleName().indexOf("d2")>0) {
tw=tw_temp;
};
} else {
log.println("\t unknown window");
}