diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 20:33:11 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-18 17:02:39 +0100 |
commit | 42fc427d047a263185d89528953f980019ef815f (patch) | |
tree | ab6d4bfb87a14b7cfded9acd5ea05582047afb53 /framework | |
parent | 7dca32d575ab974e5f42f579bdeda21d2e445efe (diff) |
fwk: Use constructor feature for ModuleAcceleratorConfiguration.
And avoid css::uno::XInitialization protocol.
Change-Id: If4a7987778e2880502bdc7ef2c30792de9377364
Diffstat (limited to 'framework')
4 files changed, 87 insertions, 148 deletions
diff --git a/framework/source/accelerators/moduleacceleratorconfiguration.cxx b/framework/source/accelerators/moduleacceleratorconfiguration.cxx index 4138155cbb4b..f19b91c291f2 100644 --- a/framework/source/accelerators/moduleacceleratorconfiguration.cxx +++ b/framework/source/accelerators/moduleacceleratorconfiguration.cxx @@ -17,65 +17,99 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <accelerators/moduleacceleratorconfiguration.hxx> - +#include <accelerators/acceleratorconfiguration.hxx> +#include <accelerators/presethandler.hxx> #include <threadhelp/readguard.hxx> #include <threadhelp/writeguard.hxx> #include "helper/mischelper.hxx" #include <acceleratorconst.h> -#include <services.h> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/embed/ElementModes.hpp> +#include <cppuhelper/supportsservice.hxx> #include <comphelper/sequenceashashmap.hxx> #include <vcl/svapp.hxx> #include <com/sun/star/util/XChangesNotifier.hpp> - +#include <cppuhelper/implbase1.hxx> +#include <rtl/ref.hxx> #include <rtl/logfile.h> -namespace framework -{ +using namespace framework; -//----------------------------------------------- -// XInterface, XTypeProvider, XServiceInfo - -DEFINE_XSERVICEINFO_MULTISERVICE_2(ModuleAcceleratorConfiguration , - ::cppu::OWeakObject , - "com.sun.star.ui.ModuleAcceleratorConfiguration" , - OUString("com.sun.star.comp.framework.ModuleAcceleratorConfiguration")) - -DEFINE_INIT_SERVICE(ModuleAcceleratorConfiguration, - { - /*Attention - I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() - to create a new instance of this class by our own supported service factory. - see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further information! - */ - } - ) +namespace { -//----------------------------------------------- -ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext) - : ModuleAcceleratorConfiguration_BASE(xContext) -{ -} +/** + implements a read/write access to a module + dependend accelerator configuration. + */ +typedef ::cppu::ImplInheritanceHelper1< + XCUBasedAcceleratorConfiguration, + css::lang::XServiceInfo > ModuleAcceleratorConfiguration_BASE; -//----------------------------------------------- -ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration() +class ModuleAcceleratorConfiguration : public ModuleAcceleratorConfiguration_BASE { -} +private: + /** identify the application module, where this accelerator + configuration cache should work on. */ + OUString m_sModule; + OUString m_sLocale; -//----------------------------------------------- -void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments) - throw(css::uno::Exception , - css::uno::RuntimeException) +public: + + /** initialize this instance and fill the internal cache. + + @param xSMGR + reference to an uno service manager, which is used internaly. + */ + ModuleAcceleratorConfiguration( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Sequence< css::uno::Any >& lArguments); + + /** TODO */ + virtual ~ModuleAcceleratorConfiguration(); + + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { + return OUString("com.sun.star.comp.framework.ModuleAcceleratorConfiguration"); + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException) + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() + throw (css::uno::RuntimeException) + { + css::uno::Sequence< OUString > aSeq(1); + aSeq[0] = OUString("com.sun.star.ui.ModuleAcceleratorConfiguration"); + return aSeq; + } + + // XComponent + virtual void SAL_CALL dispose() throw (css::uno::RuntimeException); + + /** read all data into the cache. */ + void impl_ts_fillCache(); + +private: + /** helper to listen for configuration changes without ownership cycle problems */ + css::uno::Reference< css::util::XChangesListener > m_xCfgListener; +}; + +ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Sequence< css::uno::Any >& lArguments) + : ModuleAcceleratorConfiguration_BASE(xContext) { - // SAFE -> ---------------------------------- WriteGuard aWriteLock(m_aLock); OUString sModule; @@ -95,12 +129,12 @@ void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequenc static_cast< ::cppu::OWeakObject* >(this)); aWriteLock.unlock(); - // <- SAFE ---------------------------------- +} - impl_ts_fillCache(); +ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration() +{ } -//----------------------------------------------- void ModuleAcceleratorConfiguration::impl_ts_fillCache() { // SAFE -> ---------------------------------- @@ -153,6 +187,17 @@ void SAL_CALL ModuleAcceleratorConfiguration::dispose() {} } -} // namespace framework +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_ModuleAcceleratorConfiguration_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &arguments) +{ + rtl::Reference<ModuleAcceleratorConfiguration> x(new ModuleAcceleratorConfiguration(context, arguments)); + x->impl_ts_fillCache(); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx b/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx deleted file mode 100644 index c85d8268e096..000000000000 --- a/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx +++ /dev/null @@ -1,105 +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_SOURCE_INC_ACCELERATORS_MODULEACCELERATORCONFIGURATION_HXX -#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_MODULEACCELERATORCONFIGURATION_HXX - -#include <accelerators/acceleratorconfiguration.hxx> -#include <accelerators/presethandler.hxx> - -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <macros/xserviceinfo.hxx> - -#include <com/sun/star/lang/XInitialization.hpp> -#include <cppuhelper/implbase2.hxx> - -// definition - -namespace framework -{ - -//__________________________________________ -/** - implements a read/write access to a module - dependend accelerator configuration. - */ -typedef ::cppu::ImplInheritanceHelper2< - XCUBasedAcceleratorConfiguration, - css::lang::XServiceInfo, - css::lang::XInitialization > ModuleAcceleratorConfiguration_BASE; - -class ModuleAcceleratorConfiguration : ModuleAcceleratorConfiguration_BASE -{ - //______________________________________ - // member - - private: - - //---------------------------------- - /** identify the application module, where this accelerator - configuration cache should work on. */ - OUString m_sModule; - OUString m_sLocale; - - //______________________________________ - // interface - - public: - - //---------------------------------- - /** initialize this instance and fill the internal cache. - - @param xSMGR - reference to an uno service manager, which is used internaly. - */ - ModuleAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext); - - //---------------------------------- - /** TODO */ - virtual ~ModuleAcceleratorConfiguration(); - - // XInterface, XTypeProvider, XServiceInfo - DECLARE_XSERVICEINFO - - // XInitialization - virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) - throw(css::uno::Exception , - css::uno::RuntimeException); - - // XComponent - virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); - - //______________________________________ - // helper - - private: - /** helper to listen for configuration changes without ownership cycle problems */ - css::uno::Reference< css::util::XChangesListener > m_xCfgListener; - - //---------------------------------- - /** read all data into the cache. */ - void impl_ts_fillCache(); -}; - -} // namespace framework - -#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_MODULEACCELERATORCONFIGURATION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index c86390a22001..032a5add2f06 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -40,7 +40,6 @@ #include <uielement/uicommanddescription.hxx> #include <uiconfiguration/moduleuicfgsupplier.hxx> #include <uifactory/menubarfactory.hxx> -#include <accelerators/moduleacceleratorconfiguration.hxx> #include <uifactory/toolboxfactory.hxx> #include "uiconfiguration/windowstateconfiguration.hxx" #include <services/autorecovery.hxx> @@ -62,7 +61,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::UICommandDescription ) else IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier ) else IFFACTORY( ::framework::MenuBarFactory ) else - IFFACTORY( ::framework::ModuleAcceleratorConfiguration ) else IFFACTORY( ::framework::ToolBoxFactory ) else IFFACTORY( ::framework::WindowStateConfiguration ) else IFFACTORY( ::framework::ToolbarControllerFactory ) else diff --git a/framework/util/fwk.component b/framework/util/fwk.component index 765583a1d9ff..4a8b46884c0b 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -69,7 +69,8 @@ <implementation name="com.sun.star.comp.framework.MenuBarFactory"> <service name="com.sun.star.ui.UIElementFactory"/> </implementation> - <implementation name="com.sun.star.comp.framework.ModuleAcceleratorConfiguration"> + <implementation name="com.sun.star.comp.framework.ModuleAcceleratorConfiguration" + constructor="com_sun_star_comp_framework_ModuleAcceleratorConfiguration_get_implementation"> <service name="com.sun.star.ui.ModuleAcceleratorConfiguration"/> </implementation> <implementation name="com.sun.star.comp.framework.ModuleManager" |