diff options
author | Rafael Lima <rafael.palma.lima@gmail.com> | 2023-11-26 17:02:19 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2023-11-28 15:45:43 +0100 |
commit | 751a65e5be60a35ae970b3a66b2038d90ea580e4 (patch) | |
tree | 8ed91924867e2918a846bb67a601223a0853fb45 | |
parent | df97eb056605af65df8f2b3935285b27b27c21ad (diff) |
Document SF Toolbar and ToolbarButton services
Change-Id: I57df3b88660198d2432ff73ef1b37025e1b893a3
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/159902
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Rafael Lima <rafael.palma.lima@gmail.com>
-rw-r--r-- | AllLangHelp_sbasic.mk | 2 | ||||
-rw-r--r-- | source/auxiliary/sbasic.tree | 2 | ||||
-rw-r--r-- | source/text/sbasic/shared/03/lib_ScriptForge.xhp | 14 | ||||
-rw-r--r-- | source/text/sbasic/shared/03/sf_toc.xhp | 69 | ||||
-rw-r--r-- | source/text/sbasic/shared/03/sf_toolbar.xhp | 261 | ||||
-rw-r--r-- | source/text/sbasic/shared/03/sf_toolbarbutton.xhp | 345 |
6 files changed, 690 insertions, 3 deletions
diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk index 8b7719e2b3..d32336e7a3 100644 --- a/AllLangHelp_sbasic.mk +++ b/AllLangHelp_sbasic.mk @@ -109,6 +109,8 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\ helpcontent2/source/text/sbasic/shared/03/sf_textstream \ helpcontent2/source/text/sbasic/shared/03/sf_timer \ helpcontent2/source/text/sbasic/shared/03/sf_toc \ + helpcontent2/source/text/sbasic/shared/03/sf_toolbar \ + helpcontent2/source/text/sbasic/shared/03/sf_toolbarbutton \ helpcontent2/source/text/sbasic/shared/03/sf_ui \ helpcontent2/source/text/sbasic/shared/03/sf_unittest \ helpcontent2/source/text/sbasic/shared/03/sf_writer \ diff --git a/source/auxiliary/sbasic.tree b/source/auxiliary/sbasic.tree index 8371609dc9..9d02967080 100644 --- a/source/auxiliary/sbasic.tree +++ b/source/auxiliary/sbasic.tree @@ -376,6 +376,8 @@ <topic id="sbasic/text/sbasic/shared/03/sf_string.xhp">String service</topic> <topic id="sbasic/text/sbasic/shared/03/sf_textstream.xhp">TextStream service</topic> <topic id="sbasic/text/sbasic/shared/03/sf_timer.xhp">Timer service</topic> + <topic id="sbasic/text/sbasic/shared/03/sf_toolbar.xhp">Toolbar service</topic> + <topic id="sbasic/text/sbasic/shared/03/sf_toolbarbutton.xhp">ToolbarButton service</topic> <topic id="sbasic/text/sbasic/shared/03/sf_ui.xhp">UI service</topic> <topic id="sbasic/text/sbasic/shared/03/sf_unittest.xhp">UnitTest service</topic> <topic id="sbasic/text/sbasic/shared/03/sf_writer.xhp">Writer service</topic> diff --git a/source/text/sbasic/shared/03/lib_ScriptForge.xhp b/source/text/sbasic/shared/03/lib_ScriptForge.xhp index af306b184a..7b978e89a5 100644 --- a/source/text/sbasic/shared/03/lib_ScriptForge.xhp +++ b/source/text/sbasic/shared/03/lib_ScriptForge.xhp @@ -123,13 +123,15 @@ <tablecell> <paragraph id="par_id441613885558931" localize="false" role="tablecontent"> <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#FormControl">FormControl</link><br/> - <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Menu">Menu</link><br/><br/> + <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Menu">Menu</link><br/> + <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#PopupMenu">PopupMenu</link><br/> </paragraph> </tablecell> <tablecell> <paragraph id="par_id701643305576632" localize="false" role="tablecontent"> - <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#PopupMenu">PopupMenu</link><br/> - <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#UI">UI</link><br/><br/> + <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Toolbar">Toolbar</link><br/> + <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#ToolbarButton">ToolbarButton</link><br/> + <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#UI">UI</link><br/> </paragraph> </tablecell> </tablerow> @@ -237,6 +239,12 @@ <section id="Timer"> <embed href="text/sbasic/shared/03/sf_timer.xhp#abstract"/> </section> + <section id="Toolbar"> + <embed href="text/sbasic/shared/03/sf_toolbar.xhp#abstract"/> + </section> + <section id="ToolbarButton"> + <embed href="text/sbasic/shared/03/sf_toolbarbutton.xhp#abstract"/> + </section> <section id="UI"> <embed href="text/sbasic/shared/03/sf_ui.xhp#abstract"/> </section> diff --git a/source/text/sbasic/shared/03/sf_toc.xhp b/source/text/sbasic/shared/03/sf_toc.xhp index 849cb5829e..8255b37e30 100644 --- a/source/text/sbasic/shared/03/sf_toc.xhp +++ b/source/text/sbasic/shared/03/sf_toc.xhp @@ -925,6 +925,75 @@ </table> </section> + <h2 id="hd_id1016711992036103"><literal>ScriptForge</literal>.<literal>Toolbar</literal> service</h2> + <embed href="text/sbasic/shared/03/sf_toolbar.xhp#methods_toc"/> + <section id="SF_Toolbar_properties"> + <table id="tab_id901611086021125"> + <tablerow> + <tablecell colspan="3"> + <paragraph id="par_id651606205603658" role="tablehead">List of Properties in the Toolbar Service</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id761611032873522" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">BuiltIn</link><br/> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">Docked</link><br/> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">HasGlobalScope</link><br/> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id14161108680254" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">Name</link><br/> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">ResourceURL</link><br/><br/> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id761611086895413" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">Visible</link><br/> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#properties_toc">XUIElement</link><br/><br/> + </paragraph> + </tablecell> + </tablerow> + </table> + </section> + + <h2 id="hd_id1016711992054103"><literal>ScriptForge</literal>.<literal>ToolbarButton</literal> service</h2> + <embed href="text/sbasic/shared/03/sf_toolbarbutton.xhp#methods_toc"/> + <section id="SF_ToolbarButton_properties"> + <table id="tab_id901611080961125"> + <tablerow> + <tablecell colspan="3"> + <paragraph id="par_id651635105603658" role="tablehead">List of Properties in the ToolbarButton Service</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id761611025873522" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Caption</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Height</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Index</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">OnClick</link><br/> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id14161101710254" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Parent</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">TipText</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Visible</link><br/><br/> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id761611033695413" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Width</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">X</link><br/> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#properties_toc">Y</link><br/><br/> + </paragraph> + </tablecell> + </tablerow> + </table> + </section> + <h2 id="hd_id1016711992512950"><literal>ScriptForge</literal>.<literal>UI</literal> service</h2> <embed href="text/sbasic/shared/03/sf_ui.xhp#methods_toc"/> <section id="SF_UI_properties"> diff --git a/source/text/sbasic/shared/03/sf_toolbar.xhp b/source/text/sbasic/shared/03/sf_toolbar.xhp new file mode 100644 index 0000000000..a5e19d6707 --- /dev/null +++ b/source/text/sbasic/shared/03/sf_toolbar.xhp @@ -0,0 +1,261 @@ +<?xml version="1.0" encoding="UTF-8"?> +<helpdocument version="1.0"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> + +<meta> + <topic id="SF_Toolbar" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">SFWidgets.Toolbar service</title> + <filename>/text/sbasic/shared/03/sf_toolbar.xhp</filename> + </topic> +</meta> + +<body> + <section id="SFWidgets-sf_toolbar"> + <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id261582733781987"> + <bookmark_value>Toolbar service</bookmark_value> + </bookmark> + </section> + + <section id="abstract"> + <h1 id="hd_id731582733781114" xml-lang="en-US"><variable id="ToolbarService"><link href="text/sbasic/shared/03/sf_toolbar.xhp"><literal>SFWidgets</literal>.<literal>Toolbar</literal> service</link></variable></h1> + <paragraph role="paragraph" id="par_id571700837631557">The <literal>Toolbar</literal> service allows to retrieve information related to the toolbars available for a specific document window. With this service it is possible to:</paragraph> + <list type="unordered"> + <listitem> + <paragraph id="par_id891589189452545" role="listitem">Toggle the visibility of specific toolbars.</paragraph> + </listitem> + <listitem> + <paragraph id="par_id811589189463041" role="listitem">Access information about the buttons available in each toolbar.</paragraph> + </listitem> + </list> + </section> + <paragraph role="paragraph" id="par_id141700851608146">Each %PRODUCTNAME application has its own set of available toolbars. This service handles both built-in and custom toolbars.</paragraph> + <note id="par_id181700851890467">The status bar and the menu bar are not considered toolbars in the context of this service.</note> + + <h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2> + <paragraph role="paragraph" id="par_id141609955500101">Before using the <literal>Toolbar</literal> service the <literal>ScriptForge</literal> library needs to be loaded or imported:</paragraph> + <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#importLibs"/> + + <paragraph role="paragraph" id="par_id411700851985942">The <literal>Toolbar</literal> service is invoked using the <literal>Toolbars</literal> method, which is available in the following services: <literal>Calc</literal>, <literal>Datasheet</literal>, <literal>Document</literal>, <literal>FormDocument</literal> and <literal>Writer</literal>.</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/> + <paragraph role="paragraph" id="par_id771700853155061">The example below gets an <literal>Array</literal> with the names of the toolbars available in the current document.</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id561700853223079">oDoc = CreateScriptService("Document", ThisComponent)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id821700853223579">arrToolbars = oDoc.Toolbars()</paragraph> + <paragraph role="bascode" localize="false" id="bas_id751700853223764">MsgBox SF_String.Represent(arrToolbars)</paragraph> + </bascode> + <tip id="par_id961700853354817">Use the <literal>Toolbars</literal> method without arguments to retrieve an array with available toolbar names.</tip> + <paragraph role="paragraph" id="par_id171700853415555">The example below toggles the visibility of the <menuitem>Standard</menuitem> toolbar:</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id141700853757638">oDoc = CreateScriptService("Document", ThisComponent)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id651700853757894">toolbar = oDoc.Toolbars("standardbar")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id117008537580631">toolbar.Visible = Not toolbar.Visible</paragraph> + </bascode> + + <embed href="text/sbasic/shared/00000003.xhp#In_Python"/> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id171701008968310">bas = CreateScriptService("Basic")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id621701008969941">doc = CreateScriptService("Document", bas.ThisComponent)</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id441701008970173">arr_toolbars = doc.Toolbars()</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id617010091805031">bas.MsgBox(repr(toolbars))</paragraph> + </pycode> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id221701009213403">bas = CreateScriptService("Basic")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id481701009213644">doc = CreateScriptService("Document", bas.ThisComponent)</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id801701009213818">toolbar = doc.Toolbars("standardbar")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id381701009320054">toolbar.Visible = not toolbar.Visible</paragraph> + </pycode> + + <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id81611339709014"> + <bookmark_value>Toolbar service;BuiltIn property</bookmark_value> + <bookmark_value>Toolbar service;Docked property</bookmark_value> + <bookmark_value>Toolbar service;HasGlobalScope property</bookmark_value> + <bookmark_value>Toolbar service;Name property</bookmark_value> + <bookmark_value>Toolbar service;ResourceURL property</bookmark_value> + <bookmark_value>Toolbar service;Visible property</bookmark_value> + <bookmark_value>Toolbar service;XUIElement property</bookmark_value> + </bookmark> + <h2 id="hd_id351582885195476" xml-lang="en-US">Properties</h2> + <section id="properties_toc"> + <table id="tab_id971582885195582"> + <tablerow> + <tablecell> + <paragraph id="par_id41582885195836" role="tablehead">Name</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id31582885195372" role="tablehead">Readonly</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id31582885195238" role="tablehead">Type</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id931582885195131" role="tablehead">Description</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id7715828856553" role="tablecontent" localize="false">BuiltIn</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655779" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655525" role="tablecontent" localize="false">Boolean</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655885" role="tablecontent">Returns <literal>True</literal> when the toolbar is part of the set of standard toolbars shipped with %PRODUCTNAME.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655313" role="tablecontent" localize="false">Docked</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655669" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885623525" role="tablecontent" localize="false">Boolean</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885657885" role="tablecontent">Returns <literal>True</literal> when the toolbar is active in the window and docked.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655394" role="tablecontent" localize="false">HasGlobalScope</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655710" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885651142" role="tablecontent" localize="false">Boolean</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655102" role="tablecontent">Returns <literal>True</literal> when the toolbar is available in all documents of the same type.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655332" role="tablecontent" localize="false">Name</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655205" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655787" role="tablecontent" localize="false">String</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655369" role="tablecontent">Returns the name of the toolbar.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655349" role="tablecontent" localize="false">ResourceURL</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655966" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885605065" role="tablecontent" localize="false">String</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655812" role="tablecontent">Returns the resource URL of the toolbar, in the form <literal>private:toolbar/toolbar_name</literal>.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655387" role="tablecontent" localize="false">Visible</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655212" role="tablecontent">No</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655373" role="tablecontent" localize="false">Boolean</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655344" role="tablecontent">Returns <literal>True</literal> when the toolbar is active and visible in the document window.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655311" role="tablecontent" localize="false">XUIElement</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655788" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655522" role="tablecontent" localize="false">UNO Object</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655062" role="tablecontent">Returns the <link href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1ui_1_1XUIElement.html">com.sun.star.ui.XUIElement</link> UNO object that represents the toolbar.</paragraph> + </tablecell> + </tablerow> + </table> + </section> + + <section id="methods_toc"> + <table id="tab_id901611086279902"> + <tablerow> + <tablecell colspan="3"><paragraph id="par_id651606319520519" role="tablehead">List of Methods in the Toolbar Service</paragraph></tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id761611086279902" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbar.xhp#ToolbarButtons">ToolbarButtons</link><br/> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id141611086279902" role="tablecontent" localize="false"> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id761611086279903" role="tablecontent" localize="false"> + </paragraph> + </tablecell> + </tablerow> + </table> + </section> + + <section id="ToolbarButtons"> + <comment> ToolbarButtons ------------------------------------------------------------------------------------- </comment> + <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id92158919969883"> + <bookmark_value>Toolbar service;ToolbarButtons</bookmark_value> + </bookmark> + <h2 id="hd_id201589199698251" localize="false">ToolbarButtons</h2> + <paragraph role="paragraph" id="par_id93158919969864">Returns an <literal>Array</literal> containing the names of all toolbar buttons when called without arguments.</paragraph> + <paragraph role="paragraph" id="par_id421611148353046">Provide the name of a toolbar button as argument to obtain a <literal>ToolbarButton</literal> service instance.</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/> + <paragraph role="paragraph" localize="false" id="par_id181622827609276"> + <input>svc.ToolbarButtons(opt buttonname: str): any</input> + </paragraph> + <embed href="text/sbasic/shared/00000003.xhp#functparameters"/> + <paragraph role="paragraph" id="par_id381701012526415"><emph>buttonname</emph>: The name of a toolbar button in the current toolbar.</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#functexample"/> + <paragraph role="paragraph" id="par_id601611148017930">The example below returns the command executed when the button <menuitem>New</menuitem> is clicked in the <menuitem>Standard</menuitem> toolbar:</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id421701012864607">oToolbar = oDoc.Toolbars("standardbar")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id771701013457279">oToolbarButton = oToolbar.ToolbarButtons("New")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id841701013457456">MsgBox oToolbarButton.OnClick</paragraph> + </bascode> + <embed href="text/sbasic/shared/00000003.xhp#In_Python"/> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id821701012860544">toolbar = doc.Toolbars("standardbar")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id321701013509953">toolbar_button = toolbar.ToolbarButtons("New")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id981701013510153">bas.MsgBox(toolbar_button.OnClick)</paragraph> + </pycode> + <note id="par_id531701012694220">Inactive toolbars do not have buttons. Therefore, calling the <literal>ToolbarButtons</literal> method will make the toolbar visible.</note> + </section> + + <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/> + <section id="relatedtopics"> + <embed href="text/sbasic/shared/03/sf_toolbarbutton.xhp#ToolbarButtonService"/> + </section> +</body> +</helpdocument> diff --git a/source/text/sbasic/shared/03/sf_toolbarbutton.xhp b/source/text/sbasic/shared/03/sf_toolbarbutton.xhp new file mode 100644 index 0000000000..e43c0147cd --- /dev/null +++ b/source/text/sbasic/shared/03/sf_toolbarbutton.xhp @@ -0,0 +1,345 @@ +<?xml version="1.0" encoding="UTF-8"?> +<helpdocument version="1.0"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> + +<meta> + <topic id="SF_ToolbarButton" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">SFWidgets.ToolbarButton service</title> + <filename>/text/sbasic/shared/03/sf_toolbarbutton.xhp</filename> + </topic> +</meta> + +<body> + <section id="SFWidgets-sf_toolbarbutton"> + <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id261582733781987"> + <bookmark_value>ToolbarButton service</bookmark_value> + </bookmark> + </section> + + <section id="abstract"> + <h1 id="hd_id731582733781114"><variable id="ToolbarButtonService"><link href="text/sbasic/shared/03/sf_toolbarbutton.xhp"><literal>SFWidgets</literal>.<literal>ToolbarButton</literal> service</link></variable></h1> + <paragraph role="paragraph" id="par_id571700837631557">The <literal>ToolbarButton</literal> service allows to retrieve information related to the toolbar buttons available in a given toolbar. With this service it is possible to:</paragraph> + <list type="unordered"> + <listitem> + <paragraph id="par_id891589189452545" role="listitem">Toggle the visibility of toolbar elements.</paragraph> + </listitem> + <listitem> + <paragraph id="par_id811589189463041" role="listitem">Execute the command associated with a given toolbar button.</paragraph> + </listitem> + </list> + </section> + + <h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2> + <paragraph role="paragraph" id="par_id141609955500101">Before using the <literal>ToolbarButton</literal> service the <literal>ScriptForge</literal> library needs to be loaded or imported:</paragraph> + <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#importLibs"/> + + <paragraph role="paragraph" id="par_id411700851985942">The <literal>ToolbarButton</literal> service is invoked using the <literal>ToolbarButtons</literal> method from the <literal>Toolbar</literal> service.</paragraph> + + <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/> + <paragraph role="paragraph" id="par_id771700853155061">The example below retrieves the names of all buttons available in the <menuitem>Standard</menuitem> toolbar.</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id561700853223079">oDoc = CreateScriptService("Document", ThisComponent)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id821700853223579">oToolbar = oDoc.Toolbars("standardbar")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id201701020721930">arrToolbarButtons = oToolbar.ToolbarButtons()</paragraph> + <paragraph role="bascode" localize="false" id="bas_id751700853223764">MsgBox SF_String.Represent(arrToolbarButtons)</paragraph> + </bascode> + <tip id="par_id961700853354817">Use the <literal>ToolbarButtons</literal> method without arguments to retrieve an array with all available toolbar button names.</tip> + <paragraph role="paragraph" id="par_id171700853415555">The example below toggles the visibility of the <menuitem>Print</menuitem> button in the <menuitem>Standard</menuitem> toolbar:</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id141700853757638">oDoc = CreateScriptService("Document", ThisComponent)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id651700853757894">oToolbar = oDoc.Toolbars("standardbar")</paragraph> + <paragraph role="bascode" id="bas_id117008537580631">oToolbarButton = oToolbar.ToolbarButtons("Print")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id161701021081876">oToolbarButton.Visible = Not oToolbarButton.Visible</paragraph> + </bascode> + <tip id="par_id981701021131646">The button name passed as argument to the <literal>ToolbarButtons</literal> method is the localized button name defined in the <menuitem>Tools - Customize - Toolbars</menuitem> dialog.</tip> + <note id="par_id531701012694220">Inactive toolbars do not have buttons. Therefore, calling the <literal>ToolbarButtons</literal> method will make the toolbar visible.</note> + + <embed href="text/sbasic/shared/00000003.xhp#In_Python"/> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id171701008968310">bas = CreateScriptService("Basic")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id621701008969941">doc = CreateScriptService("Document", bas.ThisComponent)</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id441701008970173">toolbar = doc.Toolbars("standardbar")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id891701021459391">arr_toolbar_buttons = toolbar.ToolbarButtons()</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id617010091805031">bas.MsgBox(repr(arr_toolbar_buttons))</paragraph> + </pycode> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id221701009213403">bas = CreateScriptService("Basic")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id481701009213644">doc = CreateScriptService("Document", bas.ThisComponent)</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id801701009213818">toolbar = doc.Toolbars("standardbar")</paragraph> + <paragraph role="pycode" id="pyc_id351701021554314">toolbar_button = toolbar.ToolbarButtons("Print")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id381701009320054">toolbar_button.Visible = not toolbar_button.Visible</paragraph> + </pycode> + + <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id81611339709014"> + <bookmark_value>ToolbarButton service;Caption property</bookmark_value> + <bookmark_value>ToolbarButton service;Height property</bookmark_value> + <bookmark_value>ToolbarButton service;Index property</bookmark_value> + <bookmark_value>ToolbarButton service;OnClick property</bookmark_value> + <bookmark_value>ToolbarButton service;Parent property</bookmark_value> + <bookmark_value>ToolbarButton service;TipText property</bookmark_value> + <bookmark_value>ToolbarButton service;Visible property</bookmark_value> + <bookmark_value>ToolbarButton service;Width property</bookmark_value> + <bookmark_value>ToolbarButton service;X property</bookmark_value> + <bookmark_value>ToolbarButton service;Y property</bookmark_value> + </bookmark> + <h2 id="hd_id351582885195476" xml-lang="en-US">Properties</h2> + <section id="properties_toc"> + <table id="tab_id971582885195582"> + <tablerow> + <tablecell> + <paragraph id="par_id41582885195836" role="tablehead">Name</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id31582885195372" role="tablehead">Readonly</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id31582885195238" role="tablehead">Type</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id931582885195131" role="tablehead">Description</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id7715828856553" role="tablecontent" localize="false">Caption</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655779" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655525" role="tablecontent" localize="false">String</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655885" role="tablecontent">Returns the name of the button.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655313" role="tablecontent" localize="false">Height</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655669" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885623525" role="tablecontent" localize="false">Long</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885657885" role="tablecontent">Returns the height of the button, in pixels.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655394" role="tablecontent" localize="false">Index</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655710" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885651142" role="tablecontent" localize="false">Long</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655102" role="tablecontent">Returns the index of the button in its parent toolbar.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655332" role="tablecontent" localize="false">OnClick</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655205" role="tablecontent">No</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655787" role="tablecontent" localize="false">String</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655369" role="tablecontent">The UNO command or script executed when the button is pressed. Read the Wiki page <link href="https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification">Scripting Framework URI Specification</link> to learn more on how to define a URI string.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655349" role="tablecontent" localize="false">Parent</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655966" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885605065" role="tablecontent"><literal>Toolbar</literal> service</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655812" role="tablecontent">Returns a <literal>Toolbar</literal> service instance corresponding to the parent toolbar of the current toolbar button.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655387" role="tablecontent" localize="false">TipText</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655212" role="tablecontent">No</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655373" role="tablecontent" localize="false">String</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655344" role="tablecontent">Specifies the tooltip text shown when the user hovers over the toolbar button.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885655311" role="tablecontent" localize="false">Visible</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885655788" role="tablecontent">No</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885655522" role="tablecontent" localize="false">Boolean</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885655062" role="tablecontent">Specifies whether the toolbar button is visible or not.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885652661" role="tablecontent" localize="false">Width</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885651058" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885659542" role="tablecontent" localize="false">Long</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885653342" role="tablecontent">Returns the width of the button, in pixels.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885604761" role="tablecontent" localize="false">X</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885636258" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885699442" role="tablecontent" localize="false">Long</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885641742" role="tablecontent">Returns the X (horizontal) coordinate of the top-left corner of the button, in pixels.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id771582885604161" role="tablecontent" localize="false">Y</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id861582885603158" role="tablecontent">Yes</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id271582885603642" role="tablecontent" localize="false">Long</paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id581582885609942" role="tablecontent">Returns the Y (vertical) coordinate of the top-left corner of the button, in pixels.</paragraph> + </tablecell> + </tablerow> + </table> + </section> + + <h2 id="hd_id501701094012462">Use of <literal>ToolbarButton</literal> alongside the <literal>PopupMenu</literal> service</h2> + <paragraph role="paragraph" id="par_id731701094077095">A common use case of the properties <literal>X</literal> and <literal>Y</literal> described above is to open a popup menu in the position where the toolbar button is located.</paragraph> + <paragraph role="paragraph" id="par_id761701094138529">Suppose you create the script below and associate it with a button named "My Button" in the <literal>standardbar</literal>. When it is clicked, a popup menu will be shown with 3 options for the user to select.</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id871701094239003">Sub OpenPopupMenu()</paragraph> + <paragraph role="bascode" localize="false" id="bas_id991701094239228"> GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id100170109439419"> oDoc = CreateScriptService("Document", ThisComponent)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id811701094239628"> oToolbar = oDoc.Toolbars("standardbar")</paragraph> + <paragraph role="bascode" id="bas_id971701094239852"> oButton = oToolbar.ToolbarButtons("My Button")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id741701094240084"> oPopup = CreateScriptService("SFWidgets.PopupMenu", , oButton.X, oButton.Y + oButton.Height)</paragraph> + <paragraph role="bascode" id="bas_id521701094240308"> oPopup.AddItem("Item A", "A")</paragraph> + <paragraph role="bascode" id="bas_id201701094240523"> oPopup.AddItem("Item B", "B")</paragraph> + <paragraph role="bascode" id="bas_id961701094240764"> oPopup.AddItem("Item C", "C")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id381701094240979"> strResponse = oPopup.Execute(False)</paragraph> + <paragraph role="bascode" id="bas_id531701094241275"> MsgBox "Your choice: " & strResponse</paragraph> + <paragraph role="bascode" localize="false" id="bas_id481701094241629">End Sub</paragraph> + </bascode> + <embed href="text/sbasic/shared/00000003.xhp#In_Python"/> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id651701094979197">def open_popup_menu(args=None):</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id481701094979605"> bas = CreateScriptService("Basic")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id921701094979429"> doc = CreateScriptService("Document", bas.ThisComponent)</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id471701094979804"> toolbar = doc.Toolbars("standardbar")</paragraph> + <paragraph role="pycode" id="pyc_id231701094980046"> toolbutton = toolbar.ToolbarButtons("My Button")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id921701094980261"> popup = CreateScriptService("PopupMenu", None, toolbutton.X, toolbutton.Y + toolbutton.Height)</paragraph> + <paragraph role="pycode" id="pyc_id521701094980469"> popup.AddItem("Item A", "A")</paragraph> + <paragraph role="pycode" id="pyc_id841701094980684"> popup.AddItem("Item B", "B")</paragraph> + <paragraph role="pycode" id="pyc_id441701094980908"> popup.AddItem("Item C", "C")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id501701094981133"> response = popup.Execute(False)</paragraph> + <paragraph role="pycode" id="pyc_id241701094981357"> bas.MsgBox(f"Your choice: {response}")</paragraph> + </pycode> + + <section id="methods_toc"> + <table id="tab_id901611086279902"> + <tablerow> + <tablecell colspan="3"><paragraph id="par_id651606319520519" role="tablehead">List of Methods in the ToolbarButton Service</paragraph></tablecell> + </tablerow> + <tablerow> + <tablecell> + <paragraph id="par_id761611086279902" role="tablecontent" localize="false"> + <link href="text/sbasic/shared/03/sf_toolbarbutton.xhp#Execute">Execute</link><br/> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id141611086279902" role="tablecontent" localize="false"> + </paragraph> + </tablecell> + <tablecell> + <paragraph id="par_id761611086279903" role="tablecontent" localize="false"> + </paragraph> + </tablecell> + </tablerow> + </table> + </section> + + <section id="Execute"> + <comment> Execute -------------------------------------------------------------------------------------------- </comment> + <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id92158919969883"> + <bookmark_value>ToolbarButton service;Execute</bookmark_value> + </bookmark> + <h2 id="hd_id201589199698251" localize="false">Execute</h2> + <paragraph role="paragraph" id="par_id93158919969864">Executes the command or script associated with the toolbar button.</paragraph> + <paragraph role="paragraph" id="par_id191701023292148">This method returns the value returned by the command or script executed.</paragraph> + <tip id="par_id731701023160247">Use the <literal>OnClick</literal> property to determine the command or script that shall be executed. If the command/script does not return any value, then <literal>Null</literal> is returned.</tip> + <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/> + <paragraph role="paragraph" localize="false" id="par_id181622827609276"> + <input>svc.Execute(): any</input> + </paragraph> + <embed href="text/sbasic/shared/00000003.xhp#functexample"/> + <paragraph role="paragraph" id="par_id601611148017930">The example below executes the <menuitem>Print</menuitem> button from the <menuitem>Standard</menuitem> toolbar:</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id421701012864607">oDoc = CreateScriptService("Document", ThisComponent)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id771701013457279">oToolbar = oDoc.Toolbars("standardbar")</paragraph> + <paragraph role="bascode" id="bas_id841701013457456">oToolbarButton = oToolbar.ToolbarButtons("Print")</paragraph> + <paragraph role="bascode" localize="false" id="bas_id661701023616206">oToolbarButton.Execute()</paragraph> + </bascode> + <embed href="text/sbasic/shared/00000003.xhp#In_Python"/> + <pycode> + <paragraph role="pycode" localize="false" id="pyc_id221701002583403">bas = CreateScriptService("Basic")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id481701009203644">doc = CreateScriptService("Document", bas.ThisComponent)</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id801701009244418">toolbar = doc.Toolbars("standardbar")</paragraph> + <paragraph role="pycode" id="pyc_id351701020654314">toolbar_button = toolbar.ToolbarButtons("Print")</paragraph> + <paragraph role="pycode" localize="false" id="pyc_id381701009352154">toolbar_button.Execute()</paragraph> + </pycode> + </section> + + <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/> + <section id="relatedtopics"> + <embed href="text/sbasic/shared/03/sf_toolbar.xhp#ToolbarService"/> + </section> +</body> +</helpdocument> |