Hello,
I'm trying to create a docking window inside OpenOffice (2.0.1) like
the Gallery or the Media Player in the tools menu.
I try to achieve this but i cannot find any documentation or snippet
code about this.
I can create a "dockingwindow" and i think i have to create an UI
element with the FactoryManager and dock it via the LayoutManager but
i don't know how to do this.
I didn't find anything about this on the web or the mailinglists.
Here is my code (in Java) :
public void newDockingWindow() throws Exception
{
XWindowPeer MyWindowPeer = (XWindowPeer)
UnoRuntime.queryInterface(XWindowPeer.class,
_xController.getFrame().getContainerWindow());
XToolkit MyToolkit = MyWindowPeer.getToolkit();
WindowDescriptor aDescriptor = new WindowDescriptor();
aDescriptor.Type = WindowClass.SIMPLE;
aDescriptor.WindowServiceName = new String("dockingwindow");
aDescriptor.ParentIndex = -1;
aDescriptor.Parent = MyWindowPeer;
aDescriptor.Bounds = new Rectangle(50, 50, 100, 100);
aDescriptor.WindowAttributes = 0;
XWindowPeer xPeer = MyToolkit.createWindow(aDescriptor);
xPeer.setBackground(0x0000ff);
XWindow xWindow = (XWindow)UnoRuntime.queryInterface(
XWindow.class, xPeer);
XFrame xFrame = (XFrame)UnoRuntime.queryInterface(
XFrame.class,
_xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.frame.Frame",
_xComponentContext));
xFrame.setName("myframe");
xFrame.initialize(xWindow);
xWindow.setVisible(true);
XPropertySet props = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, _xController.getFrame());
Object obj = props.getPropertyValue("LayoutManager");
XLayoutManager layout =
(XLayoutManager)UnoRuntime.queryInterface(XLayoutManager.class, obj);
XUIElementFactoryRegistration uielemfactoryreg =
(XUIElementFactoryRegistration)UnoRuntime.queryInterface(
XUIElementFactoryRegistration.class,
_xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.ui.UIElementFactoryManager",
_xComponentContext));
// I don't know what to put here
uielemfactoryreg.registerFactory("floater", "myframe", null, null);
XUIElementFactory uielemfactory =
(XUIElementFactory)UnoRuntime.queryInterface(
XUIElementFactory.class,
_xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.ui.UIElementFactory",
_xComponentContext));
PropertyValue[] loadProps = new PropertyValue[1];
PropertyValue asTemplate = new PropertyValue();
asTemplate.Name = "Frame";
asTemplate.Value = xFrame;
loadProps[0] = asTemplate;
uielemfactory.createUIElement("private:resource/floater/myframe",
loadProps);
layout.floatWindow("private:resource/floater/myframe");
Point p = new Point(0, 0);
layout.dockWindow("private:resource/floater/myframe",
DockingArea.DOCKINGAREA_DEFAULT, p);
}
With this code, i obtain an IllegalArgumentException on the method
registerFactory.
Any help is welcome! Thank you!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]