diff options
author | Ariel Constenla-Haile <arielch@apache.org> | 2012-10-16 20:28:22 +0000 |
---|---|---|
committer | Ariel Constenla-Haile <arielch@apache.org> | 2012-10-16 20:28:22 +0000 |
commit | 093977b1171fae4eaef13a6d32929451fc64ae66 (patch) | |
tree | dfd3acd6b6747d70ddc1d4d9a6e7edbe99005403 /shell/source/win32/simplemail | |
parent | 7a652a2b2ab5e0d37e32185c8c5fac3af482bb76 (diff) |
#i93995# - Allow setting Body of a simple mail message
Notes
merged as: a47a153a7f75edfe3bce33f0d34b723cbd2d5195
Diffstat (limited to 'shell/source/win32/simplemail')
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.cxx | 42 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.hxx | 3 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.cxx | 12 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.hxx | 14 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailsuppl.hxx | 3 |
5 files changed, 49 insertions, 25 deletions
diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx index fd4262ee991c..84d235da5964 100644 --- a/shell/source/win32/simplemail/smplmailclient.cxx +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -29,6 +29,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 @@ -44,6 +45,7 @@ #include <process.h> #include <vector> +using css::uno::UNO_QUERY; using css::uno::Reference; using css::uno::Exception; using css::uno::RuntimeException; @@ -52,21 +54,22 @@ 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; typedef std::vector<rtl::OUString> StringList_t; typedef StringList_t::const_iterator StringListIterator_t; -const rtl::OUString TO = rtl::OUString::createFromAscii("--to"); -const rtl::OUString CC = rtl::OUString::createFromAscii("--cc"); -const rtl::OUString BCC = rtl::OUString::createFromAscii("--bcc"); -const rtl::OUString FROM = rtl::OUString::createFromAscii("--from"); -const rtl::OUString SUBJECT = rtl::OUString::createFromAscii("--subject"); -const rtl::OUString BODY = rtl::OUString::createFromAscii("--body"); -const rtl::OUString ATTACH = rtl::OUString::createFromAscii("--attach"); -const rtl::OUString FLAG_MAPI_DIALOG = rtl::OUString::createFromAscii("--mapi-dialog"); -const rtl::OUString FLAG_MAPI_LOGON_UI = rtl::OUString::createFromAscii("--mapi-logon-ui"); +const rtl::OUString TO = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--to")); +const rtl::OUString CC = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--cc")); +const rtl::OUString BCC = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--bcc")); +const rtl::OUString FROM = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--from")); +const rtl::OUString SUBJECT = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--subject")); +const rtl::OUString BODY = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--body")); +const rtl::OUString ATTACH = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--attach")); +const rtl::OUString FLAG_MAPI_DIALOG = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--mapi-dialog")); +const rtl::OUString FLAG_MAPI_LOGON_UI = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--mapi-logon-ui")); namespace /* private */ { @@ -185,6 +188,17 @@ void CSmplMailClient::assembleCommandLine( { OSL_ENSURE(rCommandArgs.size() == 0, "Provided command argument buffer not empty"); + Reference<XSimpleMailMessage2> xMessage( xSimpleMailMessage, UNO_QUERY ); + if (xMessage.is()) + { + rtl::OUString body = xMessage->getBody(); + if (body.getLength()>0) + { + rCommandArgs.push_back(BODY); + rCommandArgs.push_back(body); + } + } + rtl::OUString to = xSimpleMailMessage->getRecipient(); if (to.getLength() > 0) { @@ -227,7 +241,7 @@ void CSmplMailClient::assembleCommandLine( osl::FileBase::RC err = osl::FileBase::getSystemPathFromFileURL(attachments[i], sysPath); if (err != osl::FileBase::E_None) throw IllegalArgumentException( - rtl::OUString::createFromAscii("Invalid attachment file URL"), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid attachment file URL")), static_cast<XSimpleMailClient*>(this), 1); @@ -253,7 +267,7 @@ void SAL_CALL CSmplMailClient::sendSimpleMailMessage( if (!executeSenddoc(senddocParams)) throw Exception( - rtl::OUString::createFromAscii("Send email failed"), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Send email failed")), static_cast<XSimpleMailClient*>(this)); } @@ -262,7 +276,7 @@ void CSmplMailClient::validateParameter( { if (!xSimpleMailMessage.is()) throw IllegalArgumentException( - rtl::OUString::createFromAscii("Empty mail message reference"), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Empty mail message reference")), static_cast<XSimpleMailClient*>(this), 1); @@ -272,14 +286,14 @@ void CSmplMailClient::validateParameter( // check the flags, the allowed range is 0 - (2^n - 1) if (aFlag < 0 || aFlag > 3) throw IllegalArgumentException( - rtl::OUString::createFromAscii("Invalid flag value"), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid flag value")), static_cast<XSimpleMailClient*>(this), 2); // check if a recipient is specified of the flags NO_USER_INTERFACE is specified if ((aFlag & NO_USER_INTERFACE) && !xSimpleMailMessage->getRecipient().getLength()) throw IllegalArgumentException( - rtl::OUString::createFromAscii("No recipient specified"), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No recipient specified")), static_cast<XSimpleMailClient*>(this), 1); } diff --git a/shell/source/win32/simplemail/smplmailclient.hxx b/shell/source/win32/simplemail/smplmailclient.hxx index a4012e8a97c2..9b69ef45eac1 100644 --- a/shell/source/win32/simplemail/smplmailclient.hxx +++ b/shell/source/win32/simplemail/smplmailclient.hxx @@ -26,10 +26,7 @@ #include <cppuhelper/compbase1.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> - -#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ #include <com/sun/star/system/XSimpleMailClient.hpp> -#endif namespace css = ::com::sun::star; diff --git a/shell/source/win32/simplemail/smplmailmsg.cxx b/shell/source/win32/simplemail/smplmailmsg.cxx index 7b2b540fcba3..07939771a3dd 100644 --- a/shell/source/win32/simplemail/smplmailmsg.cxx +++ b/shell/source/win32/simplemail/smplmailmsg.cxx @@ -54,6 +54,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; +} + //------------------------------------------------ // //------------------------------------------------ diff --git a/shell/source/win32/simplemail/smplmailmsg.hxx b/shell/source/win32/simplemail/smplmailmsg.hxx index 783f2f0540aa..5bbb1c3d296c 100644 --- a/shell/source/win32/simplemail/smplmailmsg.hxx +++ b/shell/source/win32/simplemail/smplmailmsg.hxx @@ -31,21 +31,24 @@ #include <cppuhelper/compbase1.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> - -#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ -#include <com/sun/star/system/XSimpleMailMessage.hpp> -#endif +#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); + //------------------------------------------------ // //------------------------------------------------ @@ -107,6 +110,7 @@ public: throw (::com::sun::star::uno::RuntimeException); private: + rtl::OUString m_aBody; rtl::OUString m_aRecipient; rtl::OUString m_aOriginator; rtl::OUString m_aSubject; diff --git a/shell/source/win32/simplemail/smplmailsuppl.hxx b/shell/source/win32/simplemail/smplmailsuppl.hxx index d5adccea5015..a3c51ee8ebcf 100644 --- a/shell/source/win32/simplemail/smplmailsuppl.hxx +++ b/shell/source/win32/simplemail/smplmailsuppl.hxx @@ -27,10 +27,7 @@ #include <cppuhelper/compbase2.hxx> #include <osl/mutex.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> - -#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ #include <com/sun/star/system/XSimpleMailClientSupplier.hpp> -#endif #ifndef _SIMPLEMAPI_HXX_ #include "simplemapi.hxx" |