diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 20:08:25 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-10 16:29:16 +0100 |
commit | cecce73bd6eb61deba9550c5ad768ef5ed9821ea (patch) | |
tree | e07fcb2dc3c426269f39c4a6900a22dd4477e269 | |
parent | db74b4cd9e95112d524de2f4395a3ab7f9f1c0cf (diff) |
fwk: Use constructor feature for ModuleUIConfigurationManagerSupplier.
Change-Id: I4674ed6852807e08ff8319515b0ab4e9535b668a
-rw-r--r-- | framework/inc/uiconfiguration/moduleuicfgsupplier.hxx | 101 | ||||
-rw-r--r-- | framework/source/register/registerservices.cxx | 2 | ||||
-rw-r--r-- | framework/source/uiconfiguration/moduleuicfgsupplier.cxx | 91 | ||||
-rw-r--r-- | framework/util/fwk.component | 3 |
4 files changed, 69 insertions, 128 deletions
diff --git a/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx b/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx deleted file mode 100644 index 6a34a12b26b1..000000000000 --- a/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- 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 INCLUDED_FRAMEWORK_INC_UICONFIGURATION_MODULEUICFGSUPPLIER_HXX -#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_MODULEUICFGSUPPLIER_HXX - - -/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble - with solaris headers ... -*/ -#include <vector> -#include <list> -#include <boost/unordered_map.hpp> - -#include <threadhelp/threadhelpbase.hxx> -#include <macros/generic.hxx> -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <macros/xserviceinfo.hxx> -#include <stdtypes.h> - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XTypeProvider.hpp> -#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> - -#include <cppuhelper/implbase3.hxx> -#include <rtl/ustring.hxx> - - -namespace framework -{ - class ModuleUIConfigurationManagerSupplier : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. - public cppu::WeakImplHelper3< - com::sun::star::lang::XServiceInfo , - com::sun::star::lang::XComponent , - com::sun::star::ui::XModuleUIConfigurationManagerSupplier > - { - public: - // XInterface, XTypeProvider, XServiceInfo - DECLARE_XSERVICEINFO - - ModuleUIConfigurationManagerSupplier( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext ); - virtual ~ModuleUIConfigurationManagerSupplier(); - - // XComponent - virtual void SAL_CALL dispose() - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - - // XModuleUIConfigurationManagerSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( const OUString& ModuleIdentifier ) - 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::XModuleUIConfigurationManager2 >, OUStringHash, ::std::equal_to< OUString > > ModuleToModuleCfgMgr; - -//TODO_AS void impl_initStorages(); - - // private methods - ModuleToModuleCfgMgr m_aModuleToModuleUICfgMgrMap; - bool m_bDisposed; -// TODO_AS bool m_bInit; - OUString m_aDefaultConfigURL; - OUString m_aUserConfigURL; - com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDefaultCfgRootStorage; - com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserCfgRootStorage; - com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit; - com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleMgr; - com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; - ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener - }; -} - -#endif // INCLUDED_FRAMEWORK_INC_UICONFIGURATION_MODULEUICFGSUPPLIER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index 328dc8ca616b..0e402fad9ede 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -39,7 +39,6 @@ #include <jobs/jobexecutor.hxx> #include <services/layoutmanager.hxx> #include <uielement/controlmenucontroller.hxx> -#include <uiconfiguration/moduleuicfgsupplier.hxx> #include <uiconfiguration/moduleuiconfigurationmanager.hxx> #include <uifactory/menubarfactory.hxx> #include <accelerators/globalacceleratorconfiguration.hxx> @@ -58,7 +57,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::LayoutManager ) else IFFACTORY( ::framework::ControlMenuController ) else IFFACTORY( ::framework::ModuleManager ) else - IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier ) else IFFACTORY( ::framework::ModuleUIConfigurationManager ) else IFFACTORY( ::framework::MenuBarFactory ) else IFFACTORY( ::framework::GlobalAcceleratorConfiguration ) else diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx index 48f116a9f74e..eaa237831899 100644 --- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx +++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx @@ -17,8 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <uiconfiguration/moduleuicfgsupplier.hxx> #include <threadhelp/resetableguard.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <macros/xserviceinfo.hxx> +#include <stdtypes.h> #include <services.h> #include <com/sun/star/lang/DisposedException.hpp> @@ -31,10 +33,21 @@ #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/embed/XPackageStructureCreator.hpp> #include <com/sun/star/ui/ModuleUIConfigurationManager.hpp> - -#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#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> + +#include <cppuhelper/implbase3.hxx> +#include <rtl/ref.hxx> #include <vcl/svapp.hxx> +#include <boost/unordered_map.hpp> + using namespace com::sun::star::uno; using namespace com::sun::star::io; using namespace com::sun::star::lang; @@ -43,36 +56,54 @@ using namespace com::sun::star::beans; using namespace com::sun::star::embed; using namespace ::com::sun::star::ui; using namespace ::com::sun::star::frame; +using namespace framework; -namespace framework -{ +namespace { -class RootStorageWrapper : public ::cppu::WeakImplHelper1< com::sun::star::embed::XTransactedObject > +class ModuleUIConfigurationManagerSupplier : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. + public cppu::WeakImplHelper3< + css::lang::XServiceInfo , + css::lang::XComponent , + css::ui::XModuleUIConfigurationManagerSupplier > { public: - // XInterface, XTypeProvider - RootStorageWrapper( const Reference< XTransactedObject >& xRootCommit ) : m_xRootCommit( xRootCommit ) {} - virtual ~RootStorageWrapper() {} + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO - // XTransactedObject - virtual void SAL_CALL commit() throw ( com::sun::star::io::IOException, com::sun::star::lang::WrappedTargetException ) - { - m_xRootCommit->commit(); - } + ModuleUIConfigurationManagerSupplier( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~ModuleUIConfigurationManagerSupplier(); - virtual void SAL_CALL revert() throw ( com::sun::star::io::IOException, com::sun::star::lang::WrappedTargetException ) - { - m_xRootCommit->revert(); - } + // XComponent + virtual void SAL_CALL dispose() + throw (css::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) + throw (css::uno::RuntimeException); + + // XModuleUIConfigurationManagerSupplier + virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( const OUString& ModuleIdentifier ) + throw (css::container::NoSuchElementException, css::uno::RuntimeException); private: - Reference< XTransactedObject > m_xRootCommit; + typedef ::boost::unordered_map< OUString, css::uno::Reference< css::ui::XModuleUIConfigurationManager2 >, OUStringHash, ::std::equal_to< OUString > > ModuleToModuleCfgMgr; + +//TODO_AS void impl_initStorages(); + + // private methods + ModuleToModuleCfgMgr m_aModuleToModuleUICfgMgrMap; + bool m_bDisposed; +// TODO_AS bool m_bInit; + OUString m_aDefaultConfigURL; + OUString m_aUserConfigURL; + css::uno::Reference< css::embed::XStorage > m_xDefaultCfgRootStorage; + css::uno::Reference< css::embed::XStorage > m_xUserCfgRootStorage; + css::uno::Reference< css::embed::XTransactedObject > m_xUserRootCommit; + css::uno::Reference< css::frame::XModuleManager2 > m_xModuleMgr; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener }; -//***************************************************************************************************************** -// XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** - DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( ModuleUIConfigurationManagerSupplier , ::cppu::OWeakObject , "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" , @@ -203,6 +234,18 @@ throw ( NoSuchElementException, RuntimeException) return pIter->second; } -} // namespace framework +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_ModuleUIConfigurationManagerSupplier_get_implementation( + css::uno::XComponentContext * context, + uno_Sequence * arguments) +{ + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + rtl::Reference<ModuleUIConfigurationManagerSupplier> x( + new ModuleUIConfigurationManagerSupplier(context)); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/util/fwk.component b/framework/util/fwk.component index 1dddf74bf1a5..7dee7c7e3997 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -73,7 +73,8 @@ <implementation name="com.sun.star.comp.framework.ModuleUIConfigurationManager"> <service name="com.sun.star.ui.ModuleUIConfigurationManager"/> </implementation> - <implementation name="com.sun.star.comp.framework.ModuleUIConfigurationManagerSupplier"> + <implementation name="com.sun.star.comp.framework.ModuleUIConfigurationManagerSupplier" + constructor="com_sun_star_comp_framework_ModuleUIConfigurationManagerSupplier_get_implementation"> <service name="com.sun.star.ui.ModuleUIConfigurationManagerSupplier"/> </implementation> <implementation name="com.sun.star.comp.framework.ObjectMenuController" |