diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /helpcontent2/source/text/sbasic/guide | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream/1%7.0.4.tar.xz libreoffice-upstream/1%7.0.4.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
9 files changed, 791 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/guide/access2base.xhp b/helpcontent2/source/text/sbasic/guide/access2base.xhp new file mode 100644 index 000000000..0e76f09e6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/access2base.xhp @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?> + + + +<!-- +=================================================================================================================== +=== The Access2Base library is a part of the LibreOffice project. === +=== Full documentation is available on http://www.access2base.com === +=================================================================================================================== + + Access2Base is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Access2Base is free software; you can redistribute it and/or modify it under the terms of either (at your option): + + 1) 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/ . + + 2) The GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. If a copy of the LGPL was not + distributed with this file, see http://www.gnu.org/licenses/ . + --> + + +<helpdocument version="1.0"> +<meta> + <topic id="textsbasicsharedA2B001xml" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">Access2Base</title> + <filename>/text/sbasic/guide/access2base.xhp</filename> + </topic> + <history> + <created date="2013-11-01T00:00:00">Access2Base topic first insertion, by Jean-Pierre Ledure</created> + </history> +</meta> +<body> +<bookmark xml-lang="en-US" branch="index" id="bm_idA2B001"> +<bookmark_value>Access2Base</bookmark_value> +<bookmark_value>Microsoft Access; Access2Base</bookmark_value> +<bookmark_value>Access databases; run in Base</bookmark_value> +</bookmark> + <paragraph role="heading" id="hd_idA2B002" xml-lang="en-US" level="1">Access2Base</paragraph> + <paragraph role="heading" id="hd_idA2B003" xml-lang="en-US" level="2">What is Access2Base?</paragraph> + <paragraph role="paragraph" id="par_idA2B004" xml-lang="en-US">Access2Base is a LibreOffice Basic library of macros for (business or personal) application developers and advanced users. It is one of the libraries stored in "LibreOffice macros and dialogs".</paragraph> + <paragraph role="paragraph" id="par_idA2B005" xml-lang="en-US">The functionalities provided by the implemented macros are all directly inspired by Microsoft Access. The macros are callable mainly from a LibreOffice <emph>Base</emph> application, but also from <emph>any</emph> LibreOffice document (Writer, Calc, ...) where access to data stored in a database makes sense.</paragraph> + <paragraph role="paragraph" id="par_idA2B006" xml-lang="en-US">The API provided by Access2Base is intended to be more concise, intuitive and easy to learn than the standard UNO API (API = Application Programming Interface).</paragraph> + <paragraph role="warning" id="par_idA2B007" xml-lang="en-US"><emph>The library is documented online on </emph><link href="http://www.access2base.com" name="http://www.access2base.com"><emph>http://www.access2base.com</emph></link>.</paragraph> + <paragraph role="heading" id="hd_idA2B008" xml-lang="en-US" level="2">The implemented macros include:</paragraph> + <list type="ordered" format="1"> + <listitem> + <paragraph role="listitem" id="par_idA2B009" xml-lang="en-US">a simplified and extensible API for <emph>forms</emph>, <emph>dialogs</emph> and <emph>controls</emph> manipulations similar with the Microsoft Access object model,</paragraph> + </listitem> + <listitem> + <paragraph role="listitem" id="par_idA2B010" xml-lang="en-US">an API for database access with the <emph>table</emph>, <emph>query</emph>, <emph>recordset</emph> and <emph>field</emph> objects,</paragraph> + </listitem> + <listitem> + <paragraph role="listitem" id="par_idA2B011" xml-lang="en-US">a number of <emph>actions</emph> with a syntax identical to their corresponding Microsoft Access macros/actions,</paragraph> + </listitem> + <listitem> + <paragraph role="listitem" id="par_idA2B012" xml-lang="en-US">the <emph>DLookup</emph>, <emph>DSum</emph>, ... database functions,</paragraph> + </listitem> + <listitem> + <paragraph role="listitem" id="par_idA2B013" xml-lang="en-US">the support of the shortcut notations like <item type="literal">Forms!myForm!myControl</item></paragraph> + </listitem> + </list> + <paragraph role="paragraph" id="par_idA2B014" xml-lang="en-US">in addition</paragraph> + <list type="ordered" format="1" startwith="6"> + <listitem> + <paragraph role="listitem" id="par_idA2B015" xml-lang="en-US">a consistent errors and exceptions handler,</paragraph> + </listitem> + <listitem> + <paragraph role="listitem" id="par_idA2B016" xml-lang="en-US">facilities for programming form, dialog and control <emph>events</emph> and</paragraph> + </listitem> + <listitem> + <paragraph role="listitem" id="par_idA2B017" xml-lang="en-US">the support of both embedded forms and standalone (Writer) forms.</paragraph> + </listitem> + </list> + <paragraph role="heading" id="hd_idA2B018" xml-lang="en-US" level="2">Compare Access2Base with Microsoft Access VBA</paragraph> + <bascode> + <paragraph role="bascode" id="hd_idA2B019" xml-lang="en-US" localize="false">REM Open a form ... </paragraph> + <paragraph role="bascode" id="hd_idA2B020" xml-lang="en-US" localize="false"> OpenForm("myForm") </paragraph> + <paragraph role="bascode" id="hd_idA2B021" xml-lang="en-US" localize="false">REM Move a form to new left-top coordinates ... </paragraph> + <paragraph role="bascode" id="hd_idA2B022" xml-lang="en-US" localize="false"> Dim ofForm As Object ' In VBA => Dim ofForm As Form </paragraph> + <paragraph role="bascode" id="hd_idA2B023" xml-lang="en-US" localize="false"> Set ofForm = Forms("myForm") </paragraph> + <paragraph role="bascode" id="hd_idA2B024" xml-lang="en-US" localize="false"> ofForm.Move(100, 200) </paragraph> + <paragraph role="bascode" id="hd_idA2B025" xml-lang="en-US" localize="false">REM Get the value of a control ... </paragraph> + <paragraph role="bascode" id="hd_idA2B026" xml-lang="en-US" localize="false"> Dim ocControl As Object </paragraph> + <paragraph role="bascode" id="hd_idA2B027" xml-lang="en-US" localize="false"> ocControl = ofForm.Controls("myControl") </paragraph> + <paragraph role="bascode" id="hd_idA2B028" xml-lang="en-US" localize="false"> MsgBox ocControl.Value </paragraph> + <paragraph role="bascode" id="hd_idA2B029" xml-lang="en-US" localize="false">REM Hide a control ... </paragraph> + <paragraph role="bascode" id="hd_idA2B030" xml-lang="en-US" localize="false"> ocControl.Visible = False </paragraph> + <paragraph role="bascode" id="hd_idA2B031" xml-lang="en-US" localize="false">REM ... or alternatively ... </paragraph> + <paragraph role="bascode" id="hd_idA2B032" xml-lang="en-US" localize="false"> setValue("Forms!myForm!myControl.Visible", False) ' Shortcut notation </paragraph> + <paragraph role="bascode" id="hd_idA2B033" xml-lang="en-US" localize="false"> ' In VBA => Forms!myForm!myControl.Visible = False </paragraph> + </bascode> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/basic_2_python.xhp b/helpcontent2/source/text/sbasic/guide/basic_2_python.xhp new file mode 100644 index 000000000..4ea2d89f4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/basic_2_python.xhp @@ -0,0 +1,181 @@ +<?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="text/sbasic/guide/basic_2_python"> + <title id="tit" xml-lang="en-US">Basic to Python</title> + <filename>/text/sbasic/guide/basic_2_python.xhp</filename> + </topic> + </meta> + <body> + <bookmark branch="index" id="N0430"> + <bookmark_value>Basic;Calling Python</bookmark_value> + <bookmark_value>API;SimpleFileAccess</bookmark_value> + <bookmark_value>API;PathSettings</bookmark_value> + <bookmark_value>API;XScript</bookmark_value> + </bookmark> + <h1 id="hd_id811571848401485"><variable id="basic2python"><link href="text/sbasic/guide/basic_2_python.xhp" name="Basic Programming Examples">Calling Python Scripts from Basic</link></variable></h1> + <paragraph role="paragraph" id="N0432">Calling Python scripts from %PRODUCTNAME Basic macros is possible, and valuable features can be obtained such as:</paragraph> + <list type="unordered"> + <listitem><paragraph role="listitem" id="N0433"><literal>ComputerName</literal> identification or <literal>OSName</literal> detection are possible,</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0434">Basic <literal>FileLen()</literal> function and <link href="https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1ucb_1_1SimpleFileAccess.html" name="ucb.SimpleFileAccess">com.sun.star.ucb.SimpleFileAccess.</link><literal>getSize()</literal> API function exhibit a 2 Gigabytes file size upper limit that Python helps to overcome,</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0435"><link href="https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSettings.html" name="util.PathSettings">com.sun.star.util.PathSettings</link> can be normalized,</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0436">and many more.</paragraph></listitem> + </list> + <tip id="N0437">A reasonable exposure to %PRODUCTNAME Basic and to <link href="https://api.libreoffice.org/" name="Application Programming Interface">Application Programming Interface (API)</link> features is recommended prior to perform inter-language calls from Basic to Python, to JavaScript or any other script engine.</tip> + <h2 id="N0438">Retrieving Python Scripts</h2> + <paragraph role="paragraph" id="N0439">Python scripts can be personal, shared, or embedded in documents. In order to execute them, %PRODUCTNAME Basic needs to be provided with Python script locations. Locating <link href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1script_1_1provider_1_1XScript.html" name="script.provider.XScript">com.sun.star.script.provider.XScript</link> interface compliant UNO objects allows the execution of Python scripts:</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="N0440">Option Explicit</paragraph> + <paragraph role="bascode" localize="false" id="N0441"> </paragraph> + <paragraph role="bascode" localize="false" id="N0442">Public Function GetPythonScript(macro As String, _</paragraph> + <paragraph role="bascode" localize="false" id="N0443"> Optional location As String) As com.sun.star.script.provider.Xscript</paragraph> + <paragraph role="bascode" id="N0444"> ''' Grab Python script object before execution</paragraph> + <paragraph role="bascode" id="N0445"> ' Arguments:</paragraph> + <paragraph role="bascode" id="N0446"> ' macro : as "library/module.py$macro" or "module.py$macro"</paragraph> + <paragraph role="bascode" id="N0447"> ' location: as "document", "share", "user" or ENUM(eration)</paragraph> + <paragraph role="bascode" id="N0448"> ' Result:</paragraph> + <paragraph role="bascode" id="N0449"> ' located com.sun.star.script.provider.XScript UNO service'''</paragraph> + <paragraph role="bascode" localize="false" id="N0450"> If IsMissing(location) Then location = "user"</paragraph> + <paragraph role="bascode" localize="false" id="N0451"> Dim mspf As Object ' com.sun.star.script.provider.MasterScriptProviderFactory</paragraph> + <paragraph role="bascode" id="N0452"> Dim sp As Object ' com.sun.star.script.provider.XScriptProvider compatible</paragraph> + <paragraph role="bascode" localize="false" id="N0453"> Dim uri As String</paragraph> + <paragraph role="bascode" localize="false" id="N0454"> If location="document" Then</paragraph> + <paragraph role="bascode" localize="false" id="N0455"> sp = ThisComponent.getScriptProvider()</paragraph> + <paragraph role="bascode" localize="false" id="N0456"> Else</paragraph> + <paragraph role="bascode" localize="false" id="N0457"> mspf = CreateUNOService("com.sun.star.script.provider.MasterScriptProviderFactory")</paragraph> + <paragraph role="bascode" localize="false" id="N0458"> sp = mspf.createScriptProvider("")</paragraph> + <paragraph role="bascode" localize="false" id="N0459"> End If</paragraph> + <paragraph role="bascode" localize="false" id="N0460"> uri = "vnd.sun.star.script:"& macro &"?language=Python&location="& location</paragraph> + <paragraph role="bascode" localize="false" id="N0461"> GetPythonScript = sp.getScript(uri)</paragraph> + <paragraph role="bascode" localize="false" id="N0462">End Function ' GetPythonScript</paragraph> + </bascode> + <h2 id="N0463">Executing Python Scripts</h2> + <embed href="text/sbasic/python/python_2_basic.xhp#APIScriptingFramework" /> + <h3 id="N0464">Syntax</h3> + <paragraph role="paragraph" localize="false" id="N0465"><literal>workstation_name = script.invoke(Array(), Array(), Array())</literal></paragraph> + <paragraph role="paragraph" id="N0466"><literal>opSysName = script.invoke(Array(), in_outs, Array())</literal> ' in_out is an Array</paragraph> + <paragraph role="paragraph" localize="false" id="N0467"><literal>file_len = script.invoke(Array(systemFilePath), Array(), Array())</literal></paragraph> + <paragraph role="paragraph" localize="false" id="N0468"><literal>normalizedPath = script.invoke(Array(systemFilePath), Array(), Array())</literal></paragraph> + <h3 id="N0469">Embedded Scripts Examples</h3> + <paragraph role="paragraph" id="N0470">Below <literal>ComputerName</literal>, and <literal>GetFilelen</literal> routines are calling their Python counterparts, using aforementioned <literal>GetPythonScript</literal> function. Exception handling is not detailed.</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="N0471">Option Explicit</paragraph> + <paragraph role="bascode" id="N0472">Option Compatible ' Properties are supported</paragraph> + <paragraph role="bascode" localize="false" id="N0473"> </paragraph> + <paragraph role="bascode" localize="false" id="N0474">Private scr As Object ' com.sun.star.script.provider.XScript</paragraph> + <paragraph role="bascode" localize="false" id="N0475"> </paragraph> + <paragraph role="bascode" localize="false" id="N0476">Private Property Get ComputerName As String</paragraph> + <paragraph role="bascode" id="N0477"> '''Workstation name'''</paragraph> + <paragraph role="bascode" localize="false" id="N0478"> scr = GetPythonScript("Platform.py$computer_name", "document")</paragraph> + <paragraph role="bascode" localize="false" id="N0479"> ComputerName = scr.invoke(Array(), Array(), Array())</paragraph> + <paragraph role="bascode" localize="false" id="N0480">End Property ' ComputerName</paragraph> + <paragraph role="bascode" localize="false" id="N0481"> </paragraph> + <paragraph role="bascode" localize="false" id="N0482">Private Function GetFilelen(systemFilePath As String) As Currency</paragraph> + <paragraph role="bascode" id="N0483"> '''File size in bytes'''</paragraph> + <paragraph role="bascode" localize="false" id="N0484"> scr = GetPythonScript("Os/Path.py$get_size", Script.ISEMBEDDED)</paragraph> + <paragraph role="bascode" localize="false" id="N0485"> GetFilelen = scr.invoke(Array(systemFilePath), Array(), Array(),)</paragraph> + <paragraph role="bascode" localize="false" id="N0486">End Function ' GetFilelen</paragraph> + <paragraph role="bascode" localize="false" id="N0487"> </paragraph> + <paragraph role="bascode" localize="false" id="N0488">Private Type _SCRIPT_LOCATION</paragraph> + <paragraph role="bascode" id="N0489"> ISEMBEDDED As String ' document script</paragraph> + <paragraph role="bascode" id="N0490"> ISPERSONAL As String ' user script</paragraph> + <paragraph role="bascode" id="N0491"> ISSHARED As String ' %PRODUCTNAME macro</paragraph> + <paragraph role="bascode" localize="false" id="N0492">End Type ' _SCRIPT_LOCATION</paragraph> + <paragraph role="bascode" localize="false" id="N0493"> </paragraph> + <paragraph role="bascode" localize="false" id="N0494">Public Function Script() As Object ' Text enumeration</paragraph> + <paragraph role="bascode" localize="false" id="N0495"> Static enums As _SCRIPT_LOCATION : With enums</paragraph> + <paragraph role="bascode" localize="false" id="N0496"> If .ISEMBEDDED = "" Then</paragraph> + <paragraph role="bascode" id="N0497"> .ISEMBEDDED = "document" ' document script</paragraph> + <paragraph role="bascode" id="N0498"> .ISPERSONAL = "user" ' user scripts</paragraph> + <paragraph role="bascode" id="N0499"> .ISSHARED = "share" ' %PRODUCTNAME macro</paragraph> + <paragraph role="bascode" localize="false" id="N0500"> End If : End With ' enums</paragraph> + <paragraph role="bascode" localize="false" id="N0501"> Script = enums</paragraph> + <paragraph role="bascode" localize="false" id="N0502">End Function ' Script</paragraph> + </bascode> + <paragraph role="paragraph" id="N0503">Two different Python modules are called. They can either be embedded in the current document, either be stored on the file system. Argument type checking is skipped for clarity:</paragraph> + <list type="unordered"> + <listitem><paragraph localize="false" role="paragraph" id="N0504">Platform.py</paragraph></listitem> + </list> + <pycode> + <paragraph role="pycode" localize="false" id="N0505"># -*- coding: utf-8 -*-</paragraph> + <paragraph role="pycode" localize="false" id="N0506">from __future__ import unicode_literals</paragraph> + <paragraph role="pycode" localize="false" id="N0507"> </paragraph> + <paragraph role="pycode" localize="false" id="N0508">import platform</paragraph> + <paragraph role="pycode" localize="false" id="N0509"> </paragraph> + <paragraph role="pycode" localize="false" id="N0510">def computer_name() -> str:</paragraph> + <paragraph role="pycode" localize="false" id="N0511"> return platform.node()</paragraph> + <paragraph role="pycode" localize="false" id="N0512"> </paragraph> + <paragraph role="pycode" localize="false" id="N0513">def OSname() -> str:</paragraph> + <paragraph role="pycode" localize="false" id="N0514"> return platform.system()</paragraph> + </pycode> + <list type="unordered"> + <listitem><paragraph localize="false" role="paragraph" id="N0515">Os/Path.py</paragraph></listitem> + </list> + <pycode> + <paragraph role="pycode" localize="false" id="N0516"># -*- coding: utf-8 -*-</paragraph> + <paragraph role="pycode" localize="false" id="N0517">from __future__ import unicode_literals</paragraph> + <paragraph role="pycode" localize="false" id="N0518"> </paragraph> + <paragraph role="pycode" localize="false" id="N0519">import os.path</paragraph> + <paragraph role="pycode" localize="false" id="N0520"> </paragraph> + <paragraph role="pycode" localize="false" id="N0521">def get_size(systemFilePath: str) -> str:</paragraph> + <paragraph role="pycode" localize="false" id="N0522"> return str(os.path.getsize(systemFilePath))</paragraph> + <paragraph role="pycode" localize="false" id="N0523"> </paragraph> + <paragraph role="pycode" localize="false" id="N0524">def normalyze(systemPath: str) -> str:</paragraph> + <paragraph role="pycode" localize="false" id="N0525"> return os.path.normpath(systemPath)</paragraph> + </pycode> + <h3 id="N0526">Personal or Shared Scripts Examples</h3> + <paragraph role="paragraph" id="N0527">The calling mechanism for personal or shared Python scripts is identical to that of embedded scripts. Library names are mapped to folders. Computing %PRODUCTNAME user profile and shared modules system file paths can be performed as detailed in <link href="text/sbasic/python/python_session.xhp">Getting session information</link>. Below <literal>OSName</literal>, <literal>HelloWorld</literal> and <literal>NormalizePath</literal> routines are calling their Python counterparts, using aforementioned <literal>GetPythonScript</literal> function. Exception handling is not detailed.</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="N0528">Option Explicit</paragraph> + <paragraph role="bascode" id="N0529">Option Compatible ' Properties are supported</paragraph> + <paragraph role="bascode" localize="false" id="N0530"> </paragraph> + <paragraph role="bascode" localize="false" id="N0531">Private scr As Object ' com.sun.star.script.provider.XScript</paragraph> + <paragraph role="bascode" localize="false" id="N0532"> </paragraph> + <paragraph role="bascode" localize="false" id="N0533">Private Property Get OSName As String</paragraph> + <paragraph role="bascode" id="N0534"> '''Platform name as "Linux", "Darwin" or "Windows"'''</paragraph> + <paragraph role="bascode" localize="false" id="N0535"> scr = GetPythonScript("Platform.py$OSname", Script.ISPERSONAL)</paragraph> + <paragraph role="bascode" localize="false" id="N0536"> OSName = scr.invoke(Array(), Array(), Array()) </paragraph> + <paragraph role="bascode" localize="false" id="N0537">End Property ' OSName</paragraph> + <paragraph role="bascode" localize="false" id="N0538"> </paragraph> + <paragraph role="bascode" localize="false" id="N0539">Private Sub HelloWorld()</paragraph> + <paragraph role="bascode" id="N0540"> '''%PRODUCTNAME Python shared sample'''</paragraph> + <paragraph role="bascode" localize="false" id="N0541"> scr = GetPythonScript("HelloWorld.py$HelloWorldPython", Script.ISSHARED)</paragraph> + <paragraph role="bascode" localize="false" id="N0542"> scr.invoke(Array(), Array(), Array(),)</paragraph> + <paragraph role="bascode" localize="false" id="N0543">End Sub ' HelloWorld</paragraph> + <paragraph role="bascode" localize="false" id="N0544"> </paragraph> + <paragraph role="bascode" localize="false" id="N0545">Public Function NormalizePath(systemFilePath As String) As String</paragraph> + <paragraph role="bascode" id="N0546"> '''Strip superfluous '\..' in path'''</paragraph> + <paragraph role="bascode" localize="false" id="N0547"> scr = GetPythonScript("Os/Path.py$normalyze", "user")</paragraph> + <paragraph role="bascode" localize="false" id="N0548"> NormalizePath = scr.invoke(Array(systemFilePath), Array(), Array())</paragraph> + <paragraph role="bascode" localize="false" id="N0549">End Function ' NormalizePath</paragraph> + </bascode> + <h2 id="N0550">Python standard modules</h2> + <paragraph role="paragraph" id="N0551">%PRODUCTNAME embedded Python contains many standard libraries to benefit from. They bear a rich feature set, such as but not limited to:</paragraph> + <list type="unordered"> + <listitem><paragraph role="listitem" id="N0552"><emph>argparse</emph> Parser for command-line options, arguments and sub-commands</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0553"><emph>cmath</emph> Mathematical functions for complex numbers</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0554"><emph>csv</emph> CSV files reading and writing</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0555"><emph>datetime</emph> Genuine date and time types</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0556"><emph>json</emph> JSON encoder and decoder</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0557"><emph>math</emph> Mathematical functions</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0558"><emph>re</emph> Regular expression operations</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0559"><emph>socket</emph> Low-level networking interface</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0560"><emph>sys</emph> System-specific parameters and functions</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0561"><emph>unittest</emph> and <emph>trace</emph> Unit testing framework and Track Python execution</paragraph></listitem> + <listitem><paragraph role="listitem" id="N0562"><emph>xml.etree.ElementTree</emph> ElementTree XML API</paragraph></listitem> + </list> + <section id="relatedtopics" > + <embed href="text/sbasic/python/python_2_basic.xhp#py2ba_h1"/> + <embed href="text/sbasic/shared/main0601.xhp#mainsbasic"/> + <embed href="text/sbasic/python/main0000.xhp#pythonscriptshelp"/> + </section> + </body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/basic_examples.xhp b/helpcontent2/source/text/sbasic/guide/basic_examples.xhp new file mode 100644 index 000000000..97b11c065 --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/basic_examples.xhp @@ -0,0 +1,36 @@ +<?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="basicexamples" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">Basic Programming Examples</title> + <filename>/text/sbasic/guide/basic_examples.xhp</filename> + </topic> + </meta> + <body> + <bookmark xml-lang="en-US" branch="index" id="bm_id171559140731329"> + <bookmark_value>Basic;programming examples</bookmark_value> + </bookmark> + <section id="basicexamplesh1"> + <h1 id="hd_id471559139063621"><variable id="basicexamplestit"><link href="text/sbasic/guide/basic_examples.xhp" name="Basic Programming Examples">Basic Programming Examples</link></variable></h1> + </section> + <embed href="text/sbasic/python/python_handler.xhp#pythonhandler_h1"/> + <embed href="text/sbasic/python/python_listener.xhp#pythonlistener"/> + <embed href="text/sbasic/python/python_session.xhp#pythonsession"/> + <embed href="text/sbasic/python/python_platform.xhp#pythonplatform"/> + <embed href="text/sbasic/python/python_document_events.xhp#pythonmonitor"/> + <embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/> + <embed href="text/sbasic/guide/sample_code.xhp#sample_code"/> + <embed href="text/sbasic/guide/basic_2_python.xhp#basic2python"/> + <section id="relatedtopics"> + <embed href="text/sbasic/shared/main0601.xhp#mainsbasic"/> + </section> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/control_properties.xhp b/helpcontent2/source/text/sbasic/guide/control_properties.xhp new file mode 100644 index 000000000..7d8ff2c3e --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/control_properties.xhp @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + + +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> + +<helpdocument version="1.0"> +<meta> +<topic id="textsbasicguidecontrol_propertiesxml" indexer="include" status="PUBLISH"> +<title id="tit" xml-lang="en-US">Changing the Properties of Controls in the Dialog Editor</title> +<filename>/text/sbasic/guide/control_properties.xhp</filename> +</topic> +<history> +<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created> +</history> +</meta> +<body> +<bookmark xml-lang="en-US" branch="index" id="bm_id3145786"><bookmark_value>properties; controls in dialog editor</bookmark_value> +<bookmark_value>changing;control properties</bookmark_value> +<bookmark_value>controls;changing properties</bookmark_value> +<bookmark_value>dialog editor;changing control properties</bookmark_value> +</bookmark> +<paragraph role="heading" id="hd_id3145786" xml-lang="en-US" level="1"><variable id="control_properties"><link href="text/sbasic/guide/control_properties.xhp" name="Changing the Properties of Controls in the Dialog Editor">Changing the Properties of Controls in the Dialog Editor</link> +</variable></paragraph> +<paragraph role="paragraph" id="par_id3147317" xml-lang="en-US">You can set the properties of control that you add to a dialog. For example, you can change the color, name, and size of a button that you added. You can change most control properties when you create or edit a dialog. However, you can only change some properties at runtime.</paragraph> +<paragraph role="paragraph" id="par_id3145749" xml-lang="en-US">To change the properties of a control in design mode, right-click the control, and then choose <emph>Properties</emph>.</paragraph> +<section id="relatedtopics"> +<embed href="text/sbasic/guide/create_dialog.xhp#create_dialog"/> +<embed href="text/sbasic/guide/insert_control.xhp#insert_control"/> +<embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/> +<embed href="text/sbasic/guide/sample_code.xhp#sample_code"/> +</section> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/create_dialog.xhp b/helpcontent2/source/text/sbasic/guide/create_dialog.xhp new file mode 100644 index 000000000..e948d4467 --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/create_dialog.xhp @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> + + + +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> + + + <helpdocument version="1.0"> +<meta> +<topic id="textsbasicguidecreate_dialogxml" indexer="include" status="PUBLISH"> +<title id="tit" xml-lang="en-US">Creating a Basic Dialog</title> +<filename>/text/sbasic/guide/create_dialog.xhp</filename> +</topic> +</meta> +<body> +<bookmark xml-lang="en-US" branch="index" id="bm_id3149346"><bookmark_value>dialogs;creating Basic dialogs</bookmark_value> +</bookmark><paragraph role="heading" id="hd_id3149346" xml-lang="en-US" level="1"><variable id="create_dialog"><link href="text/sbasic/guide/create_dialog.xhp" name="Creating a Basic Dialog">Creating a Basic Dialog</link> +</variable></paragraph> +<list type="ordered"> +<listitem> +<paragraph role="listitem" id="par_id3163802" xml-lang="en-US">Choose <emph>Tools - Macros - Organize Dialogs</emph>, and then click <emph>New</emph>.</paragraph> +</listitem> +<listitem> +<paragraph role="listitem" id="par_id3150447" xml-lang="en-US">Enter a name for the dialog and click <emph>OK</emph>. To rename the dialog later, right-click the name on the tab and choose <emph>Rename</emph>.<comment>UFI: issue #i51589#</comment></paragraph> +</listitem> +<listitem> +<paragraph role="listitem" id="par_idN1065F" xml-lang="en-US">Click <emph>Edit</emph>. The Basic dialog editor opens and contains a blank dialog.</paragraph> +</listitem> +<listitem> +<paragraph role="listitem" id="par_id3153726" xml-lang="en-US">If you do not see the <emph>Toolbox</emph> bar, click the arrow next to the <emph>Insert Controls </emph>icon to open the <emph>Toolbox</emph> bar.</paragraph> +</listitem> +<listitem> +<paragraph role="listitem" id="par_id3148455" xml-lang="en-US">Click a tool and then drag in the dialog to create the control.</paragraph> +</listitem> +</list> +<section id="relatedtopics"> +<embed href="text/sbasic/guide/control_properties.xhp#control_properties"/> +<embed href="text/sbasic/guide/insert_control.xhp#insert_control"/> +<embed href="text/sbasic/guide/translation.xhp#translation"/> +<embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/> +<embed href="text/sbasic/guide/sample_code.xhp#sample_code"/> +</section> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/insert_control.xhp b/helpcontent2/source/text/sbasic/guide/insert_control.xhp new file mode 100644 index 000000000..cbc6fdbdb --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/insert_control.xhp @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> + + +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> + +<helpdocument version="1.0"> +<meta> +<topic id="textsbasicguideinsert_controlxml" indexer="include" status="PUBLISH"> +<title id="tit" xml-lang="en-US">Creating Controls in the Dialog Editor</title> +<filename>/text/sbasic/guide/insert_control.xhp</filename> +</topic> +<history> +<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created> +</history> +</meta> +<body> +<bookmark xml-lang="en-US" branch="index" id="bm_id3149182"><bookmark_value>controls; creating in the dialog editor</bookmark_value> +<bookmark_value>dialog editor;creating controls</bookmark_value> +</bookmark> +<paragraph role="heading" id="hd_id3149182" xml-lang="en-US" level="1"><variable id="insert_control"><link href="text/sbasic/guide/insert_control.xhp" name="Creating Controls in the Dialog Editor">Creating Controls in the Dialog Editor</link> +</variable></paragraph> +<paragraph role="paragraph" id="par_id3146797" xml-lang="en-US">Use the tools on the <emph>Toolbox </emph>of the BASIC dialog editor to add controls to your dialog.</paragraph> +<list type="ordered"> +<listitem> +<paragraph role="listitem" id="par_id3150276" xml-lang="en-US">To open the <emph>Toolbox</emph>, click the arrow next to the <emph>Insert Controls</emph> icon on the <emph>Macro</emph> toolbar.</paragraph> +</listitem> +<listitem> +<paragraph role="listitem" id="par_id3145068" xml-lang="en-US">Click a tool on the toolbar, for example, <emph>Button</emph>.</paragraph> +</listitem> +<listitem> +<paragraph role="listitem" id="par_id3153360" xml-lang="en-US">On the dialog, drag the button to the size you want.</paragraph> +</listitem> +</list> +<section id="relatedtopics"> +<embed href="text/sbasic/guide/control_properties.xhp#control_properties"/> +<embed href="text/sbasic/guide/create_dialog.xhp#create_dialog"/> +<embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/> +<embed href="text/sbasic/guide/sample_code.xhp#sample_code"/> +</section> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/sample_code.xhp b/helpcontent2/source/text/sbasic/guide/sample_code.xhp new file mode 100644 index 000000000..7ef8b6a45 --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/sample_code.xhp @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> +<helpdocument version="1.0"> + <meta> + <topic id="textsbasicguidesample_codexml" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">Programming Examples for Controls in the Dialog Editor</title> + <filename>/text/sbasic/guide/sample_code.xhp</filename> + </topic> + <history> + <created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created> + </history> + </meta> +<body> + <bookmark xml-lang="en-US" branch="index" id="bm_id3155338"><bookmark_value>programming examples for controls</bookmark_value> + <bookmark_value>dialogs;loading (example)</bookmark_value> + <bookmark_value>dialogs;displaying (example)</bookmark_value> + <bookmark_value>controls;reading or editing properties (example)</bookmark_value> + <bookmark_value>list boxes;removing entries from (example)</bookmark_value> + <bookmark_value>list boxes;adding entries to (example)</bookmark_value> + <bookmark_value>examples; programming controls</bookmark_value> + <bookmark_value>dialog editor;programming examples for controls</bookmark_value> + <bookmark_value>Tools;LoadDialog</bookmark_value> +</bookmark> +<section id="samplecode"> + <paragraph role="heading" id="hd_id3155338" xml-lang="en-US" level="1"><variable id="sample_code"><link href="text/sbasic/guide/sample_code.xhp" name="Programming Examples for Controls in the Dialog Editor">Programming Examples for Controls in the Dialog Editor</link> + </variable></paragraph> +</section> +<paragraph role="paragraph" id="par_id3153031" xml-lang="en-US">The following examples are for a new <link href="text/sbasic/guide/create_dialog.xhp" name="dialog">dialog</link> called "Dialog1". Use the tools on the <emph>Toolbox</emph> bar in the dialog editor to create the dialog and add the following controls: a <emph>Check Box</emph> called "CheckBox1", a <emph>Label Field</emph> called "Label1", a <emph>Button</emph> called "CommandButton1", and a <emph>List Box</emph> called "ListBox1".</paragraph> +<paragraph role="warning" id="par_id3154141" xml-lang="en-US">Be consistent with uppercase and lowercase letter when you attach a control to an object variable.</paragraph> +<paragraph role="heading" id="hd_id3154909" xml-lang="en-US" level="3">Global Function for Loading Dialogs</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3153193" xml-lang="en-US" localize="false">Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)</paragraph> +<paragraph role="bascode" id="par_id3145787" xml-lang="en-US" localize="false">Dim oLib as Object ' com.sun.star.script.XLibraryContainer</paragraph> +<paragraph role="bascode" id="par_id3148576" xml-lang="en-US" localize="false">Dim oLibDialog as Object</paragraph> +<paragraph role="bascode" id="par_id3153726" xml-lang="en-US" localize="false">Dim oRuntimeDialog as Object</paragraph> +<paragraph role="bascode" id="par_id3149261" xml-lang="en-US" localize="false"> If IsMissing(oLibContainer) Then</paragraph> +<paragraph role="bascode" id="par_id3148646" xml-lang="en-US" localize="false"> oLibContainer = DialogLibraries</paragraph> +<paragraph role="bascode" id="par_id3151115" xml-lang="en-US" localize="false"> End If</paragraph> +<paragraph role="bascode" id="par_id3146986" xml-lang="en-US" localize="false"> oLibContainer.LoadLibrary(LibName)</paragraph> +<paragraph role="bascode" id="par_id3145366" xml-lang="en-US" localize="false"> oLib = oLibContainer.GetByName(Libname)</paragraph> +<paragraph role="bascode" id="par_id3145271" xml-lang="en-US" localize="false"> oLibDialog = oLib.GetByName(DialogName)</paragraph> +<paragraph role="bascode" id="par_id3144764" xml-lang="en-US" localize="false"> oRuntimeDialog = CreateUnoDialog(oLibDialog)</paragraph> +<paragraph role="bascode" id="par_id3153876" xml-lang="en-US" localize="false"> LoadDialog() = oRuntimeDialog</paragraph> +<paragraph role="bascode" id="par_id3156286" xml-lang="en-US" localize="false">End Function</paragraph> +</bascode> +<paragraph role="paragraph" id="par_id3153032" xml-lang="en-US"><literal>LoadDialog</literal> function is stored in <literal>Tools.ModuleControls</literal> available from %PRODUCTNAME Macros and Dialogs.</paragraph> +<paragraph role="heading" id="hd_id3149412" xml-lang="en-US" level="3">Displaying a Dialog</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3145801" xml-lang="en-US">REM global definition of variables</paragraph> +<paragraph role="bascode" id="par_id3150716" xml-lang="en-US" localize="false">Dim oDialog1 AS Object</paragraph> +<paragraph role="bascode" id="par_id3154510" xml-lang="en-US" localize="false">Sub StartDialog1</paragraph> +<paragraph role="bascode" id="par_id6715587" xml-lang="en-US" localize="false"> With GlobalScope.BasicLibraries</paragraph> +<paragraph role="bascode" id="par_id3148575" xml-lang="en-US" localize="false"> If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")</paragraph> +<paragraph role="bascode" id="par_id5815587" xml-lang="en-US" localize="false"> End With</paragraph> +<paragraph role="bascode" id="par_id3150327" xml-lang="en-US" localize="false"> oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1")</paragraph> +<paragraph role="bascode" id="par_id3155767" xml-lang="en-US" localize="false"> oDialog1.Execute()</paragraph> +<paragraph role="bascode" id="par_id3149019" xml-lang="en-US" localize="false">End Sub</paragraph> +</bascode> +<paragraph role="heading" id="hd_id3150042" xml-lang="en-US" level="3">Read or Edit Properties of Controls in the Program</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3159267" xml-lang="en-US" localize="false">Sub Sample1</paragraph> +<paragraph role="bascode" id="par_id6715588" xml-lang="en-US" localize="false"> With GlobalScope.Basiclibraries</paragraph> +<paragraph role="bascode" id="par_id3148576" xml-lang="en-US" localize="false"> If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")</paragraph> +<paragraph role="bascode" id="par_id5815588" xml-lang="en-US" localize="false"> End With</paragraph> +<paragraph role="bascode" id="par_id3163808" xml-lang="en-US" localize="false"> oDialog1 = Tools.LoadDialog("Standard", "Dialog1")</paragraph> +<paragraph role="bascode" id="par_id3145232" xml-lang="en-US"> REM get dialog model</paragraph> +<paragraph role="bascode" id="par_id3146316" xml-lang="en-US" localize="false"> oDialog1Model = oDialog1.Model</paragraph> +<paragraph role="bascode" id="par_id3154021" xml-lang="en-US"> REM display text of Label1</paragraph> +<paragraph role="bascode" id="par_id3150301" xml-lang="en-US" localize="false"> oLabel1 = oDialog1.GetControl("Label1")</paragraph> +<paragraph role="bascode" id="par_id3152584" xml-lang="en-US" localize="false"> MsgBox oLabel1.Text</paragraph> +<paragraph role="bascode" id="par_id3151277" xml-lang="en-US"> REM set new text for control Label1</paragraph> +<paragraph role="bascode" id="par_id3154119" xml-lang="en-US"> oLabel1.Text = "New Files"</paragraph> +<paragraph role="bascode" id="par_id3155115" xml-lang="en-US"> REM display model properties for the control CheckBox1</paragraph> +<paragraph role="bascode" id="par_id3166426" xml-lang="en-US" localize="false"> oCheckBox1Model = oDialog1Model.CheckBox1</paragraph> +<paragraph role="bascode" id="par_id3153270" xml-lang="en-US" localize="false"> MsgBox oCheckBox1Model.Dbg_Properties</paragraph> +<paragraph role="bascode" id="par_id3149817" xml-lang="en-US"> REM set new state for CheckBox1 for model of control</paragraph> +<paragraph role="bascode" id="par_id3145134" xml-lang="en-US" localize="false"> oCheckBox1Model.State = 1</paragraph> +<paragraph role="bascode" id="par_id3159102" xml-lang="en-US"> REM display model properties for control CommandButton1</paragraph> +<paragraph role="bascode" id="par_id3152777" xml-lang="en-US" localize="false"> oCMD1Model = oDialog1Model.CommandButton1</paragraph> +<paragraph role="bascode" id="par_id3149209" xml-lang="en-US" localize="false"> MsgBox oCMD1Model.Dbg_Properties</paragraph> +<paragraph role="bascode" id="par_id3150368" xml-lang="en-US"> REM display properties of control CommandButton1</paragraph> +<paragraph role="bascode" id="par_id3150883" xml-lang="en-US" localize="false"> oCMD1 = oDialog1.GetControl("CommandButton1")</paragraph> +<paragraph role="bascode" id="par_id3155380" xml-lang="en-US" localize="false"> MsgBox oCMD1.Dbg_Properties</paragraph> +<paragraph role="bascode" id="par_id3150201" xml-lang="en-US"> REM execute dialog</paragraph> +<paragraph role="bascode" id="par_id3154485" xml-lang="en-US" localize="false"> oDialog1.Execute()</paragraph> +<paragraph role="bascode" id="par_id3146115" xml-lang="en-US" localize="false">End Sub</paragraph> +</bascode> +<paragraph role="heading" id="hd_id3145387" xml-lang="en-US" level="3">Add an Entry to a ListBox</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3155088" xml-lang="en-US" localize="false">Sub AddEntry</paragraph> +<paragraph role="bascode" id="par_id6715589" xml-lang="en-US" localize="false"> With GlobalScope.Basiclibraries</paragraph> +<paragraph role="bascode" id="par_id3148577" xml-lang="en-US" localize="false"> If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")</paragraph> +<paragraph role="bascode" id="par_id5815589" xml-lang="en-US" localize="false"> End With</paragraph> +<paragraph role="bascode" id="par_id3159222" xml-lang="en-US" localize="false"> oDialog1 = ModuleControls.LoadDialog("Standard", "Dialog1")</paragraph> +<paragraph role="bascode" id="par_id3148700" xml-lang="en-US"> REM adds a new entry to the ListBox</paragraph> +<paragraph role="bascode" id="par_id3159173" xml-lang="en-US" localize="false"> oDialog1Model = oDialog1.Model</paragraph> +<paragraph role="bascode" id="par_id3153305" xml-lang="en-US" localize="false"> oListBox = oDialog1.GetControl("ListBox1")</paragraph> +<paragraph role="bascode" id="par_id3153914" xml-lang="en-US" localize="false"> Dim iCount as integer</paragraph> +<paragraph role="bascode" id="par_id3151243" xml-lang="en-US" localize="false"> iCount = oListbox.ItemCount</paragraph> +<paragraph role="bascode" id="par_id3144504" xml-lang="en-US"> oListbox.additem("New Item" & iCount,0)</paragraph> +<paragraph role="bascode" id="par_id3149328" xml-lang="en-US" localize="false">End Sub</paragraph> +</bascode> +<paragraph role="heading" id="hd_id3147071" xml-lang="en-US" level="3">Remove an Entry from a ListBox</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3159095" xml-lang="en-US" localize="false">Sub RemoveEntry</paragraph> +<paragraph role="bascode" id="par_id6715590" xml-lang="en-US" localize="false"> With GlobalScope.Basiclibraries</paragraph> +<paragraph role="bascode" id="par_id3148578" xml-lang="en-US" localize="false"> If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")</paragraph> +<paragraph role="bascode" id="par_id5815590" xml-lang="en-US" localize="false"> End With</paragraph> +<paragraph role="bascode" id="par_id3149443" xml-lang="en-US" localize="false"> oDialog1 = Tools.ModuleControls.LoadDialogLoadDialog("Standard", "Dialog1")</paragraph> +<paragraph role="bascode" id="par_id3153247" xml-lang="en-US"> REM remove the first entry from the ListBox</paragraph> +<paragraph role="bascode" id="par_id3151302" xml-lang="en-US" localize="false"> oDialog1Model = oDialog1.Model</paragraph> +<paragraph role="bascode" id="par_id3153976" xml-lang="en-US" localize="false"> oListBox = oDialog1.GetControl("ListBox1")</paragraph> +<paragraph role="bascode" id="par_id3155383" xml-lang="en-US" localize="false"> oListbox.removeitems(0,1)</paragraph> +<paragraph role="bascode" id="par_id3150892" xml-lang="en-US" localize="false">End Sub</paragraph> +</bascode> +<section id="relatedtopics"> +<embed href="text/sbasic/guide/control_properties.xhp#control_properties"/> +<embed href="text/sbasic/guide/create_dialog.xhp#create_dialog"/> +<embed href="text/sbasic/guide/insert_control.xhp#insert_control"/> +<embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/> +</section> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/show_dialog.xhp b/helpcontent2/source/text/sbasic/guide/show_dialog.xhp new file mode 100644 index 000000000..117ff796c --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/show_dialog.xhp @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> +<helpdocument version="1.0"> +<meta> +<topic id="textsbasicguideshow_dialogxml" indexer="include" status="PUBLISH"> +<title id="tit" xml-lang="en-US">Opening a Dialog With Basic</title> +<filename>/text/sbasic/guide/show_dialog.xhp</filename> +</topic> +</meta> +<body> +<bookmark xml-lang="en-US" branch="index" id="bm_id3154140"> + <bookmark_value>module/dialog toggle</bookmark_value> + <bookmark_value>dialogs;using Basic to show (example)</bookmark_value> + <bookmark_value>examples; showing a dialog with Basic</bookmark_value> + <bookmark_value>Tools;LoadDialog</bookmark_value> +</bookmark> +<paragraph role="heading" id="hd_id3154140" xml-lang="en-US" level="1"><variable id="show_dialog"><link href="text/sbasic/guide/show_dialog.xhp" name="Opening a Dialog With Basic">Opening a Dialog With Basic</link> +</variable></paragraph> +<paragraph role="paragraph" id="par_id3145171" xml-lang="en-US">In the <item type="productname">%PRODUCTNAME</item> BASIC window for a dialog that you created, leave the dialog editor by clicking the name tab of the Module that the dialog is assigned to. The name tab is at the bottom of the window.</paragraph> +<paragraph role="paragraph" id="par_id3153968" xml-lang="en-US">Enter the following code for a subroutine called <emph>Dialog1Show</emph>. In this example, the name of the dialog that you created is "Dialog1":</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3156443" xml-lang="en-US" localize="false">Sub Dialog1Show</paragraph> +<paragraph role="bascode" id="par_id6715587" xml-lang="en-US" localize="false"> With GlobalScope.BasicLibraries</paragraph> +<paragraph role="bascode" id="par_id3148575" xml-lang="en-US" localize="false"> If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")</paragraph> +<paragraph role="bascode" id="par_id5815587" xml-lang="en-US" localize="false"> End With</paragraph> +<paragraph role="bascode" id="par_id3152463" xml-lang="en-US" localize="false"> oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1")</paragraph> +<paragraph role="bascode" id="par_id3148646" xml-lang="en-US" localize="false"> oDialog1.Execute()</paragraph> +<paragraph role="bascode" id="par_id3147349" xml-lang="en-US" localize="false">End Sub</paragraph> +</bascode> +<paragraph role="paragraph" id="par_id3152596" xml-lang="en-US">Without using "LoadDialog" you can call the code as follows:</paragraph> +<bascode> +<paragraph role="bascode" id="par_id3163710" xml-lang="en-US" localize="false">Sub Dialog1Show</paragraph> +<paragraph role="bascode" id="par_id3146985" xml-lang="en-US" localize="false"> DialogLibraries.LoadLibrary("Standard")</paragraph> +<paragraph role="bascode" id="par_id3155418" xml-lang="en-US" localize="false"> oDialog1 = CreateUnoDialog( DialogLibraries.Standard.Dialog1 )</paragraph> +<paragraph role="bascode" id="par_id3154944" xml-lang="en-US" localize="false"> oDialog1.Execute()</paragraph> +<paragraph role="bascode" id="par_id3145800" xml-lang="en-US" localize="false">End Sub</paragraph> +</bascode> +<paragraph role="paragraph" id="par_id3153157" xml-lang="en-US">When you execute this code, "Dialog1" opens. To close the dialog, click the close button (x) on its title bar.</paragraph> +<section id="relatedtopics"> +<embed href="text/sbasic/guide/control_properties.xhp#control_properties"/> +<embed href="text/sbasic/guide/create_dialog.xhp#create_dialog"/> +<embed href="text/sbasic/guide/insert_control.xhp#insert_control"/> +<embed href="text/sbasic/python/python_dialogs.xhp#pythondialog"/> +<embed href="text/sbasic/guide/sample_code.xhp#sample_code"/> +</section> +</body> +</helpdocument> diff --git a/helpcontent2/source/text/sbasic/guide/translation.xhp b/helpcontent2/source/text/sbasic/guide/translation.xhp new file mode 100644 index 000000000..38608ddea --- /dev/null +++ b/helpcontent2/source/text/sbasic/guide/translation.xhp @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> + + + +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> + + + <helpdocument version="1.0"> +<meta> +<topic id="textsbasicguidetranslationxml" indexer="include" status="PUBLISH"> +<title id="tit" xml-lang="en-US">Translation of Controls in the Dialog Editor</title> +<filename>/text/sbasic/guide/translation.xhp</filename> +</topic> +</meta> +<body> +<bookmark xml-lang="en-US" branch="index" id="bm_id8915372"><bookmark_value>dialogs;translating</bookmark_value> +<bookmark_value>localizing dialogs</bookmark_value> +<bookmark_value>translating dialogs</bookmark_value> +</bookmark> +<paragraph role="heading" id="hd_id3574896" xml-lang="en-US" level="1"><variable id="translation"><link href="text/sbasic/guide/translation.xhp">Translation of Controls in the Dialog Editor</link> +</variable></paragraph> +<paragraph role="paragraph" id="par_id4601940" xml-lang="en-US">The Language toolbar in the Basic IDE dialog editor shows controls to enable and manage localizable dialogs.</paragraph> +<paragraph role="paragraph" id="par_id9538560" xml-lang="en-US">By default, any dialog that you create only contains string resources for one language. You may want to create dialogs that automatically show localized strings according to the user's language settings.</paragraph> +<bookmark xml-lang="en-US" branch="hid/.uno:CurrentLanguage" id="bm_id9421979" localize="false"/><paragraph role="paragraph" id="par_id6998809" xml-lang="en-US"><ahelp hid="." visibility="hidden">Select the language for the strings that you want to edit. Click the Manage Languages icon to add languages.</ahelp></paragraph><comment>Manage Language icon is in sbasic/shared/02/20000000.xhp</comment> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/managelanguages/ManageLanguagesDialog" id="bm_id1646778" localize="false"/> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/managelanguages/@@nowidget@@" id="bm_id1646778" localize="false"/> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/managelanguages/treeview" id="bm_id16467781" localize="false"/><paragraph role="paragraph" id="par_id71413" xml-lang="en-US"><ahelp hid="." visibility="hidden">Click a language, then click Default to set the language as default, or click Delete to remove the language from the list.</ahelp></paragraph> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/managelanguages/add" id="bm_id1228370" localize="false"/><paragraph role="paragraph" id="par_id2924283" xml-lang="en-US"><ahelp hid="." visibility="hidden">Opens a dialog where you can add a language to the list.</ahelp></paragraph> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/managelanguages/delete" id="bm_id1601611" localize="false"/><paragraph role="paragraph" id="par_id5781731" xml-lang="en-US"><ahelp hid="." visibility="hidden">Select a language in the list and click Delete to remove that language. When you remove all languages, the string resources for localizable dialogs are removed from all dialogs in the current library.</ahelp></paragraph> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/managelanguages/default" id="bm_id733359" localize="false"/><paragraph role="paragraph" id="par_id6942045" xml-lang="en-US"><ahelp hid="." visibility="hidden">Select a language in the list and click Default to set the language as default language.</ahelp></paragraph> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/defaultlanguage/DefaultLanguageDialog" id="bm_id879849" localize="false"/> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/defaultlanguage/@@nowidget@@" id="bm_id879849" localize="false"/> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/defaultlanguage/entries" id="bm_id879848" localize="false"/><paragraph role="paragraph" id="par_id4721823" xml-lang="en-US"><ahelp hid="." visibility="hidden">The default language will be used as a source for all other language strings.</ahelp></paragraph> +<bookmark xml-lang="en-US" branch="hid/modules/BasicIDE/ui/defaultlanguage/checkedentries" id="bm_id8675191" localize="false"/><paragraph role="paragraph" id="par_id5806756" xml-lang="en-US"><ahelp hid="." visibility="hidden">Add UI languages for your dialog strings.</ahelp></paragraph> +<paragraph role="heading" id="hd_id6596881" xml-lang="en-US" level="2">To enable localizable dialogs</paragraph> +<list type="ordered"> +<listitem> +<paragraph role="paragraph" id="par_id8750572" xml-lang="en-US">In the Basic IDE dialog editor, open the Language toolbar choosing <item type="menuitem">View - Toolbars - Language</item>. </paragraph> +<paragraph role="paragraph" id="par_id2224494" xml-lang="en-US">If the current library already contains a localizable dialog, the Language toolbar is shown automatically.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id7359233" xml-lang="en-US">Click the <emph>Manage Languages</emph> icon +<image id="img_id2526017" src="cmd/sc_managelanguage.png" width="0.1665inch" height="0.1665inch"><alt id="alt_id2526017" xml-lang="en-US">Manage Language icon</alt> + </image> on the Language toolbar or on the Toolbox bar.</paragraph> +<paragraph role="paragraph" id="par_id6549272" xml-lang="en-US">You see the Manage User Interface Language dialog. The dialog manages languages for the current library. The name of the current library is shown on the title bar.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id6529740" xml-lang="en-US">Click Add in the dialog to add a language entry. </paragraph> +<paragraph role="paragraph" id="par_id7811822" xml-lang="en-US">This step enables all new dialogs to contain localizable string resources.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id9121982" xml-lang="en-US">The first time you click Add, you see the Set Default User Interface Language dialog. The following times you click Add, this dialog has the name Add User Interface Language.</paragraph> +<paragraph role="paragraph" id="par_id3640247" xml-lang="en-US">You can also change the default language in the Manage User Interface Language dialog.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id3808404" xml-lang="en-US">Select a language. </paragraph> +<paragraph role="paragraph" id="par_id4585100" xml-lang="en-US">This adds string resources to contain the translated versions of all strings to the dialog properties. The set of dialog strings of the default language is copied to the new set of strings. Later, you can switch to the new language and then translate the strings.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id2394482" xml-lang="en-US">Close the dialog or add additional languages.</paragraph> +</listitem> +</list> +<paragraph role="heading" id="hd_id631733" xml-lang="en-US" level="2">To edit localizable controls in your dialog</paragraph> +<paragraph role="paragraph" id="par_id2334665" xml-lang="en-US">Once you have added the resources for localizable strings in your dialogs, you can select the current language from the Current Language listbox on the Language toolbar.</paragraph> +<list type="ordered"> +<listitem> +<paragraph role="paragraph" id="par_id8956572" xml-lang="en-US">Switch the Current Language listbox to display the default language.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id500808" xml-lang="en-US">Insert any number of controls to your dialog and enter all strings you want.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id8366649" xml-lang="en-US">Select another language in the Current Language listbox.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id476393" xml-lang="en-US">Using the control's property dialogs, edit all strings to the other language.</paragraph> +</listitem> +<listitem> +<paragraph role="paragraph" id="par_id2655720" xml-lang="en-US">Repeat for all languages that you added.</paragraph> +</listitem> +</list> +<paragraph role="paragraph" id="par_id3682058" xml-lang="en-US">The user of your dialog will see the strings of the user interface language of the user's version of %PRODUCTNAME, if you did provide strings in that language. </paragraph> +<paragraph role="paragraph" id="par_id5977965" xml-lang="en-US">If no language matches the user's version, the user will see the default language strings. </paragraph> +<paragraph role="paragraph" id="par_id3050325" xml-lang="en-US">If the user has an older version of %PRODUCTNAME that does not know localizable string resources for Basic dialogs, the user will see the default language strings.</paragraph> +<section id="relatedtopics"> +<embed href="text/sbasic/guide/create_dialog.xhp#create_dialog"/> +<embed href="text/sbasic/guide/insert_control.xhp#insert_control"/> +<embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/> +<embed href="text/sbasic/guide/sample_code.xhp#sample_code"/> +</section> +</body> +</helpdocument> |