[Solved] Packaging right-click context menus in an extension

Discussions about using 3rd party extension with OpenOffice.org

[Solved] Packaging right-click context menus in an extension

Postby dbm » Mon Feb 03, 2020 11:37 pm

I am developing a programming tool extension on the Windows 10 version of Libre Office 6.3 and have run into a difficulty packaging the macros and related menu/toolbar/context menu components into an extension. While I have been able to add menu and tool bar changes using ADDON.XCU xml, specifications, I have been unable to find a method of packaging my context menu changes.

Below is an example of the type of context menu change I would like to package, highlighted and circled:

Image


Ideally, I would like to include these changes as something similar to the specification used for adding and merging menus and toolbars in the extension package.

Alternatively, I would be open to building these menus dynamically, using a basic macro, if someone can point me to appropriate documentation and/or examples.

Does anyone know of documentation, posts or examples explaining how to accomplish this using either of these techniques, or can suggest another method of modifying context menus from an extension.

Thanks in advance – david.
Last edited by Hagar Delest on Fri Feb 07, 2020 11:00 pm, edited 1 time in total.
Reason: tagged solved
Libreoffice 6.3 on Windows 10
dbm
 
Posts: 3
Joined: Mon Feb 03, 2020 6:16 pm

Re: Packaging right-click context menus in an extension

Postby JeJe » Tue Feb 04, 2020 12:16 am

Don't know about extensions but for information on intercepting context menus:

https://wiki.openoffice.org/wiki/User:A ... ementation

viewtopic.php?f=45&t=81436

An alternative to modifying the context menu might be to use a mouse handler and have a menu that pops up when you right click with a modifier key (eg shift + right click).

Edit: Or a keyboard shortcut of course.
Last edited by JeJe on Tue Feb 04, 2020 12:26 am, edited 1 time in total.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1567
Joined: Wed Mar 09, 2016 2:40 pm

Re: Packaging right-click context menus in an extension

Postby Villeroy » Tue Feb 04, 2020 12:24 am

I would think that LibreOffice can do that because LibreOffice lets you customize context menus just like main menues and toolbars.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29915
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Packaging right-click context menus in an extension

Postby JeJe » Tue Feb 04, 2020 12:36 am

Another advance from LibreOffice! Someone asked a similar question about a year ago but got no answer

https://ask.libreoffice.org/en/question ... extension/

LibreOffice 6.2 API Documentation would be the place to look maybe:

https://api.libreoffice.org/

Edit:

Java ContextMenuInterceptor example:

https://api.libreoffice.org/examples/De ... mples.html
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1567
Joined: Wed Mar 09, 2016 2:40 pm

Re: Packaging right-click context menus in an extension

Postby dbm » Tue Feb 04, 2020 2:10 am

Thanks for the responses.

I will investigate the context menu strategy.

It does not appear that anyone answered the similar question posed last year, but given the ability to package tool bars and menus, one would think that the ability to package context menus would be offered as well. Does anyone have any information indicating that this can not be done with the current release of the software?
Libreoffice 6.3 on Windows 10
dbm
 
Posts: 3
Joined: Mon Feb 03, 2020 6:16 pm

Re: Packaging right-click context menus in an extension

Postby Villeroy » Tue Feb 04, 2020 12:20 pm

https://libreoffice.org/ is the successor to OpenOffice. SInce many years OpenOffice is no longer under active development.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29915
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Packaging right-click context menus in an extension

Postby dbm » Fri Feb 07, 2020 9:43 pm

I did find an acceptable solution for this issue and while it works in my case, it may not be universally applicable.

In LibreOffice 6.3.4.2, I was able to package all of the menu, toolbar and context menu customizations in a template which I then load when initializing the code for my extension. The only issue that I encountered was, what I think is a bug in the toolbar customization where icons are corrupted when scoping the toolbar customs at the document level. It is possible to replace the corrupted icon file with a sound file and repack the template though it adds a bunch of steps to the packaging process. Alternatively, tool changes and menu changes could be packaged using the traditional methods while just packaging the context menus in a template.

While this works in my case, I do not expect that this solution will work for everyone - it would be nice to have a documented way of packaging context menu changes and also notebook bar changes.
Libreoffice 6.3 on Windows 10
dbm
 
Posts: 3
Joined: Mon Feb 03, 2020 6:16 pm

Re: [Solved] Packaging right-click context menus in an exten

Postby JeJe » Fri Feb 07, 2020 11:28 pm

LibreOffice has three different icon sizes for toolbars so to be compatible with all options your customization should provide icons for each... just mentioning that in case it might have something to do with your icon problems.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1567
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Packaging right-click context menus in an exten

Postby DavidBo » Sun Feb 21, 2021 3:40 pm

Great you have solved it, but I don't understand how you did it.
How could you design a context menu entry? shown in your picture.
Next what do mean by template? What kind of file are you working with?
Apache Open Office 4.1.9 Windows 10
DavidBo
 
Posts: 27
Joined: Thu Mar 12, 2009 3:57 pm

Re: [Solved] Packaging right-click context menus in an exten

Postby Villeroy » Sun Feb 21, 2021 3:46 pm

If you don't know what a template is, you never used any office suite of the past 30 years.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29915
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Packaging right-click context menus in an exten

Postby DavidBo » Sun Feb 21, 2021 3:54 pm

I don't understand how menus are related to templates unless we are talking about special templates used for extensions.
Another possibility is that he has added the menu entries through the tool-> customize functionality.
I have not seen how you can add a right click context menu in an addons.xcu. So if he has done that I would like to know.
Apache Open Office 4.1.9 Windows 10
DavidBo
 
Posts: 27
Joined: Thu Mar 12, 2009 3:57 pm

Re: [Solved] Packaging right-click context menus in an exten

Postby RoryOF » Sun Feb 21, 2021 4:13 pm

Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32703
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] Packaging right-click context menus in an exten

Postby Villeroy » Sun Feb 21, 2021 5:20 pm

DavidBo wrote:I don't understand how menus are related to templates unless we are talking about special templates used for extensions.
Another possibility is that he has added the menu entries through the tool-> customize functionality.
I have not seen how you can add a right click context menu in an addons.xcu. So if he has done that I would like to know.

Like MS Office, OpenOffice allows you to customize toolbars and menu entries specific to a document class (template). Just declare that you want to save the customization in the current document instead of the global settings.
Keyboard shortcuts would be too confusing, therefore you can't define shortcuts for specific documents. LibreOffice added the ability to customize context menues. This way you create a template with or without macro code that serves a special purpose (reporting, data entry, form letters etc.) with menues and toolbars adjusted to the specific task. This is sooo 90ies but 1% of office users may be still able to utilize stuff like this.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29915
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Extensions

Who is online

Users browsing this forum: No registered users and 0 guests