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