diff options
author | LibreOfficiant <LibreOfficiant@sfr.fr> | 2019-05-20 10:06:15 +0200 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2019-05-20 15:35:09 +0200 |
commit | 4f954243e76c64fb09489cb5f501e395bf37e6ca (patch) | |
tree | 560320662f1dd40ce2de9839e8447b4670cd3f90 /source | |
parent | 9e082dd83b0203f1035f9fc4e95380034b68ae8e (diff) |
- Partial refactoring using API calls
- New bookmarks
- Link from Basic Adv libraries to Platform page
Caution: Please fix GlobalScope miss in </bascode> parser in the first place!
Change-Id: Ifeaa98d5491b659a1dddbdbe3dddc417779374cf
Reviewed-on: https://gerrit.libreoffice.org/72583
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'source')
-rw-r--r-- | source/text/sbasic/python/python_platform.xhp | 34 | ||||
-rw-r--r-- | source/text/sbasic/shared/03/lib_tools.xhp | 3 | ||||
-rw-r--r-- | source/text/sbasic/shared/03132100.xhp | 3 |
3 files changed, 29 insertions, 11 deletions
diff --git a/source/text/sbasic/python/python_platform.xhp b/source/text/sbasic/python/python_platform.xhp index 7ee0b379f9..acad02559f 100644 --- a/source/text/sbasic/python/python_platform.xhp +++ b/source/text/sbasic/python/python_platform.xhp @@ -21,10 +21,12 @@ <bookmark_value>Platform;isWindows</bookmark_value> <bookmark_value>Platform;ComputerName</bookmark_value> <bookmark_value>Platform;OSName</bookmark_value> + <bookmark_value>API;ConfigurationAccess</bookmark_value> + <bookmark_value>Tools;GetRegistryContent</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> + <note id="N0511">ComputerName property is solely available for Windows. Basic calls to Python macros help overcome %PRODUCTNAME Basic limitations.</note> <h2 id="N0512">Using a Python class:</h2> <pycode> <paragraph role="pycode" localize="false" id="N0513">import os, platform</paragraph> @@ -45,7 +47,8 @@ <paragraph role="pycode" localize="false" id="N0528"> def PathDelimiter(self): return os.pathsep</paragraph> </pycode> <h2 id="N0529">Using a Basic classmodule:</h2> - <bascode> + <tip id="NO529b">%PRODUCTNAME Basic lacks MacOS X native recognition. Platform identification is possible using %PRODUCTNAME Application Programming Interface (API).</tip> + <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> @@ -59,24 +62,33 @@ <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="N0543"> isLinux = ( GetGUIType()=4 ) ' Applies to MacOS 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="M0542">Public Property Get IsMacOSX As Boolean</paragraph> + <paragraph role="bascode" localize="false" id="M0543"> isMacOSX = ( OSName="MAC" )</paragraph> + <paragraph role="bascode" localize="false" id="M0544">End Property ' Platform.isMacOSX</paragraph> + <paragraph role="bascode" localize="false" id="M0545"></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="N0551"> ' Return platform name as "MAC", "UNIX", "WIN"</paragraph> + <paragraph role="bascode" localize="false" id="N0551"> ' Inferred from "Tools.UCB.ShowHelperDialog" function</paragraph> + <!-- <paragraph role="bascode" localize="false" id="N0552"> With GlobalScope.Basiclibraries</paragraph>--> + <paragraph role="bascode" localize="false" id="N0552"> With Basiclibraries</paragraph> <!-- to replace with line above --> + <paragraph role="bascode" localize="false" id="M0552"> If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")</paragraph> + <paragraph role="bascode" localize="false" id="O0552"> End With</paragraph> + <paragraph role="bascode" localize="false" id="N0553"> Dim keyNode As Object 'com.sun.star.configuration.ConfigurationAccess</paragraph> + <paragraph role="bascode" localize="false" id="M0553"> keyNode = Tools.Misc.GetRegistryKeyContent("org.openoffice.Office.Common/Help")</paragraph> + <paragraph role="bascode" localize="false" id="N0554"> OSName = keyNode.GetByName("System")</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="N0560"> Case "MAC", "UNIX" : PathDelimiter = ":"</paragraph> + <paragraph role="bascode" localize="false" id="N0561"> Case "WIN" : 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> @@ -107,7 +119,7 @@ <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"/> -<!-- +<!--WIP <paragraph role="paragraph" id="N0585"> <link href="text/sbasic/python/python_from_basic.xhp">Basic to Python function calls</link> </paragraph>--> @@ -115,4 +127,4 @@ <embed href="text/sbasic/python/main0000.xhp#pythonscriptshelp"/> </section> </body> -</helpdocument> +</helpdocument>
\ No newline at end of file diff --git a/source/text/sbasic/shared/03/lib_tools.xhp b/source/text/sbasic/shared/03/lib_tools.xhp index dcf6950a48..dac54b1688 100644 --- a/source/text/sbasic/shared/03/lib_tools.xhp +++ b/source/text/sbasic/shared/03/lib_tools.xhp @@ -1592,5 +1592,8 @@ </tablerow> </table> </section> + <section id="relatedTopics"> + <embed href="text/sbasic/python/python_platform.xhp#pythonplatform"/> + </section> </body> </helpdocument> diff --git a/source/text/sbasic/shared/03132100.xhp b/source/text/sbasic/shared/03132100.xhp index 0f04fb8fca..88aaa15719 100644 --- a/source/text/sbasic/shared/03132100.xhp +++ b/source/text/sbasic/shared/03132100.xhp @@ -48,6 +48,9 @@ <paragraph xml-lang="en-US" id="par_id3145609" role="bascode" localize="false"> MsgBox GetGUIType</paragraph> <paragraph xml-lang="en-US" id="par_id3145069" role="bascode" localize="false">End Sub</paragraph> </bascode> + <section id="relatedTopics"> + <embed href="text/sbasic/python/python_platform.xhp#pythonplatform"/> + </section> </body> </helpdocument> |