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...)

转载于:https://www.cnblogs.com/zhyryxz/archive/2010/03/24/1693854.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值