LibreOffice Module framework (master) 1
globalacceleratorconfiguration.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22#include <helper/mischelper.hxx>
23
24#include <com/sun/star/util/XChangesNotifier.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26
29#include <rtl/ref.hxx>
30
31using namespace framework;
32
33namespace {
34
39typedef ::cppu::ImplInheritanceHelper<
41 css::lang::XServiceInfo > GlobalAcceleratorConfiguration_BASE;
42class GlobalAcceleratorConfiguration : public GlobalAcceleratorConfiguration_BASE
43{
44public:
45
51 explicit GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext);
52
53 virtual OUString SAL_CALL getImplementationName() override
54 {
55 return "com.sun.star.comp.framework.GlobalAcceleratorConfiguration";
56 }
57
58 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
59 {
60 return cppu::supportsService(this, ServiceName);
61 }
62
63 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
64 {
65 return {"com.sun.star.ui.GlobalAcceleratorConfiguration"};
66 }
67
69 void fillCache();
70
71private:
72
74 css::uno::Reference< css::util::XChangesListener > m_xCfgListener;
75};
76
77GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
78 : GlobalAcceleratorConfiguration_BASE(xContext)
79{
80 // force keyboard string registration.
81 KeyMapping::get();
82}
83
84void GlobalAcceleratorConfiguration::fillCache()
85{
88#if 0
89 // get current office locale ... but don't cache it.
90 // Otherwise we must be listener on the configuration layer
91 // which seems to superfluous for this small implementation .-)
92 // XXX: what is this good for? it was a comphelper::Locale but unused
93 LanguageTag aLanguageTag(m_sLocale);
94#endif
95
96 // May be there exists no accelerator config? Handle it gracefully :-)
97 try
98 {
99 m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
100 XCUBasedAcceleratorConfiguration::reload();
101
102 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
103 m_xCfgListener = new WeakChangesListener(this);
104 xBroadcaster->addChangesListener(m_xCfgListener);
105 }
106 catch(const css::uno::RuntimeException&)
107 { throw; }
108 catch(const css::uno::Exception&)
109 {}
110}
111
112}
113
114extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
116 css::uno::XComponentContext *context,
117 css::uno::Sequence<css::uno::Any> const &)
118{
119 rtl::Reference<GlobalAcceleratorConfiguration> xGAC = new GlobalAcceleratorConfiguration(context);
120 xGAC->fillCache();
121 return cppu::acquire(xGAC.get());
122}
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_GlobalAcceleratorConfiguration_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral CFG_ENTRY_GLOBAL
unsigned char sal_Bool