2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-09-20 09:06:24 +00:00
|
|
|
|
|
|
|
#include <accelerators/moduleacceleratorconfiguration.hxx>
|
|
|
|
|
|
|
|
#include <threadhelp/readguard.hxx>
|
|
|
|
#include <threadhelp/writeguard.hxx>
|
2011-03-23 16:10:20 +00:00
|
|
|
#include "helper/mischelper.hxx"
|
2004-09-20 09:06:24 +00:00
|
|
|
|
|
|
|
#include <acceleratorconst.h>
|
|
|
|
#include <services.h>
|
|
|
|
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
2013-05-27 14:52:39 +02:00
|
|
|
#define SERVICENAME_MODULEACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.ModuleAcceleratorConfiguration")
|
|
|
|
#define IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.comp.framework.ModuleAcceleratorConfiguration")
|
2004-09-20 09:06:24 +00:00
|
|
|
|
|
|
|
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 )
|
|
|
|
|
2013-05-27 15:15:03 +02:00
|
|
|
DEFINE_XSERVICEINFO_MULTISERVICE_2(ModuleAcceleratorConfiguration ,
|
|
|
|
::cppu::OWeakObject ,
|
|
|
|
SERVICENAME_MODULEACCELERATORCONFIGURATION ,
|
|
|
|
IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION)
|
2004-09-20 09:06:24 +00:00
|
|
|
|
|
|
|
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.
|
2013-04-15 04:49:39 +02:00
|
|
|
see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further information!
|
2004-09-20 09:06:24 +00:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2013-05-27 15:15:03 +02:00
|
|
|
ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
|
|
|
|
: XCUBasedAcceleratorConfiguration(xContext)
|
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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
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);
|
|
|
|
|
2013-05-27 14:52:39 +02:00
|
|
|
OUString sModule;
|
|
|
|
if (lArguments.getLength() == 1 && (lArguments[0] >>= sModule))
|
|
|
|
{
|
|
|
|
m_sModule = sModule;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
::comphelper::SequenceAsHashMap lArgs(lArguments);
|
|
|
|
m_sModule = lArgs.getUnpackedValueOrDefault(OUString("ModuleIdentifier"), OUString());
|
|
|
|
m_sLocale = lArgs.getUnpackedValueOrDefault(OUString("Locale") , OUString("x-default"));
|
|
|
|
}
|
2004-09-20 09:06:24 +00:00
|
|
|
|
2011-12-26 14:20:50 -02:00
|
|
|
if (m_sModule.isEmpty())
|
2004-09-20 09:06:24 +00:00
|
|
|
throw css::uno::RuntimeException(
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString("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);
|
2008-12-01 13:46:00 +00:00
|
|
|
m_sModuleCFG = m_sModule;
|
2004-09-20 09:06:24 +00:00
|
|
|
aReadLock.unlock();
|
|
|
|
// <- SAFE ----------------------------------
|
|
|
|
|
2013-03-28 00:13:14 +01:00
|
|
|
#if 0
|
2004-09-20 09:06:24 +00:00
|
|
|
// 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 .-)
|
2013-03-28 00:13:14 +01:00
|
|
|
// XXX: what is this good for? it was a comphelper::Locale but unused
|
|
|
|
LanguageTag aLanguageTag(m_sLocale);
|
|
|
|
#endif
|
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);
|
2011-03-23 16:10:20 +00:00
|
|
|
m_xCfgListener = new WeakChangesListener(this);
|
|
|
|
xBroadcaster->addChangesListener(m_xCfgListener);
|
2004-10-14 08:26:22 +00:00
|
|
|
}
|
2012-02-02 22:53:48 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2004-10-14 08:26:22 +00:00
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{}
|
2004-09-20 09:06:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 11:58:32 +00:00
|
|
|
//-----------------------------------------------
|
|
|
|
//
|
|
|
|
// XComponent.dispose(), #i120029#, to release the cyclic reference
|
|
|
|
//
|
|
|
|
void SAL_CALL ModuleAcceleratorConfiguration::dispose()
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
|
|
|
|
if ( xBroadcaster.is() )
|
|
|
|
xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
|
|
|
|
}
|
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
|
|
|
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: */
|