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/source/accelerators | |
parent | 7dca32d575ab974e5f42f579bdeda21d2e445efe (diff) |
fwk: Use constructor feature for ModuleAcceleratorConfiguration.
And avoid css::uno::XInitialization protocol.
Change-Id: If4a7987778e2880502bdc7ef2c30792de9377364
Diffstat (limited to 'framework/source/accelerators')
-rw-r--r-- | framework/source/accelerators/moduleacceleratorconfiguration.cxx | 125 |
1 files changed, 85 insertions, 40 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: */ |