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:06:24 +00:00
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
#include <accelerators/acceleratorconfiguration.hxx>
|
|
|
|
#include <accelerators/presethandler.hxx>
|
2017-10-23 22:41:08 +02:00
|
|
|
#include <helper/mischelper.hxx>
|
2004-09-20 09:06:24 +00:00
|
|
|
|
|
|
|
#include <acceleratorconst.h>
|
|
|
|
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2014-01-09 20:33:11 +01:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
2004-09-20 09:06:24 +00:00
|
|
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2004-09-20 09:06:24 +00:00
|
|
|
#include <comphelper/sequenceashashmap.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
2008-12-01 13:46:00 +00:00
|
|
|
#include <com/sun/star/util/XChangesNotifier.hpp>
|
|
|
|
|
2015-08-14 10:23:57 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2014-01-09 20:33:11 +01:00
|
|
|
#include <rtl/ref.hxx>
|
2008-12-01 13:46:00 +00:00
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
using namespace framework;
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
namespace {
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
/**
|
|
|
|
implements a read/write access to a module
|
2014-04-09 12:44:22 +02:00
|
|
|
dependent accelerator configuration.
|
2014-01-09 20:33:11 +01:00
|
|
|
*/
|
2015-08-14 10:23:57 +09:00
|
|
|
typedef ::cppu::ImplInheritanceHelper<
|
2014-01-09 20:33:11 +01:00
|
|
|
XCUBasedAcceleratorConfiguration,
|
|
|
|
css::lang::XServiceInfo > ModuleAcceleratorConfiguration_BASE;
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
class ModuleAcceleratorConfiguration : public ModuleAcceleratorConfiguration_BASE
|
2004-09-20 09:06:24 +00:00
|
|
|
{
|
2014-01-09 20:33:11 +01:00
|
|
|
private:
|
|
|
|
/** identify the application module, where this accelerator
|
|
|
|
configuration cache should work on. */
|
|
|
|
OUString m_sModule;
|
|
|
|
OUString m_sLocale;
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
/** 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:33:11 +01:00
|
|
|
*/
|
|
|
|
ModuleAcceleratorConfiguration(
|
2014-01-22 11:54:19 +01:00
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& xContext,
|
2015-10-13 16:59:57 +02:00
|
|
|
const css::uno::Sequence< css::uno::Any >& lArguments);
|
2014-01-09 20:33:11 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual OUString SAL_CALL getImplementationName() override
|
2014-01-09 20:33:11 +01:00
|
|
|
{
|
|
|
|
return OUString("com.sun.star.comp.framework.ModuleAcceleratorConfiguration");
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
|
2014-01-09 20:33:11 +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:33:11 +01:00
|
|
|
{
|
2016-10-14 18:42:56 +05:30
|
|
|
return {"com.sun.star.ui.ModuleAcceleratorConfiguration"};
|
2014-01-09 20:33:11 +01:00
|
|
|
}
|
|
|
|
|
2014-01-22 11:54:19 +01:00
|
|
|
/// This has to be called after when the instance is acquire()'d.
|
|
|
|
void SAL_CALL fillCache();
|
2014-01-09 20:33:11 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
/** helper to listen for configuration changes without ownership cycle problems */
|
|
|
|
css::uno::Reference< css::util::XChangesListener > m_xCfgListener;
|
|
|
|
};
|
|
|
|
|
|
|
|
ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(
|
2014-01-22 11:54:19 +01:00
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& xContext,
|
2015-10-13 16:59:57 +02:00
|
|
|
const css::uno::Sequence< css::uno::Any >& lArguments)
|
2014-01-09 20:33:11 +01:00
|
|
|
: ModuleAcceleratorConfiguration_BASE(xContext)
|
2004-09-20 09:06:24 +00:00
|
|
|
{
|
2014-03-18 08:16:40 +01:00
|
|
|
SolarMutexGuard g;
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2013-05-27 14:52:39 +02:00
|
|
|
OUString sModule;
|
|
|
|
if (lArguments.getLength() == 1 && (lArguments[0] >>= sModule))
|
|
|
|
{
|
|
|
|
m_sModule = sModule;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
::comphelper::SequenceAsHashMap lArgs(lArguments);
|
2013-06-29 21:24:12 +02:00
|
|
|
m_sModule = lArgs.getUnpackedValueOrDefault("ModuleIdentifier", OUString());
|
|
|
|
m_sLocale = lArgs.getUnpackedValueOrDefault("Locale", OUString("x-default"));
|
2013-05-27 14:52:39 +02:00
|
|
|
}
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2011-12-26 14:20:50 -02:00
|
|
|
if (m_sModule.isEmpty())
|
2004-09-20 09:06:24 +00:00
|
|
|
throw css::uno::RuntimeException(
|
2017-01-27 16:09:54 +02:00
|
|
|
"The module dependent accelerator configuration service was initialized with an empty module identifier!",
|
2004-09-20 09:06:24 +00:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this));
|
2014-01-22 11:54:19 +01:00
|
|
|
}
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2014-01-22 11:54:19 +01:00
|
|
|
void ModuleAcceleratorConfiguration::fillCache()
|
|
|
|
{
|
2014-03-18 08:16:40 +01:00
|
|
|
{
|
|
|
|
SolarMutexGuard g;
|
|
|
|
m_sModuleCFG = m_sModule;
|
|
|
|
}
|
2004-09-20 09:06:24 +00:00
|
|
|
|
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:06:24 +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:06:24 +00:00
|
|
|
|
2004-10-14 08:26:22 +00:00
|
|
|
// May be the current app module does not have any
|
|
|
|
// accelerator config? Handle it gracefully :-)
|
|
|
|
try
|
|
|
|
{
|
2008-12-01 13:46:00 +00:00
|
|
|
m_sGlobalOrModules = CFG_ENTRY_MODULES;
|
|
|
|
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:06:24 +00:00
|
|
|
}
|
|
|
|
|
2014-01-09 20:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
|
|
|
|
com_sun_star_comp_framework_ModuleAcceleratorConfiguration_get_implementation(
|
|
|
|
css::uno::XComponentContext *context,
|
2014-01-22 11:54:19 +01:00
|
|
|
css::uno::Sequence<css::uno::Any> const &arguments)
|
2014-01-09 20:33:11 +01:00
|
|
|
{
|
2014-01-22 11:54:19 +01:00
|
|
|
ModuleAcceleratorConfiguration *inst = new ModuleAcceleratorConfiguration(context, arguments);
|
|
|
|
css::uno::XInterface *acquired_inst = cppu::acquire(inst);
|
|
|
|
|
|
|
|
inst->fillCache();
|
2014-01-21 15:45:43 +01:00
|
|
|
|
2014-01-22 11:54:19 +01:00
|
|
|
return acquired_inst;
|
2014-01-09 20:33:11 +01:00
|
|
|
}
|
2004-11-17 13:58:05 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|