diff options
author | Noel Grandin <noel@peralex.com> | 2013-03-05 15:08:38 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-03-07 08:23:42 +0200 |
commit | e721452988b54eb2e02c3885fde288be70bcf1f1 (patch) | |
tree | 88d250835c0ca08fcfc4e2ad93f3f62766aa95ee /sfx2 | |
parent | e70c068ba413564067f17107b0773910ced760d1 (diff) |
fdo#46808, small cleanups
Change-Id: I8d34bfca5009a4a44444b19a39c6f8338614e4c4
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/request.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/mailmodel.cxx | 236 | ||||
-rw-r--r-- | sfx2/source/dialog/taskpane.cxx | 9 |
4 files changed, 126 insertions, 127 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 1fb305a28d71..bd813e0f4e34 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -1102,8 +1102,6 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) { try { - uno::Reference< lang::XMultiServiceFactory > xSMGR = - ::comphelper::getProcessServiceFactory(); uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); uno::Reference< css::system::XSystemShellExecute > xSystemShell( diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index 3525f22646ee..8170a0480ded 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -359,11 +359,9 @@ void SfxRequest_Impl::Record } } - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xFactory( - ::comphelper::getProcessServiceFactory(), - com::sun::star::uno::UNO_QUERY); + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - uno::Reference< util::XURLTransformer > xTransform( util::URLTransformer::create( ::comphelper::getComponentContext(xFactory) ) ); + uno::Reference< util::XURLTransformer > xTransform = util::URLTransformer::create( xContext ); com::sun::star::util::URL aURL; aURL.Complete = aCmd; diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index 6ce7a2215a01..8522a2e7fbb7 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -19,32 +19,34 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertyAccess.hpp> -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/ucb/CommandAbortedException.hpp> -#include <com/sun/star/uno/Reference.h> -#include <com/sun/star/util/URLTransformer.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> -#include <com/sun/star/system/XSimpleMailClientSupplier.hpp> -#include <com/sun/star/system/SimpleMailClientFlags.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XContainerQuery.hpp> +#include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> -#include <com/sun/star/container/XContainerQuery.hpp> -#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/security/CertificateValidity.hpp> #include <com/sun/star/security/DocumentSignatureInformation.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/system/SimpleSystemMail.hpp> +#include <com/sun/star/system/SimpleCommandMail.hpp> +#include <com/sun/star/system/XSimpleMailClientSupplier.hpp> +#include <com/sun/star/system/SimpleMailClientFlags.hpp> +#include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/util/URLTransformer.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/util/XModifiable.hpp> #include <rtl/textenc.h> #include <rtl/uri.h> #include <rtl/uri.hxx> @@ -546,7 +548,7 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( css::util::URL aPrepareURL; css::uno::Reference< css::frame::XDispatch > xPrepareDispatch; css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( xFrame, css::uno::UNO_QUERY ); - css::uno::Reference< css::util::XURLTransformer > xURLTransformer( css::util::URLTransformer::create( ::comphelper::getComponentContext(xSMGR) ) ); + css::uno::Reference< css::util::XURLTransformer > xURLTransformer( css::util::URLTransformer::create( xContext ) ); if( !bSendAsPDF ) { try @@ -768,133 +770,135 @@ SfxMailModel::SendMailResult SfxMailModel::Send( const css::uno::Reference< css: SendMailResult eResult = SEND_MAIL_ERROR; if ( !maAttachedDocuments.empty() ) { - css::uno::Reference < XMultiServiceFactory > xMgr = ::comphelper::getProcessServiceFactory(); - if ( xMgr.is() ) + css::uno::Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + + css::uno::Reference< XSimpleMailClientSupplier > xSimpleMailClientSupplier; + + // Prefer the SimpleSystemMail service if available + try { + xSimpleMailClientSupplier = SimpleSystemMail::create( xContext ); + } + catch ( const uno::Exception & ) + {} + + if ( ! xSimpleMailClientSupplier.is() ) { - css::uno::Reference< XSimpleMailClientSupplier > xSimpleMailClientSupplier; + try { + xSimpleMailClientSupplier = SimpleCommandMail::create( xContext ); + } + catch ( const uno::Exception & ) + {} + } - // Prefer the SimpleSystemMail service if available - xSimpleMailClientSupplier = css::uno::Reference< XSimpleMailClientSupplier >( - xMgr->createInstance( OUString( "com.sun.star.system.SimpleSystemMail" )), - UNO_QUERY ); + if ( xSimpleMailClientSupplier.is() ) + { + css::uno::Reference< XSimpleMailClient > xSimpleMailClient = xSimpleMailClientSupplier->querySimpleMailClient(); - if ( ! xSimpleMailClientSupplier.is() ) + if ( !xSimpleMailClient.is() ) { - xSimpleMailClientSupplier = css::uno::Reference< XSimpleMailClientSupplier >( - xMgr->createInstance( OUString( "com.sun.star.system.SimpleCommandMail" )), - UNO_QUERY ); + // no mail client support => message box! + return SEND_MAIL_ERROR; } - if ( xSimpleMailClientSupplier.is() ) + // we have a simple mail client + css::uno::Reference< XSimpleMailMessage > xSimpleMailMessage = xSimpleMailClient->createSimpleMailMessage(); + if ( xSimpleMailMessage.is() ) { - css::uno::Reference< XSimpleMailClient > xSimpleMailClient = xSimpleMailClientSupplier->querySimpleMailClient(); - - if ( !xSimpleMailClient.is() ) + sal_Int32 nSendFlags = SimpleMailClientFlags::DEFAULTS; + if ( maFromAddress.Len() == 0 ) { - // no mail client support => message box! - return SEND_MAIL_ERROR; + // from address not set, try figure out users e-mail address + CreateFromAddress_Impl( maFromAddress ); } + xSimpleMailMessage->setOriginator( maFromAddress ); - // we have a simple mail client - css::uno::Reference< XSimpleMailMessage > xSimpleMailMessage = xSimpleMailClient->createSimpleMailMessage(); - if ( xSimpleMailMessage.is() ) - { - sal_Int32 nSendFlags = SimpleMailClientFlags::DEFAULTS; - if ( maFromAddress.Len() == 0 ) - { - // from address not set, try figure out users e-mail address - CreateFromAddress_Impl( maFromAddress ); - } - xSimpleMailMessage->setOriginator( maFromAddress ); + size_t nToCount = mpToList ? mpToList->size() : 0; + size_t nCcCount = mpCcList ? mpCcList->size() : 0; + size_t nCcSeqCount = nCcCount; - size_t nToCount = mpToList ? mpToList->size() : 0; - size_t nCcCount = mpCcList ? mpCcList->size() : 0; - size_t nCcSeqCount = nCcCount; + // set recipient (only one) for this simple mail server!! + if ( nToCount > 1 ) + { + nCcSeqCount = nToCount - 1 + nCcCount; + xSimpleMailMessage->setRecipient( *mpToList->at( 0 ) ); + nSendFlags = SimpleMailClientFlags::NO_USER_INTERFACE; + } + else if ( nToCount == 1 ) + { + xSimpleMailMessage->setRecipient( *mpToList->at( 0 ) ); + nSendFlags = SimpleMailClientFlags::NO_USER_INTERFACE; + } - // set recipient (only one) for this simple mail server!! - if ( nToCount > 1 ) - { - nCcSeqCount = nToCount - 1 + nCcCount; - xSimpleMailMessage->setRecipient( *mpToList->at( 0 ) ); - nSendFlags = SimpleMailClientFlags::NO_USER_INTERFACE; - } - else if ( nToCount == 1 ) - { - xSimpleMailMessage->setRecipient( *mpToList->at( 0 ) ); - nSendFlags = SimpleMailClientFlags::NO_USER_INTERFACE; - } + // all other recipient must be handled with CC recipients! + if ( nCcSeqCount > 0 ) + { + size_t nIndex = 0; + Sequence< OUString > aCcRecipientSeq; - // all other recipient must be handled with CC recipients! - if ( nCcSeqCount > 0 ) + aCcRecipientSeq.realloc( nCcSeqCount ); + if ( nCcSeqCount > nCcCount ) { - size_t nIndex = 0; - Sequence< OUString > aCcRecipientSeq; - - aCcRecipientSeq.realloc( nCcSeqCount ); - if ( nCcSeqCount > nCcCount ) + for ( size_t i = 1; i < nToCount; ++i ) { - for ( size_t i = 1; i < nToCount; ++i ) - { - aCcRecipientSeq[nIndex++] = *mpToList->at(i); - } + aCcRecipientSeq[nIndex++] = *mpToList->at(i); } + } - for ( size_t i = 0; i < nCcCount; i++ ) - { - aCcRecipientSeq[nIndex++] = *mpCcList->at(i); - } - xSimpleMailMessage->setCcRecipient( aCcRecipientSeq ); + for ( size_t i = 0; i < nCcCount; i++ ) + { + aCcRecipientSeq[nIndex++] = *mpCcList->at(i); } + xSimpleMailMessage->setCcRecipient( aCcRecipientSeq ); + } - size_t nBccCount = mpBccList ? mpBccList->size() : 0; - if ( nBccCount > 0 ) + size_t nBccCount = mpBccList ? mpBccList->size() : 0; + if ( nBccCount > 0 ) + { + Sequence< OUString > aBccRecipientSeq( nBccCount ); + for ( size_t i = 0; i < nBccCount; ++i ) { - Sequence< OUString > aBccRecipientSeq( nBccCount ); - for ( size_t i = 0; i < nBccCount; ++i ) - { - aBccRecipientSeq[i] = *mpBccList->at(i); - } - xSimpleMailMessage->setBccRecipient( aBccRecipientSeq ); + aBccRecipientSeq[i] = *mpBccList->at(i); } + xSimpleMailMessage->setBccRecipient( aBccRecipientSeq ); + } - Sequence< OUString > aAttachmentSeq(&(maAttachedDocuments[0]),maAttachedDocuments.size()); + Sequence< OUString > aAttachmentSeq(&(maAttachedDocuments[0]),maAttachedDocuments.size()); - if ( xSimpleMailMessage->getSubject().isEmpty() ) { - OUString baseName( maAttachedDocuments[0].copy( maAttachedDocuments[0].lastIndexOf( '/' ) + 1 ) ); - OUString subject( baseName ); - if ( maAttachedDocuments.size() > 1 ) - subject += OUString(", ..."); - xSimpleMailMessage->setSubject( subject ); - } - xSimpleMailMessage->setAttachement( aAttachmentSeq ); + if ( xSimpleMailMessage->getSubject().isEmpty() ) { + OUString baseName( maAttachedDocuments[0].copy( maAttachedDocuments[0].lastIndexOf( '/' ) + 1 ) ); + OUString subject( baseName ); + if ( maAttachedDocuments.size() > 1 ) + subject += OUString(", ..."); + xSimpleMailMessage->setSubject( subject ); + } + xSimpleMailMessage->setAttachement( aAttachmentSeq ); - sal_Bool bSend( sal_False ); - try - { - xSimpleMailClient->sendSimpleMailMessage( xSimpleMailMessage, nSendFlags ); - bSend = sal_True; - } - catch ( IllegalArgumentException& ) - { - } - catch ( Exception& ) - { - } + sal_Bool bSend( sal_False ); + try + { + xSimpleMailClient->sendSimpleMailMessage( xSimpleMailMessage, nSendFlags ); + bSend = sal_True; + } + catch ( IllegalArgumentException& ) + { + } + catch ( Exception& ) + { + } - if ( bSend == sal_False ) - { - css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow(); + if ( bSend == sal_False ) + { + css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow(); - SolarMutexGuard aGuard; - Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); + SolarMutexGuard aGuard; + Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); - ErrorBox aBox( pParentWindow, SfxResId( RID_ERRBOX_MAIL_CONFIG )); - aBox.Execute(); - eResult = SEND_MAIL_CANCELLED; - } - else - eResult = SEND_MAIL_OK; + ErrorBox aBox( pParentWindow, SfxResId( RID_ERRBOX_MAIL_CONFIG )); + aBox.Execute(); + eResult = SEND_MAIL_CANCELLED; } + else + eResult = SEND_MAIL_OK; } } } diff --git a/sfx2/source/dialog/taskpane.cxx b/sfx2/source/dialog/taskpane.cxx index cdc6f22f7bf3..4f44b6910ba3 100644 --- a/sfx2/source/dialog/taskpane.cxx +++ b/sfx2/source/dialog/taskpane.cxx @@ -99,11 +99,11 @@ namespace sfx2 ::utl::OConfigurationTreeRoot lcl_getModuleUIElementStatesConfig( const ::rtl::OUString& i_rModuleIdentifier, const ::rtl::OUString& i_rResourceURL = ::rtl::OUString() ) { - const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + const Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); ::rtl::OUStringBuffer aPathComposer; try { - const Reference< XModuleManager2 > xModuleAccess( ModuleManager::create(aContext.getUNOContext()) ); + const Reference< XModuleManager2 > xModuleAccess( ModuleManager::create(xContext) ); const ::comphelper::NamedValueCollection aModuleProps( xModuleAccess->getByName( i_rModuleIdentifier ) ); const ::rtl::OUString sWindowStateRef( aModuleProps.getOrDefault( "ooSetupFactoryWindowStateConfigRef", ::rtl::OUString() ) ); @@ -121,7 +121,7 @@ namespace sfx2 { DBG_UNHANDLED_EXCEPTION(); } - return ::utl::OConfigurationTreeRoot( aContext, aPathComposer.makeStringAndClear(), false ); + return ::utl::OConfigurationTreeRoot( xContext, aPathComposer.makeStringAndClear(), false ); } //-------------------------------------------------------------------------------------------------------------- @@ -382,8 +382,7 @@ namespace sfx2 //------------------------------------------------------------------------------------------------------------------ void CustomToolPanel::impl_updatePanelConfig( const bool i_bVisible ) const { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - ::utl::OConfigurationTreeRoot aConfig( aContext, m_sPanelConfigPath, true ); + ::utl::OConfigurationTreeRoot aConfig( ::comphelper::getProcessComponentContext(), m_sPanelConfigPath, true ); aConfig.setNodeValue( "Visible", makeAny( i_bVisible ) ); aConfig.commit(); |