Bug 97448 - Create a helper to generate an Addons.xcu for an extension
Summary: Create a helper to generate an Addons.xcu for an extension
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Devansh Varshney
URL:
Whiteboard:
Keywords: difficultyMedium, easyHack, skillPython, skillScript
Depends on:
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2016-01-30 11:05 UTC by Björn Michaelsen
Modified: 2024-04-22 08:43 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Michaelsen 2016-01-30 11:05:19 UTC
The AddOns.xcu file in an extension describes what menus or toolbars an extension adds/modifies/removes. Well-commented examples for it can be found in the sdk-examples repository at:

 https://gerrit.libreoffice.org/gitweb?p=sdk-examples.git;a=summary

e.g. the TuesdayPython/Addons.xcu.

The XML format of these is pretty verbose and cumbersome -- and handwriting these can be errorprone. It would be nice to have script (in Python or somesuch) wizard that can generate these.
Comment 1 Robinson Tryon (qubit) 2016-02-18 14:52:01 UTC Comment hidden (obsolete)
Comment 2 Siddhartha Gairola 2017-01-03 12:37:36 UTC
Hi, I would like to work on this bug.
Comment 3 jani 2017-02-09 06:51:58 UTC Comment hidden (obsolete)
Comment 4 jani 2017-05-14 07:43:26 UTC Comment hidden (obsolete)
Comment 5 Xisco Faulí 2017-06-14 02:22:24 UTC Comment hidden (obsolete)
Comment 6 Xisco Faulí 2017-07-15 02:31:39 UTC Comment hidden (obsolete)
Comment 7 Siddhartha Gairola 2017-07-15 07:14:53 UTC
Hi, sorry for the delayed response. Yes, I would like to continue working on this. But was a bit preoccupied lately. If anyone wants to continue, you are welcome to do so.
Thank you.
Comment 8 Xisco Faulí 2017-08-15 02:23:35 UTC Comment hidden (obsolete)
Comment 9 Xisco Faulí 2017-09-15 15:27:49 UTC Comment hidden (obsolete)
Comment 10 Xisco Faulí 2017-09-16 02:04:46 UTC Comment hidden (obsolete)
Comment 11 Xisco Faulí 2017-09-17 02:04:38 UTC Comment hidden (obsolete)
Comment 12 codetronaut 2020-02-14 14:41:02 UTC
Hello, I would like to work on this Bug.
Comment 13 codetronaut 2020-02-17 11:34:02 UTC
Please provide me little guidance to proceed.
thank you.
Comment 14 Buovjaga 2020-02-17 12:05:55 UTC
(In reply to codetronaut from comment #13)
> Please provide me little guidance to proceed.
> thank you.

Where are you stuck at the moment? What did you try and research so far?
Comment 15 codetronaut 2020-02-17 15:01:08 UTC
one thing, can I take reference to this:https://blog.mdda.net/oss/2011/10/07/python-libreoffice

also, I saw .xcu is somewhat like .xml so should I create python script for the same?
Comment 16 Buovjaga 2020-02-17 15:53:55 UTC
(In reply to codetronaut from comment #15)
> one thing, can I take reference to
> this:https://blog.mdda.net/oss/2011/10/07/python-libreoffice
> 
> also, I saw .xcu is somewhat like .xml so should I create python script for
> the same?

The .xcu files contain XML. Björn's proposal was to create a wizard-like script to help with their generation.

I assume the idea was to simply have the script ask questions on the command line about what menu or toolbar items should be modified. In other words, I don't believe the idea was to create a LibreOffice *extension*.
Comment 17 codetronaut 2020-02-17 20:56:27 UTC
okay, so the task is to create a wizard-like script which first generates the logs(i.e adds/modifies/removes) of extension in .xcu (i.e in XML) and then converts it to some human-readable format. Right?
Comment 18 codetronaut 2020-02-17 20:59:07 UTC
my bad *not logs I mean description of.
Comment 19 Buovjaga 2020-02-18 07:53:12 UTC
(In reply to codetronaut from comment #17)
> okay, so the task is to create a wizard-like script which first generates
> the logs(i.e adds/modifies/removes) of extension in .xcu (i.e in XML) and
> then converts it to some human-readable format. Right?

Right, except skip the last part, because Björn did not mention any conversion to a human-readable format.

The TuesdayPython Addons.xcu refers to this document, which is helpful: https://wiki.openoffice.org/wiki/Framework/Article/Addon_Menu_Toolbar_Merging
Comment 20 codetronaut 2020-02-18 18:13:26 UTC
From where should I take reference for the generation of logs/descriptions I tried to implement a script for the generation of .xml file, i.e from where should this script will take data from.  

Please bear with me I am a little beginner.
Comment 21 Buovjaga 2020-02-18 19:08:53 UTC
(In reply to codetronaut from comment #20)
> From where should I take reference for the generation of logs/descriptions I
> tried to implement a script for the generation of .xml file, i.e from where
> should this script will take data from.  
> 
> Please bear with me I am a little beginner.

Björn would be the best one to comment, but from what I understand:

1. Have template fragments based on what is listed at https://wiki.openoffice.org/wiki/Framework/Article/Addon_Menu_Toolbar_Merging
2. Take the data to fill the template fragments from command line, asking questions from the script user
Comment 22 codetronaut 2020-02-19 09:49:47 UTC
okay, please have a look if I am going right,

https://pastebin.com/pcSijHwx

what I did is created a script that forms an XML file and later I will be giving the user to enter according to the particular bug.
Comment 23 Xisco Faulí 2020-07-22 15:10:46 UTC
Dear codetronaut,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assign it back to yourself if you're still working on this.
Comment 24 Devansh Varshney 2024-02-23 08:00:10 UTC
python3 addon_console.py.py --addon-name org.openoffice.Office \
                      --merge-type menu \
                      --merge-name org.libreoffice.TuesdayPrinter.menus \
                      --merge-point .uno:PickList\.uno:Print \
                      --merge-command Replace \
                      --merge-fallback AddAfter \
                      --output-dir /path/to/output_directory


/path/to/output_directory with the desired output directory where you want to save the Addons.xcu file, if not given then in the end prompt will ask you -

> Save Addons.xcu file to desktop or specify a path to custom directory? (d/c): d


For the toolbar merge, you would execute a similar command, adjusting the --merge-type, --merge-name, --merge-point, --merge-command, and --merge-fallback parameters accordingly.


Dummy Example i/p -

Input Parameters:
-----------------
Addon Name:

For Menu Merge:
Merge Name: org.libreoffice.TuesdayPrinter.menus
Merge Point: .uno:PickList\.uno:Print
Merge Command: Replace
Merge Fallback: AddAfter
Item Name: submenu1
Title: Print on Tuesdays
URL: service:org.libreoffice.TuesdayPrinter?printontuesday
Image Identifier: %origin%/images/printtuesday

For Toolbar Merge:
Merge Name: org.libreoffice.TuesdayPrinter.standardbar
Merge Point: .uno:PrintDefault
Merge Command: Replace
Merge Fallback: AddAfter
Item Name: button1
Title: Print on Tuesdays
URL: service:org.libreoffice.TuesdayPrinter?printontuesday
Image Identifier: %origin%/images/printtuesday


> ========================================================================
> o/p from terminal -

python3 addon_console.py --addon-name MyAddon --merge-type menu --merge-name MyMerge --merge-point .uno:FileMenu --merge-command AddBefore --merge-fallback AddAfter

Select the application module context for the merge instruction:
1. Writer
2. Spreadsheet
3. Presentation
4. Draw
5. Formula
6. Chart
7. Bibliography
Enter your choice (1-7): 1
Enter item name (or 'done' to finish): OfficeMenuBarMerging
Enter item title: Print on Tuesdays
Enter item URL: service:org.libreoffice.TuesdayPrinter?printontuesday
Enter path to item image (optional): %origin%/images/printtuesday
Error: Invalid path: Path does not exist
Enter item name (or 'done' to finish): org.libreoffice.TuesdayPrinter.menus
Enter item title: MergePoint
Enter item URL: uno:PickList\.uno:Print
Enter path to item image (optional):
Enter item name (or 'done' to finish): done
Are you done entering items? (yes/no): yes
Save Addons.xcu file to desktop or specify a path to custom directory? (d/c): d