Search code examples
libreoffice-calclibreoffice-basic

What is the easiest way to duplicate an OO / LO macro dialog?


In OpenOffice / LibreOffice Calc, what is the easiest way to duplicate a macro dialog?

I've got one built already for a particular task, but I need another that is only slightly different, and don't want to have to build it from scratch. I tried editing the ODS as a ZIP, and duplicating the dialog resource, but when I re-opened the file, I got a warning that it was corrupt, and the duplicate was automatically removed.


Solution

  • Say you have an .ods file with an embedded dialog called Dialog1. Unzip the .ods file and make the following changes:

    • Copy and paste Dialog1.xml to Dialog2.xml
    • Edit Dialog2.xml and change the ID to dlg:id="Dialog2"
    • Edit dialog-lb.xml and add <library:element library:name="Dialog2"/>
    • Edit META-INF/manifest.xml and add <manifest:file-entry manifest:full-path="Dialogs/Standard/Dialog2.xml" manifest:media-type="text/xml"/>

    Now zip the file back up, making sure to zip it where META-INF is the folder at the first level. There should be no more warnings about a corrupt file.

    If the dialogs have been localized for more than one language, then all string IDs have to be unique. For example &amp;241.DlgSpellSearch.Title would need to be changed to &amp;242.DlgSpellReplace.Title and the corresponding entries in DialogStrings_es_ES.properties (Spanish-Spain locale as an example) need to match.