LCOV - code coverage report
Current view: top level - sw/source/uibase/inc - mailmergehelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 26 34.6 %
Date: 2015-06-13 12:38:46 Functions: 5 13 38.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_MAILMERGEHELPER_HXX
      20             : #define INCLUDED_SW_SOURCE_UIBASE_INC_MAILMERGEHELPER_HXX
      21             : 
      22             : #include <svtools/stdctrl.hxx>
      23             : #include <unotools/configitem.hxx>
      24             : #include <com/sun/star/uno/Sequence.h>
      25             : #include <com/sun/star/mail/XAuthenticator.hpp>
      26             : #include <com/sun/star/mail/XConnectionListener.hpp>
      27             : #include <com/sun/star/uno/XCurrentContext.hpp>
      28             : #include <com/sun/star/mail/XMailMessage.hpp>
      29             : #include <com/sun/star/datatransfer/XTransferable.hpp>
      30             : #include <com/sun/star/beans/XPropertySet.hpp>
      31             : #include <cppuhelper/implbase.hxx>
      32             : #include <cppuhelper/compbase.hxx>
      33             : #include <vcl/scrbar.hxx>
      34             : #include <rtl/ustring.hxx>
      35             : #include "swdllapi.h"
      36             : 
      37             : class SwMailMergeConfigItem;
      38             : 
      39             : namespace com { namespace sun { namespace star { namespace mail {
      40             :     class XMailService;
      41             :     class XSmtpService;
      42             : } } } }
      43             : 
      44             : namespace SwMailMergeHelper
      45             : {
      46             :     SW_DLLPUBLIC OUString CallSaveAsDialog(OUString& rFilter);
      47             :     SW_DLLPUBLIC bool CheckMailAddress(const OUString& rMailAddress);
      48             :     SW_DLLPUBLIC css::uno::Reference<css::mail::XSmtpService> ConnectToSmtpServer(
      49             :                             SwMailMergeConfigItem& rConfigItem,
      50             :                             css::uno::Reference<css::mail::XMailService>& xInMailService,
      51             :                             const OUString& rInMailServerPassword,
      52             :                             const OUString& rOutMailServerPassword,
      53             :                             vcl::Window* pDialogParentWindow = 0);
      54             : }
      55             : 
      56             : struct SwAddressPreview_Impl;
      57             : 
      58             : // Preview window used to show the possible selection of address blocks
      59             : // and also the resulting address filled with database data
      60             : class SW_DLLPUBLIC SwAddressPreview : public vcl::Window
      61             : {
      62             :     VclPtr<ScrollBar> aVScrollBar;
      63             :     SwAddressPreview_Impl* pImpl;
      64             :     Link<> m_aSelectHdl;
      65             : 
      66             :     void DrawText_Impl(vcl::RenderContext& rRenderContext, const OUString& rAddress,
      67             :                        const Point& rTopLeft, const Size& rSize, bool bIsSelected);
      68             : 
      69             :     virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
      70             :     virtual void Resize() SAL_OVERRIDE;
      71             :     virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      72             :     virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
      73             :     virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
      74             :     void UpdateScrollBar();
      75             : 
      76             :     DECL_LINK(ScrollHdl, void*);
      77             : 
      78             : public:
      79             :     SwAddressPreview(vcl::Window* pParent, WinBits nStyle=WB_BORDER);
      80             :     virtual ~SwAddressPreview();
      81             :     virtual void dispose() SAL_OVERRIDE;
      82             : 
      83             :     void positionScrollBar();
      84             : 
      85             :     /** The address string is a list of address elements separated by spaces
      86             :     and breaks. The addresses fit into the given layout. If more addresses then
      87             :     rows/columns should be used a scrollbar will be added.
      88             : 
      89             :      AddAddress appends the new address to the already added ones.
      90             :      Initially the first added address will be selected
      91             :     */
      92             :     void AddAddress(const OUString& rAddress);
      93             :     //  for preview mode - replaces the currently used address by the given one
      94             :     void SetAddress(const OUString& rAddress);
      95             :     // removes all addresses
      96             :     void Clear();
      97             : 
      98             :     // returns the selected address
      99             :     sal_uInt16 GetSelectedAddress() const;
     100             :     void SelectAddress(sal_uInt16 nSelect);
     101             :     void ReplaceSelectedAddress(const OUString&);
     102             :     void RemoveSelectedAddress();
     103             : 
     104             :     // set the number of rows and columns of addresses
     105             :     void SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns);
     106             :     void EnableScrollBar(bool bEnable = true);
     107             : 
     108             :     // fill the actual data into a string (address block or greeting)
     109             :     static OUString FillData(const OUString& rAddress, SwMailMergeConfigItem& rConfigItem,
     110             :                              const css::uno::Sequence<OUString>* pAssignments = 0);
     111             : 
     112           0 :     void SetSelectHdl (const Link<>& rLink) { m_aSelectHdl = rLink; }
     113             : };
     114             : 
     115             : // iterate over an address block or a greeting line the iterator returns the
     116             : // parts either as pure string or as column
     117         290 : struct SwMergeAddressItem
     118             : {
     119             :     OUString sText;
     120             :     bool bIsColumn;
     121             :     bool bIsReturn;
     122             : 
     123         290 :     SwMergeAddressItem()
     124             :         : bIsColumn(false)
     125         290 :         , bIsReturn(false)
     126         290 :     {}
     127             : };
     128             : 
     129          50 : class SW_DLLPUBLIC SwAddressIterator
     130             : {
     131             :     OUString sAddress;
     132             : public:
     133          50 :     SwAddressIterator(const OUString& rAddress) :
     134          50 :         sAddress(rAddress)
     135          50 :     {}
     136             : 
     137             :     SwMergeAddressItem  Next();
     138         340 :     bool HasMore() const { return !sAddress.isEmpty(); }
     139             : };
     140             : 
     141             : class SW_DLLPUBLIC SwAuthenticator :
     142             :     public cppu::WeakImplHelper<css::mail::XAuthenticator>
     143             : {
     144             :     OUString m_aUserName;
     145             :     OUString m_aPassword;
     146             :     VclPtr<vcl::Window> m_pParentWindow;
     147             : public:
     148           0 :     SwAuthenticator()
     149           0 :         : m_pParentWindow(0)
     150           0 :     {}
     151           0 :     SwAuthenticator(const OUString& username, const OUString& password, vcl::Window* pParent)
     152             :         : m_aUserName(username)
     153             :         , m_aPassword(password)
     154           0 :         , m_pParentWindow(pParent)
     155           0 :     {}
     156             :     virtual ~SwAuthenticator();
     157             : 
     158             :     virtual OUString SAL_CALL getUserName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             :     virtual OUString SAL_CALL getPassword() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     160             : 
     161             : };
     162             : 
     163             : class SW_DLLPUBLIC SwConnectionContext : public cppu::WeakImplHelper<css::uno::XCurrentContext>
     164             : {
     165             :     OUString m_sMailServer;
     166             :     sal_Int16 m_nPort;
     167             :     OUString m_sConnectionType;
     168             : 
     169             : public:
     170             :     SwConnectionContext(const OUString& rMailServer, sal_Int16 nPort, const OUString& rConnectionType);
     171             :     virtual ~SwConnectionContext();
     172             : 
     173             :     virtual css::uno::Any SAL_CALL getValueByName(const OUString& Name)
     174             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             : };
     176             : 
     177           0 : class SwMutexBase
     178             : {
     179             : public:
     180             :     osl::Mutex m_aMutex;
     181             : };
     182             : 
     183             : class SW_DLLPUBLIC SwConnectionListener :
     184             :         public SwMutexBase,
     185             :         public cppu::WeakComponentImplHelper<css::mail::XConnectionListener>
     186             : {
     187             :     using cppu::WeakComponentImplHelperBase::disposing;
     188             : 
     189             : public:
     190           0 :     SwConnectionListener() :
     191           0 :         cppu::WeakComponentImplHelper<css::mail::XConnectionListener>(m_aMutex)
     192           0 :     {}
     193             :     virtual ~SwConnectionListener();
     194             : 
     195             :     virtual void SAL_CALL connected(const css::lang::EventObject& aEvent)
     196             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     197             : 
     198             :     virtual void SAL_CALL disconnected(const css::lang::EventObject& aEvent)
     199             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             : 
     201             :     virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
     202             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : };
     204             : 
     205             : class SW_DLLPUBLIC SwMailTransferable :
     206             :         public SwMutexBase,
     207             :         public cppu::WeakComponentImplHelper<css::datatransfer::XTransferable, css::beans::XPropertySet>
     208             : {
     209             :     OUString  m_aMimeType;
     210             :     OUString  m_sBody;
     211             :     OUString  m_aURL;
     212             :     OUString  m_aName;
     213             :     bool m_bIsBody;
     214             : 
     215             :     public:
     216             :     SwMailTransferable(const OUString& rURL, const OUString& rName, const OUString& rMimeType);
     217             :     SwMailTransferable(const OUString& rBody, const OUString& rMimeType);
     218             :     virtual ~SwMailTransferable();
     219             :     virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& aFlavor)
     220             :                 throw (css::datatransfer::UnsupportedFlavorException, css::io::IOException,
     221             :                        css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     222             : 
     223             :     virtual css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors()
     224             :                             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     225             :     virtual sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& aFlavor)
     226             :                             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     227             : 
     228             :     //XPropertySet
     229             :     virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo()
     230             :                 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     231             :     virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const css::uno::Any& aValue)
     232             :                 throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
     233             :                       css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
     234             :                       css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     235             : 
     236             :     virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName)
     237             :                 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
     238             :                       css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             :     virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName,
     240             :                                                     const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener)
     241             :                 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
     242             :                       css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     243             :     virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName,
     244             :                                                        const css::uno::Reference<css::beans::XPropertyChangeListener >& aListener)
     245             :                 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
     246             :                       css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     247             :     virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName,
     248             :                                                     const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener)
     249             :                 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
     250             :                       css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     251             :     virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,
     252             :                                                        const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener)
     253             :                 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
     254             :                       css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     255             : 
     256             : };
     257             : 
     258             : class SW_DLLPUBLIC SwMailMessage :
     259             :         public SwMutexBase,
     260             :         public cppu::WeakComponentImplHelper<css::mail::XMailMessage>
     261             : {
     262             :     OUString m_sSenderName;
     263             :     OUString m_sSenderAddress;
     264             :     OUString m_sReplyToAddress;
     265             :     OUString m_sSubject;
     266             : 
     267             :     css::uno::Reference<css::datatransfer::XTransferable> m_xBody;
     268             : //  css::mail::MailMessageBody m_aBody;
     269             : 
     270             :     css::uno::Sequence<OUString> m_aRecipients;
     271             :     css::uno::Sequence<OUString> m_aCcRecipients;
     272             :     css::uno::Sequence<OUString> m_aBccRecipients;
     273             : //  css::uno::Sequence<css::mail::MailAttachmentDescriptor> m_aAttachments;
     274             :     css::uno::Sequence<css::mail::MailAttachment> m_aAttachments;
     275             : public:
     276             :     SwMailMessage();
     277             :     virtual ~SwMailMessage();
     278             : 
     279             :     // attributes
     280             :     virtual OUString SAL_CALL getSenderName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     281             :     virtual OUString SAL_CALL getSenderAddress() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     282             :     virtual OUString SAL_CALL getReplyToAddress() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     283             :     virtual void SAL_CALL setReplyToAddress( const OUString& _replytoaddress )
     284             :                         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     285             :     virtual OUString SAL_CALL getSubject() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     286             :     virtual void SAL_CALL setSubject(const OUString& _subject)
     287             :                         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     288             : 
     289             :     virtual css::uno::Reference<css::datatransfer::XTransferable> SAL_CALL getBody()
     290             :                         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     291             :     virtual void SAL_CALL setBody(const css::uno::Reference<css::datatransfer::XTransferable>& _body)
     292             :                         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     293             : 
     294             :     // methods
     295             :     virtual void SAL_CALL addRecipient( const OUString& sRecipientAddress )
     296             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     297             :     virtual void SAL_CALL addCcRecipient( const OUString& sRecipientAddress )
     298             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     299             :     virtual void SAL_CALL addBccRecipient( const OUString& sRecipientAddress )
     300             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     301             :     virtual css::uno::Sequence<OUString> SAL_CALL getRecipients()
     302             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     303             :     virtual css::uno::Sequence<OUString> SAL_CALL getCcRecipients()
     304             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     305             :     virtual css::uno::Sequence<OUString> SAL_CALL getBccRecipients()
     306             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     307             :     virtual void SAL_CALL addAttachment(const css::mail::MailAttachment& aMailAttachment)
     308             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     309             :     virtual css::uno::Sequence<css::mail::MailAttachment> SAL_CALL getAttachments()
     310             :                 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     311           0 :     void SetSenderName(const OUString& rSenderName)
     312             :     {
     313           0 :         m_sSenderName = rSenderName;
     314           0 :     }
     315           0 :     void SetSenderAddress(const OUString& rSenderAddress)
     316             :     {
     317           0 :         m_sSenderAddress = rSenderAddress;
     318           0 :     }
     319             : };
     320             : 
     321             : #endif
     322             : 
     323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11