Page 1 of 1

[Solved] Add item in File / Wizards menu

PostPosted: Wed Dec 09, 2020 6:32 pm
by Mr.Dandy
Hello folks,

Try to build an OXT who add its menu item under File / Wizards
Capture.PNG

I use an Addons.xcu like this:
Code: Select all   Expand viewCollapse view
<?xml version='1.0' encoding='UTF-8'?>
<oor:component-data
xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
oor:name="Addons"
oor:package="org.openoffice.Office">
<node oor:name="AddonUI">
<node oor:name="OfficeMenuBarMerging">
      <node oor:name="foo-menu" oor:op="replace">
      <node oor:name="S1" oor:op="replace">
        <prop oor:name="MergePoint">
          <value>.uno:PickList\.uno:AutoPilotMenu</value>
        </prop>
        <prop oor:name="MergeCommand">
         <value>AddAfter</value>
        </prop>
        <prop oor:name="MergeFallback">
         <value>AddPath</value>
        </prop>
        <prop oor:name="MergeContext" oor:type="xs:string">
          <value>com.sun.star.frame.StartModule</value>
        </prop>
        <node oor:name="MenuItems">
         <node oor:name="M1" oor:op="replace">
              <prop oor:name="URL" oor:type="xs:string">
            <value>vnd.sun.star.script:QRcodeJS.QRcodeJS.Main?language=Basic&amp;location=application</value>
         </prop>
         <prop oor:name="Title" oor:type="xs:string">
            <value>Foo wizard...</value>
         </prop>
         <prop oor:name="Target" oor:type="xs:string">
            <value>_self</value>
         </prop>
         </node>
        </node>
      </node>
      </node>
    </node>
</node>
</oor:component-data>

But this creates item below Wizards and not in sub menu :(

Thanks to advice me

Re: Add item in File / Wizards menu

PostPosted: Thu Dec 10, 2020 9:05 pm
by Villeroy
IMHO, all this UI rubbish is not worth the pain. However, you can try to manipulate the menu manually via Tools>Customize... Just add some dummy pointing to anything. Then have a look which configuration file changed in which ways.

Re: Add item in File / Wizards menu

PostPosted: Fri Dec 11, 2020 11:27 am
by Mr.Dandy
Sorry, this menu is not present in the dialog to be customize:
Capture.PNG


I guess that exist an xml or xcu to give this list.
But I have not find it.

Re: Add item in File / Wizards menu

PostPosted: Fri Dec 11, 2020 11:52 am
by RoryOF
I have not time to look in depth at this, but I know that the MRI extension uses an addons.xcu to place its entries onto /Tools /Addons menu. If you open the MRI-1.3.4.oxt with an archive manager you should be able to extract addons.xcu and examine its structure.

Re: Add item in File / Wizards menu

PostPosted: Fri Dec 11, 2020 12:14 pm
by Villeroy
Tools>AddOns is what you get when you define entries below <node oor:name="AddonMenu"> (kind of "default menu").

Re: Add item in File / Wizards menu

PostPosted: Sun Dec 13, 2020 3:06 pm
by Mr.Dandy
Wizards items menu can be listed with ConfigurationProvider.

Another approach with:
Code: Select all   Expand viewCollapse view
Sub Main
   Dim oCfg as Object, oList as Object, oElem as Object
   Dim aNode(0) As new com.sun.star.beans.PropertyValue
   Dim sProvider$, sAccess$, sNode$, sName$
   sName = "Dandy"
   sProvider = "com.sun.star.configuration.ConfigurationProvider"
   sAccess = "com.sun.star.configuration.ConfigurationUpdateAccess"
   sNode = "/org.openoffice.Office.Common/Menus/Wizard/" 'org.openoffice.Office.Common"
   oCfg = createUnoService(sProvider)
   aNode(0).name= "nodepath"
   aNode(0).Value = sNode
   oList = oCfg.createInstanceWithArguments(sAccess, aNode())
   
   oItem = oList.getElementNames()
   For i = 0 to UBound(oItem)
      If oItem(i) = sName then exit sub
   Next i
   oElem = oList.createInstance()

End sub

But it crash :(

Re: Add item in File / Wizards menu

PostPosted: Sun Dec 13, 2020 3:15 pm
by RoryOF
With the crash do you get any error message?

Re: Add item in File / Wizards menu

PostPosted: Sat Dec 19, 2020 4:48 pm
by Mr.Dandy
No error, just crash at the last line.
Unable to create instance.

You can try the script above to see this.

Re: Add item in File / Wizards menu

PostPosted: Sat Dec 19, 2020 5:19 pm
by RoryOF
If you expand your last line it gives

oElem = oCfg.createInstanceWithArguments(sAccess, aNode()).createInstance()

Does that make sense?

Re: Add item in File / Wizards menu

PostPosted: Sun Dec 20, 2020 12:04 pm
by Mr.Dandy
RoryOF wrote:Does that make sense?

I'm try to get this menu like this code snippet:
viewtopic.php?f=21&t=7128&p=33605

Do you see another way?

Re: Add item in File / Wizards menu

PostPosted: Sun Dec 20, 2020 12:50 pm
by JeJe
Your "Another approach with:" code doesn't crash for me on 4.1.6 on Windows 8

Edit: but "Dandy" won't be found. Having you tried exploring with MRI on olist without running the end bit?

Re: Add item in File / Wizards menu

PostPosted: Sun Dec 20, 2020 6:10 pm
by Mr.Dandy
JeJe wrote:Having you tried exploring with MRI on olist without running the end bit?

Yes, you can execute MRI on oList and run its createInstance method.

But if you try to see its properties: this crashes.

Re: Add item in File / Wizards menu

PostPosted: Sun Dec 20, 2020 11:14 pm
by JeJe
Yeah, and its a nasty crash, I have to go into Window's Task Manager and clear OO before I can load it again.

There's another menu example here:

https://wiki.openoffice.org/wiki/API/Sa ... rites-Menu

Re: Add item in File / Wizards menu

PostPosted: Fri Dec 25, 2020 12:04 pm
by Mr.Dandy
JeJe wrote:There's another menu example here:

This works!

Thanks

Re: [Solved] Add item in File / Wizards menu

PostPosted: Fri Dec 25, 2020 12:13 pm
by Villeroy
Holy shit.
I mean: Merry Christmas!

But this is far too complicated. And why can't this be inserted with an entry in the XML configuration?