LibreOffice Module sw (master)  1
mailmrge.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 <vcl/svapp.hxx>
21 #include <vcl/settings.hxx>
22 
23 #include <tools/urlobj.hxx>
24 #include <svl/urihelper.hxx>
25 #include <unotools/pathoptions.hxx>
26 #include <view.hxx>
27 #include <docsh.hxx>
29 #include <printdata.hxx>
30 #include <wrtsh.hxx>
31 #include <dbmgr.hxx>
32 #include <swmodule.hxx>
33 #include <modcfg.hxx>
34 #include <mailmergehelper.hxx>
35 #include <mailmrge.hxx>
36 #include <sfx2/docfile.hxx>
39 #include <com/sun/star/container/XContainerQuery.hpp>
40 #include <com/sun/star/container/XEnumeration.hpp>
41 #include <com/sun/star/form/runtime/XFormController.hpp>
42 #include <com/sun/star/frame/Frame.hpp>
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #include <com/sun/star/sdbcx/XRowLocate.hpp>
45 #include <com/sun/star/sdb/XResultSetAccess.hpp>
46 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
47 #include <com/sun/star/view/XSelectionSupplier.hpp>
49 #include <cppuhelper/implbase.hxx>
50 
51 #include <algorithm>
52 
53 using namespace ::com::sun::star;
54 using namespace ::com::sun::star::container;
55 using namespace ::com::sun::star::lang;
56 using namespace ::com::sun::star::sdb;
57 using namespace ::com::sun::star::sdbc;
58 using namespace ::com::sun::star::sdbcx;
59 using namespace ::com::sun::star::beans;
60 using namespace ::com::sun::star::util;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::frame;
63 using namespace ::com::sun::star::form;
64 using namespace ::com::sun::star::view;
65 using namespace ::com::sun::star::ui::dialogs;
66 
68  uno::Reference<runtime::XFormController> xFController;
69  uno::Reference<XSelectionChangeListener> xChgLstnr;
70  uno::Reference<XSelectionSupplier> xSelSupp;
71 };
72 
73 class SwXSelChgLstnr_Impl : public cppu::WeakImplHelper
74  <
75  view::XSelectionChangeListener
76  >
77 {
79 public:
80  explicit SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg);
81 
82  virtual void SAL_CALL selectionChanged( const EventObject& aEvent ) override;
83  virtual void SAL_CALL disposing( const EventObject& Source ) override;
84 };
85 
87  rParent(rParentDlg)
88 {}
89 
90 void SwXSelChgLstnr_Impl::selectionChanged( const EventObject& )
91 {
92  //call the parent to enable selection mode
93  Sequence <Any> aSelection;
94  if(rParent.pImpl->xSelSupp.is())
95  rParent.pImpl->xSelSupp->getSelection() >>= aSelection;
96 
97  bool bEnable = aSelection.hasElements();
98  rParent.m_xMarkedRB->set_sensitive(bEnable);
99  if(bEnable)
100  rParent.m_xMarkedRB->set_active(true);
101  else if(rParent.m_xMarkedRB->get_active()) {
102  rParent.m_xAllRB->set_active(true);
103  rParent.m_aSelection.realloc(0);
104  }
105 }
106 
107 void SwXSelChgLstnr_Impl::disposing( const EventObject& )
108 {
109  OSL_FAIL("disposing");
110 }
111 
113  const OUString& rSourceName,
114  const OUString& rTableName,
115  sal_Int32 nCommandType,
116  const uno::Reference< XConnection>& _xConnection,
117  Sequence< Any > const * pSelection)
118  : SfxDialogController(pParent, "modules/swriter/ui/mailmerge.ui", "MailmergeDialog")
119  , pImpl(new SwMailMergeDlg_Impl)
120  , rSh(rShell)
121  , nMergeType(DBMGR_MERGE_EMAIL)
122  , m_xBeamerWin(m_xBuilder->weld_container("beamer"))
123  , m_xAllRB(m_xBuilder->weld_radio_button("all"))
124  , m_xMarkedRB(m_xBuilder->weld_radio_button("selected"))
125  , m_xFromRB(m_xBuilder->weld_radio_button("rbfrom"))
126  , m_xFromNF(m_xBuilder->weld_spin_button("from"))
127  , m_xToNF(m_xBuilder->weld_spin_button("to"))
128  , m_xPrinterRB(m_xBuilder->weld_radio_button("printer"))
129  , m_xMailingRB(m_xBuilder->weld_radio_button("electronic"))
130  , m_xFileRB(m_xBuilder->weld_radio_button("file"))
131  , m_xSingleJobsCB(m_xBuilder->weld_check_button("singlejobs"))
132  , m_xPasswordCB(m_xBuilder->weld_check_button("passwd-check"))
133  , m_xSaveMergedDocumentFT(m_xBuilder->weld_label("savemergeddoclabel"))
134  , m_xSaveSingleDocRB(m_xBuilder->weld_radio_button("singledocument"))
135  , m_xSaveIndividualRB(m_xBuilder->weld_radio_button("individualdocuments"))
136  , m_xGenerateFromDataBaseCB(m_xBuilder->weld_check_button("generate"))
137  , m_xColumnFT(m_xBuilder->weld_label("fieldlabel"))
138  , m_xColumnLB(m_xBuilder->weld_combo_box("field"))
139  , m_xPasswordFT(m_xBuilder->weld_label("passwd-label"))
140  , m_xPasswordLB(m_xBuilder->weld_combo_box("passwd-combobox"))
141  , m_xPathFT(m_xBuilder->weld_label("pathlabel"))
142  , m_xPathED(m_xBuilder->weld_entry("path"))
143  , m_xPathPB(m_xBuilder->weld_button("pathpb"))
144  , m_xFilterFT(m_xBuilder->weld_label("fileformatlabel"))
145  , m_xFilterLB(m_xBuilder->weld_combo_box("fileformat"))
146  , m_xAddressFieldLB(m_xBuilder->weld_combo_box("address"))
147  , m_xSubjectFT(m_xBuilder->weld_label("subjectlabel"))
148  , m_xSubjectED(m_xBuilder->weld_entry("subject"))
149  , m_xFormatFT(m_xBuilder->weld_label("mailformatlabel"))
150  , m_xAttachFT(m_xBuilder->weld_label("attachmentslabel"))
151  , m_xAttachED(m_xBuilder->weld_entry("attachments"))
152  , m_xAttachPB(m_xBuilder->weld_button("attach"))
153  , m_xFormatHtmlCB(m_xBuilder->weld_check_button("html"))
154  , m_xFormatRtfCB(m_xBuilder->weld_check_button("rtf"))
155  , m_xFormatSwCB(m_xBuilder->weld_check_button("swriter"))
156  , m_xOkBTN(m_xBuilder->weld_button("ok"))
157 {
158  m_xSingleJobsCB->hide(); // not supported in since cws printerpullpages anymore
159  //task #97066# mailing of form letters is currently not supported
160  m_xMailingRB->hide();
161  m_xSubjectFT->hide();
162  m_xSubjectED->hide();
163  m_xFormatFT->hide();
164  m_xFormatSwCB->hide();
165  m_xFormatHtmlCB->hide();
166  m_xFormatRtfCB->hide();
167  m_xAttachFT->hide();
168  m_xAttachED->hide();
169  m_xAttachPB->hide();
170  m_xPasswordCB->hide();
171  m_xPasswordFT->hide();
172  m_xPasswordLB->hide();
173 
174  uno::Reference< lang::XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
175  if(pSelection) {
176  m_aSelection = *pSelection;
177  m_xBeamerWin->hide();
178  } else {
179  try {
180  // create a frame wrapper for myself
181  m_xFrame = frame::Frame::create( comphelper::getProcessComponentContext() );
182  m_xFrame->initialize(m_xBeamerWin->CreateChildFrame());
183  } catch (const Exception&) {
184  m_xFrame.clear();
185  }
186  if(m_xFrame.is()) {
187  URL aURL;
188  aURL.Complete = ".component:DB/DataSourceBrowser";
189  uno::Reference<XDispatch> xD = m_xFrame->queryDispatch(aURL,
190  "",
191  0x0C);
192  if(xD.is()) {
193  Sequence<PropertyValue> aProperties(3);
194  PropertyValue* pProperties = aProperties.getArray();
195  pProperties[0].Name = "DataSourceName";
196  pProperties[0].Value <<= rSourceName;
197  pProperties[1].Name = "Command";
198  pProperties[1].Value <<= rTableName;
199  pProperties[2].Name = "CommandType";
200  pProperties[2].Value <<= nCommandType;
201  xD->dispatch(aURL, aProperties);
202  m_xBeamerWin->show();
203  }
204  uno::Reference<XController> xController = m_xFrame->getController();
205  pImpl->xFController.set(xController, UNO_QUERY);
206  if(pImpl->xFController.is()) {
207  uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl( );
208  pImpl->xSelSupp.set(xCtrl, UNO_QUERY);
209  if(pImpl->xSelSupp.is()) {
210  pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this);
211  pImpl->xSelSupp->addSelectionChangeListener( pImpl->xChgLstnr );
212  }
213  }
214  }
215  }
216 
217  pModOpt = SW_MOD()->GetModuleConfig();
218 
219  MailTextFormats nMailingMode(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));
223 
224  m_xAllRB->set_active(true);
225 
226  // Install handlers
227  m_xOkBTN->connect_clicked(LINK(this, SwMailMergeDlg, ButtonHdl));
228 
229  m_xPathPB->connect_clicked(LINK(this, SwMailMergeDlg, InsertPathHdl));
230 
231  m_xPrinterRB->connect_toggled(LINK(this, SwMailMergeDlg, OutputTypeHdl));
232  m_xFileRB->connect_toggled(LINK(this, SwMailMergeDlg, OutputTypeHdl));
233 
234  //#i63267# printing might be disabled
236  m_xPrinterRB->set_sensitive(bIsPrintable);
237  OutputTypeHdl(bIsPrintable ? *m_xPrinterRB : *m_xFileRB);
238 
239  m_xGenerateFromDataBaseCB->connect_toggled(LINK(this, SwMailMergeDlg, FilenameHdl));
240  bool bColumn = pModOpt->IsNameFromColumn();
241  if(bColumn)
242  m_xGenerateFromDataBaseCB->set_active(true);
243 
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);
249 
250  m_xFilterLB->connect_changed(LINK(this, SwMailMergeDlg, FileFormatHdl));
251 
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);
257 
258  SwDBManager* pDBManager = rSh.GetDBManager();
259  if(_xConnection.is())
260  SwDBManager::GetColumnNames(*m_xAddressFieldLB, _xConnection, rTableName);
261  else
262  pDBManager->GetColumnNames(*m_xAddressFieldLB, rSourceName, rTableName);
263  for(sal_Int32 nEntry = 0, nEntryCount = m_xAddressFieldLB->get_count(); nEntry < nEntryCount; ++nEntry)
264  {
265  m_xColumnLB->append_text(m_xAddressFieldLB->get_text(nEntry));
266  m_xPasswordLB->append_text(m_xAddressFieldLB->get_text(nEntry));
267  }
268 
269  m_xAddressFieldLB->set_active_text("EMAIL");
270 
271  OUString sPath(pModOpt->GetMailingPath());
272  if(sPath.isEmpty()) {
273  SvtPathOptions aPathOpt;
274  sPath = aPathOpt.GetWorkPath();
275  }
276  INetURLObject aURL(sPath);
277  if(aURL.GetProtocol() == INetProtocol::File)
278  m_xPathED->set_text(aURL.PathToFileName());
279  else
280  m_xPathED->set_text(aURL.GetFull());
281 
282  if (!bColumn )
283  {
284  m_xColumnLB->set_active_text("NAME");
285  m_xPasswordLB->set_active_text("PASSWORD");
286  }
287  else
288  {
289  m_xColumnLB->set_active_text(pModOpt->GetNameFromColumn());
290  m_xPasswordLB->set_active_text(pModOpt->GetPasswordFromColumn());
291  }
292 
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);
299 
300  const bool bEnable = m_aSelection.hasElements();
301  m_xMarkedRB->set_sensitive(bEnable);
302  if (bEnable)
303  m_xMarkedRB->set_active(true);
304  else {
305  m_xAllRB->set_active(true);
306  m_xMarkedRB->set_sensitive(false);
307  }
308  try {
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))
314  + ":eflags="
315  + OUString::number(static_cast<sal_Int32>(SfxFilterFlags::NOTINFILEDLG))
316  + ":default_first");
317  uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
318  const OUString sName("Name");
319  sal_Int32 nODT = -1;
320  while(xList->hasMoreElements()) {
321  comphelper::SequenceAsHashMap aFilter(xList->nextElement());
322  const OUString sFilter = aFilter.getUnpackedValueOrDefault(sName, OUString());
323 
324  uno::Any aProps = xFilterFactory->getByName(sFilter);
325  uno::Sequence< beans::PropertyValue > aFilterProperties;
326  aProps >>= aFilterProperties;
327  OUString sUIName2;
328  auto pProp = std::find_if(aFilterProperties.begin(), aFilterProperties.end(),
329  [](const beans::PropertyValue& rProp) { return rProp.Name == "UIName"; });
330  if (pProp != aFilterProperties.end())
331  pProp->Value >>= sUIName2;
332  if( !sUIName2.isEmpty() ) {
333  if( sFilter == "writer8" )
334  nODT = m_xFilterLB->get_count();
335  m_xFilterLB->append(sFilter, sUIName2);
336  }
337  }
338  m_xFilterLB->set_active( nODT );
339  } catch (const uno::Exception&) {
340  }
341 }
342 
344 {
345  if(m_xFrame.is()) {
346  m_xFrame->setComponent(nullptr, nullptr);
347  m_xFrame->dispose();
348  }
349 }
350 
352 {
353  if (ExecQryShell())
354  m_xDialog->response(RET_OK);
355 }
356 
358 {
359  bool bPrint = m_xPrinterRB->get_active();
360  m_xSingleJobsCB->set_sensitive(bPrint);
361 
362  m_xSaveMergedDocumentFT->set_sensitive( !bPrint );
363  m_xSaveSingleDocRB->set_sensitive( !bPrint );
364  m_xSaveIndividualRB->set_sensitive( !bPrint );
365 
366  if( !bPrint ) {
367  SaveTypeHdl( m_xSaveSingleDocRB->get_active() ? *m_xSaveSingleDocRB : *m_xSaveIndividualRB );
368  } else {
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 );
380  }
381 }
382 
384 {
385  bool bIndividual = m_xSaveIndividualRB->get_active();
386 
387  m_xGenerateFromDataBaseCB->set_sensitive( bIndividual );
388  if( bIndividual )
389  {
390  FilenameHdl(*m_xGenerateFromDataBaseCB);
391  }
392  else
393  {
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 );
404  }
405 }
406 
407 IMPL_LINK( SwMailMergeDlg, FilenameHdl, weld::ToggleButton&, rBox, void )
408 {
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 );
417 
418  if(m_xFilterLB->get_active_id() == "writer_pdf_Export")
419  {
420  m_xPasswordCB->show();
421  m_xPasswordFT->show();
422  m_xPasswordLB->show();
423 
424  m_xPasswordCB->set_sensitive( bEnable );
425  m_xPasswordFT->set_sensitive( bEnable );
426  m_xPasswordLB->set_sensitive( bEnable );
427  }
428 }
429 
431 {
432  if(m_xFilterLB->get_active_id() == "writer_pdf_Export")
433  {
434  m_xPasswordCB->show();
435  m_xPasswordFT->show();
436  m_xPasswordLB->show();
437 
438  m_xPasswordCB->set_sensitive( true );
439  m_xPasswordFT->set_sensitive( true );
440  m_xPasswordLB->set_sensitive( true );
441  }
442  else
443  {
444  m_xPasswordCB->hide();
445  m_xPasswordFT->hide();
446  m_xPasswordLB->hide();
447  }
448 }
449 
451 {
452  m_xFromRB->set_active(true);
453 }
454 
456 {
457  return (m_xSaveSingleDocRB->get_active() || !m_xGenerateFromDataBaseCB->get_active());
458 }
459 
461 {
462  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
463  INetURLObject aAbs;
464  if( pMedium )
465  aAbs = pMedium->GetURLObject();
466  if( INetProtocol::NotValid == aAbs.GetProtocol() )
467  {
468  SvtPathOptions aPathOpt;
469  aAbs.SetURL( aPathOpt.GetWorkPath() );
470  }
472  aAbs, m_xPathED->get_text(), URIHelper::GetMaybeFileHdl());
473 }
474 
476 {
477  if(pImpl->xSelSupp.is()) {
478  pImpl->xSelSupp->removeSelectionChangeListener( pImpl->xChgLstnr );
479  }
480 
481  if (m_xPrinterRB->get_active())
483  else {
488 
489  if (!AskUserFilename())
490  {
491  pModOpt->SetNameFromColumn(m_xColumnLB->get_active_text());
492  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();
496  } else {
497  //#i97667# reset column name - otherwise it's remembered from the last run
498  pModOpt->SetNameFromColumn(OUString());
499  pModOpt->SetPasswordFromColumn(OUString());
500  //start save as dialog
501  OUString sFilter;
503  if (m_sFilename.isEmpty())
504  return false;
505  m_sSaveFilter = sFilter;
506  }
507  }
508 
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();
513 
514  if (nEnd < nStart)
515  std::swap(nEnd, nStart);
516 
517  m_aSelection.realloc(nEnd - nStart + 1);
518  Any* pSelection = m_aSelection.getArray();
519  for (sal_Int32 i = nStart; i <= nEnd; ++i, ++pSelection)
520  *pSelection <<= i;
521  } else if (m_xAllRB->get_active() )
522  m_aSelection.realloc(0); // Empty selection = insert all
523  else {
524  if(pImpl->xSelSupp.is()) {
525  //update selection
526  uno::Reference< XRowLocate > xRowLocate(GetResultSet(),UNO_QUERY);
527  uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY);
528  pImpl->xSelSupp->getSelection() >>= m_aSelection;
529  if ( xRowLocate.is() ) {
530  for (Any& rRow : m_aSelection) {
531  if ( xRowLocate->moveToBookmark(rRow) )
532  rRow <<= xRes->getRow();
533  }
534  }
535  }
536  }
538  SwPrintData aPrtData( rIDDA.getPrintData() );
539  aPrtData.SetPrintSingleJobs(m_xSingleJobsCB->get_active());
540  rIDDA.setPrintData(aPrtData);
541 
542  pModOpt->SetSinglePrintJob(m_xSingleJobsCB->get_active());
543 
544  MailTextFormats nMailingMode = MailTextFormats::NONE;
545 
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  pModOpt->SetMailingFormats(nMailingMode);
553  return true;
554 }
555 
557 {
558  if( AskUserFilename() )
559  return m_sFilename;
560  OUString sPath( pModOpt->GetMailingPath() );
561  if( sPath.isEmpty() ) {
562  SvtPathOptions aPathOpt;
563  sPath = aPathOpt.GetWorkPath();
564  }
565  if( !sPath.endsWith("/") )
566  sPath += "/";
567  return sPath;
568 }
569 
571 {
572  uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
573  uno::Reference < XFolderPicker2 > xFP = FolderPicker::create(xContext);
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());
579  else
580  m_xPathED->set_text(aURL.GetFull());
581  }
582 }
583 
584 uno::Reference<XResultSet> SwMailMergeDlg::GetResultSet() const
585 {
586  uno::Reference< XResultSet > xResSetClone;
587  if ( pImpl->xFController.is() ) {
588  // we create a clone to do the task
589  uno::Reference< XResultSetAccess > xResultSetAccess( pImpl->xFController->getModel(),UNO_QUERY);
590  if ( xResultSetAccess.is() )
591  xResSetClone = xResultSetAccess->createResultSet();
592  }
593  return xResSetClone;
594 }
595 
597  : GenericDialogController(pParent, "modules/swriter/ui/mailmergedialog.ui", "MailMergeDialog")
598  , m_xThisDocRB(m_xBuilder->weld_radio_button("document"))
599 {
600 }
601 
603 {
604 }
605 
607  : GenericDialogController(pParent, "modules/swriter/ui/mergeconnectdialog.ui", "MergeConnectDialog")
608  , m_xUseExistingRB(m_xBuilder->weld_radio_button("existing"))
609 {
610 }
611 
613 {
614 }
615 
616 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
URL aURL
virtual void SAL_CALL disposing(const EventObject &Source) override
Definition: mailmrge.cxx:107
SwMailMergeCreateFromDlg(weld::Window *pParent)
Definition: mailmrge.cxx:596
std::unique_ptr< weld::Label > m_xSubjectFT
Definition: mailmrge.hxx:92
std::unique_ptr< weld::Container > m_xBeamerWin
Definition: mailmrge.hxx:60
std::unique_ptr< weld::Entry > m_xSubjectED
Definition: mailmrge.hxx:93
std::unique_ptr< weld::CheckButton > m_xPasswordCB
Definition: mailmrge.hxx:73
std::unique_ptr< weld::ComboBox > m_xFilterLB
Definition: mailmrge.hxx:89
std::unique_ptr< weld::SpinButton > m_xToNF
Definition: mailmrge.hxx:66
css::uno::Sequence< css::uno::Any > m_aSelection
Definition: mailmrge.hxx:54
std::unique_ptr< weld::RadioButton > m_xMarkedRB
Definition: mailmrge.hxx:63
std::unique_ptr< weld::Label > m_xFormatFT
Definition: mailmrge.hxx:94
css::uno::Reference< css::sdbc::XResultSet > GetResultSet() const
Definition: mailmrge.cxx:584
std::unique_ptr< weld::CheckButton > m_xSingleJobsCB
Definition: mailmrge.hxx:72
static const AllSettings & GetSettings()
std::unique_ptr< SwMailMergeDlg_Impl > pImpl
Definition: mailmrge.hxx:48
std::unique_ptr< weld::CheckButton > m_xFormatRtfCB
Definition: mailmrge.hxx:99
friend class SwXSelChgLstnr_Impl
Definition: mailmrge.hxx:46
bool AskUserFilename() const
Definition: mailmrge.cxx:455
std::unique_ptr< weld::Entry > m_xPathED
Definition: mailmrge.hxx:86
uno::Reference< XSelectionChangeListener > xChgLstnr
Definition: mailmrge.cxx:69
std::unique_ptr< weld::Entry > m_xAttachED
Definition: mailmrge.hxx:96
OUString PathToFileName() const
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
const SwView & GetView() const
Definition: wrtsh.hxx:428
Reference< XController > xController
PropertiesInfo aProperties
std::unique_ptr< weld::RadioButton > m_xSaveSingleDocRB
Definition: mailmrge.hxx:76
Print mail merge.
Definition: dbmgr.hxx:89
virtual void SAL_CALL selectionChanged(const EventObject &aEvent) override
Definition: mailmrge.cxx:90
std::unique_ptr< weld::Button > m_xOkBTN
Definition: mailmrge.hxx:102
Send mail merge as email.
Definition: dbmgr.hxx:90
virtual ~SwMailMergeCreateFromDlg() override
Definition: mailmrge.cxx:602
IMPL_LINK_NOARG(SwMailMergeDlg, ButtonHdl, weld::Button &, void)
Definition: mailmrge.cxx:351
std::unique_ptr< weld::CheckButton > m_xFormatHtmlCB
Definition: mailmrge.hxx:98
std::unique_ptr< weld::RadioButton > m_xMailingRB
Definition: mailmrge.hxx:69
const OUString & GetMailingPath() const
Definition: modcfg.hxx:355
std::unique_ptr< weld::RadioButton > m_xAllRB
Definition: mailmrge.hxx:62
SwModuleOptions * pModOpt
Definition: mailmrge.hxx:51
const char * sName
uno::Reference< XSelectionSupplier > xSelSupp
Definition: mailmrge.cxx:70
css::uno::Reference< css::frame::XFrame2 > m_xFrame
Definition: mailmrge.hxx:55
std::unique_ptr< weld::ComboBox > m_xAddressFieldLB
Definition: mailmrge.hxx:91
void SetNameFromColumn(const OUString &rSet)
Definition: modcfg.hxx:341
void SetMailingPath(const OUString &sPath)
Definition: modcfg.hxx:356
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:331
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2664
virtual ~SwMailMergeFieldConnectionsDlg() override
Definition: mailmrge.cxx:612
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
SwMailMergeDlg & rParent
Definition: mailmrge.cxx:78
OUString CallSaveAsDialog(weld::Window *pParent, OUString &rFilter)
#define SW_MOD()
Definition: swmodule.hxx:255
#define SAL_MAX_INT32
MailTextFormats GetMailingFormats() const
Definition: modcfg.hxx:324
std::unique_ptr< weld::ComboBox > m_xColumnLB
Definition: mailmrge.hxx:82
int i
virtual const SwPrintData & getPrintData() const =0
Returns the PrintData.
SwWrtShell & rSh
Definition: mailmrge.hxx:50
void SetMailingFormats(MailTextFormats nSet)
Definition: modcfg.hxx:325
OUString GetURLfromPath() const
Definition: mailmrge.cxx:460
void SetIsFileEncryptedFromColumn(bool bSet)
Definition: modcfg.hxx:345
virtual ~SwMailMergeDlg() override
Definition: mailmrge.cxx:343
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
std::unique_ptr< weld::RadioButton > m_xFromRB
Definition: mailmrge.hxx:64
std::unique_ptr< weld::RadioButton > m_xFileRB
Definition: mailmrge.hxx:70
Object Value
OUString m_sFilename
Definition: mailmrge.hxx:58
IMPL_LINK(SwMailMergeDlg, FilenameHdl, weld::ToggleButton &, rBox, void)
Definition: mailmrge.cxx:407
SwDocShell * GetDocShell()
Definition: view.cxx:1109
std::unique_ptr< weld::Label > m_xAttachFT
Definition: mailmrge.hxx:95
std::unique_ptr< weld::CheckButton > m_xFormatSwCB
Definition: mailmrge.hxx:100
Provides access to the formatting devices of a document.
OUString GetTargetURL() const
Definition: mailmrge.cxx:556
void SetPasswordFromColumn(const OUString &rSet)
Definition: modcfg.hxx:352
SwMailMergeDlg(weld::Window *pParent, SwWrtShell &rSh, const OUString &rSourceName, const OUString &rTableName, sal_Int32 nCommandType, const css::uno::Reference< css::sdbc::XConnection > &xConnection, css::uno::Sequence< css::uno::Any > const *pSelection)
Definition: mailmrge.cxx:112
OUString m_sSaveFilter
Definition: mailmrge.hxx:57
bool ExecQryShell()
Definition: mailmrge.cxx:475
void SetSinglePrintJob(bool b)
Definition: modcfg.hxx:328
const OUString & GetWorkPath() const
Reference< XMultiServiceFactory > getProcessServiceFactory()
std::unique_ptr< weld::Button > m_xPathPB
Definition: mailmrge.hxx:87
uno::Reference< runtime::XFormController > xFController
Definition: mailmrge.cxx:68
MailTextFormats
Definition: modcfg.hxx:38
void SetPrintSingleJobs(bool b)
Definition: printdata.hxx:164
Save mail merge as files.
Definition: dbmgr.hxx:91
SwXSelChgLstnr_Impl(SwMailMergeDlg &rParentDlg)
Definition: mailmrge.cxx:86
std::unique_ptr< weld::Label > m_xPasswordFT
Definition: mailmrge.hxx:83
std::unique_ptr< weld::SpinButton > m_xFromNF
Definition: mailmrge.hxx:65
INetProtocol GetProtocol() const
std::unique_ptr< weld::ComboBox > m_xPasswordLB
Definition: mailmrge.hxx:84
RET_OK
virtual void setPrintData(const SwPrintData &rPrtData)=0
Sets the PrintData.
Reference< XExecutableDialog > m_xDialog
SwMailMergeFieldConnectionsDlg(weld::Window *pParent)
Definition: mailmrge.cxx:606
const INetURLObject & GetURLObject() const
Reference< XComponentContext > getProcessComponentContext()
const OUString & GetNameFromColumn() const
Definition: modcfg.hxx:340
void SetIsNameFromColumn(bool bSet)
Definition: modcfg.hxx:332
const MiscSettings & GetMiscSettings() const
std::unique_ptr< weld::RadioButton > m_xPrinterRB
Definition: mailmrge.hxx:68
bool SetURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void GetColumnNames(weld::ComboBox &rBox, const OUString &rDBName, const OUString &rTableName)
Fill listbox with all column names of a database table.
Definition: dbmgr.cxx:658
bool GetDisablePrinting() const
std::unique_ptr< weld::Button > m_xAttachPB
Definition: mailmrge.hxx:97
std::unique_ptr< weld::CheckButton > m_xGenerateFromDataBaseCB
Definition: mailmrge.hxx:79
std::unique_ptr< weld::RadioButton > m_xSaveIndividualRB
Definition: mailmrge.hxx:77
const OUString & GetPasswordFromColumn() const
Definition: modcfg.hxx:351
bool IsNameFromColumn() const
Definition: modcfg.hxx:331
OUString GetFull() const
DBManagerOptions nMergeType
Definition: mailmrge.hxx:53
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
SfxMedium * GetMedium() const