I have created an extension. After installation of that extension I recommend to create a toolbar button through Tools Menu Customization. But it is difficult for some people to create that button. So my question is, Is there anyway by which after installation of the extension a button will be automatically created to run that extension.
I suggest you to study another extensions written is same progamming language as your one was written.
@KamilLanda
Extension Code.odt (39.7 KB)
The macro code is attached herewith. What should be done so that Menu and submenu be automatically created after installation of extension.
In @elmau example is the node <node oor:name="Submenu">
and you need to insert next subnodes to this node. You will change the lines in subnodes <node oor:name="m0" oor:op="replace">
for example to oor:name="m0.m0"
, oor:name="m0.m1"
etc.
And for macro running there will be macro:/// in URL subnode.
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///MyNewExtension.Module1.StartMacro</value>
</prop>
Wiki with details about the file Addons.xcu.
Or link to one shorter Czech article OpenOffice.cz | Ako vytvoriĹĄ rozšĂrenie 8 – Volanie programov z menu that has the details about the file Addons.xcu, I believe the e-translator will be sufficient. You can press Ctrl+F to find Submenu and it will highlight Submenu “nodes” in XML structure.
I can see the regular expressions like this in your code…
[:digit:]{1,4}|^[ABCD]- Exh. [:digit:]{1,4},
[:digit:]{1,4}|^[ABCD] Exh. [:digit:]{1,4},
[:digit:]{1,4}|^[ABCD] Exh.[:digit:]{1,4},
[:digit:]{1,4}|^([ABCD]) Exh. [:digit:]{1,4},
[:digit:]{1,4}|^\([ABCD]\)Exh.[:digit:]{1,4},
[:digit:]{1,4}|^[ABCD] Exh [:digit:]{1,4},
Let’s assume you can have optional dot followed by space(s) after the string “Exh”. Then use .?\s*
I guess you can replace the regex mentioned above with this one?
[:digit:]{1,4}|^\(?[ABCD]\)?\-?\s*Exh\-?\.?\s*\d{1,4}
You can also assign the keyboard shortcut to one of your main macros. Please check the source code of this extension…
You must add a file called Addons.xcu in the root of your extension. In the following example we add a menu and a new toolbar with a command button.
<?xml version="1.0" encoding="utf-8"?>
<oor:component-data xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oor="http://openoffice.org/2001/registry" oor:name="Addons" oor:package="org.openoffice.Office">
<node oor:name="AddonUI">
<node oor:name="OfficeMenuBar">
<node oor:name="org.myfirstextension" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en">My Extension</value>
<value xml:lang="es">Mi ExtensiĂłn</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<node oor:name="Submenu">
<node oor:name="m0" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en">Option 1</value>
<value xml:lang="es">OpciĂłn 1</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.myfirstextension?option1</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value>%origin%/images/icon</value>
</prop>
</node>
</node>
</node>
</node>
<node oor:name="OfficeToolBar">
<node oor:name="org.myfirstextension" oor:op="replace">
<node oor:name="t0" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en">Option 1</value>
<value xml:lang="es">OpciĂłn 1</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.myfirstextension?option1</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value>%origin%/images/icon</value>
</prop>
</node>
</node>
</node>
</node>
</oor:component-data>