catch(com.sun.star.uno.Exception e) {
throw new StatusException("Could not create 'com.sun.star.awt.Toolkit'.", e);
}
XExtendedToolkit xExtendedToolkit = (XExtendedToolkit)UnoRuntime.queryInterface(XExtendedToolkit.class, aToolkit);
AccessibilityTools accTools = new AccessibilityTools();
XWindow xWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, xExtendedToolkit.getActiveTopWindow());
XAccessible xRoot = accTools.getAccessibleObject(xWindow);
XTopWindow tw = null;
XAccessibleComponent xAccessibleComponent = null;
int k = xExtendedToolkit.getTopWindowCount();
for (int i=0;i<k;i++) {
try {
XTopWindow tw_temp = xExtendedToolkit.getTopWindow(i);
XAccessible xacc = (XAccessible)UnoRuntime.queryInterface(XAccessible.class, tw_temp);
if (xacc != null) {
System.out.println("Name: " + xacc.getAccessibleContext().getAccessibleName());
if (xacc.getAccessibleContext().getAccessibleName().startsWith("the title")) {
tw = tw_temp;
XAccessibleContext xContext = xacc.getAccessibleContext();
xAccessibleComponent = (XAccessibleComponent)UnoRuntime.queryInterface(XAccessibleComponent.class, xContext);
if (xAccessibleComponent == null)
System.out.println("!!!! MIST !!!!");
else
System.out.println("########## KLAPPT ########## ");
}
}
else {
log.println("\t unknown window");
}
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
}
}
if (tw == null) {
System.out.println("No TopWindow :-(");
return null;
}
xWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, tw);
Rectangle posSize = xWindow.getPosSize();
// compare the center point with the dimensions of the current top window
boolean windowOK = false;
while(!windowOK) {
if (posSize.X <= center.X && center.X <= posSize.X + posSize.Width) {
if (posSize.Y <= center.Y && center.Y <= posSize.Y +posSize.Height) {
// move window out of the way
posSize.X = posSize.X + 10;
posSize.Y = posSize.Y +10;
xWindow.setPosSize(posSize.X, posSize.Y, posSize.Width, posSize.Height, PosSize.POS);
}
else {
windowOK = true;
}
}