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