Kaydet (Commit) 9c41a60c authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Convert ui::ModuleUIConfigurationManager service to new style

.. and convert it to WeakImplHelper at the same time.

Change-Id: I20549f5cc6efb60c5210d3f9b6ecf3ade7e4a75a
üst 92dfa82d
......@@ -37,7 +37,6 @@ namespace framework{
#define SERVICENAME_PROTOCOLHANDLER DECLARE_ASCII("com.sun.star.frame.ProtocolHandler" )
#define SERVICENAME_POPUPMENUCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.frame.PopupMenuControllerFactory" )
#define SERVICENAME_POPUPMENUCONTROLLER DECLARE_ASCII("com.sun.star.frame.PopupMenuController" )
#define SERVICENAME_MODULEUICONFIGURATIONMANAGER DECLARE_ASCII("com.sun.star.ui.ModuleUIConfigurationManager" )
#define SERVICENAME_MENUBARFACTORY DECLARE_ASCII("com.sun.star.ui.UIElementFactory" )
#define SERVICENAME_FRAMECONTROLLER DECLARE_ASCII("com.sun.star.frame.Controller" )
#define SERVICENAME_TOOLBARFACTORY DECLARE_ASCII("com.sun.star.ui.ToolBarFactory" )
......@@ -83,7 +82,6 @@ namespace framework{
#define IMPLEMENTATIONNAME_UIELEMENTFACTORYMANAGER DECLARE_ASCII("com.sun.star.comp.framework.UIElementFactoryManager" )
#define IMPLEMENTATIONNAME_MODULEMANAGER DECLARE_ASCII("com.sun.star.comp.framework.ModuleManager" )
#define IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGERSUPPLIER DECLARE_ASCII("com.sun.star.comp.framework.ModuleUIConfigurationManagerSupplier" )
#define IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGER DECLARE_ASCII("com.sun.star.comp.framework.ModuleUIConfigurationManager" )
#define IMPLEMENTATIONNAME_MENUBARFACTORY DECLARE_ASCII("com.sun.star.comp.framework.MenuBarFactory" )
#define IMPLEMENTATIONNAME_STARTMODULE DECLARE_ASCII("com.sun.star.comp.framework.BackingComp" )
#define IMPLEMENTATIONNAME_WINDOWSTATECONFIGURATION DECLARE_ASCII("com.sun.star.comp.framework.WindowStateConfiguration" )
......
......@@ -40,6 +40,7 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManager2.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
......@@ -80,7 +81,7 @@ namespace framework
throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
private:
typedef ::boost::unordered_map< OUString, com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager >, OUStringHash, ::std::equal_to< OUString > > ModuleToModuleCfgMgr;
typedef ::boost::unordered_map< OUString, com::sun::star::uno::Reference< ::com::sun::star::ui::XModuleUIConfigurationManager2 >, OUStringHash, ::std::equal_to< OUString > > ModuleToModuleCfgMgr;
//TODO_AS void impl_initStorages();
......
......@@ -41,37 +41,29 @@
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
#include <com/sun/star/ui/XUIConfiguration.hpp>
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManager2.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/ConfigurationEvent.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include <rtl/ustring.hxx>
namespace framework
{
class ModuleUIConfigurationManager : public com::sun::star::lang::XTypeProvider ,
public com::sun::star::lang::XServiceInfo ,
public com::sun::star::lang::XComponent ,
public com::sun::star::lang::XInitialization ,
public ::com::sun::star::ui::XUIConfiguration ,
public ::com::sun::star::ui::XUIConfigurationManager ,
public ::com::sun::star::ui::XModuleUIConfigurationManager ,
public ::com::sun::star::ui::XUIConfigurationPersistence ,
private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
public ::cppu::OWeakObject
class ModuleUIConfigurationManager : private ThreadHelpBase, // Struct for right initalization of mutex member! Must be first of baseclasses.
cppu::WeakImplHelper4<
com::sun::star::lang::XServiceInfo,
com::sun::star::lang::XComponent,
com::sun::star::lang::XInitialization,
com::sun::star::ui::XModuleUIConfigurationManager2 >
{
public:
// XInterface, XTypeProvider, XServiceInfo
FWK_DECLARE_XINTERFACE
FWK_DECLARE_XTYPEPROVIDER
DECLARE_XSERVICEINFO
ModuleUIConfigurationManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xServiceManager );
......
......@@ -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;
......
......@@ -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
......
......@@ -423,6 +423,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ui,\
DocumentAcceleratorConfiguration \
GlobalAcceleratorConfiguration \
ModuleAcceleratorConfiguration \
ModuleUIConfigurationManager \
ModuleUIConfigurationManagerSupplier \
UICategoryDescription \
UIConfigurationManager \
......@@ -1538,7 +1539,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/ui,\
ItemDescriptor \
ModuleUICategoryDescription \
ModuleUICommandDescription \
ModuleUIConfigurationManager \
ModuleWindowStateConfiguration \
UIElement \
UIElementFactory \
......@@ -3972,6 +3972,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/ui,\
XDockingAreaAcceptor \
XImageManager \
XModuleUIConfigurationManager \
XModuleUIConfigurationManager2 \
XModuleUIConfigurationManagerSupplier \
XSidebar \
XSidebarPanel \
......
......@@ -19,11 +19,10 @@
#ifndef __com_sun_star_ui_ModuleUIConfigurationManager_idl__
#define __com_sun_star_ui_ModuleUIConfigurationManager_idl__
#include <com/sun/star/lang/XInitialization.idl>
#include <com/sun/star/ui/XUIConfigurationManager.idl>
#include <com/sun/star/ui/XUIConfigurationPersistence.idl>
#include <com/sun/star/ui/XModuleUIConfigurationManager.idl>
#include <com/sun/star/ui/XUIConfiguration.idl>
#include <com/sun/star/ui/XModuleUIConfigurationManager2.idl>
#include <com/sun/star/configuration/CorruptedUIConfigurationException.idl>
#include <com/sun/star/beans/UnknownPropertyException.idl>
#include <com/sun/star/lang/WrappedTargetException.idl>
module com { module sun { module star { module ui {
......@@ -44,7 +43,7 @@ module com { module sun { module star { module ui {
@since OOo 2.0
*/
service ModuleUIConfigurationManager
service ModuleUIConfigurationManager : XModuleUIConfigurationManager2
{
/** provides a function to initialize a module user interface configuration manager instance.
......@@ -65,27 +64,12 @@ service ModuleUIConfigurationManager
as a read-only container.
</p>
*/
interface com::sun::star::lang::XInitialization;
createDefault([in] string ModuleShortName, [in] string ModuleIdentifier)
raises ( com::sun::star::configuration::CorruptedUIConfigurationException,
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::WrappedTargetException );
/** provides access to persistence functions to load/store user interface element
settings from/to a module storage.
*/
interface com::sun::star::ui::XUIConfigurationPersistence;
/** provides functions to change, insert and remove user interface element settings
from a module user interface configuration manager.
*/
interface com::sun::star::ui::XUIConfigurationManager;
/** provides access to the default layer of a module based ui configuration
manager.
*/
interface com::sun::star::ui::XModuleUIConfigurationManager;
/** provides functions to add and remove listeners for changes within a module user
interface configuration manager.
*/
interface com::sun::star::ui::XUIConfiguration;
};
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __com_sun_star_ui_XModuleUIConfigurationManager2_idl__
#define __com_sun_star_ui_XModuleUIConfigurationManager2_idl__
#include <com/sun/star/ui/XUIConfigurationManager.idl>
#include <com/sun/star/ui/XUIConfigurationPersistence.idl>
#include <com/sun/star/ui/XModuleUIConfigurationManager.idl>
#include <com/sun/star/ui/XUIConfiguration.idl>
module com { module sun { module star { module ui {
/**
Provides a unified interface for the ModuleUIConfigurationManager service.
@since LibreOffice 4.2
*/
interface XModuleUIConfigurationManager2
{
/** provides access to persistence functions to load/store user interface element
settings from/to a module storage.
*/
interface com::sun::star::ui::XUIConfigurationPersistence;
/** provides functions to change, insert and remove user interface element settings
from a module user interface configuration manager.
*/
interface com::sun::star::ui::XUIConfigurationManager;
/** provides access to the default layer of a module based ui configuration
manager.
*/
interface com::sun::star::ui::XModuleUIConfigurationManager;
/** provides functions to add and remove listeners for changes within a module user
interface configuration manager.
*/
interface com::sun::star::ui::XUIConfiguration;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment