diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 13:09:36 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-17 12:24:48 +0100 |
commit | 87051bb36af387371d4204c874a0c78adf7631d1 (patch) | |
tree | c8932c1eb68c0192b6ebb08cb56f0ebf6a8385db | |
parent | e076f677d94d7e0b794eafd77ba3e2d9320fd3e8 (diff) |
fwk: Use constructor feature for AddonsToolBoxFactory.
Change-Id: Ifd0c71a5f37fa87c8acc2d810496925788be99ef
-rw-r--r-- | framework/inc/uifactory/addonstoolboxfactory.hxx | 71 | ||||
-rw-r--r-- | framework/source/register/registerservices.cxx | 2 | ||||
-rw-r--r-- | framework/source/uifactory/addonstoolboxfactory.cxx | 76 | ||||
-rw-r--r-- | framework/util/fwk.component | 3 |
4 files changed, 61 insertions, 91 deletions
diff --git a/framework/inc/uifactory/addonstoolboxfactory.hxx b/framework/inc/uifactory/addonstoolboxfactory.hxx deleted file mode 100644 index e6583e0f8cde..000000000000 --- a/framework/inc/uifactory/addonstoolboxfactory.hxx +++ /dev/null @@ -1,71 +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_INC_UIFACTORY_ADDONSTOOLBOXFACTORY_HXX -#define INCLUDED_FRAMEWORK_INC_UIFACTORY_ADDONSTOOLBOXFACTORY_HXX - -#include <stdtypes.h> -#include <threadhelp/threadhelpbase.hxx> -#include <macros/generic.hxx> -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <macros/xserviceinfo.hxx> -#include <services.h> - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XTypeProvider.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/ui/XUIElementFactory.hpp> -#include <com/sun/star/frame/XModuleManager2.hpp> -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/XModel.hpp> - -#include <cppuhelper/implbase2.hxx> -#include <rtl/ustring.hxx> - -namespace framework -{ - -class AddonsToolBoxFactory : protected ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. - public ::cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo , - com::sun::star::ui::XUIElementFactory > -{ - public: - AddonsToolBoxFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); - virtual ~AddonsToolBoxFactory(); - - // XInterface, XTypeProvider, XServiceInfo - DECLARE_XSERVICEINFO - - // XUIElementFactory - virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - - sal_Bool hasButtonsInContext( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& rPropSeq, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); - - private: - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; -}; - -} - -#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_ADDONSTOOLBOXFACTORY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index b6796d8e8b97..768fbd2f5638 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -53,7 +53,6 @@ #include <accelerators/moduleacceleratorconfiguration.hxx> #include <accelerators/documentacceleratorconfiguration.hxx> #include <uifactory/toolboxfactory.hxx> -#include <uifactory/addonstoolboxfactory.hxx> #include "uiconfiguration/windowstateconfiguration.hxx" #include <services/autorecovery.hxx> #include <helper/statusindicatorfactory.hxx> @@ -91,7 +90,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::ModuleAcceleratorConfiguration ) else IFFACTORY( ::framework::DocumentAcceleratorConfiguration ) else IFFACTORY( ::framework::ToolBoxFactory ) else - IFFACTORY( ::framework::AddonsToolBoxFactory ) else IFFACTORY( ::framework::WindowStateConfiguration ) else IFFACTORY( ::framework::ToolbarControllerFactory ) else IFFACTORY( ::framework::AutoRecovery ) else diff --git a/framework/source/uifactory/addonstoolboxfactory.cxx b/framework/source/uifactory/addonstoolboxfactory.cxx index 2c51b9d8d425..992dfb630bc9 100644 --- a/framework/source/uifactory/addonstoolboxfactory.cxx +++ b/framework/source/uifactory/addonstoolboxfactory.cxx @@ -17,26 +17,30 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <uifactory/addonstoolboxfactory.hxx> - #include <uielement/addonstoolbarwrapper.hxx> #include <threadhelp/resetableguard.hxx> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/ModuleManager.hpp> +#include <com/sun/star/frame/XModuleManager2.hpp> #include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> - #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/ui/XUIElementFactory.hpp> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/supportsservice.hxx> #include <vcl/svapp.hxx> +#include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> -//_________________________________________________________________________________________________________________ -// Defines -//_________________________________________________________________________________________________________________ +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#include <services.h> using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -44,20 +48,48 @@ using namespace com::sun::star::frame; using namespace com::sun::star::beans; using namespace com::sun::star::util; using namespace ::com::sun::star::ui; +using namespace framework; -namespace framework +namespace { + +class AddonsToolBoxFactory : protected ThreadHelpBase, // Struct for right initalization of mutex member! Must be first of baseclasses. + public ::cppu::WeakImplHelper2< css::lang::XServiceInfo , + css::ui::XUIElementFactory > { +public: + AddonsToolBoxFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~AddonsToolBoxFactory(); + + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { + return OUString("com.sun.star.comp.framework.AddonsToolBarFactory"); + } + + 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.ToolBarFactory"); + return aSeq; + } -//***************************************************************************************************************** -// XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** -PRIVATE_DEFINE_XSERVICEINFO_NEWSTYLE( AddonsToolBoxFactory, - ::cppu::OWeakObject, - SERVICENAME_TOOLBARFACTORY, - IMPLEMENTATIONNAME_ADDONSTOOLBARFACTORY ) -PRIVATE_DEFINE_ONEINSTANCEFACTORY( AddonsToolBoxFactory ) + // XUIElementFactory + virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException ); -DEFINE_INIT_SERVICE ( AddonsToolBoxFactory, {} ) + sal_Bool hasButtonsInContext( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rPropSeq, + const css::uno::Reference< css::frame::XFrame >& rFrame ); + +private: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager; +}; AddonsToolBoxFactory::AddonsToolBoxFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) : @@ -197,4 +229,14 @@ throw ( ::com::sun::star::container::NoSuchElementException, } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_AddonsToolBarFactory_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) +{ + rtl::Reference<AddonsToolBoxFactory> x(new AddonsToolBoxFactory(context)); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/util/fwk.component b/framework/util/fwk.component index 1971d4a9d124..c066749d97a9 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -22,7 +22,8 @@ <implementation name="com.sun.star.comp.frame.SessionListener"> <service name="com.sun.star.frame.SessionListener"/> </implementation> - <implementation name="com.sun.star.comp.framework.AddonsToolBarFactory"> + <implementation name="com.sun.star.comp.framework.AddonsToolBarFactory" + constructor="com_sun_star_comp_framework_AddonsToolBarFactory_get_implementation"> <service name="com.sun.star.ui.ToolBarFactory"/> </implementation> <implementation name="com.sun.star.comp.framework.AutoRecovery"> |