Add command menuitem
Motive: adding a new command as a menuitem 'Clear Cell Content' and merging it with a present
command menuitem 'Clear Format' of 'FormatMenu' into one popup menuitem of 'EditMenu'.
Steps need to do as follow:
1. add a new command/define everything for the new command
1.1 define id
#define FN_CLEAR_CELL_CONTENT ...
1.2 define status
FN_CLEAR_CELL_CONTENT //status(final|play)
[
ExecMethod = Execute;
StateMethod = NoState;
]
1.3 define flags and config
SfxVoidItem ClearCellContent FN_CLEAR_CELL_CONTENT
()
[
/*flags:*/
HasDialog=TRUE,
AutoUpdate=FALSE,
....
/*config:*/
AccelConfig=TRUE,
MenuConfig=TRUE,
...
]
1.4 define slotinfo
SfxSlotInfo FN_CLEAR_CELL_CONTENT
{
Slotname[en-US]="...";
};
1.5 define operation for the command
case FN_CLEAR_CELL_CONTENT
{
//opertation to do
}
1.6 add a menuitem for the command
<menu:menuitem menu:id=".uno:ClearCellContent">
1.7 add a node for the command in ***.xcu
<node oor:name=".uno:ClearCellContent" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Clear Cell Content</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
spotted-The 'Label' property of node specifies its dispaly name in en-US. But for GenericalCommands.xcu
and CalcCommands.xcu, which one could be the proper file to add it in? The answer is it depends. They decide a menuitem can be used/showed in multip module or only one module. If you add it in the latter one but still use this it as a menuitem for another application, there will be one menuitem diaplayed but with blank name.
2. Merge two command menuitems into one popup menuitem
->Find the present menuitem definition in menubar.xml
<menu:menuitem menu:id=".uno:FormatMenu">
<menu:menupopup>
<menu:menuitem menu:id=".uno:ClearFormat"/>
<munu:menuseparator/>
...
</menu:menupopup>
</menu>
->add a node in .xcu file for your new popup menu
<node oor:name=".uno:Clear" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Clear</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
spotted-all nodes here are commands,but Only those you defined the operation for them are excutable.For the others you can click but no response.
->difine the popup menu as a menuitem of 'Edit' menu
<menu:menuitem menu:id=".uno:EditMenu">
<menu:menupopup>
<menu:menu menu:id=".uno:Clear">
<menu:menuitem menu:id=".uno:ClearCellContent"/>
<menu:menuitem menu:id=".uno:ClearFormat"/>
</menu:menu>
...
</menu:menupopup>
</menu>
spotted- here it specified 'Clear' was a popup menuitem and you will find a triangle direction following.
My doubts:
According to .xcs, there are two sets repectively naming 'Commands' and 'Popups'. Does it seriously distinguish them? Like my new popup menuitem, Should i add it into 'Popups' sets? (In fact, i added it into 'Commands' sets but it works well...)