nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / uibase / inc / mailmergehelper.hxx
blob3b476a5245bfbeab763472b138bd163d90a0ce7c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_MAILMERGEHELPER_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_MAILMERGEHELPER_HXX
22 #include <com/sun/star/uno/Sequence.h>
23 #include <com/sun/star/mail/XAuthenticator.hpp>
24 #include <com/sun/star/mail/XConnectionListener.hpp>
25 #include <com/sun/star/uno/XCurrentContext.hpp>
26 #include <com/sun/star/mail/XMailMessage.hpp>
27 #include <com/sun/star/datatransfer/XTransferable.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/compbase.hxx>
31 #include <vcl/customweld.hxx>
32 #include <vcl/weld.hxx>
33 #include <rtl/ustring.hxx>
34 #include <swdllapi.h>
36 class SwMailMergeConfigItem;
38 namespace com::sun::star::mail {
39 class XMailService;
40 class XSmtpService;
43 namespace SwMailMergeHelper
45 SW_DLLPUBLIC OUString CallSaveAsDialog(weld::Window* pParent, OUString& rFilter);
46 SW_DLLPUBLIC bool CheckMailAddress(const OUString& rMailAddress);
47 SW_DLLPUBLIC css::uno::Reference<css::mail::XSmtpService> ConnectToSmtpServer(
48 SwMailMergeConfigItem const & rConfigItem,
49 css::uno::Reference<css::mail::XMailService>& xInMailService,
50 const OUString& rInMailServerPassword,
51 const OUString& rOutMailServerPassword,
52 weld::Window* pDialogParentWindow = nullptr);
55 struct SwAddressPreview_Impl;
57 // Preview window used to show the possible selection of address blocks
58 // and also the resulting address filled with database data
59 class SW_DLLPUBLIC SwAddressPreview : public weld::CustomWidgetController
61 std::unique_ptr<SwAddressPreview_Impl> pImpl;
62 std::unique_ptr<weld::ScrolledWindow> m_xVScrollBar;
63 Link<LinkParamNone*,void> m_aSelectHdl;
65 void DrawText_Impl(vcl::RenderContext& rRenderContext, const OUString& rAddress,
66 const Point& rTopLeft, const Size& rSize, bool bIsSelected);
68 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
69 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
70 virtual bool KeyInput( const KeyEvent& rKEvt ) override;
71 void UpdateScrollBar();
73 DECL_LINK(ScrollHdl, weld::ScrolledWindow&,void);
75 public:
76 SwAddressPreview(std::unique_ptr<weld::ScrolledWindow> xParent);
77 virtual ~SwAddressPreview() override;
79 /** The address string is a list of address elements separated by spaces
80 and breaks. The addresses fit into the given layout. If more addresses then
81 rows/columns should be used a scrollbar will be added.
83 AddAddress appends the new address to the already added ones.
84 Initially the first added address will be selected
86 void AddAddress(const OUString& rAddress);
87 // for preview mode - replaces the currently used address by the given one
88 void SetAddress(const OUString& rAddress);
89 // removes all addresses
90 void Clear();
92 // returns the selected address
93 sal_uInt16 GetSelectedAddress() const;
94 void SelectAddress(sal_uInt16 nSelect);
95 void ReplaceSelectedAddress(const OUString&);
96 void RemoveSelectedAddress();
98 // set the number of rows and columns of addresses
99 void SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns);
100 void EnableScrollBar();
102 // fill the actual data into a string (address block or greeting)
103 static OUString FillData(const OUString& rAddress, SwMailMergeConfigItem const & rConfigItem,
104 const css::uno::Sequence<OUString>* pAssignments = nullptr);
106 void SetSelectHdl (const Link<LinkParamNone*,void>& rLink) { m_aSelectHdl = rLink; }
110 // iterate over an address block or a greeting line the iterator returns the
111 // parts either as pure string or as column
112 struct SwMergeAddressItem
114 OUString sText;
115 bool bIsColumn;
116 bool bIsReturn;
118 SwMergeAddressItem()
119 : bIsColumn(false)
120 , bIsReturn(false)
124 class SW_DLLPUBLIC SwAddressIterator
126 OUString sAddress;
127 public:
128 SwAddressIterator(const OUString& rAddress) :
129 sAddress(rAddress)
132 SwMergeAddressItem Next();
133 bool HasMore() const { return !sAddress.isEmpty(); }
136 class SW_DLLPUBLIC SwAuthenticator :
137 public cppu::WeakImplHelper<css::mail::XAuthenticator>
139 OUString m_aUserName;
140 OUString m_aPassword;
141 weld::Window* m_pParentWindow;
142 public:
143 SwAuthenticator()
144 : m_pParentWindow(nullptr)
146 SwAuthenticator(const OUString& username, const OUString& password, weld::Window* pParent)
147 : m_aUserName(username)
148 , m_aPassword(password)
149 , m_pParentWindow(pParent)
151 virtual ~SwAuthenticator() override;
153 virtual OUString SAL_CALL getUserName() override;
154 virtual OUString SAL_CALL getPassword() override;
158 class SW_DLLPUBLIC SwConnectionContext : public cppu::WeakImplHelper<css::uno::XCurrentContext>
160 OUString m_sMailServer;
161 sal_Int16 m_nPort;
162 OUString m_sConnectionType;
164 public:
165 SwConnectionContext(const OUString& rMailServer, sal_Int16 nPort, const OUString& rConnectionType);
166 virtual ~SwConnectionContext() override;
168 virtual css::uno::Any SAL_CALL getValueByName(const OUString& Name) override;
171 class SwMutexBase
173 public:
174 osl::Mutex m_aMutex;
177 class SW_DLLPUBLIC SwConnectionListener :
178 public SwMutexBase,
179 public cppu::WeakComponentImplHelper<css::mail::XConnectionListener>
181 using cppu::WeakComponentImplHelperBase::disposing;
183 public:
184 SwConnectionListener() :
185 cppu::WeakComponentImplHelper<css::mail::XConnectionListener>(m_aMutex)
187 virtual ~SwConnectionListener() override;
189 virtual void SAL_CALL connected(const css::lang::EventObject& aEvent) override;
191 virtual void SAL_CALL disconnected(const css::lang::EventObject& aEvent) override;
193 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
196 class SW_DLLPUBLIC SwMailTransferable :
197 public SwMutexBase,
198 public cppu::WeakComponentImplHelper<css::datatransfer::XTransferable, css::beans::XPropertySet>
200 OUString m_aMimeType;
201 OUString m_sBody;
202 OUString m_aURL;
203 OUString m_aName;
204 bool m_bIsBody;
206 public:
207 SwMailTransferable(const OUString& rURL, const OUString& rName, const OUString& rMimeType);
208 SwMailTransferable(const OUString& rBody, const OUString& rMimeType);
209 virtual ~SwMailTransferable() override;
210 virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& aFlavor) override;
212 virtual css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override;
213 virtual sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& aFlavor) override;
215 //XPropertySet
216 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
217 virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const css::uno::Any& aValue) override;
219 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) override;
220 virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName,
221 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
222 virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName,
223 const css::uno::Reference<css::beans::XPropertyChangeListener >& aListener) override;
224 virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName,
225 const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override;
226 virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,
227 const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override;
231 class SW_DLLPUBLIC SwMailMessage :
232 public SwMutexBase,
233 public cppu::WeakComponentImplHelper<css::mail::XMailMessage>
235 OUString m_sSenderName;
236 OUString m_sSenderAddress;
237 OUString m_sReplyToAddress;
238 OUString m_sSubject;
240 css::uno::Reference<css::datatransfer::XTransferable> m_xBody;
241 // css::mail::MailMessageBody m_aBody;
243 css::uno::Sequence<OUString> m_aRecipients;
244 css::uno::Sequence<OUString> m_aCcRecipients;
245 css::uno::Sequence<OUString> m_aBccRecipients;
246 // css::uno::Sequence<css::mail::MailAttachmentDescriptor> m_aAttachments;
247 css::uno::Sequence<css::mail::MailAttachment> m_aAttachments;
248 public:
249 SwMailMessage();
250 virtual ~SwMailMessage() override;
252 // attributes
253 virtual OUString SAL_CALL getSenderName() override;
254 virtual OUString SAL_CALL getSenderAddress() override;
255 virtual OUString SAL_CALL getReplyToAddress() override;
256 virtual void SAL_CALL setReplyToAddress( const OUString& _replytoaddress ) override;
257 virtual OUString SAL_CALL getSubject() override;
258 virtual void SAL_CALL setSubject(const OUString& _subject) override;
260 virtual css::uno::Reference<css::datatransfer::XTransferable> SAL_CALL getBody() override;
261 virtual void SAL_CALL setBody(const css::uno::Reference<css::datatransfer::XTransferable>& _body) override;
263 // methods
264 virtual void SAL_CALL addRecipient( const OUString& sRecipientAddress ) override;
265 virtual void SAL_CALL addCcRecipient( const OUString& sRecipientAddress ) override;
266 virtual void SAL_CALL addBccRecipient( const OUString& sRecipientAddress ) override;
267 virtual css::uno::Sequence<OUString> SAL_CALL getRecipients() override;
268 virtual css::uno::Sequence<OUString> SAL_CALL getCcRecipients() override;
269 virtual css::uno::Sequence<OUString> SAL_CALL getBccRecipients() override;
270 virtual void SAL_CALL addAttachment(const css::mail::MailAttachment& aMailAttachment) override;
271 virtual css::uno::Sequence<css::mail::MailAttachment> SAL_CALL getAttachments() override;
272 void SetSenderName(const OUString& rSenderName)
274 m_sSenderName = rSenderName;
276 void SetSenderAddress(const OUString& rSenderAddress)
278 m_sSenderAddress = rSenderAddress;
282 #endif
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */