Hi,
My goal is to create a non-modal dialog to replace default Styles and
Formatting - dialog.
MyDialog contains a listbox for styles just like the Style and
Formatting - dialog.
I would appreciate your opinion about the way I have done this dialog.
There is also a problem: this dialog won't close when clicking that
cross at top right corner of the dialog.
What I've done wrong?
Is the dialog even the right way to do this?
private void createDialog() throws java.lang.Exception {
String listBoxName = "StyleListBox";
// create the dialog model and set its properties
Object dialogModel =
xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.awt.UnoControlDialogModel", xRemoteContext);
XPropertySet xPSetDialog = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, dialogModel);
xPSetDialog.setPropertyValue("Sizeable", new Boolean(false));
xPSetDialog.setPropertyValue("PositionX", new Integer(100));
xPSetDialog.setPropertyValue("PositionY", new Integer(100));
xPSetDialog.setPropertyValue("Width", new Integer(120));
xPSetDialog.setPropertyValue("Height", new Integer(280));
xPSetDialog.setPropertyValue("Title",
new String("Styles and Formatting"));
xPSetDialog.setPropertyValue("Closeable", new Boolean(false));
// get the service manager from the dialog model
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(
XMultiServiceFactory.class, dialogModel);
// create the listbox model and set its properties
Object listBoxModel = xMultiServiceFactory.createInstance(
"com.sun.star.awt.UnoControlListBoxModel");
String[] a = {"My Heading1", "My Heading2"};
XPropertySet xPSetListBox = (XPropertySet)
UnoRuntime.queryInterface(
XPropertySet.class, listBoxModel);
xPSetListBox.setPropertyValue("MultiSelection", new Boolean(false));
xPSetListBox.setPropertyValue("StringItemList", a);
xPSetListBox.setPropertyValue("Name", listBoxName);
xPSetListBox.setPropertyValue("PositionX", new Integer(0));
xPSetListBox.setPropertyValue("PositionY", new Integer(0));
xPSetListBox.setPropertyValue("Width", new Integer(120));
xPSetListBox.setPropertyValue("Height", new Integer(280));
// insert listbox model into the dialog model
XNameContainer xNameCont = (XNameContainer)
UnoRuntime.queryInterface(
XNameContainer.class, dialogModel);
xNameCont.insertByName(listBoxName, listBoxModel);
// create the dialog control and set the model
Object dialog = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.awt.UnoControlDialog", xRemoteContext);
XControl xControl = (XControl) UnoRuntime.queryInterface(
XControl.class, dialog);
XControlModel xControlModel = (XControlModel)
UnoRuntime.queryInterface(
XControlModel.class, dialogModel);
xControl.setModel(xControlModel);
// not quite sure what this does but it works
XWindow xWindow = (XWindow) UnoRuntime.queryInterface(
XWindow.class, xControl);
xWindow.setVisible(true);
}
Tuomas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]