diff options
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/config/itemholder2.cxx | 10 | ||||
-rw-r--r-- | svtools/source/dialogs/insdlg.cxx | 123 | ||||
-rw-r--r-- | svtools/source/filter/FilterConfigCache.cxx | 42 | ||||
-rw-r--r-- | svtools/source/filter/FilterConfigItem.cxx | 76 |
4 files changed, 120 insertions, 131 deletions
diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx index 14d7c950a74b..2fcbfb8a8d45 100644 --- a/svtools/source/config/itemholder2.cxx +++ b/svtools/source/config/itemholder2.cxx @@ -31,6 +31,7 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <svtools/accessibilityoptions.hxx> #include <svtools/apearcfg.hxx> @@ -58,12 +59,11 @@ ItemHolder2::ItemHolder2() { try { - css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); + css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); css::uno::Reference< css::lang::XComponent > xCfg( - xSMGR->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ))), - css::uno::UNO_QUERY); - if (xCfg.is()) - xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this)); + css::configuration::theDefaultProvider::get( xContext ), + css::uno::UNO_QUERY_THROW ); + xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this)); } catch(const css::uno::RuntimeException&) { diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx index 460b183cea84..a5e1f0eaafdb 100644 --- a/svtools/source/dialogs/insdlg.cxx +++ b/svtools/source/dialogs/insdlg.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <comphelper/processfactory.hxx> #include <com/sun/star/container/XNameAccess.hpp> @@ -118,89 +119,83 @@ void SvObjectServerList::FillInsertObjects() */ { try{ - uno::Reference< lang::XMultiServiceFactory > _globalMSFactory= comphelper::getProcessServiceFactory(); - if( _globalMSFactory.is()) - { - ::rtl::OUString sProviderService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" )); - uno::Reference< lang::XMultiServiceFactory > sProviderMSFactory( - _globalMSFactory->createInstance( sProviderService ), uno::UNO_QUERY ); + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + + uno::Reference< lang::XMultiServiceFactory > sProviderMSFactory = + configuration::theDefaultProvider::get(xContext); + + ::rtl::OUString sReaderService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" )); + uno::Sequence< uno::Any > aArguments( 1 ); + beans::PropertyValue aPathProp; + aPathProp.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); + aPathProp.Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Embedding/ObjectNames" )); + aArguments[0] <<= aPathProp; + + uno::Reference< container::XNameAccess > xNameAccess( + sProviderMSFactory->createInstanceWithArguments( sReaderService,aArguments ), + uno::UNO_QUERY ); - if( sProviderMSFactory.is()) + if( xNameAccess.is()) { - ::rtl::OUString sReaderService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" )); - uno::Sequence< uno::Any > aArguments( 1 ); - beans::PropertyValue aPathProp; - aPathProp.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); - aPathProp.Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Embedding/ObjectNames" )); - aArguments[0] <<= aPathProp; - - uno::Reference< container::XNameAccess > xNameAccess( - sProviderMSFactory->createInstanceWithArguments( sReaderService,aArguments ), - uno::UNO_QUERY ); - - if( xNameAccess.is()) - { - uno::Sequence< ::rtl::OUString > seqNames= xNameAccess->getElementNames(); - sal_Int32 nInd; + uno::Sequence< ::rtl::OUString > seqNames= xNameAccess->getElementNames(); + sal_Int32 nInd; - ::rtl::OUString aStringProductName( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTNAME" ) ); - sal_Int32 nStringProductNameLength = aStringProductName.getLength(); + ::rtl::OUString aStringProductName( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTNAME" ) ); + sal_Int32 nStringProductNameLength = aStringProductName.getLength(); - ::rtl::OUString aStringProductVersion( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTVERSION" ) ); - sal_Int32 nStringProductVersionLength = aStringProductVersion.getLength(); + ::rtl::OUString aStringProductVersion( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTVERSION" ) ); + sal_Int32 nStringProductVersionLength = aStringProductVersion.getLength(); - for( nInd = 0; nInd < seqNames.getLength(); nInd++ ) + for( nInd = 0; nInd < seqNames.getLength(); nInd++ ) + { + uno::Reference< container::XNameAccess > xEntry ; + xNameAccess->getByName( seqNames[nInd] ) >>= xEntry; + if ( xEntry.is() ) { - uno::Reference< container::XNameAccess > xEntry ; - xNameAccess->getByName( seqNames[nInd] ) >>= xEntry; - if ( xEntry.is() ) - { - ::rtl::OUString aUIName; - ::rtl::OUString aClassID; - xEntry->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ObjectUIName" )) ) >>= aUIName; - xEntry->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ClassID" )) ) >>= aClassID; + ::rtl::OUString aUIName; + ::rtl::OUString aClassID; + xEntry->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ObjectUIName" )) ) >>= aUIName; + xEntry->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ClassID" )) ) >>= aClassID; - if ( !aUIName.isEmpty() ) + if ( !aUIName.isEmpty() ) + { + // replace %PRODUCTNAME + sal_Int32 nIndex = aUIName.indexOf( aStringProductName ); + while( nIndex != -1 ) { - // replace %PRODUCTNAME - sal_Int32 nIndex = aUIName.indexOf( aStringProductName ); - while( nIndex != -1 ) - { - aUIName = aUIName.replaceAt( - nIndex, nStringProductNameLength, - utl::ConfigManager::getProductName() ); - nIndex = aUIName.indexOf( aStringProductName ); - } - - // replace %PRODUCTVERSION - nIndex = aUIName.indexOf( aStringProductVersion ); - while( nIndex != -1 ) - { - aUIName = aUIName.replaceAt( - nIndex, nStringProductVersionLength, - utl::ConfigManager::getProductVersion() ); - nIndex = aUIName.indexOf( aStringProductVersion ); - } + aUIName = aUIName.replaceAt( + nIndex, nStringProductNameLength, + utl::ConfigManager::getProductName() ); + nIndex = aUIName.indexOf( aStringProductName ); } - SvGlobalName aClassName; - if( aClassName.MakeId( String( aClassID ))) + // replace %PRODUCTVERSION + nIndex = aUIName.indexOf( aStringProductVersion ); + while( nIndex != -1 ) { - if( !Get( aClassName ) ) - // noch nicht eingetragen - aObjectServerList.push_back( SvObjectServer( aClassName, aUIName ) ); + aUIName = aUIName.replaceAt( + nIndex, nStringProductVersionLength, + utl::ConfigManager::getProductVersion() ); + nIndex = aUIName.indexOf( aStringProductVersion ); } } + + SvGlobalName aClassName; + if( aClassName.MakeId( String( aClassID ))) + { + if( !Get( aClassName ) ) + // noch nicht eingetragen + aObjectServerList.push_back( SvObjectServer( aClassName, aUIName ) ); + } } } } - } #ifdef WNT - SvGlobalName aOleFact( SO3_OUT_CLASSID ); - String aOleObj( SVT_RESSTR( STR_FURTHER_OBJECT ) ); - aObjectServerList.push_back( SvObjectServer( aOleFact, aOleObj ) ); + SvGlobalName aOleFact( SO3_OUT_CLASSID ); + String aOleObj( SVT_RESSTR( STR_FURTHER_OBJECT ) ); + aObjectServerList.push_back( SvObjectServer( aOleFact, aOleObj ) ); #endif }catch(const container::NoSuchElementException&) diff --git a/svtools/source/filter/FilterConfigCache.cxx b/svtools/source/filter/FilterConfigCache.cxx index f0b6a5fbcf86..fb6352ec5a4f 100644 --- a/svtools/source/filter/FilterConfigCache.cxx +++ b/svtools/source/filter/FilterConfigCache.cxx @@ -33,11 +33,13 @@ #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> using namespace ::com::sun::star::lang ; // XMultiServiceFactory using namespace ::com::sun::star::container ; // XNameAccess using namespace ::com::sun::star::uno ; // Reference using namespace ::com::sun::star::beans ; // PropertyValue +using namespace ::com::sun::star::configuration ; using ::rtl::OUString; const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameList[] = @@ -127,32 +129,28 @@ String FilterConfigCache::FilterConfigCacheEntry::GetShortName() Reference< XInterface > openConfig(const char* sPackage) throw(RuntimeException) { - Reference< XMultiServiceFactory > xSMGR( - comphelper::getProcessServiceFactory() ); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); Reference< XInterface > xCfg; try { // get access to config API (not to file!) - Reference< XMultiServiceFactory > xConfigProvider( xSMGR->createInstance( - OUString( "com.sun.star.configuration.ConfigurationProvider" )), UNO_QUERY); - - if (xConfigProvider.is()) - { - Sequence< Any > lParams(1); - PropertyValue aParam ; - - // define cfg path for open - aParam.Name = OUString( "nodepath" ); - if (rtl_str_compareIgnoreAsciiCase(sPackage, "types") == 0) - aParam.Value <<= OUString( "/org.openoffice.TypeDetection.Types/Types" ); - if (rtl_str_compareIgnoreAsciiCase(sPackage, "filters") == 0) - aParam.Value <<= OUString( "/org.openoffice.TypeDetection.GraphicFilter/Filters" ); - lParams[0] = makeAny(aParam); - - // get access to file - xCfg = xConfigProvider->createInstanceWithArguments( - OUString( "com.sun.star.configuration.ConfigurationAccess" ), lParams); - } + Reference< XMultiServiceFactory > xConfigProvider = theDefaultProvider::get( xContext ); + + Sequence< Any > lParams(1); + PropertyValue aParam ; + + // define cfg path for open + aParam.Name = OUString( "nodepath" ); + if (rtl_str_compareIgnoreAsciiCase(sPackage, "types") == 0) + aParam.Value <<= OUString( "/org.openoffice.TypeDetection.Types/Types" ); + if (rtl_str_compareIgnoreAsciiCase(sPackage, "filters") == 0) + aParam.Value <<= OUString( "/org.openoffice.TypeDetection.GraphicFilter/Filters" ); + lParams[0] = makeAny(aParam); + + // get access to file + xCfg = xConfigProvider->createInstanceWithArguments( + OUString( "com.sun.star.configuration.ConfigurationAccess" ), lParams); } catch(const RuntimeException&) { throw; } diff --git a/svtools/source/filter/FilterConfigItem.cxx b/svtools/source/filter/FilterConfigItem.cxx index 275bcebdebbf..108b3dd29127 100644 --- a/svtools/source/filter/FilterConfigItem.cxx +++ b/svtools/source/filter/FilterConfigItem.cxx @@ -32,6 +32,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> @@ -45,6 +46,7 @@ using namespace ::com::sun::star::uno ; // Reference using namespace ::com::sun::star::util ; // XChangesBatch using namespace ::com::sun::star::awt ; // Size using namespace ::com::sun::star::container ; // +using namespace ::com::sun::star::configuration; // using namespace ::com::sun::star::task ; // XStatusIndicator static sal_Bool ImpIsTreeAvailable( Reference< XMultiServiceFactory >& rXCfgProv, const rtl::OUString& rTree ) @@ -122,50 +124,44 @@ void FilterConfigItem::ImpInitTree( const String& rSubTree ) { bModified = sal_False; - Reference< XMultiServiceFactory > xSMGR( - comphelper::getProcessServiceFactory() ); + Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - Reference< XMultiServiceFactory > xCfgProv( - xSMGR->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ), - UNO_QUERY ); + Reference< XMultiServiceFactory > xCfgProv = theDefaultProvider::get( xContext ); - if ( xCfgProv.is() ) + OUString sTree( + OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.")) + + rSubTree); + if ( ImpIsTreeAvailable(xCfgProv, sTree) ) { - OUString sTree( - OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.")) + - rSubTree); - if ( ImpIsTreeAvailable(xCfgProv, sTree) ) - { - Any aAny; - // creation arguments: nodepath - PropertyValue aPathArgument; - aAny <<= sTree; - aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); - aPathArgument.Value = aAny; - - // creation arguments: commit mode - PropertyValue aModeArgument; - sal_Bool bAsyncron = sal_True; - aAny <<= bAsyncron; - aModeArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) ); - aModeArgument.Value = aAny; - - Sequence< Any > aArguments( 2 ); - aArguments[ 0 ] <<= aPathArgument; - aArguments[ 1 ] <<= aModeArgument; + Any aAny; + // creation arguments: nodepath + PropertyValue aPathArgument; + aAny <<= sTree; + aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); + aPathArgument.Value = aAny; - try - { - xUpdatableView = xCfgProv->createInstanceWithArguments( - OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ), - aArguments ); - if ( xUpdatableView.is() ) - xPropSet = Reference< XPropertySet >( xUpdatableView, UNO_QUERY ); - } - catch ( ::com::sun::star::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" ); - } + // creation arguments: commit mode + PropertyValue aModeArgument; + sal_Bool bAsyncron = sal_True; + aAny <<= bAsyncron; + aModeArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) ); + aModeArgument.Value = aAny; + + Sequence< Any > aArguments( 2 ); + aArguments[ 0 ] <<= aPathArgument; + aArguments[ 1 ] <<= aModeArgument; + + try + { + xUpdatableView = xCfgProv->createInstanceWithArguments( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ), + aArguments ); + if ( xUpdatableView.is() ) + xPropSet = Reference< XPropertySet >( xUpdatableView, UNO_QUERY ); + } + catch ( ::com::sun::star::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" ); } } } |