1*6d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6d739b60SAndrew Rist * distributed with this work for additional information 6*6d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6d739b60SAndrew Rist * "License"); you may not use this file except in compliance 9*6d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*6d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*6d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6d739b60SAndrew Rist * software distributed under the License is distributed on an 15*6d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6d739b60SAndrew Rist * KIND, either express or implied. See the License for the 17*6d739b60SAndrew Rist * specific language governing permissions and limitations 18*6d739b60SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*6d739b60SAndrew Rist *************************************************************/ 21*6d739b60SAndrew Rist 22*6d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir #include <accelerators/moduleacceleratorconfiguration.hxx> 27cdf0e10cSrcweir 28cdf0e10cSrcweir //_______________________________________________ 29cdf0e10cSrcweir // own includes 30cdf0e10cSrcweir #include <threadhelp/readguard.hxx> 31cdf0e10cSrcweir #include <threadhelp/writeguard.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #ifndef __FRAMEWORK_ACCELERATORCONST_H_ 34cdf0e10cSrcweir #include <acceleratorconst.h> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #include <services.h> 37cdf0e10cSrcweir 38cdf0e10cSrcweir //_______________________________________________ 39cdf0e10cSrcweir // interface includes 40cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 41cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 43cdf0e10cSrcweir 44cdf0e10cSrcweir //_______________________________________________ 45cdf0e10cSrcweir // other includes 46cdf0e10cSrcweir 47cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX 48cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #include <vcl/svapp.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_ 53cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 54cdf0e10cSrcweir #endif 55cdf0e10cSrcweir 56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XCHANGESNOTIFIER_HPP_ 57cdf0e10cSrcweir #include <com/sun/star/util/XChangesNotifier.hpp> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir 60cdf0e10cSrcweir #ifndef _RTL_LOGFILE_HXX_ 61cdf0e10cSrcweir #include <rtl/logfile.hxx> 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir 64cdf0e10cSrcweir #ifndef _RTL_LOGFILE_HXX_ 65cdf0e10cSrcweir #include <rtl/logfile.h> 66cdf0e10cSrcweir #endif 67cdf0e10cSrcweir 68cdf0e10cSrcweir //_______________________________________________ 69cdf0e10cSrcweir // const 70cdf0e10cSrcweir 71cdf0e10cSrcweir namespace framework 72cdf0e10cSrcweir { 73cdf0e10cSrcweir 74cdf0e10cSrcweir //----------------------------------------------- 75cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 76cdf0e10cSrcweir DEFINE_XINTERFACE_2(ModuleAcceleratorConfiguration , 77cdf0e10cSrcweir XCUBasedAcceleratorConfiguration , 78cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XServiceInfo) , 79cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XInitialization)) 80cdf0e10cSrcweir 81cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(ModuleAcceleratorConfiguration, 82cdf0e10cSrcweir XCUBasedAcceleratorConfiguration , 83cdf0e10cSrcweir css::lang::XServiceInfo , 84cdf0e10cSrcweir css::lang::XInitialization ) 85cdf0e10cSrcweir 86cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE(ModuleAcceleratorConfiguration , 87cdf0e10cSrcweir ::cppu::OWeakObject , 88cdf0e10cSrcweir SERVICENAME_MODULEACCELERATORCONFIGURATION , 89cdf0e10cSrcweir IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION) 90cdf0e10cSrcweir 91cdf0e10cSrcweir DEFINE_INIT_SERVICE(ModuleAcceleratorConfiguration, 92cdf0e10cSrcweir { 93cdf0e10cSrcweir /*Attention 94cdf0e10cSrcweir I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() 95cdf0e10cSrcweir to create a new instance of this class by our own supported service factory. 96cdf0e10cSrcweir see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations! 97cdf0e10cSrcweir */ 98cdf0e10cSrcweir } 99cdf0e10cSrcweir ) 100cdf0e10cSrcweir 101cdf0e10cSrcweir //----------------------------------------------- 102cdf0e10cSrcweir ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR) 103cdf0e10cSrcweir : XCUBasedAcceleratorConfiguration(xSMGR) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration" ); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir //----------------------------------------------- 109cdf0e10cSrcweir ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration() 110cdf0e10cSrcweir { 111cdf0e10cSrcweir // m_aPresetHandler.removeStorageListener(this); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir //----------------------------------------------- 115cdf0e10cSrcweir void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments) 116cdf0e10cSrcweir throw(css::uno::Exception , 117cdf0e10cSrcweir css::uno::RuntimeException) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::initialize" ); 120cdf0e10cSrcweir // SAFE -> ---------------------------------- 121cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 122cdf0e10cSrcweir 123cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lArgs(lArguments); 124cdf0e10cSrcweir m_sModule = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleIdentifier"), ::rtl::OUString()); 125cdf0e10cSrcweir m_sLocale = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Locale") , ::rtl::OUString::createFromAscii("x-default")); 126cdf0e10cSrcweir 127cdf0e10cSrcweir if (!m_sModule.getLength()) 128cdf0e10cSrcweir throw css::uno::RuntimeException( 129cdf0e10cSrcweir ::rtl::OUString::createFromAscii("The module dependend accelerator configuration service was initialized with an empty module identifier!"), 130cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this)); 131cdf0e10cSrcweir 132cdf0e10cSrcweir aWriteLock.unlock(); 133cdf0e10cSrcweir // <- SAFE ---------------------------------- 134cdf0e10cSrcweir 135cdf0e10cSrcweir impl_ts_fillCache(); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir //----------------------------------------------- 139cdf0e10cSrcweir void ModuleAcceleratorConfiguration::impl_ts_fillCache() 140cdf0e10cSrcweir { 141cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::impl_ts_fillCache" ); 142cdf0e10cSrcweir // SAFE -> ---------------------------------- 143cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 144cdf0e10cSrcweir ::rtl::OUString sModule = m_sModule; 145cdf0e10cSrcweir m_sModuleCFG = m_sModule; 146cdf0e10cSrcweir aReadLock.unlock(); 147cdf0e10cSrcweir // <- SAFE ---------------------------------- 148cdf0e10cSrcweir 149cdf0e10cSrcweir // get current office locale ... but dont cache it. 150cdf0e10cSrcweir // Otherwise we must be listener on the configuration layer 151cdf0e10cSrcweir // which seems to superflous for this small implementation .-) 152cdf0e10cSrcweir ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale); 153cdf0e10cSrcweir 154cdf0e10cSrcweir // May be the current app module does not have any 155cdf0e10cSrcweir // accelerator config? Handle it gracefully :-) 156cdf0e10cSrcweir try 157cdf0e10cSrcweir { 158cdf0e10cSrcweir m_sGlobalOrModules = CFG_ENTRY_MODULES; 159cdf0e10cSrcweir XCUBasedAcceleratorConfiguration::reload(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW); 162cdf0e10cSrcweir xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this)); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun) 165cdf0e10cSrcweir { throw exRun; } 166cdf0e10cSrcweir catch(const css::uno::Exception&) 167cdf0e10cSrcweir {} 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir } // namespace framework 171cdf0e10cSrcweir 172