How to insert tab pages to a dialog using Java?
Posted: Tue Dec 30, 2014 3:02 pm
As a beginner I am using Java to create a UNO dialog with a number of tab pages. However, when I insert a UnoControlTabPageModel to its container, UnoControlTabPageContainerModel, I get a SIGSEV (see code and SIGSEV output below). I use Libreoffice + SDK 4.2.7 and a netbeans Apache Openoffice 4.0.6 plugin.
My question is: does anybody know how to successfully create a dialog with tab pages in Java? (Examples exist for Python and Basic (e.g., here), however, for this project I really need to use Java).
The SIGSEV occurs when I execute:
giving the following stacktrace (complete output attached):
a larger sample of the code is listed below (while the full file is on pastebin):
My question is: does anybody know how to successfully create a dialog with tab pages in Java? (Examples exist for Python and Basic (e.g., here), however, for this project I really need to use Java).
The SIGSEV occurs when I execute:
Code: Select all
xTabPageContainerModel.insertByIndex(0, oTabPageModel);
Code: Select all
j com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(JLjava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+0
j com.sun.star.bridges.jni_uno.JNI_proxy.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+146
j com.sun.proxy.$Proxy18.insertByIndex(ILjava/lang/Object;)V+23
j com.kuijper.BTGUI.insertTabPage(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;IIS)Ljava/lang/Object;+176
j com.kuijper.ConfigDialog.<init>(Lcom/sun/star/uno/XComponentContext;)V+49
j com.kuijper.BibTexLib.dispatch(Lcom/sun/star/util/URL;[Lcom/sun/star/beans/PropertyValue;)V+40
a larger sample of the code is listed below (while the full file is on pastebin):
Code: Select all
// create a TabPage model using the dialog's
// MultiServiceFactory, which is contained in m_xMSFDialog
Object oTabPageModel = m_xMSFDialog.createInstance(
"com.sun.star.awt.tab.UnoControlTabPageModel"
);
// get the tab page model's interface, so that we can set certain
// properties to the TabPageModel
XTabPageModel xTabPageModel = (XTabPageModel)
UnoRuntime.queryInterface(XTabPageModel.class,oTabPageModel);
// set properties of the tab page using XMultiPropertySet
XMultiPropertySet xTabPageMPSet = (XMultiPropertySet)
UnoRuntime.queryInterface(
XMultiPropertySet.class,
xTabPageModel
);
// set the actual properties
// strangely, setting properties such as ToolTip, while mentioned in the API docs
// results in an exception, so I am only setting the title property here
// http://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/tab/XTabPageModel.html
xTabPageMPSet.setPropertyValues(
new String[]{
"Title"
},
new Object[]{
new String("the title")
});
// We also have to get the interface to the TabPageContainerModel
// as this contains the function InsertByIndex
XTabPageContainerModel xTabPageContainerModel =
(XTabPageContainerModel) UnoRuntime.queryInterface(
XTabPageContainerModel.class, oTabPageContainerModel
);
// add the model to the container
// Here, the SIGSEV occurs:
xTabPageContainerModel.insertByIndex(0, oTabPageModel);