Kaydet (Commit) f789715a authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Stephan Bergmann

fdo#46808, Use factory methods for frame::DispatchHelper instances

Change-Id: I7bdf16fc6d042e5ecd404c604a8b7c31c1ac7bc1
üst 65c78617
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include <com/sun/star/chart2/RelativeSize.hpp> #include <com/sun/star/chart2/RelativeSize.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.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/frame/FrameSearchFlag.hpp>
#include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/util/XUpdatable.hpp>
#include <comphelper/InlineContainer.hxx> #include <comphelper/InlineContainer.hxx>
...@@ -1550,11 +1550,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) ...@@ -1550,11 +1550,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
if( ! bReturn && if( ! bReturn &&
nCode == KEY_ESCAPE ) nCode == KEY_ESCAPE )
{ {
uno::Reference< frame::XDispatchHelper > xDispatchHelper( uno::Reference< frame::XDispatchHelper > xDispatchHelper( frame::DispatchHelper::create(m_xCC) );
m_xCC->getServiceManager()->createInstanceWithContext(
C2U("com.sun.star.frame.DispatchHelper"), m_xCC ), uno::UNO_QUERY );
if( xDispatchHelper.is())
{
uno::Sequence< beans::PropertyValue > aArgs; uno::Sequence< beans::PropertyValue > aArgs;
xDispatchHelper->executeDispatch( xDispatchHelper->executeDispatch(
uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ),
...@@ -1564,7 +1560,6 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) ...@@ -1564,7 +1560,6 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
aArgs ); aArgs );
bReturn = true; bReturn = true;
} }
}
if( ! bReturn && if( ! bReturn &&
(nCode == KEY_DELETE || nCode == KEY_BACKSPACE )) (nCode == KEY_DELETE || nCode == KEY_BACKSPACE ))
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <com/sun/star/beans/XPropertySet.hpp> #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/frame/XDispatchProviderInterception.hpp>
#include <com/sun/star/lang/SystemDependent.hpp> #include <com/sun/star/lang/SystemDependent.hpp>
#include <com/sun/star/awt/XSystemChildFactory.hpp> #include <com/sun/star/awt/XSystemChildFactory.hpp>
...@@ -299,14 +300,7 @@ sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent) ...@@ -299,14 +300,7 @@ sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent)
debug_fprintf(NSP_LOG_APPEND, "load document success\n"); debug_fprintf(NSP_LOG_APPEND, "load document success\n");
// create frame::XDispatchHelper and frame::XDispatchProvider // create frame::XDispatchHelper and frame::XDispatchProvider
m_xDispatcher = Reference< frame::XDispatchHelper > ( m_xDispatcher = Reference< frame::XDispatchHelper >( frame::DispatchHelper::create( xContext ) );
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_xDispatchProvider = Reference< frame::XDispatchProvider >(m_xFrame, uno::UNO_QUERY); m_xDispatchProvider = Reference< frame::XDispatchProvider >(m_xFrame, uno::UNO_QUERY);
if(!m_xDispatchProvider.is()) if(!m_xDispatchProvider.is())
{ {
......
...@@ -42,10 +42,10 @@ ...@@ -42,10 +42,10 @@
#include <com/sun/star/awt/XMenuExtended.hpp> #include <com/sun/star/awt/XMenuExtended.hpp>
#include <com/sun/star/awt/XMenuListener.hpp> #include <com/sun/star/awt/XMenuListener.hpp>
#include <com/sun/star/awt/XPopupMenuExtended.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/XController.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XDispatch.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/XDispatchProvider.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
...@@ -718,8 +718,7 @@ void ...@@ -718,8 +718,7 @@ void
FrameHelper::dispatchCommand (OUString command) FrameHelper::dispatchCommand (OUString command)
{ {
OUString target = OUString(RTL_CONSTASCII_USTRINGPARAM("")); OUString target = OUString(RTL_CONSTASCII_USTRINGPARAM(""));
Reference < XDispatchHelper > xdh (m_xMSF->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), Reference < XDispatchHelper > xdh( DispatchHelper::create(comphelper::ComponentContext(m_xMSF).getUNOContext()) );
UNO_QUERY);
// This is a special case, we don't want the helper to be disconnected from the frame // This is a special case, we don't want the helper to be disconnected from the frame
// when PrintPreview dettaches. See the frameAction method. // when PrintPreview dettaches. See the frameAction method.
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include "basmethnode.hxx" #include "basmethnode.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp> #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/XDesktop.hpp>
#include <com/sun/star/frame/XDispatchHelper.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/script/browse/BrowseNodeTypes.hpp> #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
...@@ -263,11 +263,8 @@ namespace basprov ...@@ -263,11 +263,8 @@ namespace basprov
if ( xProv.is() ) if ( xProv.is() )
{ {
Reference< frame::XDispatchHelper > xHelper( xSMgr->createInstanceWithContext( Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create( m_xContext ) );
::rtl::OUString( "com.sun.star.frame.DispatchHelper" ), m_xContext ), UNO_QUERY );
if ( xHelper.is() )
{
Sequence < PropertyValue > aArgs(7); Sequence < PropertyValue > aArgs(7);
aArgs[0].Name = ::rtl::OUString("Document"); aArgs[0].Name = ::rtl::OUString("Document");
aArgs[0].Value <<= sDocURL; aArgs[0].Value <<= sDocURL;
...@@ -285,7 +282,6 @@ namespace basprov ...@@ -285,7 +282,6 @@ namespace basprov
} }
} }
} }
}
else else
{ {
throw IllegalArgumentException( throw IllegalArgumentException(
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include <com/sun/star/frame/DispatchResultState.hpp> #include <com/sun/star/frame/DispatchResultState.hpp>
#include <com/sun/star/task/XJobExecutor.hpp> #include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.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/XDesktop.hpp>
#include <com/sun/star/frame/XDispatchHelper.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/CloseVetoException.hpp> #include <com/sun/star/util/CloseVetoException.hpp>
...@@ -1308,16 +1308,14 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) ...@@ -1308,16 +1308,14 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
} }
Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
Reference< com::sun::star::frame::XDispatchProvider > xProv( Reference< com::sun::star::frame::XDispatchProvider > xProv(
xORB->createInstance( ::rtl::OUString("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); xORB->createInstance( ::rtl::OUString("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY );
if ( xProv.is() ) if ( xProv.is() )
{ {
::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
Reference< com::sun::star::frame::XDispatchHelper > xHelper( Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
xORB->createInstance( ::rtl::OUString("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
if ( xHelper.is() )
{
Sequence < com::sun::star::beans::PropertyValue > aSeq; Sequence < com::sun::star::beans::PropertyValue > aSeq;
if ( rReq.GetArgs() ) if ( rReq.GetArgs() )
TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
...@@ -1330,7 +1328,6 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) ...@@ -1330,7 +1328,6 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
} }
} }
}
break; break;
case FN_LABEL : case FN_LABEL :
...@@ -1338,16 +1335,14 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) ...@@ -1338,16 +1335,14 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
case FN_XFORMS_INIT : case FN_XFORMS_INIT :
{ {
Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
Reference< com::sun::star::frame::XDispatchProvider > xProv( Reference< com::sun::star::frame::XDispatchProvider > xProv(
xORB->createInstance( ::rtl::OUString("com.sun.star.text.ModuleDispatcher")), UNO_QUERY ); xORB->createInstance( ::rtl::OUString("com.sun.star.text.ModuleDispatcher")), UNO_QUERY );
if ( xProv.is() ) if ( xProv.is() )
{ {
::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() ); ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
Reference< com::sun::star::frame::XDispatchHelper > xHelper( Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
xORB->createInstance( ::rtl::OUString("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
if ( xHelper.is() )
{
Sequence < com::sun::star::beans::PropertyValue > aSeq; Sequence < com::sun::star::beans::PropertyValue > aSeq;
if ( rReq.GetArgs() ) if ( rReq.GetArgs() )
TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq ); TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
...@@ -1360,7 +1355,6 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) ...@@ -1360,7 +1355,6 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) ); rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
} }
} }
}
break; break;
case SID_ADDRESS_DATA_SOURCE: case SID_ADDRESS_DATA_SOURCE:
......
...@@ -28,8 +28,9 @@ ...@@ -28,8 +28,9 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #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 <comphelper/processfactory.hxx>
#include <hintids.hxx> #include <hintids.hxx>
...@@ -1005,15 +1006,13 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -1005,15 +1006,13 @@ void SwDocShell::Execute(SfxRequest& rReq)
if( !ERRCODE_TOERROR( eErr ) ) if( !ERRCODE_TOERROR( eErr ) )
{ {
uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< frame::XDispatchProvider > xProv( uno::Reference< frame::XDispatchProvider > xProv(
xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"))), UNO_QUERY ); xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"))), UNO_QUERY );
if ( xProv.is() ) if ( xProv.is() )
{ {
::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress"));
uno::Reference< frame::XDispatchHelper > xHelper( uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), UNO_QUERY );
if ( xHelper.is() )
{
pStrm->Seek( STREAM_SEEK_TO_END ); pStrm->Seek( STREAM_SEEK_TO_END );
*pStrm << '\0'; *pStrm << '\0';
pStrm->Seek( STREAM_SEEK_TO_BEGIN ); pStrm->Seek( STREAM_SEEK_TO_BEGIN );
...@@ -1035,7 +1034,6 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -1035,7 +1034,6 @@ void SwDocShell::Execute(SfxRequest& rReq)
} }
} }
} }
}
else else
ErrorHandler::HandleError(ErrCode( eErr )); ErrorHandler::HandleError(ErrCode( eErr ));
} }
...@@ -1079,15 +1077,13 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -1079,15 +1077,13 @@ void SwDocShell::Execute(SfxRequest& rReq)
if ( nWhich == FN_OUTLINE_TO_IMPRESS ) if ( nWhich == FN_OUTLINE_TO_IMPRESS )
{ {
uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< frame::XDispatchProvider > xProv( uno::Reference< frame::XDispatchProvider > xProv(
xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"))), UNO_QUERY ); xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"))), UNO_QUERY );
if ( xProv.is() ) if ( xProv.is() )
{ {
::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress")); ::rtl::OUString aCmd(RTL_CONSTASCII_USTRINGPARAM("SendOutlineToImpress"));
uno::Reference< frame::XDispatchHelper > xHelper( uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))), UNO_QUERY );
if ( xHelper.is() )
{
pStrm->Seek( STREAM_SEEK_TO_END ); pStrm->Seek( STREAM_SEEK_TO_END );
*pStrm << '\0'; *pStrm << '\0';
pStrm->Seek( STREAM_SEEK_TO_BEGIN ); pStrm->Seek( STREAM_SEEK_TO_BEGIN );
...@@ -1109,7 +1105,6 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -1109,7 +1105,6 @@ void SwDocShell::Execute(SfxRequest& rReq)
} }
} }
} }
}
else else
{ {
TransferDataContainer* pClipCntnr = TransferDataContainer* pClipCntnr =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment