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.getLength());
365  auto it = aTemp.getArray();
366  *it = std::as_const(m_aAddressBlocks)[nSelect];
367  it = std::copy_n(std::cbegin(m_aAddressBlocks), nSelect - 1, std::next(it));
368  std::copy(std::next(std::cbegin(m_aAddressBlocks), nSelect + 1), std::cend(m_aAddressBlocks), it);
369  m_aAddressBlocks = aTemp;
370  }
371  return m_aAddressBlocks;
372 }
373 
375  bool bIsCountry, const OUString& rCountry)
376 {
377  weld::RadioButton *pActive = m_xNeverRB.get();
378  if(bIsCountry)
379  {
380  pActive = !rCountry.isEmpty() ? m_xDependentRB.get() : m_xAlwaysRB.get();
381  m_xCountryED->set_text(rCountry);
382  }
383  pActive->set_active(true);
384  IncludeHdl_Impl(*pActive);
385  m_xDeletePB->set_sensitive(m_aAddressBlocks.getLength() > 1);
386 }
387 
389 {
390  if (m_xDependentRB->get_active())
391  return m_xCountryED->get_text();
392  return OUString();
393 }
394 
395 IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, weld::Button&, rButton, void)
396 {
397  if (m_aAddressBlocks.getLength())
398  {
399  const sal_Int32 nSelected = static_cast<sal_Int32>(m_xPreview->GetSelectedAddress());
400  comphelper::removeElementAt(m_aAddressBlocks, nSelected);
401  if (m_aAddressBlocks.getLength() <= 1)
402  rButton.set_sensitive(false);
403  m_xPreview->RemoveSelectedAddress();
404  }
405 }
406 
407 IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, weld::Button&, rButton, void)
408 {
409  bool bCustomize = &rButton == m_xCustomizePB.get();
413  std::unique_ptr<SwCustomizeAddressBlockDialog> xDlg(new SwCustomizeAddressBlockDialog(&rButton,
414  m_rConfig, nType));
415  if(bCustomize)
416  {
417  xDlg->SetAddress(m_aAddressBlocks[m_xPreview->GetSelectedAddress()]);
418  }
419  if (RET_OK != xDlg->run())
420  return;
421 
422  const OUString sNew = xDlg->GetAddress();
423  if(bCustomize)
424  {
425  m_xPreview->ReplaceSelectedAddress(sNew);
426  m_aAddressBlocks.getArray()[m_xPreview->GetSelectedAddress()] = sNew;
427  }
428  else
429  {
430  m_xPreview->AddAddress(sNew);
431  m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() + 1);
432  const sal_Int32 nSelect = m_aAddressBlocks.getLength() - 1;
433  m_aAddressBlocks.getArray()[nSelect] = sNew;
434  m_xPreview->SelectAddress(o3tl::narrowing<sal_uInt16>(nSelect));
435  }
436  m_xDeletePB->set_sensitive(m_aAddressBlocks.getLength() > 1);
437 }
438 
440 {
441  m_xCountryED->set_sensitive(m_xDependentRB->get_active());
442 }
443 
444 #define USER_DATA_SALUTATION -1
445 #define USER_DATA_PUNCTUATION -2
446 #define USER_DATA_TEXT -3
447 #define USER_DATA_NONE -4
448 
449 IMPL_LINK(SwCustomizeAddressBlockDialog, TextFilterHdl, OUString&, rTest, bool)
450 {
451  rTest = m_aTextFilter.filter(rTest);
452  return true;
453 }
454 
456  weld::Widget* pParent, SwMailMergeConfigItem& rConfig, DialogType eType)
457  : SfxDialogController(pParent, "modules/swriter/ui/addressblockdialog.ui",
458  "AddressBlockDialog")
459  , m_aTextFilter("<>")
460  , m_rConfigItem(rConfig)
461  , m_eType(eType)
462  , m_aSelectionChangedIdle("SwCustomizeAddressBlockDialog m_aSelectionChangedIdle")
463  , m_xAddressElementsFT(m_xBuilder->weld_label("addressesft"))
464  , m_xAddressElementsLB(m_xBuilder->weld_tree_view("addresses"))
465  , m_xInsertFieldIB(m_xBuilder->weld_button("toaddr"))
466  , m_xRemoveFieldIB(m_xBuilder->weld_button("fromaddr"))
467  , m_xDragFT(m_xBuilder->weld_label("addressdestft"))
468  , m_xUpIB(m_xBuilder->weld_button("up"))
469  , m_xLeftIB(m_xBuilder->weld_button("left"))
470  , m_xRightIB(m_xBuilder->weld_button("right"))
471  , m_xDownIB(m_xBuilder->weld_button("down"))
472  , m_xFieldFT(m_xBuilder->weld_label("customft"))
473  , m_xFieldCB(m_xBuilder->weld_combo_box("custom"))
474  , m_xOK(m_xBuilder->weld_button("ok"))
475  , m_xPreview(new SwAddressPreview(m_xBuilder->weld_scrolled_window("previewwin", true)))
476  , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "addrpreview", *m_xPreview))
477  , m_xDragED(new AddressMultiLineEdit(this))
478  , m_xDragWIN(new weld::CustomWeld(*m_xBuilder, "addressdest", *m_xDragED))
479 {
480  m_aSelectionChangedIdle.SetInvokeHandler( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedIdleHdl ) );
481 
482  Size aSize(m_xDragED->GetDrawingArea()->get_size_request());
483  m_xPreview->set_size_request(aSize.Width(), aSize.Height());
484 
485  m_xFieldCB->connect_entry_insert_text(LINK(this, SwCustomizeAddressBlockDialog, TextFilterHdl));
486  m_xAddressElementsLB->set_size_request(-1, m_xAddressElementsLB->get_height_rows(16));
487 
488  if( eType >= GREETING_FEMALE )
489  {
490  m_xFieldFT->show();
491  m_xFieldCB->show();
492  m_xAddressElementsLB->append(OUString::number(USER_DATA_SALUTATION), SwResId(ST_SALUTATION));
493  m_xAddressElementsLB->append(OUString::number(USER_DATA_PUNCTUATION), SwResId(ST_PUNCTUATION));
494  m_xAddressElementsLB->append(OUString::number(USER_DATA_TEXT), SwResId(ST_TEXT));
495  for (size_t i = 0; i < SAL_N_ELEMENTS(RA_SALUTATION); ++i)
496  m_aSalutations.push_back(SwResId(RA_SALUTATION[i]));
497  for (size_t i = 0; i < SAL_N_ELEMENTS(RA_PUNCTUATION); ++i)
498  m_aPunctuations.push_back(SwResId(RA_PUNCTUATION[i]));
499  m_xDragED->SetText(" ");
500  m_xDialog->set_title(SwResId(eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE));
501  m_xAddressElementsFT->set_label(SwResId(ST_SALUTATIONELEMENTS));
502  m_xInsertFieldIB->set_tooltip_text(SwResId(ST_INSERTSALUTATIONFIELD));
503  m_xRemoveFieldIB->set_tooltip_text(SwResId(ST_REMOVESALUTATIONFIELD));
504  m_xDragFT->set_label(SwResId(ST_DRAGSALUTATION));
505  }
506  else
507  {
508  if (eType == ADDRESSBLOCK_EDIT)
509  m_xDialog->set_title(SwResId(ST_TITLE_EDIT));
510  m_xDragED->SetText("\n\n\n\n\n");
511  /* Set custom HIDs for swriter/01/mm_newaddblo.xhp */
515  m_xDragWIN->set_help_id( HID_MM_ADDBLOCK_DRAG );
516  m_xPreviewWIN->set_help_id( HID_MM_ADDBLOCK_PREVIEW );
517  m_xRightIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
518  m_xLeftIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
519  m_xDownIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
520  m_xUpIB->set_help_id( HID_MM_ADDBLOCK_MOVEBUTTONS );
521  }
522 
523  const std::vector<std::pair<OUString, int>>& rHeaders = m_rConfigItem.GetDefaultAddressHeaders();
524  for (size_t i = 0; i < rHeaders.size(); ++i)
525  m_xAddressElementsLB->append(OUString::number(i), rHeaders[i].first);
526  m_xOK->connect_clicked(LINK(this, SwCustomizeAddressBlockDialog, OKHdl_Impl));
527  m_xAddressElementsLB->connect_changed(LINK(this, SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl));
528  if (m_xAddressElementsLB->n_children())
529  m_xAddressElementsLB->select(0);
530  m_xDragED->SetModifyHdl(LINK(this, SwCustomizeAddressBlockDialog, EditModifyHdl_Impl));
531  m_xDragED->SetSelectionChangedHdl( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl));
532  m_xFieldCB->connect_changed(LINK(this, SwCustomizeAddressBlockDialog, FieldChangeComboBoxHdl_Impl));
533  Link<weld::Button&,void> aImgButtonHdl = LINK(this, SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl);
534  m_xInsertFieldIB->connect_clicked(aImgButtonHdl);
535  m_xRemoveFieldIB->connect_clicked(aImgButtonHdl);
536  m_xUpIB->connect_clicked(aImgButtonHdl);
537  m_xLeftIB->connect_clicked(aImgButtonHdl);
538  m_xRightIB->connect_clicked(aImgButtonHdl);
539  m_xDownIB->connect_clicked(aImgButtonHdl);
541 }
542 
544 {
545  return m_xDragED->SetCursorLogicPosition(rPosition);
546 }
547 
549 {
550  m_xDragED->UpdateFields();
551 }
552 
554 {
555  m_xDragED->EndDropTarget();
556 }
557 
559 {
560  m_xDialog->response(RET_OK);
561 }
562 
563 IMPL_LINK(SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl, weld::TreeView&, rBox, void)
564 {
565  sal_Int32 nUserData = rBox.get_selected_id().toInt32();
566  // Check if the selected entry is already in the address and then forbid inserting
567  m_xInsertFieldIB->set_sensitive(nUserData >= 0 || !HasItem(nUserData));
568 }
569 
571 {
572  m_xPreview->SetAddress(SwAddressPreview::FillData(GetAddress(), m_rConfigItem));
573  UpdateImageButtons_Impl();
574 }
575 
576 IMPL_LINK(SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl, weld::Button&, rButton, void)
577 {
578  if (m_xInsertFieldIB.get() == &rButton)
579  {
580  int nEntry = m_xAddressElementsLB->get_selected_index();
581  if (nEntry != -1)
582  {
583  m_xDragED->InsertNewEntry("<" + m_xAddressElementsLB->get_text(nEntry) + ">");
584  }
585  }
586  else if (m_xRemoveFieldIB.get() == &rButton)
587  {
588  m_xDragED->RemoveCurrentEntry();
589  }
590  else
591  {
593  if (m_xUpIB.get() == &rButton)
594  nMove = MoveItemFlags::Up;
595  else if (m_xLeftIB.get() == &rButton)
596  nMove = MoveItemFlags::Left;
597  else if (m_xRightIB.get() == &rButton)
598  nMove = MoveItemFlags::Right;
599  m_xDragED->MoveCurrentItem(nMove);
600  }
601  UpdateImageButtons_Impl();
602 }
603 
605 {
606  sal_Int32 nRet = USER_DATA_NONE;
607  const OUString sSelected = m_xDragED->GetCurrentItem();
608  if(!sSelected.isEmpty())
609  {
610  for (int i = 0, nEntryCount = m_xAddressElementsLB->n_children(); i < nEntryCount; ++i)
611  {
612  const OUString sEntry = m_xAddressElementsLB->get_text(i);
613  if( sEntry == sSelected.subView( 1, sSelected.getLength() - 2 ) )
614  {
615  nRet = m_xAddressElementsLB->get_id(i).toInt32();
616  break;
617  }
618  }
619  }
620  return nRet;
621 }
622 
623 bool SwCustomizeAddressBlockDialog::HasItem(sal_Int32 nUserData)
624 {
625  //get the entry from the ListBox
626  OUString sEntry;
627  for (int i = 0, nEntryCount = m_xAddressElementsLB->n_children(); i < nEntryCount; ++i)
628  {
629  if (m_xAddressElementsLB->get_id(i).toInt32() == nUserData)
630  {
631  sEntry = m_xAddressElementsLB->get_text(i);
632  break;
633  }
634  }
635  //search for this entry in the content
636  return m_xDragED->GetText().indexOf(OUStringConcatenation("<" + sEntry + ">")) >= 0;
637 }
638 
639 IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, SelectionChangedIdleHdl, Timer*, void)
640 {
641  // called in case the selection of the edit field changes.
642  // determine selection - if it's one of the editable fields then
643  // enable the related ComboBox and fill it
644 
645  // don't trigger outself again
646  m_xDragED->SetSelectionChangedHdl(Link<bool, void>());
647 
648  sal_Int32 nSelected = GetSelectedItem_Impl();
649  if (USER_DATA_NONE != nSelected)
650  m_xDragED->SelectCurrentItem();
651 
652  if(m_xFieldCB->get_visible() && (USER_DATA_NONE != nSelected) && (nSelected < 0))
653  {
654  //search in ListBox if it's one of the first entries
655  OUString sSelect;
656  std::vector<OUString>* pVector = nullptr;
657  switch(nSelected) {
659  sSelect = m_sCurrentSalutation;
660  pVector = &m_aSalutations;
661  break;
663  sSelect = m_sCurrentPunctuation;
664  pVector = &m_aPunctuations;
665  break;
666  case USER_DATA_TEXT:
667  sSelect = m_sCurrentText;
668  break;
669  }
670  m_xFieldCB->clear();
671  if(pVector) {
672  for (const auto& rItem : *pVector)
673  m_xFieldCB->append_text(rItem);
674  }
675  m_xFieldCB->set_entry_text(sSelect);
676  m_xFieldCB->set_sensitive(true);
677  m_xFieldFT->set_sensitive(true);
678  }
679  else
680  {
681  m_xFieldCB->set_sensitive(false);
682  m_xFieldFT->set_sensitive(false);
683  }
684 
685  UpdateImageButtons_Impl();
686  m_xDragED->SetSelectionChangedHdl( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl));
687 }
688 
689 IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, bool, bIdle, void)
690 {
691  if (bIdle)
692  m_aSelectionChangedIdle.Start();
693  else
694  {
695  m_aSelectionChangedIdle.Stop();
696  SelectionChangedIdleHdl(nullptr);
697  }
698 }
699 
700 IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, FieldChangeComboBoxHdl_Impl, weld::ComboBox&, void)
701 {
702  //changing the field content changes the related members, too
703  sal_Int32 nSelected = GetSelectedItem_Impl();
704  const OUString sContent = m_xFieldCB->get_active_text();
705  switch(nSelected) {
707  m_sCurrentSalutation = sContent;
708  break;
710  m_sCurrentPunctuation = sContent;
711  break;
712  case USER_DATA_TEXT:
713  m_sCurrentText = sContent;
714  break;
715  }
716  UpdateImageButtons_Impl();
717  m_xPreview->SetAddress(GetAddress());
718  EditModifyHdl_Impl(*m_xDragED);
719 }
720 
722 {
723  MoveItemFlags nMove = m_xDragED->IsCurrentItemMoveable();
724  m_xUpIB->set_sensitive( bool(nMove & MoveItemFlags::Up) );
725  m_xLeftIB->set_sensitive( bool(nMove & MoveItemFlags::Left) );
726  m_xRightIB->set_sensitive( bool(nMove & MoveItemFlags::Right) );
727  m_xDownIB->set_sensitive( bool(nMove & MoveItemFlags::Down) );
728  m_xRemoveFieldIB->set_sensitive(m_xDragED->HasCurrentItem());
729  int nEntry = m_xAddressElementsLB->get_selected_index();
730  m_xInsertFieldIB->set_sensitive( nEntry != -1 &&
731  (m_xAddressElementsLB->get_id(nEntry).toInt32() >= 0 || !m_xFieldCB->get_active_text().isEmpty()));
732 }
733 
734 void SwCustomizeAddressBlockDialog::SetAddress(const OUString& rAddress)
735 {
736  m_xDragED->SetText(rAddress);
738  EditModifyHdl_Impl(*m_xDragED);
739 }
740 
742 {
743  OUString sAddress(m_xDragED->GetAddress());
744  //remove placeholders by the actual content
745  if (m_xFieldFT->get_visible())
746  {
747  for (int i = 0, nEntryCount = m_xAddressElementsLB->n_children(); i < nEntryCount; ++i)
748  {
749  const OUString sEntry = "<" + m_xAddressElementsLB->get_text(i) + ">";
750  sal_Int32 nUserData = m_xAddressElementsLB->get_id(i).toInt32();
751  switch(nUserData)
752  {
754  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentSalutation);
755  break;
757  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentPunctuation);
758  break;
759  case USER_DATA_TEXT:
760  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentText);
761  break;
762  }
763  }
764  }
765  return sAddress;
766 }
767 
768 namespace {
769 
770 struct SwAssignFragment
771 {
772  std::unique_ptr<weld::Builder> m_xBuilder;
773  std::unique_ptr<weld::Label> m_xLabel;
774  std::unique_ptr<weld::ComboBox> m_xComboBox;
775  std::unique_ptr<weld::Label> m_xPreview;
776 
777  SwAssignFragment(weld::Container* pGrid, int nLine)
778  : m_xBuilder(Application::CreateBuilder(pGrid, "modules/swriter/ui/assignfragment.ui"))
779  , m_xLabel(m_xBuilder->weld_label("label"))
780  , m_xComboBox(m_xBuilder->weld_combo_box("combobox"))
781  , m_xPreview(m_xBuilder->weld_label("preview"))
782  {
783  m_xLabel->set_grid_left_attach(0);
784  m_xLabel->set_grid_top_attach(nLine);
785 
786  m_xComboBox->set_grid_left_attach(1);
787  m_xComboBox->set_grid_top_attach(nLine);
788 
789  m_xPreview->set_grid_left_attach(2);
790  m_xPreview->set_grid_top_attach(nLine);
791  }
792 };
793 
794 }
795 
797 {
798  friend class SwAssignFieldsDialog;
799  std::unique_ptr<weld::ScrolledWindow> m_xVScroll;
800  std::unique_ptr<weld::Container> m_xGrid;
801 
802  std::vector<SwAssignFragment> m_aFields;
803 
805 
807 
808  DECL_LINK(MatchHdl_Impl, weld::ComboBox&, void);
809  DECL_LINK(GotFocusHdl_Impl, weld::Widget&, void);
810 
811  void MakeVisible(const tools::Rectangle & rRect);
812 public:
813  SwAssignFieldsControl(std::unique_ptr<weld::ScrolledWindow> xWindow,
814  std::unique_ptr<weld::Container> xGrid);
815 
816  void Init(SwAssignFieldsDialog* pDialog, SwMailMergeConfigItem& rConfigItem);
817  void SetModifyHdl(const Link<LinkParamNone*,void>& rModifyHdl)
818  {
819  m_aModifyHdl = rModifyHdl;
820  m_aModifyHdl.Call(nullptr);
821  }
822 };
823 
824 SwAssignFieldsControl::SwAssignFieldsControl(std::unique_ptr<weld::ScrolledWindow> xWindow,
825  std::unique_ptr<weld::Container> xGrid)
826  : m_xVScroll(std::move(xWindow))
827  , m_xGrid(std::move(xGrid))
828  , m_rConfigItem(nullptr)
829 {
830 }
831 
833 {
834  m_rConfigItem = &rConfigItem;
835 
836  //get the name of the default headers
837  const std::vector<std::pair<OUString, int>>& rHeaders = rConfigItem.GetDefaultAddressHeaders();
838  //get the actual data
839  uno::Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), uno::UNO_QUERY);
840  //get the name of the actual columns
841  uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
842  uno::Sequence< OUString > aFields;
843  if(xColAccess.is())
844  aFields = xColAccess->getElementNames();
845 
846  //get the current assignment list
847  //each position in this sequence matches the position in the header array rHeaders
848  //if no assignment is available an empty sequence will be returned
849  uno::Sequence< OUString> aAssignments = rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
850  Link<weld::ComboBox&,void> aMatchHdl = LINK(this, SwAssignFieldsControl, MatchHdl_Impl);
851  Link<weld::Widget&,void> aFocusHdl = LINK(this, SwAssignFieldsControl, GotFocusHdl_Impl);
852 
853  int nLabelWidth(0), nComboBoxWidth(0), nPreviewWidth(0);
854 
855  //fill the controls
856  for (size_t i = 0; i < rHeaders.size(); ++i)
857  {
858  m_aFields.emplace_back(m_xGrid.get(), i);
859 
860  const OUString rHeader = rHeaders[i].first;
861  weld::ComboBox& rNewLB = *m_aFields.back().m_xComboBox;
862  rNewLB.append_text(SwResId(SW_STR_NONE));
863  rNewLB.set_active(0);
864 
865  for (const OUString& rField : std::as_const(aFields))
866  rNewLB.append_text(rField);
867  //select the ListBox
868  //if there is an assignment
869  if(o3tl::make_unsigned(aAssignments.getLength()) > i && !aAssignments[i].isEmpty())
870  rNewLB.set_active_text(aAssignments[i]);
871  else //otherwise the current column name may match one of the db columns
872  rNewLB.set_active_text(rHeader);
873 
874  weld::Label& rNewText = *m_aFields.back().m_xLabel;
875  rNewText.set_label("<" + rHeader + ">");
876 
877  weld::Label& rNewPreview = *m_aFields.back().m_xPreview;
878  //then the preview can be filled accordingly
879  if (xColAccess.is() && rNewLB.get_active() > 0 &&
880  xColAccess->hasByName(rNewLB.get_active_text()))
881  {
882  uno::Any aCol = xColAccess->getByName(rNewLB.get_active_text());
883  uno::Reference< XColumn > xColumn;
884  aCol >>= xColumn;
885  if(xColumn.is())
886  {
887  try
888  {
889  rNewPreview.set_label(xColumn->getString());
890  }
891  catch (const SQLException&)
892  {
893  }
894  }
895  }
896 
897  if (i == 0)
898  {
899  auto nLineHeight = m_xGrid->get_preferred_size().Height();
900  m_xVScroll->set_size_request(m_xVScroll->get_approximate_digit_width() * 65,
901  nLineHeight * 6);
902  nComboBoxWidth = rNewLB.get_preferred_size().Width();
903  }
904 
905  nLabelWidth = std::max<int>(nLabelWidth, rNewText.get_preferred_size().Width());
906  nPreviewWidth = std::max<int>(nPreviewWidth, rNewPreview.get_preferred_size().Width());
907 
908  rNewLB.connect_changed(aMatchHdl);
909  rNewLB.connect_focus_in(aFocusHdl);
910  rNewText.show();
911  rNewLB.show();
912  rNewPreview.show();
913  }
914  pDialog->ConnectSizeGroups(nLabelWidth, nComboBoxWidth, nPreviewWidth);
915 }
916 
918 {
919  //determine range of visible positions
920  auto nMinVisiblePos = m_xVScroll->vadjustment_get_value();
921  auto nMaxVisiblePos = nMinVisiblePos + m_xVScroll->vadjustment_get_page_size();
922  if (rRect.Top() < nMinVisiblePos || rRect.Bottom() > nMaxVisiblePos)
923  m_xVScroll->vadjustment_set_value(rRect.Top());
924 }
925 
926 IMPL_LINK(SwAssignFieldsControl, MatchHdl_Impl, weld::ComboBox&, rBox, void)
927 {
928  const OUString sColumn = rBox.get_active_text();
929  uno::Reference< XColumnsSupplier > xColsSupp( m_rConfigItem->GetResultSet(), uno::UNO_QUERY);
930  uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
931  OUString sPreview;
932  if(xColAccess.is() && xColAccess->hasByName(sColumn))
933  {
934  uno::Any aCol = xColAccess->getByName(sColumn);
935  uno::Reference< XColumn > xColumn;
936  aCol >>= xColumn;
937  if(xColumn.is())
938  {
939  try
940  {
941  sPreview = xColumn->getString();
942  }
943  catch (const sdbc::SQLException&)
944  {
945  }
946  }
947  }
948  auto aLBIter = std::find_if(m_aFields.begin(), m_aFields.end(), [&rBox](const SwAssignFragment& rFragment){
949  return &rBox == rFragment.m_xComboBox.get(); });
950  if (aLBIter != m_aFields.end())
951  {
952  auto nIndex = static_cast<sal_Int32>(std::distance(m_aFields.begin(), aLBIter));
953  m_aFields[nIndex].m_xPreview->set_label(sPreview);
954  }
955  m_aModifyHdl.Call(nullptr);
956 }
957 
958 IMPL_LINK(SwAssignFieldsControl, GotFocusHdl_Impl, weld::Widget&, rBox, void)
959 {
960  int x, y, width, height;
961  rBox.get_extents_relative_to(*m_xGrid, x, y, width, height);
962  // the container has a border of 3 in the .ui
963  tools::Rectangle aRect(Point(x - 3, y - 3), Size(width + 6, height + 6));
964  MakeVisible(aRect);
965 }
966 
968  weld::Window* pParent, SwMailMergeConfigItem& rConfigItem,
969  const OUString& rPreview,
970  bool bIsAddressBlock)
971  : SfxDialogController(pParent, "modules/swriter/ui/assignfieldsdialog.ui", "AssignFieldsDialog")
972  , m_sNone(SwResId(SW_STR_NONE))
973  , m_rPreviewString(rPreview)
974  , m_rConfigItem(rConfigItem)
975  , m_xPreview(new SwAddressPreview(m_xBuilder->weld_scrolled_window("previewwin", true)))
976  , m_xMatchingFI(m_xBuilder->weld_label("MATCHING_LABEL"))
977  , m_xAddressTitle(m_xBuilder->weld_label("addresselem"))
978  , m_xMatchTitle(m_xBuilder->weld_label("matchelem"))
979  , m_xPreviewTitle(m_xBuilder->weld_label("previewelem"))
980  , m_xPreviewFI(m_xBuilder->weld_label("PREVIEW_LABEL"))
981  , m_xOK(m_xBuilder->weld_button("ok"))
982  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "PREVIEW", *m_xPreview))
983  , m_xFieldsControl(new SwAssignFieldsControl(m_xBuilder->weld_scrolled_window("scroll"),
984  m_xBuilder->weld_container("FIELDS")))
985 {
986  m_xPreviewWin->set_size_request(m_xMatchingFI->get_approximate_digit_width() * 45,
987  m_xMatchingFI->get_text_height() * 5);
988  m_xFieldsControl->Init(this, rConfigItem);
989 
990  const OUString sMatchesTo( SwResId(ST_MATCHESTO) );
991  if (!bIsAddressBlock)
992  {
993  m_xPreviewFI->set_label(SwResId(ST_SALUTATIONPREVIEW));
994  m_xMatchingFI->set_label(SwResId(ST_SALUTATIONMATCHING));
995  m_xAddressTitle->set_label(SwResId(ST_SALUTATIONELEMENT));
996  }
997 
998  m_xFieldsControl->SetModifyHdl(LINK(this, SwAssignFieldsDialog, AssignmentModifyHdl_Impl ));
999  m_xMatchingFI->set_label(m_xMatchingFI->get_label().replaceAll("%1", sMatchesTo));
1000  m_xOK->connect_clicked(LINK(this, SwAssignFieldsDialog, OkHdl_Impl));
1001 }
1002 
1004 {
1005 }
1006 
1007 uno::Sequence< OUString > SwAssignFieldsDialog::CreateAssignments()
1008 {
1009  uno::Sequence< OUString > aAssignments(
1011  OUString* pAssignments = aAssignments.getArray();
1012  sal_Int32 nIndex = 0;
1013  for (const auto& rLBItem : m_xFieldsControl->m_aFields)
1014  {
1015  const OUString sSelect = rLBItem.m_xComboBox->get_active_text();
1016  pAssignments[nIndex] = (m_sNone != sSelect) ? sSelect : OUString();
1017  ++nIndex;
1018  }
1019  return aAssignments;
1020 }
1021 
1023 {
1026  CreateAssignments() );
1027  m_xDialog->response(RET_OK);
1028 }
1029 
1030 IMPL_LINK_NOARG(SwAssignFieldsDialog, AssignmentModifyHdl_Impl, LinkParamNone*, void)
1031 {
1032  uno::Sequence< OUString > aAssignments = CreateAssignments();
1033  const OUString sPreview = SwAddressPreview::FillData(
1034  m_rPreviewString, m_rConfigItem, &aAssignments);
1035  m_xPreview->SetAddress(sPreview);
1036 }
1037 
1038 void SwAssignFieldsDialog::ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
1039 {
1040  m_xAddressTitle->set_size_request(nLabelWidth, -1);
1041  m_xMatchTitle->set_size_request(nComboBoxWidth, -1);
1042  m_xPreviewTitle->set_size_request(nPreviewWidth, -1);
1043 }
1044 
1045 namespace
1046 {
1047  const EECharAttrib* FindCharAttrib(int nStartPosition, std::vector<EECharAttrib>& rAttribList)
1048  {
1049  for (auto it = rAttribList.rbegin(); it != rAttribList.rend(); ++it)
1050  {
1051  const auto& rTextAtr = *it;
1052  if (rTextAtr.pAttr->Which() != EE_CHAR_GRABBAG)
1053  continue;
1054  if (rTextAtr.nStart <= nStartPosition && rTextAtr.nEnd >= nStartPosition)
1055  {
1056  return &rTextAtr;
1057  }
1058  }
1059 
1060  return nullptr;
1061  }
1062 }
1063 
1065  : m_pParentDialog(pParent)
1066 {
1067 }
1068 
1070 {
1071  if (m_xDropTarget.is())
1072  {
1073  m_xEditEngine->RemoveView(m_xEditView.get());
1074  auto xRealDropTarget = GetDrawingArea()->get_drop_target();
1075  uno::Reference<css::datatransfer::dnd::XDropTargetListener> xListener(m_xDropTarget, uno::UNO_QUERY);
1076  xRealDropTarget->removeDropTargetListener(xListener);
1077  m_xDropTarget.clear();
1078  }
1079 }
1080 
1082 {
1083  assert(!m_xDropTarget.is());
1084 }
1085 
1087 {
1088  Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(160, 60), MapMode(MapUnit::MapAppFont)));
1089  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
1090  WeldEditView::SetDrawingArea(pDrawingArea);
1091 }
1092 
1094 {
1095  if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
1096  return false; // we want default esc behaviour
1097  if (rKEvt.GetCharCode())
1098  return true; // handled
1099  return WeldEditView::KeyInput(rKEvt);
1100 }
1101 
1103 {
1104  if (rMEvt.GetClicks() >= 2)
1105  return true; // handled
1106  return WeldEditView::MouseButtonDown(rMEvt);
1107 }
1108 
1110 {
1111  return m_xEditEngine->GetText();
1112 }
1113 
1114 void AddressMultiLineEdit::SetText( const OUString& rStr )
1115 {
1116  m_xEditEngine->SetText(rStr);
1117  //set attributes to all address tokens
1118 
1119  sal_Int32 nSequence(0);
1120  SfxGrabBagItem aProtectAttr(EE_CHAR_GRABBAG);
1121  const sal_uInt32 nParaCount = m_xEditEngine->GetParagraphCount();
1122  for(sal_uInt32 nPara = 0; nPara < nParaCount; ++nPara)
1123  {
1124  sal_Int32 nIndex = 0;
1125  const OUString sPara = m_xEditEngine->GetText( nPara );
1126  if (!sPara.isEmpty() && !sPara.endsWith(" "))
1127  {
1128  ESelection aPaM(nPara, sPara.getLength(), nPara, sPara.getLength());
1129  m_xEditEngine->QuickInsertText(" ", aPaM);
1130  }
1131  for(;;)
1132  {
1133  const sal_Int32 nStart = sPara.indexOf( '<', nIndex );
1134  if (nStart < 0)
1135  break;
1136  const sal_Int32 nEnd = sPara.indexOf( '>', nStart );
1137  if (nEnd < 0)
1138  break;
1139  nIndex = nEnd;
1140  SfxItemSet aSet(m_xEditEngine->GetEmptyItemSet());
1141  // make each one different, so they are not collapsed together
1142  // as one attribute
1143  aProtectAttr.GetGrabBag()["Index"] <<= nSequence++;
1144  aSet.Put(aProtectAttr);
1145  m_xEditEngine->QuickSetAttribs(aSet, ESelection(nPara, nStart, nPara, nEnd + 1));
1146  }
1147 
1148  }
1149  // add two empty paragraphs at the end
1152  {
1153  sal_Int32 nLastLen = m_xEditEngine->GetText(nParaCount - 1).getLength();
1154  if(nLastLen)
1155  {
1156  int nPara = nParaCount ? nParaCount - 1 : 0;
1157  ESelection aPaM(nPara, nLastLen, nPara, nLastLen);
1158  m_xEditEngine->QuickInsertText("\n \n ", aPaM);
1159  }
1160  }
1161 
1162  m_xEditView->SetSelection(ESelection(0, 0, 0, 0));
1163 }
1164 
1165 // Insert the new entry in front of the entry at the beginning of the selection
1166 void AddressMultiLineEdit::InsertNewEntry( const OUString& rStr )
1167 {
1168  // insert new entry after current selected one.
1169  ESelection aSelection = m_xEditView->GetSelection();
1170  const sal_uInt32 nPara = aSelection.nStartPara;
1171 
1172  std::vector<EECharAttrib> aAttribList;
1173  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1174 
1175  sal_Int32 nIndex = aSelection.nEndPara;
1176  const EECharAttrib* pAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1177  if(nullptr != pAttrib)
1178  nIndex = pAttrib->nEnd;
1179  InsertNewEntryAtPosition( rStr, nPara, nIndex );
1180 
1181  // select the new entry
1182  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1183  pAttrib = FindCharAttrib(nIndex, aAttribList);
1184  const sal_Int32 nEnd = pAttrib ? pAttrib->nEnd : nIndex;
1185  ESelection aEntrySel(nPara, nIndex, nPara, nEnd);
1186  m_xEditView->SetSelection(aEntrySel);
1187  Invalidate();
1188  m_aModifyLink.Call(*this);
1189 }
1190 
1191 void AddressMultiLineEdit::InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex )
1192 {
1193  ESelection aInsertPos(nPara, nIndex, nPara, nIndex);
1194  m_xEditEngine->QuickInsertText(rStr, aInsertPos);
1195 
1196  //restore the attributes
1197  SetText( GetAddress() );
1198 
1199  //select the newly inserted/moved element
1200  m_xEditView->SetSelection(aInsertPos);
1201  m_aSelectionLink.Call(false);
1202 }
1203 
1205 {
1206  ESelection aSelection = m_xEditView->GetSelection();
1207 
1208  std::vector<EECharAttrib> aAttribList;
1209  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1210 
1211  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1212  if(pBeginAttrib &&
1213  (pBeginAttrib->nStart <= aSelection.nStartPos
1214  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1215  {
1216  const sal_uInt32 nPara = aSelection.nStartPara;
1217  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1218  m_xEditEngine->QuickInsertText(OUString(), aEntrySel);
1219  //restore the attributes
1220  SetText( GetAddress() );
1221  m_aModifyLink.Call(*this);
1222  }
1223 }
1224 
1226 {
1227  ESelection aSelection = m_xEditView->GetSelection();
1228 
1229  std::vector<EECharAttrib> aAttribList;
1230  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1231 
1232  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1233  if(!pBeginAttrib ||
1234  pBeginAttrib->nStart > aSelection.nStartPos ||
1235  pBeginAttrib->nEnd < aSelection.nEndPos)
1236  return;
1237 
1238  //current item has been found
1239  sal_Int32 nPara = aSelection.nStartPara;
1240  sal_Int32 nIndex = pBeginAttrib->nStart;
1241  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1242  const OUString sCurrentItem = m_xEditEngine->GetText(aEntrySel);
1243  m_xEditEngine->RemoveAttribs(aEntrySel, false, EE_CHAR_GRABBAG);
1244  m_xEditEngine->QuickInsertText(OUString(), aEntrySel);
1245  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1246  switch (nMove)
1247  {
1248  case MoveItemFlags::Left :
1249  if(nIndex)
1250  {
1251  //go left to find a predecessor or simple text
1252  --nIndex;
1253  const OUString sPara = m_xEditEngine->GetText( nPara );
1254  sal_Int32 nSearchIndex = sPara.lastIndexOf( '>', nIndex+1 );
1255  if( nSearchIndex != -1 && nSearchIndex == nIndex )
1256  {
1257  nSearchIndex = sPara.lastIndexOf( '<', nIndex );
1258  if( nSearchIndex != -1 )
1259  nIndex = nSearchIndex;
1260  }
1261  }
1262  break;
1263  case MoveItemFlags::Right:
1264  {
1265  //go right to find a successor or simple text
1266  ++nIndex;
1267  const EECharAttrib* pEndAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1268  if(pEndAttrib && pEndAttrib->nEnd >= nIndex)
1269  {
1270  nIndex = pEndAttrib->nEnd;
1271  }
1272  }
1273  break;
1274  case MoveItemFlags::Up :
1275  --nPara;
1276  nIndex = 0;
1277  break;
1278  case MoveItemFlags::Down :
1279  ++nPara;
1280  nIndex = 0;
1281  break;
1282  default: break;
1283  }
1284  //add a new paragraph if there is none yet
1285  if (nPara >= m_xEditEngine->GetParagraphCount())
1286  {
1287  auto nInsPara = nPara - 1;
1288  auto nInsPos = m_xEditEngine->GetTextLen( nPara - 1 );
1289  ESelection aTemp(nInsPara, nInsPos, nInsPara, nInsPos);
1290  m_xEditEngine->QuickInsertText("\n", aTemp);
1291  }
1292  InsertNewEntryAtPosition( sCurrentItem, nPara, nIndex );
1293 
1294  // select the new entry [#i40817]
1295  m_xEditEngine->GetCharAttribs(nPara, aAttribList);
1296  const EECharAttrib* pAttrib = FindCharAttrib(nIndex, aAttribList);
1297  if (pAttrib)
1298  aEntrySel = ESelection(nPara, nIndex, nPara, pAttrib->nEnd);
1299  m_xEditView->SetSelection(aEntrySel);
1300  Invalidate();
1301  m_aModifyLink.Call(*this);
1302 }
1303 
1305 {
1307  ESelection aSelection = m_xEditView->GetSelection();
1308 
1309  std::vector<EECharAttrib> aAttribList;
1310  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1311 
1312  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1313  if (pBeginAttrib &&
1314  (pBeginAttrib->nStart <= aSelection.nStartPos
1315  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1316  {
1317  if (pBeginAttrib->nStart)
1318  nRet |= MoveItemFlags::Left;
1319  //if there is an entry it can always be move to the right and down
1321  if (aSelection.nStartPara > 0)
1322  nRet |= MoveItemFlags::Up;
1323  }
1324  return nRet;
1325 }
1326 
1328 {
1329  ESelection aSelection = m_xEditView->GetSelection();
1330 
1331  std::vector<EECharAttrib> aAttribList;
1332  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1333 
1334  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1335  return (pBeginAttrib &&
1336  (pBeginAttrib->nStart <= aSelection.nStartPos
1337  && pBeginAttrib->nEnd >= aSelection.nEndPos));
1338 }
1339 
1341 {
1342  ESelection aSelection = m_xEditView->GetSelection();
1343 
1344  std::vector<EECharAttrib> aAttribList;
1345  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1346 
1347  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1348  if (pBeginAttrib &&
1349  (pBeginAttrib->nStart <= aSelection.nStartPos
1350  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1351  {
1352  const sal_uInt32 nPara = aSelection.nStartPara;
1353  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1354  return m_xEditEngine->GetText( aEntrySel );
1355  }
1356  return OUString();
1357 }
1358 
1360 {
1361  ESelection aSelection = m_xEditView->GetSelection();
1362 
1363  std::vector<EECharAttrib> aAttribList;
1364  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1365 
1366  const EECharAttrib* pBeginAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList);
1367  if (pBeginAttrib &&
1368  (pBeginAttrib->nStart <= aSelection.nStartPos
1369  && pBeginAttrib->nEnd >= aSelection.nEndPos))
1370  {
1371  const sal_uInt32 nPara = aSelection.nStartPara;
1372  ESelection aEntrySel(nPara, pBeginAttrib->nStart, nPara, pBeginAttrib->nEnd);
1373  m_xEditView->SetSelection(aEntrySel);
1374  Invalidate();
1375  }
1376 }
1377 
1379 {
1380  OUString sRet;
1381  const sal_uInt32 nParaCount = m_xEditEngine->GetParagraphCount();
1382  for(sal_uInt32 nPara = nParaCount; nPara; --nPara)
1383  {
1384  const OUString sPara = comphelper::string::stripEnd(m_xEditEngine->GetText(nPara - 1), ' ');
1385  //don't add empty trailing paragraphs
1386  if(!sRet.isEmpty() || !sPara.isEmpty())
1387  {
1388  sRet = sPara + sRet;
1389  //insert the para break
1390  if(nPara > 1)
1391  sRet = "\n" + sRet;
1392  }
1393  }
1394  return sRet;
1395 }
1396 
1398 {
1399  ESelection aSelection = m_xEditView->GetSelection();
1400 
1401  //restore the attributes
1402  SetText( GetAddress() );
1403 
1404  //reselect the element
1405  m_xEditView->SetSelection(aSelection);
1406  m_aSelectionLink.Call(false);
1407 }
1408 
1410 {
1412  m_aSelectionLink.Call(true);
1413 }
1414 
1415 namespace
1416 {
1417  // sit between the tree as drag source and the editview as drop target and translate
1418  // the tree dnd data to the simple string the editview wants
1419  class DropTargetListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDropTargetListener,
1420  css::datatransfer::dnd::XDropTarget >
1421  {
1422  private:
1423  css::uno::Reference<css::datatransfer::dnd::XDropTarget> m_xRealDropTarget;
1424  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
1425  SwCustomizeAddressBlockDialog* m_pParentDialog;
1426 
1427  // XEventListener
1428  virtual void SAL_CALL disposing( const css::lang::EventObject& ) override
1429  {
1430  m_xRealDropTarget.clear();
1431  m_aListeners.clear();
1432  }
1433 
1434  // XDropTargetListener
1435  virtual void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override
1436  {
1437  SolarMutexGuard aGuard;
1438 
1439  auto aReplacement(dtde);
1440 
1441  Point aMousePos(dtde.LocationX, dtde.LocationY);
1442  bool bAllowed = m_pParentDialog->SetCursorLogicPosition(aMousePos);
1443  if (bAllowed)
1444  {
1445  if (weld::TreeView* pTree = m_pParentDialog->get_drag_source())
1446  {
1447  int nEntry = pTree->get_selected_index();
1448  if (nEntry != -1)
1449  {
1450  sal_Int32 nUserData = pTree->get_id(nEntry).toInt32();
1451  //special entries can only be once in the address / greeting
1452  if (nUserData >= 0 || !m_pParentDialog->HasItem(nUserData))
1453  {
1455  xContainer->CopyString( "<" + pTree->get_text(nEntry) + ">" );
1456 
1457  // replace what the treeview is offering with what ImpEditView::drop wants
1458  aReplacement.Transferable = xContainer.get();
1459  }
1460  }
1461  }
1462  }
1463 
1464  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1465  for (auto const& listener : aListeners)
1466  listener->drop(aReplacement);
1467 
1468  if (bAllowed)
1469  m_pParentDialog->UpdateFields();
1470  }
1471 
1472  virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override
1473  {
1474  auto aReplacement(dtdee);
1475  // replace what the treeview is offering with what ImpEditView::dragEnter wants
1476  aReplacement.SupportedDataFlavors.realloc(1);
1477  SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aReplacement.SupportedDataFlavors.getArray()[0]);
1478 
1479  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1480  for (auto const& listener : aListeners)
1481  listener->dragEnter(aReplacement);
1482  }
1483 
1484  virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override
1485  {
1486  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1487  for (auto const& listener : aListeners)
1488  listener->dragExit( dte );
1489  }
1490 
1491  virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override
1492  {
1493  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1494  for (auto const& listener : aListeners)
1495  listener->dragOver( dtde );
1496  }
1497 
1498  virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override
1499  {
1500  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(m_aListeners);
1501  for (auto const& listener : aListeners)
1502  listener->dropActionChanged( dtde );
1503  }
1504 
1505  // XDropTarget
1506  virtual void SAL_CALL addDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) override
1507  {
1508  m_aListeners.push_back(xListener);
1509  }
1510 
1511  virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) override
1512  {
1513  m_aListeners.erase(std::remove(m_aListeners.begin(), m_aListeners.end(), xListener), m_aListeners.end());
1514  }
1515 
1516  virtual sal_Bool SAL_CALL isActive() override
1517  {
1518  return m_xRealDropTarget->isActive();
1519  }
1520 
1521  virtual void SAL_CALL setActive(sal_Bool active) override
1522  {
1523  m_xRealDropTarget->setActive(active);
1524  }
1525 
1526  virtual sal_Int8 SAL_CALL getDefaultActions() override
1527  {
1528  return m_xRealDropTarget->getDefaultActions();
1529  }
1530 
1531  virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override
1532  {
1533  m_xRealDropTarget->setDefaultActions(actions);
1534  }
1535 
1536  public:
1537  DropTargetListener(css::uno::Reference<css::datatransfer::dnd::XDropTarget> xRealDropTarget,
1538  SwCustomizeAddressBlockDialog* pParentDialog)
1539  : m_xRealDropTarget(xRealDropTarget)
1540  , m_pParentDialog(pParentDialog)
1541  {
1542  }
1543  };
1544 }
1545 
1546 css::uno::Reference<css::datatransfer::dnd::XDropTarget> AddressMultiLineEdit::GetDropTarget()
1547 {
1548  if (!m_xDropTarget.is())
1549  {
1550  auto xRealDropTarget = GetDrawingArea()->get_drop_target();
1551  rtl::Reference<DropTargetListener> pProxy = new DropTargetListener(xRealDropTarget, m_pParentDialog);
1552  xRealDropTarget->addDropTargetListener(pProxy);
1553  m_xDropTarget = pProxy;
1554  }
1555  return m_xDropTarget;
1556 }
1557 
1559 {
1560  Point aMousePos = EditViewOutputDevice().PixelToLogic(rPosition);
1561  m_xEditView->SetCursorLogicPosition(aMousePos, false, true);
1562 
1563  ESelection aSelection = m_xEditView->GetSelection();
1564  std::vector<EECharAttrib> aAttribList;
1565  m_xEditEngine->GetCharAttribs(aSelection.nStartPara, aAttribList);
1566  return FindCharAttrib(aSelection.nStartPos, aAttribList) == nullptr;
1567 }
1568 
1569 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nEnd
OString stripEnd(const OString &rIn, char c)
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
std::unique_ptr< SwAddressPreview > m_xPreview
void SetAddress(const OUString &rAddress)
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
constexpr OStringLiteral HID_MM_ADDBLOCK_REMOVE
Definition: helpids.h:107
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
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
constexpr OStringLiteral HID_MM_ADDBLOCK_PREVIEW
Definition: helpids.h:109
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)
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
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
std::unique_ptr< weld::Button > m_xUpIB
constexpr OStringLiteral HID_MM_ADDBLOCK_DRAG
Definition: helpids.h:108
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
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
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
constexpr OStringLiteral HID_MM_ADDBLOCK_ELEMENTS
Definition: helpids.h:105
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
constexpr tools::Long Top() const
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
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
constexpr tools::Long Bottom() const
std::unique_ptr< weld::Button > m_xOK
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT 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)
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)
constexpr OStringLiteral HID_MM_ADDBLOCK_INSERT
Definition: helpids.h:106
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
virtual void set_size_request(int nWidth, int nHeight)=0
SwMailMergeConfigItem * m_rConfigItem
void SetModifyHdl(const Link< LinkParamNone *, void > &rModifyHdl)
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
constexpr OStringLiteral HID_MM_ADDBLOCK_MOVEBUTTONS
Definition: helpids.h:110
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)