LibreOffice Module sw (master)  1
mmaddressblockpage.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 "mmaddressblockpage.hxx"
21 #include <mailmergewizard.hxx>
22 #include <swtypes.hxx>
23 #include "addresslistdialog.hxx"
24 #include <editeng/eeitem.hxx>
25 #include <o3tl/safeint.hxx>
26 #include <svl/grabbagitem.hxx>
27 #include <svl/itemset.hxx>
28 #include <vcl/event.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/weld.hxx>
31 #include <vcl/transfer.hxx>
32 #include <mmconfigitem.hxx>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
35 #include <com/sun/star/sdbc/SQLException.hpp>
36 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
37 #include <com/sun/star/sdb/XColumn.hpp>
38 #include <comphelper/sequence.hxx>
39 #include <comphelper/string.hxx>
40 #include <tools/diagnose_ex.h>
41 
42 #include <vector>
43 #include <strings.hrc>
44 #include <mmaddressblockpage.hrc>
45 #include <helpids.h>
46 
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::container;
49 using namespace ::com::sun::star::sdb;
50 using namespace ::com::sun::star::sdbc;
51 using namespace ::com::sun::star::sdbcx;
52 
54  : vcl::OWizardPage(pPage, pWizard, "modules/swriter/ui/mmaddressblockpage.ui", "MMAddressBlockPage")
55  , m_pWizard(pWizard)
56  , m_xAddressListPB(m_xBuilder->weld_button("addresslist"))
57  , m_xCurrentAddressFI(m_xBuilder->weld_label("currentaddress"))
58  , m_xStep2(m_xBuilder->weld_container("step2"))
59  , m_xStep3(m_xBuilder->weld_container("step3"))
60  , m_xStep4(m_xBuilder->weld_container("step4"))
61  , m_xSettingsFI(m_xBuilder->weld_label("settingsft"))
62  , m_xAddressCB(m_xBuilder->weld_check_button("address"))
63  , m_xSettingsPB(m_xBuilder->weld_button("settings"))
64  , m_xHideEmptyParagraphsCB(m_xBuilder->weld_check_button("hideempty"))
65  , m_xAssignPB(m_xBuilder->weld_button("assign"))
66  , m_xDocumentIndexFI(m_xBuilder->weld_label("documentindex"))
67  , m_xPrevSetIB(m_xBuilder->weld_button("prev"))
68  , m_xNextSetIB(m_xBuilder->weld_button("next"))
69  , m_xDifferentlist(m_xBuilder->weld_button("differentlist"))
70  , m_xSettings(new SwAddressPreview(m_xBuilder->weld_scrolled_window("settingspreviewwin", true)))
71  , m_xPreview(new SwAddressPreview(m_xBuilder->weld_scrolled_window("addresspreviewwin", true)))
72  , m_xSettingsWIN(new weld::CustomWeld(*m_xBuilder, "settingspreview", *m_xSettings))
73  , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "addresspreview", *m_xPreview))
74 {
75  m_xSettingsWIN->set_size_request(m_xDifferentlist->get_approximate_digit_width() * 40,
76  m_xDifferentlist->get_text_height() * 6);
77  m_xPreviewWIN->set_size_request(m_xDifferentlist->get_approximate_digit_width() * 44,
78  m_xDifferentlist->get_text_height() * 6);
79  m_sChangeAddress = m_xDifferentlist->get_label();
80  m_sDocument = m_xDocumentIndexFI->get_label();
81 
83  m_xAddressListPB->connect_clicked(LINK(this, SwMailMergeAddressBlockPage, AddressListHdl_Impl));
84  m_xSettingsPB->connect_clicked(LINK(this, SwMailMergeAddressBlockPage, SettingsHdl_Impl));
85  m_xAssignPB->connect_clicked(LINK(this, SwMailMergeAddressBlockPage, AssignHdl_Impl ));
86  m_xAddressCB->connect_toggled(LINK(this, SwMailMergeAddressBlockPage, AddressBlockHdl_Impl));
87  m_xSettings->SetSelectHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl));
88  m_xHideEmptyParagraphsCB->connect_toggled(LINK(this, SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl));
89 
90  Link<weld::Button&,void> aLink = LINK(this, SwMailMergeAddressBlockPage, InsertDataHdl_Impl);
91  m_xPrevSetIB->connect_clicked(aLink);
92  m_xNextSetIB->connect_clicked(aLink);
93 
94  // lock in preferred size including current address line
95  Size aSize1(m_xContainer->get_preferred_size());
96 
97  OUString sOrigLabel = m_xAddressListPB->get_label();
99  Size aSize2(m_xContainer->get_preferred_size());
100  m_xAddressListPB->set_label(sOrigLabel);
101 
102  m_xCurrentAddressFI->hide();
103 
104  m_xContainer->set_size_request(std::max(aSize1.Width(), aSize2.Width()),
105  std::max(aSize1.Height(), aSize2.Height()));
106 }
107 
109 {
110  m_xPreviewWIN.reset();
111  m_xSettingsWIN.reset();
112  m_xPreview.reset();
113  m_xSettings.reset();
114 }
115 
117 {
118  return m_pWizard->GetConfigItem().GetResultSet().is();
119 }
120 
122 {
124  bool bIsLetter = rConfigItem.IsOutputToLetter();
125 
126  //no address block is created for e-Mail
127  m_xStep2->set_visible(bIsLetter);
128  m_xStep3->set_visible(bIsLetter);
129  m_xStep4->set_visible(bIsLetter);
130 
131  if (!bIsLetter)
132  return;
133 
134  m_xHideEmptyParagraphsCB->set_active( rConfigItem.IsHideEmptyParagraphs() );
135  m_xDocumentIndexFI->set_label(m_sDocument.replaceFirst("%1", "1"));
136 
137  m_xSettings->Clear();
138  const uno::Sequence< OUString> aBlocks =
140  for(const auto& rAddress : aBlocks)
141  m_xSettings->AddAddress(rAddress);
142  m_xSettings->SelectAddress(o3tl::narrowing<sal_uInt16>(rConfigItem.GetCurrentAddressBlockIndex()));
143  m_xAddressCB->set_active(rConfigItem.IsAddressBlock());
144  AddressBlockHdl_Impl(*m_xAddressCB);
145  m_xSettings->SetLayout(1, 2);
146  InsertDataHdl(nullptr);
147 }
148 
150 {
151  return ::vcl::WizardTypes::eTravelForward != _eReason || m_pWizard->GetConfigItem().GetResultSet().is();
152 }
153 
155 {
156  try
157  {
158  SwAddressListDialog aAddrDialog(this);
159  if (RET_OK == aAddrDialog.run())
160  {
161  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
162  rConfigItem.SetCurrentConnection(
163  aAddrDialog.GetSource(),
164  aAddrDialog.GetConnection(),
165  aAddrDialog.GetColumnsSupplier(),
166  aAddrDialog.GetDBData());
167  OUString sFilter = aAddrDialog.GetFilter();
168  rConfigItem.SetFilter( sFilter );
169  InsertDataHdl(nullptr);
170  GetWizard()->UpdateRoadmap();
171  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
172  }
173  }
174  catch (const uno::Exception& e)
175  {
176  TOOLS_WARN_EXCEPTION("sw", "");
177  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pWizard->getDialog(),
178  VclMessageType::Warning, VclButtonsType::Ok, e.Message));
179  xBox->run();
180  }
181 }
182 
184 {
185  SwSelectAddressBlockDialog aDlg(m_pWizard->getDialog(), m_pWizard->GetConfigItem());
186  SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
187  aDlg.SetAddressBlocks(rConfig.GetAddressBlocks(), m_xSettings->GetSelectedAddress());
188  aDlg.SetSettings(rConfig.IsIncludeCountry(), rConfig.GetExcludeCountry());
189  if (aDlg.run() == RET_OK)
190  {
191  //the dialog provides the selected address at the first position!
192  const uno::Sequence< OUString> aBlocks = aDlg.GetAddressBlocks();
193  rConfig.SetAddressBlocks(aBlocks);
194  m_xSettings->Clear();
195  for(const auto& rAddress : aBlocks)
196  m_xSettings->AddAddress(rAddress);
197  m_xSettings->SelectAddress(0);
198  m_xSettings->Invalidate(); // #i40408
199  rConfig.SetCountrySettings(aDlg.IsIncludeCountry(), aDlg.GetCountry());
200  InsertDataHdl(nullptr);
201  }
202  GetWizard()->UpdateRoadmap();
203  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
204 }
205 
207 {
208  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
209  const sal_uInt16 nSel = m_xSettings->GetSelectedAddress();
210  const uno::Sequence< OUString> aBlocks = rConfigItem.GetAddressBlocks();
211  SwAssignFieldsDialog aDlg(m_pWizard->getDialog(), m_pWizard->GetConfigItem(), aBlocks[nSel], true);
212  if(RET_OK == aDlg.run())
213  {
214  //preview update
215  InsertDataHdl(nullptr);
216  GetWizard()->UpdateRoadmap();
217  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
218  }
219 }
220 
221 void SwMailMergeAddressBlockPage::EnableAddressBlock(bool bAll, bool bSelective)
222 {
223  m_xSettingsFI->set_sensitive(bAll);
224  m_xAddressCB->set_sensitive(bAll);
225  bSelective &= bAll;
226  m_xHideEmptyParagraphsCB->set_sensitive(bSelective);
227  m_xSettingsWIN->set_sensitive(bSelective);
228  m_xSettingsPB->set_sensitive(bSelective);
229  m_xStep3->set_sensitive(bSelective);
230  m_xStep4->set_sensitive(bSelective);
231 }
232 
233 IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, weld::Toggleable&, rBox, void)
234 {
235  EnableAddressBlock(rBox.get_sensitive(), rBox.get_active());
236  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
237  rConfigItem.SetAddressBlock(m_xAddressCB->get_active());
238  m_pWizard->UpdateRoadmap();
239  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
240 }
241 
242 IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl, LinkParamNone*, void)
243 {
244  const sal_uInt16 nSel = m_xSettings->GetSelectedAddress();
245  const uno::Sequence< OUString> aBlocks =
246  m_pWizard->GetConfigItem().GetAddressBlocks();
247  m_xPreview->SetAddress(SwAddressPreview::FillData(aBlocks[nSel],
248  m_pWizard->GetConfigItem()));
249  m_pWizard->GetConfigItem().SetCurrentAddressBlockIndex( nSel );
250  GetWizard()->UpdateRoadmap();
251  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
252 }
253 
254 IMPL_LINK(SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl, weld::Toggleable&, rBox, void)
255 {
256  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
257  rConfigItem.SetHideEmptyParagraphs(rBox.get_active());
258 }
259 
261 {
262  //if no pButton is given, the first set has to be pre-set
264  std::unique_ptr<weld::WaitObject> xWaitObj(new weld::WaitObject(m_pWizard->getDialog()));
265  if(!pButton)
266  {
267  rConfig.GetResultSet();
268  }
269  else
270  {
271  bool bNext = pButton == m_xNextSetIB.get();
272  sal_Int32 nPos = rConfig.GetResultSetPosition();
273  rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
274  }
275  xWaitObj.reset();
276  sal_Int32 nPos = rConfig.GetResultSetPosition();
277  bool bEnable = true;
278  if(nPos < 1)
279  {
280  bEnable = false;
281  nPos = 1;
282  }
283  else
284  {
285  //if output type is letter
286  if (m_xSettings->IsVisible())
287  {
288  //Fill data into preview
289  const sal_uInt16 nSel = m_xSettings->GetSelectedAddress();
290  const uno::Sequence< OUString> aBlocks =
292  m_xPreview->SetAddress(SwAddressPreview::FillData(aBlocks[nSel], rConfig));
293  }
294  }
295  m_xPrevSetIB->set_sensitive(bEnable);
296  m_xDocumentIndexFI->set_label(m_sDocument.replaceFirst("%1", OUString::number(nPos)));
297 
298  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
299  bool bHasResultSet = rConfig.GetResultSet().is();
300  m_xCurrentAddressFI->set_visible(bHasResultSet);
301  if(bHasResultSet)
302  {
303  m_xCurrentAddressFI->set_label(m_sCurrentAddress.replaceFirst("%1", rConfig.GetCurrentDBData().sDataSource));
305  }
306  EnableAddressBlock(bHasResultSet, m_xAddressCB->get_active());
307 }
308 
309 IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, weld::Button&, rButton, void)
310 {
311  InsertDataHdl(&rButton);
312 }
313 
315  : SfxDialogController(pParent, "modules/swriter/ui/selectblockdialog.ui", "SelectBlockDialog")
316  , m_rConfig(rConfig)
317  , m_xPreview(new SwAddressPreview(m_xBuilder->weld_scrolled_window("previewwin", true)))
318  , m_xNewPB(m_xBuilder->weld_button("new"))
319  , m_xCustomizePB(m_xBuilder->weld_button("edit"))
320  , m_xDeletePB(m_xBuilder->weld_button("delete"))
321  , m_xNeverRB(m_xBuilder->weld_radio_button("never"))
322  , m_xAlwaysRB(m_xBuilder->weld_radio_button("always"))
323  , m_xDependentRB(m_xBuilder->weld_radio_button("dependent"))
324  , m_xCountryED(m_xBuilder->weld_entry("country"))
325  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", *m_xPreview))
326 {
327  m_xPreviewWin->set_size_request(m_xCountryED->get_approximate_digit_width() * 45,
328  m_xCountryED->get_text_height() * 12);
329 
330  Link<weld::Button&,void> aCustomizeHdl = LINK(this, SwSelectAddressBlockDialog, NewCustomizeHdl_Impl);
331  m_xNewPB->connect_clicked(aCustomizeHdl);
332  m_xCustomizePB->connect_clicked(aCustomizeHdl);
333 
334  m_xDeletePB->connect_clicked(LINK(this, SwSelectAddressBlockDialog, DeleteHdl_Impl));
335 
336  Link<weld::Toggleable&,void> aLk = LINK(this, SwSelectAddressBlockDialog, IncludeHdl_Impl);
337  m_xNeverRB->connect_toggled(aLk);
338  m_xAlwaysRB->connect_toggled(aLk);
339  m_xDependentRB->connect_toggled(aLk);
340  m_xPreview->SetLayout(2, 2);
341  m_xPreview->EnableScrollBar();
342 }
343 
345 {
346 }
347 
348 void SwSelectAddressBlockDialog::SetAddressBlocks(const uno::Sequence< OUString>& rBlocks,
349  sal_uInt16 nSelectedAddress)
350 {
351  m_aAddressBlocks = rBlocks;
352  for (const auto& rAddressBlock : std::as_const(m_aAddressBlocks))
353  m_xPreview->AddAddress(rAddressBlock);
354  m_xPreview->SelectAddress(nSelectedAddress);
355 }
356 
357 // return the address blocks and put the selected one to the first position
358 const uno::Sequence< OUString >& SwSelectAddressBlockDialog::GetAddressBlocks()
359 {
360  //put the selected block to the first position
361  const sal_Int32 nSelect = static_cast<sal_Int32>(m_xPreview->GetSelectedAddress());
362  if(nSelect)
363  {
364  uno::Sequence< OUString >aTemp = m_aAddressBlocks;
365  aTemp[0] = m_aAddressBlocks[nSelect];
366  std::copy(m_aAddressBlocks.begin(), std::next(m_aAddressBlocks.begin(), nSelect), std::next(aTemp.begin()));
367  std::copy(std::next(m_aAddressBlocks.begin(), nSelect + 1), m_aAddressBlocks.end(), std::next(aTemp.begin(), nSelect + 1));
368  m_aAddressBlocks = aTemp;
369  }
370  return m_aAddressBlocks;
371 }
372 
374  bool bIsCountry, const OUString& rCountry)
375 {
376  weld::RadioButton *pActive = m_xNeverRB.get();
377  if(bIsCountry)
378  {
379  pActive = !rCountry.isEmpty() ? m_xDependentRB.get() : m_xAlwaysRB.get();
380  m_xCountryED->set_text(rCountry);
381  }
382  pActive->set_active(true);
383  IncludeHdl_Impl(*pActive);
384  m_xDeletePB->set_sensitive(m_aAddressBlocks.getLength() > 1);
385 }
386 
388 {
389  if (m_xDependentRB->get_active())
390  return m_xCountryED->get_text();
391  return OUString();
392 }
393 
394 IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, weld::Button&, rButton, void)
395 {
396  if (m_aAddressBlocks.getLength())
397  {
398  const sal_Int32 nSelected = static_cast<sal_Int32>(m_xPreview->GetSelectedAddress());
399  comphelper::removeElementAt(m_aAddressBlocks, nSelected);
400  if (m_aAddressBlocks.getLength() <= 1)
401  rButton.set_sensitive(false);
402  m_xPreview->RemoveSelectedAddress();
403  }
404 }
405 
406 IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, weld::Button&, rButton, void)
407 {
408  bool bCustomize = &rButton == m_xCustomizePB.get();
412  std::unique_ptr<SwCustomizeAddressBlockDialog> xDlg(new SwCustomizeAddressBlockDialog(&rButton,
413  m_rConfig, nType));
414  if(bCustomize)
415  {
416  xDlg->SetAddress(m_aAddressBlocks[m_xPreview->GetSelectedAddress()]);
417  }
418  if (RET_OK != xDlg->run())
419  return;
420 
421  const OUString sNew = xDlg->GetAddress();
422  if(bCustomize)
423  {
424  m_xPreview->ReplaceSelectedAddress(sNew);
425  m_aAddressBlocks[m_xPreview->GetSelectedAddress()] = sNew;
426  }
427  else
428  {
429  m_xPreview->AddAddress(sNew);
430  m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() + 1);
431  const sal_Int32 nSelect = m_aAddressBlocks.getLength() - 1;
432  m_aAddressBlocks[nSelect] = sNew;
433  m_xPreview->SelectAddress(o3tl::narrowing<sal_uInt16>(nSelect));
434  }
435  m_xDeletePB->set_sensitive(m_aAddressBlocks.getLength() > 1);
436 }
437 
439 {
440  m_xCountryED->set_sensitive(m_xDependentRB->get_active());
441 }
442 
443 #define USER_DATA_SALUTATION -1
444 #define USER_DATA_PUNCTUATION -2
445 #define USER_DATA_TEXT -3
446 #define USER_DATA_NONE -4
447 
448 IMPL_LINK(SwCustomizeAddressBlockDialog, TextFilterHdl, OUString&, rTest, bool)
449 {
450  rTest = m_aTextFilter.filter(rTest);
451  return true;
452 }
453 
455  weld::Widget* pParent, SwMailMergeConfigItem& rConfig, DialogType eType)
456  : SfxDialogController(pParent, "modules/swriter/ui/addressblockdialog.ui",
457  "AddressBlockDialog")
458  , m_aTextFilter("<>")
459  , m_rConfigItem(rConfig)
460  , m_eType(eType)
461  , m_xAddressElementsFT(m_xBuilder->weld_label("addressesft"))
462  , m_xAddressElementsLB(m_xBuilder->weld_tree_view("addresses"))
463  , m_xInsertFieldIB(m_xBuilder->weld_button("toaddr"))
464  , m_xRemoveFieldIB(m_xBuilder->weld_button("fromaddr"))
465  , m_xDragFT(m_xBuilder->weld_label("addressdestft"))
466  , m_xUpIB(m_xBuilder->weld_button("up"))
467  , m_xLeftIB(m_xBuilder->weld_button("left"))
468  , m_xRightIB(m_xBuilder->weld_button("right"))
469  , m_xDownIB(m_xBuilder->weld_button("down"))
470  , m_xFieldFT(m_xBuilder->weld_label("customft"))
471  , m_xFieldCB(m_xBuilder->weld_combo_box("custom"))
472  , m_xOK(m_xBuilder->weld_button("ok"))
473  , m_xPreview(new SwAddressPreview(m_xBuilder->weld_scrolled_window("previewwin", true)))
474  , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "addrpreview", *m_xPreview))
475  , m_xDragED(new AddressMultiLineEdit(this))
476  , m_xDragWIN(new weld::CustomWeld(*m_xBuilder, "addressdest", *m_xDragED))
477 {
478  m_aSelectionChangedIdle.SetInvokeHandler( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedIdleHdl ) );
479 
480  Size aSize(m_xDragED->GetDrawingArea()->get_size_request());
481  m_xPreview->set_size_request(aSize.Width(), aSize.Height());
482 
483  m_xFieldCB->connect_entry_insert_text(LINK(this, SwCustomizeAddressBlockDialog, TextFilterHdl));
484  m_xAddressElementsLB->set_size_request(-1, m_xAddressElementsLB->get_height_rows(16));
485 
486  if( eType >= GREETING_FEMALE )
487  {
488  m_xFieldFT->show();
489  m_xFieldCB->show();
490  m_xAddressElementsLB->append(OUString::number(USER_DATA_SALUTATION), SwResId(ST_SALUTATION));
491  m_xAddressElementsLB->append(OUString::number(USER_DATA_PUNCTUATION), SwResId(ST_PUNCTUATION));
492  m_xAddressElementsLB->append(OUString::number(USER_DATA_TEXT), SwResId(ST_TEXT));
493  for (size_t i = 0; i < SAL_N_ELEMENTS(RA_SALUTATION); ++i)
494  m_aSalutations.push_back(SwResId(RA_SALUTATION[i]));
495  for (size_t i = 0; i < SAL_N_ELEMENTS(RA_PUNCTUATION); ++i)
496  m_aPunctuations.push_back(SwResId(RA_PUNCTUATION[i]));
497  m_xDragED->SetText(" ");
498  m_xDialog->set_title(SwResId(eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE));
499  m_xAddressElementsFT->set_label(SwResId(ST_SALUTATIONELEMENTS));
500  m_xInsertFieldIB->set_tooltip_text(SwResId(ST_INSERTSALUTATIONFIELD));
501  m_xRemoveFieldIB->set_tooltip_text(SwResId(ST_REMOVESALUTATIONFIELD));
502  m_xDragFT->set_label(SwResId(ST_DRAGSALUTATION));
503  }
504  else
505  {
506  if (eType == ADDRESSBLOCK_EDIT)
507  m_xDialog->set_title(SwResId(ST_TITLE_EDIT));
508  m_xDragED->SetText("\n\n\n\n\n");
509  /* Set custom HIDs for swriter/01/mm_newaddblo.xhp */
513  m_xDragWIN->set_help_id( HID_MM_ADDBLOCK_DRAG );
514  m_xPreviewWIN->set_help_id( HID_MM_ADDBLOCK_PREVIEW );
515  m_xRightIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
516  m_xLeftIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
517  m_xDownIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
518  m_xUpIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
519  }
520 
521  const std::vector<std::pair<OUString, int>>& rHeaders = m_rConfigItem.GetDefaultAddressHeaders();
522  for (size_t i = 0; i < rHeaders.size(); ++i)
523  m_xAddressElementsLB->append(OUString::number(i), rHeaders[i].first);
524  m_xOK->connect_clicked(LINK(this, SwCustomizeAddressBlockDialog, OKHdl_Impl));
525  m_xAddressElementsLB->connect_changed(LINK(this, SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl));
526  if (m_xAddressElementsLB->n_children())
527  m_xAddressElementsLB->select(0);
528  m_xDragED->SetModifyHdl(LINK(this, SwCustomizeAddressBlockDialog, EditModifyHdl_Impl));
529  m_xDragED->SetSelectionChangedHdl( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl));
530  m_xFieldCB->connect_changed(LINK(this, SwCustomizeAddressBlockDialog, FieldChangeComboBoxHdl_Impl));
531  Link<weld::Button&,void> aImgButtonHdl = LINK(this, SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl);
532  m_xInsertFieldIB->connect_clicked(aImgButtonHdl);
533  m_xRemoveFieldIB->connect_clicked(aImgButtonHdl);
534  m_xUpIB->connect_clicked(aImgButtonHdl);
535  m_xLeftIB->connect_clicked(aImgButtonHdl);
536  m_xRightIB->connect_clicked(aImgButtonHdl);
537  m_xDownIB->connect_clicked(aImgButtonHdl);
539 }
540 
542 {
543  return m_xDragED->SetCursorLogicPosition(rPosition);
544 }
545 
547 {
548  m_xDragED->UpdateFields();
549 }
550 
552 {
553  m_xDragED->EndDropTarget();
554 }
555 
557 {
558  m_xDialog->response(RET_OK);
559 }
560 
561 IMPL_LINK(SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl, weld::TreeView&, rBox, void)
562 {
563  sal_Int32 nUserData = rBox.get_selected_id().toInt32();
564  // Check if the selected entry is already in the address and then forbid inserting
565  m_xInsertFieldIB->set_sensitive(nUserData >= 0 || !HasItem(nUserData));
566 }
567 
569 {
570  m_xPreview->SetAddress(SwAddressPreview::FillData(GetAddress(), m_rConfigItem));
571  UpdateImageButtons_Impl();
572 }
573 
574 IMPL_LINK(SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl, weld::Button&, rButton, void)
575 {
576  if (m_xInsertFieldIB.get() == &rButton)
577  {
578  int nEntry = m_xAddressElementsLB->get_selected_index();
579  if (nEntry != -1)
580  {
581  m_xDragED->InsertNewEntry("<" + m_xAddressElementsLB->get_text(nEntry) + ">");
582  }
583  }
584  else if (m_xRemoveFieldIB.get() == &rButton)
585  {
586  m_xDragED->RemoveCurrentEntry();
587  }
588  else
589  {
591  if (m_xUpIB.get() == &rButton)
592  nMove = MoveItemFlags::Up;
593  else if (m_xLeftIB.get() == &rButton)
594  nMove = MoveItemFlags::Left;
595  else if (m_xRightIB.get() == &rButton)
596  nMove = MoveItemFlags::Right;
597  m_xDragED->MoveCurrentItem(nMove);
598  }
599  UpdateImageButtons_Impl();
600 }
601 
603 {
604  sal_Int32 nRet = USER_DATA_NONE;
605  const OUString sSelected = m_xDragED->GetCurrentItem();
606  if(!sSelected.isEmpty())
607  {
608  for (int i = 0, nEntryCount = m_xAddressElementsLB->n_children(); i < nEntryCount; ++i)
609  {
610  const OUString sEntry = m_xAddressElementsLB->get_text(i);
611  if( sEntry == sSelected.subView( 1, sSelected.getLength() - 2 ) )
612  {
613  nRet = m_xAddressElementsLB->get_id(i).toInt32();
614  break;
615  }
616  }
617  }
618  return nRet;
619 }
620 
621 bool SwCustomizeAddressBlockDialog::HasItem(sal_Int32 nUserData)
622 {
623  //get the entry from the ListBox
624  OUString sEntry;
625  for (int i = 0, nEntryCount = m_xAddressElementsLB->n_children(); i < nEntryCount; ++i)
626  {
627  if (m_xAddressElementsLB->get_id(i).toInt32() == nUserData)
628  {
629  sEntry = m_xAddressElementsLB->get_text(i);
630  break;
631  }
632  }
633  //search for this entry in the content
634  return m_xDragED->GetText().indexOf(OUString("<" + sEntry + ">")) >= 0;
635 }
636 
637 IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, SelectionChangedIdleHdl, Timer*, void)
638 {
639  // called in case the selection of the edit field changes.
640  // determine selection - if it's one of the editable fields then
641  // enable the related ComboBox and fill it
642 
643  // don't trigger outself again
644  m_xDragED->SetSelectionChangedHdl(Link<bool, void>());
645 
646  sal_Int32 nSelected = GetSelectedItem_Impl();
647  if (USER_DATA_NONE != nSelected)
648  m_xDragED->SelectCurrentItem();
649 
650  if(m_xFieldCB->get_visible() && (USER_DATA_NONE != nSelected) && (nSelected < 0))
651  {
652  //search in ListBox if it's one of the first entries
653  OUString sSelect;
654  std::vector<OUString>* pVector = nullptr;
655  switch(nSelected) {
657  sSelect = m_sCurrentSalutation;
658  pVector = &m_aSalutations;
659  break;
661  sSelect = m_sCurrentPunctuation;
662  pVector = &m_aPunctuations;
663  break;
664  case USER_DATA_TEXT:
665  sSelect = m_sCurrentText;
666  break;
667  }
668  m_xFieldCB->clear();
669  if(pVector) {
670  for (const auto& rItem : *pVector)
671  m_xFieldCB->append_text(rItem);
672  }
673  m_xFieldCB->set_entry_text(sSelect);
674  m_xFieldCB->set_sensitive(true);
675  m_xFieldFT->set_sensitive(true);
676  }
677  else
678  {
679  m_xFieldCB->set_sensitive(false);
680  m_xFieldFT->set_sensitive(false);
681  }
682 
683  UpdateImageButtons_Impl();
684  m_xDragED->SetSelectionChangedHdl( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl));
685 }
686 
687 IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, bool, bIdle, void)
688 {
689  if (bIdle)
690  m_aSelectionChangedIdle.Start();
691  else
692  {
693  m_aSelectionChangedIdle.Stop();
694  SelectionChangedIdleHdl(nullptr);
695  }
696 }
697 
698 IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, FieldChangeComboBoxHdl_Impl, weld::ComboBox&, void)
699 {
700  //changing the field content changes the related members, too
701  sal_Int32 nSelected = GetSelectedItem_Impl();
702  const OUString sContent = m_xFieldCB->get_active_text();
703  switch(nSelected) {
705  m_sCurrentSalutation = sContent;
706  break;
708  m_sCurrentPunctuation = sContent;
709  break;
710  case USER_DATA_TEXT:
711  m_sCurrentText = sContent;
712  break;
713  }
714  UpdateImageButtons_Impl();
715  m_xPreview->SetAddress(GetAddress());
716  EditModifyHdl_Impl(*m_xDragED);
717 }
718 
720 {
721  MoveItemFlags nMove = m_xDragED->IsCurrentItemMoveable();
722  m_xUpIB->set_sensitive( bool(nMove & MoveItemFlags::Up) );
723  m_xLeftIB->set_sensitive( bool(nMove & MoveItemFlags::Left) );
724  m_xRightIB->set_sensitive( bool(nMove & MoveItemFlags::Right) );
725  m_xDownIB->set_sensitive( bool(nMove & MoveItemFlags::Down) );
726  m_xRemoveFieldIB->set_sensitive(m_xDragED->HasCurrentItem());
727  int nEntry = m_xAddressElementsLB->get_selected_index();
728  m_xInsertFieldIB->set_sensitive( nEntry != -1 &&
729  (m_xAddressElementsLB->get_id(nEntry).toInt32() >= 0 || !m_xFieldCB->get_active_text().isEmpty()));
730 }
731 
732 void SwCustomizeAddressBlockDialog::SetAddress(const OUString& rAddress)
733 {
734  m_xDragED->SetText(rAddress);
736  EditModifyHdl_Impl(*m_xDragED);
737 }
738 
740 {
741  OUString sAddress(m_xDragED->GetAddress());
742  //remove placeholders by the actual content
743  if (m_xFieldFT->get_visible())
744  {
745  for (int i = 0, nEntryCount = m_xAddressElementsLB->n_children(); i < nEntryCount; ++i)
746  {
747  const OUString sEntry = "<" + m_xAddressElementsLB->get_text(i) + ">";
748  sal_Int32 nUserData = m_xAddressElementsLB->get_id(i).toInt32();
749  switch(nUserData)
750  {
752  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentSalutation);
753  break;
755  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentPunctuation);
756  break;
757  case USER_DATA_TEXT:
758  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentText);
759  break;
760  }
761  }
762  }
763  return sAddress;
764 }
765 
766 namespace {
767 
768 struct SwAssignFragment
769 {
770  std::unique_ptr<weld::Builder> m_xBuilder;
771  std::unique_ptr<weld::Label> m_xLabel;
772  std::unique_ptr<weld::ComboBox> m_xComboBox;
773  std::unique_ptr<weld::Label> m_xPreview;
774 
775  SwAssignFragment(weld::Container* pGrid, int nLine)
776  : m_xBuilder(Application::CreateBuilder(pGrid, "modules/swriter/ui/assignfragment.ui"))
777  , m_xLabel(m_xBuilder->weld_label("label"))
778  , m_xComboBox(m_xBuilder->weld_combo_box("combobox"))
779  , m_xPreview(m_xBuilder->weld_label("preview"))
780  {
781  m_xLabel->set_grid_left_attach(0);
782  m_xLabel->set_grid_top_attach(nLine);
783 
784  m_xComboBox->set_grid_left_attach(1);
785  m_xComboBox->set_grid_top_attach(nLine);
786 
787  m_xPreview->set_grid_left_attach(2);
788  m_xPreview->set_grid_top_attach(nLine);
789  }
790 };
791 
792 }
793 
795 {
796  friend class SwAssignFieldsDialog;
797  std::unique_ptr<weld::ScrolledWindow> m_xVScroll;
798  std::unique_ptr<weld::Container> m_xGrid;
799 
800  std::vector<SwAssignFragment> m_aFields;
801 
803 
805 
806  DECL_LINK(MatchHdl_Impl, weld::ComboBox&, void);
807  DECL_LINK(GotFocusHdl_Impl, weld::Widget&, void);
808 
809  void MakeVisible(const tools::Rectangle & rRect);
810 public:
811  SwAssignFieldsControl(std::unique_ptr<weld::ScrolledWindow> xWindow,
812  std::unique_ptr<weld::Container> xGrid);
813 
814  void Init(SwAssignFieldsDialog* pDialog, SwMailMergeConfigItem& rConfigItem);
815  void SetModifyHdl(const Link<LinkParamNone*,void>& rModifyHdl)
816  {
817  m_aModifyHdl = rModifyHdl;
818  m_aModifyHdl.Call(nullptr);
819  }
820 };
821 
822 SwAssignFieldsControl::SwAssignFieldsControl(std::unique_ptr<weld::ScrolledWindow> xWindow,
823  std::unique_ptr<weld::Container> xGrid)
824  : m_xVScroll(std::move(xWindow))
825  , m_xGrid(std::move(xGrid))
826  , m_rConfigItem(nullptr)
827 {
828 }
829 
831 {
832  m_rConfigItem = &rConfigItem;
833 
834  //get the name of the default headers
835  const std::vector<std::pair<OUString, int>>& rHeaders = rConfigItem.GetDefaultAddressHeaders();
836  //get the actual data
837  uno::Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), uno::UNO_QUERY);
838  //get the name of the actual columns
839  uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
840  uno::Sequence< OUString > aFields;
841  if(xColAccess.is())
842  aFields = xColAccess->getElementNames();
843 
844  //get the current assignment list
845  //each position in this sequence matches the position in the header array rHeaders
846  //if no assignment is available an empty sequence will be returned
847  uno::Sequence< OUString> aAssignments = rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
848  Link<weld::ComboBox&,void> aMatchHdl = LINK(this, SwAssignFieldsControl, MatchHdl_Impl);
849  Link<weld::Widget&,void> aFocusHdl = LINK(this, SwAssignFieldsControl, GotFocusHdl_Impl);
850 
851  int nLabelWidth(0), nComboBoxWidth(0), nPreviewWidth(0);
852 
853  //fill the controls
854  for (size_t i = 0; i < rHeaders.size(); ++i)
855  {
856  m_aFields.emplace_back(m_xGrid.get(), i);
857 
858  const OUString rHeader = rHeaders[i].first;
859  weld::ComboBox& rNewLB = *m_aFields.back().m_xComboBox;
860  rNewLB.append_text(SwResId(SW_STR_NONE));
861  rNewLB.set_active(0);
862 
863  for (const OUString& rField : std::as_const(aFields))
864  rNewLB.append_text(rField);
865  //select the ListBox
866  //if there is an assignment
867  if(o3tl::make_unsigned(aAssignments.getLength()) > i && !aAssignments[i].isEmpty())
868  rNewLB.set_active_text(aAssignments[i]);
869  else //otherwise the current column name may match one of the db columns
870  rNewLB.set_active_text(rHeader);
871 
872  weld::Label& rNewText = *m_aFields.back().m_xLabel;
873  rNewText.set_label("<" + rHeader + ">");
874 
875  weld::Label& rNewPreview = *m_aFields.back().m_xPreview;
876  //then the preview can be filled accordingly
877  if (xColAccess.is() && rNewLB.get_active() > 0 &&
878  xColAccess->hasByName(rNewLB.get_active_text()))
879  {
880  uno::Any aCol = xColAccess->getByName(rNewLB.get_active_text());
881  uno::Reference< XColumn > xColumn;
882  aCol >>= xColumn;
883  if(xColumn.is())
884  {
885  try
886  {
887  rNewPreview.set_label(xColumn->getString());
888  }
889  catch (const SQLException&)
890  {
891  }
892  }
893  }
894 
895  if (i == 0)
896  {
897  auto nLineHeight = m_xGrid->get_preferred_size().Height();
898  m_xVScroll->set_size_request(m_xVScroll->get_approximate_digit_width() * 65,
899  nLineHeight * 6);
900  nComboBoxWidth = rNewLB.get_preferred_size().Width();
901  }
902 
903  nLabelWidth = std::max<int>(nLabelWidth, rNewText.get_preferred_size().Width());
904  nPreviewWidth = std::max<int>(nPreviewWidth, rNewPreview.get_preferred_size().Width());
905 
906  rNewLB.connect_changed(aMatchHdl);
907  rNewLB.connect_focus_in(aFocusHdl);
908  rNewText.show();
909  rNewLB.show();
910  rNewPreview.show();
911  }
912  pDialog->ConnectSizeGroups(nLabelWidth, nComboBoxWidth, nPreviewWidth);
913 }
914 
916 {
917  //determine range of visible positions
918  auto nMinVisiblePos = m_xVScroll->vadjustment_get_value();
919  auto nMaxVisiblePos = nMinVisiblePos + m_xVScroll->vadjustment_get_page_size();
920  if (rRect.Top() < nMinVisiblePos || rRect.Bottom() > nMaxVisiblePos)
921  m_xVScroll->vadjustment_set_value(rRect.Top());
922 }
923 
924 IMPL_LINK(SwAssignFieldsControl, MatchHdl_Impl, weld::ComboBox&, rBox, void)
925 {
926  const OUString sColumn = rBox.get_active_text();
927  uno::Reference< XColumnsSupplier > xColsSupp( m_rConfigItem->GetResultSet(), uno::UNO_QUERY);
928  uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
929  OUString sPreview;
930  if(xColAccess.is() && xColAccess->hasByName(sColumn))
931  {
932  uno::Any aCol = xColAccess->getByName(sColumn);
933  uno::Reference< XColumn > xColumn;
934  aCol >>= xColumn;
935  if(xColumn.is())
936  {
937  try
938  {
939  sPreview = xColumn->getString();
940  }
941  catch (const sdbc::SQLException&)
942  {
943  }
944  }
945  }
946  auto aLBIter = std::find_if(m_aFields.begin(), m_aFields.end(), [&rBox](const SwAssignFragment& rFragment){
947  return &rBox == rFragment.m_xComboBox.get(); });
948  if (aLBIter != m_aFields.end())
949  {
950  auto nIndex = static_cast<sal_Int32>(std::distance(m_aFields.begin(), aLBIter));
951  m_aFields[nIndex].m_xPreview->set_label(sPreview);
952  }
953  m_aModifyHdl.Call(nullptr);
954 }
955 
956 IMPL_LINK(SwAssignFieldsControl, GotFocusHdl_Impl, weld::Widget&, rBox, void)
957 {
958  int x, y, width, height;
959  rBox.get_extents_relative_to(*m_xGrid, x, y, width, height);
960  // the container has a border of 3 in the .ui
961  tools::Rectangle aRect(Point(x - 3, y - 3), Size(width + 6, height + 6));
962  MakeVisible(aRect);
963 }
964 
966  weld::Window* pParent, SwMailMergeConfigItem& rConfigItem,
967  const OUString& rPreview,
968  bool bIsAddressBlock)
969  : SfxDialogController(pParent, "modules/swriter/ui/assignfieldsdialog.ui", "AssignFieldsDialog")
970  , m_sNone(SwResId(SW_STR_NONE))
971  , m_rPreviewString(rPreview)
972  , m_rConfigItem(rConfigItem)
973  , m_xPreview(new SwAddressPreview(m_xBuilder->weld_scrolled_window("previewwin", true)))
974  , m_xMatchingFI(m_xBuilder->weld_label("MATCHING_LABEL"))
975  , m_xAddressTitle(m_xBuilder->weld_label("addresselem"))
976  , m_xMatchTitle(m_xBuilder->weld_label("matchelem"))
977  , m_xPreviewTitle(m_xBuilder->weld_label("previewelem"))
978  , m_xPreviewFI(m_xBuilder->weld_label("PREVIEW_LABEL"))
979  , m_xOK(m_xBuilder->weld_button("ok"))
980  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "PREVIEW", *m_xPreview))
981  , m_xFieldsControl(new SwAssignFieldsControl(m_xBuilder->weld_scrolled_window("scroll"),
982  m_xBuilder->weld_container("FIELDS")))
983 {
984  m_xPreviewWin->set_size_request(m_xMatchingFI->get_approximate_digit_width() * 45,
985  m_xMatchingFI->get_text_height() * 5);
986  m_xFieldsControl->Init(this, rConfigItem);
987 
988  const OUString sMatchesTo( SwResId(ST_MATCHESTO) );
989  if (!bIsAddressBlock)
990  {
991  m_xPreviewFI->set_label(SwResId(ST_SALUTATIONPREVIEW));
992  m_xMatchingFI->set_label(SwResId(ST_SALUTATIONMATCHING));
993  m_xAddressTitle->set_label(SwResId(ST_SALUTATIONELEMENT));
994  }
995 
996  m_xFieldsControl->SetModifyHdl(LINK(this, SwAssignFieldsDialog, AssignmentModifyHdl_Impl ));
997  m_xMatchingFI->set_label(m_xMatchingFI->get_label().replaceAll("%1", sMatchesTo));
998  m_xOK->connect_clicked(LINK(this, SwAssignFieldsDialog, OkHdl_Impl));
999 }
1000 
1002 {
1003 }
1004 
1005 uno::Sequence< OUString > SwAssignFieldsDialog::CreateAssignments()
1006 {
1007  uno::Sequence< OUString > aAssignments(
1009  OUString* pAssignments = aAssignments.getArray();
1010  sal_Int32 nIndex = 0;
1011  for (const auto& rLBItem : m_xFieldsControl->m_aFields)
1012  {
1013  const OUString sSelect = rLBItem.m_xComboBox->get_active_text();
1014  pAssignments[nIndex] = (m_sNone != sSelect) ? sSelect : OUString();
1015  ++nIndex;
1016  }
1017  return aAssignments;
1018 }
1019 
1021 {
1024  CreateAssignments() );
1025  m_xDialog->response(RET_OK);
1026 }
1027 
1028 IMPL_LINK_NOARG(SwAssignFieldsDialog, AssignmentModifyHdl_Impl, LinkParamNone*, void)
1029 {
1030  uno::Sequence< OUString > aAssignments = CreateAssignments();
1031  const OUString sPreview = SwAddressPreview::FillData(
1032  m_rPreviewString, m_rConfigItem, &aAssignments);
1033  m_xPreview->SetAddress(sPreview);
1034 }
1035 
1036 void SwAssignFieldsDialog::ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
1037 {
1038  m_xAddressTitle->set_size_request(nLabelWidth, -1);
1039  m_xMatchTitle->set_size_request(nComboBoxWidth, -1);
1040  m_xPreviewTitle->set_size_request(nPreviewWidth, -1);
1041 }
1042 
1043 namespace
1044 {
1045  const EECharAttrib* FindCharAttrib(int nStartPosition, std::vector<EECharAttrib>& rAttribList)
1046  {
1047  for (auto it = rAttribList.rbegin(); it != rAttribList.rend(); ++it)
1048  {
1049  const auto& rTextAtr = *it;
1050  if (rTextAtr.pAttr->Which() != EE_CHAR_GRABBAG)
1051  continue;
1052  if (rTextAtr.nStart <= nStartPosition && rTextAtr.nEnd >= nStartPosition)
1053  {
1054  return &rTextAtr;
1055  }
1056  }
1057 
1058  return nullptr;
1059  }
1060 }
1061 
1063  : m_pParentDialog(pParent)
1064 {
1065 }
1066 
1068 {
1069  if (m_xDropTarget.is())
1070  {
1071  auto xRealDropTarget = GetDrawingArea()->get_drop_target();
1072  uno::Reference<css::datatransfer::dnd::XDropTargetListener> xListener(m_xDropTarget, uno::UNO_QUERY);
1073  xRealDropTarget->removeDropTargetListener(xListener);
1074  m_xDropTarget.clear();
1075  }
1076 }
1077 
1079 {
1080  assert(!m_xDropTarget.is());
1081 }
1082 
1084 {
1085  Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(160, 60), MapMode(MapUnit::MapAppFont)));
1086  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
1087  WeldEditView::SetDrawingArea(pDrawingArea);
1088 }
1089 
1091 {
1092  if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
1093  return false; // we want default esc behaviour
1094  if (rKEvt.GetCharCode())
1095  return true; // handled
1096  return WeldEditView::KeyInput(rKEvt);
1097 }
1098 
1100 {
1101  if (rMEvt.GetClicks() >= 2)
1102  return true; // handled
1103  return WeldEditView::MouseButtonDown(rMEvt);
1104 }
1105 
1107 {
1108  return m_xEditEngine->GetText();
1109 }
1110 
1111 void AddressMultiLineEdit::SetText( const OUString& rStr )
1112 {
1113  m_xEditEngine->SetText(rStr);
1114  //set attributes to all address tokens
1115 
1116  sal_Int32 nSequence(0);
1117  SfxGrabBagItem aProtectAttr(EE_CHAR_GRABBAG);
1118  const sal_uInt32 nParaCount = m_xEditEngine->GetParagraphCount();
1119  for(sal_uInt32 nPara = 0; nPara < nParaCount; ++nPara)
1120  {
1121  sal_Int32 nIndex = 0;
1122  const OUString sPara = m_xEditEngine->GetText( nPara );
1123  if (!sPara.isEmpty() && !sPara.endsWith(" "))
1124  {
1125  ESelection aPaM(nPara, sPara.getLength(), nPara, sPara.getLength());
1126  m_xEditEngine->QuickInsertText(" ", aPaM);
1127  }
1128  for(;;)
1129  {
1130  const sal_Int32 nStart = sPara.indexOf( '<', nIndex );
1131  if (nStart < 0)
1132  break;
1133  const sal_Int32 nEnd = sPara.indexOf( '>', nStart );
1134  if (nEnd < 0)
1135  break;
1136  nIndex = nEnd;
1137  SfxItemSet aSet(m_xEditEngine->GetEmptyItemSet());
1138  // make each one different, so they are not collapsed together
1139  // as one attribute
1140  aProtectAttr.GetGrabBag()["Index"] <<= nSequence++;
1141  aSet.Put(aProtectAttr);
1142  m_xEditEngine->QuickSetAttribs(aSet, ESelection(nPara, nStart, nPara, nEnd + 1));
1143  }
1144 
1145  }
1146  // add two empty paragraphs at the end
1149  {
1150  sal_Int32 nLastLen = m_xEditEngine->GetText(nParaCount - 1).getLength();
1151  if(nLastLen)
1152  {
1153  int nPara = nParaCount ? nParaCount - 1 : 0;
1154  ESelection aPaM(nPara, nLastLen, nPara, nLastLen);
1155  m_xEditEngine->QuickInsertText("\n \n ", aPaM);
1156  }
1157  }
1158 
1159  m_xEditView->SetSelection(ESelection(0, 0, 0, 0));
1160 }
1161 
1162 // Insert the new entry in front of the entry at the beginning of the selection
1163 void AddressMultiLineEdit::InsertNewEntry( const OUString& rStr )
1164 {
1165  // insert new entry after current selected one.
1166  ESelection aSelection = m_xEditView->GetSelection();
1167  const sal_uInt32 nPara = aSelection.nStartPara;
1168 
1169  std::vector<EECharAttrib> aAttribList;
1170  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1171 
1172  sal_Int32 nIndex = aSelection.nEndPara;
1173  const EECharAttrib* pAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1174  if(nullptr != pAttrib)
1175  nIndex = pAttrib->nEnd;
1176  InsertNewEntryAtPosition( rStr, nPara, nIndex );
1177 
1178  // select the new entry
1179  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1180  pAttrib = FindCharAttrib(nIndex, aAttribList);
1181  const sal_Int32 nEnd = pAttrib ? pAttrib->nEnd : nIndex;
1182  ESelection aEntrySel(nPara, nIndex, nPara, nEnd);
1183  m_xEditView->SetSelection(aEntrySel);
1184  Invalidate();
1185  m_aModifyLink.Call(*this);
1186 }
1187 
1188 void AddressMultiLineEdit::InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex )
1189 {
1190  ESelection aInsertPos(nPara, nIndex, nPara, nIndex);
1191  m_xEditEngine->QuickInsertText(rStr, aInsertPos);
1192 
1193  //restore the attributes
1194  SetText( GetAddress() );
1195 
1196  //select the newly inserted/moved element
1197  m_xEditView->SetSelection(aInsertPos);
1198  m_aSelectionLink.Call(false);
1199 }
1200 
1202 {
1203  ESelection aSelection = m_xEditView->GetSelection();
1204 
1205  std::vector<EECharAttrib> aAttribList;
1206  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1207 
1208  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1209  if(pBeginAttrib &&
1210  (pBeginAttrib->nStart <= aSelection.nStartPos
1211  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1212  {
1213  const sal_uInt32 nPara = aSelection.nStartPara;
1214  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1215  m_xEditEngine->QuickInsertText(OUString(), aEntrySel);
1216  //restore the attributes
1217  SetText( GetAddress() );
1218  m_aModifyLink.Call(*this);
1219  }
1220 }
1221 
1223 {
1224  ESelection aSelection = m_xEditView->GetSelection();
1225 
1226  std::vector<EECharAttrib> aAttribList;
1227  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1228 
1229  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1230  if(!pBeginAttrib ||
1231  pBeginAttrib->nStart > aSelection.nStartPos ||
1232  pBeginAttrib->nEnd < aSelection.nEndPos)
1233  return;
1234 
1235  //current item has been found
1236  sal_Int32 nPara = aSelection.nStartPara;
1237  sal_Int32 nIndex = pBeginAttrib->nStart;
1238  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1239  const OUString sCurrentItem = m_xEditEngine->GetText(aEntrySel);
1240  m_xEditEngine->RemoveAttribs(aEntrySel, false, EE_CHAR_GRABBAG);
1241  m_xEditEngine->QuickInsertText(OUString(), aEntrySel);
1242  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1243  switch (nMove)
1244  {
1245  case MoveItemFlags::Left :
1246  if(nIndex)
1247  {
1248  //go left to find a predecessor or simple text
1249  --nIndex;
1250  const OUString sPara = m_xEditEngine->GetText( nPara );
1251  sal_Int32 nSearchIndex = sPara.lastIndexOf( '>', nIndex+1 );
1252  if( nSearchIndex != -1 && nSearchIndex == nIndex )
1253  {
1254  nSearchIndex = sPara.lastIndexOf( '<', nIndex );
1255  if( nSearchIndex != -1 )
1256  nIndex = nSearchIndex;
1257  }
1258  }
1259  break;
1260  case MoveItemFlags::Right:
1261  {
1262  //go right to find a successor or simple text
1263  ++nIndex;
1264  const EECharAttrib* pEndAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1265  if(pEndAttrib && pEndAttrib->nEnd >= nIndex)
1266  {
1267  nIndex = pEndAttrib->nEnd;
1268  }
1269  }
1270  break;
1271  case MoveItemFlags::Up :
1272  --nPara;
1273  nIndex = 0;
1274  break;
1275  case MoveItemFlags::Down :
1276  ++nPara;
1277  nIndex = 0;
1278  break;
1279  default: break;
1280  }
1281  //add a new paragraph if there is none yet
1282  if (nPara >= m_xEditEngine->GetParagraphCount())
1283  {
1284  auto nInsPara = nPara - 1;
1285  auto nInsPos = m_xEditEngine->GetTextLen( nPara - 1 );
1286  ESelection aTemp(nInsPara, nInsPos, nInsPara, nInsPos);
1287  m_xEditEngine->QuickInsertText("\n", aTemp);
1288  }
1289  InsertNewEntryAtPosition( sCurrentItem, nPara, nIndex );
1290 
1291  // select the new entry [#i40817]
1292  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1293  const EECharAttrib* pAttrib = FindCharAttrib(nIndex, aAttribList);
1294  if (pAttrib)
1295  aEntrySel = ESelection(nPara, nIndex, nPara, pAttrib->nEnd);
1296  m_xEditView->SetSelection(aEntrySel);
1297  Invalidate();
1298  m_aModifyLink.Call(*this);
1299 }
1300 
1302 {
1304  ESelection aSelection = m_xEditView->GetSelection();
1305 
1306  std::vector<EECharAttrib> aAttribList;
1307  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1308 
1309  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1310  if (pBeginAttrib &&
1311  (pBeginAttrib->nStart <= aSelection.nStartPos
1312  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1313  {
1314  if (pBeginAttrib->nStart)
1315  nRet |= MoveItemFlags::Left;
1316  //if there is an entry it can always be move to the right and down
1318  if (aSelection.nStartPara > 0)
1319  nRet |= MoveItemFlags::Up;
1320  }
1321  return nRet;
1322 }
1323 
1325 {
1326  ESelection aSelection = m_xEditView->GetSelection();
1327 
1328  std::vector<EECharAttrib> aAttribList;
1329  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1330 
1331  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1332  return (pBeginAttrib &&
1333  (pBeginAttrib->nStart <= aSelection.nStartPos
1334  && pBeginAttrib->nEnd >= aSelection.nEndPos));
1335 }
1336 
1338 {
1339  ESelection aSelection = m_xEditView->GetSelection();
1340 
1341  std::vector<EECharAttrib> aAttribList;
1342  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1343 
1344  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1345  if (pBeginAttrib &&
1346  (pBeginAttrib->nStart <= aSelection.nStartPos
1347  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1348  {
1349  const sal_uInt32 nPara = aSelection.nStartPara;
1350  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1351  return m_xEditEngine->GetText( aEntrySel );
1352  }
1353  return OUString();
1354 }
1355 
1357 {
1358  ESelection aSelection = m_xEditView->GetSelection();
1359 
1360  std::vector<EECharAttrib> aAttribList;
1361  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1362 
1363  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1364  if (pBeginAttrib &&
1365  (pBeginAttrib->nStart <= aSelection.nStartPos
1366  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1367  {
1368  const sal_uInt32 nPara = aSelection.nStartPara;
1369  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1370  m_xEditView->SetSelection(aEntrySel);
1371  Invalidate();
1372  }
1373 }
1374 
1376 {
1377  OUString sRet;
1378  const sal_uInt32 nParaCount = m_xEditEngine->GetParagraphCount();
1379  for(sal_uInt32 nPara = nParaCount; nPara; --nPara)
1380  {
1381  const OUString sPara = comphelper::string::stripEnd(m_xEditEngine->GetText(nPara - 1), ' ');
1382  //don't add empty trailing paragraphs
1383  if(!sRet.isEmpty() || !sPara.isEmpty())
1384  {
1385  sRet = sPara + sRet;
1386  //insert the para break
1387  if(nPara > 1)
1388  sRet = "\n" + sRet;
1389  }
1390  }
1391  return sRet;
1392 }
1393 
1395 {
1396  ESelection aSelection = m_xEditView->GetSelection();
1397 
1398  //restore the attributes
1399  SetText( GetAddress() );
1400 
1401  //reselect the element
1402  m_xEditView->SetSelection(aSelection);
1403  m_aSelectionLink.Call(false);
1404 }
1405 
1407 {
1409  m_aSelectionLink.Call(true);
1410 }
1411 
1412 namespace
1413 {
1414  // sit between the tree as drag source and the editview as drop target and translate
1415  // the tree dnd data to the simple string the editview wants
1416  class DropTargetListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDropTargetListener,
1417  css::datatransfer::dnd::XDropTarget >
1418  {
1419  private:
1420  css::uno::Reference<css::datatransfer::dnd::XDropTarget> m_xRealDropTarget;
1421  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
1422  SwCustomizeAddressBlockDialog* m_pParentDialog;
1423 
1424  // XEventListener
1425  virtual void SAL_CALL disposing( const css::lang::EventObject& ) override
1426  {
1427  m_xRealDropTarget.clear();
1428  m_aListeners.clear();
1429  }
1430 
1431  // XDropTargetListener
1432  virtual void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override
1433  {
1434  SolarMutexGuard aGuard;
1435 
1436  auto aReplacement(dtde);
1437 
1438  Point aMousePos(dtde.LocationX, dtde.LocationY);
1439  bool bAllowed = m_pParentDialog->SetCursorLogicPosition(aMousePos);
1440  if (bAllowed)
1441  {
1442  if (weld::TreeView* pTree = m_pParentDialog->get_drag_source())
1443  {
1444  int nEntry = pTree->get_selected_index();
1445  if (nEntry != -1)
1446  {
1447  sal_Int32 nUserData = pTree->get_id(nEntry).toInt32();
1448  //special entries can only be once in the address / greeting
1449  if (nUserData >= 0 || !m_pParentDialog->HasItem(nUserData))
1450  {
1452  xContainer->CopyString( "<" + pTree->get_text(nEntry) + ">" );
1453 
1454  // replace what the treeview is offering with what ImpEditView::drop wants
1455  aReplacement.Transferable = xContainer.get();
1456  }
1457  }
1458  }
1459  }
1460 
1461  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1462  for (auto const& listener : aListeners)
1463  listener->drop(aReplacement);
1464 
1465  if (bAllowed)
1466  m_pParentDialog->UpdateFields();
1467  }
1468 
1469  virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override
1470  {
1471  auto aReplacement(dtdee);
1472  // replace what the treeview is offering with what ImpEditView::dragEnter wants
1473  aReplacement.SupportedDataFlavors.realloc(1);
1474  SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aReplacement.SupportedDataFlavors[0]);
1475 
1476  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1477  for (auto const& listener : aListeners)
1478  listener->dragEnter(aReplacement);
1479  }
1480 
1481  virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override
1482  {
1483  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1484  for (auto const& listener : aListeners)
1485  listener->dragExit( dte );
1486  }
1487 
1488  virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override
1489  {
1490  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1491  for (auto const& listener : aListeners)
1492  listener->dragOver( dtde );
1493  }
1494 
1495  virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override
1496  {
1497  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1498  for (auto const& listener : aListeners)
1499  listener->dropActionChanged( dtde );
1500  }
1501 
1502  // XDropTarget
1503  virtual void SAL_CALL addDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) override
1504  {
1505  m_aListeners.push_back(xListener);
1506  }
1507 
1508  virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) override
1509  {
1510  m_aListeners.erase(std::remove(m_aListeners.begin(), m_aListeners.end(), xListener), m_aListeners.end());
1511  }
1512 
1513  virtual sal_Bool SAL_CALL isActive() override
1514  {
1515  return m_xRealDropTarget->isActive();
1516  }
1517 
1518  virtual void SAL_CALL setActive(sal_Bool active) override
1519  {
1520  m_xRealDropTarget->setActive(active);
1521  }
1522 
1523  virtual sal_Int8 SAL_CALL getDefaultActions() override
1524  {
1525  return m_xRealDropTarget->getDefaultActions();
1526  }
1527 
1528  virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override
1529  {
1530  m_xRealDropTarget->setDefaultActions(actions);
1531  }
1532 
1533  public:
1534  DropTargetListener(css::uno::Reference<css::datatransfer::dnd::XDropTarget> xRealDropTarget,
1535  SwCustomizeAddressBlockDialog* pParentDialog)
1536  : m_xRealDropTarget(xRealDropTarget)
1537  , m_pParentDialog(pParentDialog)
1538  {
1539  }
1540  };
1541 }
1542 
1543 css::uno::Reference<css::datatransfer::dnd::XDropTarget> AddressMultiLineEdit::GetDropTarget()
1544 {
1545  if (!m_xDropTarget.is())
1546  {
1547  auto xRealDropTarget = GetDrawingArea()->get_drop_target();
1548  rtl::Reference<DropTargetListener> pProxy = new DropTargetListener(xRealDropTarget, m_pParentDialog);
1549  xRealDropTarget->addDropTargetListener(pProxy);
1550  m_xDropTarget = pProxy;
1551  }
1552  return m_xDropTarget;
1553 }
1554 
1556 {
1557  Point aMousePos = EditViewOutputDevice().PixelToLogic(rPosition);
1558  m_xEditView->SetCursorLogicPosition(aMousePos, false, true);
1559 
1560  ESelection aSelection = m_xEditView->GetSelection();
1561  std::vector<EECharAttrib> aAttribList;
1562  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1563  return FindCharAttrib(aSelection.nStartPos, aAttribList) == nullptr;
1564 }
1565 
1566 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nEnd
std::unique_ptr< weld::Button > m_xRightIB
std::unique_ptr< weld::Button > m_xInsertFieldIB
std::unique_ptr< weld::Container > m_xGrid
SwAssignFieldsControl(std::unique_ptr< weld::ScrolledWindow > xWindow, std::unique_ptr< weld::Container > xGrid)
bool IsHideEmptyParagraphs() const
OString stripEnd(std::string_view rIn, char c)
std::unique_ptr< SwAddressPreview > m_xPreview
void SetAddress(const OUString &rAddress)
#define HID_MM_ADDBLOCK_DRAG
Definition: helpids.h:149
std::vector< OUString > m_aSalutations
sal_Int32 nStartPara
sal_Int32 nIndex
std::unique_ptr< weld::Button > m_xLeftIB
std::unique_ptr< weld::Button > m_xNewPB
void InsertDataHdl(const weld::Button *pButton)
sal_Int32 nStart
SwMailMergeConfigItem & GetConfigItem()
std::unique_ptr< weld::Label > m_xPreviewTitle
std::unique_ptr< weld::Button > m_xDifferentlist
#define HID_MM_ADDBLOCK_MOVEBUTTONS
Definition: helpids.h:151
virtual Dialog * getDialog() override
OUString GetAddress() const
std::unique_ptr< weld::Label > m_xMatchTitle
MoveItemFlags IsCurrentItemMoveable() const
std::unique_ptr< SwAssignFieldsControl > m_xFieldsControl
signed char sal_Int8
SwSelectAddressBlockDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfig)
std::unique_ptr< weld::RadioButton > m_xNeverRB
virtual void EditViewSelectionChange() override
sal_uIntPtr sal_uLong
OUString sDataSource
Definition: swdbdata.hxx:30
sal_Int32 GetCurrentAddressBlockIndex() const
void SetCurrentConnection(css::uno::Reference< css::sdbc::XDataSource > const &xSource, const SharedConnection &rConnection, css::uno::Reference< css::sdbcx::XColumnsSupplier > const &xColumnsSupplier, const SwDBData &rDBData)
SwAssignFieldsDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfigItem, const OUString &rPreview, bool bIsAddressBlock)
sal_uInt16 GetCode() const
const SwDBData & GetCurrentDBData() const
std::unique_ptr< weld::CheckButton > m_xAddressCB
#define USER_DATA_TEXT
std::vector< Reference< css::datatransfer::clipboard::XClipboardListener > > m_aListeners
Link< AddressMultiLineEdit &, void > m_aModifyLink
std::unique_ptr< weld::CustomWeld > m_xSettingsWIN
IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, weld::Button &, void)
virtual int get_active() const =0
float x
void InsertNewEntry(const OUString &rStr)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
std::unique_ptr< weld::Label > m_xLabel
SwMailMergeWizard * GetWizard()
bool SetCursorLogicPosition(const Point &rPosition)
#define HID_MM_ADDBLOCK_REMOVE
Definition: helpids.h:148
constexpr tools::Long Width() const
sal_uInt16 GetClicks() const
std::vector< SwAssignFragment > m_aFields
void MoveCurrentItem(MoveItemFlags nMove)
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
virtual void show()=0
const css::uno::Sequence< OUString > & GetAddressBlocks()
std::vector< OUString > m_aPunctuations
css::uno::Sequence< OUString > GetAddressBlocks() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
std::unique_ptr< weld::Button > m_xUpIB
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
tools::Long Bottom() const
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
virtual ~AddressMultiLineEdit() override
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
std::unique_ptr< weld::Button > m_xNextSetIB
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
void MakeVisible(const tools::Rectangle &rRect)
virtual ~SwSelectAddressBlockDialog() override
virtual OutputDevice & get_ref_device()=0
sal_Int32 nEndPos
std::unique_ptr< weld::Button > m_xCustomizePB
Link< bool, void > m_aSelectionLink
std::unique_ptr< weld::Container > m_xStep3
#define MM_GREETINGSPAGE
constexpr TypedWhichId< SfxGrabBagItem > EE_CHAR_GRABBAG(EE_CHAR_START+31)
constexpr OUStringLiteral sPreview
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
Listeners aListeners
#define HID_MM_ADDBLOCK_PREVIEW
Definition: helpids.h:150
float y
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< weld::CustomWeld > m_xDragWIN
css::uno::Reference< css::sdbc::XResultSet > const & GetResultSet() const
std::unique_ptr< weld::ScrolledWindow > m_xVScroll
std::unique_ptr< weld::Container > m_xContainer
SwMailMergeAddressBlockPage(weld::Container *pPage, SwMailMergeWizard *pWizard)
const std::vector< std::pair< OUString, int > > & GetDefaultAddressHeaders() const
void set_active_text(const OUString &rStr)
std::unique_ptr< weld::ComboBox > m_xFieldCB
sal_Int32 nEndPara
#define TOOLS_WARN_EXCEPTION(area, stream)
SwCustomizeAddressBlockDialog(weld::Widget *pParent, SwMailMergeConfigItem &rConfig, DialogType)
virtual ~SwAssignFieldsDialog() override
const SwDBData & GetDBData() const
int i
weld::TreeView * get_drag_source() const
std::unique_ptr< weld::Button > m_xOK
std::unique_ptr< weld::Container > m_xStep2
void connect_changed(const Link< ComboBox &, void > &rLink)
std::unique_ptr< weld::Label > m_xDocumentIndexFI
std::unique_ptr< weld::Label > m_xPreviewFI
void SetHideEmptyParagraphs(bool bSet)
std::unique_ptr< weld::Label > m_xAddressElementsFT
std::unique_ptr< weld::Label > m_xFieldFT
virtual void set_active(bool active)=0
void SetAddressBlock(bool bSet)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
unsigned char sal_Bool
OUString GetFilter() const
const std::map< OUString, css::uno::Any > & GetGrabBag() const
virtual bool KeyInput(const KeyEvent &rKEvt) override
std::unique_ptr< weld::Button > m_xPrevSetIB
std::unique_ptr< EditView > m_xEditView
sal_Int32 GetResultSetPosition() const
virtual ~SwMailMergeAddressBlockPage() override
virtual void connect_focus_in(const Link< Widget &, void > &rLink)
virtual void set_active(int pos)=0
void SetFilter(OUString const &)
std::unique_ptr< weld::Label > m_xMatchingFI
std::unique_ptr< SwAddressPreview > m_xPreview
std::unique_ptr< weld::Button > m_xRemoveFieldIB
tools::Long Top() const
std::unique_ptr< weld::Button > m_xDownIB
sal_Int32 MoveResultSet(sal_Int32 nTarget)
virtual Size get_preferred_size() const =0
void SetText(const OUString &rStr)
css::uno::Sequence< OUString > CreateAssignments()
#define USER_DATA_SALUTATION
std::unique_ptr< weld::RadioButton > m_xAlwaysRB
css::uno::Sequence< OUString > GetColumnAssignment(const SwDBData &rDBData) const
virtual void set_label(const OUString &rText)=0
std::unique_ptr< weld::Button > m_xOK
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
std::unique_ptr< weld::Label > m_xSettingsFI
css::uno::Reference< css::sdbcx::XColumnsSupplier > GetColumnsSupplier() const
AddressMultiLineEdit(SwCustomizeAddressBlockDialog *pParent)
virtual bool KeyInput(const KeyEvent &rKEvt) override
const vcl::KeyCode & GetKeyCode() const
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
std::unique_ptr< weld::RadioButton > m_xDependentRB
void SetSettings(bool bIsCountry, const OUString &sCountry)
void EnableAddressBlock(bool bAll, bool bSelective)
#define HID_MM_ADDBLOCK_INSERT
Definition: helpids.h:147
SwCustomizeAddressBlockDialog * m_pParentDialog
std::unique_ptr< weld::Label > m_xDragFT
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks, sal_uInt16 nSelected)
constexpr sal_uInt16 KEY_ESCAPE
IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, weld::Toggleable &, rBox, void)
void removeElementAt(css::uno::Sequence< T > &_rSeq, sal_Int32 _nPos)
virtual bool canAdvance() const override
std::unique_ptr< weld::Button > m_xAssignPB
const T * HasItem(const ww8::PoolItems &rItems, sal_uInt16 eType)
bool isActive()
std::unique_ptr< weld::Button > m_xDeletePB
sal_Unicode GetCharCode() const
RET_OK
Reference< XExecutableDialog > m_xDialog
bool SetCursorLogicPosition(const Point &rPosition)
std::unique_ptr< weld::Button > m_xSettingsPB
virtual void EditViewSelectionChange() override
QPRO_FUNC_TYPE nType
#define USER_DATA_PUNCTUATION
OUString GetCurrentItem() const
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void SetColumnAssignment(const SwDBData &rDBData, const css::uno::Sequence< OUString > &)
void Init(SwAssignFieldsDialog *pDialog, SwMailMergeConfigItem &rConfigItem)
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
std::unique_ptr< weld::CheckButton > m_xHideEmptyParagraphsCB
Reference< XColumn > xColumn
std::unique_ptr< SwAddressPreview > m_xPreview
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks)
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget() override
#define USER_DATA_NONE
css::uno::Reference< css::sdbc::XDataSource > GetSource() const
std::unique_ptr< AddressMultiLineEdit > m_xDragED
bool HasItem(sal_Int32 nUserData)
std::unique_ptr< EditEngine > m_xEditEngine
css::uno::Sequence< OUString > m_aAddressBlocks
std::unique_ptr< weld::Container > m_xStep4
void setActive(bool bActive)
css::uno::Reference< css::datatransfer::dnd::XDropTarget > m_xDropTarget
void append_text(const OUString &rStr)
DECL_LINK(MatchHdl_Impl, weld::ComboBox &, void)
bool IsAddressBlock() const
virtual ~SwCustomizeAddressBlockDialog() override
SharedConnection GetConnection() const
const EnumerationType m_eType
void InsertNewEntryAtPosition(const OUString &rStr, sal_uLong nPara, sal_uInt16 nIndex)
std::unique_ptr< SwAddressPreview > m_xSettings
void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
SwMailMergeConfigItem & m_rConfigItem
virtual OutputDevice & EditViewOutputDevice() const override
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
virtual void set_size_request(int nWidth, int nHeight)=0
SwMailMergeConfigItem * m_rConfigItem
void SetModifyHdl(const Link< LinkParamNone *, void > &rModifyHdl)
#define HID_MM_ADDBLOCK_ELEMENTS
Definition: helpids.h:146
std::unique_ptr< weld::Label > m_xCurrentAddressFI
std::unique_ptr< weld::TreeView > m_xAddressElementsLB
static OUString FillData(const OUString &rAddress, SwMailMergeConfigItem const &rConfigItem, const css::uno::Sequence< OUString > *pAssignments=nullptr)
std::unique_ptr< weld::Entry > m_xCountryED
virtual void Activate() override
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
SwMailMergeConfigItem & m_rConfigItem
Link< LinkParamNone *, void > m_aModifyHdl
sal_uInt16 nPos
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
bool IsOutputToLetter() const
virtual OUString get_active_text() const =0
std::unique_ptr< weld::Button > m_xAddressListPB
std::unique_ptr< weld::Label > m_xAddressTitle
sal_Int32 nStartPos
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)