Files
odfstudio/wizards/source/sfwidgets/script.xlb
T
Jean-Pierre Ledure ca1dca4f1d ScriptForge (ContextMenu) new RemoveAllItems() method
The contextmenu service handles the context
menus stored in a document. So far, it
provided only the AddItem() method to add
new items at the bottom of the menu.

The new method allows to forget the preconfigured
menu and to replace it completely.

Example: associate next Sub with the
         on-right-click event of sheet 'Sheet1'
         => The custom menu appears when
            right-clicking in column C, otherwise
            normal behaviour
  Sub OnRightClick1(Optional XRange)
       ' Xrange is a com.sun.star.table.XCellRange
  Dim calc, menu, bColumn
  Set calc = CreateScriptService("Calc", ThisComponent)
  Set menu = calc.ContextMenus("cell")
  menu.RemoveAllItems()
  bColumn =  ( Len(calc.Intersect("Sheet1.$C:$C", _
             XRange.AbsoluteName)) > 0 )
  If bColumn Then
      menu.AddItem("A", Script := "vnd.sun.star.script:...&location=document")
      ...
  End If
  menu.Activate(bColumn)
  End Sub

The function is available both for Basic and Python user scripts.
The user documentation will have to be reviewed.

Change-Id: I84ee8724bf99c37397a19d729133cc4686a63980
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180520
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2025-01-21 09:30:57 +01:00

12 lines
688 B
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="SFWidgets" library:readonly="false" library:passwordprotected="false">
<library:element library:name="SF_ToolbarButton"/>
<library:element library:name="SF_Toolbar"/>
<library:element library:name="SF_MenuListener"/>
<library:element library:name="SF_Menu"/>
<library:element library:name="SF_ContextMenu"/>
<library:element library:name="SF_PopupMenu"/>
<library:element library:name="SF_Register"/>
<library:element library:name="__License"/>
</library:library>