[Libreoffice-commits] core.git: offapi/com offapi/UnoApi_offapi.mk shell/source

Ariel Constenla-Haile arielch at apache.org
Fri Jun 7 05:40:46 PDT 2013


 offapi/UnoApi_offapi.mk                            |    1 
 offapi/com/sun/star/system/XSimpleMailMessage2.idl |   36 +++++++++++
 shell/source/cmdmail/cmdmailmsg.cxx                |   66 +++++++--------------
 shell/source/cmdmail/cmdmailmsg.hxx                |   15 +++-
 shell/source/cmdmail/cmdmailsuppl.cxx              |   13 ++++
 shell/source/win32/simplemail/smplmailclient.cxx   |   15 ++++
 shell/source/win32/simplemail/smplmailmsg.cxx      |   12 +++
 shell/source/win32/simplemail/smplmailmsg.hxx      |   12 ++-
 shell/source/win32/simplemail/smplmailsuppl.hxx    |    1 
 9 files changed, 120 insertions(+), 51 deletions(-)

New commits:
commit a47a153a7f75edfe3bce33f0d34b723cbd2d5195
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Tue Oct 16 20:28:22 2012 +0000

    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

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index bd28407..1342d3f 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3582,6 +3582,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/system,\
 	XSimpleMailClient \
 	XSimpleMailClientSupplier \
 	XSimpleMailMessage \
+	XSimpleMailMessage2 \
 	XSystemShellExecute \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/table,\
diff --git a/offapi/com/sun/star/system/XSimpleMailMessage2.idl b/offapi/com/sun/star/system/XSimpleMailMessage2.idl
new file mode 100644
index 0000000..2108956
--- /dev/null
+++ b/offapi/com/sun/star/system/XSimpleMailMessage2.idl
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_system_XSimpleMailMessage2_idl__
+#define __com_sun_star_system_XSimpleMailMessage2_idl__
+
+#include <com/sun/star/system/XSimpleMailMessage.idl>
+
+module com { module sun { module star { module system {
+
+/** This interface extends XSimpleMailMessage
+
+    @since LibreOffice 4.2
+*/
+interface XSimpleMailMessage2 : XSimpleMailMessage
+{
+    [attribute] string Body;
+};
+
+}; }; }; };
+
+#endif
diff --git a/shell/source/cmdmail/cmdmailmsg.cxx b/shell/source/cmdmail/cmdmailmsg.cxx
index ca56e0f..298da1d 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 3c810f7..24a3514 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 81a322e..7687fae 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 9db17ce..5a9b30d 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 bae8bec..d37fe83 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 76e3822..7d659db 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 557c01d..7440cd8 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"


More information about the Libreoffice-commits mailing list