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 throw(css::uno::Exception ,
96 css::uno::RuntimeException)
97 {
98 }
99
100 //-----------------------------------------------
impl_ts_fillCache()101 void GlobalAcceleratorConfiguration::impl_ts_fillCache()
102 {
103 // get current office locale ... but dont cache it.
104 // Otherwise we must be listener on the configuration layer
105 // which seems to superflous for this small implementation .-)
106 ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
107
108 // May be there exists no accelerator config? Handle it gracefully :-)
109 try
110 {
111 m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
112 XCUBasedAcceleratorConfiguration::reload();
113
114 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
115 xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
116 }
117 catch(const css::uno::RuntimeException& exRun)
118 { throw exRun; }
119 catch(const css::uno::Exception&)
120 {}
121 }
122
123 //-----------------------------------------------
124 //
125 // XComponent.dispose(), #120029#, to release the cyclic reference
126 //
dispose()127 void SAL_CALL GlobalAcceleratorConfiguration::dispose()
128 throw(css::uno::RuntimeException)
129 {
130 try
131 {
132 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
133 if ( xBroadcaster.is() )
134 xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
135 }
136 catch(const css::uno::RuntimeException& exRun)
137 { throw exRun; }
138 catch(const css::uno::Exception&)
139 {}
140 }
141
142 } // namespace framework
143