diff options
author | Ariel Constenla-Haile <arielch@apache.org> | 2012-10-16 20:28:22 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-07 13:40:25 +0100 |
commit | a47a153a7f75edfe3bce33f0d34b723cbd2d5195 (patch) | |
tree | c13f6f5bafbb11026a193e0bfff07a371764598e /shell/source | |
parent | d371248b8eab5cbdc22221603c0587066240223a (diff) |
Resolves: #i93995# Allow setting Body of a simple mail message
(cherry picked from commit 093977b1171fae4eaef13a6d32929451fc64ae66)
Conflicts:
offapi/com/sun/star/system/makefile.mk
shell/source/cmdmail/cmdmailmsg.cxx
shell/source/cmdmail/cmdmailmsg.hxx
shell/source/win32/simplemail/smplmailclient.cxx
shell/source/win32/simplemail/smplmailclient.hxx
shell/source/win32/simplemail/smplmailmsg.hxx
shell/source/win32/simplemail/smplmailsuppl.hxx
Change-Id: Ief1aefee32a6750dfed96476d2968ce76b038440
Diffstat (limited to 'shell/source')
-rw-r--r-- | shell/source/cmdmail/cmdmailmsg.cxx | 66 | ||||
-rw-r--r-- | shell/source/cmdmail/cmdmailmsg.hxx | 15 | ||||
-rw-r--r-- | shell/source/cmdmail/cmdmailsuppl.cxx | 13 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.cxx | 15 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.cxx | 12 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.hxx | 12 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailsuppl.hxx | 1 |
7 files changed, 83 insertions, 51 deletions
diff --git a/shell/source/cmdmail/cmdmailmsg.cxx b/shell/source/cmdmail/cmdmailmsg.cxx index ca56e0f2e18d..298da1d05fac 100644 --- a/shell/source/cmdmail/cmdmailmsg.cxx +++ b/shell/source/cmdmail/cmdmailmsg.cxx @@ -17,16 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <osl/diagnose.h> #include "cmdmailmsg.hxx" -#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp> -#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/RuntimeException.hpp> - -//------------------------------------------------------------------------ -// namespace directives -//------------------------------------------------------------------------ using com::sun::star::lang::IllegalArgumentException; using com::sun::star::lang::WrappedTargetException; @@ -38,7 +29,19 @@ using namespace cppu; using namespace com::sun::star::uno; -//------------------------------------------------ +void SAL_CALL CmdMailMsg::setBody( const OUString& aBody ) + throw (RuntimeException) +{ + MutexGuard aGuard( m_aMutex ); + m_aBody = aBody; +} + +OUString SAL_CALL CmdMailMsg::getBody( ) + throw (RuntimeException) +{ + MutexGuard aGuard( m_aMutex ); + return m_aBody; +} void SAL_CALL CmdMailMsg::setRecipient( const OUString& aRecipient ) throw (RuntimeException) @@ -47,8 +50,6 @@ void SAL_CALL CmdMailMsg::setRecipient( const OUString& aRecipient ) m_aRecipient = aRecipient; } -//------------------------------------------------ - OUString SAL_CALL CmdMailMsg::getRecipient( ) throw (RuntimeException) { @@ -56,8 +57,6 @@ OUString SAL_CALL CmdMailMsg::getRecipient( ) return m_aRecipient; } -//------------------------------------------------ - void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient ) throw (RuntimeException) { @@ -65,8 +64,6 @@ void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipie m_CcRecipients = aCcRecipient; } -//------------------------------------------------ - Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient( ) throw (RuntimeException) { @@ -74,8 +71,6 @@ Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient( ) return m_CcRecipients; } -//------------------------------------------------ - void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient ) throw (RuntimeException) { @@ -83,8 +78,6 @@ void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecip m_BccRecipients = aBccRecipient; } -//------------------------------------------------ - Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient( ) throw (RuntimeException) { @@ -92,8 +85,6 @@ Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient( ) return m_BccRecipients; } -//------------------------------------------------ - void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator ) throw (RuntimeException) { @@ -101,8 +92,6 @@ void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator ) m_aOriginator = aOriginator; } -//------------------------------------------------ - OUString SAL_CALL CmdMailMsg::getOriginator( ) throw (RuntimeException) { @@ -110,8 +99,6 @@ OUString SAL_CALL CmdMailMsg::getOriginator( ) return m_aOriginator; } -//------------------------------------------------ - void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject ) throw (RuntimeException) { @@ -119,8 +106,6 @@ void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject ) m_aSubject = aSubject; } -//------------------------------------------------ - OUString SAL_CALL CmdMailMsg::getSubject( ) throw (RuntimeException) { @@ -128,8 +113,6 @@ OUString SAL_CALL CmdMailMsg::getSubject( ) return m_aSubject; } -//------------------------------------------------ - void SAL_CALL CmdMailMsg::setAttachement( const Sequence< OUString >& aAttachment ) throw (IllegalArgumentException, RuntimeException) { @@ -137,8 +120,6 @@ void SAL_CALL CmdMailMsg::setAttachement( const Sequence< OUString >& aAttachmen m_Attachments = aAttachment; } -//------------------------------------------------ - Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( ) throw (RuntimeException) { @@ -146,13 +127,14 @@ Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( ) return m_Attachments; } -//------------------------------------------------ - Any SAL_CALL CmdMailMsg::getByName( const OUString& aName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException) { MutexGuard aGuard( m_aMutex ); + if( 0 == aName.compareToAscii( "body" ) && !m_aBody.isEmpty() ) + return makeAny( m_aBody ); + if( 0 == aName.compareToAscii( "from" ) && !m_aOriginator.isEmpty() ) return makeAny( m_aOriginator ); @@ -175,15 +157,16 @@ Any SAL_CALL CmdMailMsg::getByName( const OUString& aName ) static_cast < XNameAccess * > (this) ); } -//------------------------------------------------ - Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( ) throw (::com::sun::star::uno::RuntimeException) { MutexGuard aGuard( m_aMutex ); sal_Int32 nItems = 0; - Sequence< OUString > aRet( 6 ); + Sequence< OUString > aRet( 7 ); + + if( !m_aBody.isEmpty() ) + aRet[nItems++] = OUString("body"); if( !m_aOriginator.isEmpty() ) aRet[nItems++] = OUString("from"); @@ -207,13 +190,14 @@ Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( ) return aRet; } -//------------------------------------------------ - sal_Bool SAL_CALL CmdMailMsg::hasByName( const OUString& aName ) throw (RuntimeException) { MutexGuard aGuard( m_aMutex ); + if( 0 == aName.compareToAscii( "body" ) && !m_aBody.isEmpty() ) + return sal_True; + if( 0 == aName.compareToAscii( "from" ) && !m_aOriginator.isEmpty() ) return sal_True; @@ -235,8 +219,6 @@ Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( ) return sal_False; } -//------------------------------------------------ - Type SAL_CALL CmdMailMsg::getElementType( ) throw (RuntimeException) { @@ -244,8 +226,6 @@ Type SAL_CALL CmdMailMsg::getElementType( ) return Type(); } -//------------------------------------------------ - sal_Bool SAL_CALL CmdMailMsg::hasElements( ) throw (RuntimeException) { diff --git a/shell/source/cmdmail/cmdmailmsg.hxx b/shell/source/cmdmail/cmdmailmsg.hxx index 3c810f7194fa..24a3514d2aab 100644 --- a/shell/source/cmdmail/cmdmailmsg.hxx +++ b/shell/source/cmdmail/cmdmailmsg.hxx @@ -24,7 +24,7 @@ #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/system/XSimpleMailMessage.hpp> +#include <com/sun/star/system/XSimpleMailMessage2.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/Reference.hxx> @@ -34,9 +34,10 @@ class CmdMailMsg : public cppu::WeakImplHelper2< - ::com::sun::star::system::XSimpleMailMessage, + ::com::sun::star::system::XSimpleMailMessage2, ::com::sun::star::container::XNameAccess > { + OUString m_aBody; OUString m_aRecipient; OUString m_aOriginator; OUString m_aSubject; @@ -54,6 +55,12 @@ public: // XSimpleMailMessage //------------------------------------------------ + virtual void SAL_CALL setBody( const OUString& aBody ) + throw (::com::sun::star::uno::RuntimeException); + + virtual OUString SAL_CALL getBody( ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRecipient( const OUString& aRecipient ) throw (::com::sun::star::uno::RuntimeException); @@ -90,7 +97,7 @@ public: virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAttachement( ) throw (::com::sun::star::uno::RuntimeException); - //------------------------------------------------ + //------------------------------------------------ // XNameAccess //------------------------------------------------ @@ -103,7 +110,7 @@ public: virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException); - //------------------------------------------------ + //------------------------------------------------ // XElementAccess //------------------------------------------------ diff --git a/shell/source/cmdmail/cmdmailsuppl.cxx b/shell/source/cmdmail/cmdmailsuppl.cxx index 81a322e51b10..7687faed8b41 100644 --- a/shell/source/cmdmail/cmdmailsuppl.cxx +++ b/shell/source/cmdmail/cmdmailsuppl.cxx @@ -45,6 +45,7 @@ using com::sun::star::beans::PropertyValue; using com::sun::star::system::XSimpleMailClientSupplier; using com::sun::star::system::XSimpleMailClient; using com::sun::star::system::XSimpleMailMessage; +using com::sun::star::system::XSimpleMailMessage2; using com::sun::star::container::XNameAccess; using com::sun::star::container::NoSuchElementException; using osl::MutexGuard; @@ -186,6 +187,18 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM throw; } + Reference< XSimpleMailMessage2 > xMessage( xSimpleMailMessage, UNO_QUERY ); + if ( xMessage.is() ) + { + rtl::OUString sBody = xMessage->getBody(); + if ( sBody.getLength() > 0 ) + { + aBuffer.append("--body \""); + aBuffer.append(OUStringToOString(sBody, osl_getThreadTextEncoding())); + aBuffer.append("\" "); + } + } + // Append originator if set in the message if ( !xSimpleMailMessage->getOriginator().isEmpty() ) { diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx index 9db17ce8347c..5a9b30de840f 100644 --- a/shell/source/win32/simplemail/smplmailclient.cxx +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -23,6 +23,7 @@ #include "smplmailclient.hxx" #include "smplmailmsg.hxx" #include <com/sun/star/system/SimpleMailClientFlags.hpp> +#include <com/sun/star/system/XSimpleMailMessage2.hpp> #include <osl/file.hxx> #define WIN32_LEAN_AND_MEAN @@ -38,6 +39,7 @@ #include <process.h> #include <vector> +using css::uno::UNO_QUERY; using css::uno::Reference; using css::uno::Exception; using css::uno::RuntimeException; @@ -46,6 +48,7 @@ using css::lang::IllegalArgumentException; using css::system::XSimpleMailClient; using css::system::XSimpleMailMessage; +using css::system::XSimpleMailMessage2; using css::system::SimpleMailClientFlags::NO_USER_INTERFACE; using css::system::SimpleMailClientFlags::NO_LOGON_DIALOG; @@ -56,6 +59,7 @@ const OUString CC("--cc"); const OUString BCC("--bcc"); const OUString FROM("--from"); const OUString SUBJECT("--subject"); +const OUString BODY("--body"); const OUString ATTACH("--attach"); const OUString FLAG_MAPI_DIALOG("--mapi-dialog"); const OUString FLAG_MAPI_LOGON_UI("--mapi-logon-ui"); @@ -175,6 +179,17 @@ void CSmplMailClient::assembleCommandLine( { OSL_ENSURE(rCommandArgs.empty(), "Provided command argument buffer not empty"); + Reference<XSimpleMailMessage2> xMessage( xSimpleMailMessage, UNO_QUERY ); + if (xMessage.is()) + { + OUString body = xMessage->getBody(); + if (body.getLength()>0) + { + rCommandArgs.push_back(BODY); + rCommandArgs.push_back(body); + } + } + OUString to = xSimpleMailMessage->getRecipient(); if (to.getLength() > 0) { diff --git a/shell/source/win32/simplemail/smplmailmsg.cxx b/shell/source/win32/simplemail/smplmailmsg.cxx index bae8bec90db7..d37fe836183a 100644 --- a/shell/source/win32/simplemail/smplmailmsg.cxx +++ b/shell/source/win32/simplemail/smplmailmsg.cxx @@ -43,6 +43,18 @@ CSmplMailMsg::CSmplMailMsg( ) { } +void SAL_CALL CSmplMailMsg::setBody( const ::rtl::OUString& aBody ) + throw (RuntimeException) +{ + m_aBody = aBody; +} + +::rtl::OUString SAL_CALL CSmplMailMsg::getBody( ) + throw (RuntimeException) +{ + return m_aBody; +} + //------------------------------------------------ void SAL_CALL CSmplMailMsg::setRecipient( const OUString& aRecipient ) diff --git a/shell/source/win32/simplemail/smplmailmsg.hxx b/shell/source/win32/simplemail/smplmailmsg.hxx index 76e3822a6a32..7d659db363de 100644 --- a/shell/source/win32/simplemail/smplmailmsg.hxx +++ b/shell/source/win32/simplemail/smplmailmsg.hxx @@ -23,19 +23,24 @@ #include <cppuhelper/compbase1.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> - -#include <com/sun/star/system/XSimpleMailMessage.hpp> +#include <com/sun/star/system/XSimpleMailMessage2.hpp> //---------------------------------------------------------- // class declaration //---------------------------------------------------------- class CSmplMailMsg : - public cppu::WeakImplHelper1< com::sun::star::system::XSimpleMailMessage > + public cppu::WeakImplHelper1< com::sun::star::system::XSimpleMailMessage2 > { public: CSmplMailMsg( ); + virtual void SAL_CALL setBody( const ::rtl::OUString& aBody ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getBody( ) + throw (::com::sun::star::uno::RuntimeException); + //------------------------------------------------ virtual void SAL_CALL setRecipient( const OUString& aRecipient ) @@ -85,6 +90,7 @@ public: throw (::com::sun::star::uno::RuntimeException); private: + OUString m_aBody; OUString m_aRecipient; OUString m_aOriginator; OUString m_aSubject; diff --git a/shell/source/win32/simplemail/smplmailsuppl.hxx b/shell/source/win32/simplemail/smplmailsuppl.hxx index 557c01d78e53..7440cd870421 100644 --- a/shell/source/win32/simplemail/smplmailsuppl.hxx +++ b/shell/source/win32/simplemail/smplmailsuppl.hxx @@ -23,7 +23,6 @@ #include <cppuhelper/compbase2.hxx> #include <osl/mutex.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> - #include <com/sun/star/system/XSimpleMailClientSupplier.hpp> #include "simplemapi.hxx" |