LCOV - code coverage report
Current view: top level - sw/source/core/uibase/inc - mailmergehelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 21 0.0 %
Date: 2014-04-14 Functions: 0 15 0.0 %
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_UI_INC_MAILMERGEHELPER_HXX
      20             : #define INCLUDED_SW_SOURCE_UI_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/implbase1.hxx>
      32             : #include <cppuhelper/compbase1.hxx>
      33             : #include <cppuhelper/compbase2.hxx>
      34             : #include <vcl/scrbar.hxx>
      35             : #include "rtl/ustring.hxx"
      36             : #include "swdllapi.h"
      37             : 
      38             : class SwMailMergeConfigItem;
      39             : 
      40             : namespace com { namespace sun { namespace star { namespace mail {
      41             :     class XMailService;
      42             :     class XSmtpService;
      43             : } } } }
      44             : 
      45             : namespace SwMailMergeHelper
      46             : {
      47             :     SW_DLLPUBLIC OUString CallSaveAsDialog(OUString& rFilter);
      48             :     SW_DLLPUBLIC bool    CheckMailAddress( const OUString& rMailAddress );
      49             :     SW_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::mail::XSmtpService >
      50             :                          ConnectToSmtpServer( SwMailMergeConfigItem& rConfigItem,
      51             :                             com::sun::star::uno::Reference< com::sun::star::mail::XMailService >&  xInMailService,
      52             :                             const OUString& rInMailServerPassword,
      53             :                             const OUString& rOutMailServerPassword,
      54             :                             Window* pDialogParentWindow = 0 );
      55             : }
      56             : 
      57             : struct SwAddressPreview_Impl;
      58             : 
      59             : /*-------------------------------------------------------------------------
      60             :     Preview window used to show the possible selection of address blocks
      61             :     and also the resulting address filled with database data
      62             :   -----------------------------------------------------------------------*/
      63           0 : class SW_DLLPUBLIC SwAddressPreview : public Window
      64             : {
      65             :     ScrollBar               aVScrollBar;
      66             :     SwAddressPreview_Impl*  pImpl;
      67             :     Link                    m_aSelectHdl;
      68             : 
      69             :     void DrawText_Impl( const OUString& rAddress, const Point& rTopLeft, const Size& rSize, bool bIsSelected);
      70             : 
      71             :     virtual void        Paint(const Rectangle&) SAL_OVERRIDE;
      72             :     virtual void        Resize() SAL_OVERRIDE;
      73             :     virtual void        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      74             :     virtual void        KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
      75             :     virtual void        StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
      76             :     void                UpdateScrollBar();
      77             : 
      78             :     DECL_LINK(ScrollHdl, void*);
      79             : 
      80             : public:
      81             :     SwAddressPreview(Window* pParent, const ResId& rResId);
      82             : 
      83             :     SwAddressPreview(Window* pParent, WinBits nStyle=WB_BORDER);
      84             : 
      85             :     void positionScrollBar();
      86             : 
      87             :     /** The address string is a list of address elements separated by spaces
      88             :     and breaks. The addresses fit into the given layout. If more addresses then
      89             :     rows/columns should be used a scrollbar will be added.
      90             : 
      91             :      AddAddress appends the new address to the already added ones.
      92             :      Initially the first added address will be selected
      93             :     */
      94             :     void                    AddAddress(const OUString& rAddress);
      95             :     //  for preview mode - replaces the currently used address by the given one
      96             :     void                    SetAddress(const OUString& rAddress);
      97             :     // removes all addresses
      98             :     void                    Clear();
      99             : 
     100             :     // returns the selected address
     101             :     sal_uInt16              GetSelectedAddress() const;
     102             :     void                    SelectAddress(sal_uInt16 nSelect);
     103             :     void                    ReplaceSelectedAddress(const OUString&);
     104             :     void                    RemoveSelectedAddress();
     105             : 
     106             :     // set the number of rows and columns of addresses
     107             :     void                    SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns);
     108             :     void                    EnableScrollBar(bool bEnable = true);
     109             : 
     110             :     // fill the actual data into a string (address block or greeting)
     111             :     static OUString FillData(
     112             :             const OUString& rAddress,
     113             :             SwMailMergeConfigItem& rConfigItem,
     114             :             const ::com::sun::star::uno::Sequence< OUString>* pAssignments = 0);
     115             : 
     116           0 :     void    SetSelectHdl (const Link& rLink) {m_aSelectHdl = rLink;}
     117             : };
     118             : 
     119             : /*-------------------------------------------------------------------------
     120             :     iterate over an address block or a greeting line
     121             :     the iterator returns the parts either as pure string
     122             :     or as column
     123             :   -----------------------------------------------------------------------*/
     124           0 : struct SwMergeAddressItem
     125             : {
     126             :     OUString  sText;
     127             :     bool      bIsColumn;
     128             :     bool      bIsReturn;
     129           0 :     SwMergeAddressItem() :
     130             :         bIsColumn(false),
     131           0 :         bIsReturn(false) {}
     132             : };
     133             : 
     134           0 : class SW_DLLPUBLIC   SwAddressIterator
     135             : {
     136             :     OUString sAddress;
     137             : public:
     138           0 :     SwAddressIterator(const OUString& rAddress) :
     139           0 :         sAddress(rAddress){}
     140             : 
     141             :     SwMergeAddressItem  Next();
     142           0 :     bool                HasMore() const{return !sAddress.isEmpty();}
     143             : };
     144             : 
     145             : class SW_DLLPUBLIC SwAuthenticator :
     146             :     public cppu::WeakImplHelper1< ::com::sun::star::mail::XAuthenticator>
     147             : {
     148             :     OUString m_aUserName;
     149             :     OUString m_aPassword;
     150             :     Window*         m_pParentWindow;
     151             : public:
     152           0 :     SwAuthenticator() : m_pParentWindow(0) {}
     153           0 :     SwAuthenticator(const OUString& username, const OUString& password, Window* pParent) :
     154             :         m_aUserName(username),
     155             :         m_aPassword(password),
     156           0 :         m_pParentWindow( pParent )
     157           0 :     {}
     158             :     virtual ~SwAuthenticator();
     159             : 
     160             :     virtual OUString SAL_CALL getUserName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :     virtual OUString SAL_CALL getPassword(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             : 
     163             : };
     164             : 
     165             : class SW_DLLPUBLIC SwConnectionContext :
     166             :     public cppu::WeakImplHelper1< ::com::sun::star::uno::XCurrentContext >
     167             : {
     168             :     OUString     m_sMailServer;
     169             :     sal_Int16           m_nPort;
     170             :     OUString     m_sConnectionType;
     171             : 
     172             : public:
     173             :     SwConnectionContext(const OUString& rMailServer, sal_Int16 nPort, const OUString& rConnectionType);
     174             :     virtual ~SwConnectionContext();
     175             : 
     176             :     virtual ::com::sun::star::uno::Any SAL_CALL     getValueByName( const OUString& Name )
     177             :                                                             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     178             : };
     179             : 
     180           0 : class SwMutexBase
     181             : {
     182             : public:
     183             :     osl::Mutex m_aMutex;
     184             : };
     185             : 
     186             : class SW_DLLPUBLIC SwConnectionListener :
     187             :         public SwMutexBase,
     188             :         public cppu::WeakComponentImplHelper1< ::com::sun::star::mail::XConnectionListener >
     189             : {
     190             :     using cppu::WeakComponentImplHelperBase::disposing;
     191             : 
     192             : public:
     193           0 :     SwConnectionListener() :
     194           0 :         cppu::WeakComponentImplHelper1< ::com::sun::star::mail::XConnectionListener>(m_aMutex)
     195           0 :     {}
     196             :     virtual ~SwConnectionListener();
     197             : 
     198             :     virtual void SAL_CALL connected(const ::com::sun::star::lang::EventObject& aEvent)
     199             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             : 
     201             :     virtual void SAL_CALL disconnected(const ::com::sun::star::lang::EventObject& aEvent)
     202             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : 
     204             :     virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject& aEvent)
     205             :         throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     206             : };
     207             : 
     208             : class SwMailTransferable :
     209             :         public SwMutexBase,
     210             :         public cppu::WeakComponentImplHelper2
     211             :         <
     212             :             ::com::sun::star::datatransfer::XTransferable,
     213             :             ::com::sun::star::beans::XPropertySet
     214             :         >
     215             : {
     216             :     OUString  m_aMimeType;
     217             :     OUString  m_sBody;
     218             :     OUString  m_aURL;
     219             :     OUString  m_aName;
     220             :     bool           m_bIsBody;
     221             : 
     222             :     public:
     223             :     SwMailTransferable(const OUString& rURL, const OUString& rName, const OUString& rMimeType);
     224             :     SwMailTransferable(const OUString& rBody, const OUString& rMimeType);
     225             :     virtual ~SwMailTransferable();
     226             :     virtual ::com::sun::star::uno::Any SAL_CALL
     227             :                         getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
     228             :                             throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     229             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL
     230             :                         getTransferDataFlavors(  )
     231             :                             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     232             :     virtual sal_Bool SAL_CALL
     233             :                         isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
     234             :                             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     235             : 
     236             :     //XPropertySet
     237             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     238             :     virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             :     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     240             :     virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     241             :     virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     242             :     virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     243             :     virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     244             : 
     245             : };
     246             : 
     247             : class SwMailMessage :
     248             :         public SwMutexBase,
     249             :         public cppu::WeakComponentImplHelper1< ::com::sun::star::mail::XMailMessage >
     250             : {
     251             :     OUString                                                                         m_sSenderName;
     252             :     OUString                                                                         m_sSenderAddress;
     253             :     OUString                                                                         m_sReplyToAddress;
     254             :     OUString                                                                         m_sSubject;
     255             : 
     256             :     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable>        m_xBody;
     257             : //    ::com::sun::star::mail::MailMessageBody                                                 m_aBody;
     258             : 
     259             :     ::com::sun::star::uno::Sequence< OUString >                                      m_aRecipients;
     260             :     ::com::sun::star::uno::Sequence< OUString >                                      m_aCcRecipients;
     261             :     ::com::sun::star::uno::Sequence< OUString >                                      m_aBccRecipients;
     262             : //    ::com::sun::star::uno::Sequence< ::com::sun::star::mail::MailAttachmentDescriptor >     m_aAttachments;
     263             :     ::com::sun::star::uno::Sequence<  ::com::sun::star::mail::MailAttachment >              m_aAttachments;
     264             : public:
     265             :     SwMailMessage();
     266             :     virtual ~SwMailMessage();
     267             : 
     268             :     // attributes
     269             :     virtual OUString SAL_CALL    getSenderName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     270             :     virtual OUString SAL_CALL    getSenderAddress() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     271             :     virtual OUString SAL_CALL    getReplyToAddress() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     272             :     virtual void SAL_CALL               setReplyToAddress( const OUString& _replytoaddress ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     273             :     virtual OUString SAL_CALL    getSubject() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     274             :     virtual void SAL_CALL               setSubject( const OUString& _subject ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     275             : 
     276             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL
     277             :                                         getBody()
     278             :                                                 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     279             :     virtual void SAL_CALL               setBody( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _body )
     280             :                                                 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     281             : 
     282             :     // methods
     283             :     virtual void SAL_CALL               addRecipient( const OUString& sRecipientAddress ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     284             :     virtual void SAL_CALL               addCcRecipient( const OUString& sRecipientAddress ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     285             :     virtual void SAL_CALL               addBccRecipient( const OUString& sRecipientAddress ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     286             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
     287             :                                         getRecipients(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     288             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
     289             :                                         getCcRecipients(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     290             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
     291             :                                         getBccRecipients(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     292             :     virtual void SAL_CALL               addAttachment( const ::com::sun::star::mail::MailAttachment& aMailAttachment )
     293             :                                             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     294             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::mail::MailAttachment > SAL_CALL
     295             :                                         getAttachments(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     296           0 :     void                                SetSenderName(const OUString& rSenderName)
     297           0 :                                                 {m_sSenderName = rSenderName;}
     298           0 :     void                                SetSenderAddress(const OUString& rSenderAddress)
     299           0 :                                                 {m_sSenderAddress = rSenderAddress;}
     300             : };
     301             : 
     302             : #endif
     303             : 
     304             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10