xref: /AOO41X/main/framework/source/accelerators/globalacceleratorconfiguration.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
30 #include <accelerators/globalacceleratorconfiguration.hxx>
31 
32 //_______________________________________________
33 // own includes
34 #include <threadhelp/readguard.hxx>
35 #include <threadhelp/writeguard.hxx>
36 
37 #include <acceleratorconst.h>
38 #include <services.h>
39 
40 //_______________________________________________
41 // interface includes
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/embed/ElementModes.hpp>
44 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/util/XChangesNotifier.hpp>
47 
48 //_______________________________________________
49 // other includes
50 #include <vcl/svapp.hxx>
51 #include <comphelper/locale.hxx>
52 #include <comphelper/configurationhelper.hxx>
53 
54 //_______________________________________________
55 // const
56 
57 namespace framework
58 {
59 
60 //-----------------------------------------------
61 // XInterface, XTypeProvider, XServiceInfo
62 DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration           ,
63                     XCUBasedAcceleratorConfiguration                 ,
64                     DIRECT_INTERFACE(css::lang::XServiceInfo),
65 					DIRECT_INTERFACE(css::lang::XInitialization))
66 DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(GlobalAcceleratorConfiguration,
67                                       XCUBasedAcceleratorConfiguration      ,
68                                       css::lang::XServiceInfo       ,
69 									  css::lang::XInitialization)
70 
71 DEFINE_XSERVICEINFO_MULTISERVICE(GlobalAcceleratorConfiguration                   ,
72                                  ::cppu::OWeakObject                              ,
73                                  SERVICENAME_GLOBALACCELERATORCONFIGURATION       ,
74                                  IMPLEMENTATIONNAME_GLOBALACCELERATORCONFIGURATION)
75 
76 DEFINE_INIT_SERVICE(GlobalAcceleratorConfiguration,
77                     {
78                         /*Attention
79                         I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
80                         to create a new instance of this class by our own supported service factory.
81                         see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
82                         */
83                         impl_ts_fillCache();
84                     }
85                    )
86 
87 //-----------------------------------------------
88 GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
89     : XCUBasedAcceleratorConfiguration(xSMGR)
90 {
91 }
92 
93 //-----------------------------------------------
94 GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration()
95 {
96 }
97 
98 void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& /*lArguments*/)
99 	throw(css::uno::Exception		,
100 		  css::uno::RuntimeException)
101 {
102 }
103 
104 //-----------------------------------------------
105 void GlobalAcceleratorConfiguration::impl_ts_fillCache()
106 {
107     // get current office locale ... but dont cache it.
108     // Otherwise we must be listener on the configuration layer
109     // which seems to superflous for this small implementation .-)
110 	::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
111 
112     // May be there exists no accelerator config? Handle it gracefully :-)
113     try
114     {
115         m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
116         XCUBasedAcceleratorConfiguration::reload();
117 
118 		css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
119 		xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
120     }
121     catch(const css::uno::RuntimeException& exRun)
122         { throw exRun; }
123     catch(const css::uno::Exception&)
124         {}
125 }
126 
127 } // namespace framework
128