Hi Ariel,
well the constructor methods can't be used in Basic today. But we have
it on our todo list for the future.
createInstanceWithArgumentsAndContext is the way you have to go to
instantiate such a service in Basic. But keep in mind that if it is the
default constructor with only the context parameter a simple
createInstanceWithContext should be enough.
I would recommmend to use always the newer methods from the
XMulitComponentFactory with the Context because it should be used
everywhere.
Juergen
Ariel Constenla-Haile wrote:
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
***********************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]