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 <i18nlangtag/languagetag.hxx>
37 : #include <comphelper/configurationhelper.hxx>
38 :
39 : #define IMPLEMENTATIONNAME_GLOBALACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.comp.framework.GlobalAcceleratorConfiguration")
40 :
41 : namespace framework
42 : {
43 :
44 : //-----------------------------------------------
45 : // XInterface, XTypeProvider, XServiceInfo
46 136782 : DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration ,
47 : XCUBasedAcceleratorConfiguration ,
48 : DIRECT_INTERFACE(css::lang::XServiceInfo),
49 : DIRECT_INTERFACE(css::lang::XInitialization))
50 0 : DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(GlobalAcceleratorConfiguration,
51 : XCUBasedAcceleratorConfiguration ,
52 : css::lang::XServiceInfo ,
53 : css::lang::XInitialization)
54 :
55 2466 : DEFINE_XSERVICEINFO_MULTISERVICE_2(GlobalAcceleratorConfiguration ,
56 : ::cppu::OWeakObject ,
57 : DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration"),
58 : IMPLEMENTATIONNAME_GLOBALACCELERATORCONFIGURATION)
59 :
60 1382 : DEFINE_INIT_SERVICE(GlobalAcceleratorConfiguration,
61 : {
62 : /*Attention
63 : I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
64 : to create a new instance of this class by our own supported service factory.
65 : see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further information!
66 : */
67 : impl_ts_fillCache();
68 : }
69 : )
70 :
71 : //-----------------------------------------------
72 1382 : GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
73 1382 : : XCUBasedAcceleratorConfiguration(xContext)
74 : {
75 1382 : }
76 :
77 : //-----------------------------------------------
78 2764 : GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration()
79 : {
80 2764 : }
81 :
82 0 : void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& /*lArguments*/)
83 : throw(css::uno::Exception ,
84 : css::uno::RuntimeException)
85 : {
86 0 : }
87 :
88 : //-----------------------------------------------
89 1382 : void GlobalAcceleratorConfiguration::impl_ts_fillCache()
90 : {
91 : #if 0
92 : // get current office locale ... but dont cache it.
93 : // Otherwise we must be listener on the configuration layer
94 : // which seems to superflous for this small implementation .-)
95 : // XXX: what is this good for? it was a comphelper::Locale but unused
96 : LanguageTag aLanguageTag(m_sLocale);
97 : #endif
98 :
99 : // May be there exists no accelerator config? Handle it gracefully :-)
100 : try
101 : {
102 1382 : m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
103 1382 : XCUBasedAcceleratorConfiguration::reload();
104 :
105 1382 : css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
106 1382 : m_xCfgListener = new WeakChangesListener(this);
107 1382 : xBroadcaster->addChangesListener(m_xCfgListener);
108 : }
109 0 : catch(const css::uno::RuntimeException&)
110 0 : { throw; }
111 0 : catch(const css::uno::Exception&)
112 : {}
113 1382 : }
114 :
115 : //-----------------------------------------------
116 : //
117 : // XComponent.dispose(), #i120029#, to release the cyclic reference
118 : //
119 1381 : void SAL_CALL GlobalAcceleratorConfiguration::dispose()
120 : throw(css::uno::RuntimeException)
121 : {
122 : try
123 : {
124 1381 : css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
125 1381 : if ( xBroadcaster.is() )
126 1381 : xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
127 : }
128 0 : catch(const css::uno::RuntimeException&)
129 0 : { throw; }
130 0 : catch(const css::uno::Exception&)
131 : {}
132 1381 : }
133 :
134 402 : } // namespace framework
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|