2010-10-12 15:53:47 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2004-09-20 09:06:24 +00:00
/*************************************************************************
*
2008-04-11 07:10:39 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2004-09-20 09:06:24 +00:00
*
2010-02-12 15:01:35 +01:00
* Copyright 2000 , 2010 Oracle and / or its affiliates .
2004-09-20 09:06:24 +00:00
*
2008-04-11 07:10:39 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2004-09-20 09:06:24 +00:00
*
2008-04-11 07:10:39 +00:00
* This file is part of OpenOffice . org .
2004-09-20 09:06:24 +00:00
*
2008-04-11 07:10:39 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2004-09-20 09:06:24 +00:00
*
2008-04-11 07:10:39 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2004-09-20 09:06:24 +00:00
*
2008-04-11 07:10:39 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2004-09-20 09:06:24 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-16 12:42:01 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_framework.hxx"
2004-09-20 09:06:24 +00:00
# include <accelerators/moduleacceleratorconfiguration.hxx>
//_______________________________________________
// own includes
# include <threadhelp/readguard.hxx>
# include <threadhelp/writeguard.hxx>
# include <acceleratorconst.h>
# include <services.h>
//_______________________________________________
// interface includes
# include <com/sun/star/beans/XPropertySet.hpp>
# include <com/sun/star/lang/XSingleServiceFactory.hpp>
# include <com/sun/star/embed/ElementModes.hpp>
//_______________________________________________
// other includes
# include <comphelper/sequenceashashmap.hxx>
# include <vcl/svapp.hxx>
2008-12-01 13:46:00 +00:00
# include <comphelper/configurationhelper.hxx>
# include <com/sun/star/util/XChangesNotifier.hpp>
# include <rtl/logfile.hxx>
# include <rtl/logfile.h>
2004-09-20 09:06:24 +00:00
//_______________________________________________
// const
namespace framework
{
//-----------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
DEFINE_XINTERFACE_2 ( ModuleAcceleratorConfiguration ,
2008-12-01 13:46:00 +00:00
XCUBasedAcceleratorConfiguration ,
2004-09-20 09:06:24 +00:00
DIRECT_INTERFACE ( css : : lang : : XServiceInfo ) ,
DIRECT_INTERFACE ( css : : lang : : XInitialization ) )
DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS ( ModuleAcceleratorConfiguration ,
2008-12-01 13:46:00 +00:00
XCUBasedAcceleratorConfiguration ,
2004-09-20 09:06:24 +00:00
css : : lang : : XServiceInfo ,
css : : lang : : XInitialization )
DEFINE_XSERVICEINFO_MULTISERVICE ( ModuleAcceleratorConfiguration ,
: : cppu : : OWeakObject ,
SERVICENAME_MODULEACCELERATORCONFIGURATION ,
IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION )
DEFINE_INIT_SERVICE ( ModuleAcceleratorConfiguration ,
{
/*Attention
I think we don ' t need any mutex or lock here . . . because we are called by our own static method impl_createInstance ( )
to create a new instance of this class by our own supported service factory .
see macro DEFINE_XSERVICEINFO_MULTISERVICE and " impl_initService() " for further informations !
*/
}
)
//-----------------------------------------------
ModuleAcceleratorConfiguration : : ModuleAcceleratorConfiguration ( const css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR )
2008-12-01 13:46:00 +00:00
: XCUBasedAcceleratorConfiguration ( xSMGR )
2004-09-20 09:06:24 +00:00
{
2009-09-08 04:57:32 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLogger , " framework " , " Ocke.Janssen@sun.com " , " ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration " ) ;
2004-09-20 09:06:24 +00:00
}
//-----------------------------------------------
ModuleAcceleratorConfiguration : : ~ ModuleAcceleratorConfiguration ( )
{
2008-12-01 13:46:00 +00:00
// m_aPresetHandler.removeStorageListener(this);
2004-09-20 09:06:24 +00:00
}
//-----------------------------------------------
void SAL_CALL ModuleAcceleratorConfiguration : : initialize ( const css : : uno : : Sequence < css : : uno : : Any > & lArguments )
throw ( css : : uno : : Exception ,
css : : uno : : RuntimeException )
{
2009-09-08 04:57:32 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLogger , " framework " , " Ocke.Janssen@sun.com " , " ModuleAcceleratorConfiguration::initialize " ) ;
2004-09-20 09:06:24 +00:00
// SAFE -> ----------------------------------
WriteGuard aWriteLock ( m_aLock ) ;
: : comphelper : : SequenceAsHashMap lArgs ( lArguments ) ;
2010-11-20 12:20:55 +01:00
m_sModule = lArgs . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ModuleIdentifier " ) ) , : : rtl : : OUString ( ) ) ;
m_sLocale = lArgs . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Locale " ) ) , : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " x-default " ) ) ) ;
2004-09-20 09:06:24 +00:00
if ( ! m_sModule . getLength ( ) )
throw css : : uno : : RuntimeException (
2010-11-20 12:20:55 +01:00
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The module dependend accelerator configuration service was initialized with an empty module identifier! " ) ) ,
2004-09-20 09:06:24 +00:00
static_cast < : : cppu : : OWeakObject * > ( this ) ) ;
aWriteLock . unlock ( ) ;
// <- SAFE ----------------------------------
impl_ts_fillCache ( ) ;
}
//-----------------------------------------------
void ModuleAcceleratorConfiguration : : impl_ts_fillCache ( )
{
2009-09-08 04:57:32 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLogger , " framework " , " Ocke.Janssen@sun.com " , " ModuleAcceleratorConfiguration::impl_ts_fillCache " ) ;
2004-09-20 09:06:24 +00:00
// SAFE -> ----------------------------------
ReadGuard aReadLock ( m_aLock ) ;
: : rtl : : OUString sModule = m_sModule ;
2008-12-01 13:46:00 +00:00
m_sModuleCFG = m_sModule ;
2004-09-20 09:06:24 +00:00
aReadLock . unlock ( ) ;
// <- SAFE ----------------------------------
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
2008-12-01 13:46:00 +00:00
: : comphelper : : Locale aLocale = : : comphelper : : Locale ( m_sLocale ) ;
2004-09-20 09:06:24 +00:00
2004-10-14 08:26:22 +00:00
// May be the current app module does not have any
// accelerator config? Handle it gracefully :-)
try
{
2008-12-01 13:46:00 +00:00
m_sGlobalOrModules = CFG_ENTRY_MODULES ;
XCUBasedAcceleratorConfiguration : : reload ( ) ;
css : : uno : : Reference < css : : util : : XChangesNotifier > xBroadcaster ( m_xCfg , css : : uno : : UNO_QUERY_THROW ) ;
xBroadcaster - > addChangesListener ( static_cast < css : : util : : XChangesListener * > ( this ) ) ;
2004-10-14 08:26:22 +00:00
}
catch ( const css : : uno : : RuntimeException & exRun )
{ throw exRun ; }
catch ( const css : : uno : : Exception & )
{ }
2004-09-20 09:06:24 +00:00
}
} // namespace framework
2004-11-17 13:58:05 +00:00
2010-10-12 15:53:47 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */