try
{
XPropertySet docProps = dbfTools.queryPropertySet( m_document.getDocument() );
XLibraryContainer basicLibs = (XLibraryContainer)UnoRuntime.queryInterface(
XLibraryContainer.class, docProps.getPropertyValue( "BasicLibraries" ) );
XNameContainer basicLib = basicLibs.createLibrary( "default" );
String sListSelectionScript =
"Option Explicit\n" +
"\n" +
"Sub onListBoxSelected( oEvent as Object )\n" +
" Dim oView as Object\n" +
" Dim oSheet as Object\n" +
" Dim oSheets as Object\n" +
"\n" +
" Dim oControlModel as Object\n" +
" Dim sSheet as String\n" +
"\n" +
" if ( oEvent.Selected <> 65535 ) Then\n" +
" oControlModel = oEvent.Source.Model\n" +
" sSheet = oControlModel.StringItemList( oEvent.Selected )\n" +
"\n" +
" oSheets = thisComponent.Sheets\n" +
" oSheet = oSheets.getByName(sSheet)\n" +
"\n" +
" oView = thisComponent.CurrentController\n" +
" oView.setActiveSheet( oSheet )\n" +
" End If\n" +
"End Sub\n" +
"\n" +
"Sub onButtonClicked\n" +
" MsgBox \"clicked\"\n" +
"End Sub\n";
basicLib.insertByName( "callbacks", sListSelectionScript );
}
catch( com.sun.star.uno.Exception e )
{
e.printStackTrace( System.err );
}