https://bugs.freedesktop.org/show_bug.cgi?id=67366
Priority: medium
Bug ID: 67366
Assignee: [email protected]
Summary: ContextMenu ActionTrigger do not work
Severity: normal
Classification: Unclassified
OS: All
Reporter: [email protected]
Hardware: Other
Status: UNCONFIRMED
Version: 4.1.0.4 release
Component: Writer
Product: LibreOffice
I wrote an extension which shows information in the context menu of Writer.
It doesn’t work anymore with LO 4.1. This is a regression.
I implemented my own XContextMenuInterceptor with notifyContextMenuExecute
which create new entries to the context menu, then I return the proper value:
com.sun.star.ui.ContextMenuInterceptorAction.EXECUTE_MODIFIED
But nothing happens. The extension works properly until it returns the value.
Here is the simplified code (in Python) :
import uno
import unohelper
import re
from com.sun.star.task import XJob
from com.sun.star.task import XJobExecutor
from com.sun.star.ui import XContextMenuInterceptor
from com.sun.star.beans import PropertyValue
class MyContextMenuInterceptor (XContextMenuInterceptor, unohelper.Base):
def __init__ (self, ctx):
self.ctx = ctx
def notifyContextMenuExecute (self, xEvent):
try:
xContextMenu = xEvent.ActionTriggerContainer
if (xContextMenu):
i = xContextMenu.Count
xMenuItem =
xContextMenu.createInstance("com.sun.star.ui.ActionTrigger")
xMenuItem.setPropertyValue("Text", u"MY INFORMATION")
xContextMenu.insertByIndex(i, xMenuItem)
print("it goes and works until there")
# The controller should execute the modified context menu and
stop notifying other interceptors.
return
uno.getConstantByName("com.sun.star.ui.ContextMenuInterceptorAction.EXECUTE_MODIFIED")
except:
traceback.print_exc()
return
uno.getConstantByName("com.sun.star.ui.ContextMenuInterceptorAction.IGNORED")
class JobExecutor (XJob, unohelper.Base):
def __init__ (self, ctx):
self.ctx = ctx
def execute (self, args):
if not args:
return
# what event?
bCorrectEvent = False
for arg in args:
if arg.Name == "Environment":
for v in arg.Value:
if v.Name == "EnvType" and v.Value == "DOCUMENTEVENT":
bCorrectEvent = True
elif v.Name == "EventName":
pass
# check is correct event
#print "Event: %s" % v.Value
elif v.Name == "Model":
model = v.Value
if bCorrectEvent:
if model.supportsService("com.sun.star.text.TextDocument"):
xController = model.getCurrentController()
if xController:
xController.registerContextMenuInterceptor(MyContextMenuInterceptor(self.ctx))
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(JobExecutor,
"grammalecte.ContextMenuHandler", ("grammalecte.ContextMenuHandler",),)
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs