I am trying to add an options dialog to my python extension for LibreOffice. My problem is that the dialog only displays if I remove the service name from the EventHandlerService property in my OptionsDialog.xcu file. I see someone had a similar problem in this thread:
viewtopic.php?f=20&t=19784
The poster's solution was: "Found the problem with my EventHandlerService: it was not registered as a RegistrationClass. I had to edit the nbproject/project-uno.properties so the registration.classname property also contained my DialogEventHandler."
But I'm not sure what this means or how to do this in Python.
Is there more to do besides this:
g_ImplementationHelper.addImplementation(
create_option_handler, "OptionsPageHandler", ("mytools.search.IncrementalSearch.OptionsPageHandler",),)
Thanks for any help you can provide!
[Solved] OptionsDialog not showing up for Python Extension
[Solved] OptionsDialog not showing up for Python Extension
Last edited by jmarch on Fri Jan 11, 2019 4:27 pm, edited 1 time in total.
LibreOffice 7.3 on Mac Monterey
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: OptionsDialog not showing up for Python Extension
Hi,
The "addImplementation" method should return : the handler class, the implementation name and a tuple of supported services. Something like, in your case:
In your "OptionsDialog.xcu" config file, the value of the "EventHandlerService" property should be the same implementation name :
Regards.
The "addImplementation" method should return : the handler class, the implementation name and a tuple of supported services. Something like, in your case:
Code: Select all
g_ImplementationHelper.addImplementation(
create_option_handler, "mytools.search.IncrementalSearch.OptionsPageHandler", ("mytools.search.IncrementalSearch.OptionsPageHandler",),)
Code: Select all
[...]
<prop oor:name="EventHandlerService">
<value>mytools.search.IncrementalSearch.OptionsPageHandler</value>
</prop>
[...]
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Re: OptionsDialog not showing up for Python Extension
Thanks for your reply. I reduced my extension to the bare minimum to narrow things down. Maybe I need to be doing something more in my Event Handler? This is what I have:
In OptionsDialog.xcu I have this:
The dialog will display if I remove abc.OptionsPageHander here:
Thanks for any help.
Code: Select all
import uno
import unohelper
from com.sun.star.awt import XActionListener, XContainerWindowEventHandler
from com.sun.star.lang import Locale, XServiceInfo, XInitialization
IMPLEMENTATION_NAME = "abc.OptionsPageHandler"
class OptionsPageHandler(unohelper.Base,
XContainerWindowEventHandler, XServiceInfo):
""" Option page implementation for incremental search. """
def __init__(self, ctx, args):
self.ctx = ctx
# XContainerWindowEventHandler
def getSupportedMethodNames(self):
return ("external_event", )
# XServiceInfo
def supportsService(self, name):
return (name == IMPLEMENTATION_NAME)
def getImplementationName(self):
return IMPLEMENTATION_NAME
def getSupportedServiceNames(self):
return (IMPLEMENTATION_NAME,)
def getServiceNames(self):
return (IMPLEMENTATION_NAME,)
def callHandlerMethod(self, window, ev, name):
# if name == "external_event":
# self.handle(window, ev)
# return True
# else:
# return False
return True
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(
OptionsPageHandler, IMPLEMENTATION_NAME, (IMPLEMENTATION_NAME,),)
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
<oor:component-data
xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
oor:package="org.openoffice.Office"
oor:name="OptionsDialog">
<node oor:name="Nodes">
<node oor:name="Writer" oor:op="fuse">
<node oor:name="Leaves">
<node oor:name="abc.OptionsPageHandler.nodes.Writer.ASTLeaf" oor:op="fuse">
<prop oor:name="Id">
<value>abc.OptionsPageHandler</value>
</prop>
<prop oor:name="Label">
<value xml:lang="en-US">ABC Settings</value>
</prop>
<prop oor:name="OptionsPage">
<value>%origin%/dialogs/ASTLeaf.xdl</value>
</prop>
<prop oor:name="EventHandlerService">
<value>abc.OptionsPageHandler</value>
</prop>
</node>
</node>
</node>
</node>
</oor:component-data>
Code: Select all
<prop oor:name="EventHandlerService">
<value></value>
</prop>
LibreOffice 7.3 on Mac Monterey
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: OptionsDialog not showing up for Python Extension
As written in the Developper's Guide, "the value of the property Id must be same as the extension identifier".
In your file, that value is the name of the dialog handler class. Is it actually the same as the extension identifier? If so, try renaming it...
In your file, that value is the name of the dialog handler class. Is it actually the same as the extension identifier? If so, try renaming it...
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Re: OptionsDialog not showing up for Python Extension
Thanks so much for your help. I'm still not sure precisely what the problem was, but it's working now. For others with this problem I found this example very helpful:
https://github.com/p--q/OptionsDialog
https://github.com/p--q/OptionsDialog
LibreOffice 7.3 on Mac Monterey
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: [Solved] OptionsDialog not showing up for Python Extensi
Thanks for the link !
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems