[Libreoffice-commits] help.git: AllLangHelp_sbasic.mk source/text

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 23 11:39:49 UTC 2019


 AllLangHelp_sbasic.mk                          |    1 
 source/text/sbasic/python/python_examples.xhp  |    7 -
 source/text/sbasic/python/python_platform.xhp  |  117 +++++++++++++++++++++++++
 source/text/sbasic/shared/03132100.xhp         |    2 
 source/text/sbasic/shared/GetPathSeparator.xhp |    4 
 5 files changed, 125 insertions(+), 6 deletions(-)

New commits:
commit de5dad498afaadc2308ee247f26aa6f9b14a3d66
Author:     Alain Romedenne <OpenOfficiant at sfr.fr>
AuthorDate: Tue Jan 22 23:40:10 2019 -0200
Commit:     Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Wed Jan 23 12:39:28 2019 +0100

    Add more python examples
    
    Change-Id: Id34674cd96d615b8613a35e18d96886a3d39bae0
    Reviewed-on: https://gerrit.libreoffice.org/66763
    Tested-by: Jenkins
    Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>

diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk
index cc08cf424..16cac3877 100644
--- a/AllLangHelp_sbasic.mk
+++ b/AllLangHelp_sbasic.mk
@@ -369,6 +369,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\
     helpcontent2/source/text/sbasic/python/python_examples \
     helpcontent2/source/text/sbasic/python/python_ide \
     helpcontent2/source/text/sbasic/python/python_locations \
+    helpcontent2/source/text/sbasic/python/python_platform \
     helpcontent2/source/text/sbasic/python/python_programming \
     helpcontent2/source/text/sbasic/python/python_screen \
     helpcontent2/source/text/sbasic/python/python_shell \
diff --git a/source/text/sbasic/python/python_examples.xhp b/source/text/sbasic/python/python_examples.xhp
index 40c00f8e3..085f9ddad 100644
--- a/source/text/sbasic/python/python_examples.xhp
+++ b/source/text/sbasic/python/python_examples.xhp
@@ -31,10 +31,11 @@
     <embed href="text/sbasic/python/python_dialog.xhp#pythondialog"/>
     <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_import.xhp#pythonimport"/>
     -->
+    <embed href="text/sbasic/python/python_platform.xhp#pythonplatform"/>
+    <!--<embed href="text/sbasic/python/python_import.xhp#pythonimport"/>-->
+
     <embed href="text/sbasic/python/python_screen.xhp#ioscreen"/>
-    <!--<embed href="text/sbasic/python/python_shell.xhp#pythonshell"/>-->
+    <embed href="text/sbasic/python/python_shell.xhp#pythonshell1"/>
 </body>
 </helpdocument>
diff --git a/source/text/sbasic/python/python_platform.xhp b/source/text/sbasic/python/python_platform.xhp
new file mode 100644
index 000000000..5127069fb
--- /dev/null
+++ b/source/text/sbasic/python/python_platform.xhp
@@ -0,0 +1,117 @@
+<?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/python/Python_Platform">
+            <title id="tit" xml-lang="en-US">Python : Platform class</title>
+            <filename>/text/sbasic/python/python_platform.xhp</filename>
+        </topic>
+    </meta>
+    <body>
+    <bookmark branch="index" id="N0508">
+        <bookmark_value>Platform;isLinux</bookmark_value>
+        <bookmark_value>Platform;isMacOsX</bookmark_value>
+        <bookmark_value>Platform;isWindows</bookmark_value>
+        <bookmark_value>Platform;ComputerName</bookmark_value>
+        <bookmark_value>Platform;OSName</bookmark_value>
+    </bookmark>
+    <h1 id="N0509"><variable id="pythonplatform"><link href="text/sbasic/python/python_platform.xhp" name="platform01">Identifying the operating system</link></variable></h1>
+    <paragraph role="paragraph" id="N0510">Identifying the operating system can be performed with Python or Basic language.</paragraph>
+    <tip id="N0511">%PRODUCTNAME Basic lacks Mac OS X native recognition while ComputerName property is solely available for Windows. Basic calls to Python macros help overcome such limitations.</tip>
+    <h2 id="N0512">Using a Python class:</h2>
+    <pycode>
+        <paragraph role="pycode" localize="false" id="N0513">import os, platform</paragraph>
+        <paragraph role="pycode" localize="false" id="N0514">class Platform():</paragraph>
+        <paragraph role="pycode" localize="false" id="N0515">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0516">    def ComputerName(self): return platform.node()</paragraph>
+        <paragraph role="pycode" localize="false" id="N0517">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0518">    def DirSeparator(self): return os.sep</paragraph>
+        <paragraph role="pycode" localize="false" id="N0519">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0520">    def isLinux(self): return (self.OSName=='Linux')</paragraph>
+        <paragraph role="pycode" localize="false" id="N0521">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0522">    def isMacOSX(self): return (self.OSName=='Darwin')</paragraph>
+        <paragraph role="pycode" localize="false" id="N0523">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0524">    def isWindows(self): return (self.OSName=='Windows')</paragraph>
+        <paragraph role="pycode" localize="false" id="N0525">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0526">    def OSName(self): return platform.system()</paragraph>
+        <paragraph role="pycode" localize="false" id="N0527">    @property</paragraph>
+        <paragraph role="pycode" localize="false" id="N0528">    def PathDelimiter(self): return os.pathsep</paragraph>
+    </pycode>
+    <h2 id="N0529">Using a Basic classmodule:</h2>
+    <bascode>
+        <paragraph role="bascode" localize="false" id="N0530">Option Compatible</paragraph>
+        <paragraph role="bascode" localize="false" id="N0531">Option ClassModule</paragraph>
+        <paragraph role="bascode" localize="false" id="N0532">Option Explicit</paragraph>
+        <paragraph role="bascode" localize="false" id="N0533"></paragraph>
+        <paragraph role="bascode" localize="false" id="N0534">Public Property Get ComputerName As String</paragraph>
+        <paragraph role="bascode" localize="false" id="N0535">    If isWindows Then ComputerName = Environ("ComputerName")</paragraph>
+        <paragraph role="bascode" localize="false" id="N0536">End Property ' Platform.ComputerName</paragraph>
+        <paragraph role="bascode" localize="false" id="N0537"></paragraph>
+        <paragraph role="bascode" localize="false" id="N0538">Public Property Get DirSeparator As String</paragraph>
+        <paragraph role="bascode" localize="false" id="N0539">    DirSeparator = GetPathSeparator()</paragraph>
+        <paragraph role="bascode" localize="false" id="N0540">End Property ' Platform.DirSeparator</paragraph>
+        <paragraph role="bascode" localize="false" id="N0541"></paragraph>
+        <paragraph role="bascode" localize="false" id="N0542">Public Property Get IsLinux As Boolean</paragraph>
+        <paragraph role="bascode" localize="false" id="N0543">    isLinux = ( GetGUIType()=4 ) ' Applies to Mac OS X as well </paragraph>
+        <paragraph role="bascode" localize="false" id="N0544">End Property ' Platform.isLinux</paragraph>
+        <paragraph role="bascode" localize="false" id="N0545"></paragraph>
+        <paragraph role="bascode" localize="false" id="N0546">Public Property Get IsWindows As Boolean</paragraph>
+        <paragraph role="bascode" localize="false" id="N0547">    isWindows = ( GetGUIType()=1 )</paragraph>
+        <paragraph role="bascode" localize="false" id="N0548">End Property ' Platform.isWindows</paragraph>
+        <paragraph role="bascode" localize="false" id="N0549"></paragraph>
+        <paragraph role="bascode" localize="false" id="N0550">Public Property Get OSName As String</paragraph>
+        <paragraph role="bascode" localize="false" id="N0551">    Select Case GetGUIType()</paragraph>
+        <paragraph role="bascode" localize="false" id="N0552">        Case 1 : OSName = "Windows"</paragraph>
+        <paragraph role="bascode" localize="false" id="N0553">        Case 4 : OSName = "Linux"</paragraph>
+        <paragraph role="bascode" localize="false" id="N0554">     End Select</paragraph>
+        <paragraph role="bascode" localize="false" id="N0555">End Property ' Platform.OSName</paragraph>
+        <paragraph role="bascode" localize="false" id="N0556"></paragraph>
+        <paragraph role="bascode" localize="false" id="N0557">Public Property Get PathDelimiter As String</paragraph>
+        <paragraph role="bascode" localize="false" id="N0559">    Select Case OSName</paragraph>
+        <paragraph role="bascode" localize="false" id="N0560">        Case "Linux" : PathDelimiter = ":"</paragraph>
+        <paragraph role="bascode" localize="false" id="N0561">        Case "Windows" : PathDelimiter = ";"</paragraph>
+        <paragraph role="bascode" localize="false" id="N0562">     End Select</paragraph>
+        <paragraph role="bascode" localize="false" id="N0563">End Property ' Platform.PathDelimiter</paragraph>
+    </bascode>
+    <h2 id="N0564">Examples:</h2>
+    <paragraph role="paragraph" id="N0565">With Python</paragraph>
+    <paragraph role="paragraph" localize="false" id="N0566"><literal>>>> from <the_module> import Platform</literal></paragraph>
+    <paragraph role="paragraph" xml-lang="en-US" id="N0567"><literal>>>> print(Platform().isMacOSX)  # object property</literal></paragraph>
+    <paragraph role="paragraph" localize="false" id="N0568"><literal>True</literal></paragraph>
+    <paragraph role="paragraph" xml-lang="en-US" id="N0569"><literal>>>> input(Platform().OSName)  # object property</literal></paragraph>
+    <paragraph role="paragraph" localize="false" id="N0570"><literal>Darwin</literal></paragraph>
+    <paragraph role="paragraph" id="N0571">
+        From <menuitem>Tools – Macros - Run Macro...</menuitem> menu.</paragraph>
+    <pycode>
+        <paragraph role="pycode" localize="false" id="N0572">from <the_module> import Platform</paragraph>
+        <paragraph role="pycode" localize="false" id="N0573">import screen_io as ui</paragraph>
+        <paragraph role="pycode" localize="false" id="N0574">p = Platform()</paragraph>
+        <paragraph role="pycode" localize="false" id="N0575">ui.MsgBox(''.join(['isMacOS: ',str(p.isMacOSX)]),0,p.OSName)</paragraph>
+    </pycode>
+    <paragraph role="paragraph" id="N0576">With %PRODUCTNAME Basic</paragraph>
+    <bascode>
+        <paragraph role="bascode" localize="false" id="N0577">Sub Platform_example()</paragraph>
+        <paragraph role="bascode" xml-lang="en-US" id="N0578">    Dim p As New Platform ' instance of Platform class</paragraph>
+        <paragraph role="bascode" xml-lang="en-US" id="N0579">    MsgBox p.isLinux ' object property</paragraph>
+        <paragraph role="bascode" xml-lang="en-US" id="N0580">    Print p.isWindows, p.OSName ' object properties</paragraph>
+        <paragraph role="bascode" localize="false" id="N0581">End Sub ' Platform_example</paragraph>
+    </bascode>
+    <section id="relatedTopics">
+        <embed href="text/sbasic/python/python_screen.xhp#ioscreen"/>
+        <embed href="text/sbasic/shared/03132100.xhp#getguitype2"/>
+        <embed href="text/sbasic/shared/GetPathSeparator.xhp#getpathseparator01"/>
+<!--
+        <paragraph role="paragraph" id="N0585">
+            <link href="text/sbasic/python/python_from_basic.xhp">Basic to Python function calls</link>
+        </paragraph>-->
+        <embed href="text/sbasic/python/python_examples.xhp#pythonexamples2"/>
+    </section>
+</body>
+</helpdocument>
diff --git a/source/text/sbasic/shared/03132100.xhp b/source/text/sbasic/shared/03132100.xhp
index 07527ed07..0f04fb8fc 100644
--- a/source/text/sbasic/shared/03132100.xhp
+++ b/source/text/sbasic/shared/03132100.xhp
@@ -29,7 +29,7 @@
       <section id="getguitype">
 <bookmark xml-lang="en-US" branch="index" id="bm_id3147143"><bookmark_value>GetGuiType function</bookmark_value>
 </bookmark>
