diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-08 15:02:35 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-05-13 09:38:01 +0200 |
commit | 86c1ebc1ef4a90e9bc58fb69c2d1d978765a34ca (patch) | |
tree | f9ba1c3c02198c83484b68fc190cd2995f6734ab /cui/source | |
parent | ee7f8cb10178fbc348210f6dea0e2ae64964ab6d (diff) |
fdo#46808, Convert util::PathSettings service to new style
Change-Id: I302be46b46518e1e872771e1c8a0647f7c330b30
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/customize/cfg.cxx | 31 | ||||
-rw-r--r-- | cui/source/options/optpath.cxx | 150 |
2 files changed, 85 insertions, 96 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 2adfb0aace50..4aad676607b5 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -62,13 +62,20 @@ #include <comphelper/documentinfo.hxx> #include <comphelper/processfactory.hxx> #include <unotools/configmgr.hxx> -#include <com/sun/star/ui/ItemType.hpp> -#include <com/sun/star/ui/ItemStyle.hpp> -#include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/FileSystemStorageFactory.hpp> +#include <com/sun/star/frame/XFramesSupplier.hpp> +#include <com/sun/star/frame/XFrames.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/UICommandDescription.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> +#include <com/sun/star/ui/ItemType.hpp> +#include <com/sun/star/ui/ItemStyle.hpp> +#include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfiguration.hpp> #include <com/sun/star/ui/XUIConfigurationListener.hpp> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> @@ -79,16 +86,10 @@ #include <com/sun/star/ui/UIElementType.hpp> #include <com/sun/star/ui/ImageType.hpp> #include <com/sun/star/ui/WindowStateConfiguration.hpp> -#include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> -#include <com/sun/star/frame/XFramesSupplier.hpp> -#include <com/sun/star/frame/XFrames.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/graphic/GraphicProvider.hpp> -#include <com/sun/star/embed/ElementModes.hpp> -#include <com/sun/star/embed/FileSystemStorageFactory.hpp> +#include <com/sun/star/util/PathSettings.hpp> #include "dlgname.hxx" @@ -5013,15 +5014,11 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( Window *pWindow, m_xGraphProvider = uno::Reference< graphic::XGraphicProvider >( graphic::GraphicProvider::create( xComponentContext ) ); - uno::Reference< beans::XPropertySet > xPropSet( - xServiceManager->createInstance( OUString("com.sun.star.util.PathSettings" ) ), - uno::UNO_QUERY ); - - uno::Any aAny = xPropSet->getPropertyValue( OUString( "UserConfig" ) ); + uno::Reference< css::util::XPathSettings > xPathSettings = + css::util::PathSettings::create( xComponentContext ); - OUString aDirectory; - aAny >>= aDirectory; + OUString aDirectory = xPathSettings->getUserConfig(); sal_Int32 aCount = aDirectory.getLength(); diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index dfc13a1b29ff..774d3356f7dd 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/util/PathSettings.hpp> #include <officecfg/Office/Common.hxx> #include "optHeaderTabListbox.hxx" #include <readonlyimage.hxx> @@ -77,7 +78,7 @@ struct OptPath_Impl SvtDefaultOptions m_aDefOpt; Image m_aLockImage; OUString m_sMultiPathDlg; - Reference< XPropertySet > m_xPathSettings; + Reference< css::util::XPathSettings > m_xPathSettings; OptPath_Impl(const Image& rLockImage, const OUString& rMultiPathDlg) : m_aLockImage(rLockImage) @@ -716,66 +717,61 @@ void SvxPathTabPage::GetPathList( { String sCfgName = getCfgName_Impl( _nPathHandle ); - // load PathSettings service if necessary - if ( !pImpl->m_xPathSettings.is() ) - { - Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory(); - pImpl->m_xPathSettings = Reference< XPropertySet >( xSMgr->createInstance( - OUString( "com.sun.star.util.PathSettings" ) ), UNO_QUERY ); - } - try { - if ( pImpl->m_xPathSettings.is() ) + // load PathSettings service if necessary + if ( !pImpl->m_xPathSettings.is() ) { - // load internal paths - String sProp( sCfgName ); - sProp = sCfgName; - sProp += POSTFIX_INTERNAL; - Any aAny = pImpl->m_xPathSettings->getPropertyValue( sProp ); - Sequence< OUString > aPathSeq; - if ( aAny >>= aPathSeq ) - { - long i, nCount = aPathSeq.getLength(); - const OUString* pPaths = aPathSeq.getConstArray(); + Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); + pImpl->m_xPathSettings = css::util::PathSettings::create( xContext ); + } - for ( i = 0; i < nCount; ++i ) - { - if ( _rInternalPath.Len() > 0 ) - _rInternalPath += ';'; - _rInternalPath += String( pPaths[i] ); - } - } - // load user paths - sProp = sCfgName; - sProp += POSTFIX_USER; - aAny = pImpl->m_xPathSettings->getPropertyValue( sProp ); - if ( aAny >>= aPathSeq ) + // load internal paths + String sProp( sCfgName ); + sProp += POSTFIX_INTERNAL; + Any aAny = pImpl->m_xPathSettings->getPropertyValue( sProp ); + Sequence< OUString > aPathSeq; + if ( aAny >>= aPathSeq ) + { + long i, nCount = aPathSeq.getLength(); + const OUString* pPaths = aPathSeq.getConstArray(); + + for ( i = 0; i < nCount; ++i ) { - long i, nCount = aPathSeq.getLength(); - const OUString* pPaths = aPathSeq.getConstArray(); + if ( _rInternalPath.Len() > 0 ) + _rInternalPath += ';'; + _rInternalPath += String( pPaths[i] ); + } + } + // load user paths + sProp = sCfgName; + sProp += POSTFIX_USER; + aAny = pImpl->m_xPathSettings->getPropertyValue( sProp ); + if ( aAny >>= aPathSeq ) + { + long i, nCount = aPathSeq.getLength(); + const OUString* pPaths = aPathSeq.getConstArray(); - for ( i = 0; i < nCount; ++i ) - { - if ( _rUserPath.Len() > 0 ) - _rUserPath += ';'; - _rUserPath += String( pPaths[i] ); - } + for ( i = 0; i < nCount; ++i ) + { + if ( _rUserPath.Len() > 0 ) + _rUserPath += ';'; + _rUserPath += String( pPaths[i] ); } - // then the writable path - sProp = sCfgName; - sProp += POSTFIX_WRITABLE; - aAny = pImpl->m_xPathSettings->getPropertyValue( sProp ); - OUString sWritablePath; - if ( aAny >>= sWritablePath ) - _rWritablePath = String( sWritablePath ); - - // and the readonly flag - sProp = sCfgName; - Reference< XPropertySetInfo > xInfo = pImpl->m_xPathSettings->getPropertySetInfo(); - Property aProp = xInfo->getPropertyByName( sProp ); - _rReadOnly = ( ( aProp.Attributes & PropertyAttribute::READONLY ) == PropertyAttribute::READONLY ); } + // then the writable path + sProp = sCfgName; + sProp += POSTFIX_WRITABLE; + aAny = pImpl->m_xPathSettings->getPropertyValue( sProp ); + OUString sWritablePath; + if ( aAny >>= sWritablePath ) + _rWritablePath = String( sWritablePath ); + + // and the readonly flag + sProp = sCfgName; + Reference< XPropertySetInfo > xInfo = pImpl->m_xPathSettings->getPropertySetInfo(); + Property aProp = xInfo->getPropertyByName( sProp ); + _rReadOnly = ( ( aProp.Attributes & PropertyAttribute::READONLY ) == PropertyAttribute::READONLY ); } catch( const Exception& ) { @@ -790,36 +786,32 @@ void SvxPathTabPage::SetPathList( { String sCfgName = getCfgName_Impl( _nPathHandle ); - // load PathSettings service if necessary - if ( !pImpl->m_xPathSettings.is() ) - { - Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory(); - pImpl->m_xPathSettings = Reference< XPropertySet >( xSMgr->createInstance( - "com.sun.star.util.PathSettings" ), UNO_QUERY ); - } - try { - if ( pImpl->m_xPathSettings.is() ) + // load PathSettings service if necessary + if ( !pImpl->m_xPathSettings.is() ) { - // save user paths - char cDelim = MULTIPATH_DELIMITER; - sal_uInt16 nCount = comphelper::string::getTokenCount(_rUserPath, cDelim); - Sequence< OUString > aPathSeq( nCount ); - OUString* pArray = aPathSeq.getArray(); - for ( sal_uInt16 i = 0; i < nCount; ++i ) - pArray[i] = OUString( _rUserPath.GetToken( i, cDelim ) ); - String sProp( sCfgName ); - sProp += POSTFIX_USER; - Any aValue = makeAny( aPathSeq ); - pImpl->m_xPathSettings->setPropertyValue( sProp, aValue ); - - // then the writable path - aValue = makeAny( OUString( _rWritablePath ) ); - sProp = sCfgName; - sProp += POSTFIX_WRITABLE; - pImpl->m_xPathSettings->setPropertyValue( sProp, aValue ); + Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); + pImpl->m_xPathSettings = css::util::PathSettings::create( xContext ); } + + // save user paths + char cDelim = MULTIPATH_DELIMITER; + sal_uInt16 nCount = comphelper::string::getTokenCount(_rUserPath, cDelim); + Sequence< OUString > aPathSeq( nCount ); + OUString* pArray = aPathSeq.getArray(); + for ( sal_uInt16 i = 0; i < nCount; ++i ) + pArray[i] = OUString( _rUserPath.GetToken( i, cDelim ) ); + String sProp( sCfgName ); + sProp += POSTFIX_USER; + Any aValue = makeAny( aPathSeq ); + pImpl->m_xPathSettings->setPropertyValue( sProp, aValue ); + + // then the writable path + aValue = makeAny( OUString( _rWritablePath ) ); + sProp = sCfgName; + sProp += POSTFIX_WRITABLE; + pImpl->m_xPathSettings->setPropertyValue( sProp, aValue ); } catch( const Exception& e ) { |