summaryrefslogtreecommitdiff
path: root/wizards/source/sfdialogs/SF_Register.xba
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/source/sfdialogs/SF_Register.xba')
-rw-r--r--wizards/source/sfdialogs/SF_Register.xba47
1 files changed, 31 insertions, 16 deletions
diff --git a/wizards/source/sfdialogs/SF_Register.xba b/wizards/source/sfdialogs/SF_Register.xba
index 0bda31d48ebe..fc3dbf54008c 100644
--- a/wizards/source/sfdialogs/SF_Register.xba
+++ b/wizards/source/sfdialogs/SF_Register.xba
@@ -226,6 +226,7 @@ Public Function _NewDialog(Optional ByVal pvArgs As Variant) As Object
''' Library: the name of the library hosting the dialog. Default = "Standard"
''' DialogName: The name of the dialog
''' Library and dialog names are case-sensitive
+''' Context: When called from Python, the context must be provided : XSCRIPTCONTEXT
''' Returns: the instance or Nothing
Dim oDialog As Object ' Return value
@@ -233,11 +234,14 @@ Dim vContainer As Variant ' Alias of pvArgs(0)
Dim vLibrary As Variant ' Alias of pvArgs(1)
Dim vDialogName As Variant ' Alias of pvArgs(2)
Dim oLibraries As Object ' com.sun.star.comp.sfx2.DialogLibraryContainer
-Dim oLibrary As Object ' com.sun.star.container.XNameAccess
+Dim vContext As Variant ' com.sun.star.uno.XComponentContext
Dim oDialogProvider As Object ' com.sun.star.io.XInputStreamProvider
Dim oEnum As Object ' com.sun.star.container.XEnumeration
Dim oComp As Object ' com.sun.star.lang.XComponent
+Dim oDialogControl As Object ' com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
Dim vWindow As Window ' A single component
+Dim sScope As String ' "application" or "document"
+Dim sURI As String ' URI of the targeted dialog
Dim oUi As Object ' "UI" service
Dim bFound As Boolean ' True if WindowName is found on the desktop
Const cstService = "SFDialogs.Dialog"
@@ -255,16 +259,18 @@ Check:
If Not ScriptForge.SF_Utils._Validate(vContainer, "Container", Array(V_STRING, ScriptForge.V_OBJECT)) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(vLibrary, "Library", V_STRING) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(vDialogName, "DialogName", V_STRING) Then GoTo Finally
+ If UBound(pvArgs) >= 3 Then vContext = pvArgs(3) Else vContext = Nothing
+ If Not ScriptForge.SF_Utils._Validate(vContext, "DialogName", V_OBJECT) Then GoTo Finally
Set oDialog = Nothing
Try:
- ' Determine the container and the library hosting the dialog
- Set oLibraries = Nothing
+ ' Determine the library container hosting the dialog
+ Set oUi = ScriptForge.SF_Register.CreateScriptService("UI")
+ Set oComp = Nothing
If VarType(vContainer) = V_STRING Then
- If UCase(vContainer) = UCase(cstGlobal) Then Set oLibraries = GlobalScope.DialogLibraries
+ bFound = ( UCase(vContainer) = UCase(cstGlobal) )
End If
- If IsNull(oLibraries) Then
- Set oUi = ScriptForge.SF_Register.CreateScriptService("UI")
+ If Not bFound Then
Select Case VarType(vContainer)
Case V_STRING
If Len(vContainer) > 0 Then
@@ -294,19 +300,27 @@ Try:
End Select
If Not bFound Then GoTo CatchNotFound
If Len(vWindow.DocumentType) = 0 Then GoTo CatchNotFound
- ' The library is now fully determined
- Set oLibraries = oComp.DialogLibraries
End If
- ' Load the library and get the dialog
- With oLibraries
- If Not .hasByName(vLibrary) Then GoTo CatchNotFound
- If Not .isLibraryLoaded(vLibrary) Then .loadLibrary(vLibrary)
- Set oLibrary = .getByName(vLibrary)
- If Not oLibrary.hasByName(vDialogName) Then GoTo CatchNotFound
- Set oDialogProvider = oLibrary.getByName(vDialogName)
- End With
+ ' Determine the dialog provider
+ Select Case True
+ Case IsNull(vContext) And IsNull(oComp) ' Basic and GlobalScope
+ Set oDialogProvider = GetProcessServiceManager.createInstance("com.sun.star.awt.DialogProvider")
+ Case IsNull(vContext) And Not IsNull(oComp) ' Basic and Document
+ Set oDialogProvider = GetProcessServiceManager.createInstanceWithArguments("com.sun.star.awt.DialogProvider", Array(oComp))
+ Case Not IsNull(vContext) And IsNull(oComp) ' Python and GlobalScope
+ Set oDialogProvider = vContext.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider", vContext)
+ Case Not IsNull(vContext) And Not IsNull(oComp) ' Python and Document
+ Set oDialogProvider = vContext.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider", Array(oComp))
+ End Select
+
+ ' Create the graphcal interface
+ sScope = Iif(IsNull(oComp), "application", "document")
+ sURI = "vnd.sun.star.script:" & vLibrary & "." & vDialogName & "?location=" & sScope
+ On Local Error GoTo CatchNotFound
+ Set oDialogControl = oDialogProvider.createDialog(sURI)
+ ' Initialize the basic SF_Dialog instance to return to the user script
Set oDialog = New SF_Dialog
With oDialog
Set .[Me] = oDialog
@@ -314,6 +328,7 @@ Try:
._Library = vLibrary
._Name = vDialogName
Set ._DialogProvider = oDialogProvider
+ Set ._DialogControl = oDialogControl
._Initialize()
End With