1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mailmergehelper.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _MAILMERGEHELPER_HXX
31 #define _MAILMERGEHELPER_HXX
33 #include <svtools/stdctrl.hxx>
34 #include <unotools/configitem.hxx>
35 #include <com/sun/star/uno/Sequence.h>
36 #include "com/sun/star/mail/XAuthenticator.hpp"
37 #include "com/sun/star/mail/XConnectionListener.hpp"
38 #include "com/sun/star/uno/XCurrentContext.hpp"
39 #include "com/sun/star/mail/XMailMessage.hpp"
40 #include "com/sun/star/datatransfer/XTransferable.hpp"
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <cppuhelper/implbase1.hxx>
43 #include <cppuhelper/compbase1.hxx>
44 #include <cppuhelper/compbase2.hxx>
45 #include <vcl/scrbar.hxx>
49 class SwMailMergeConfigItem
;
50 namespace com
{ namespace sun
{ namespace star
{
52 class XComponentContext
;
55 class XMultiServiceFactory
;
62 /*-- 14.06.2004 12:27:42---------------------------------------------------
64 -----------------------------------------------------------------------*/
65 namespace SwMailMergeHelper
67 SW_DLLPUBLIC String
CallSaveAsDialog(String
& rFilter
);
68 SW_DLLPUBLIC
bool CheckMailAddress( const ::rtl::OUString
& rMailAddress
);
69 SW_DLLPUBLIC
com::sun::star::uno::Reference
< com::sun::star::mail::XSmtpService
>
70 ConnectToSmtpServer( SwMailMergeConfigItem
& rConfigItem
,
71 com::sun::star::uno::Reference
< com::sun::star::mail::XMailService
>& xInMailService
,
72 const String
& rInMailServerPassword
,
73 const String
& rOutMailServerPassword
,
74 Window
* pDialogParentWindow
= 0 );
76 /* -----------------06.04.2004 10:29-----------------
78 --------------------------------------------------*/
79 class SW_DLLPUBLIC SwBoldFixedInfo
: public FixedInfo
82 SwBoldFixedInfo(Window
* pParent
, const ResId
& rResId
);
85 struct SwAddressPreview_Impl
;
86 namespace com
{namespace sun
{namespace star
{
92 /*-- 27.04.2004 13:20:00---------------------------------------------------
93 Preview window used to show the possible selection of address blocks
94 and also the resulting address filled with database data
95 -----------------------------------------------------------------------*/
96 class SW_DLLPUBLIC SwAddressPreview
: public Window
98 ScrollBar aVScrollBar
;
99 SwAddressPreview_Impl
* pImpl
;
102 void DrawText_Impl( const ::rtl::OUString
& rAddress
, const Point
& rTopLeft
, const Size
& rSize
, bool bIsSelected
);
104 virtual void Paint(const Rectangle
&);
105 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
106 virtual void KeyInput( const KeyEvent
& rKEvt
);
107 virtual void StateChanged( StateChangedType nStateChange
);
108 void UpdateScrollBar();
110 DECL_LINK(ScrollHdl
, ScrollBar
*);
113 SwAddressPreview(Window
* pParent
, const ResId rResId
);
116 /** The address string is a list of address elements separated by spaces
117 and breaks. The addresses fit into the given layout. If more addresses then
118 rows/columns should be used a scrollbar will be added.
120 AddAddress appends the new address to the already added ones.
121 Initially the first added address will be selected
123 void AddAddress(const ::rtl::OUString
& rAddress
);
124 // for preview mode - replaces the currently used address by the given one
125 void SetAddress(const ::rtl::OUString
& rAddress
);
126 // removes all addresses
129 // returns the selected address
130 sal_uInt16
GetSelectedAddress() const;
131 void SelectAddress(sal_uInt16 nSelect
);
132 void ReplaceSelectedAddress(const ::rtl::OUString
&);
133 void RemoveSelectedAddress();
135 // set the number of rows and columns of addresses
136 void SetLayout(sal_uInt16 nRows
, sal_uInt16 nColumns
);
137 void EnableScrollBar(bool bEnable
= true);
139 // fill the actual data into a string (address block or greeting)
140 static String
FillData(
141 const ::rtl::OUString
& rAddress
,
142 SwMailMergeConfigItem
& rConfigItem
,
143 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>* pAssignments
= 0);
145 void SetSelectHdl (const Link
& rLink
) {m_aSelectHdl
= rLink
;}
148 /*-- 11.05.2004 15:39:59---------------------------------------------------
149 iterate over an address block or a greeting line
150 the iterator returns the parts either as pure string
152 -----------------------------------------------------------------------*/
153 struct SwMergeAddressItem
158 SwMergeAddressItem() :
162 class SW_DLLPUBLIC SwAddressIterator
166 SwAddressIterator(const String
& rAddress
) :
169 SwMergeAddressItem
Next();
170 bool HasMore() const{return sAddress
.Len() > 0;}
173 /*-- 21.05.2004 10:31:15---------------------------------------------------
175 -----------------------------------------------------------------------*/
176 class SW_DLLPUBLIC SwAuthenticator
:
177 public cppu::WeakImplHelper1
< ::com::sun::star::mail::XAuthenticator
>
179 ::rtl::OUString m_aUserName
;
180 ::rtl::OUString m_aPassword
;
181 Window
* m_pParentWindow
;
183 SwAuthenticator() : m_pParentWindow(0) {}
184 SwAuthenticator(const ::rtl::OUString
& username
, const ::rtl::OUString
& password
, Window
* pParent
) :
185 m_aUserName(username
),
186 m_aPassword(password
),
187 m_pParentWindow( pParent
)
191 virtual ::rtl::OUString SAL_CALL
getUserName( ) throw (::com::sun::star::uno::RuntimeException
);
192 virtual ::rtl::OUString SAL_CALL
getPassword( ) throw (::com::sun::star::uno::RuntimeException
);
195 /*-- 25.08.2004 12:48:47---------------------------------------------------
197 -----------------------------------------------------------------------*/
198 class SW_DLLPUBLIC SwConnectionContext
:
199 public cppu::WeakImplHelper1
< ::com::sun::star::uno::XCurrentContext
>
201 ::rtl::OUString m_sMailServer
;
203 ::rtl::OUString m_sConnectionType
;
206 SwConnectionContext(const ::rtl::OUString
& rMailServer
, sal_Int16 nPort
, const ::rtl::OUString
& rConnectionType
);
207 ~SwConnectionContext();
209 virtual ::com::sun::star::uno::Any SAL_CALL
getValueByName( const ::rtl::OUString
& Name
)
210 throw (::com::sun::star::uno::RuntimeException
);
212 /*-- 21.05.2004 10:39:20---------------------------------------------------
214 -----------------------------------------------------------------------*/
220 /*-- 21.05.2004 10:39:20---------------------------------------------------
222 -----------------------------------------------------------------------*/
223 class SW_DLLPUBLIC SwConnectionListener
:
225 public cppu::WeakComponentImplHelper1
< ::com::sun::star::mail::XConnectionListener
>
227 using cppu::WeakComponentImplHelperBase::disposing
;
230 SwConnectionListener() :
231 cppu::WeakComponentImplHelper1
< ::com::sun::star::mail::XConnectionListener
>(m_aMutex
)
233 ~SwConnectionListener();
235 virtual void SAL_CALL
connected(const ::com::sun::star::lang::EventObject
& aEvent
)
236 throw (::com::sun::star::uno::RuntimeException
);
238 virtual void SAL_CALL
disconnected(const ::com::sun::star::lang::EventObject
& aEvent
)
239 throw (::com::sun::star::uno::RuntimeException
);
241 virtual void SAL_CALL
disposing(const com::sun::star::lang::EventObject
& aEvent
)
242 throw(com::sun::star::uno::RuntimeException
);
245 /*-- 13.07.2004 09:02:12---------------------------------------------------
247 -----------------------------------------------------------------------*/
248 class SwMailTransferable
:
250 public cppu::WeakComponentImplHelper2
252 ::com::sun::star::datatransfer::XTransferable
,
253 ::com::sun::star::beans::XPropertySet
256 rtl::OUString m_aMimeType
;
257 rtl::OUString m_sBody
;
258 rtl::OUString m_aURL
;
259 rtl::OUString m_aName
;
263 SwMailTransferable(const rtl::OUString
& rURL
, const rtl::OUString
& rName
, const rtl::OUString
& rMimeType
);
264 SwMailTransferable(const rtl::OUString
& rBody
, const rtl::OUString
& rMimeType
);
265 ~SwMailTransferable();
266 virtual ::com::sun::star::uno::Any SAL_CALL
267 getTransferData( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
)
268 throw (::com::sun::star::datatransfer::UnsupportedFlavorException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
269 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::datatransfer::DataFlavor
> SAL_CALL
270 getTransferDataFlavors( )
271 throw (::com::sun::star::uno::RuntimeException
) ;
272 virtual ::sal_Bool SAL_CALL
273 isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
)
274 throw (::com::sun::star::uno::RuntimeException
);
277 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
278 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
);
279 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
);
280 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
);
281 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
);
282 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
);
283 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
);
287 /*-- 22.06.2004 16:38:34---------------------------------------------------
289 -----------------------------------------------------------------------*/
290 class SwMailMessage
:
292 public cppu::WeakComponentImplHelper1
< ::com::sun::star::mail::XMailMessage
>
294 ::rtl::OUString m_sSenderName
;
295 ::rtl::OUString m_sSenderAddress
;
296 ::rtl::OUString m_sReplyToAddress
;
297 ::rtl::OUString m_sSubject
;
299 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> m_xBody
;
300 // ::com::sun::star::mail::MailMessageBody m_aBody;
302 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> m_aRecipients
;
303 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> m_aCcRecipients
;
304 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> m_aBccRecipients
;
305 // ::com::sun::star::uno::Sequence< ::com::sun::star::mail::MailAttachmentDescriptor > m_aAttachments;
306 ::com::sun::star::uno::Sequence
< ::com::sun::star::mail::MailAttachment
> m_aAttachments
;
312 virtual ::rtl::OUString SAL_CALL
getSenderName() throw (::com::sun::star::uno::RuntimeException
);
313 virtual ::rtl::OUString SAL_CALL
getSenderAddress() throw (::com::sun::star::uno::RuntimeException
);
314 virtual ::rtl::OUString SAL_CALL
getReplyToAddress() throw (::com::sun::star::uno::RuntimeException
);
315 virtual void SAL_CALL
setReplyToAddress( const ::rtl::OUString
& _replytoaddress
) throw (::com::sun::star::uno::RuntimeException
);
316 virtual ::rtl::OUString SAL_CALL
getSubject() throw (::com::sun::star::uno::RuntimeException
);
317 virtual void SAL_CALL
setSubject( const ::rtl::OUString
& _subject
) throw (::com::sun::star::uno::RuntimeException
);
319 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> SAL_CALL
321 throw (::com::sun::star::uno::RuntimeException
);
322 virtual void SAL_CALL
setBody( const ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
>& _body
)
323 throw (::com::sun::star::uno::RuntimeException
);
326 virtual void SAL_CALL
addRecipient( const ::rtl::OUString
& sRecipientAddress
) throw (::com::sun::star::uno::RuntimeException
);
327 virtual void SAL_CALL
addCcRecipient( const ::rtl::OUString
& sRecipientAddress
) throw (::com::sun::star::uno::RuntimeException
);
328 virtual void SAL_CALL
addBccRecipient( const ::rtl::OUString
& sRecipientAddress
) throw (::com::sun::star::uno::RuntimeException
);
329 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
330 getRecipients( ) throw (::com::sun::star::uno::RuntimeException
);
331 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
332 getCcRecipients( ) throw (::com::sun::star::uno::RuntimeException
);
333 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
334 getBccRecipients( ) throw (::com::sun::star::uno::RuntimeException
);
335 virtual void SAL_CALL
addAttachment( const ::com::sun::star::mail::MailAttachment
& aMailAttachment
)
336 throw (::com::sun::star::uno::RuntimeException
);
337 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::mail::MailAttachment
> SAL_CALL
338 getAttachments( ) throw (::com::sun::star::uno::RuntimeException
);
339 void SetSenderName(const ::rtl::OUString
& rSenderName
)
340 {m_sSenderName
= rSenderName
;}
341 void SetSenderAddress(const ::rtl::OUString
& rSenderAddress
)
342 {m_sSenderAddress
= rSenderAddress
;}
344 /*-- 21.05.2004 10:17:22---------------------------------------------------
346 -----------------------------------------------------------------------*/
347 SW_DLLPUBLIC ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>
349 ::com::sun::star::uno::Reference
<
350 ::com::sun::star::lang::XMultiServiceFactory
> rSrvMgr
);