Make getProcessComponentContext/ServiceFactory throw instead of returning null
...with the same rationale as recent 543158edba
"Require XComponentContext.getServiceManager to throw instead of returning null"
(this helps find problems like 065a758d0c2b66c6683d648347b7a6cdef4a80f7 "Enable
experimental gtk3 plugin only via SAL_USE_VCLPLUGIN").
Removed comphelper::createProcessComponent[WithAguments] and replaced its few
uses with direct calls to createInstance[WithArguments].
Change-Id: Ia44b8656f74de88ef6eab3eb6bd597729b08e1c8
This commit is contained in:
@@ -39,34 +39,17 @@ namespace comphelper
|
||||
COMPHELPER_DLLPUBLIC void setProcessServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr);
|
||||
|
||||
/**
|
||||
* This function get the process service factory. If no service factory is set the function returns
|
||||
* a null interface.
|
||||
* This function gets the process service factory.
|
||||
*
|
||||
* If no service factory is set the function throws a RuntimeException.
|
||||
*
|
||||
* @author Juergen Schmidt
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getProcessServiceFactory();
|
||||
|
||||
/** creates a component, using the process factory if set
|
||||
@see getProcessServiceFactory
|
||||
@see setProcessServiceFactory
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
|
||||
createProcessComponent(
|
||||
const ::rtl::OUString& _rServiceSpecifier
|
||||
) SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
|
||||
/** Obtains a component context from a service factory.
|
||||
|
||||
/** creates a component with arguments, using the process factory if set
|
||||
|
||||
@see getProcessServiceFactory
|
||||
@see setProcessServiceFactory
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
|
||||
createProcessComponentWithArguments(
|
||||
const ::rtl::OUString& _rServiceSpecifier,
|
||||
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArgs
|
||||
) SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
|
||||
|
||||
/** Tries to obtain a component context from a service factory.
|
||||
Throws a RuntimeException if no component context can be obtained.
|
||||
|
||||
@param factory may be null
|
||||
@return may be null
|
||||
@@ -79,7 +62,8 @@ getComponentContext(
|
||||
|
||||
/**
|
||||
* This function gets the process service factory's default component context.
|
||||
* If no service factory is set the function returns a null interface.
|
||||
*
|
||||
* Throws a RuntimeException if no component context can be obtained.
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
|
||||
#include "com/sun/star/beans/XPropertySet.hpp"
|
||||
|
||||
#include "com/sun/star/uno/DeploymentException.hpp"
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace com::sun::star::uno;
|
||||
@@ -59,32 +59,14 @@ Reference< XMultiServiceFactory > getProcessServiceFactory()
|
||||
{
|
||||
Reference< XMultiServiceFactory> xReturn;
|
||||
xReturn = localProcessFactory( xReturn, sal_False );
|
||||
if ( !xReturn.is() )
|
||||
{
|
||||
throw DeploymentException(
|
||||
"null process service factory", Reference< XInterface >() );
|
||||
}
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
Reference< XInterface > createProcessComponent( const ::rtl::OUString& _rServiceSpecifier ) SAL_THROW( ( RuntimeException ) )
|
||||
{
|
||||
Reference< XInterface > xComponent;
|
||||
|
||||
Reference< XMultiServiceFactory > xFactory( getProcessServiceFactory() );
|
||||
if ( xFactory.is() )
|
||||
xComponent = xFactory->createInstance( _rServiceSpecifier );
|
||||
|
||||
return xComponent;
|
||||
}
|
||||
|
||||
Reference< XInterface > createProcessComponentWithArguments( const ::rtl::OUString& _rServiceSpecifier,
|
||||
const Sequence< Any >& _rArgs ) SAL_THROW( ( RuntimeException ) )
|
||||
{
|
||||
Reference< XInterface > xComponent;
|
||||
|
||||
Reference< XMultiServiceFactory > xFactory( getProcessServiceFactory() );
|
||||
if ( xFactory.is() )
|
||||
xComponent = xFactory->createInstanceWithArguments( _rServiceSpecifier, _rArgs );
|
||||
|
||||
return xComponent;
|
||||
}
|
||||
|
||||
Reference< XComponentContext > getComponentContext(
|
||||
Reference< XMultiServiceFactory > const & factory)
|
||||
{
|
||||
@@ -96,9 +78,18 @@ Reference< XComponentContext > getComponentContext(
|
||||
RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ),
|
||||
uno::UNO_QUERY );
|
||||
}
|
||||
catch (beans::UnknownPropertyException const&) {
|
||||
catch (beans::UnknownPropertyException & e) {
|
||||
throw DeploymentException(
|
||||
"unknown service factory DefaultContext property: " + e.Message,
|
||||
Reference< XInterface >( factory, UNO_QUERY ) );
|
||||
}
|
||||
}
|
||||
if ( !xRet.is() )
|
||||
{
|
||||
throw DeploymentException(
|
||||
"no service factory DefaultContext",
|
||||
Reference< XInterface >( factory, UNO_QUERY ) );
|
||||
}
|
||||
return xRet;
|
||||
}
|
||||
|
||||
|
@@ -443,7 +443,7 @@ sal_Bool SvxAutoCorrect::FnChgOrdinalNumber(
|
||||
// Check if the characters after that number correspond to the ordinal suffix
|
||||
rtl::OUString sServiceName("com.sun.star.i18n.OrdinalSuffix");
|
||||
uno::Reference< i18n::XOrdinalSuffix > xOrdSuffix(
|
||||
comphelper::createProcessComponent( sServiceName ),
|
||||
comphelper::getProcessServiceFactory()->createInstance( sServiceName ),
|
||||
uno::UNO_QUERY );
|
||||
|
||||
if ( xOrdSuffix.is( ) )
|
||||
|
@@ -270,7 +270,7 @@ void AccessibleControlShape::Init()
|
||||
// finally, aggregate a proxy for the control context
|
||||
// first a factory for the proxy
|
||||
Reference< XProxyFactory > xFactory;
|
||||
xFactory = xFactory.query( createProcessComponent( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.ProxyFactory" ) ) ) );
|
||||
xFactory = xFactory.query( getProcessServiceFactory()->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.ProxyFactory" ) ) ) );
|
||||
OSL_ENSURE( xFactory.is(), "AccessibleControlShape::Init: could not create a proxy factory!" );
|
||||
// then the proxy itself
|
||||
if ( xFactory.is() && xNativeControlContext.is() )
|
||||
|
@@ -84,7 +84,7 @@ namespace toolkit
|
||||
{
|
||||
rbTriedCreation = true;
|
||||
rDefaultFormats = Reference< XNumberFormatsSupplier >(
|
||||
::comphelper::createProcessComponent(
|
||||
::comphelper::getProcessServiceFactory()->createInstance(
|
||||
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatsSupplier" ) ) ),
|
||||
UNO_QUERY_THROW
|
||||
);
|
||||
|
@@ -487,7 +487,7 @@ void DeInitVCL()
|
||||
try
|
||||
{
|
||||
uno::Reference<lang::XComponent> const xDesktop(
|
||||
comphelper::createProcessComponent(
|
||||
comphelper::getProcessServiceFactory()->createInstance(
|
||||
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),
|
||||
uno::UNO_QUERY_THROW)
|
||||
;
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "com/sun/star/container/XNameAccess.hpp"
|
||||
#include "com/sun/star/io/XInputStream.hpp"
|
||||
#include "com/sun/star/lang/Locale.hpp"
|
||||
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
|
||||
#include "com/sun/star/uno/Any.hxx"
|
||||
#include "com/sun/star/uno/Exception.hpp"
|
||||
#include "com/sun/star/uno/Reference.hxx"
|
||||
@@ -409,7 +410,7 @@ bool ImplImageTree::find(
|
||||
args[0] <<= i->first + ".zip";
|
||||
try {
|
||||
i->second.set(
|
||||
comphelper::createProcessComponentWithArguments(
|
||||
comphelper::getProcessServiceFactory()->createInstanceWithArguments(
|
||||
rtl::OUString( "com.sun.star.packages.zip.ZipFileAccess"),
|
||||
args),
|
||||
css::uno::UNO_QUERY_THROW);
|
||||
|
Reference in New Issue
Block a user