diff options
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/scriptforge/SF_FileSystem.xba | 42 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Platform.xba | 20 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Root.xba | 2 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Utils.xba | 7 | ||||
-rw-r--r-- | wizards/source/scriptforge/python/scriptforge.py | 11 |
5 files changed, 76 insertions, 6 deletions
diff --git a/wizards/source/scriptforge/SF_FileSystem.xba b/wizards/source/scriptforge/SF_FileSystem.xba index d71937d6e64a..935c559f5c8e 100644 --- a/wizards/source/scriptforge/SF_FileSystem.xba +++ b/wizards/source/scriptforge/SF_FileSystem.xba @@ -86,7 +86,7 @@ End Property ' ScriptForge.SF_FileSystem.ConfigFolder REM ----------------------------------------------------------------------------- Property Get ExtensionsFolder() As String -''' Return the folder containing the installed extensions +''' Return the folder containing the extensions installed for the current user Dim oMacro As Object ' /singletons/com.sun.star.util.theMacroExpander Const cstThisSub = "FileSystem.getExtensionsFolder" @@ -651,6 +651,45 @@ Catch: End Function ' ScriptForge.SF_FileSystem.DeleteFolder REM ----------------------------------------------------------------------------- +Public Function ExtensionFolder(Optional ByVal Extension As Variant) As String +''' Return the folder where the given extension is installed. The argument must +''' be in the list of extensions provided by the SF_Platform.Extensions property +''' Args: +''' Extension: a valid extension name +''' Returns: +''' The requested folder using the FileNaming notation +''' Example: +''' MsgBox FSO.ExtensionFolder("apso.python.script.organizer") + +Dim sFolder As String ' Return value +Static vExtensions As Variant ' Cached list of existing extension names +Dim oPackage As Object ' /singletons/com.sun.star.deployment.PackageInformationProvider +Const cstThisSub = "FileSystem.ExtensionFolder" +Const cstSubArgs = "Extension" + + If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch + sFolder = "" + +Check: + If IsEmpty(vExtensions) Then vExtensions = SF_Platform.Extensions + If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then + If Not SF_Utils._Validate(Extension, "Extension", V_STRING, vExtensions) Then GoTo Finally + End If + +Try: + ' Search an individual folder + Set oPackage = SF_Utils._GetUnoService("PackageInformationProvider") + sFolder = oPackage.getPackageLocation(Extension) + +Finally: + ExtensionFolder = SF_FileSystem._ConvertFromUrl(sFolder) + SF_Utils._ExitFunction(cstThisSub) + Exit Function +Catch: + GoTo Finally +End Function ' ScritForge.SF_FileSystem.ExtensionFolder + +REM ----------------------------------------------------------------------------- Public Function FileExists(Optional ByVal FileName As Variant) As Boolean ''' Return True if the given file exists ''' Args: @@ -1215,6 +1254,7 @@ Public Function Methods() As Variant , "CreateTextFile" _ , "DeleteFile" _ , "DeleteFolder" _ + , "ExtensionFolder" _ , "FileExists" _ , "Files" _ , "FolderExists" _ diff --git a/wizards/source/scriptforge/SF_Platform.xba b/wizards/source/scriptforge/SF_Platform.xba index 8bd7b5cad35f..33bbf7877b9e 100644 --- a/wizards/source/scriptforge/SF_Platform.xba +++ b/wizards/source/scriptforge/SF_Platform.xba @@ -74,6 +74,15 @@ Property Get CurrentUser() As String End Property ' ScriptForge.SF_Platform.CurrentUser (get) REM ----------------------------------------------------------------------------- +Property Get Extensions() As Variant +''' Returns the list of availableeExtensions as an unsorted array of unique strings +''' To get the list sorted, use SF_Array.Sort() +''' Example: +''' myExtensionsList = platform.Extensions + Extensions = _PropertyGet("Extensions") +End Property ' ScriptForge.SF_Platform.Extensions (get) + +REM ----------------------------------------------------------------------------- Property Get Fonts() As Variant ''' Returns the list of available fonts as an unsorted array of unique strings ''' To get the list sorted, use SF_Array.Sort() @@ -251,6 +260,7 @@ Public Function Properties() As Variant , "ComputerName" _ , "CPUCount" _ , "CurrentUser" _ + , "Extensions" _ , "Fonts" _ , "FormatLocale" _ , "Locale" _ @@ -350,6 +360,9 @@ Dim oDevice As Object ' com.sun.star.awt.XDevice Dim oFontDescriptors As Variant ' Array of com.sun.star.awt.FontDescriptor Dim sFonts As String ' Comma-separated list of fonts Dim sFont As String ' A single font name +Dim vExtensionsList As Variant ' Array of extension descriptors +Dim sExtensions As String ' Comma separated list of extensions +Dim sExtension As String ' A single extension name Dim i As Long Const cstPyHelper = "$" & "_SF_Platform" @@ -365,6 +378,13 @@ Const cstSubArgs = "" With ScriptForge.SF_Session _PropertyGet = .ExecutePythonScript(.SCRIPTISSHARED, _SF_.PythonHelper & cstPyHelper, psProperty) End With + Case "Extensions" + Set vExtensionsList = SF_Utils._GetUnoService("PackageInformationProvider").ExtensionList + sExtensions = "" + For i = 0 To UBound(vExtensionsList) + sExtensions = sExtensions & "," & vExtensionsList(i)(0) + Next i + If Len(sExtensions) > 0 Then _PropertyGet = Split(Mid(sExtensions, 2), ",") Else _PropertyGet = Array() Case "Fonts" Set oToolkit = SF_Utils._GetUnoService("Toolkit") Set oDevice = oToolkit.createScreenCompatibleDevice(0, 0) diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba index d14e121173cd..7df7cd3957a6 100644 --- a/wizards/source/scriptforge/SF_Root.xba +++ b/wizards/source/scriptforge/SF_Root.xba @@ -73,6 +73,7 @@ Private BrowseNodeFactory As Object ' com.sun.star.script.browse.BrowseNode Private DatabaseContext As Object ' com.sun.star.sdb.DatabaseContext Private ConfigurationProvider _ As Object ' com.sun.star.configuration.ConfigurationProvider +Private PackageProvider As Object ' com.sun.star.comp.deployment.PackageInformationProvider Private MailService As Object ' com.sun.star.system.SimpleCommandMail or com.sun.star.system.SimpleSystemMail Private GraphicExportFilter As Object ' com.sun.star.drawing.GraphicExportFilter Private Toolkit As Object ' com.sun.star.awt.Toolkit @@ -138,6 +139,7 @@ Private Sub Class_Initialize() Set BrowseNodeFactory = Nothing Set DatabaseContext = Nothing Set ConfigurationProvider = Nothing + Set PackageProvider = Nothing Set MailService = Nothing Set GraphicExportFilter = Nothing Set Toolkit = Nothing diff --git a/wizards/source/scriptforge/SF_Utils.xba b/wizards/source/scriptforge/SF_Utils.xba index cbe07ce2b0ae..2ca9a6fe09d3 100644 --- a/wizards/source/scriptforge/SF_Utils.xba +++ b/wizards/source/scriptforge/SF_Utils.xba @@ -21,7 +21,7 @@ REM ===================================================================== GLOBAL Global _SF_ As Variant ' SF_Root (Basic) object) ''' ScriptForge version -Const SF_Version = "7.3" +Const SF_Version = "7.4" ''' Standard symbolic names for VarTypes ' V_EMPTY = 0 @@ -415,6 +415,11 @@ Dim oDefaultContext As Object .OfficeLocale.Country = Right(sLocale, 2) End If Set _GetUNOService = .OfficeLocale + Case "PackageInformationProvider" + If IsEmpty(.PackageProvider) Or IsNull(.PackageProvider) Then + Set .PackageProvider = GetDefaultContext.getByName("/singletons/com.sun.star.deployment.PackageInformationProvider") + End If + Set _GetUNOService = .PackageProvider Case "PathSettings" If IsEmpty(.PathSettings) Or IsNull(.PathSettings) Then Set .PathSettings = CreateUnoService("com.sun.star.util.PathSettings") diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py index 7edc737acec4..5eb0b08a5863 100644 --- a/wizards/source/scriptforge/python/scriptforge.py +++ b/wizards/source/scriptforge/python/scriptforge.py @@ -1095,6 +1095,9 @@ class SFScriptForge: def DeleteFolder(self, foldername): return self.ExecMethod(self.vbMethod, 'DeleteFolder', foldername) + def ExtensionFolder(self, extension): + return self.ExecMethod(self.vbMethod, 'ExtensionFolder', extension) + def FileExists(self, filename): return self.ExecMethod(self.vbMethod, 'FileExists', filename) @@ -1218,10 +1221,10 @@ class SFScriptForge: servicename = 'ScriptForge.Platform' servicesynonyms = ('platform', 'scriptforge.platform') serviceproperties = dict(Architecture = False, ComputerName = False, CPUCount = False, CurrentUser = False, - Fonts = False, FormatLocale = False, Locale = False, Machine = False, - OfficeLocale = False, OfficeVersion = False, OSName = False, OSPlatform = False, - OSRelease = False, OSVersion = False, Printers = False, Processor = False, - PythonVersion = False, SystemLocale = False) + Extensions = False, Fonts = False, FormatLocale = False, Locale = False, + Machine = False, OfficeLocale = False, OfficeVersion = False, OSName = False, + OSPlatform = False, OSRelease = False, OSVersion = False, Printers = False, + Processor = False, PythonVersion = False, SystemLocale = False) # Python helper functions py = ScriptForge.pythonhelpermodule + '$' + '_SF_Platform' |