-<paragraph xml-lang="en-US" id="hd_id3155310" role="heading" level="1"><link href="text/sbasic/shared/03132100.xhp" name="GetGuiType Function">GetGuiType Function</link></paragraph>
+<h1 id="hd_id3155310"><variable id="getguitype2"><link href="text/sbasic/shared/03132100.xhp" name="GetGuiType Function">GetGuiType Function</link></variable></h1>
          <paragraph xml-lang="en-US" id="par_id3152459" role="paragraph">Returns a numerical value that specifies the graphical user interface.</paragraph>
       </section>
       <paragraph xml-lang="en-US" id="par_id3153323" role="paragraph">This function is only provided for downward compatibility to previous versions. The return value is not defined in client-server environments.</paragraph>
diff --git a/source/text/sbasic/shared/GetPathSeparator.xhp b/source/text/sbasic/shared/GetPathSeparator.xhp
index 7b1215c58..6efe46456 100644
--- a/source/text/sbasic/shared/GetPathSeparator.xhp
+++ b/source/text/sbasic/shared/GetPathSeparator.xhp
@@ -19,8 +19,8 @@
         <bookmark_value>GetPathSeparator function</bookmark_value>
     </bookmark>
     <section id="getpathseparator">
-        <paragraph role="heading" level="1"  id="N0002"><link href="text/sbasic/shared/GetPathSeparator.xhp" name="GetPathSeparator">GetPathSeparator Function</link></paragraph>
-        <paragraph role="paragraph"  id="N0003">Return the operating system-dependent directory separator used to specify file paths.</paragraph>
+        <paragraph role="heading" level="1"  id="N0002"><variable id="getpathseparator01"><link href="text/sbasic/shared/GetPathSeparator.xhp" name="GetPathSeparator">GetPathSeparator Function</link></variable></paragraph>
+        <paragraph role="paragraph"  id="N0003">Returns the operating system-dependent directory separator used to specify file paths.</paragraph>
     </section>
     <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
     <paragraph role="code"  id="N0005" localize="false">GetPathSeparator()</paragraph>


More information about the Libreoffice-commits mailing list