/** * ******************************************************************* create a new frame with a * new container window inside, which isn't part of the global frame tree. * * <p>Attention: a) This frame wont be destroyed by the office. It must be closed by you! Do so - * please call XCloseable::close(). b) The container window is part of the frame. Dont hold it * alive - nor try to kill it. It will be destroyed inside close(). */ public void createPreviewFrame(XMultiServiceFactory xmsf, XControl xControl) throws com.sun.star.uno.Exception, com.sun.star.lang.IllegalArgumentException { XWindowPeer controlPeer = xControl.getPeer(); XWindow controlWindow = UnoRuntime.queryInterface(XWindow.class, xControl); Rectangle r = controlWindow.getPosSize(); Object toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit"); XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, toolkit); WindowDescriptor aDescriptor = new WindowDescriptor(); aDescriptor.Type = WindowClass.SIMPLE; aDescriptor.WindowServiceName = "window"; aDescriptor.ParentIndex = -1; aDescriptor.Parent = controlPeer; // xWindowPeer; //argument ! aDescriptor.Bounds = new Rectangle(0, 0, r.Width, r.Height); aDescriptor.WindowAttributes = VclWindowPeerAttribute.CLIPCHILDREN | WindowAttribute.SHOW; XWindowPeer xPeer = xToolkit.createWindow(aDescriptor); xWindow = UnoRuntime.queryInterface(XWindow.class, xPeer); Object frame = xmsf.createInstance("com.sun.star.frame.Frame"); xFrame = UnoRuntime.queryInterface(XFrame.class, frame); xFrame.initialize(xWindow); xWindow.setVisible(true); }