summaryrefslogtreecommitdiff
path: root/wizards/source
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2022-02-27 14:04:12 +0100
committerJean-Pierre Ledure <jp@ledure.be>2022-02-27 15:27:15 +0100
commit740329373b2fe2c4f7c18ff1921e2f100d49a6bf (patch)
tree09b031ddaa6a8e457bef3af1c434245328e3b3cd /wizards/source
parent794f3a07b94d134c0393b5f804b8afaca3e20e59 (diff)
ScriptForge - (SF_Platform) add the FilterNames property
The FilterNames property returns, as an unsorted zero-based array of strings, the list of available/installed import and export filters for components. The property can serve as support for the FilterName argument used for opening and saving documents. The FilterNames property is available both from Basic and Python user scripts. Change-Id: I607500b56836ceeb6716b10d39d22638b0741f3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130624 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards/source')
-rw-r--r--wizards/source/scriptforge/SF_Platform.xba14
-rw-r--r--wizards/source/scriptforge/python/scriptforge.py8
2 files changed, 18 insertions, 4 deletions
diff --git a/wizards/source/scriptforge/SF_Platform.xba b/wizards/source/scriptforge/SF_Platform.xba
index 33bbf7877b9e..8403866fffe8 100644
--- a/wizards/source/scriptforge/SF_Platform.xba
+++ b/wizards/source/scriptforge/SF_Platform.xba
@@ -83,6 +83,15 @@ Property Get Extensions() As Variant
End Property &apos; ScriptForge.SF_Platform.Extensions (get)
REM -----------------------------------------------------------------------------
+Property Get FilterNames() As Variant
+&apos;&apos;&apos; Returns the list of available document import and export filter names as an unsorted array of unique strings
+&apos;&apos;&apos; To get the list sorted, use SF_Array.Sort()
+&apos;&apos;&apos; Example:
+&apos;&apos;&apos; myFilterNamesList = platform.FilterNames
+ FilterNames = _PropertyGet(&quot;FilterNames&quot;)
+End Property &apos; ScriptForge.SF_Platform.FilterNames (get)
+
+REM -----------------------------------------------------------------------------
Property Get Fonts() As Variant
&apos;&apos;&apos; Returns the list of available fonts as an unsorted array of unique strings
&apos;&apos;&apos; To get the list sorted, use SF_Array.Sort()
@@ -261,6 +270,7 @@ Public Function Properties() As Variant
, &quot;CPUCount&quot; _
, &quot;CurrentUser&quot; _
, &quot;Extensions&quot; _
+ , &quot;FilterNames&quot; _
, &quot;Fonts&quot; _
, &quot;FormatLocale&quot; _
, &quot;Locale&quot; _
@@ -357,6 +367,7 @@ Dim oLocale As Object &apos; com.sun.star.lang.Locale
Dim oPrinterServer As Object &apos; com.sun.star.awt.PrinterServer
Dim oToolkit As Object &apos; com.sun.star.awt.Toolkit
Dim oDevice As Object &apos; com.sun.star.awt.XDevice
+Dim oFilterFactory As Object &apos; com.sun.star.document.FilterFactory
Dim oFontDescriptors As Variant &apos; Array of com.sun.star.awt.FontDescriptor
Dim sFonts As String &apos; Comma-separated list of fonts
Dim sFont As String &apos; A single font name
@@ -385,6 +396,9 @@ Const cstSubArgs = &quot;&quot;
sExtensions = sExtensions &amp; &quot;,&quot; &amp; vExtensionsList(i)(0)
Next i
If Len(sExtensions) &gt; 0 Then _PropertyGet = Split(Mid(sExtensions, 2), &quot;,&quot;) Else _PropertyGet = Array()
+ Case &quot;FilterNames&quot;
+ Set oFilterFactory = SF_Utils._GetUNOService(&quot;FilterFactory&quot;)
+ _PropertyGet = oFilterFactory.getElementNames()
Case &quot;Fonts&quot;
Set oToolkit = SF_Utils._GetUnoService(&quot;Toolkit&quot;)
Set oDevice = oToolkit.createScreenCompatibleDevice(0, 0)
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index dea3a9854ebf..d9fac9c26d5e 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1234,10 +1234,10 @@ class SFScriptForge:
servicename = 'ScriptForge.Platform'
servicesynonyms = ('platform', 'scriptforge.platform')
serviceproperties = dict(Architecture = False, ComputerName = False, CPUCount = False, CurrentUser = 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)
+ Extensions = False, FilterNames = 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'