Hi,

one more info. Thinking again and talking with Andreas showed us that it can be a different problem. Some objects are not usable if not initialized and in that case the type provider doesn't work.

So the best solution is to have an additional shortcut createUnoServiceWithArguments(...) in Basic as well and the direct support of the service constructors ...

Juergen


Juergen Schmidt wrote:
Ariel Constenla-Haile wrote:
Hello Paolo,

Paolo Mantovani escribió:
In practice, if I well understand Frank's answer, using createWithArguments/AndContext/AndWhatever things it's not better than simply doing:

obj = CreateUNOService("service.name")
obj.initialize(Array(arg1, arg2, arg3))

because this is what (more or less) currently happens behind the scene

this simpler way will fail depending on how is the service implemented.
For example if we test this on the
com.sun.star.deployment.ui.PackageManagerDialog, with *this* new-style
service, one can not *first* call createUnoService() and *then*
initialize() passing to this last call the constructor's parameters,
because, as shown in the example bellow, initialize() "fails" == the
object returned by createUnoService() has no such method, as
XInitialization is not implemented.


'******************************************************************
REM "shared" opens the PackageManagerDialog with the shared layer selected REM "user" opens the PackageManagerDialog with the user layer selected
REM     This does not work in the new, OOo 3.0 dialog

Sub TEST_createInstanceWithArgumentsAndContext
        Dim oPackagemanager as Object, oListener as Object
    oPackagemanager = _
        GetProcessServiceManager.createInstanceWithArgumentsAndContext(_
            "com.sun.star.deployment.ui.PackageManagerDialog", _
            Array(_
ThisComponent.CurrentController.Frame.ContainerWindow,_
                    "user"_
                ),_
            GetDefaultContext()_
            )
               oPackagemanager.setDialogTitle("This is a test")

    oListener = createUnoListener(_
                    "testPackageManagerDialog_", _
                    "com.sun.star.ui.dialogs.XDialogClosedListener")
                       oPackagemanager.startExecuteModal(oListener)
End Sub

'**************************************************************************

Sub TEST_first_createUnoService_then_initialize_FAILS

    Dim oPackagemanager as Object, oListener as Object

    'first instantiate using createUnoService
    oPackagemanager = createUnoService(_
        "com.sun.star.deployment.ui.PackageManagerDialog")
           'then initialize...
    'FAILS!
    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

'***************************************************************************
[NOTE: this is just a demo, and not the way the PackageManagerDialog is
to be used, or at least not how it's used in
Oxt_Handler::dispatchWithNotification()
framework/source/dispatch/oxt_handler.cxx 1.3 202 ss. Here the
PackageManagerDialog is instantiated at the service manager, and then
XJobExecutor::trigger() is called ]

This *may* not apply to *all* new-styles services, but in *this* case
it's due to the way the PackageManagerDialog is implemented: as
::com::sun::star::lang::XInitialization is not implemented, there is no
way to call XInitialization::initialize().

Other services, for example the CopyTableWizard
(http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/application/CopyTableWizard.html)
has two constructors, but implements XInitialization, so first
createUnoService() and then initialize() *may* [didn't try it] work with it.
Anyway, we, API clients, shouldn't in theory get worried about how
things are implemented, and rely instead only in the specification...
And OOo Basic programmers should have a way to instantiate new style services at least as simple as createUnoService().
yes, of course the users shouldn't have to take care of this details. Ariel showed a bad example. There are probably some strange reasons why it doesn't work (some new sophisticated impl helper that doesn't support everything) and we should take a look on it.

But we still have on our todo list to support the new style service constructors in Basic directly. The prio isn't to high because it should normally work with the old mechanisms as well.

So please sty tuned, i hope we can support it for OO.org 3.1.

Python could support it also if somebody will start working on it. Otherwise it's the same problem as for Basic currently.

Juergen


Regards
Ariel.






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to