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 <vcl/fixed.hxx>
25 #include <vcl/weld.hxx>
26 #include <vcl/txtattr.hxx>
27 #include <vcl/xtextedt.hxx>
28 #include <vcl/textview.hxx>
29 #include <vcl/builderfactory.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <vcl/treelistentry.hxx>
32 #include <mmconfigitem.hxx>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/sdbc/SQLException.hpp>
35 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
36 #include <com/sun/star/sdb/XColumn.hpp>
37 #include <comphelper/string.hxx>
38 #include <sal/log.hxx>
39 
40 #include <vector>
41 #include <globals.hrc>
42 #include <strings.hrc>
43 #include <dbui.hrc>
44 #include <mmaddressblockpage.hrc>
45 #include <helpids.h>
46 
47 using namespace svt;
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::container;
50 using namespace ::com::sun::star::sdb;
51 using namespace ::com::sun::star::sdbc;
52 using namespace ::com::sun::star::sdbcx;
53 
55  svt::OWizardPage(_pParent, "MMAddressBlockPage",
56  "modules/swriter/ui/mmaddressblockpage.ui")
57  , m_pWizard(_pParent)
58 {
59  get(m_pAddressListPB, "addresslist");
60  get(m_pCurrentAddressFI, "currentaddress");
61  get(m_pStep2, "step2");
62  get(m_pStep3, "step3");
63  get(m_pStep4, "step4");
64  get(m_pSettingsFI, "settingsft");
65  get(m_pAddressCB, "address");
66  get(m_pSettingsWIN, "settingspreview");
67  Size aSize(LogicToPixel(Size(164 , 45), MapMode(MapUnit::MapAppFont)));
70  get(m_pSettingsPB, "settings");
71  get(m_pHideEmptyParagraphsCB, "hideempty");
72  get(m_pAssignPB, "assign");
73  get(m_pPreviewWIN, "addresspreview");
74  aSize = LogicToPixel(Size(176, 46), MapMode(MapUnit::MapAppFont));
77  get(m_pDocumentIndexFI, "documentindex");
78  get(m_pPrevSetIB, "prev");
79  get(m_pNextSetIB, "next");
81  m_sChangeAddress = get<Button>("differentlist")->GetText();
82 
84  m_pAddressListPB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AddressListHdl_Impl));
85  m_pSettingsPB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, SettingsHdl_Impl));
86  m_pAssignPB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AssignHdl_Impl ));
87  m_pAddressCB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockHdl_Impl));
88  m_pSettingsWIN->SetSelectHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl));
90 
91  Link<Button*,void> aLink = LINK(this, SwMailMergeAddressBlockPage, InsertDataHdl_Impl);
92  m_pPrevSetIB->SetClickHdl(aLink);
93  m_pNextSetIB->SetClickHdl(aLink);
94 }
95 
97 {
98  disposeOnce();
99 }
100 
102 {
105  m_pStep2.clear();
106  m_pStep3.clear();
107  m_pStep4.clear();
113  m_pAssignPB.clear();
118  m_pWizard.clear();
120 }
121 
123 {
124  return m_pWizard->GetConfigItem().GetResultSet().is();
125 }
126 
128 {
130  bool bIsLetter = rConfigItem.IsOutputToLetter();
131 
132  //no address block is created for e-Mail
133  m_pStep2->Show(bIsLetter);
134  m_pStep3->Show(bIsLetter);
135  m_pStep4->Show(bIsLetter);
136 
137  if (bIsLetter)
138  {
140  m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", "1"));
141 
143  const uno::Sequence< OUString> aBlocks =
145  for(sal_Int32 nAddress = 0; nAddress < aBlocks.getLength(); ++nAddress)
146  m_pSettingsWIN->AddAddress(aBlocks[nAddress]);
147  m_pSettingsWIN->SelectAddress(static_cast<sal_uInt16>(rConfigItem.GetCurrentAddressBlockIndex()));
148  m_pAddressCB->Check(rConfigItem.IsAddressBlock());
149  AddressBlockHdl_Impl(m_pAddressCB);
150  m_pSettingsWIN->SetLayout(1, 2);
151  InsertDataHdl_Impl(nullptr);
152  }
153 }
154 
156 {
157  return ::svt::WizardTypes::eTravelForward != _eReason || m_pWizard->GetConfigItem().GetResultSet().is();
158 }
159 
161 {
162  try
163  {
164  SwAddressListDialog aAddrDialog(this);
165  if (RET_OK == aAddrDialog.run())
166  {
167  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
168  rConfigItem.SetCurrentConnection(
169  aAddrDialog.GetSource(),
170  aAddrDialog.GetConnection(),
171  aAddrDialog.GetColumnsSupplier(),
172  aAddrDialog.GetDBData());
173  OUString sFilter = aAddrDialog.GetFilter();
174  rConfigItem.SetFilter( sFilter );
175  InsertDataHdl_Impl(nullptr);
176  GetWizard()->UpdateRoadmap();
177  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
178  }
179  }
180  catch (const uno::Exception& e)
181  {
182  SAL_WARN("sw", e);
183  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
184  VclMessageType::Warning, VclButtonsType::Ok, e.Message));
185  xBox->run();
186  }
187 }
188 
190 {
191  SwSelectAddressBlockDialog aDlg(GetFrameWeld(), m_pWizard->GetConfigItem());
192  SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
193  aDlg.SetAddressBlocks(rConfig.GetAddressBlocks(), m_pSettingsWIN->GetSelectedAddress());
194  aDlg.SetSettings(rConfig.IsIncludeCountry(), rConfig.GetExcludeCountry());
195  if (aDlg.run() == RET_OK)
196  {
197  //the dialog provides the selected address at the first position!
198  const uno::Sequence< OUString> aBlocks = aDlg.GetAddressBlocks();
199  rConfig.SetAddressBlocks(aBlocks);
200  m_pSettingsWIN->Clear();
201  for(sal_Int32 nAddress = 0; nAddress < aBlocks.getLength(); ++nAddress)
202  m_pSettingsWIN->AddAddress(aBlocks[nAddress]);
203  m_pSettingsWIN->SelectAddress(0);
204  m_pSettingsWIN->Invalidate(); // #i40408
205  rConfig.SetCountrySettings(aDlg.IsIncludeCountry(), aDlg.GetCountry());
206  InsertDataHdl_Impl(nullptr);
207  }
208  GetWizard()->UpdateRoadmap();
209  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
210 }
211 
212 IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, Button*, pButton, void)
213 {
214  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
215  const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
216  const uno::Sequence< OUString> aBlocks = rConfigItem.GetAddressBlocks();
217  SwAssignFieldsDialog aDlg(pButton->GetFrameWeld(), m_pWizard->GetConfigItem(), aBlocks[nSel], true);
218  if(RET_OK == aDlg.run())
219  {
220  //preview update
221  InsertDataHdl_Impl(nullptr);
222  GetWizard()->UpdateRoadmap();
223  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
224  }
225 }
226 
227 void SwMailMergeAddressBlockPage::EnableAddressBlock(bool bAll, bool bSelective)
228 {
229  m_pSettingsFI->Enable(bAll);
230  m_pAddressCB->Enable(bAll);
231  bSelective &= bAll;
232  m_pHideEmptyParagraphsCB->Enable(bSelective);
233  m_pSettingsWIN->Enable(bSelective);
234  m_pSettingsPB->Enable(bSelective);
235  m_pStep3->Enable(bSelective);
236  m_pStep4->Enable(bSelective);
237 }
238 
239 IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, Button*, pBox, void)
240 {
241  EnableAddressBlock(pBox->IsEnabled(), static_cast<CheckBox*>(pBox)->IsChecked());
242  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
243  rConfigItem.SetAddressBlock(m_pAddressCB->IsChecked());
244  m_pWizard->UpdateRoadmap();
245  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
246 }
247 
248 IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl, LinkParamNone*, void)
249 {
250  const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
251  const uno::Sequence< OUString> aBlocks =
252  m_pWizard->GetConfigItem().GetAddressBlocks();
253  m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(aBlocks[nSel],
254  m_pWizard->GetConfigItem()));
255  m_pWizard->GetConfigItem().SetCurrentAddressBlockIndex( nSel );
256  GetWizard()->UpdateRoadmap();
257  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
258 }
259 
260 IMPL_LINK(SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl, Button*, pBox, void)
261 {
262  SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
263  rConfigItem.SetHideEmptyParagraphs( static_cast<CheckBox*>(pBox)->IsChecked() );
264 }
265 
266 IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, Button*, pButton, void)
267 {
268  //if no pButton is given, the first set has to be pre-set
269  SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
270  m_pWizard->EnterWait();
271  if(!pButton)
272  {
273  rConfig.GetResultSet();
274  }
275  else
276  {
277  bool bNext = pButton == m_pNextSetIB;
278  sal_Int32 nPos = rConfig.GetResultSetPosition();
279  rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
280  }
281  m_pWizard->LeaveWait();
282  sal_Int32 nPos = rConfig.GetResultSetPosition();
283  bool bEnable = true;
284  if(nPos < 1)
285  {
286  bEnable = false;
287  nPos = 1;
288  }
289  else
290  {
291  //if output type is letter
292  if(m_pSettingsWIN->IsVisible())
293  {
294  //Fill data into preview
295  const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
296  const uno::Sequence< OUString> aBlocks =
297  m_pWizard->GetConfigItem().GetAddressBlocks();
298  m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(aBlocks[nSel], rConfig));
299  }
300  }
301  m_pPrevSetIB->Enable(bEnable);
302  m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", OUString::number(nPos)));
303 
304  GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
305  bool bHasResultSet = rConfig.GetResultSet().is();
306  m_pCurrentAddressFI->Show(bHasResultSet);
307  if(bHasResultSet)
308  {
309  m_pCurrentAddressFI->SetText(m_sCurrentAddress.replaceFirst("%1", rConfig.GetCurrentDBData().sDataSource));
310  m_pAddressListPB->SetText(m_sChangeAddress);
311  }
312  EnableAddressBlock(bHasResultSet, m_pAddressCB->IsChecked());
313 }
314 
316  : SfxDialogController(pParent, "modules/swriter/ui/selectblockdialog.ui", "SelectBlockDialog")
317  , m_rConfig(rConfig)
318  , m_xPreview(new AddressPreview(m_xBuilder->weld_scrolled_window("previewwin")))
319  , m_xNewPB(m_xBuilder->weld_button("new"))
320  , m_xCustomizePB(m_xBuilder->weld_button("edit"))
321  , m_xDeletePB(m_xBuilder->weld_button("delete"))
322  , m_xNeverRB(m_xBuilder->weld_radio_button("never"))
323  , m_xAlwaysRB(m_xBuilder->weld_radio_button("always"))
324  , m_xDependentRB(m_xBuilder->weld_radio_button("dependent"))
325  , m_xCountryED(m_xBuilder->weld_entry("country"))
326  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", *m_xPreview))
327 {
328  m_xPreviewWin->set_size_request(m_xCountryED->get_approximate_digit_width() * 45,
329  m_xCountryED->get_text_height() * 12);
330 
331  Link<weld::Button&,void> aCustomizeHdl = LINK(this, SwSelectAddressBlockDialog, NewCustomizeHdl_Impl);
332  m_xNewPB->connect_clicked(aCustomizeHdl);
333  m_xCustomizePB->connect_clicked(aCustomizeHdl);
334 
335  m_xDeletePB->connect_clicked(LINK(this, SwSelectAddressBlockDialog, DeleteHdl_Impl));
336 
337  Link<weld::ToggleButton&,void> aLk = LINK(this, SwSelectAddressBlockDialog, IncludeHdl_Impl);
338  m_xNeverRB->connect_toggled(aLk);
339  m_xAlwaysRB->connect_toggled(aLk);
340  m_xDependentRB->connect_toggled(aLk);
341  m_xPreview->SetLayout(2, 2);
342  m_xPreview->EnableScrollBar();
343 }
344 
346 {
347 }
348 
349 void SwSelectAddressBlockDialog::SetAddressBlocks(const uno::Sequence< OUString>& rBlocks,
350  sal_uInt16 nSelectedAddress)
351 {
352  m_aAddressBlocks = rBlocks;
353  for (sal_Int32 nAddress = 0; nAddress < m_aAddressBlocks.getLength(); ++nAddress)
354  m_xPreview->AddAddress(m_aAddressBlocks[nAddress]);
355  m_xPreview->SelectAddress(nSelectedAddress);
356 }
357 
358 // return the address blocks and put the selected one to the first position
359 const uno::Sequence< OUString >& SwSelectAddressBlockDialog::GetAddressBlocks()
360 {
361  //put the selected block to the first position
362  const sal_Int32 nSelect = static_cast<sal_Int32>(m_xPreview->GetSelectedAddress());
363  if(nSelect)
364  {
365  uno::Sequence< OUString >aTemp = m_aAddressBlocks;
366  OUString* pTemp = aTemp.getArray();
367  pTemp[0] = m_aAddressBlocks[nSelect];
368  sal_Int32 nIndex = 0;
369  const sal_Int32 nNumBlocks = m_aAddressBlocks.getLength();
370  for(sal_Int32 nAddress = 1; nAddress < nNumBlocks; ++nAddress)
371  {
372  if(nIndex == nSelect)
373  ++nIndex;
374  pTemp[nAddress] = m_aAddressBlocks[nIndex];
375  nIndex++;
376  }
377  m_aAddressBlocks = aTemp;
378  }
379  return m_aAddressBlocks;
380 }
381 
383  bool bIsCountry, const OUString& rCountry)
384 {
385  weld::RadioButton *pActive = m_xNeverRB.get();
386  if(bIsCountry)
387  {
388  pActive = !rCountry.isEmpty() ? m_xDependentRB.get() : m_xAlwaysRB.get();
389  m_xCountryED->set_text(rCountry);
390  }
391  pActive->set_active(true);
392  IncludeHdl_Impl(*pActive);
393  m_xDeletePB->set_sensitive(m_aAddressBlocks.getLength() > 1);
394 }
395 
397 {
398  if (m_xDependentRB->get_active())
399  return m_xCountryED->get_text();
400  return OUString();
401 }
402 
403 IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, weld::Button&, rButton, void)
404 {
405  if(m_aAddressBlocks.getLength())
406  {
407  const sal_Int32 nSelected = static_cast<sal_Int32>(m_xPreview->GetSelectedAddress());
408  OUString* pAddressBlocks = m_aAddressBlocks.getArray();
409  sal_Int32 nSource = 0;
410  for(sal_Int32 nTarget = 0; nTarget < m_aAddressBlocks.getLength() - 1; nTarget++)
411  {
412  if(nSource == nSelected)
413  ++nSource;
414  pAddressBlocks[nTarget] = pAddressBlocks[nSource++];
415  }
416  m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() - 1);
417  if (m_aAddressBlocks.getLength() <= 1)
418  rButton.set_sensitive(false);
419  m_xPreview->RemoveSelectedAddress();
420  }
421 }
422 
423 IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, weld::Button&, rButton, void)
424 {
425  bool bCustomize = &rButton == m_xCustomizePB.get();
431  nullptr /*TODO*/,m_rConfig,nType));
432  if(bCustomize)
433  {
434  pDlg->SetAddress(m_aAddressBlocks[m_xPreview->GetSelectedAddress()]);
435  }
436  if(RET_OK == pDlg->Execute())
437  {
438  const OUString sNew = pDlg->GetAddress();
439  if(bCustomize)
440  {
441  m_xPreview->ReplaceSelectedAddress(sNew);
442  m_aAddressBlocks[m_xPreview->GetSelectedAddress()] = sNew;
443  }
444  else
445  {
446  m_xPreview->AddAddress(sNew);
447  m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() + 1);
448  const sal_Int32 nSelect = m_aAddressBlocks.getLength() - 1;
449  m_aAddressBlocks[nSelect] = sNew;
450  m_xPreview->SelectAddress(static_cast<sal_uInt16>(nSelect));
451  }
452  m_xDeletePB->set_sensitive(m_aAddressBlocks.getLength() > 1);
453  }
454 }
455 
457 {
458  m_xCountryED->set_sensitive(m_xDependentRB->get_active());
459 }
460 
461 #define USER_DATA_SALUTATION -1
462 #define USER_DATA_PUNCTUATION -2
463 #define USER_DATA_TEXT -3
464 #define USER_DATA_NONE -4
465 
467  vcl::Window* pParent, SwMailMergeConfigItem& rConfig, DialogType eType)
468  : SfxModalDialog(pParent, "AddressBlockDialog",
469  "modules/swriter/ui/addressblockdialog.ui")
470  , m_aTextFilter("<>")
471  , m_rConfigItem(rConfig)
472  , m_eType(eType)
473 {
474  get(m_pOK, "ok");
475  get(m_pPreviewWIN, "addrpreview");
476  get(m_pFieldCB, "custom");
478  get(m_pFieldFT, "customft");
479  get(m_pDownIB, "down");
480  get(m_pRightIB, "right");
481  get(m_pLeftIB, "left");
482  get(m_pUpIB, "up");
483  get(m_pDragED, "addressdest");
485  get(m_pDragFT, "addressdestft");
486  get(m_pRemoveFieldIB, "fromaddr");
487  get(m_pInsertFieldIB, "toaddr");
488  get(m_pAddressElementsLB, "addresses");
491  get(m_pAddressElementsFT, "addressesft");
492 
493  if( eType >= GREETING_FEMALE )
494  {
495  m_pFieldFT->Show();
496  m_pFieldCB->Show();
497  SvTreeListEntry* pEntry = m_pAddressElementsLB->InsertEntry(SwResId(ST_SALUTATION));
498  pEntry->SetUserData(reinterpret_cast<void*>(sal_Int32(USER_DATA_SALUTATION)) );
499  pEntry = m_pAddressElementsLB->InsertEntry(SwResId(ST_PUNCTUATION));
500  pEntry->SetUserData(reinterpret_cast<void*>(sal_Int32(USER_DATA_PUNCTUATION)) );
501  pEntry = m_pAddressElementsLB->InsertEntry(SwResId(ST_TEXT));
502  pEntry->SetUserData(reinterpret_cast<void*>(sal_Int32(USER_DATA_TEXT)) );
503  for (size_t i = 0; i < SAL_N_ELEMENTS(RA_SALUTATION); ++i)
504  m_aSalutations.push_back(SwResId(RA_SALUTATION[i]));
505  for (size_t i = 0; i < SAL_N_ELEMENTS(RA_PUNCTUATION); ++i)
506  m_aPunctuations.push_back(SwResId(RA_PUNCTUATION[i]));
507  m_pDragED->SetText(" ");
508  SetText(SwResId(eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE));
509  m_pAddressElementsFT->SetText(SwResId(ST_SALUTATIONELEMENTS));
510  m_pInsertFieldIB->SetQuickHelpText(SwResId(ST_INSERTSALUTATIONFIELD));
511  m_pRemoveFieldIB->SetQuickHelpText(SwResId(ST_REMOVESALUTATIONFIELD));
512  m_pDragFT->SetText(SwResId(ST_DRAGSALUTATION));
513  }
514  else
515  {
516  if(eType == ADDRESSBLOCK_EDIT)
517  SetText(SwResId(ST_TITLE_EDIT));
518  m_pDragED->SetText("\n\n\n\n\n");
519  /* Set custom HIDs for swriter/01/mm_newaddblo.xhp */
529  }
530 
531  const std::vector<std::pair<OUString, int>>& rHeaders = m_rConfigItem.GetDefaultAddressHeaders();
532  for (size_t i = 0; i < rHeaders.size(); ++i)
533  {
535  pEntry->SetUserData(reinterpret_cast<void*>(static_cast<sal_IntPtr>(i)));
536  }
538  m_pAddressElementsLB->SetSelectHdl(LINK(this, SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl ));
539  m_pDragED->SetModifyHdl(LINK(this, SwCustomizeAddressBlockDialog, EditModifyHdl_Impl));
540  m_pDragED->SetSelectionChangedHdl( LINK( this, SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl));
541  Link<Edit&,void> aFieldsLink = LINK(this, SwCustomizeAddressBlockDialog, FieldChangeHdl_Impl);
542  m_pFieldCB->SetModifyHdl(aFieldsLink);
543  m_pFieldCB->SetSelectHdl(LINK(this, SwCustomizeAddressBlockDialog, FieldChangeComboBoxHdl_Impl));
544  Link<Button*,void> aImgButtonHdl = LINK(this, SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl);
545  m_pInsertFieldIB->SetClickHdl(aImgButtonHdl);
546  m_pRemoveFieldIB->SetClickHdl(aImgButtonHdl);
547  m_pUpIB->SetClickHdl(aImgButtonHdl);
548  m_pLeftIB->SetClickHdl(aImgButtonHdl);
549  m_pRightIB->SetClickHdl(aImgButtonHdl);
550  m_pDownIB->SetClickHdl(aImgButtonHdl);
552 }
553 
555 {
556  disposeOnce();
557 }
558 
560 {
565  m_pDragFT.clear();
566  m_pDragED.clear();
567  m_pUpIB.clear();
568  m_pLeftIB.clear();
569  m_pRightIB.clear();
570  m_pDownIB.clear();
571  m_pFieldFT.clear();
572  m_pFieldCB.clear();
574  m_pOK.clear();
576 }
577 
579 {
580  EndDialog(RET_OK);
581 }
582 
583 IMPL_LINK(SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl, SvTreeListBox*, pBox, void)
584 {
585  sal_Int32 nUserData = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pBox->FirstSelected()->GetUserData()));
586  // Check if the selected entry is already in the address and then forbid inserting
587  m_pInsertFieldIB->Enable(nUserData >= 0 || !HasItem_Impl(nUserData));
588 }
589 
591 {
592  m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(GetAddress(), m_rConfigItem));
593  UpdateImageButtons_Impl();
594 }
595 
596 IMPL_LINK(SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl, Button*, pButton, void)
597 {
598  if (m_pInsertFieldIB == pButton)
599  {
600  SvTreeListEntry* pEntry = m_pAddressElementsLB->GetCurEntry();
601  if(pEntry)
602  {
603  m_pDragED->InsertNewEntry("<" + m_pAddressElementsLB->GetEntryText(pEntry) + ">");
604  }
605  }
606  else if (m_pRemoveFieldIB == pButton)
607  {
608  m_pDragED->RemoveCurrentEntry();
609  }
610  else
611  {
613  if (m_pUpIB == pButton)
614  nMove = MoveItemFlags::Up;
615  else if (m_pLeftIB == pButton)
616  nMove = MoveItemFlags::Left;
617  else if (m_pRightIB == pButton)
618  nMove = MoveItemFlags::Right;
619  m_pDragED->MoveCurrentItem(nMove);
620  }
621  UpdateImageButtons_Impl();
622 }
623 
625 {
626  sal_Int32 nRet = USER_DATA_NONE;
627  const OUString sSelected = m_pDragED->GetCurrentItem();
628  if(!sSelected.isEmpty())
629  for(sal_uLong i = 0; i < m_pAddressElementsLB->GetEntryCount(); ++i)
630  {
632  const OUString sEntry = m_pAddressElementsLB->GetEntryText(pEntry);
633  if( sEntry == sSelected.copy( 1, sSelected.getLength() - 2 ) )
634  {
635  nRet = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()));
636  break;
637  }
638  }
639  return nRet;
640 }
641 
643 {
644  //get the entry from the ListBox
645  OUString sEntry;
646  for(sal_uLong i = 0; i < m_pAddressElementsLB->GetEntryCount(); ++i)
647  {
649  if(static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData())) == nUserData)
650  {
651  sEntry = m_pAddressElementsLB->GetEntryText(pEntry);
652  break;
653  }
654  }
655  //search for this entry in the content
656  return m_pDragED->GetText().indexOf("<" + sEntry + ">") >= 0;
657 }
658 
659 IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, AddressMultiLineEdit&, rEdit, void)
660 {
661  // called in case the selection of the edit field changes.
662  // determine selection - if it's one of the editable fields then
663  // enable the related ComboBox and fill it
664  static bool bOnEntry = false;
665  if(bOnEntry)
666  return;
667 
668  bOnEntry = true;
669  sal_Int32 nSelected = GetSelectedItem_Impl();
670  if(USER_DATA_NONE != nSelected)
671  rEdit.SelectCurrentItem();
672 
673  if(m_pFieldCB->IsVisible() && (USER_DATA_NONE != nSelected) && (nSelected < 0))
674  {
675  //search in ListBox if it's one of the first entries
676  OUString sSelect;
677  std::vector<OUString>* pVector = nullptr;
678  switch(nSelected) {
680  sSelect = m_sCurrentSalutation;
681  pVector = &m_aSalutations;
682  break;
684  sSelect = m_sCurrentPunctuation;
685  pVector = &m_aPunctuations;
686  break;
687  case USER_DATA_TEXT:
688  sSelect = m_sCurrentText;
689  break;
690  }
691  m_pFieldCB->Clear();
692  if(pVector) {
693  for (const auto& rItem : *pVector)
694  m_pFieldCB->InsertEntry(rItem);
695  }
696  m_pFieldCB->SetText(sSelect);
697  m_pFieldCB->Enable();
698  m_pFieldFT->Enable();
699  }
700  else
701  {
702  m_pFieldCB->Enable(false);
703  m_pFieldFT->Enable(false);
704  }
705 
706  UpdateImageButtons_Impl();
707  bOnEntry = false;
708 }
709 
710 IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, FieldChangeComboBoxHdl_Impl, ComboBox&, void)
711 {
712  FieldChangeHdl_Impl(*m_pFieldCB);
713 }
715 {
716  //changing the field content changes the related members, too
717  sal_Int32 nSelected = GetSelectedItem_Impl();
718  const OUString sContent = m_pFieldCB->GetText();
719  switch(nSelected) {
721  m_sCurrentSalutation = sContent;
722  break;
724  m_sCurrentPunctuation = sContent;
725  break;
726  case USER_DATA_TEXT:
727  m_sCurrentText = sContent;
728  break;
729  }
730  UpdateImageButtons_Impl();
731  m_pPreviewWIN->SetAddress(GetAddress());
732  m_pDragED->Modify();
733 }
734 
736 {
738  m_pUpIB->Enable( bool(nMove & MoveItemFlags::Up) );
739  m_pLeftIB->Enable( bool(nMove & MoveItemFlags::Left) );
740  m_pRightIB->Enable( bool(nMove & MoveItemFlags::Right) );
741  m_pDownIB->Enable( bool(nMove & MoveItemFlags::Down) );
744  m_pInsertFieldIB->Enable( pEntry &&
745  (0 < static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData())) || !m_pFieldCB->GetText().isEmpty()));
746 }
747 
748 void SwCustomizeAddressBlockDialog::SetAddress(const OUString& rAddress)
749 {
750  m_pDragED->SetText( rAddress );
752  m_pDragED->Modify();
753 }
754 
756 {
757  OUString sAddress(m_pDragED->GetAddress());
758  //remove placeholders by the actual content
759  if(m_pFieldFT->IsVisible())
760  {
761  for(sal_uLong i = 0; i < m_pAddressElementsLB->GetEntryCount(); ++i)
762  {
764  const OUString sEntry = "<" + m_pAddressElementsLB->GetEntryText(pEntry) + ">";
765  sal_Int32 nUserData = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()));
766  switch(nUserData)
767  {
769  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentSalutation);
770  break;
772  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentPunctuation);
773  break;
774  case USER_DATA_TEXT:
775  sAddress = sAddress.replaceFirst(sEntry, m_sCurrentText);
776  break;
777  }
778  }
779  }
780  return sAddress;
781 }
782 
784 {
785  std::unique_ptr<weld::Builder> m_xBuilder;
786  std::unique_ptr<weld::Label> m_xLabel;
787  std::unique_ptr<weld::ComboBox> m_xComboBox;
788  std::unique_ptr<weld::Label> m_xPreview;
789 
791  : m_xBuilder(Application::CreateBuilder(pGrid, "modules/swriter/ui/assignfragment.ui"))
792  , m_xLabel(m_xBuilder->weld_label("label"))
793  , m_xComboBox(m_xBuilder->weld_combo_box("combobox"))
794  , m_xPreview(m_xBuilder->weld_label("preview"))
795  {
796  m_xLabel->set_grid_left_attach(0);
797  m_xLabel->set_grid_top_attach(nLine);
798 
799  m_xComboBox->set_grid_left_attach(1);
800  m_xComboBox->set_grid_top_attach(nLine);
801 
802  m_xPreview->set_grid_left_attach(2);
803  m_xPreview->set_grid_top_attach(nLine);
804  }
805 };
806 
808 {
809  friend class SwAssignFieldsDialog;
810  std::unique_ptr<weld::ScrolledWindow> m_xVScroll;
811  std::unique_ptr<weld::Container> m_xGrid;
812 
813  std::vector<SwAssignFragment> m_aFields;
814 
816 
818 
819  DECL_LINK(MatchHdl_Impl, weld::ComboBox&, void);
820  DECL_LINK(GotFocusHdl_Impl, weld::Widget&, void);
821 
822  void MakeVisible(const tools::Rectangle & rRect);
823 public:
824  SwAssignFieldsControl(std::unique_ptr<weld::ScrolledWindow> xWindow,
825  std::unique_ptr<weld::Container> xGrid);
826 
827  void Init(SwAssignFieldsDialog* pDialog, SwMailMergeConfigItem& rConfigItem);
828  void SetModifyHdl(const Link<LinkParamNone*,void>& rModifyHdl)
829  {
830  m_aModifyHdl = rModifyHdl;
831  m_aModifyHdl.Call(nullptr);
832  }
833 };
834 
835 SwAssignFieldsControl::SwAssignFieldsControl(std::unique_ptr<weld::ScrolledWindow> xWindow,
836  std::unique_ptr<weld::Container> xGrid)
837  : m_xVScroll(std::move(xWindow))
838  , m_xGrid(std::move(xGrid))
839  , m_rConfigItem(nullptr)
840 {
841 }
842 
844 {
845  m_rConfigItem = &rConfigItem;
846 
847  //get the name of the default headers
848  const std::vector<std::pair<OUString, int>>& rHeaders = rConfigItem.GetDefaultAddressHeaders();
849  //get the actual data
850  uno::Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), uno::UNO_QUERY);
851  //get the name of the actual columns
852  uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
853  uno::Sequence< OUString > aFields;
854  if(xColAccess.is())
855  aFields = xColAccess->getElementNames();
856  const OUString* pFields = aFields.getConstArray();
857 
858  //get the current assignment list
859  //each position in this sequence matches the position in the header array rHeaders
860  //if no assignment is available an empty sequence will be returned
861  uno::Sequence< OUString> aAssignments = rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
862  Link<weld::ComboBox&,void> aMatchHdl = LINK(this, SwAssignFieldsControl, MatchHdl_Impl);
863  Link<weld::Widget&,void> aFocusHdl = LINK(this, SwAssignFieldsControl, GotFocusHdl_Impl);
864 
865  int nLabelWidth(0), nComboBoxWidth(0), nPreviewWidth(0);
866 
867  //fill the controls
868  for (size_t i = 0; i < rHeaders.size(); ++i)
869  {
870  m_aFields.emplace_back(m_xGrid.get(), i);
871 
872  const OUString rHeader = rHeaders[i].first;
873  weld::ComboBox& rNewLB = *m_aFields.back().m_xComboBox;
874  rNewLB.append_text(SwResId(SW_STR_NONE));
875  rNewLB.set_active(0);
876 
877  for (sal_Int32 nField = 0; nField < aFields.getLength(); ++nField)
878  rNewLB.append_text(pFields[nField]);
879  //select the ListBox
880  //if there is an assignment
881  if(static_cast<sal_uInt32>(aAssignments.getLength()) > i && !aAssignments[i].isEmpty())
882  rNewLB.set_active_text(aAssignments[i]);
883  else //otherwise the current column name may match one of the db columns
884  rNewLB.set_active_text(rHeader);
885 
886  weld::Label& rNewText = *m_aFields.back().m_xLabel;
887  rNewText.set_label("<" + rHeader + ">");
888 
889  weld::Label& rNewPreview = *m_aFields.back().m_xPreview;
890  //then the preview can be filled accordingly
891  if (xColAccess.is() && rNewLB.get_active() > 0 &&
892  xColAccess->hasByName(rNewLB.get_active_text()))
893  {
894  uno::Any aCol = xColAccess->getByName(rNewLB.get_active_text());
895  uno::Reference< XColumn > xColumn;
896  aCol >>= xColumn;
897  if(xColumn.is())
898  {
899  try
900  {
901  rNewPreview.set_label(xColumn->getString());
902  }
903  catch (const SQLException&)
904  {
905  }
906  }
907  }
908 
909  if (i == 0)
910  {
911  auto nLineHeight = m_xGrid->get_preferred_size().Height();
912  m_xVScroll->set_size_request(m_xVScroll->get_approximate_digit_width() * 65,
913  nLineHeight * 6);
914  nComboBoxWidth = rNewLB.get_preferred_size().Width();
915  }
916 
917  nLabelWidth = std::max<int>(nLabelWidth, rNewText.get_preferred_size().Width());
918  nPreviewWidth = std::max<int>(nPreviewWidth, rNewPreview.get_preferred_size().Width());
919 
920  rNewLB.connect_changed(aMatchHdl);
921  rNewLB.connect_focus_in(aFocusHdl);
922  rNewText.show();
923  rNewLB.show();
924  rNewPreview.show();
925  }
926  pDialog->ConnectSizeGroups(nLabelWidth, nComboBoxWidth, nPreviewWidth);
927 }
928 
930 {
931  //determine range of visible positions
932  auto nMinVisiblePos = m_xVScroll->vadjustment_get_value();
933  auto nMaxVisiblePos = nMinVisiblePos + m_xVScroll->vadjustment_get_page_size();
934  if (rRect.Top() < nMinVisiblePos || rRect.Bottom() > nMaxVisiblePos)
935  m_xVScroll->vadjustment_set_value(rRect.Top());
936 }
937 
938 IMPL_LINK(SwAssignFieldsControl, MatchHdl_Impl, weld::ComboBox&, rBox, void)
939 {
940  const OUString sColumn = rBox.get_active_text();
941  uno::Reference< XColumnsSupplier > xColsSupp( m_rConfigItem->GetResultSet(), uno::UNO_QUERY);
942  uno::Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr;
943  OUString sPreview;
944  if(xColAccess.is() && xColAccess->hasByName(sColumn))
945  {
946  uno::Any aCol = xColAccess->getByName(sColumn);
947  uno::Reference< XColumn > xColumn;
948  aCol >>= xColumn;
949  if(xColumn.is())
950  {
951  try
952  {
953  sPreview = xColumn->getString();
954  }
955  catch (const sdbc::SQLException&)
956  {
957  }
958  }
959  }
960  auto aLBIter = std::find_if(m_aFields.begin(), m_aFields.end(), [&rBox](const SwAssignFragment& rFragment){
961  return &rBox == rFragment.m_xComboBox.get(); });
962  if (aLBIter != m_aFields.end())
963  {
964  auto nIndex = static_cast<sal_Int32>(std::distance(m_aFields.begin(), aLBIter));
965  m_aFields[nIndex].m_xPreview->set_label(sPreview);
966  }
967  m_aModifyHdl.Call(nullptr);
968 }
969 
970 IMPL_LINK(SwAssignFieldsControl, GotFocusHdl_Impl, weld::Widget&, rBox, void)
971 {
972  int x, y, width, height;
973  rBox.get_extents_relative_to(*m_xGrid, x, y, width, height);
974  // the container has a border of 3 in the .ui
975  tools::Rectangle aRect(Point(x - 3, y - 3), Size(width + 6, height + 6));
976  MakeVisible(aRect);
977 }
978 
980  weld::Window* pParent, SwMailMergeConfigItem& rConfigItem,
981  const OUString& rPreview,
982  bool bIsAddressBlock)
983  : SfxDialogController(pParent, "modules/swriter/ui/assignfieldsdialog.ui", "AssignFieldsDialog")
984  , m_sNone(SwResId(SW_STR_NONE))
985  , m_rPreviewString(rPreview)
986  , m_rConfigItem(rConfigItem)
987  , m_xPreview(new AddressPreview(m_xBuilder->weld_scrolled_window("previewwin")))
988  , m_xMatchingFI(m_xBuilder->weld_label("MATCHING_LABEL"))
989  , m_xAddressTitle(m_xBuilder->weld_label("addresselem"))
990  , m_xMatchTitle(m_xBuilder->weld_label("matchelem"))
991  , m_xPreviewTitle(m_xBuilder->weld_label("previewelem"))
992  , m_xPreviewFI(m_xBuilder->weld_label("PREVIEW_LABEL"))
993  , m_xOK(m_xBuilder->weld_button("ok"))
994  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "PREVIEW", *m_xPreview))
995  , m_xFieldsControl(new SwAssignFieldsControl(m_xBuilder->weld_scrolled_window("scroll"),
996  m_xBuilder->weld_container("FIELDS")))
997 {
998  m_xPreviewWin->set_size_request(m_xMatchingFI->get_approximate_digit_width() * 45,
999  m_xMatchingFI->get_text_height() * 5);
1000  m_xFieldsControl->Init(this, rConfigItem);
1001 
1002  const OUString sMatchesTo( SwResId(ST_MATCHESTO) );
1003  if (!bIsAddressBlock)
1004  {
1005  m_xPreviewFI->set_label(SwResId(ST_SALUTATIONPREVIEW));
1006  m_xMatchingFI->set_label(SwResId(ST_SALUTATIONMATCHING));
1007  m_xAddressTitle->set_label(SwResId(ST_SALUTATIONELEMENT));
1008  }
1009 
1010  m_xFieldsControl->SetModifyHdl(LINK(this, SwAssignFieldsDialog, AssignmentModifyHdl_Impl ));
1011  m_xMatchingFI->set_label(m_xMatchingFI->get_label().replaceAll("%1", sMatchesTo));
1012  m_xOK->connect_clicked(LINK(this, SwAssignFieldsDialog, OkHdl_Impl));
1013 }
1014 
1016 {
1017 }
1018 
1019 uno::Sequence< OUString > SwAssignFieldsDialog::CreateAssignments()
1020 {
1021  uno::Sequence< OUString > aAssignments(
1023  OUString* pAssignments = aAssignments.getArray();
1024  sal_Int32 nIndex = 0;
1025  for (const auto& rLBItem : m_xFieldsControl->m_aFields)
1026  {
1027  const OUString sSelect = rLBItem.m_xComboBox->get_active_text();
1028  pAssignments[nIndex] = (m_sNone != sSelect) ? sSelect : OUString();
1029  ++nIndex;
1030  }
1031  return aAssignments;
1032 }
1033 
1035 {
1038  CreateAssignments() );
1039  m_xDialog->response(RET_OK);
1040 }
1041 
1042 IMPL_LINK_NOARG(SwAssignFieldsDialog, AssignmentModifyHdl_Impl, LinkParamNone*, void)
1043 {
1044  uno::Sequence< OUString > aAssignments = CreateAssignments();
1045  const OUString sPreview = SwAddressPreview::FillData(
1046  m_rPreviewString, m_rConfigItem, &aAssignments);
1047  m_xPreview->SetAddress(sPreview);
1048 }
1049 
1050 void SwAssignFieldsDialog::ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
1051 {
1052  m_xAddressTitle->set_size_request(nLabelWidth, -1);
1053  m_xMatchTitle->set_size_request(nComboBoxWidth, -1);
1054  m_xPreviewTitle->set_size_request(nPreviewWidth, -1);
1055 }
1056 
1058  : SvTreeListBox(pParent, nStyle)
1059  , m_pParentDialog(nullptr)
1060 {
1061  SetStyle( GetStyle() | /*WB_HASBUTTONS|WB_HASBUTTONSATROOT|*/
1062  WB_CLIPCHILDREN );
1063  SetSelectionMode( SelectionMode::Single );
1064  SetDragDropMode( DragDropMode::CTRL_COPY );
1065  EnableAsyncDrag(true);
1066  // expand selection to the complete width of the ListBox
1068  Show();
1069 
1070 }
1071 
1073 {
1074  disposeOnce();
1075 }
1076 
1078 {
1081 }
1082 
1084 
1085 void DDListBox::SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
1086 {
1087  m_pParentDialog = pParent;
1088 }
1089 
1090 void DDListBox::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
1091 {
1092  SvTreeListEntry* pEntry = GetCurEntry();
1093  if(pEntry)
1094  {
1095  ReleaseMouse();
1096 
1098 
1099  sal_Int32 nUserData = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()));
1100  //special entries can only be once in the address / greeting
1101  if(nUserData >= 0 || !m_pParentDialog->HasItem_Impl(nUserData))
1102  {
1103  pContainer->CopyString( "<" + GetEntryText(pEntry) + ">" );
1104  pContainer->StartDrag( this, DND_ACTION_COPY, GetDragFinishedHdl() );
1105  }
1106  }
1107 }
1108 
1110  : VclMultiLineEdit(pParent, nBits)
1111  , m_pParentDialog(nullptr)
1112 {
1115  EnableFocusSelectionHide(false);
1116 }
1117 
1119 {
1120  disposeOnce();
1121 }
1122 
1124 {
1128 }
1129 
1130 
1132 {
1133  return LogicToPixel(Size(160, 60), MapMode(MapUnit::MapAppFont));
1134 }
1135 
1136 
1138 
1139 void AddressMultiLineEdit::SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
1140 {
1141  m_pParentDialog = pParent;
1142 }
1143 
1145 {
1146  if (m_aSelectionLink.IsSet() && dynamic_cast<const TextHint*>(&rHint))
1147  {
1148  const TextHint& rTextHint = static_cast<const TextHint&>(rHint);
1149  if (rTextHint.GetId() == SfxHintId::TextViewSelectionChanged ||
1150  rTextHint.GetId() == SfxHintId::TextViewCaretChanged)
1151  {
1152  m_aSelectionLink.Call(*this);
1153  }
1154  }
1155 }
1156 
1158 {
1159  bool bHandled = false;
1160  if( MouseNotifyEvent::KEYINPUT == rNEvt.GetType() &&
1161  rNEvt.GetKeyEvent()->GetCharCode())
1162  {
1163  bHandled = true;
1164  }
1165  else if(MouseNotifyEvent::MOUSEBUTTONDOWN == rNEvt.GetType()) {
1166  const MouseEvent *pMEvt = rNEvt.GetMouseEvent();
1167  if(pMEvt->GetClicks() >= 2)
1168  bHandled = true;
1169  }
1170  if(!bHandled)
1171  bHandled = VclMultiLineEdit::PreNotify( rNEvt );
1172  return bHandled;
1173 
1174 }
1175 
1176 void AddressMultiLineEdit::SetText( const OUString& rStr )
1177 {
1179  //set attributes to all address tokens
1180 
1181  ExtTextEngine* pTextEngine = GetTextEngine();
1182  TextAttribProtect aProtectAttr;
1183  const sal_uInt32 nParaCount = pTextEngine->GetParagraphCount();
1184  for(sal_uInt32 nPara = 0; nPara < nParaCount; ++nPara)
1185  {
1186  sal_Int32 nIndex = 0;
1187  const OUString sPara = pTextEngine->GetText( nPara );
1188  if(!sPara.isEmpty() && !sPara.endsWith(" "))
1189  {
1190  TextPaM aPaM(nPara, sPara.getLength());
1191  pTextEngine->ReplaceText(TextSelection( aPaM ), " ");
1192  }
1193  for(;;)
1194  {
1195  const sal_Int32 nStart = sPara.indexOf( '<', nIndex );
1196  if (nStart < 0)
1197  break;
1198  const sal_Int32 nEnd = sPara.indexOf( '>', nStart );
1199  if (nEnd < 0)
1200  break;
1201  nIndex = nEnd;
1202  pTextEngine->SetAttrib( aProtectAttr, nPara, nStart, nEnd + 1, false );
1203  }
1204 
1205  }
1206  // add two empty paragraphs at the end
1209  {
1210  sal_Int32 nLastLen = pTextEngine->GetText(nParaCount - 1).getLength();
1211  if(nLastLen)
1212  {
1213  TextPaM aPaM(nParaCount ? nParaCount - 1 : 0, nLastLen);
1214  pTextEngine->ReplaceText(TextSelection( aPaM ), "\n \n ");
1215  }
1216  }
1217 }
1218 
1219 // Insert the new entry in front of the entry at the beginning of the selection
1220 void AddressMultiLineEdit::InsertNewEntry( const OUString& rStr )
1221 {
1222  // insert new entry after current selected one.
1223  TextView* pTextView = GetTextView();
1224  const TextSelection& rSelection = pTextView->GetSelection();
1225  const sal_uInt32 nPara = rSelection.GetStart().GetPara();
1226  sal_Int32 nIndex = rSelection.GetEnd().GetIndex();
1227  ExtTextEngine *pTextEngine = GetTextEngine();
1228  const TextCharAttrib *pAttrib;
1229  if(nullptr != (pAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED )))
1230  nIndex = pAttrib->GetEnd();
1231  InsertNewEntryAtPosition( rStr, nPara, nIndex );
1232 
1233  // select the new entry
1234  pAttrib = pTextEngine->FindCharAttrib(TextPaM(nPara, nIndex),TEXTATTR_PROTECTED);
1235  const sal_Int32 nEnd = pAttrib ? pAttrib->GetEnd() : nIndex;
1236  TextSelection aEntrySel(TextPaM(nPara, nIndex), TextPaM(nPara, nEnd));
1237  pTextView->SetSelection(aEntrySel);
1238  Invalidate();
1239  Modify();
1240 }
1241 
1242 void AddressMultiLineEdit::InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex )
1243 {
1244  ExtTextEngine* pTextEngine = GetTextEngine();
1245  TextPaM aInsertPos( nPara, nIndex );
1246 
1247  pTextEngine->ReplaceText( aInsertPos, rStr );
1248 
1249  //restore the attributes
1250  SetText( GetAddress() );
1251  //select the newly inserted/moved element
1252  TextSelection aEntrySel(aInsertPos);
1253  TextView* pTextView = GetTextView();
1254  pTextView->SetSelection(aEntrySel);
1255  m_aSelectionLink.Call(*this);
1256 }
1257 
1259 {
1260  ExtTextEngine* pTextEngine = GetTextEngine();
1261  TextView* pTextView = GetTextView();
1262  const TextSelection& rSelection = pTextView->GetSelection();
1263  const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1264  if(pBeginAttrib &&
1265  (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
1266  && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
1267  {
1268  const sal_uInt32 nPara = rSelection.GetStart().GetPara();
1269  TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
1270  pTextEngine->ReplaceText(aEntrySel, OUString());
1271  //restore the attributes
1272  SetText( GetAddress() );
1273  Modify();
1274  }
1275 }
1276 
1278 {
1279  ExtTextEngine* pTextEngine = GetTextEngine();
1280  TextView* pTextView = GetTextView();
1281  const TextSelection& rSelection = pTextView->GetSelection();
1282  const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1283  if(!pBeginAttrib ||
1284  !(pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex() &&
1285  pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
1286  return;
1287 
1288  //current item has been found
1289  sal_uInt32 nPara = rSelection.GetStart().GetPara();
1290  sal_Int32 nIndex = pBeginAttrib->GetStart();
1291  TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
1292  const OUString sCurrentItem = pTextEngine->GetText(aEntrySel);
1293  pTextEngine->RemoveAttrib( nPara, *pBeginAttrib );
1294  pTextEngine->ReplaceText(aEntrySel, OUString());
1295  switch(nMove)
1296  {
1297  case MoveItemFlags::Left :
1298  if(nIndex)
1299  {
1300  //go left to find a predecessor or simple text
1301  --nIndex;
1302  const OUString sPara = pTextEngine->GetText( nPara );
1303  sal_Int32 nSearchIndex = sPara.lastIndexOf( '>', nIndex+1 );
1304  if( nSearchIndex != -1 && nSearchIndex == nIndex )
1305  {
1306  nSearchIndex = sPara.lastIndexOf( '<', nIndex );
1307  if( nSearchIndex != -1 )
1308  nIndex = nSearchIndex;
1309  }
1310  }
1311  break;
1312  case MoveItemFlags::Right:
1313  {
1314  //go right to find a successor or simple text
1315  ++nIndex;
1316  const TextCharAttrib* pEndAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1317  if(pEndAttrib && pEndAttrib->GetEnd() >= nIndex)
1318  {
1319  nIndex = pEndAttrib->GetEnd();
1320  }
1321  }
1322  break;
1323  case MoveItemFlags::Up :
1324  --nPara;
1325  nIndex = 0;
1326  break;
1327  case MoveItemFlags::Down :
1328  ++nPara;
1329  nIndex = 0;
1330  break;
1331  default: break;
1332  }
1333  //add a new paragraph if there is none yet
1334  if(nPara >= pTextEngine->GetParagraphCount())
1335  {
1336 
1337  TextPaM aTemp(nPara - 1, pTextEngine->GetTextLen( nPara - 1 ));
1338  pTextEngine->ReplaceText(aTemp, "\n");
1339  }
1340  InsertNewEntryAtPosition( sCurrentItem, nPara, nIndex );
1341 
1342  // select the new entry [#i40817]
1343  const TextCharAttrib *pAttrib = pTextEngine->FindCharAttrib(TextPaM(nPara, nIndex),TEXTATTR_PROTECTED);
1344  if (pAttrib)
1345  aEntrySel = TextSelection(TextPaM(nPara, nIndex), TextPaM(nPara, pAttrib->GetEnd()));
1346  pTextView->SetSelection(aEntrySel);
1347  Invalidate();
1348  Modify();
1349 
1350 }
1351 
1353 {
1355  ExtTextEngine* pTextEngine = GetTextEngine();
1356  TextView* pTextView = GetTextView();
1357  const TextSelection& rSelection = pTextView->GetSelection();
1358  const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1359  if(pBeginAttrib &&
1360  (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
1361  && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
1362  {
1363  if(pBeginAttrib->GetStart())
1364  nRet |= MoveItemFlags::Left;
1365  //if there is an entry it can always be move to the right and down
1367  if(rSelection.GetStart().GetPara() > 0)
1368  nRet |= MoveItemFlags::Up;
1369  }
1370  return nRet;
1371 }
1372 
1374 {
1375  ExtTextEngine* pTextEngine = GetTextEngine();
1376  TextView* pTextView = GetTextView();
1377  const TextSelection& rSelection = pTextView->GetSelection();
1378  const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1379  return (pBeginAttrib &&
1380  (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
1381  && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()));
1382 }
1383 
1385 {
1386  ExtTextEngine* pTextEngine = GetTextEngine();
1387  TextView* pTextView = GetTextView();
1388  const TextSelection& rSelection = pTextView->GetSelection();
1389  const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1390  if(pBeginAttrib &&
1391  (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
1392  && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
1393  {
1394  const sal_uInt32 nPara = rSelection.GetStart().GetPara();
1395  TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
1396  return pTextEngine->GetText( aEntrySel );
1397  }
1398  return OUString();
1399 }
1400 
1402 {
1403  ExtTextEngine* pTextEngine = GetTextEngine();
1404  TextView* pTextView = GetTextView();
1405  const TextSelection& rSelection = pTextView->GetSelection();
1406  const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED );
1407  if(pBeginAttrib &&
1408  (pBeginAttrib->GetStart() <= rSelection.GetStart().GetIndex()
1409  && pBeginAttrib->GetEnd() >= rSelection.GetEnd().GetIndex()))
1410  {
1411  const sal_uInt32 nPara = rSelection.GetStart().GetPara();
1412  TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
1413  pTextView->SetSelection(aEntrySel);
1414  Invalidate();
1415  }
1416 }
1417 
1419 {
1420  OUString sRet;
1421  ExtTextEngine* pTextEngine = GetTextEngine();
1422  const sal_uInt32 nParaCount = pTextEngine->GetParagraphCount();
1423  for(sal_uInt32 nPara = nParaCount; nPara; --nPara)
1424  {
1425  const OUString sPara = comphelper::string::stripEnd(pTextEngine->GetText(nPara - 1), ' ');
1426  //don't add empty trailing paragraphs
1427  if(!sRet.isEmpty() || !sPara.isEmpty())
1428  {
1429  sRet = sPara + sRet;
1430  //insert the para break
1431  if(nPara > 1)
1432  sRet = "\n" + sRet;
1433  }
1434  }
1435  return sRet;
1436 }
1437 
1438 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long Width() const
void SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
std::unique_ptr< weld::Container > m_xGrid
SwAssignFieldsControl(std::unique_ptr< weld::ScrolledWindow > xWindow, std::unique_ptr< weld::Container > xGrid)
bool IsHideEmptyParagraphs() const
void SetAddress(const OUString &rAddress)
std::unique_ptr< AddressPreview > m_xPreview
virtual void dispose() override
#define HID_MM_ADDBLOCK_DRAG
Definition: helpids.h:149
VclPtr< SwAddressPreview > m_pSettingsWIN
IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, Button *, void)
std::vector< OUString > m_aSalutations
OString stripEnd(const OString &rIn, sal_Char c)
std::unique_ptr< weld::Button > m_xNewPB
OUString const m_rPreviewString
std::unique_ptr< weld::ComboBox > m_xComboBox
DDListBox(vcl::Window *pParent, const WinBits nStyle)
void SetUserData(void *pPtr)
SwMailMergeConfigItem & GetConfigItem()
VclPtr< SwAddressPreview > m_pPreviewWIN
std::unique_ptr< weld::Label > m_xPreviewTitle
VclPtr< VclContainer > m_pStep3
#define HID_MM_ADDBLOCK_MOVEBUTTONS
Definition: helpids.h:151
#define DND_ACTION_COPY
void SetClickHdl(const Link< Button *, void > &rLink)
virtual void dispose() override
void EnableFocusSelectionHide(bool bHide)
std::unique_ptr< weld::Label > m_xMatchTitle
void SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
std::unique_ptr< SwAssignFieldsControl > m_xFieldsControl
virtual SvTreeListEntry * InsertEntry(const OUString &rText, SvTreeListEntry *pParent=nullptr, bool bChildrenOnDemand=false, sal_uLong nPos=TREELIST_APPEND, void *pUserData=nullptr, SvLBoxButtonKind eButtonKind=SvLBoxButtonKind::EnabledCheckbox)
long Height() const
signed char sal_Int8
virtual ~DDListBox() override
SwSelectAddressBlockDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfig)
std::unique_ptr< weld::RadioButton > m_xNeverRB
OUString GetText(LineEnd aSeparator=LINEEND_LF) const
VclPtr< SwCustomizeAddressBlockDialog > m_pParentDialog
css::uno::Reference< css::sdbcx::XColumnsSupplier > GetColumnsSupplier()
sal_uIntPtr sal_uLong
OUString sDataSource
Definition: swdbdata.hxx:30
sal_uLong GetEntryCount() const
VclPtr< DDListBox > m_pAddressElementsLB
void EnableAsyncDrag(bool b)
void SetText(const OUString &rStr) override
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)
const TextPaM & GetEnd() const
SharedConnection GetConnection()
SwAssignFieldsDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfigItem, const OUString &rPreview, bool bIsAddressBlock)
void set_height_request(sal_Int32 nHeightRequest)
#define TEXTATTR_PROTECTED
const SwDBData & GetCurrentDBData() const
#define USER_DATA_TEXT
const KeyEvent * GetKeyEvent() const
VclPtr< CheckBox > m_pHideEmptyParagraphsCB
sal_Int32 GetStart() const
VclPtr< FixedText > m_pCurrentAddressFI
void SetHelpId(const OString &)
TextView * GetTextView() const
virtual int get_active() const =0
const TextCharAttrib * FindCharAttrib(const TextPaM &rPaM, sal_uInt16 nWhich) const
float x
SvTreeListEntry * GetCurEntry() const
void InsertNewEntry(const OUString &rStr)
void SetQuickHelpText(const OUString &rHelpText)
void SetSelectHdl(const Link< LinkParamNone *, void > &rLink)
#define HID_MM_ADDBLOCK_REMOVE
Definition: helpids.h:148
sal_uInt16 GetClicks() const
sal_Int64 WinBits
std::vector< SwAssignFragment > m_aFields
void MoveCurrentItem(MoveItemFlags nMove)
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
virtual void show()=0
virtual void SetModifyHdl(const Link< Edit &, void > &rLink)
void Enable(bool bEnable=true, bool bChild=true)
void AddAddress(const OUString &rAddress)
The address string is a list of address elements separated by spaces and breaks.
FUNC_TYPE const nType
void SetSelectHdl(const Link< ComboBox &, void > &rLink)
const css::uno::Sequence< OUString > & GetAddressBlocks()
std::vector< OUString > m_aPunctuations
virtual void Modify() override
VclPtr< PushButton > m_pRemoveFieldIB
void SetDragDropMode(DragDropMode)
virtual void dispose() override
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
VclPtr< SwCustomizeAddressBlockDialog > m_pParentDialog
virtual ~AddressMultiLineEdit() override
VclPtr< FixedText > m_pSettingsFI
void set_width_request(sal_Int32 nWidthRequest)
virtual OUString GetText() const
long Top() const
void MakeVisible(const tools::Rectangle &rRect)
sal_uInt32 GetParagraphCount() const
virtual ~SwSelectAddressBlockDialog() override
void SetSelectHdl(const Link< SvTreeListBox *, void > &rNewHdl)
std::unique_ptr< weld::Button > m_xCustomizePB
#define MM_GREETINGSPAGE
virtual Size GetOptimalSize() const override
std::unique_ptr< AddressPreview > m_xPreview
virtual void set_active(bool active)=0
virtual void dispose() override
#define HID_MM_ADDBLOCK_PREVIEW
Definition: helpids.h:150
virtual void ActivatePage() override
float y
bool HasItem_Impl(sal_Int32 nUserData)
#define SAL_N_ELEMENTS(arr)
css::uno::Reference< css::sdbc::XResultSet > const & GetResultSet() const
void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff)
std::unique_ptr< weld::ScrolledWindow > m_xVScroll
const std::vector< std::pair< OUString, int > > & GetDefaultAddressHeaders() const
void set_active_text(const OUString &rStr)
AddressMultiLineEdit(vcl::Window *pParent, WinBits nWinStyle)
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
css::uno::Reference< css::sdbc::XDataSource > GetSource()
virtual ~SwAssignFieldsDialog() override
const SwDBData & GetDBData() const
SwMailMergeAddressBlockPage(SwMailMergeWizard *_pParent)
VclPtr< PushButton > m_pAddressListPB
VclPtr< PushButton > m_pSettingsPB
void connect_changed(const Link< ComboBox &, void > &rLink)
virtual void dispose() override
VclPtr< PushButton > m_pInsertFieldIB
virtual void SetText(const OUString &rStr) override
std::unique_ptr< weld::Label > m_xPreviewFI
virtual bool commitPage(::svt::WizardTypes::CommitPageReason _eReason) override
int i
void SetHideEmptyParagraphs(bool bSet)
VclPtr< SwAddressPreview > m_pPreviewWIN
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
void SupportProtectAttribute(bool bSupport)
virtual OUString GetText() const override
virtual void dispose() override
void * GetUserData() const
void SetAddressBlock(bool bSet)
VclPtr< SwMailMergeWizard > m_pWizard
weld::Window * GetFrameWeld(SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
long Bottom() const
VclPtr< PushButton > m_pPrevSetIB
const TextPaM & GetStart() const
Link< sal_Int8, void > GetDragFinishedHdl() const
#define VCL_BUILDER_FACTORY_CONSTRUCTOR(typeName, arg2)
virtual bool PreNotify(NotifyEvent &rNEvt) override
ExtTextEngine * GetTextEngine() const
MouseNotifyEvent GetType() const
void SetAttrib(const TextAttrib &rAttr, sal_uInt32 nPara, sal_Int32 nStart, sal_Int32 nEnd, bool bIdleFormatAndUpdate=true)
sal_Int32 GetResultSetPosition() const
virtual ~SwMailMergeAddressBlockPage() override
void SetTextFilter(TextFilter *pFilter)
VclPtr< VclContainer > m_pStep4
virtual void connect_focus_in(const Link< Widget &, void > &rLink)
void SelectAddress(sal_uInt16 nSelect)
virtual void set_active(int pos)=0
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void SetFilter(OUString const &)
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
void SetSelection(const TextSelection &rNewSel)
SwAssignFragment(weld::Container *pGrid, int nLine)
std::unique_ptr< weld::Label > m_xMatchingFI
virtual OUString GetEntryText(SvTreeListEntry *pEntry) const
void Check(bool bCheck=true)
std::unique_ptr< weld::Builder > m_xBuilder
sal_Int32 MoveResultSet(sal_Int32 nTarget)
long GetTextHeight() const
sal_Int32 GetTextLen() const
virtual Size get_preferred_size() const =0
void SetStyle(WinBits nStyle)
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 LogicToPixel(const Point &rLogicPt) const
const TextSelection & GetSelection() const
void ReleaseMouse()
std::unique_ptr< weld::Label > m_xLabel
IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, Button *, pButton, void)
void SetSelectionMode(SelectionMode)
Link< AddressMultiLineEdit &, void > m_aSelectionLink
std::unique_ptr< weld::RadioButton > m_xDependentRB
void SetSettings(bool bIsCountry, const OUString &sCountry)
void EnableAddressBlock(bool bAll, bool bSelective)
weld::Entry & rEdit
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
#define HID_MM_ADDBLOCK_INSERT
Definition: helpids.h:147
VclPtr< FixedText > m_pAddressElementsFT
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks, sal_uInt16 nSelected)
virtual bool canAdvance() const override
const MouseEvent * GetMouseEvent() const
VclPtr< AddressMultiLineEdit > m_pDragED
sal_Int32 GetEnd() const
bool IsVisible() const
sal_Int32 GetIndex() const
std::unique_ptr< weld::Button > m_xDeletePB
sal_Unicode GetCharCode() const
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uLong nPos) const
RET_OK
MoveItemFlags IsCurrentItemMoveable()
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
const css::uno::Sequence< OUString > GetAddressBlocks() const
void SetSelectionChangedHdl(const Link< AddressMultiLineEdit &, void > &rLink)
VclPtr< PushButton > m_pNextSetIB
void SetModifyHdl(const Link< Edit &, void > &rLink) override
#define USER_DATA_PUNCTUATION
bool PreNotify(NotifyEvent &rNEvt) override
void SetColumnAssignment(const SwDBData &rDBData, const css::uno::Sequence< OUString > &)
void Init(SwAssignFieldsDialog *pDialog, SwMailMergeConfigItem &rConfigItem)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
VclPtr< PushButton > m_pAssignPB
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks)
void ReplaceText(const TextSelection &rSel, const OUString &rText)
virtual void dispose() override
#define USER_DATA_NONE
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
OUString GetText() const override
css::uno::Sequence< OUString > m_aAddressBlocks
#define SAL_WARN(area, stream)
virtual void dispose() override
void append_text(const OUString &rStr)
WinBits GetStyle() const
DECL_LINK(MatchHdl_Impl, weld::ComboBox &, void)
bool IsAddressBlock() const
virtual ~SwCustomizeAddressBlockDialog() override
void InsertNewEntryAtPosition(const OUString &rStr, sal_uLong nPara, sal_uInt16 nIndex)
void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
SwMailMergeConfigItem & m_rConfigItem
std::unique_ptr< TextCharAttrib > RemoveAttrib(sal_uInt32 nPara, const TextCharAttrib &rAttrib)
VclPtr< FixedText > m_pDocumentIndexFI
sal_Int32 nPos
VclPtr< VclContainer > m_pStep2
SwMailMergeConfigItem * m_rConfigItem
void SetModifyHdl(const Link< LinkParamNone *, void > &rModifyHdl)
#define HID_MM_ADDBLOCK_ELEMENTS
Definition: helpids.h:146
WinBits const WB_CLIPCHILDREN
SwCustomizeAddressBlockDialog(vcl::Window *pParent, SwMailMergeConfigItem &rConfig, DialogType)
static OUString FillData(const OUString &rAddress, SwMailMergeConfigItem const &rConfigItem, const css::uno::Sequence< OUString > *pAssignments=nullptr)
std::unique_ptr< weld::Entry > m_xCountryED
sal_uInt32 GetPara() const
virtual void SetText(const OUString &rStr) override
SwMailMergeConfigItem & m_rConfigItem
void SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns)
Link< LinkParamNone *, void > m_aModifyHdl
bool IsOutputToLetter() const
virtual OUString get_active_text() const =0
std::unique_ptr< weld::Label > m_xAddressTitle
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
std::unique_ptr< weld::Label > m_xPreview