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/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 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 //----------------------------------------------- 90cdf0e10cSrcweir GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration() 91cdf0e10cSrcweir { 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 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 //----------------------------------------------- 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 123cdf0e10cSrcweir } // namespace framework 124