UnoService in PyUNO for keyboard shortcuts in extensions: JobExecutor never called.

classic Classic list List threaded Threaded
5 messages Options
jan-3 jan-3
Reply | Threaded
Open this post in threaded view
|

UnoService in PyUNO for keyboard shortcuts in extensions: JobExecutor never called.

Hello,

I wrote an extension (https://github.com/jdittrich/Office-QDA-TagTree/tree/keyboardShortcut) using PyUNO. I would like to give some functions of it a keyboard shortcut.
However, I can't get the JobExecutor Interface called.

It would be of great help, if a person experienced with (Py) UNO could have a look at my approach. I assume it to be a simple misunderstanding of an PyUNO concept (which I could not find out though I read the documentation I found)

WHAT I DID:
1. The define-in-"Accelerators.xcu"-part [1]  worked (The shortcut shows up in the Keyboard-shortcut customization dialog).
3. I implemented an XJobExecutor Interface [2]
2. I created an uno service via  g_ImplementationHelper.addImplementation, using the class from 2.  [3] this service should be called by the shortcut

PROBLEM: the jobExecutor is never executed when I press the keyboard shortcut. Despite doing a step-by step debugging and turned on debug messages, I was unable to locate a problem.

POSSIBLE PROBLEM SOURCES:
* I was unable to find the docuementation for g_ImplementationHelper.addImplementation e.g. if it takes a class or an instance. I tried with both (the inked example is an instance), non worked.


LINKS TO RELEVANT CODE PARTS:
[1] https://github.com/jdittrich/Office-QDA-TagTree/blob/keyboardShortcut/Accelerators.xcu#L10
[2] https://github.com/jdittrich/Office-QDA-TagTree/blob/keyboardShortcut/src/qdacodehelper.py#L215
[3] https://github.com/jdittrich/Office-QDA-TagTree/blob/keyboardShortcut/src/qdacodehelper.py#L247


_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Miklos Vajna-4 Miklos Vajna-4
Reply | Threaded
Open this post in threaded view
|

Re: UnoService in PyUNO for keyboard shortcuts in extensions: JobExecutor never called.

Hi,

On Tue, Aug 08, 2017 at 09:21:36AM +0200, jan d <[hidden email]> wrote:
> POSSIBLE PROBLEM SOURCES:
> * I was unable to find the docuementation for
> g_ImplementationHelper.addImplementation e.g. if it takes a class or an
> instance. I tried with both (the inked example is an instance), non worked.

https://gerrit.libreoffice.org/gitweb?p=sdk-examples.git;a=blob;f=TuesdayPython/TuesdayPrinter.py;hb=HEAD#l61

I think this does something similar to your use-case, and there you can
see that addImplementation() takes a class, not an instance.

Regards,

Miklos

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (188 bytes) Download Attachment
jan-3 jan-3
Reply | Threaded
Open this post in threaded view
|

Re: UnoService in PyUNO for keyboard shortcuts in extensions: JobExecutor never called.

Hi Miklos, Hi List,

I did some changes and passed the class instead of the instance but it does not work either; looking at the print messages that I inserted it seems to be never initialized.
I'll try to step through the TuesdayPrinter.py and see if that gives me any insights; if you have any other ideas,I'd be happy to hear what else could be wrong.

Jan


On Tue, Aug 8, 2017 at 9:30 AM, Miklos Vajna <[hidden email]> wrote:
Hi,

On Tue, Aug 08, 2017 at 09:21:36AM +0200, jan d <[hidden email]> wrote:
> POSSIBLE PROBLEM SOURCES:
> * I was unable to find the docuementation for
> g_ImplementationHelper.addImplementation e.g. if it takes a class or an
> instance. I tried with both (the inked example is an instance), non worked.

https://gerrit.libreoffice.org/gitweb?p=sdk-examples.git;a=blob;f=TuesdayPython/TuesdayPrinter.py;hb=HEAD#l61

I think this does something similar to your use-case, and there you can
see that addImplementation() takes a class, not an instance.

Regards,

Miklos


_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
jan-3 jan-3
Reply | Threaded
Open this post in threaded view
|

Re: UnoService in PyUNO for keyboard shortcuts in extensions: JobExecutor never called.

Hello,

Just for documenting it for people who might try this in the future: I managed to create the UnoService and have it reaact to the shortcut.
It seems that services can only be created directly and in the scope of the file/import that is run: Having it created inside a function did not work, moving it out to the first level (in python this means: no indention) it works. If someone knows why that is the case, I'd be ahppy if we could add a sentence on it to the PyUno documentation or so.

Jan

On Fri, Aug 11, 2017 at 1:06 AM, jan d <[hidden email]> wrote:
Hi Miklos, Hi List,

I did some changes and passed the class instead of the instance but it does not work either; looking at the print messages that I inserted it seems to be never initialized.
I'll try to step through the TuesdayPrinter.py and see if that gives me any insights; if you have any other ideas,I'd be happy to hear what else could be wrong.

Jan


On Tue, Aug 8, 2017 at 9:30 AM, Miklos Vajna <[hidden email]> wrote:
Hi,

On Tue, Aug 08, 2017 at 09:21:36AM +0200, jan d <[hidden email]> wrote:
> POSSIBLE PROBLEM SOURCES:
> * I was unable to find the docuementation for
> g_ImplementationHelper.addImplementation e.g. if it takes a class or an
> instance. I tried with both (the inked example is an instance), non worked.

https://gerrit.libreoffice.org/gitweb?p=sdk-examples.git;a=blob;f=TuesdayPython/TuesdayPrinter.py;hb=HEAD#l61

I think this does something similar to your use-case, and there you can
see that addImplementation() takes a class, not an instance.

Regards,

Miklos



_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Miklos Vajna-4 Miklos Vajna-4
Reply | Threaded
Open this post in threaded view
|

Re: UnoService in PyUNO for keyboard shortcuts in extensions: JobExecutor never called.

On Sat, Aug 12, 2017 at 05:36:58AM +0200, jan d <[hidden email]> wrote:
> Just for documenting it for people who might try this in the future: I
> managed to create the UnoService and have it reaact to the shortcut.
> It seems that services can only be created directly and in the scope of the
> file/import that is run: Having it created inside a function did not work,
> moving it out to the first level (in python this means: no indention) it
> works. If someone knows why that is the case, I'd be ahppy if we could add
> a sentence on it to the PyUno documentation or so.

One reason might be that some services are specific to a document,
others are not. E.g. you can create a new text document as a global
object but when you create a new bookmark, you have to created it inside
a text document. That means it does matter what factory (global or the
one of an existing object) you use when you create new objects.

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (188 bytes) Download Attachment