diff options
author | Noel Grandin <noel@peralex.com> | 2013-07-08 15:05:56 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-07-23 10:05:42 +0200 |
commit | 9c41a60c0d802c618ac414822615a5c9e9e92f9f (patch) | |
tree | 3582b3afa7427489391cb9fece6154b64042c310 /framework/source/uiconfiguration | |
parent | 92dfa82d2d25f2acdee0a538bf15f1fac36c0ecf (diff) |
fdo#46808, Convert ui::ModuleUIConfigurationManager service to new style
.. and convert it to WeakImplHelper at the same time.
Change-Id: I20549f5cc6efb60c5210d3f9b6ecf3ade7e4a75a
Diffstat (limited to 'framework/source/uiconfiguration')
-rw-r--r-- | framework/source/uiconfiguration/moduleuicfgsupplier.cxx | 21 | ||||
-rw-r--r-- | framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx | 109 |
2 files changed, 56 insertions, 74 deletions
diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx index c891fd38d1b8..6ed1210a52d9 100644 --- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx +++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/embed/XPackageStructureCreator.hpp> +#include <com/sun/star/ui/ModuleUIConfigurationManager.hpp> #include <rtl/logfile.hxx> #include <cppuhelper/implbase1.hxx> @@ -113,7 +114,7 @@ ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier( cons const Sequence< OUString > aNameSeq = xNameAccess->getElementNames(); const OUString* pNameSeq = aNameSeq.getConstArray(); for ( sal_Int32 n = 0; n < aNameSeq.getLength(); n++ ) - m_aModuleToModuleUICfgMgrMap.insert( ModuleToModuleCfgMgr::value_type( pNameSeq[n], Reference< XUIConfigurationManager >() )); + m_aModuleToModuleUICfgMgrMap.insert( ModuleToModuleCfgMgr::value_type( pNameSeq[n], Reference< XModuleUIConfigurationManager2 >() )); } catch(...) { @@ -175,7 +176,7 @@ throw ( RuntimeException ) } // XModuleUIConfigurationManagerSupplier -Reference< XUIConfigurationManager > SAL_CALL ModuleUIConfigurationManagerSupplier::getUIConfigurationManager( const OUString& ModuleIdentifier ) +Reference< XUIConfigurationManager > SAL_CALL ModuleUIConfigurationManagerSupplier::getUIConfigurationManager( const OUString& sModuleIdentifier ) throw ( NoSuchElementException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManagerSupplier::getUIConfigurationManager" ); @@ -185,7 +186,7 @@ throw ( NoSuchElementException, RuntimeException) if ( m_bDisposed ) throw DisposedException(); - ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.find( ModuleIdentifier ); + ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.find( sModuleIdentifier ); if ( pIter == m_aModuleToModuleUICfgMgrMap.end() ) throw NoSuchElementException(); //TODO_AS impl_initStorages(); @@ -198,7 +199,7 @@ throw ( NoSuchElementException, RuntimeException) { Sequence< PropertyValue > lProps; Reference< XNameAccess > xCont(m_xModuleMgr, UNO_QUERY); - xCont->getByName(ModuleIdentifier) >>= lProps; + xCont->getByName(sModuleIdentifier) >>= lProps; for (sal_Int32 i=0; i<lProps.getLength(); ++i) { if ( lProps[i].Name == "ooSetupFactoryShortName" ) @@ -215,16 +216,8 @@ throw ( NoSuchElementException, RuntimeException) if (sShort.isEmpty()) throw NoSuchElementException(); - PropertyValue aArg; - Sequence< Any > aArgs( 2 ); - aArg.Name = OUString( "ModuleShortName" ); - aArg.Value <<= sShort; - aArgs[0] <<= aArg; - aArg.Name = OUString( "ModuleIdentifier" ); - aArg.Value <<= ModuleIdentifier; - aArgs[1] <<= aArg; - - pIter->second.set( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(SERVICENAME_MODULEUICONFIGURATIONMANAGER, aArgs, m_xContext ),UNO_QUERY ); + + pIter->second = css::ui::ModuleUIConfigurationManager::createDefault(m_xContext, sShort, sModuleIdentifier); } return pIter->second; diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index dfadbe57429a..eaadaa583df0 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -56,31 +56,12 @@ using namespace ::com::sun::star::ui; namespace framework { +#define SERVICENAME_MODULEUICONFIGURATIONMANAGER DECLARE_ASCII("com.sun.star.ui.ModuleUIConfigurationManager" ) +#define IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGER DECLARE_ASCII("com.sun.star.comp.framework.ModuleUIConfigurationManager" ) + //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XINTERFACE_8 ( ModuleUIConfigurationManager , - OWeakObject , - DIRECT_INTERFACE( css::lang::XTypeProvider ), - DIRECT_INTERFACE( css::lang::XServiceInfo ), - DIRECT_INTERFACE( css::lang::XComponent ), - DIRECT_INTERFACE( css::lang::XInitialization ), - DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfiguration ), - DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationManager ), - DIRECT_INTERFACE( ::com::sun::star::ui::XModuleUIConfigurationManager ), - DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationPersistence ) - ) - -DEFINE_XTYPEPROVIDER_8 ( ModuleUIConfigurationManager , - css::lang::XTypeProvider , - css::lang::XServiceInfo , - css::lang::XComponent , - css::lang::XInitialization , - ::com::sun::star::ui::XUIConfiguration , - ::com::sun::star::ui::XUIConfigurationManager , - ::com::sun::star::ui::XModuleUIConfigurationManager , - ::com::sun::star::ui::XUIConfigurationPersistence - ) DEFINE_XSERVICEINFO_MULTISERVICE_2 ( ModuleUIConfigurationManager , ::cppu::OWeakObject , @@ -807,56 +788,64 @@ void SAL_CALL ModuleUIConfigurationManager::initialize( const Sequence< Any >& a { ResetableGuard aLock( m_aLock ); - if ( !m_bInitialized ) + if( m_bInitialized ) + { + return; + } + + if( aArguments.getLength() == 2 && (aArguments[0] >>= m_aModuleShortName) && (aArguments[1] >>= m_aModuleIdentifier)) + { + } + else { ::comphelper::SequenceAsHashMap lArgs(aArguments); - m_aModuleIdentifier = lArgs.getUnpackedValueOrDefault("ModuleIdentifier", OUString()); m_aModuleShortName = lArgs.getUnpackedValueOrDefault("ModuleShortName", OUString()); + m_aModuleIdentifier = lArgs.getUnpackedValueOrDefault("ModuleIdentifier", OUString()); + } - for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + OUString aResourceType; + if ( i == ::com::sun::star::ui::UIElementType::MENUBAR ) + aResourceType = PresetHandler::RESOURCETYPE_MENUBAR(); + else if ( i == ::com::sun::star::ui::UIElementType::TOOLBAR ) + aResourceType = PresetHandler::RESOURCETYPE_TOOLBAR(); + else if ( i == ::com::sun::star::ui::UIElementType::STATUSBAR ) + aResourceType = PresetHandler::RESOURCETYPE_STATUSBAR(); + + if ( !aResourceType.isEmpty() ) { - OUString aResourceType; - if ( i == ::com::sun::star::ui::UIElementType::MENUBAR ) - aResourceType = PresetHandler::RESOURCETYPE_MENUBAR(); - else if ( i == ::com::sun::star::ui::UIElementType::TOOLBAR ) - aResourceType = PresetHandler::RESOURCETYPE_TOOLBAR(); - else if ( i == ::com::sun::star::ui::UIElementType::STATUSBAR ) - aResourceType = PresetHandler::RESOURCETYPE_STATUSBAR(); - - if ( !aResourceType.isEmpty() ) - { - m_pStorageHandler[i] = new PresetHandler( m_xContext ); - m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES, - aResourceType, // this path wont be used later ... seee next lines! - m_aModuleShortName, - css::uno::Reference< css::embed::XStorage >()); // no document root used here! - } + m_pStorageHandler[i] = new PresetHandler( m_xContext ); + m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES, + aResourceType, // this path wont be used later ... seee next lines! + m_aModuleShortName, + css::uno::Reference< css::embed::XStorage >()); // no document root used here! } + } - // initialize root storages for all resource types - m_xUserRootCommit = css::uno::Reference< css::embed::XTransactedObject >( - m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getOrCreateRootStorageUser(), css::uno::UNO_QUERY); // can be empty - m_xDefaultConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageShare( - m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageShare()); - m_xUserConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageUser( - m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageUser()); + // initialize root storages for all resource types + m_xUserRootCommit = css::uno::Reference< css::embed::XTransactedObject >( + m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getOrCreateRootStorageUser(), css::uno::UNO_QUERY); // can be empty + m_xDefaultConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageShare( + m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageShare()); + m_xUserConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageUser( + m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageUser()); - if ( m_xUserConfigStorage.is() ) + if ( m_xUserConfigStorage.is() ) + { + Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY ); + if ( xPropSet.is() ) { - Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY ); - if ( xPropSet.is() ) - { - long nOpenMode = 0; - Any a = xPropSet->getPropertyValue("OpenMode"); - if ( a >>= nOpenMode ) - m_bReadOnly = !( nOpenMode & ElementModes::WRITE ); - } + long nOpenMode = 0; + Any a = xPropSet->getPropertyValue("OpenMode"); + if ( a >>= nOpenMode ) + m_bReadOnly = !( nOpenMode & ElementModes::WRITE ); } + } - impl_Initialize(); + impl_Initialize(); - m_bInitialized = true; - } + m_bInitialized = true; } // XUIConfiguration |