Line data Source code
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 :
20 : #include <accelerators/globalacceleratorconfiguration.hxx>
21 :
22 : #include <threadhelp/readguard.hxx>
23 : #include <threadhelp/writeguard.hxx>
24 : #include "helper/mischelper.hxx"
25 :
26 : #include <acceleratorconst.h>
27 : #include <services.h>
28 :
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <com/sun/star/embed/ElementModes.hpp>
31 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
32 : #include <com/sun/star/container/XNameAccess.hpp>
33 : #include <com/sun/star/util/XChangesNotifier.hpp>
34 :
35 : #include <vcl/svapp.hxx>
36 : #include <comphelper/locale.hxx>
37 : #include <comphelper/configurationhelper.hxx>
38 :
39 :
40 : namespace framework
41 : {
42 :
43 : //-----------------------------------------------
44 : // XInterface, XTypeProvider, XServiceInfo
45 0 : DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration ,
46 : XCUBasedAcceleratorConfiguration ,
47 : DIRECT_INTERFACE(css::lang::XServiceInfo),
48 : DIRECT_INTERFACE(css::lang::XInitialization))
49 0 : DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(GlobalAcceleratorConfiguration,
50 : XCUBasedAcceleratorConfiguration ,
51 : css::lang::XServiceInfo ,
52 : css::lang::XInitialization)
53 :
54 105 : DEFINE_XSERVICEINFO_MULTISERVICE(GlobalAcceleratorConfiguration ,
55 : ::cppu::OWeakObject ,
56 : DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration"),
57 : IMPLEMENTATIONNAME_GLOBALACCELERATORCONFIGURATION)
58 :
59 0 : DEFINE_INIT_SERVICE(GlobalAcceleratorConfiguration,
60 : {
61 : /*Attention
62 : I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
63 : to create a new instance of this class by our own supported service factory.
64 : see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
65 : */
66 : impl_ts_fillCache();
67 : }
68 : )
69 :
70 : //-----------------------------------------------
71 0 : GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
72 0 : : XCUBasedAcceleratorConfiguration(xSMGR)
73 : {
74 0 : }
75 :
76 : //-----------------------------------------------
77 0 : GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration()
78 : {
79 0 : }
80 :
81 0 : void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& /*lArguments*/)
82 : throw(css::uno::Exception ,
83 : css::uno::RuntimeException)
84 : {
85 0 : }
86 :
87 : //-----------------------------------------------
88 0 : void GlobalAcceleratorConfiguration::impl_ts_fillCache()
89 : {
90 : // get current office locale ... but dont cache it.
91 : // Otherwise we must be listener on the configuration layer
92 : // which seems to superflous for this small implementation .-)
93 0 : ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
94 :
95 : // May be there exists no accelerator config? Handle it gracefully :-)
96 : try
97 : {
98 0 : m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
99 0 : XCUBasedAcceleratorConfiguration::reload();
100 :
101 0 : css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
102 0 : m_xCfgListener = new WeakChangesListener(this);
103 0 : xBroadcaster->addChangesListener(m_xCfgListener);
104 : }
105 0 : catch(const css::uno::RuntimeException&)
106 0 : { throw; }
107 0 : catch(const css::uno::Exception&)
108 0 : {}
109 0 : }
110 :
111 : } // namespace framework
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|