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;
}
}
else {
windowOK = true;
}
}
Point p = xAccessibleComponent.getLocationOnScreen();
// System.out.println("ScreenPoint: " + p.X + " " + p.Y );
// System.out.println("WindowPoint: " + posSize.X + " " + posSize.Y + " " + posSize.Width + " " + posSize.Height);
Point closer = new Point();
closer.X = p.X + posSize.Width - 2;
closer.Y = p.Y + 5;