[Libreoffice-commits] .: sfx2/source shell/source

Fridrich Strba fridrich at kemper.freedesktop.org
Fri Oct 15 02:27:25 PDT 2010


 sfx2/source/dialog/mailmodel.cxx          |   10 ++++++++--
 shell/source/win32/simplemail/senddoc.cxx |   16 +++++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 59e48cc7e19dcf1181bf24239ac0604f79f44014
Author: Tor Lillqvist <tlillqvist at novell.com>
Date:   Fri Oct 15 11:10:08 2010 +0200

    mail-document-subject.diff: sanitize subject if document mailed from LibreOffice
    
    bnc#459176

diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx
index 3bd809f..786ff4f 100644
--- a/sfx2/source/dialog/mailmodel.cxx
+++ b/sfx2/source/dialog/mailmodel.cxx
@@ -844,8 +844,14 @@ SfxMailModel::SendMailResult SfxMailModel::Send( const css::uno::Reference< css:
                     }
 
                     Sequence< OUString > aAttachmentSeq(&(maAttachedDocuments[0]),maAttachedDocuments.size());
-
-                    xSimpleMailMessage->setSubject( maSubject );
+ 
+                    if ( xSimpleMailMessage->getSubject().getLength() == 0 ) {
+                        OUString baseName( maAttachedDocuments[0].copy( maAttachedDocuments[0].lastIndexOf( '/' ) + 1 ) );
+                        OUString subject( baseName );
+                        if ( maAttachedDocuments.size() > 1 )
+                            subject += OUString::createFromAscii( ", ..." );
+                        xSimpleMailMessage->setSubject( subject );
+                    }
                     xSimpleMailMessage->setAttachement( aAttachmentSeq );
 
                     sal_Bool bSend( sal_False );
diff --git a/shell/source/win32/simplemail/senddoc.cxx b/shell/source/win32/simplemail/senddoc.cxx
index 696cd80..76aa7cc 100644
--- a/shell/source/win32/simplemail/senddoc.cxx
+++ b/shell/source/win32/simplemail/senddoc.cxx
@@ -30,6 +30,10 @@
 #include "precompiled_shell.hxx"
 #include <osl/diagnose.h>
 #include <sal/macros.h>
+#include <rtl/string.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/uri.hxx>
+#include <osl/thread.hxx>
 
 #include "simplemapi.hxx"
 
@@ -166,7 +170,17 @@ void initMapiMessage(
 {
     ZeroMemory(pMapiMessage, sizeof(MapiMessage));
              
-    pMapiMessage->lpszSubject = const_cast<char*>(gSubject.c_str());   
+    try {
+         rtl_uString *subject = NULL;
+         rtl_uString_newFromAscii(&subject, const_cast<char*>(gSubject.c_str()));
+         rtl_uString *decoded_subject = NULL;
+         rtl_uriDecode(subject, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8, &decoded_subject);
+         rtl::OUString ou_subject(decoded_subject);
+         pMapiMessage->lpszSubject = strdup(OUStringToOString(ou_subject, osl_getThreadTextEncoding(), RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK).getStr());
+    }
+    catch (...) {
+    pMapiMessage->lpszSubject = const_cast<char*>(gSubject.c_str());
+    }
     pMapiMessage->lpszNoteText = (gBody.length() ? const_cast<char*>(gBody.c_str()) : NULL);
     pMapiMessage->lpOriginator = aMapiOriginator;       
     pMapiMessage->lpRecips = &aMapiRecipientList[0];


More information about the Libreoffice-commits mailing list