merge the formfield patch from ooo-build
[ooovba.git] / framework / source / accelerators / moduleacceleratorconfiguration.cxx
blob36599063ce5c4c1b1f08192e2175e50b54c5456f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: moduleacceleratorconfiguration.cxx,v $
10 * $Revision: 1.6.244.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
33 #include <accelerators/moduleacceleratorconfiguration.hxx>
35 //_______________________________________________
36 // own includes
37 #include <threadhelp/readguard.hxx>
38 #include <threadhelp/writeguard.hxx>
40 #ifndef __FRAMEWORK_ACCELERATORCONST_H_
41 #include <acceleratorconst.h>
42 #endif
43 #include <services.h>
45 //_______________________________________________
46 // interface includes
47 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
49 #include <com/sun/star/embed/ElementModes.hpp>
51 //_______________________________________________
52 // other includes
54 #ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX
55 #include <comphelper/sequenceashashmap.hxx>
56 #endif
57 #include <vcl/svapp.hxx>
59 #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
60 #include <comphelper/configurationhelper.hxx>
61 #endif
63 #ifndef _COM_SUN_STAR_UTIL_XCHANGESNOTIFIER_HPP_
64 #include <com/sun/star/util/XChangesNotifier.hpp>
65 #endif
67 #ifndef _RTL_LOGFILE_HXX_
68 #include <rtl/logfile.hxx>
69 #endif
71 #ifndef _RTL_LOGFILE_HXX_
72 #include <rtl/logfile.h>
73 #endif
75 //_______________________________________________
76 // const
78 namespace framework
81 //-----------------------------------------------
82 // XInterface, XTypeProvider, XServiceInfo
83 DEFINE_XINTERFACE_2(ModuleAcceleratorConfiguration ,
84 XCUBasedAcceleratorConfiguration ,
85 DIRECT_INTERFACE(css::lang::XServiceInfo) ,
86 DIRECT_INTERFACE(css::lang::XInitialization))
88 DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(ModuleAcceleratorConfiguration,
89 XCUBasedAcceleratorConfiguration ,
90 css::lang::XServiceInfo ,
91 css::lang::XInitialization )
93 DEFINE_XSERVICEINFO_MULTISERVICE(ModuleAcceleratorConfiguration ,
94 ::cppu::OWeakObject ,
95 SERVICENAME_MODULEACCELERATORCONFIGURATION ,
96 IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION)
98 DEFINE_INIT_SERVICE(ModuleAcceleratorConfiguration,
100 /*Attention
101 I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
102 to create a new instance of this class by our own supported service factory.
103 see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
108 //-----------------------------------------------
109 ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
110 : XCUBasedAcceleratorConfiguration(xSMGR)
112 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration" );
115 //-----------------------------------------------
116 ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration()
118 // m_aPresetHandler.removeStorageListener(this);
121 //-----------------------------------------------
122 void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
123 throw(css::uno::Exception ,
124 css::uno::RuntimeException)
126 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::initialize" );
127 // SAFE -> ----------------------------------
128 WriteGuard aWriteLock(m_aLock);
130 ::comphelper::SequenceAsHashMap lArgs(lArguments);
131 m_sModule = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleIdentifier"), ::rtl::OUString());
132 m_sLocale = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Locale") , ::rtl::OUString::createFromAscii("x-default"));
134 if (!m_sModule.getLength())
135 throw css::uno::RuntimeException(
136 ::rtl::OUString::createFromAscii("The module dependend accelerator configuration service was initialized with an empty module identifier!"),
137 static_cast< ::cppu::OWeakObject* >(this));
139 aWriteLock.unlock();
140 // <- SAFE ----------------------------------
142 impl_ts_fillCache();
145 //-----------------------------------------------
146 void ModuleAcceleratorConfiguration::impl_ts_fillCache()
148 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::impl_ts_fillCache" );
149 // SAFE -> ----------------------------------
150 ReadGuard aReadLock(m_aLock);
151 ::rtl::OUString sModule = m_sModule;
152 m_sModuleCFG = m_sModule;
153 aReadLock.unlock();
154 // <- SAFE ----------------------------------
156 // get current office locale ... but dont cache it.
157 // Otherwise we must be listener on the configuration layer
158 // which seems to superflous for this small implementation .-)
159 ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
161 // May be the current app module does not have any
162 // accelerator config? Handle it gracefully :-)
165 m_sGlobalOrModules = CFG_ENTRY_MODULES;
166 XCUBasedAcceleratorConfiguration::reload();
168 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
169 xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
171 catch(const css::uno::RuntimeException& exRun)
172 { throw exRun; }
173 catch(const css::uno::Exception&)
177 } // namespace framework