Hello people,
While trying to translate some Java code to Basic, I had some problems
with new-style UNO service constructors
(http://api.openoffice.org/docs/DevelopersGuide/ProfUNO/ProfUNO.xhtml#1_2_1_4_2_Service_Constructors)
For example, executing the Extension Manager dialog in Java can be done
with some code like [1].
May be I'm wrong, but I remember that in Basic we had (2.2.1 ?) to
instantiate the service and then call initialize passing the chosen
contructor's parameters [2].
But initialize() fails. The only way I've found to make things work in
Basic is using createInstanceWithArguments() [3].
My question: initialize() does not work anymore? is
createInstanceWithArguments() the definitive and final way to use
new-style Service Constructors in Basic? or will this change in the future?
Bye and thanks,
Ariel.
**********************************************************************
[1]
public static void main(String[] args) {
try {
XComponentContext xContext = Bootstrap.bootstrap();
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
XDesktop.class,
xContext.getServiceManager().createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext));
XFrame xFrame = xDesktop.getCurrentFrame();
XAsynchronousExecutableDialog oPackageManagerDlg;
if ( xFrame != null ) {
XWindow xContainerWindow = xFrame.getContainerWindow();
oPackageManagerDlg = PackageManagerDialog.create(
xContext, xContainerWindow, "shared");
} else {
oPackageManagerDlg =
PackageManagerDialog.createDefault(xContext);
}
oPackageManagerDlg.setDialogTitle("This is a test");
oPackageManagerDlg.startExecuteModal( new
XDialogClosedListener() {
public void dialogClosed(DialogClosedEvent e) {
System.out.println("dialog closed");
}
public void disposing(EventObject e) {
System.out.println("dialog disposed");
}
});
} catch (BootstrapException ex) {
ex.printStackTrace();
} catch (com.sun.star.uno.DeploymentException ex) {
ex.printStackTrace();
} catch (com.sun.star.uno.Exception ex) {
ex.printStackTrace();
} finally {
System.exit(0);
}
}
***********************************************************************
[2]
Sub TEST_1
Dim oPackagemanager as Object, oListener as Object
oPackagemanager =
createUnoService("com.sun.star.deployment.ui.PackageManagerDialog")
oPackagemanager.initialize(Array(ThisComponent.CurrentController.Frame.ContainerWindow,"shared"))
oPackagemanager.setDialogTitle("This is a test")
oListener = createUnoListener("testPackageManagerDialog_",
"com.sun.star.ui.dialogs.XDialogClosedListener")
oPackagemanager.startExecuteModal(oListener)
End Sub
Sub testPackageManagerDialog_dialogClosed(oEv as Object)
End Sub
Sub testPackageManagerDialog_disposing(oEv as Object)
ENd Sub
**************************************************************************
[3]
Sub TEST_2
Dim oPackagemanager as Object, oListener as Object
oPackagemanager = GetProcessServiceManager.createInstanceWithArguments(_
"com.sun.star.deployment.ui.PackageManagerDialog", _
Array(ThisComponent.CurrentController.Frame.ContainerWindow,"shared"))
oPackagemanager.setDialogTitle("This is a test")
oListener = createUnoListener("testPackageManagerDialog_",
"com.sun.star.ui.dialogs.XDialogClosedListener")
oPackagemanager.startExecuteModal(oListener)
End Sub
***********************************************************************
--
Ariel Constenla-Haile
La Plata, Argentina
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.arielconstenlahaile.com.ar/ooo/
"Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter."
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]