diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-28 10:49:19 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-06-03 09:59:59 +0200 |
commit | a8a35e54f506ae22a0ac8f80aa824813260de000 (patch) | |
tree | a4b9e98346c9c579536557f0256abb08908fa5e8 | |
parent | 515701a1ff18d04ede235bef862c465adf41062f (diff) |
fdo#46808, Convert frame::AppDispatchProvider to new style
The service already existed, it just needed an IDL file.
Change-Id: I9553c8e7c4922f2106bc13034e0cc35669b28b7e
-rw-r--r-- | framework/inc/services.h | 1 | ||||
-rw-r--r-- | framework/source/dispatch/dispatchinformationprovider.cxx | 5 | ||||
-rw-r--r-- | include/sfx2/appuno.hxx | 8 | ||||
-rw-r--r-- | offapi/UnoApi_offapi.mk | 2 | ||||
-rw-r--r-- | offapi/com/sun/star/frame/AppDispatchProvider.idl | 37 | ||||
-rw-r--r-- | offapi/com/sun/star/frame/XAppDispatchProvider.idl | 42 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 49 | ||||
-rw-r--r-- | sfx2/util/sfx.component | 1 |
8 files changed, 137 insertions, 8 deletions
diff --git a/framework/inc/services.h b/framework/inc/services.h index 8a761e0b5f9d..24503d4041ee 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -99,7 +99,6 @@ namespace framework{ #define IMPLEMENTATIONNAME_RECENTFILESMENUCONTROLLER DECLARE_ASCII("com.sun.star.comp.framework.RecentFilesMenuController" ) #define IMPLEMENTATIONNAME_STATUSBARFACTORY DECLARE_ASCII("com.sun.star.comp.framework.StatusBarFactory" ) #define IMPLEMENTATIONNAME_STATUSBARCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.comp.framework.StatusBarControllerFactory" ) -#define IMPLEMENTATIONNAME_APPDISPATCHPROVIDER DECLARE_ASCII("com.sun.star.comp.sfx2.AppDispatchProvider" ) #define IMPLEMENTATIONNAME_SESSIONLISTENER DECLARE_ASCII("com.sun.star.comp.frame.SessionListener" ) #define IMPLEMENTATIONNAME_HELPONSTARTUP DECLARE_ASCII("com.sun.star.comp.framework.HelpOnStartup" ) #define IMPLEMENTATIONNAME_SHELLJOB DECLARE_ASCII("com.sun.star.comp.framework.ShellJob" ) diff --git a/framework/source/dispatch/dispatchinformationprovider.cxx b/framework/source/dispatch/dispatchinformationprovider.cxx index eb0e1288f28e..936a9139a416 100644 --- a/framework/source/dispatch/dispatchinformationprovider.cxx +++ b/framework/source/dispatch/dispatchinformationprovider.cxx @@ -25,6 +25,8 @@ #include <services.h> #include <com/sun/star/frame/CommandGroup.hpp> +#include <com/sun/star/frame/AppDispatchProvider.hpp> + #include <comphelper/sequenceasvector.hxx> @@ -148,8 +150,7 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvide css::uno::Reference< css::frame::XDispatchInformationProvider > xCloseDispatch(xCloser , css::uno::UNO_QUERY); css::uno::Reference< css::frame::XDispatchInformationProvider > xController (xFrame->getController() , css::uno::UNO_QUERY); - css::uno::Reference< css::frame::XDispatchInformationProvider > xAppDispatcher( - xContext->getServiceManager()->createInstanceWithContext(IMPLEMENTATIONNAME_APPDISPATCHPROVIDER, xContext), css::uno::UNO_QUERY); + css::uno::Reference< css::frame::XDispatchInformationProvider > xAppDispatcher = css::frame::AppDispatchProvider::create(xContext); css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider(3); lProvider[0] = xController ; lProvider[1] = xCloseDispatch; diff --git a/include/sfx2/appuno.hxx b/include/sfx2/appuno.hxx index 90bf2d5edf58..ff2313fd040d 100644 --- a/include/sfx2/appuno.hxx +++ b/include/sfx2/appuno.hxx @@ -28,7 +28,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/uno/Exception.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XAppDispatchProvider.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XSynchronousDispatch.hpp> #include <com/sun/star/frame/XNotifyingDispatch.hpp> @@ -40,6 +40,7 @@ #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Sequence.hxx> #include <cppuhelper/weak.hxx> +#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase4.hxx> #include <tools/errcode.hxx> @@ -81,10 +82,9 @@ public: virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); }; -class SfxAppDispatchProvider : public ::cppu::WeakImplHelper4< ::com::sun::star::frame::XDispatchProvider, +class SfxAppDispatchProvider : public ::cppu::WeakImplHelper3< ::com::sun::star::frame::XAppDispatchProvider, ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XInitialization, - ::com::sun::star::frame::XDispatchInformationProvider > + ::com::sun::star::lang::XInitialization > { ::com::sun::star::uno::WeakReference < ::com::sun::star::frame::XFrame > m_xFrame; public: diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index fc4ba305c32f..b3b12758e9c1 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -186,6 +186,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/form/runti )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/frame,\ AutoRecovery \ + AppDispatchProvider \ Bibliography \ Desktop \ DispatchHelper \ @@ -2563,6 +2564,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/frame,\ UnknownModuleException \ UntitledNumbersConst \ WindowArrange \ + XAppDispatchProvider \ XBorderResizeListener \ XBrowseHistoryRegistry \ XComponentLoader \ diff --git a/offapi/com/sun/star/frame/AppDispatchProvider.idl b/offapi/com/sun/star/frame/AppDispatchProvider.idl new file mode 100644 index 000000000000..20a6624a2158 --- /dev/null +++ b/offapi/com/sun/star/frame/AppDispatchProvider.idl @@ -0,0 +1,37 @@ +/* -*- 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 __com_sun_star_frame_AppDispatchProvider_idl__ +#define __com_sun_star_frame_AppDispatchProvider_idl__ + +#include <com/sun/star/frame/XAppDispatchProvider.idl> + + + module com { module sun { module star { module frame { + +/** + @since LibreOffice 4.2 + */ +service AppDispatchProvider : XAppDispatchProvider; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/frame/XAppDispatchProvider.idl b/offapi/com/sun/star/frame/XAppDispatchProvider.idl new file mode 100644 index 000000000000..298c62d8d60b --- /dev/null +++ b/offapi/com/sun/star/frame/XAppDispatchProvider.idl @@ -0,0 +1,42 @@ +/* -*- 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 __com_sun_star_frame_XAppDispatchProvider_idl__ +#define __com_sun_star_frame_XAppDispatchProvider_idl__ + +#include <com/sun/star/frame/XDispatchInformationProvider.idl> +#include <com/sun/star/frame/XDispatchProvider.idl> + + + module com { module sun { module star { module frame { + +/** + @since LibreOffice 4.2 + */ +interface XAppDispatchProvider +{ + interface XDispatchInformationProvider; + interface XDispatchProvider; +}; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index e7e045d556a8..7f65d0febbed 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -1990,7 +1990,54 @@ ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, com::sun::star::uno::An #endif } -SFX_IMPL_XSERVICEINFO( SfxAppDispatchProvider, "com.sun.star.frame.DispatchProvider", "com.sun.star.comp.sfx2.AppDispatchProvider" ) \ + /* XServiceInfo */ +OUString SAL_CALL SfxAppDispatchProvider::getImplementationName() throw( css::uno::RuntimeException ) +{ + return impl_getStaticImplementationName(); +} + +/* XServiceInfo */ +sal_Bool SAL_CALL SfxAppDispatchProvider::supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException ) +{ + css::uno::Sequence< OUString > seqServiceNames = getSupportedServiceNames(); + const OUString* pArray = seqServiceNames.getConstArray(); + for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) + { + if ( pArray[nCounter] == sServiceName ) + { + return sal_True; + } + } + return sal_False; +} + +/* XServiceInfo */ +css::uno::Sequence< OUString > SAL_CALL SfxAppDispatchProvider::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return impl_getStaticSupportedServiceNames(); +} + +/* Helper for XServiceInfo */ +css::uno::Sequence< OUString > SfxAppDispatchProvider::impl_getStaticSupportedServiceNames() +{ + css::uno::Sequence< OUString > seqServiceNames( 2 ); + seqServiceNames.getArray()[0] = "com.sun.star.frame.DispatchProvider"; + seqServiceNames.getArray()[1] = "com.sun.star.frame.AppDispatchProvider"; + return seqServiceNames; +} + +/* Helper for XServiceInfo */ +OUString SfxAppDispatchProvider::impl_getStaticImplementationName() +{ + return OUString::createFromAscii( "com.sun.star.comp.sfx2.AppDispatchProvider" ); +} + +/* Helper for registry */ +css::uno::Reference< css::uno::XInterface > SAL_CALL SfxAppDispatchProvider::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception ) +{ + return css::uno::Reference< css::uno::XInterface >( *new SfxAppDispatchProvider( xServiceManager ) ); +} + SFX_IMPL_SINGLEFACTORY( SfxAppDispatchProvider ); void SAL_CALL SfxAppDispatchProvider::initialize( const uno::Sequence<uno::Any>& aArguments ) throw (uno::Exception, uno::RuntimeException) diff --git a/sfx2/util/sfx.component b/sfx2/util/sfx.component index 567e10a6ed80..05c8c3bbf76e 100644 --- a/sfx2/util/sfx.component +++ b/sfx2/util/sfx.component @@ -41,6 +41,7 @@ </implementation> <implementation name="com.sun.star.comp.sfx2.AppDispatchProvider"> <service name="com.sun.star.frame.ProtocolHandler"/> + <service name="com.sun.star.frame.AppDispatchProvider"/> </implementation> <implementation name="com.sun.star.comp.sfx2.ApplicationDialogLibraryContainer"> <service name="com.sun.star.script.ApplicationDialogLibraryContainer"/> |