LCOV - code coverage report
Current view: top level - sw/source/ui/inc - mailmergehelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 20 0.0 %
Date: 2012-08-25 Functions: 0 13 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10