diff options
author | Frank Schönheit <fs@openoffice.org> | 2002-12-05 08:03:49 +0000 |
---|---|---|
committer | Frank Schönheit <fs@openoffice.org> | 2002-12-05 08:03:49 +0000 |
commit | 0dd1fdb6ba73719487de88d269d1f7f054af20ac (patch) | |
tree | 0d0ea548f9b44810c0c238b2f47edc591b9c183b /unotools | |
parent | 01e119436ba0a2c5950afac54b38859899c19d40 (diff) |
#104427# +tryCreateWithServiceFactory
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/confignode.hxx | 16 | ||||
-rw-r--r-- | unotools/source/config/confignode.cxx | 43 |
2 files changed, 52 insertions, 7 deletions
diff --git a/unotools/inc/unotools/confignode.hxx b/unotools/inc/unotools/confignode.hxx index f6594d4e2542..d9c5ff5cb498 100644 --- a/unotools/inc/unotools/confignode.hxx +++ b/unotools/inc/unotools/confignode.hxx @@ -2,9 +2,9 @@ * * $RCSfile: confignode.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: fs $ $Date: 2001-08-21 12:40:00 $ + * last change: $Author: fs $ $Date: 2002-12-05 09:02:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -304,6 +304,15 @@ namespace utl static OConfigurationTreeRoot createWithServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_PREFER_UPDATABLE, sal_Bool _bLazyWrite = sal_True); + /** tolerant version of the <member>createWithServiceFactory</member> + + <p>No assertions are thrown in case of an failure to initialize the configuration service, but once + the configuration could be initialized, errors in the creation of the specific node (e.g. because the + given node path does not exist) are still asserted.</p> + */ + static OConfigurationTreeRoot tryCreateWithServiceFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, + const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_PREFER_UPDATABLE, sal_Bool _bLazyWrite = sal_True ); + /** commit all changes made on the subtree the object is the root for<p/> All changes made on any <type>OConfigurationNode</type> object retrieved (maybe indirect) from this root object are committed when calling this method. @@ -324,6 +333,9 @@ namespace utl /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/08/21 12:40:00 fs + * #87721# +hasByHierarchicalName + * * Revision 1.2 2001/07/26 09:13:23 oj * #89831# new method to append an existing node with different name * diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index e8cdf4268211..e27bb0d598b5 100644 --- a/unotools/source/config/confignode.cxx +++ b/unotools/source/config/confignode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: confignode.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: fs $ $Date: 2001-08-21 12:40:41 $ + * last change: $Author: fs $ $Date: 2002-12-05 09:03:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -612,6 +612,15 @@ namespace utl return sal_False; } + namespace + { + static const ::rtl::OUString& lcl_getProviderServiceName( ) + { + static ::rtl::OUString s_sProviderServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); + return s_sProviderServiceName; + } + } + //------------------------------------------------------------------------ OConfigurationTreeRoot OConfigurationTreeRoot::createWithProvider(const Reference< XMultiServiceFactory >& _rxConfProvider, const ::rtl::OUString& _rPath, sal_Int32 _nDepth, CREATION_MODE _eMode, sal_Bool _bLazyWrite) { @@ -629,7 +638,7 @@ namespace utl } else { - OSL_ENSURE(xSI->supportsService(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), + OSL_ENSURE(xSI->supportsService( lcl_getProviderServiceName( ) ), "OConfigurationTreeRoot::createWithProvider: sure this is a provider? Missing the ConfigurationProvider service!"); } } @@ -696,12 +705,12 @@ namespace utl //------------------------------------------------------------------------ OConfigurationTreeRoot OConfigurationTreeRoot::createWithServiceFactory(const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rPath, sal_Int32 _nDepth, CREATION_MODE _eMode, sal_Bool _bLazyWrite) { - OSL_ENSURE(_rxORB.is(), "OConfigurationTreeRoot::createWithServiceFactory: invalid provider!"); + OSL_ENSURE(_rxORB.is(), "OConfigurationTreeRoot::createWithServiceFactory: invalid service factory!"); if (_rxORB.is()) { try { - Reference< XInterface > xProvider = _rxORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))); + Reference< XInterface > xProvider = _rxORB->createInstance( lcl_getProviderServiceName( ) ); OSL_ENSURE(xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: could not instantiate the config provider service!"); Reference< XMultiServiceFactory > xProviderAsFac(xProvider, UNO_QUERY); OSL_ENSURE(xProviderAsFac.is() || !xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: the provider is missing an interface!"); @@ -716,6 +725,27 @@ namespace utl return OConfigurationTreeRoot(); } + //------------------------------------------------------------------------ + OConfigurationTreeRoot OConfigurationTreeRoot::tryCreateWithServiceFactory( const Reference< XMultiServiceFactory >& _rxORB, + const ::rtl::OUString& _rPath, sal_Int32 _nDepth , CREATION_MODE _eMode , sal_Bool _bLazyWrite ) + { + OSL_ENSURE( _rxORB.is(), "OConfigurationTreeRoot::tryCreateWithServiceFactory: invalid service factory!" ); + if ( _rxORB.is() ) + { + try + { + Reference< XMultiServiceFactory > xConfigFactory( _rxORB->createInstance( lcl_getProviderServiceName( ) ), UNO_QUERY ); + if ( xConfigFactory.is() ) + return createWithProvider( xConfigFactory, _rPath, _nDepth, _eMode, _bLazyWrite ); + } + catch(Exception&) + { + // silent this, 'cause the contract of this method states "no assertions" + } + } + return OConfigurationTreeRoot(); + } + //........................................................................ } // namespace utl //........................................................................ @@ -723,6 +753,9 @@ namespace utl /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.5 2001/08/21 12:40:41 fs + * #87721# +hasByHierarchicalName + * * Revision 1.4 2001/07/26 09:10:58 oj * #89831# new method to append an existing node with different name * |