blueeagle wrote:
> Hi all,
> 
> I have some troubles with the display of the new added menu item.
> For examlpe, I want to add a menu item "WebHtml" in the file menu. I modified 
> the 
>  correlative files and added the necessary codes in those files. The result 
> is: The 
>  place of new menu item is there but the "WebHtml" is missing.
>  The files and added codes that I modified are as follows:
Hi LiuTao,


>  -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>  svx\inc\globlmn_tmpl.hrc
>   
>  #define ITEM_FILE_OPENDOC \
>      Identifier = SID_OPENDOC ; \
>   Command = ".uno:Open" ; \
>      HelpID = SID_OPENDOC ; \
>      Text [ de ] = "��~ffnen..." ; \
>      Text [ en-US ] = "~Open..." ;\
>   Text [ x-comment ] = " "; \
>   
>  /*******************************************added begin*/ \
>  #define ITEM_FILE_WEBHTML \
>      Identifier = SID_WEBHTML ; \
>   Command = ".uno:WebHtml" ; \
>      HelpID = SID_WEBHTML ; \
>      Text [ de ] = "Web ~Html..." ; \
>      Text [ en-US ] = "Web ~Html..."; \
>   Text [ x-comment ] = "Preview Web ~Html..." ; \
>  /*******************************************added end*/ \
This is only needed for context menus. The menu bars are now specified
by xml files.
>   
>  #define ITEM_FILE_AUTOPILOT \
>      MenuItem\
>      {\
>          Identifier = SID_AUTOPILOTMENU ; \
>    Command = ".uno:AutoPilotMenu" ; \
>          HelpID = SID_AUTOPILOTMENU ; \
>          Text [ de ] = "~Assistent" ; \
>          Text [ en-US ] = "A~utoPilot" ; \
>    Text [ x-comment ] = " ";\
>   };
>  -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>  sfx2\inc\sfxsids.hrc
>  #define SID_MAIL_SEND                       (SID_SFX_START + 364)
>  #define SID_WEBHTML       (SID_SFX_START + 393)/*added*/
>  #define SID_MAIL_FILE                       (SID_SFX_START + 365)
>  -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Looks good.
>  sfx2\sdi\sfx.sdi
>  SfxObjectItem Open SID_OPENDOC
>  (SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName 
>  SID_FILTER_NAME,SfxStringItem OpenFlags SID_OPTIONS,SfxStringItem Password 
>  SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxInt16Item 
> Version 
>  SID_VERSION,SfxStringItem Referer SID_REFERER)
>  [
>   /* flags: */
>   AutoUpdate = FALSE,
>   Cachable = Cachable,
>   FastCall = FALSE,
>   HasCoreId = FALSE,
>   HasDialog = TRUE,
>   ReadOnlyDoc = TRUE,
>   Toggle = FALSE,
>   Container = TRUE,
>   RecordAbsolute = FALSE,
>   RecordPerSet;
>   Asynchron;
>   
>   /* config: */
>   AccelConfig = TRUE,
>   MenuConfig = TRUE,
>   StatusBarConfig = FALSE,
>   ToolBoxConfig = TRUE,
>   GroupId = GID_APPLICATION;
>  ]
>  /******************************************/add begin
>  SfxObjectItem WebHtml SID_WEBHTML
>  ()
>  [
>   /* flags: */
>   AutoUpdate = FALSE,
>   Cachable = Cachable,
>   FastCall = FALSE,
>   HasCoreId = FALSE,
>   HasDialog = TRUE,
>   ReadOnlyDoc = TRUE,
>   Toggle = FALSE,
>   Container = TRUE,
>   RecordAbsolute = FALSE,
>   RecordPerSet;
>   Asynchron;
>   
>   /* config: */
>   AccelConfig = TRUE,
>   MenuConfig = TRUE,
>   StatusBarConfig = FALSE,
>   ToolBoxConfig = TRUE,
>   GroupId = GID_FORMAT;
>  ]
May be the GroupId could be GID_APPLICATION.
>  /*********************************************/added end
>  //--------------------------------------------------------------------------
>  SfxObjectItem OpenHyperlink SID_OPENHYPERLINK
>  (SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName 
>  SID_FILTER_NAME,SfxStringItem OpenFlags SID_OPTIONS,SfxStringItem Password 
>  SID_PASSWORD,SfxStringItem FilterOptions D_FILE_FILTEROPTIONS,SfxInt16Item 
> Version 
>  SID_VERSION,SfxStringItem Referer SID_REFERER)
>  [
>      /* flags: */
>      AutoUpdate = FALSE,
>      Cachable = Cachable,
>      FastCall = FALSE,
>      HasCoreId = FALSE,
>      HasDialog = TRUE,
>      ReadOnlyDoc = TRUE,
>      Toggle = FALSE,
>      Container = TRUE,
>      RecordAbsolute = FALSE,
>      RecordPerSet;
>      Asynchron;
>   
>      /* config: */
>      AccelConfig = FALSE,
>      MenuConfig = FALSE,
>      StatusBarConfig = FALSE,
>      ToolBoxConfig = FALSE,
>      GroupId = GID_APPLICATION;
>  -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>   
>  sw\uiconfig\swriter\menubar\menubar.xml
>  <menu:menuitem menu:id=".uno:Reload"/>
>     <menu:menuitem menu:id=".uno:VersionDialog"/>
>     <!-- added begin -->
>     <menu:menuitem menu:id=".uno:WebHtml" />
>     <!--added end -->
>     <menu:menuseparator/>
That's ok.

The xml file alone doesn't specify the language dependent text for the
menu entry. The are configuration files which define these language
dependent labels. Look at the "officecfg" project. It contains the
folder "registry/data/org/openoffice/Office/UI". There are two different
configuration files involved:
GenericCommands.xcu
<App-Module-Name>Commands.xcu

If you add a command which is used by more than one application you
should add a node to the GenericCommands.xcu file. Otherwise to the
corresponding module dependent Commands.xcu file.
The key for the configuration entry must be the command name which, in
your case, is "WebHtml". So you need something like:

<node oor:name="UserInterface">
 <node oor:name="Commands">
  ...
  <node oor:name=".uno:WebHtml" oor:op="replace">
   <prop oor:name="Label" oor:type="xs:string">
    <value xml:lang="en-US">!Put the text here!</value>
   </prop>
  </node>
  ...
 </node>
</node>

You can find more information on how to add a new function to the
user-interface here:
http://specs.openoffice.org/ui_in_general/api/ProgrammaticControlOfMenuAndToolbarItems.sxw

Regards,
Carsten

-- 
Carsten Driesner (cd) - Project Lead OpenOffice.org Framework
Framework wiki: http://wiki.services.openoffice.org/wiki/Framework
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to