LibreOffice Module sw (master) 1
mailmergehelper.cxx
Go to the documentation of this file.
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
20#include <swtypes.hxx>
21#include <mailmergehelper.hxx>
22#include <mmconfigitem.hxx>
23#include <docsh.hxx>
25#include <sfx2/docfile.hxx>
26#include <com/sun/star/sdbc/SQLException.hpp>
27#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
28#include <com/sun/star/sdb/XColumn.hpp>
29#include <com/sun/star/beans/XPropertySet.hpp>
30#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
31#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
32#include <com/sun/star/mail/MailServiceProvider.hpp>
33#include <com/sun/star/mail/XSmtpService.hpp>
35#include <o3tl/safeint.hxx>
36#include <utility>
37#include <vcl/event.hxx>
38#include <vcl/settings.hxx>
39#include <vcl/weldutils.hxx>
41#include <o3tl/string_view.hxx>
42
43#include <sfx2/passwd.hxx>
44
45#include <dbui.hrc>
46#include <strings.hrc>
47
48using namespace ::com::sun::star;
49using namespace ::com::sun::star::uno;
50using namespace ::com::sun::star::container;
51using namespace ::com::sun::star::sdb;
52using namespace ::com::sun::star::sdbc;
53using namespace ::com::sun::star::sdbcx;
54
56{
57
58OUString CallSaveAsDialog(weld::Window* pParent, OUString& rFilter)
59{
60 ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
61 FileDialogFlags::NONE,
62 SwDocShell::Factory().GetFactoryName(), SfxFilterFlags::NONE, SfxFilterFlags::NONE, pParent);
64
65 if (aDialog.Execute()!=ERRCODE_NONE)
66 {
67 return OUString();
68 }
69
70 rFilter = aDialog.GetRealFilter();
71 uno::Reference < ui::dialogs::XFilePicker3 > xFP = aDialog.GetFilePicker();
72 return xFP->getSelectedFiles().getConstArray()[0];
73}
74
75/*
76 simple address check: check for '@'
77 for at least one '.' after the '@',
78 for at least one character before the dot
79 and for at least two characters after the dot
80*/
81bool CheckMailAddress( std::u16string_view aMailAddress )
82{
83 const size_t nPosAt = aMailAddress.find('@');
84 if (nPosAt == std::u16string_view::npos || aMailAddress.rfind('@')!=nPosAt)
85 return false;
86 const size_t nPosDot = aMailAddress.find('.', nPosAt);
87 return !(nPosDot==std::u16string_view::npos || nPosDot-nPosAt<2 || aMailAddress.size()-nPosDot<3);
88}
89
90uno::Reference< mail::XSmtpService > ConnectToSmtpServer(
91 SwMailMergeConfigItem const & rConfigItem,
92 uno::Reference< mail::XMailService >& rxInMailService,
93 const OUString& rInMailServerPassword,
94 const OUString& rOutMailServerPassword,
95 weld::Window* pDialogParentWindow )
96{
97 uno::Reference< mail::XSmtpService > xSmtpServer;
98 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
99 try
100 {
101 uno::Reference< mail::XMailServiceProvider > xMailServiceProvider(
102 mail::MailServiceProvider::create( xContext ) );
103 xSmtpServer.set(xMailServiceProvider->create(mail::MailServiceType_SMTP), uno::UNO_QUERY);
104
105 uno::Reference< mail::XConnectionListener> xConnectionListener(new SwConnectionListener);
106
107 if(rConfigItem.IsAuthentication() && rConfigItem.IsSMTPAfterPOP())
108 {
109 uno::Reference< mail::XMailService > xInMailService =
110 xMailServiceProvider->create(
111 rConfigItem.IsInServerPOP() ?
112 mail::MailServiceType_POP3 : mail::MailServiceType_IMAP);
113 //authenticate at the POP or IMAP server first
114 OUString sPasswd = rConfigItem.GetInServerPassword();
115 if(!rInMailServerPassword.isEmpty())
116 sPasswd = rInMailServerPassword;
117 uno::Reference<mail::XAuthenticator> xAuthenticator =
118 new SwAuthenticator(
119 rConfigItem.GetInServerUserName(),
120 sPasswd,
121 pDialogParentWindow);
122
123 xInMailService->addConnectionListener(xConnectionListener);
124 //check connection
125 uno::Reference< uno::XCurrentContext> xConnectionContext =
127 rConfigItem.GetInServerName(),
128 rConfigItem.GetInServerPort(),
129 "Insecure");
130 xInMailService->connect(xConnectionContext, xAuthenticator);
131 rxInMailService = xInMailService;
132 }
133 uno::Reference< mail::XAuthenticator> xAuthenticator;
134 if(rConfigItem.IsAuthentication() &&
135 !rConfigItem.IsSMTPAfterPOP() &&
136 !rConfigItem.GetMailUserName().isEmpty())
137 {
138 OUString sPasswd = rConfigItem.GetMailPassword();
139 if(!rOutMailServerPassword.isEmpty())
140 sPasswd = rOutMailServerPassword;
141 xAuthenticator =
142 new SwAuthenticator(rConfigItem.GetMailUserName(),
143 sPasswd,
144 pDialogParentWindow);
145 }
146 else
147 xAuthenticator = new SwAuthenticator();
148 //just to check if the server exists
149 xSmtpServer->getSupportedConnectionTypes();
150 //check connection
151
152 uno::Reference< uno::XCurrentContext> xConnectionContext =
154 rConfigItem.GetMailServer(),
155 rConfigItem.GetMailPort(),
156 rConfigItem.IsSecureConnection() ? OUString("Ssl") : OUString("Insecure") );
157 xSmtpServer->connect(xConnectionContext, xAuthenticator);
158 rxInMailService = xSmtpServer;
159 }
160 catch (const uno::Exception&)
161 {
162 TOOLS_WARN_EXCEPTION( "sw", "");
163 }
164 return xSmtpServer;
165}
166
167} //namespace
168
170{
171 std::vector< OUString > aAddresses;
172 sal_uInt16 nRows;
173 sal_uInt16 nColumns;
176
178 nRows(1),
179 nColumns(1),
181 bEnableScrollBar(false)
182 {
183 }
184};
185
187 const OUString& rAddress,
188 SwMailMergeConfigItem const & rConfigItem,
189 const Sequence< OUString>* pAssignments)
190{
191 //find the column names in the address string (with name assignment!) and
192 //exchange the placeholder (like <Firstname>) with the database content
193 //unassigned columns are expanded to <not assigned>
194 Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), UNO_QUERY);
195 Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
196 Sequence< OUString> aAssignment = pAssignments ?
197 *pAssignments :
198 rConfigItem.GetColumnAssignment(
199 rConfigItem.GetCurrentDBData() );
200 const OUString* pAssignment = aAssignment.getConstArray();
201 const std::vector<std::pair<OUString, int>>& rDefHeaders = rConfigItem.GetDefaultAddressHeaders();
202 OUString sNotAssigned = "<" + SwResId(STR_NOTASSIGNED) + ">";
203
204 bool bIncludeCountry = rConfigItem.IsIncludeCountry();
205 const OUString rExcludeCountry = rConfigItem.GetExcludeCountry();
206 bool bSpecialReplacementForCountry = (!bIncludeCountry || !rExcludeCountry.isEmpty());
207 OUString sCountryColumn;
208 if( bSpecialReplacementForCountry )
209 {
210 sCountryColumn = rDefHeaders[MM_PART_COUNTRY].first;
211 Sequence< OUString> aSpecialAssignment =
212 rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
213 if(aSpecialAssignment.getLength() > MM_PART_COUNTRY && aSpecialAssignment[MM_PART_COUNTRY].getLength())
214 sCountryColumn = aSpecialAssignment[MM_PART_COUNTRY];
215 }
216
217 SwAddressIterator aIter(rAddress);
218 OUStringBuffer sAddress;
219 while(aIter.HasMore())
220 {
221 SwMergeAddressItem aItem = aIter.Next();
222 if(aItem.bIsColumn)
223 {
224 //get the default column name
225
226 //find the appropriate assignment
227 OUString sConvertedColumn = aItem.sText;
228 auto nSize = std::min(sal_uInt32(rDefHeaders.size()), sal_uInt32(aAssignment.getLength()));
229 for(sal_uInt32 nColumn = 0; nColumn < nSize; ++nColumn)
230 {
231 if (rDefHeaders[nColumn].first == aItem.sText &&
232 !pAssignment[nColumn].isEmpty())
233 {
234 sConvertedColumn = pAssignment[nColumn];
235 break;
236 }
237 }
238 if(!sConvertedColumn.isEmpty() &&
239 xColAccess.is() &&
240 xColAccess->hasByName(sConvertedColumn))
241 {
242 //get the content and exchange it in the address string
243 Any aCol = xColAccess->getByName(sConvertedColumn);
244 Reference< XColumn > xColumn;
245 aCol >>= xColumn;
246 if(xColumn.is())
247 {
248 try
249 {
250 OUString sReplace = xColumn->getString();
251
252 if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn )
253 {
254 if( !rExcludeCountry.isEmpty() && sReplace != rExcludeCountry )
255 aItem.sText = sReplace;
256 else
257 aItem.sText.clear();
258 }
259 else
260 {
261 aItem.sText = sReplace;
262 }
263 }
264 catch (const sdbc::SQLException&)
265 {
266 TOOLS_WARN_EXCEPTION( "sw", "");
267 }
268 }
269 }
270 else
271 {
272 aItem.sText = sNotAssigned;
273 }
274
275 }
276 sAddress.append(aItem.sText);
277 }
278 return sAddress.makeStringAndClear();
279}
280
281SwAddressPreview::SwAddressPreview(std::unique_ptr<weld::ScrolledWindow> xWindow)
283 , m_xVScrollBar(std::move(xWindow))
284{
285 m_xVScrollBar->connect_vadjustment_changed(LINK(this, SwAddressPreview, ScrollHdl));
286}
287
289{
290}
291
293{
294 Invalidate();
295}
296
297void SwAddressPreview::AddAddress(const OUString& rAddress)
298{
299 m_pImpl->aAddresses.push_back(rAddress);
301}
302
303void SwAddressPreview::SetAddress(const OUString& rAddress)
304{
305 m_pImpl->aAddresses.clear();
306 m_pImpl->aAddresses.push_back(rAddress);
307 m_xVScrollBar->set_vpolicy(VclPolicyType::NEVER);
308 Invalidate();
309}
310
312{
313 OSL_ENSURE(m_pImpl->nSelectedAddress < m_pImpl->aAddresses.size(), "selection invalid");
314 return m_pImpl->nSelectedAddress;
315}
316
317void SwAddressPreview::SelectAddress(sal_uInt16 nSelect)
318{
319 OSL_ENSURE(m_pImpl->nSelectedAddress < m_pImpl->aAddresses.size(), "selection invalid");
320 m_pImpl->nSelectedAddress = nSelect;
321 // now make it visible...
322 sal_uInt16 nSelectRow = nSelect / m_pImpl->nColumns;
323 sal_uInt16 nStartRow = m_xVScrollBar->vadjustment_get_value();
324 if( (nSelectRow < nStartRow) || (nSelectRow >= (nStartRow + m_pImpl->nRows) ))
325 m_xVScrollBar->vadjustment_set_value(nSelectRow);
326}
327
329{
330 m_pImpl->aAddresses.clear();
331 m_pImpl->nSelectedAddress = 0;
333}
334
336{
337 m_pImpl->aAddresses[m_pImpl->nSelectedAddress] = rNew;
338 Invalidate();
339}
340
342{
343 m_pImpl->aAddresses.erase(m_pImpl->aAddresses.begin() + m_pImpl->nSelectedAddress);
344 if(m_pImpl->nSelectedAddress)
345 --m_pImpl->nSelectedAddress;
347 Invalidate();
348}
349
350void SwAddressPreview::SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns)
351{
352 m_pImpl->nRows = nRows;
353 m_pImpl->nColumns = nColumns;
355}
356
358{
359 m_pImpl->bEnableScrollBar = true;
360}
361
363{
364 if (m_pImpl->nColumns)
365 {
366 sal_uInt16 nResultingRows = o3tl::narrowing<sal_uInt16>(m_pImpl->aAddresses.size() + m_pImpl->nColumns - 1) / m_pImpl->nColumns;
367 ++nResultingRows;
368 auto nValue = m_xVScrollBar->vadjustment_get_value();
369 if (nValue > nResultingRows)
370 nValue = nResultingRows;
371 m_xVScrollBar->set_vpolicy(m_pImpl->bEnableScrollBar && nResultingRows > m_pImpl->nRows ? VclPolicyType::ALWAYS : VclPolicyType::NEVER);
372 m_xVScrollBar->vadjustment_configure(nValue, 0, nResultingRows, 1, 10, m_pImpl->nRows);
373 }
374}
375
377{
378 const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
379 rRenderContext.SetFillColor(rSettings.GetWindowColor());
380 rRenderContext.SetLineColor(COL_TRANSPARENT);
381 rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), GetOutputSizePixel()));
382 Color aPaintColor(IsEnabled() ? rSettings.GetWindowTextColor() : rSettings.GetDisableColor());
383 rRenderContext.SetLineColor(aPaintColor);
384
385 weld::SetPointFont(rRenderContext, GetDrawingArea()->get_font());
386 vcl::Font aFont(rRenderContext.GetFont());
387 aFont.SetColor(aPaintColor);
388 rRenderContext.SetFont(aFont);
389
390 Size aSize(GetOutputSizePixel());
391 sal_uInt16 nStartRow = 0;
392 if (m_xVScrollBar->get_vpolicy() != VclPolicyType::NEVER)
393 {
394 aSize.AdjustWidth(-m_xVScrollBar->get_scroll_thickness());
395 nStartRow = m_xVScrollBar->vadjustment_get_value();
396 }
397 Size aPartSize(aSize.Width() / m_pImpl->nColumns,
398 aSize.Height() / m_pImpl->nRows);
399 aPartSize.AdjustWidth( -2 );
400 aPartSize.AdjustHeight( -2 );
401
402 sal_uInt16 nAddress = nStartRow * m_pImpl->nColumns;
403 const sal_uInt16 nNumAddresses = o3tl::narrowing<sal_uInt16>(m_pImpl->aAddresses.size());
404 for (sal_uInt16 nRow = 0; nRow < m_pImpl->nRows ; ++nRow)
405 {
406 for (sal_uInt16 nCol = 0; nCol < m_pImpl->nColumns; ++nCol)
407 {
408 if (nAddress >= nNumAddresses)
409 break;
410 Point aPos(nCol * aPartSize.Width(),
411 nRow * aPartSize.Height());
412 aPos.Move(1, 1);
413 bool bIsSelected = nAddress == m_pImpl->nSelectedAddress;
414 if ((m_pImpl->nColumns * m_pImpl->nRows) == 1)
415 bIsSelected = false;
416 OUString adr(m_pImpl->aAddresses[nAddress]);
417 DrawText_Impl(rRenderContext, adr, aPos, aPartSize, bIsSelected);
418 ++nAddress;
419 }
420 }
421 rRenderContext.SetClipRegion();
422}
423
425{
426 if (rMEvt.IsLeft() && m_pImpl->nRows && m_pImpl->nColumns)
427 {
428 //determine the selected address
429 const Point& rMousePos = rMEvt.GetPosPixel();
430 Size aSize(GetOutputSizePixel());
431 Size aPartSize( aSize.Width()/m_pImpl->nColumns, aSize.Height()/m_pImpl->nRows );
432 sal_uInt32 nRow = rMousePos.Y() / aPartSize.Height() ;
433 if (m_xVScrollBar->get_vpolicy() != VclPolicyType::NEVER)
434 {
435 nRow += m_xVScrollBar->vadjustment_get_value();
436 }
437 sal_uInt32 nCol = rMousePos.X() / aPartSize.Width();
438 sal_uInt32 nSelect = nRow * m_pImpl->nColumns + nCol;
439
440 if( nSelect < m_pImpl->aAddresses.size() &&
441 m_pImpl->nSelectedAddress != o3tl::narrowing<sal_uInt16>(nSelect))
442 {
443 m_pImpl->nSelectedAddress = o3tl::narrowing<sal_uInt16>(nSelect);
444 m_aSelectHdl.Call(nullptr);
445 }
446 Invalidate();
447 }
448 return true;
449}
450
452{
453 sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
454 bool bHandled = false;
455 if (m_pImpl->nRows && m_pImpl->nColumns)
456 {
457 sal_uInt32 nSelectedRow = m_pImpl->nSelectedAddress / m_pImpl->nColumns;
458 sal_uInt32 nSelectedColumn = m_pImpl->nSelectedAddress - (nSelectedRow * m_pImpl->nColumns);
459 switch(nKey)
460 {
461 case KEY_UP:
462 if(nSelectedRow)
463 --nSelectedRow;
464 bHandled = true;
465 break;
466 case KEY_DOWN:
467 if(m_pImpl->aAddresses.size() > o3tl::make_unsigned(m_pImpl->nSelectedAddress + m_pImpl->nColumns))
468 ++nSelectedRow;
469 bHandled = true;
470 break;
471 case KEY_LEFT:
472 if(nSelectedColumn)
473 --nSelectedColumn;
474 bHandled = true;
475 break;
476 case KEY_RIGHT:
477 if(nSelectedColumn < o3tl::make_unsigned(m_pImpl->nColumns - 1) &&
478 m_pImpl->aAddresses.size() - 1 > m_pImpl->nSelectedAddress )
479 ++nSelectedColumn;
480 bHandled = true;
481 break;
482 }
483 sal_uInt32 nSelect = nSelectedRow * m_pImpl->nColumns + nSelectedColumn;
484 if( nSelect < m_pImpl->aAddresses.size() &&
485 m_pImpl->nSelectedAddress != o3tl::narrowing<sal_uInt16>(nSelect))
486 {
487 m_pImpl->nSelectedAddress = o3tl::narrowing<sal_uInt16>(nSelect);
488 m_aSelectHdl.Call(nullptr);
489 Invalidate();
490 }
491 }
492 return bHandled;
493}
494
495void SwAddressPreview::DrawText_Impl(vcl::RenderContext& rRenderContext, std::u16string_view rAddress,
496 const Point& rTopLeft, const Size& rSize, bool bIsSelected)
497{
498 rRenderContext.SetClipRegion(vcl::Region(tools::Rectangle(rTopLeft, rSize)));
499 if (bIsSelected)
500 {
501 //selection rectangle
502 rRenderContext.SetFillColor(COL_TRANSPARENT);
503 rRenderContext.DrawRect(tools::Rectangle(rTopLeft, rSize));
504 }
505 sal_Int32 nHeight = GetTextHeight();
506 Point aStart = rTopLeft;
507 //put it away from the border
508 aStart.Move(2, 2);
509 sal_Int32 nPos = 0;
510 do
511 {
512 rRenderContext.DrawText(aStart, OUString(o3tl::getToken(rAddress, 0, '\n', nPos)));
513 aStart.AdjustY(nHeight );
514 }
515 while (nPos >= 0);
516}
517
519{
520 //currently the string may either start with a '<' then it's a column
521 //otherwise it's simple text maybe containing a return
523 if(!m_sAddress.isEmpty())
524 {
525 if(m_sAddress[0] == '<')
526 {
527 aRet.bIsColumn = true;
528 sal_Int32 nClose = m_sAddress.indexOf('>');
529 OSL_ENSURE(nClose != -1, "closing '>' not found");
530 if( nClose != -1 )
531 {
532 aRet.sText = m_sAddress.copy(1, nClose - 1);
533 m_sAddress = m_sAddress.copy(nClose + 1);
534 }
535 else
536 {
537 aRet.sText = m_sAddress.copy(1, 1);
538 m_sAddress = m_sAddress.copy(1);
539 }
540 }
541 else
542 {
543 sal_Int32 nOpen = m_sAddress.indexOf('<');
544 sal_Int32 nReturn = m_sAddress.indexOf('\n');
545 if(nReturn == 0)
546 {
547 aRet.bIsReturn = true;
548 aRet.sText = "\n";
549 m_sAddress = m_sAddress.copy(1);
550 }
551 else if(-1 == nOpen && -1 == nReturn)
552 {
553 aRet.sText = m_sAddress;
554 m_sAddress.clear();
555 }
556 else
557 {
558 if (nOpen == -1)
559 nOpen = m_sAddress.getLength();
560 if (nReturn == -1)
561 nReturn = m_sAddress.getLength();
562 sal_Int32 nTarget = std::min(nOpen, nReturn);
563 aRet.sText = m_sAddress.copy(0, nTarget);
564 m_sAddress = m_sAddress.copy(nTarget);
565 }
566 }
567 }
568 return aRet;
569
570}
571
573{
574}
575
577{
578 return m_aUserName;
579}
580
582{
583 if(!m_aUserName.isEmpty() && m_aPassword.isEmpty() && m_pParentWindow)
584 {
586 aPasswdDlg.SetMinLen(0);
587 if (RET_OK == aPasswdDlg.run())
588 m_aPassword = aPasswdDlg.GetPassword();
589 }
590 return m_aPassword;
591}
592
594 OUString aMailServer, sal_Int16 nPort,
595 OUString aConnectionType) :
596 m_sMailServer(std::move(aMailServer)),
597 m_nPort(nPort),
598 m_sConnectionType(std::move(aConnectionType))
599{
600}
601
603{
604}
605
607{
608 uno::Any aRet;
609 if( rName == "ServerName" )
610 aRet <<= m_sMailServer;
611 else if( rName == "Port" )
612 aRet <<= static_cast<sal_Int32>(m_nPort);
613 else if( rName == "ConnectionType" )
614 aRet <<= m_sConnectionType;
615 return aRet;
616}
617
619{
620}
621
622void SwConnectionListener::connected(const lang::EventObject& /*aEvent*/)
623{
624}
625
626void SwConnectionListener::disconnected(const lang::EventObject& /*aEvent*/)
627{
628}
629
630void SwConnectionListener::disposing(const lang::EventObject& /*aEvent*/)
631{
632}
633
634SwMailTransferable::SwMailTransferable(OUString aBody, OUString aMimeType) :
635 m_aMimeType(std::move( aMimeType )),
636 m_sBody(std::move( aBody )),
637 m_bIsBody( true )
638{
639}
640
642 OUString aName, OUString aMimeType) :
643 m_aMimeType(std::move( aMimeType )),
644 m_aURL(std::move(aURL)),
645 m_aName(std::move( aName )),
646 m_bIsBody( false )
647{
648}
649
651{
652}
653
654uno::Any SwMailTransferable::getTransferData( const datatransfer::DataFlavor& /*aFlavor*/ )
655{
656 uno::Any aRet;
657 if( m_bIsBody )
658 aRet <<= m_sBody;
659 else
660 {
661 Sequence<sal_Int8> aData;
662 SfxMedium aMedium( m_aURL, StreamMode::STD_READ );
663 SvStream* pStream = aMedium.GetInStream();
664 if ( aMedium.GetErrorCode() == ERRCODE_NONE && pStream)
665 {
666 aData.realloc(pStream->TellEnd());
667 pStream->Seek(0);
668 sal_Int8 * pData = aData.getArray();
669 pStream->ReadBytes( pData, aData.getLength() );
670 }
671 aRet <<= aData;
672 }
673 return aRet;
674}
675
676uno::Sequence< datatransfer::DataFlavor > SwMailTransferable::getTransferDataFlavors( )
677{
678 datatransfer::DataFlavor aRet;
679 aRet.MimeType = m_aMimeType;
680 if( m_bIsBody )
681 {
682 aRet.DataType = cppu::UnoType<OUString>::get();
683 }
684 else
685 {
686 aRet.HumanPresentableName = m_aName;
688 }
689 return { aRet };
690}
691
693 const datatransfer::DataFlavor& aFlavor )
694{
695 return (aFlavor.MimeType == m_aMimeType);
696}
697
698uno::Reference< beans::XPropertySetInfo > SwMailTransferable::getPropertySetInfo( )
699{
700 return uno::Reference< beans::XPropertySetInfo >();
701}
702
703void SwMailTransferable::setPropertyValue( const OUString& , const uno::Any& )
704{
705}
706
707uno::Any SwMailTransferable::getPropertyValue( const OUString& rPropertyName )
708{
709 uno::Any aRet;
710 if ( rPropertyName == "URL" )
711 aRet <<= m_aURL;
712 return aRet;
713}
714
716 const OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
717{
718}
719
721 const OUString&,
722 const uno::Reference< beans::XPropertyChangeListener >& )
723{
724}
725
727 const OUString&,
728 const uno::Reference< beans::XVetoableChangeListener >& )
729{
730}
731
733 const OUString& ,
734 const uno::Reference< beans::XVetoableChangeListener >& )
735{
736}
737
739{
740}
741
743{
744}
745
747{
748 return m_sSenderName;
749}
750
752{
753 return m_sSenderAddress;
754}
755
757{
758 return m_sReplyToAddress;
759}
760
761void SwMailMessage::setReplyToAddress( const OUString& _replytoaddress )
762{
763 m_sReplyToAddress = _replytoaddress;
764}
765
767{
768 return m_sSubject;
769}
770
771void SwMailMessage::setSubject( const OUString& _subject )
772{
773 m_sSubject = _subject;
774}
775
776uno::Reference< datatransfer::XTransferable > SwMailMessage::getBody()
777{
778 return m_xBody;
779}
780
782 const uno::Reference< datatransfer::XTransferable >& rBody )
783{
784 m_xBody = rBody;
785}
786
787void SwMailMessage::addRecipient( const OUString& rRecipientAddress )
788{
789 m_aRecipients.realloc(m_aRecipients.getLength() + 1);
790 m_aRecipients.getArray()[m_aRecipients.getLength() - 1] = rRecipientAddress;
791}
792
793void SwMailMessage::addCcRecipient( const OUString& rRecipientAddress )
794{
795 m_aCcRecipients.realloc(m_aCcRecipients.getLength() + 1);
796 m_aCcRecipients.getArray()[m_aCcRecipients.getLength() - 1] = rRecipientAddress;
797
798}
799
800void SwMailMessage::addBccRecipient( const OUString& rRecipientAddress )
801{
802 m_aBccRecipients.realloc(m_aBccRecipients.getLength() + 1);
803 m_aBccRecipients.getArray()[m_aBccRecipients.getLength() - 1] = rRecipientAddress;
804}
805
806uno::Sequence< OUString > SwMailMessage::getRecipients( )
807{
808 return m_aRecipients;
809}
810
811uno::Sequence< OUString > SwMailMessage::getCcRecipients( )
812{
813 return m_aCcRecipients;
814}
815
816uno::Sequence< OUString > SwMailMessage::getBccRecipients( )
817{
818 return m_aBccRecipients;
819}
820
821void SwMailMessage::addAttachment( const mail::MailAttachment& rMailAttachment )
822{
823 m_aAttachments.realloc(m_aAttachments.getLength() + 1);
824 m_aAttachments.getArray()[m_aAttachments.getLength() - 1] = rMailAttachment;
825}
826
827uno::Sequence< mail::MailAttachment > SwMailMessage::getAttachments( )
828{
829 return m_aAttachments;
830}
831
832/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
OString m_aMimeType
css::util::URL m_aURL
const StyleSettings & GetStyleSettings() const
const vcl::KeyCode & GetKeyCode() const
const Point & GetPosPixel() const
bool IsLeft() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetClipRegion()
void SetFillColor()
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const AllSettings & GetSettings() const
constexpr tools::Long Y() const
void Move(tools::Long nHorzMove, tools::Long nVertMove)
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
ErrCode GetErrorCode() const
SvStream * GetInStream()
OUString GetPassword() const
virtual short run() override
void SetMinLen(sal_uInt16 Len)
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
const Color & GetWindowColor() const
const Color & GetWindowTextColor() const
const Color & GetDisableColor() const
virtual sal_uInt64 TellEnd()
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
SwMergeAddressItem Next()
virtual bool KeyInput(const KeyEvent &rKEvt) override
void AddAddress(const OUString &rAddress)
The address string is a list of address elements separated by spaces and breaks.
static OUString FillData(const OUString &rAddress, SwMailMergeConfigItem const &rConfigItem, const css::uno::Sequence< OUString > *pAssignments=nullptr)
std::unique_ptr< SwAddressPreview_Impl > m_pImpl
Link< LinkParamNone *, void > m_aSelectHdl
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
std::unique_ptr< weld::ScrolledWindow > m_xVScrollBar
void DrawText_Impl(vcl::RenderContext &rRenderContext, std::u16string_view rAddress, const Point &rTopLeft, const Size &rSize, bool bIsSelected)
virtual ~SwAddressPreview() override
void SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
void SetAddress(const OUString &rAddress)
void SelectAddress(sal_uInt16 nSelect)
sal_uInt16 GetSelectedAddress() const
SwAddressPreview(std::unique_ptr< weld::ScrolledWindow > xParent)
void ReplaceSelectedAddress(const OUString &)
virtual OUString SAL_CALL getUserName() override
virtual ~SwAuthenticator() override
virtual OUString SAL_CALL getPassword() override
weld::Window * m_pParentWindow
virtual ~SwConnectionContext() override
virtual css::uno::Any SAL_CALL getValueByName(const OUString &Name) override
SwConnectionContext(OUString aMailServer, sal_Int16 nPort, OUString aConnectionType)
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL disconnected(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL connected(const css::lang::EventObject &aEvent) override
virtual ~SwConnectionListener() override
const SwDBData & GetCurrentDBData() const
OUString const & GetInServerUserName() const
bool IsAuthentication() const
OUString const & GetInServerName() const
OUString const & GetMailServer() const
OUString const & GetMailUserName() const
bool IsIncludeCountry() const
bool IsSecureConnection() const
sal_Int16 GetInServerPort() const
OUString & GetExcludeCountry() const
sal_Int16 GetMailPort() const
bool IsSMTPAfterPOP() const
const std::vector< std::pair< OUString, int > > & GetDefaultAddressHeaders() const
OUString const & GetInServerPassword() const
bool IsInServerPOP() const
OUString const & GetMailPassword() const
css::uno::Sequence< OUString > GetColumnAssignment(const SwDBData &rDBData) const
css::uno::Reference< css::sdbc::XResultSet > const & GetResultSet() const
virtual void SAL_CALL addBccRecipient(const OUString &sRecipientAddress) override
virtual void SAL_CALL setReplyToAddress(const OUString &_replytoaddress) override
virtual css::uno::Sequence< css::mail::MailAttachment > SAL_CALL getAttachments() override
OUString m_sSenderAddress
virtual OUString SAL_CALL getSenderAddress() override
OUString m_sSenderName
virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getBody() override
css::uno::Sequence< OUString > m_aRecipients
virtual void SAL_CALL setBody(const css::uno::Reference< css::datatransfer::XTransferable > &_body) override
virtual void SAL_CALL addAttachment(const css::mail::MailAttachment &aMailAttachment) override
css::uno::Reference< css::datatransfer::XTransferable > m_xBody
virtual css::uno::Sequence< OUString > SAL_CALL getCcRecipients() override
virtual ~SwMailMessage() override
virtual void SAL_CALL setSubject(const OUString &_subject) override
css::uno::Sequence< OUString > m_aBccRecipients
virtual void SAL_CALL addRecipient(const OUString &sRecipientAddress) override
virtual css::uno::Sequence< OUString > SAL_CALL getRecipients() override
css::uno::Sequence< css::mail::MailAttachment > m_aAttachments
virtual void SAL_CALL addCcRecipient(const OUString &sRecipientAddress) override
virtual OUString SAL_CALL getSubject() override
css::uno::Sequence< OUString > m_aCcRecipients
virtual OUString SAL_CALL getReplyToAddress() override
OUString m_sReplyToAddress
virtual css::uno::Sequence< OUString > SAL_CALL getBccRecipients() override
virtual OUString SAL_CALL getSenderName() override
virtual ~SwMailTransferable() override
virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &aFlavor) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &aFlavor) override
SwMailTransferable(OUString aURL, OUString aName, OUString aMimeType)
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
css::uno::Type const & get()
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
OUString GetRealFilter() const
void SetContext(Context _eNewContext)
void SetColor(const Color &)
sal_uInt16 GetCode() const
weld::DrawingArea * GetDrawingArea() const
Size const & GetOutputSizePixel() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
#define ERRCODE_NONE
sal_Int16 nValue
Reference< XColumn > xColumn
OUString aName
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
sal_uInt16 nPos
IMPL_LINK_NOARG(SwAddressPreview, ScrollHdl, weld::ScrolledWindow &, void)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
uno::Reference< mail::XSmtpService > ConnectToSmtpServer(SwMailMergeConfigItem const &rConfigItem, uno::Reference< mail::XMailService > &rxInMailService, const OUString &rInMailServerPassword, const OUString &rOutMailServerPassword, weld::Window *pDialogParentWindow)
OUString CallSaveAsDialog(weld::Window *pParent, OUString &rFilter)
bool CheckMailAddress(std::u16string_view aMailAddress)
constexpr OUStringLiteral first
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
OUString m_aName
const sal_Unicode *const aMimeType[]
std::vector< OUString > aAddresses
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
unsigned char sal_Bool
signed char sal_Int8
RET_OK