1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_framework.hxx"
26 #include <accelerators/globalacceleratorconfiguration.hxx>
27
28 //_______________________________________________
29 // own includes
30 #include <threadhelp/readguard.hxx>
31 #include <threadhelp/writeguard.hxx>
32
33 #include <acceleratorconst.h>
34 #include <services.h>
35
36 //_______________________________________________
37 // interface includes
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/embed/ElementModes.hpp>
40 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
41 #include <com/sun/star/container/XNameAccess.hpp>
42 #include <com/sun/star/util/XChangesNotifier.hpp>
43
44 //_______________________________________________
45 // other includes
46 #include <vcl/svapp.hxx>
47 #include <comphelper/locale.hxx>
48 #include <comphelper/configurationhelper.hxx>
49
50 //_______________________________________________
51 // const
52
53 namespace framework
54 {
55
56 //-----------------------------------------------
57 // XInterface, XTypeProvider, XServiceInfo
DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration,XCUBasedAcceleratorConfiguration,DIRECT_INTERFACE (css::lang::XServiceInfo),DIRECT_INTERFACE (css::lang::XInitialization))58 DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration ,
59 XCUBasedAcceleratorConfiguration ,
60 DIRECT_INTERFACE(css::lang::XServiceInfo),
61 DIRECT_INTERFACE(css::lang::XInitialization))
62 DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(GlobalAcceleratorConfiguration,
63 XCUBasedAcceleratorConfiguration ,
64 css::lang::XServiceInfo ,
65 css::lang::XInitialization)
66
67 DEFINE_XSERVICEINFO_MULTISERVICE(GlobalAcceleratorConfiguration ,
68 ::cppu::OWeakObject ,
69 SERVICENAME_GLOBALACCELERATORCONFIGURATION ,
70 IMPLEMENTATIONNAME_GLOBALACCELERATORCONFIGURATION)
71
72 DEFINE_INIT_SERVICE(GlobalAcceleratorConfiguration,
73 {
74 /*Attention
75 I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
76 to create a new instance of this class by our own supported service factory.
77 see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
78 */
79 impl_ts_fillCache();
80 }
81 )
82
83 //-----------------------------------------------
84 GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
85 : XCUBasedAcceleratorConfiguration(xSMGR)
86 {
87 }
88
89 //-----------------------------------------------
~GlobalAcceleratorConfiguration()90 GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration()
91 {
92 }
93
initialize(const css::uno::Sequence<css::uno::Any> &)94 void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& /*lArguments*/)
95 {
96 }
97
98 //-----------------------------------------------
impl_ts_fillCache()99 void GlobalAcceleratorConfiguration::impl_ts_fillCache()
100 {
101 // get current office locale ... but dont cache it.
102 // Otherwise we must be listener on the configuration layer
103 // which seems to superflous for this small implementation .-)
104 ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
105
106 // May be there exists no accelerator config? Handle it gracefully :-)
107 try
108 {
109 m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
110 XCUBasedAcceleratorConfiguration::reload();
111
112 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
113 xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
114 }
115 catch(const css::uno::RuntimeException& exRun)
116 { throw exRun; }
117 catch(const css::uno::Exception&)
118 {}
119 }
120
121 //-----------------------------------------------
122 //
123 // XComponent.dispose(), #120029#, to release the cyclic reference
124 //
dispose()125 void SAL_CALL GlobalAcceleratorConfiguration::dispose()
126 {
127 try
128 {
129 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
130 if ( xBroadcaster.is() )
131 xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
132 }
133 catch(const css::uno::RuntimeException& exRun)
134 { throw exRun; }
135 catch(const css::uno::Exception&)
136 {}
137 }
138
139 } // namespace framework
140