diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2013-07-26 23:01:33 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-07-31 13:25:51 +0000 |
commit | a8c403a1f8298cede274f315e367f799d4fb0f32 (patch) | |
tree | f0bffad815744bcc21e8f7b1a23c9189eb4ce3fa | |
parent | 72319bfcced8b416c347e3d92d17296b2996b80b (diff) |
fdo#46037: less occurrences of comphelper/configurationhelper in sfx2/appl
Change-Id: If1c4bafebcc570c4adb30bc507e4562357ce3f63
Reviewed-on: https://gerrit.libreoffice.org/5132
Reviewed-by: Luboš Luňák <l.lunak@suse.cz>
Tested-by: Luboš Luňák <l.lunak@suse.cz>
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 50 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 43 |
2 files changed, 27 insertions, 66 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index b05b71469eda..363bfab56de4 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -45,7 +45,6 @@ #include <cppuhelper/implbase1.hxx> #include <rtl/ustring.hxx> -#include <comphelper/configurationhelper.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequenceasvector.hxx> #include <comphelper/storagehelper.hxx> @@ -102,6 +101,8 @@ #include "templatedlg.hxx" #include "openuriexternally.hxx" +#include <officecfg/Office/ProtocolHandler.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; @@ -897,39 +898,28 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) aProtocols[0] = OUString("private:*"); aProtocols[1] = OUString("vnd.sun.star.*"); - try + // get registered protocol handlers from configuration + Reference < XNameAccess > xAccess(officecfg::Office::ProtocolHandler::HandlerSet::get()); + Sequence < OUString > aNames = xAccess->getElementNames(); + for ( sal_Int32 nName = 0; nName < aNames.getLength(); nName ++) { - // get registered protocol handlers from configuration - Reference < XNameAccess > xAccess( ::comphelper::ConfigurationHelper::openConfig( ::comphelper::getProcessComponentContext(), - OUString("org.openoffice.Office.ProtocolHandler/HandlerSet"), ::comphelper::ConfigurationHelper::E_READONLY ), UNO_QUERY ); - if ( xAccess.is() ) + Reference < XPropertySet > xSet; + Any aRet = xAccess->getByName( aNames[nName] ); + aRet >>= xSet; + if ( xSet.is() ) { - Sequence < OUString > aNames = xAccess->getElementNames(); - for ( sal_Int32 nName = 0; nName < aNames.getLength(); nName ++) - { - Reference < XPropertySet > xSet; - Any aRet = xAccess->getByName( aNames[nName] ); - aRet >>= xSet; - if ( xSet.is() ) - { - // copy protocols - aRet = xSet->getPropertyValue("Protocols"); - Sequence < OUString > aTmp; - aRet >>= aTmp; - - // todo: add operator+= to SequenceAsVector class and use SequenceAsVector for aProtocols - sal_Int32 nLength = aProtocols.getLength(); - aProtocols.realloc( nLength+aTmp.getLength() ); - for ( sal_Int32 n=0; n<aTmp.getLength(); n++ ) - aProtocols[(++nLength)-1] = aTmp[n]; - } - } + // copy protocols + aRet = xSet->getPropertyValue("Protocols"); + Sequence < OUString > aTmp; + aRet >>= aTmp; + + // todo: add operator+= to SequenceAsVector class and use SequenceAsVector for aProtocols + sal_Int32 nLength = aProtocols.getLength(); + aProtocols.realloc( nLength+aTmp.getLength() ); + for ( sal_Int32 n=0; n<aTmp.getLength(); n++ ) + aProtocols[(++nLength)-1] = aTmp[n]; } } - catch ( Exception& ) - { - // registered protocols could not be read - } sal_Bool bFound = sal_False; for ( sal_Int32 nProt=0; nProt<aProtocols.getLength(); nProt++ ) diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 1df307f333b4..b280beecb966 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -122,6 +122,9 @@ #include <sfx2/zoomitem.hxx> #include "templatedlg.hxx" +#include <officecfg/Office/Common.hxx> +#include <officecfg/Setup.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; @@ -990,31 +993,6 @@ namespace #endif // !DISABLE_SCRIPTING } -static OUString getConfigurationStringValue( - const OUString& rPackage, - const OUString& rRelPath, - const OUString& rKey, - const OUString& rDefaultValue ) -{ - OUString aDefVal( rDefaultValue ); - - try - { - ::comphelper::ConfigurationHelper::readDirectKey( - comphelper::getProcessComponentContext(), - rPackage, - rRelPath, - rKey, - ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal; - } - catch(const com::sun::star::uno::RuntimeException&) - { throw; } - catch(const com::sun::star::uno::Exception&) - {} - - return aDefVal; -} - void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) { switch ( rReq.GetSlot() ) @@ -1066,12 +1044,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) css::system::SystemShellExecute::create(xContext) ); // read repository URL from configuration - OUString sTemplRepoURL = - getConfigurationStringValue( - OUString("org.openoffice.Office.Common"), - OUString("Dictionaries"), - OUString("RepositoryURL"), - OUString()); + OUString sTemplRepoURL(officecfg::Office::Common::Dictionaries::RepositoryURL::get()); if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() ) { @@ -1079,11 +1052,9 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) aURLBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM("?lang=")); // read locale from configuration - OUString sLocale = getConfigurationStringValue( - OUString("org.openoffice.Setup"), - OUString("L10N"), - OUString("ooLocale"), - OUString("en-US")); + OUString sLocale(officecfg::Setup::L10N::ooLocale::get()); + if (sLocale.isEmpty()) + sLocale = "en-US"; aURLBuf.append( sLocale ); xSystemShell->execute( |