From e70c068ba413564067f17107b0773910ced760d1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 5 Mar 2013 14:58:29 +0200 Subject: fdo#46808, Convert text:: and drawing:: ModuleDispatcher service to new style The services already existing, just needed to create the IDL files Change-Id: Ifedd46722ba0bae2985e82d18827c61c1d12cd62 --- offapi/UnoApi_offapi.mk | 2 + offapi/com/sun/star/drawing/ModuleDispatcher.idl | 38 ++++++++++ offapi/com/sun/star/text/ModuleDispatcher.idl | 38 ++++++++++ sfx2/source/appl/appserv.cxx | 64 +++++++--------- sw/source/ui/app/docsh2.cxx | 93 +++++++++++------------- 5 files changed, 147 insertions(+), 88 deletions(-) create mode 100644 offapi/com/sun/star/drawing/ModuleDispatcher.idl create mode 100644 offapi/com/sun/star/text/ModuleDispatcher.idl diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 3007e98d0de4..1c631a31189e 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -111,6 +111,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/document,\ XMLOasisBasicImporter \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/drawing,\ + ModuleDispatcher \ ShapeCollection \ SlideRenderer \ SlideSorter \ @@ -3614,6 +3615,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/text,\ LabelFollow \ MailMergeEvent \ MailMergeType \ + ModuleDispatcher \ NotePrintMode \ PageNumberType \ ParagraphVertAlign \ diff --git a/offapi/com/sun/star/drawing/ModuleDispatcher.idl b/offapi/com/sun/star/drawing/ModuleDispatcher.idl new file mode 100644 index 000000000000..454262e753e5 --- /dev/null +++ b/offapi/com/sun/star/drawing/ModuleDispatcher.idl @@ -0,0 +1,38 @@ +/* -*- 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_drawing_ModuleDispatcher_idl__ +#define __com_sun_star_drawing_ModuleDispatcher_idl__ + +#include + + + module com { module sun { module star { module drawing { + + +/** + @since LibreOffice 4.1 + */ +service ModuleDispatcher : com::sun::star::frame::XDispatchProvider; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/text/ModuleDispatcher.idl b/offapi/com/sun/star/text/ModuleDispatcher.idl new file mode 100644 index 000000000000..eec8b4a856c6 --- /dev/null +++ b/offapi/com/sun/star/text/ModuleDispatcher.idl @@ -0,0 +1,38 @@ +/* -*- 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_text_ModuleDispatcher_idl__ +#define __com_sun_star_text_ModuleDispatcher_idl__ + +#include + + + module com { module sun { module star { module text { + + +/** + @since LibreOffice 4.1 + */ +service ModuleDispatcher : com::sun::star::frame::XDispatchProvider; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 55d74f354adb..1fb305a28d71 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -1376,26 +1378,19 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) return; } - Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - Reference< com::sun::star::frame::XDispatchProvider > xProv( - xORB->createInstance( ::rtl::OUString("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); - - if ( xProv.is() ) - { - ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); - Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); - Sequence < com::sun::star::beans::PropertyValue > aSeq; - if ( rReq.GetArgs() ) - TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); - Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq ); - ::com::sun::star::frame::DispatchResultEvent aEvent; - sal_Bool bSuccess = ( - (aResult >>= aEvent) && - (aEvent.State == ::com::sun::star::frame::DispatchResultState::SUCCESS) - ); - rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); - } + Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext ); + + ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); + Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); + Sequence < beans::PropertyValue > aSeq; + if ( rReq.GetArgs() ) + TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); + Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq ); + frame::DispatchResultEvent aEvent; + sal_Bool bSuccess = (aResult >>= aEvent) && + (aEvent.State == frame::DispatchResultState::SUCCESS); + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); } break; @@ -1403,26 +1398,19 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) case FN_BUSINESS_CARD : case FN_XFORMS_INIT : { - Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - Reference< com::sun::star::frame::XDispatchProvider > xProv( - xORB->createInstance( ::rtl::OUString("com.sun.star.text.ModuleDispatcher")), UNO_QUERY ); - - if ( xProv.is() ) - { - ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); - Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); - Sequence < com::sun::star::beans::PropertyValue > aSeq; - if ( rReq.GetArgs() ) - TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); - Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq ); - ::com::sun::star::frame::DispatchResultEvent aEvent; - sal_Bool bSuccess = ( - (aResult >>= aEvent) && - (aEvent.State == ::com::sun::star::frame::DispatchResultState::SUCCESS) - ); - rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); - } + Reference< frame::XDispatchProvider > xProv = text::ModuleDispatcher::create( xContext ); + + ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); + Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); + Sequence < beans::PropertyValue > aSeq; + if ( rReq.GetArgs() ) + TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); + Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq ); + frame::DispatchResultEvent aEvent; + sal_Bool bSuccess = (aResult >>= aEvent) && + (aEvent.State == frame::DispatchResultState::SUCCESS); + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); } break; diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index fda720cfde97..b10260b8be47 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -18,6 +18,7 @@ */ +#include #include #include @@ -998,33 +999,29 @@ void SwDocShell::Execute(SfxRequest& rReq) ErrCode eErr = aWrt.Write( xWrt ); if( !ERRCODE_TOERROR( eErr ) ) { - uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - uno::Reference< frame::XDispatchProvider > xProv( - xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"))), UNO_QUERY ); - if ( xProv.is() ) + uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext ); + + ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); + uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); + pStrm->Seek( STREAM_SEEK_TO_END ); + *pStrm << '\0'; + pStrm->Seek( STREAM_SEEK_TO_BEGIN ); + + // Transfer ownership of stream to a lockbytes object + SvLockBytes aLockBytes( pStrm, sal_True ); + SvLockBytesStat aStat; + if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) { - ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); - uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); - pStrm->Seek( STREAM_SEEK_TO_END ); - *pStrm << '\0'; - pStrm->Seek( STREAM_SEEK_TO_BEGIN ); - - // Transfer ownership of stream to a lockbytes object - SvLockBytes aLockBytes( pStrm, sal_True ); - SvLockBytesStat aStat; - if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) - { - sal_uInt32 nLen = aStat.nSize; - sal_uLong nRead = 0; - uno::Sequence< sal_Int8 > aSeq( nLen ); - aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); - - uno::Sequence< beans::PropertyValue > aArgs(1); - aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RtfOutline")); - aArgs[0].Value <<= aSeq; - xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); - } + sal_uInt32 nLen = aStat.nSize; + sal_uLong nRead = 0; + uno::Sequence< sal_Int8 > aSeq( nLen ); + aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); + + uno::Sequence< beans::PropertyValue > aArgs(1); + aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RtfOutline")); + aArgs[0].Value <<= aSeq; + xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); } } else @@ -1069,33 +1066,29 @@ void SwDocShell::Execute(SfxRequest& rReq) pStrm->Seek( STREAM_SEEK_TO_BEGIN ); if ( nWhich == FN_OUTLINE_TO_IMPRESS ) { - uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - uno::Reference< frame::XDispatchProvider > xProv( - xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"))), UNO_QUERY ); - if ( xProv.is() ) + uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext ); + + ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); + uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); + pStrm->Seek( STREAM_SEEK_TO_END ); + *pStrm << '\0'; + pStrm->Seek( STREAM_SEEK_TO_BEGIN ); + + // Transfer ownership of stream to a lockbytes object + SvLockBytes aLockBytes( pStrm, sal_True ); + SvLockBytesStat aStat; + if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) { - ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); - uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); - pStrm->Seek( STREAM_SEEK_TO_END ); - *pStrm << '\0'; - pStrm->Seek( STREAM_SEEK_TO_BEGIN ); - - // Transfer ownership of stream to a lockbytes object - SvLockBytes aLockBytes( pStrm, sal_True ); - SvLockBytesStat aStat; - if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) - { - sal_uInt32 nLen = aStat.nSize; - sal_uLong nRead = 0; - uno::Sequence< sal_Int8 > aSeq( nLen ); - aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); - - uno::Sequence< beans::PropertyValue > aArgs(1); - aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RtfOutline")); - aArgs[0].Value <<= aSeq; - xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); - } + sal_uInt32 nLen = aStat.nSize; + sal_uLong nRead = 0; + uno::Sequence< sal_Int8 > aSeq( nLen ); + aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); + + uno::Sequence< beans::PropertyValue > aArgs(1); + aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RtfOutline")); + aArgs[0].Value <<= aSeq; + xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); } } else -- cgit v1.2.3