diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 20:58:27 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-18 17:02:37 +0100 |
commit | 7dca32d575ab974e5f42f579bdeda21d2e445efe (patch) | |
tree | 420ffff2d8d6a586c666038f52fa7b2879bc2ec1 /framework | |
parent | 72b5343bd16deec540d8cd148cd7aebd74e92c16 (diff) |
fwk: Use constructor feature for DocumentAcceleratorConfiguration.
And avoid css::uno::XInitialization protocol.
Change-Id: I14daf6409bf0d651d7b23246ba3855f647b3d1ef
Diffstat (limited to 'framework')
4 files changed, 95 insertions, 161 deletions
diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx index d9e8689a7d42..be029dd46667 100644 --- a/framework/source/accelerators/documentacceleratorconfiguration.cxx +++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx @@ -17,74 +17,105 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <accelerators/documentacceleratorconfiguration.hxx> +#include <accelerators/acceleratorconfiguration.hxx> +#include <accelerators/istoragelistener.hxx> +#include <accelerators/presethandler.hxx> #include <xml/acceleratorconfigurationreader.hxx> - #include <xml/acceleratorconfigurationwriter.hxx> - #include <xml/saxnamespacefilter.hxx> #include <threadhelp/readguard.hxx> #include <threadhelp/writeguard.hxx> - #include <acceleratorconst.h> -#include <services.h> -#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/XUIConfigurationStorage.hpp> -#include <com/sun/star/io/XSeekable.hpp> - -#include <com/sun/star/io/XTruncate.hpp> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <rtl/ref.hxx> -#include <com/sun/star/embed/ElementModes.hpp> +using namespace framework; -#include <com/sun/star/xml/sax/InputSource.hpp> +namespace { -#include <com/sun/star/xml/sax/XParser.hpp> +/** + implements a read/write access to a document + based accelerator configuration. + */ -#include <comphelper/sequenceashashmap.hxx> -#include <i18nlangtag/languagetag.hxx> +typedef ::cppu::ImplInheritanceHelper1< + XMLBasedAcceleratorConfiguration, + css::lang::XServiceInfo> DocumentAcceleratorConfiguration_BASE; -namespace framework +class DocumentAcceleratorConfiguration : public DocumentAcceleratorConfiguration_BASE { +private: -//----------------------------------------------- -// XInterface, XTypeProvider, XServiceInfo - -DEFINE_XSERVICEINFO_MULTISERVICE_2(DocumentAcceleratorConfiguration , - ::cppu::OWeakObject , - "com.sun.star.ui.DocumentAcceleratorConfiguration" , - OUString("com.sun.star.comp.framework.DocumentAcceleratorConfiguration")) - -DEFINE_INIT_SERVICE(DocumentAcceleratorConfiguration, - { - /*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 information! - */ - } - ) + //---------------------------------- + /** points to the root storage of the outside document, + where we can read/save our configuration data. */ + css::uno::Reference< css::embed::XStorage > m_xDocumentRoot; -//----------------------------------------------- -DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext) - : DocumentAcceleratorConfiguration_BASE(xContext) -{ -} +public: -//----------------------------------------------- -DocumentAcceleratorConfiguration::~DocumentAcceleratorConfiguration() -{ - m_aPresetHandler.removeStorageListener(this); -} + /** initialize this instance and fill the internal cache. + + @param xSMGR + reference to an uno service manager, which is used internaly. + */ + DocumentAcceleratorConfiguration( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Sequence< css::uno::Any >& lArguments); + + virtual ~DocumentAcceleratorConfiguration(); + + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { + return OUString("com.sun.star.comp.framework.DocumentAcceleratorConfiguration"); + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException) + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() + throw (css::uno::RuntimeException) + { + css::uno::Sequence< OUString > aSeq(1); + aSeq[0] = OUString("com.sun.star.ui.DocumentAcceleratorConfiguration"); + return aSeq; + } + + // XUIConfigurationStorage + virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage) + throw(css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasStorage() + throw(css::uno::RuntimeException); + +private: + + /** read all data into the cache. */ + void impl_ts_fillCache(); + + /** forget all currently cached data AND(!) + forget all currently used storages. */ + void impl_ts_clearCache(); +}; //----------------------------------------------- -void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments) - throw(css::uno::Exception , - css::uno::RuntimeException) +DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Sequence< css::uno::Any >& lArguments) + : DocumentAcceleratorConfiguration_BASE(xContext) { - // SAFE -> ---------------------------------- WriteGuard aWriteLock(m_aLock); css::uno::Reference<css::embed::XStorage> xRoot; @@ -101,12 +132,17 @@ void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Seque } aWriteLock.unlock(); - // <- SAFE ---------------------------------- impl_ts_fillCache(); } //----------------------------------------------- +DocumentAcceleratorConfiguration::~DocumentAcceleratorConfiguration() +{ + m_aPresetHandler.removeStorageListener(this); +} + +//----------------------------------------------- void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage) throw(css::uno::RuntimeException) { @@ -185,4 +221,14 @@ void DocumentAcceleratorConfiguration::impl_ts_clearCache() } // namespace framework +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_DocumentAcceleratorConfiguration_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &arguments) +{ + rtl::Reference<DocumentAcceleratorConfiguration> x(new DocumentAcceleratorConfiguration(context, arguments)); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx b/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx deleted file mode 100644 index fdf40459f585..000000000000 --- a/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_DOCUMENTACCELERATORCONFIGURATION_HXX -#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_DOCUMENTACCELERATORCONFIGURATION_HXX - -#include <accelerators/acceleratorconfiguration.hxx> -#include <accelerators/istoragelistener.hxx> -#include <accelerators/presethandler.hxx> - -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <macros/xserviceinfo.hxx> - -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/ui/XUIConfigurationStorage.hpp> - -#include <cppuhelper/implbase2.hxx> -// definition - -namespace framework -{ - -//__________________________________________ -/** - implements a read/write access to a document - based accelerator configuration. - */ - -typedef ::cppu::ImplInheritanceHelper2< - XMLBasedAcceleratorConfiguration, - css::lang::XServiceInfo, - css::lang::XInitialization > DocumentAcceleratorConfiguration_BASE; - -class DocumentAcceleratorConfiguration : public DocumentAcceleratorConfiguration_BASE -{ - //______________________________________ - // member - - private: - - //---------------------------------- - /** points to the root storage of the outside document, - where we can read/save our configuration data. */ - css::uno::Reference< css::embed::XStorage > m_xDocumentRoot; - - //______________________________________ - // interface - - public: - - //---------------------------------- - /** initialize this instance and fill the internal cache. - - @param xSMGR - reference to an uno service manager, which is used internaly. - */ - DocumentAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext); - virtual ~DocumentAcceleratorConfiguration(); - - // XInterface, XTypeProvider, XServiceInfo - DECLARE_XSERVICEINFO - - // XInitialization - virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) - throw(css::uno::Exception , - css::uno::RuntimeException); - - // XUIConfigurationStorage - virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage) - throw(css::uno::RuntimeException); - - virtual sal_Bool SAL_CALL hasStorage() - throw(css::uno::RuntimeException); - - //______________________________________ - // helper - - private: - - //---------------------------------- - /** read all data into the cache. */ - void impl_ts_fillCache(); - - //---------------------------------- - /** forget all currently cached data AND(!) - forget all currently used storages. */ - void impl_ts_clearCache(); -}; - -} // namespace framework - -#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_DOCUMENTACCELERATORCONFIGURATION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index 69583ac795b4..c86390a22001 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -41,7 +41,6 @@ #include <uiconfiguration/moduleuicfgsupplier.hxx> #include <uifactory/menubarfactory.hxx> #include <accelerators/moduleacceleratorconfiguration.hxx> -#include <accelerators/documentacceleratorconfiguration.hxx> #include <uifactory/toolboxfactory.hxx> #include "uiconfiguration/windowstateconfiguration.hxx" #include <services/autorecovery.hxx> @@ -64,7 +63,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier ) else IFFACTORY( ::framework::MenuBarFactory ) else IFFACTORY( ::framework::ModuleAcceleratorConfiguration ) else - IFFACTORY( ::framework::DocumentAcceleratorConfiguration ) else IFFACTORY( ::framework::ToolBoxFactory ) else IFFACTORY( ::framework::WindowStateConfiguration ) else IFFACTORY( ::framework::ToolbarControllerFactory ) else diff --git a/framework/util/fwk.component b/framework/util/fwk.component index 388b2e399e89..765583a1d9ff 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -36,7 +36,8 @@ <implementation name="com.sun.star.comp.framework.Desktop"> <service name="com.sun.star.frame.Desktop"/> </implementation> - <implementation name="com.sun.star.comp.framework.DocumentAcceleratorConfiguration"> + <implementation name="com.sun.star.comp.framework.DocumentAcceleratorConfiguration" + constructor="com_sun_star_comp_framework_DocumentAcceleratorConfiguration_get_implementation"> <service name="com.sun.star.ui.DocumentAcceleratorConfiguration"/> </implementation> <implementation name="org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer"> |