Kaydet (Commit) 42fc427d authored tarafından Matúš Kukan's avatar Matúš Kukan

fwk: Use constructor feature for ModuleAcceleratorConfiguration.

And avoid css::uno::XInitialization protocol.

Change-Id: If4a7987778e2880502bdc7ef2c30792de9377364
üst 7dca32d5
......@@ -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: */
/* -*- 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: */
......@@ -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
......
......@@ -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"
......
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