new-style service and create with arguments

Lionel Elie Mamane lionel at mamane.lu
Mon May 13 23:21:39 PDT 2013


Hi,

With regards to adapting UNO services to "new style", the case of
com.sun.star.sdb.tools.ConnectionTools.

It used to be invoked as follows (in file dbaccess/source/core/dataaccess/connection.cxx, method ):

    m_xConnectionTools.set(
        m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.sdb.tools.ConnectionTools", aArguments, m_aContext),
        UNO_QUERY_THROW );

The "convert to new style" commit (002aab309055b7feeeeeb25c1835b6abe6646729)

changed that to:

    m_xConnectionTools = css::sdb::tools::ConnectionTools::create( m_aContext );

Which ignores aArguments, which creates a regression because
aArguments actually contained information that was needed...

So, I've added:

    assert(Reference< XInitialization >(m_xConnectionTools, UNO_QUERY).is());
    Reference< XInitialization > xInit(m_xConnectionTools, UNO_QUERY_THROW );
    xInit->initialize(aArguments);

This seems to work.

But my question is: is this the new idiomatic way to invoke a service
with arguments, or can I make some change to the newly-introduced
offapi/com/sun/star/sdb/tools/ConnectionTools.idl so that the service
has e.g. some createWithArguments method instead of only "create"? Or
is there some wrapper that will do the above xInit-dance for me or
some such?

-- 
Lionel


More information about the LibreOffice mailing list