diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-23 15:43:05 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-08-27 15:40:06 +0200 |
commit | f789715a414bd1115401f93d11f09260f891956c (patch) | |
tree | 2e7ce9d3841ae8c98585901ddae699dbb9528820 | |
parent | 65c78617de30f4928255b15599e7709fa0081f67 (diff) |
fdo#46808, Use factory methods for frame::DispatchHelper instances
Change-Id: I7bdf16fc6d042e5ecd404c604a8b7c31c1ac7bc1
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 25 | ||||
-rw-r--r-- | extensions/source/nsplugin/source/so_instance.cxx | 10 | ||||
-rw-r--r-- | framework/source/lomenubar/FrameHelper.cxx | 5 | ||||
-rw-r--r-- | scripting/source/basprov/basmethnode.cxx | 34 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 56 | ||||
-rw-r--r-- | sw/source/ui/app/docsh2.cxx | 85 |
6 files changed, 94 insertions, 121 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 23a6eafdc3c0..16709ef22df2 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -51,7 +51,7 @@ #include <com/sun/star/chart2/RelativeSize.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> -#include <com/sun/star/frame/XDispatchHelper.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/util/XUpdatable.hpp> #include <comphelper/InlineContainer.hxx> @@ -1550,20 +1550,15 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if( ! bReturn && nCode == KEY_ESCAPE ) { - uno::Reference< frame::XDispatchHelper > xDispatchHelper( - m_xCC->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.frame.DispatchHelper"), m_xCC ), uno::UNO_QUERY ); - if( xDispatchHelper.is()) - { - uno::Sequence< beans::PropertyValue > aArgs; - xDispatchHelper->executeDispatch( - uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), - C2U(".uno:TerminateInplaceActivation"), - C2U("_parent"), - frame::FrameSearchFlag::PARENT, - aArgs ); - bReturn = true; - } + uno::Reference< frame::XDispatchHelper > xDispatchHelper( frame::DispatchHelper::create(m_xCC) ); + uno::Sequence< beans::PropertyValue > aArgs; + xDispatchHelper->executeDispatch( + uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), + C2U(".uno:TerminateInplaceActivation"), + C2U("_parent"), + frame::FrameSearchFlag::PARENT, + aArgs ); + bReturn = true; } if( ! bReturn && diff --git a/extensions/source/nsplugin/source/so_instance.cxx b/extensions/source/nsplugin/source/so_instance.cxx index cc545c8cf0c1..b70a3e60ab40 100644 --- a/extensions/source/nsplugin/source/so_instance.cxx +++ b/extensions/source/nsplugin/source/so_instance.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/XDispatchProviderInterception.hpp> #include <com/sun/star/lang/SystemDependent.hpp> #include <com/sun/star/awt/XSystemChildFactory.hpp> @@ -299,14 +300,7 @@ sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent) debug_fprintf(NSP_LOG_APPEND, "load document success\n"); // create frame::XDispatchHelper and frame::XDispatchProvider - m_xDispatcher = Reference< frame::XDispatchHelper > ( - mxRemoteMSF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), - uno::UNO_QUERY ); - if(!m_xDispatcher.is()) - { - debug_fprintf(NSP_LOG_APPEND, "m_xDispatcher can not be getten\n"); - return sal_False; - } + m_xDispatcher = Reference< frame::XDispatchHelper >( frame::DispatchHelper::create( xContext ) ); m_xDispatchProvider = Reference< frame::XDispatchProvider >(m_xFrame, uno::UNO_QUERY); if(!m_xDispatchProvider.is()) { diff --git a/framework/source/lomenubar/FrameHelper.cxx b/framework/source/lomenubar/FrameHelper.cxx index 12edf35d15fa..cd40491344bf 100644 --- a/framework/source/lomenubar/FrameHelper.cxx +++ b/framework/source/lomenubar/FrameHelper.cxx @@ -42,10 +42,10 @@ #include <com/sun/star/awt/XMenuExtended.hpp> #include <com/sun/star/awt/XMenuListener.hpp> #include <com/sun/star/awt/XPopupMenuExtended.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XDispatchHelper.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -718,8 +718,7 @@ void FrameHelper::dispatchCommand (OUString command) { OUString target = OUString(RTL_CONSTASCII_USTRINGPARAM("")); - Reference < XDispatchHelper > xdh (m_xMSF->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), - UNO_QUERY); + Reference < XDispatchHelper > xdh( DispatchHelper::create(comphelper::ComponentContext(m_xMSF).getUNOContext()) ); // This is a special case, we don't want the helper to be disconnected from the frame // when PrintPreview dettaches. See the frameAction method. diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx index e5046619b986..a1d7c5cd8fb2 100644 --- a/scripting/source/basprov/basmethnode.cxx +++ b/scripting/source/basprov/basmethnode.cxx @@ -19,8 +19,8 @@ #include "basmethnode.hxx" #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/XDesktop.hpp> -#include <com/sun/star/frame/XDispatchHelper.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> @@ -263,24 +263,20 @@ namespace basprov if ( xProv.is() ) { - Reference< frame::XDispatchHelper > xHelper( xSMgr->createInstanceWithContext( - ::rtl::OUString( "com.sun.star.frame.DispatchHelper" ), m_xContext ), UNO_QUERY ); - - if ( xHelper.is() ) - { - Sequence < PropertyValue > aArgs(7); - aArgs[0].Name = ::rtl::OUString("Document"); - aArgs[0].Value <<= sDocURL; - aArgs[1].Name = ::rtl::OUString("LibName"); - aArgs[1].Value <<= sLibName; - aArgs[2].Name = ::rtl::OUString("Name"); - aArgs[2].Value <<= sModName; - aArgs[3].Name = ::rtl::OUString("Type"); - aArgs[3].Value <<= ::rtl::OUString("Module"); - aArgs[4].Name = ::rtl::OUString("Line"); - aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 ); - xHelper->executeDispatch( xProv, ::rtl::OUString(".uno:BasicIDEAppear"), ::rtl::OUString(), 0, aArgs ); - } + Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create( m_xContext ) ); + + Sequence < PropertyValue > aArgs(7); + aArgs[0].Name = ::rtl::OUString("Document"); + aArgs[0].Value <<= sDocURL; + aArgs[1].Name = ::rtl::OUString("LibName"); + aArgs[1].Value <<= sLibName; + aArgs[2].Name = ::rtl::OUString("Name"); + aArgs[2].Value <<= sModName; + aArgs[3].Name = ::rtl::OUString("Type"); + aArgs[3].Value <<= ::rtl::OUString("Module"); + aArgs[4].Name = ::rtl::OUString("Line"); + aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 ); + xHelper->executeDispatch( xProv, ::rtl::OUString(".uno:BasicIDEAppear"), ::rtl::OUString(), 0, aArgs ); } } } diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 063a09afee07..f28418384d2b 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -24,8 +24,8 @@ #include <com/sun/star/frame/DispatchResultState.hpp> #include <com/sun/star/task/XJobExecutor.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/XDesktop.hpp> -#include <com/sun/star/frame/XDispatchHelper.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/util/CloseVetoException.hpp> @@ -1308,27 +1308,24 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) } 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< com::sun::star::frame::XDispatchHelper > xHelper( - xORB->createInstance( ::rtl::OUString("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); - if ( xHelper.is() ) - { - 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::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 ) ); } } break; @@ -1338,27 +1335,24 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) 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< com::sun::star::frame::XDispatchHelper > xHelper( - xORB->createInstance( ::rtl::OUString("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); - if ( xHelper.is() ) - { - 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::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 ) ); } } break; diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 6138d48be0d3..eae4d3d52a89 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -28,8 +28,9 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/frame/XDispatchHelper.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/processfactory.hxx> #include <hintids.hxx> @@ -1005,34 +1006,31 @@ void SwDocShell::Execute(SfxRequest& rReq) 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() ) { ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); - uno::Reference< frame::XDispatchHelper > xHelper( - xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), UNO_QUERY ); - if ( xHelper.is() ) + 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 ) { - 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 ); } } } @@ -1079,34 +1077,31 @@ void SwDocShell::Execute(SfxRequest& rReq) 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() ) { ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); - uno::Reference< frame::XDispatchHelper > xHelper( - xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), UNO_QUERY ); - if ( xHelper.is() ) + 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 ) { - 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 ); } } } |