Hello everybody
We are moving from OpenOffice to LibreOffice
We have some macros that uses popup menus that work perfectly in
OpenOffice but they don't work in LibreOffice.
We developed our code starting from examples (thanks Hania and Ermione)
that we found over the internet and that are attached.
Any suggestions to make the macro run fine?
Thanks to everybody
REM ***** BASIC *****
Dim oDialog As Object
Dim oPopupMenu As Object
Sub Main
sLibName = "Standard"
sDialogName = "Dialog1"
DialogLibraries.LoadLibrary(sLibName)
' create new dialog
oDialog = CreateUnoDialog( _
DialogLibraries.getByName(sLibName).getByName(sDialogName))
oDialog.execute()
End Sub
Sub PopupButton
' get the size of the button
oButton = oDialog.getControl("CommandButton1")
aPosSize = oButton.PosSize
' set the position of the popup menu
Dim aRect As New com.sun.star.awt.Rectangle
With aRect
.X = aPosSize.X
.Y = aPosSize.Y + aPosSize.Height
.Width = 0'100
.Height = 0'100
End With
' menu listener
oMenuListener = CreateUnoListener( _
"PopupMenuListener_", "com.sun.star.awt.XMenuListener")
' new popupmenu
oPopupMenu = CreateUnoService("com.sun.star.awt.PopupMenu")
' set listener and insert menu items
With oPopupMenu
.addMenuListener(oMenuListener)
.insertItem(1,"Menu 1",0,0) 'id, label, type, position
.insertItem(2,"Menu 2",0,2)
.insertSeparator(1)
.setCommand(1,"item1")
.setCommand(2,"item2")
End With
' show popup menu
oPopupMenu.execute(oDialog.Peer,aRect, _
com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT)
oPopupMenu.removeMenuListener(oMenuListener)
End Sub
Sub PopupMenuListener_select ( oEv )
sCmd = oEv.Source.getCommand(oEv.MenuId)
msgbox sCmd
End Sub
Sub PopupMenuListener_highlight ( oEv )
End Sub
Sub PopupMenuListener_activate ( oEv )
End Sub
Sub PopupMenuListener_deactivate ( oEv )
End Sub
Sub PopupMenuListener_disposing( oEv )
End Sub