1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <vcl/svapp.hxx>
21 #include <vcl/settings.hxx>
22 #include <comphelper/propertyvalue.hxx>
24 #include <tools/urlobj.hxx>
25 #include <svl/urihelper.hxx>
26 #include <unotools/pathoptions.hxx>
29 #include <IDocumentDeviceAccess.hxx>
30 #include <printdata.hxx>
33 #include <swmodule.hxx>
35 #include <mailmergehelper.hxx>
36 #include <mailmrge.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <sfx2/filedlghelper.hxx>
39 #include <comphelper/documentconstants.hxx>
40 #include <comphelper/sequenceashashmap.hxx>
41 #include <com/sun/star/container/XContainerQuery.hpp>
42 #include <com/sun/star/container/XEnumeration.hpp>
43 #include <com/sun/star/form/runtime/XFormController.hpp>
44 #include <com/sun/star/frame/Frame.hpp>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/sdbcx/XRowLocate.hpp>
47 #include <com/sun/star/sdb/XResultSetAccess.hpp>
48 #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
49 #include <com/sun/star/view/XSelectionSupplier.hpp>
50 #include <comphelper/processfactory.hxx>
51 #include <cppuhelper/implbase.hxx>
55 using namespace ::com::sun::star
;
56 using namespace ::com::sun::star::container
;
57 using namespace ::com::sun::star::lang
;
58 using namespace ::com::sun::star::sdb
;
59 using namespace ::com::sun::star::sdbc
;
60 using namespace ::com::sun::star::sdbcx
;
61 using namespace ::com::sun::star::beans
;
62 using namespace ::com::sun::star::util
;
63 using namespace ::com::sun::star::uno
;
64 using namespace ::com::sun::star::frame
;
65 using namespace ::com::sun::star::form
;
66 using namespace ::com::sun::star::view
;
67 using namespace ::com::sun::star::ui::dialogs
;
69 struct SwMailMergeDlg_Impl
{
70 uno::Reference
<runtime::XFormController
> xFController
;
71 uno::Reference
<XSelectionChangeListener
> xChgLstnr
;
72 uno::Reference
<XSelectionSupplier
> xSelSupp
;
75 class SwXSelChgLstnr_Impl
: public cppu::WeakImplHelper
77 view::XSelectionChangeListener
80 SwMailMergeDlg
& m_rParent
;
82 explicit SwXSelChgLstnr_Impl(SwMailMergeDlg
& rParentDlg
);
84 virtual void SAL_CALL
selectionChanged( const EventObject
& aEvent
) override
;
85 virtual void SAL_CALL
disposing( const EventObject
& Source
) override
;
88 SwXSelChgLstnr_Impl::SwXSelChgLstnr_Impl(SwMailMergeDlg
& rParentDlg
) :
92 void SwXSelChgLstnr_Impl::selectionChanged( const EventObject
& )
94 //call the parent to enable selection mode
95 Sequence
<Any
> aSelection
;
96 if(m_rParent
.m_pImpl
->xSelSupp
.is())
97 m_rParent
.m_pImpl
->xSelSupp
->getSelection() >>= aSelection
;
99 bool bEnable
= aSelection
.hasElements();
100 m_rParent
.m_xMarkedRB
->set_sensitive(bEnable
);
102 m_rParent
.m_xMarkedRB
->set_active(true);
103 else if(m_rParent
.m_xMarkedRB
->get_active()) {
104 m_rParent
.m_xAllRB
->set_active(true);
105 m_rParent
.m_aSelection
.realloc(0);
109 void SwXSelChgLstnr_Impl::disposing( const EventObject
& )
111 OSL_FAIL("disposing");
114 SwMailMergeDlg::SwMailMergeDlg(weld::Window
* pParent
, SwWrtShell
& rShell
,
115 const OUString
& rSourceName
,
116 const OUString
& rTableName
,
117 sal_Int32 nCommandType
,
118 const uno::Reference
< XConnection
>& _xConnection
,
119 Sequence
< Any
> const * pSelection
)
120 : SfxDialogController(pParent
, "modules/swriter/ui/mailmerge.ui", "MailmergeDialog")
121 , m_pImpl(new SwMailMergeDlg_Impl
)
123 , m_nMergeType(DBMGR_MERGE_EMAIL
)
124 , m_xBeamerWin(m_xBuilder
->weld_container("beamer"))
125 , m_xAllRB(m_xBuilder
->weld_radio_button("all"))
126 , m_xMarkedRB(m_xBuilder
->weld_radio_button("selected"))
127 , m_xFromRB(m_xBuilder
->weld_radio_button("rbfrom"))
128 , m_xFromNF(m_xBuilder
->weld_spin_button("from"))
129 , m_xToNF(m_xBuilder
->weld_spin_button("to"))
130 , m_xPrinterRB(m_xBuilder
->weld_radio_button("printer"))
131 , m_xMailingRB(m_xBuilder
->weld_radio_button("electronic"))
132 , m_xFileRB(m_xBuilder
->weld_radio_button("file"))
133 , m_xSingleJobsCB(m_xBuilder
->weld_check_button("singlejobs"))
134 , m_xPasswordCB(m_xBuilder
->weld_check_button("passwd-check"))
135 , m_xSaveMergedDocumentFT(m_xBuilder
->weld_label("savemergeddoclabel"))
136 , m_xSaveSingleDocRB(m_xBuilder
->weld_radio_button("singledocument"))
137 , m_xSaveIndividualRB(m_xBuilder
->weld_radio_button("individualdocuments"))
138 , m_xGenerateFromDataBaseCB(m_xBuilder
->weld_check_button("generate"))
139 , m_xColumnFT(m_xBuilder
->weld_label("fieldlabel"))
140 , m_xColumnLB(m_xBuilder
->weld_combo_box("field"))
141 , m_xPasswordFT(m_xBuilder
->weld_label("passwd-label"))
142 , m_xPasswordLB(m_xBuilder
->weld_combo_box("passwd-combobox"))
143 , m_xPathFT(m_xBuilder
->weld_label("pathlabel"))
144 , m_xPathED(m_xBuilder
->weld_entry("path"))
145 , m_xPathPB(m_xBuilder
->weld_button("pathpb"))
146 , m_xFilterFT(m_xBuilder
->weld_label("fileformatlabel"))
147 , m_xFilterLB(m_xBuilder
->weld_combo_box("fileformat"))
148 , m_xAddressFieldLB(m_xBuilder
->weld_combo_box("address"))
149 , m_xSubjectFT(m_xBuilder
->weld_label("subjectlabel"))
150 , m_xSubjectED(m_xBuilder
->weld_entry("subject"))
151 , m_xFormatFT(m_xBuilder
->weld_label("mailformatlabel"))
152 , m_xAttachFT(m_xBuilder
->weld_label("attachmentslabel"))
153 , m_xAttachED(m_xBuilder
->weld_entry("attachments"))
154 , m_xAttachPB(m_xBuilder
->weld_button("attach"))
155 , m_xFormatHtmlCB(m_xBuilder
->weld_check_button("html"))
156 , m_xFormatRtfCB(m_xBuilder
->weld_check_button("rtf"))
157 , m_xFormatSwCB(m_xBuilder
->weld_check_button("swriter"))
158 , m_xOkBTN(m_xBuilder
->weld_button("ok"))
160 m_xSingleJobsCB
->hide(); // not supported in since cws printerpullpages anymore
161 //task #97066# mailing of form letters is currently not supported
162 m_xMailingRB
->hide();
163 m_xSubjectFT
->hide();
164 m_xSubjectED
->hide();
166 m_xFormatSwCB
->hide();
167 m_xFormatHtmlCB
->hide();
168 m_xFormatRtfCB
->hide();
172 m_xPasswordCB
->hide();
173 m_xPasswordFT
->hide();
174 m_xPasswordLB
->hide();
176 uno::Reference
< lang::XMultiServiceFactory
> xMSF
= comphelper::getProcessServiceFactory();
178 m_aSelection
= *pSelection
;
179 m_xBeamerWin
->hide();
182 // create a frame wrapper for myself
183 m_xFrame
= frame::Frame::create( comphelper::getProcessComponentContext() );
184 m_xFrame
->initialize(m_xBeamerWin
->CreateChildFrame());
185 } catch (const Exception
&) {
190 aURL
.Complete
= ".component:DB/DataSourceBrowser";
191 uno::Reference
<XDispatch
> xD
= m_xFrame
->queryDispatch(aURL
,
195 Sequence
<PropertyValue
> aProperties
197 comphelper::makePropertyValue("DataSourceName", rSourceName
),
198 comphelper::makePropertyValue("Command", rTableName
),
199 comphelper::makePropertyValue("CommandType", nCommandType
),
201 xD
->dispatch(aURL
, aProperties
);
202 m_xBeamerWin
->show();
204 uno::Reference
<XController
> xController
= m_xFrame
->getController();
205 m_pImpl
->xFController
.set(xController
, UNO_QUERY
);
206 if(m_pImpl
->xFController
.is()) {
207 uno::Reference
< awt::XControl
> xCtrl
= m_pImpl
->xFController
->getCurrentControl( );
208 m_pImpl
->xSelSupp
.set(xCtrl
, UNO_QUERY
);
209 if(m_pImpl
->xSelSupp
.is()) {
210 m_pImpl
->xChgLstnr
= new SwXSelChgLstnr_Impl(*this);
211 m_pImpl
->xSelSupp
->addSelectionChangeListener( m_pImpl
->xChgLstnr
);
217 m_pModOpt
= SW_MOD()->GetModuleConfig();
219 MailTextFormats
nMailingMode(m_pModOpt
->GetMailingFormats());
220 m_xFormatSwCB
->set_active(bool(nMailingMode
& MailTextFormats::OFFICE
));
221 m_xFormatHtmlCB
->set_active(bool(nMailingMode
& MailTextFormats::HTML
));
222 m_xFormatRtfCB
->set_active(bool(nMailingMode
& MailTextFormats::RTF
));
224 m_xAllRB
->set_active(true);
227 m_xOkBTN
->connect_clicked(LINK(this, SwMailMergeDlg
, ButtonHdl
));
229 m_xPathPB
->connect_clicked(LINK(this, SwMailMergeDlg
, InsertPathHdl
));
231 m_xPrinterRB
->connect_toggled(LINK(this, SwMailMergeDlg
, OutputTypeHdl
));
232 m_xFileRB
->connect_toggled(LINK(this, SwMailMergeDlg
, OutputTypeHdl
));
234 //#i63267# printing might be disabled
235 bool bIsPrintable
= !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
236 m_xPrinterRB
->set_sensitive(bIsPrintable
);
237 OutputTypeHdl(bIsPrintable
? *m_xPrinterRB
: *m_xFileRB
);
239 m_xGenerateFromDataBaseCB
->connect_toggled(LINK(this, SwMailMergeDlg
, FilenameHdl
));
240 bool bColumn
= m_pModOpt
->IsNameFromColumn();
242 m_xGenerateFromDataBaseCB
->set_active(true);
244 FilenameHdl(*m_xGenerateFromDataBaseCB
);
245 m_xSaveSingleDocRB
->set_active(true);
246 m_xSaveSingleDocRB
->connect_toggled(LINK(this, SwMailMergeDlg
, SaveTypeHdl
));
247 m_xSaveIndividualRB
->connect_toggled(LINK(this, SwMailMergeDlg
, SaveTypeHdl
));
248 SaveTypeHdl(*m_xSaveSingleDocRB
);
250 m_xFilterLB
->connect_changed(LINK(this, SwMailMergeDlg
, FileFormatHdl
));
252 Link
<weld::SpinButton
&,void> aLk2
= LINK(this, SwMailMergeDlg
, ModifyHdl
);
253 m_xFromNF
->connect_value_changed(aLk2
);
254 m_xToNF
->connect_value_changed(aLk2
);
255 m_xFromNF
->set_max(SAL_MAX_INT32
);
256 m_xToNF
->set_max(SAL_MAX_INT32
);
258 SwDBManager
* pDBManager
= m_rSh
.GetDBManager();
259 if(_xConnection
.is())
260 SwDBManager::GetColumnNames(*m_xAddressFieldLB
, _xConnection
, rTableName
);
262 pDBManager
->GetColumnNames(*m_xAddressFieldLB
, rSourceName
, rTableName
);
263 for(sal_Int32 nEntry
= 0, nEntryCount
= m_xAddressFieldLB
->get_count(); nEntry
< nEntryCount
; ++nEntry
)
265 m_xColumnLB
->append_text(m_xAddressFieldLB
->get_text(nEntry
));
266 m_xPasswordLB
->append_text(m_xAddressFieldLB
->get_text(nEntry
));
269 m_xAddressFieldLB
->set_active_text("EMAIL");
271 OUString
sPath(m_pModOpt
->GetMailingPath());
272 if(sPath
.isEmpty()) {
273 SvtPathOptions aPathOpt
;
274 sPath
= aPathOpt
.GetWorkPath();
276 INetURLObject
aURL(sPath
);
277 if(aURL
.GetProtocol() == INetProtocol::File
)
278 m_xPathED
->set_text(aURL
.PathToFileName());
280 m_xPathED
->set_text(aURL
.GetFull());
284 m_xColumnLB
->set_active_text("NAME");
285 m_xPasswordLB
->set_active_text("PASSWORD");
289 m_xColumnLB
->set_active_text(m_pModOpt
->GetNameFromColumn());
290 m_xPasswordLB
->set_active_text(m_pModOpt
->GetPasswordFromColumn());
293 if (m_xAddressFieldLB
->get_active() == -1)
294 m_xAddressFieldLB
->set_active(0);
295 if (m_xColumnLB
->get_active() == -1)
296 m_xColumnLB
->set_active(0);
297 if (m_xPasswordLB
->get_active() == -1)
298 m_xPasswordLB
->set_active(0);
300 const bool bEnable
= m_aSelection
.hasElements();
301 m_xMarkedRB
->set_sensitive(bEnable
);
303 m_xMarkedRB
->set_active(true);
305 m_xAllRB
->set_active(true);
306 m_xMarkedRB
->set_sensitive(false);
309 uno::Reference
< container::XNameContainer
> xFilterFactory(
310 xMSF
->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY_THROW
);
311 uno::Reference
< container::XContainerQuery
> xQuery(xFilterFactory
, UNO_QUERY_THROW
);
312 const OUString
sCommand("matchByDocumentService=com.sun.star.text.TextDocument:iflags="
313 + OUString::number(static_cast<sal_Int32
>(SfxFilterFlags::EXPORT
))
315 + OUString::number(static_cast<sal_Int32
>(SfxFilterFlags::NOTINFILEDLG
))
317 uno::Reference
< container::XEnumeration
> xList
= xQuery
->createSubSetEnumerationByQuery(sCommand
);
318 static const OUStringLiteral
sName(u
"Name");
320 while(xList
->hasMoreElements()) {
321 comphelper::SequenceAsHashMap
aFilter(xList
->nextElement());
322 const OUString sFilter
= aFilter
.getUnpackedValueOrDefault(sName
, OUString());
324 uno::Any aProps
= xFilterFactory
->getByName(sFilter
);
325 uno::Sequence
< beans::PropertyValue
> aFilterProperties
;
326 aProps
>>= aFilterProperties
;
328 auto pProp
= std::find_if(std::cbegin(aFilterProperties
), std::cend(aFilterProperties
),
329 [](const beans::PropertyValue
& rProp
) { return rProp
.Name
== "UIName"; });
330 if (pProp
!= std::cend(aFilterProperties
))
331 pProp
->Value
>>= sUIName2
;
332 if( !sUIName2
.isEmpty() ) {
333 if( sFilter
== "writer8" )
334 nODT
= m_xFilterLB
->get_count();
335 m_xFilterLB
->append(sFilter
, sUIName2
);
338 m_xFilterLB
->set_active( nODT
);
339 } catch (const uno::Exception
&) {
343 SwMailMergeDlg::~SwMailMergeDlg()
346 m_xFrame
->setComponent(nullptr, nullptr);
351 IMPL_LINK_NOARG(SwMailMergeDlg
, ButtonHdl
, weld::Button
&, void)
354 m_xDialog
->response(RET_OK
);
357 IMPL_LINK_NOARG(SwMailMergeDlg
, OutputTypeHdl
, weld::Toggleable
&, void)
359 bool bPrint
= m_xPrinterRB
->get_active();
360 m_xSingleJobsCB
->set_sensitive(bPrint
);
362 m_xSaveMergedDocumentFT
->set_sensitive( !bPrint
);
363 m_xSaveSingleDocRB
->set_sensitive( !bPrint
);
364 m_xSaveIndividualRB
->set_sensitive( !bPrint
);
367 SaveTypeHdl( m_xSaveSingleDocRB
->get_active() ? *m_xSaveSingleDocRB
: *m_xSaveIndividualRB
);
369 m_xPathFT
->set_sensitive(false);
370 m_xPathED
->set_sensitive(false);
371 m_xPathPB
->set_sensitive(false);
372 m_xColumnFT
->set_sensitive(false);
373 m_xColumnLB
->set_sensitive(false);
374 m_xFilterFT
->set_sensitive(false);
375 m_xFilterLB
->set_sensitive(false);
376 m_xGenerateFromDataBaseCB
->set_sensitive(false);
377 m_xPasswordCB
->set_sensitive( false );
378 m_xPasswordFT
->set_sensitive( false );
379 m_xPasswordLB
->set_sensitive( false );
383 IMPL_LINK_NOARG(SwMailMergeDlg
, SaveTypeHdl
, weld::Toggleable
&, void)
385 bool bIndividual
= m_xSaveIndividualRB
->get_active();
387 m_xGenerateFromDataBaseCB
->set_sensitive( bIndividual
);
390 FilenameHdl(*m_xGenerateFromDataBaseCB
);
394 m_xColumnFT
->set_sensitive(false);
395 m_xColumnLB
->set_sensitive(false);
396 m_xPathFT
->set_sensitive( false );
397 m_xPathED
->set_sensitive( false );
398 m_xPathPB
->set_sensitive( false );
399 m_xFilterFT
->set_sensitive( false );
400 m_xFilterLB
->set_sensitive( false );
401 m_xPasswordCB
->set_sensitive( false );
402 m_xPasswordFT
->set_sensitive( false );
403 m_xPasswordLB
->set_sensitive( false );
407 IMPL_LINK( SwMailMergeDlg
, FilenameHdl
, weld::Toggleable
&, rBox
, void )
409 bool bEnable
= rBox
.get_active();
410 m_xColumnFT
->set_sensitive( bEnable
);
411 m_xColumnLB
->set_sensitive(bEnable
);
412 m_xPathFT
->set_sensitive( bEnable
);
413 m_xPathED
->set_sensitive(bEnable
);
414 m_xPathPB
->set_sensitive( bEnable
);
415 m_xFilterFT
->set_sensitive( bEnable
);
416 m_xFilterLB
->set_sensitive( bEnable
);
418 if(m_xFilterLB
->get_active_id() == "writer_pdf_Export")
420 m_xPasswordCB
->show();
421 m_xPasswordFT
->show();
422 m_xPasswordLB
->show();
424 m_xPasswordCB
->set_sensitive( bEnable
);
425 m_xPasswordFT
->set_sensitive( bEnable
);
426 m_xPasswordLB
->set_sensitive( bEnable
);
430 IMPL_LINK_NOARG( SwMailMergeDlg
, FileFormatHdl
, weld::ComboBox
&, void )
432 if(m_xFilterLB
->get_active_id() == "writer_pdf_Export")
434 m_xPasswordCB
->show();
435 m_xPasswordFT
->show();
436 m_xPasswordLB
->show();
438 m_xPasswordCB
->set_sensitive( true );
439 m_xPasswordFT
->set_sensitive( true );
440 m_xPasswordLB
->set_sensitive( true );
444 m_xPasswordCB
->hide();
445 m_xPasswordFT
->hide();
446 m_xPasswordLB
->hide();
450 IMPL_LINK_NOARG(SwMailMergeDlg
, ModifyHdl
, weld::SpinButton
&, void)
452 m_xFromRB
->set_active(true);
455 bool SwMailMergeDlg::AskUserFilename() const
457 return (m_xSaveSingleDocRB
->get_active() || !m_xGenerateFromDataBaseCB
->get_active());
460 OUString
SwMailMergeDlg::GetURLfromPath() const
462 SfxMedium
* pMedium
= m_rSh
.GetView().GetDocShell()->GetMedium();
465 aAbs
= pMedium
->GetURLObject();
466 if( INetProtocol::NotValid
== aAbs
.GetProtocol() )
468 SvtPathOptions aPathOpt
;
469 aAbs
.SetURL( aPathOpt
.GetWorkPath() );
471 return URIHelper::SmartRel2Abs(
472 aAbs
, m_xPathED
->get_text(), URIHelper::GetMaybeFileHdl());
475 bool SwMailMergeDlg::ExecQryShell()
477 if(m_pImpl
->xSelSupp
.is()) {
478 m_pImpl
->xSelSupp
->removeSelectionChangeListener( m_pImpl
->xChgLstnr
);
481 if (m_xPrinterRB
->get_active())
482 m_nMergeType
= DBMGR_MERGE_PRINTER
;
484 m_nMergeType
= DBMGR_MERGE_FILE
;
485 m_pModOpt
->SetMailingPath( GetURLfromPath() );
486 m_pModOpt
->SetIsNameFromColumn(m_xGenerateFromDataBaseCB
->get_active());
487 m_pModOpt
->SetIsFileEncryptedFromColumn(m_xPasswordCB
->get_active());
489 if (!AskUserFilename())
491 m_pModOpt
->SetNameFromColumn(m_xColumnLB
->get_active_text());
492 m_pModOpt
->SetPasswordFromColumn(m_xPasswordLB
->get_active_text());
493 if (m_xFilterLB
->get_active() != -1)
494 m_sSaveFilter
= m_xFilterLB
->get_active_id();
495 m_sFilename
= OUString();
497 //#i97667# reset column name - otherwise it's remembered from the last run
498 m_pModOpt
->SetNameFromColumn(OUString());
499 m_pModOpt
->SetPasswordFromColumn(OUString());
500 //start save as dialog
502 m_sFilename
= SwMailMergeHelper::CallSaveAsDialog(m_xDialog
.get(), sFilter
);
503 if (m_sFilename
.isEmpty())
505 m_sSaveFilter
= sFilter
;
509 if (m_xFromRB
->get_active()) { // Insert list
510 // Safe: the maximal value of the fields is limited
511 sal_Int32 nStart
= m_xFromNF
->get_value();
512 sal_Int32 nEnd
= m_xToNF
->get_value();
515 std::swap(nEnd
, nStart
);
517 m_aSelection
.realloc(nEnd
- nStart
+ 1);
518 Any
* pSelection
= m_aSelection
.getArray();
519 for (sal_Int32 i
= nStart
; i
<= nEnd
; ++i
, ++pSelection
)
521 } else if (m_xAllRB
->get_active() )
522 m_aSelection
.realloc(0); // Empty selection = insert all
524 if(m_pImpl
->xSelSupp
.is()) {
526 uno::Reference
< XRowLocate
> xRowLocate(GetResultSet(),UNO_QUERY
);
527 uno::Reference
< XResultSet
> xRes(xRowLocate
,UNO_QUERY
);
528 m_pImpl
->xSelSupp
->getSelection() >>= m_aSelection
;
529 if ( xRowLocate
.is() ) {
530 for (Any
& rRow
: asNonConstRange(m_aSelection
)) {
531 if ( xRowLocate
->moveToBookmark(rRow
) )
532 rRow
<<= xRes
->getRow();
537 IDocumentDeviceAccess
& rIDDA
= m_rSh
.getIDocumentDeviceAccess();
538 SwPrintData
aPrtData( rIDDA
.getPrintData() );
539 aPrtData
.SetPrintSingleJobs(m_xSingleJobsCB
->get_active());
540 rIDDA
.setPrintData(aPrtData
);
542 m_pModOpt
->SetSinglePrintJob(m_xSingleJobsCB
->get_active());
544 MailTextFormats nMailingMode
= MailTextFormats::NONE
;
546 if (m_xFormatSwCB
->get_active())
547 nMailingMode
|= MailTextFormats::OFFICE
;
548 if (m_xFormatHtmlCB
->get_active())
549 nMailingMode
|= MailTextFormats::HTML
;
550 if (m_xFormatRtfCB
->get_active())
551 nMailingMode
|= MailTextFormats::RTF
;
552 m_pModOpt
->SetMailingFormats(nMailingMode
);
556 OUString
SwMailMergeDlg::GetTargetURL() const
558 if( AskUserFilename() )
560 OUString
sPath( m_pModOpt
->GetMailingPath() );
561 if( sPath
.isEmpty() ) {
562 SvtPathOptions aPathOpt
;
563 sPath
= aPathOpt
.GetWorkPath();
565 if( !sPath
.endsWith("/") )
570 IMPL_LINK_NOARG(SwMailMergeDlg
, InsertPathHdl
, weld::Button
&, void)
572 uno::Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
573 uno::Reference
< XFolderPicker2
> xFP
= sfx2::createFolderPicker(xContext
, m_xDialog
.get());
574 xFP
->setDisplayDirectory( GetURLfromPath() );
575 if( xFP
->execute() == RET_OK
) {
576 INetURLObject
aURL(xFP
->getDirectory());
577 if(aURL
.GetProtocol() == INetProtocol::File
)
578 m_xPathED
->set_text(aURL
.PathToFileName());
580 m_xPathED
->set_text(aURL
.GetFull());
584 uno::Reference
<XResultSet
> SwMailMergeDlg::GetResultSet() const
586 uno::Reference
< XResultSet
> xResSetClone
;
587 if ( m_pImpl
->xFController
.is() ) {
588 // we create a clone to do the task
589 uno::Reference
< XResultSetAccess
> xResultSetAccess( m_pImpl
->xFController
->getModel(),UNO_QUERY
);
590 if ( xResultSetAccess
.is() )
591 xResSetClone
= xResultSetAccess
->createResultSet();
596 SwMailMergeCreateFromDlg::SwMailMergeCreateFromDlg(weld::Window
* pParent
)
597 : GenericDialogController(pParent
, "modules/swriter/ui/mailmergedialog.ui", "MailMergeDialog")
598 , m_xThisDocRB(m_xBuilder
->weld_radio_button("document"))
602 SwMailMergeCreateFromDlg::~SwMailMergeCreateFromDlg()
606 SwMailMergeFieldConnectionsDlg::SwMailMergeFieldConnectionsDlg(weld::Window
* pParent
)
607 : GenericDialogController(pParent
, "modules/swriter/ui/mergeconnectdialog.ui", "MergeConnectDialog")
608 , m_xUseExistingRB(m_xBuilder
->weld_radio_button("existing"))
612 SwMailMergeFieldConnectionsDlg::~SwMailMergeFieldConnectionsDlg()
616 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */