2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2014-01-09 20:48:08 +01:00
|
|
|
#include <accelerators/acceleratorconfiguration.hxx>
|
|
|
|
#include <accelerators/presethandler.hxx>
|
|
|
|
#include <helper/mischelper.hxx>
|
2004-09-20 09:05:55 +00:00
|
|
|
|
|
|
|
#include <acceleratorconst.h>
|
|
|
|
|
2008-12-01 13:46:00 +00:00
|
|
|
#include <com/sun/star/util/XChangesNotifier.hpp>
|
2014-01-09 20:48:08 +01:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2015-08-14 10:23:57 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2014-01-09 20:48:08 +01:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
|
|
|
#include <rtl/ref.hxx>
|
2004-09-20 09:05:55 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/languagetag.hxx>
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2014-01-09 20:48:08 +01:00
|
|
|
using namespace framework;
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2014-01-09 20:48:08 +01:00
|
|
|
namespace {
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2014-01-09 20:48:08 +01:00
|
|
|
/**
|
|
|
|
implements a read/write access to the global
|
|
|
|
accelerator configuration.
|
|
|
|
*/
|
2015-08-14 10:23:57 +09:00
|
|
|
typedef ::cppu::ImplInheritanceHelper<
|
2014-01-09 20:48:08 +01:00
|
|
|
XCUBasedAcceleratorConfiguration,
|
|
|
|
css::lang::XServiceInfo > GlobalAcceleratorConfiguration_BASE;
|
|
|
|
class GlobalAcceleratorConfiguration : public GlobalAcceleratorConfiguration_BASE
|
2004-09-20 09:05:55 +00:00
|
|
|
{
|
2014-01-09 20:48:08 +01:00
|
|
|
public:
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2014-01-09 20:48:08 +01:00
|
|
|
/** initialize this instance and fill the internal cache.
|
|
|
|
|
|
|
|
@param xSMGR
|
2014-02-09 10:12:07 +01:00
|
|
|
reference to an uno service manager, which is used internally.
|
2014-01-09 20:48:08 +01:00
|
|
|
*/
|
2015-12-29 19:27:43 +00:00
|
|
|
explicit GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext);
|
2008-12-01 13:46:00 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual OUString SAL_CALL getImplementationName() override
|
2014-01-09 20:48:08 +01:00
|
|
|
{
|
|
|
|
return OUString("com.sun.star.comp.framework.GlobalAcceleratorConfiguration");
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
|
2014-01-09 20:48:08 +01:00
|
|
|
{
|
|
|
|
return cppu::supportsService(this, ServiceName);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
|
2014-01-09 20:48:08 +01:00
|
|
|
{
|
2016-10-14 18:42:56 +05:30
|
|
|
return {"com.sun.star.ui.GlobalAcceleratorConfiguration"};
|
2014-01-09 20:48:08 +01:00
|
|
|
}
|
|
|
|
|
2014-01-22 11:54:19 +01:00
|
|
|
/// This has to be called after when the instance is acquire()'d.
|
|
|
|
void fillCache();
|
2014-01-09 20:48:08 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/** helper to listen for configuration changes without ownership cycle problems */
|
|
|
|
css::uno::Reference< css::util::XChangesListener > m_xCfgListener;
|
|
|
|
};
|
|
|
|
|
|
|
|
GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
|
|
|
|
: GlobalAcceleratorConfiguration_BASE(xContext)
|
2008-12-01 13:46:00 +00:00
|
|
|
{
|
2004-09-20 09:05:55 +00:00
|
|
|
}
|
|
|
|
|
2014-01-22 11:54:19 +01:00
|
|
|
void GlobalAcceleratorConfiguration::fillCache()
|
2004-09-20 09:05:55 +00:00
|
|
|
{
|
2014-01-09 20:48:08 +01:00
|
|
|
/** read all data into the cache. */
|
|
|
|
|
2013-03-28 00:13:14 +01:00
|
|
|
#if 0
|
2015-09-29 17:53:40 +02:00
|
|
|
// get current office locale ... but don't cache it.
|
2004-09-20 09:05:55 +00:00
|
|
|
// Otherwise we must be listener on the configuration layer
|
2017-03-02 12:26:19 +01:00
|
|
|
// which seems to superfluous for this small implementation .-)
|
2013-03-28 00:13:14 +01:00
|
|
|
// XXX: what is this good for? it was a comphelper::Locale but unused
|
|
|
|
LanguageTag aLanguageTag(m_sLocale);
|
|
|
|
#endif
|
2004-09-20 09:05:55 +00:00
|
|
|
|
2004-10-14 08:26:22 +00:00
|
|
|
// May be there exists no accelerator config? Handle it gracefully :-)
|
|
|
|
try
|
|
|
|
{
|
2008-12-01 13:46:00 +00:00
|
|
|
m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
|
|
|
|
XCUBasedAcceleratorConfiguration::reload();
|
|
|
|
|
|
|
|
css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
|
2011-03-23 16:10:20 +00:00
|
|
|
m_xCfgListener = new WeakChangesListener(this);
|
|
|
|
xBroadcaster->addChangesListener(m_xCfgListener);
|
2004-10-14 08:26:22 +00:00
|
|
|
}
|
2012-02-02 22:53:48 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2004-10-14 08:26:22 +00:00
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{}
|
2004-09-20 09:05:55 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 11:56:37 +02:00
|
|
|
struct Instance
|
|
|
|
{
|
|
|
|
explicit Instance(css::uno::Reference<css::uno::XComponentContext> const & context)
|
|
|
|
: instance(new GlobalAcceleratorConfiguration(context))
|
|
|
|
{
|
|
|
|
instance->fillCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::Reference<GlobalAcceleratorConfiguration> instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Singleton:
|
|
|
|
public rtl::StaticWithArg<
|
|
|
|
Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
|
|
|
|
{};
|
|
|
|
|
2014-01-09 20:48:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
|
|
|
|
com_sun_star_comp_framework_GlobalAcceleratorConfiguration_get_implementation(
|
|
|
|
css::uno::XComponentContext *context,
|
2014-01-22 11:54:19 +01:00
|
|
|
css::uno::Sequence<css::uno::Any> const &)
|
2014-01-09 20:48:08 +01:00
|
|
|
{
|
2017-02-19 11:56:37 +02:00
|
|
|
return cppu::acquire(static_cast<cppu::OWeakObject*>(Singleton::get(context).instance.get()));
|
2014-01-09 20:48:08 +01:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|