summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-08-23 15:43:05 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-08-27 15:40:06 +0200
commitf789715a414bd1115401f93d11f09260f891956c (patch)
tree2e7ce9d3841ae8c98585901ddae699dbb9528820 /sw
parent65c78617de30f4928255b15599e7709fa0081f67 (diff)
fdo#46808, Use factory methods for frame::DispatchHelper instances
Change-Id: I7bdf16fc6d042e5ecd404c604a8b7c31c1ac7bc1
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/app/docsh2.cxx85
1 files changed, 40 insertions, 45 deletions
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 );
}
}
}