LibreOffice Module sw (master)  1
label1.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 <memory>
21 #include <vcl/svapp.hxx>
22 #include <rtl/ustring.hxx>
23 #include <tools/lineend.hxx>
24 #include <svtools/unitconv.hxx>
25 #include <com/sun/star/uno/Sequence.h>
26 #include <swtypes.hxx>
27 #include <labimp.hxx>
28 #include "swuilabimp.hxx"
29 #include "labfmt.hxx"
30 #include "labprt.hxx"
31 #include <dbmgr.hxx>
32 #include <uitool.hxx>
33 #include <cmdid.h>
34 #include <helpids.h>
35 #include <strings.hrc>
36 #include <envimg.hxx>
37 
38 void SwLabRec::SetFromItem( const SwLabItem& rItem )
39 {
40  m_nHDist = rItem.m_lHDist;
41  m_nVDist = rItem.m_lVDist;
42  m_nWidth = rItem.m_lWidth;
43  m_nHeight = rItem.m_lHeight;
44  m_nLeft = rItem.m_lLeft;
45  m_nUpper = rItem.m_lUpper;
46  m_nCols = rItem.m_nCols;
47  m_nRows = rItem.m_nRows;
48  m_nPWidth = rItem.m_lPWidth;
49  m_nPHeight = rItem.m_lPHeight;
50  m_bCont = rItem.m_bCont;
51 }
52 
53 void SwLabRec::FillItem( SwLabItem& rItem ) const
54 {
55  rItem.m_lHDist = m_nHDist;
56  rItem.m_lVDist = m_nVDist;
57  rItem.m_lWidth = m_nWidth;
58  rItem.m_lHeight = m_nHeight;
59  rItem.m_lLeft = m_nLeft;
60  rItem.m_lUpper = m_nUpper;
61  rItem.m_nCols = m_nCols;
62  rItem.m_lPWidth = m_nPWidth;
63  rItem.m_lPHeight = m_nPHeight;
64  rItem.m_nRows = m_nRows;
65 }
66 
67 void SwLabDlg::ReplaceGroup_( const OUString &rMake )
68 {
69  // Remove old entries
70  m_pRecs->erase(m_pRecs->begin() + 1, m_pRecs->end());
71  aLabelsCfg.FillLabels(rMake, *m_pRecs);
72  aLstGroup = rMake;
73 }
74 
75 void SwLabDlg::PageCreated(const OString &rId, SfxTabPage &rPage)
76 {
77  if (rId == "labels")
78  {
79  if (m_bLabel)
80  {
81  static_cast<SwLabPage*>(&rPage)->SetDBManager(pDBManager);
82  static_cast<SwLabPage*>(&rPage)->InitDatabaseBox();
83  }
84  else
85  static_cast<SwLabPage*>(&rPage)->SetToBusinessCard();
86  }
87  else if (rId == "options")
88  m_pPrtPage = static_cast<SwLabPrtPage*>(&rPage);
89 }
90 
92  SwDBManager* pDBManager_, bool bLabel)
93  : SfxTabDialogController(pParent, "modules/swriter/ui/labeldialog.ui", "LabelDialog", &rSet)
94  , pDBManager(pDBManager_)
95  , m_pPrtPage(nullptr)
96  , aTypeIds(50, 10)
97  , m_pRecs(new SwLabRecs)
98  , m_bLabel(bLabel)
99 {
100  weld::WaitObject aWait(pParent);
101 
102  // Read user label from writer.cfg
103  SwLabItem aItem(static_cast<const SwLabItem&>(rSet.Get( FN_LABEL )));
104  std::unique_ptr<SwLabRec> pRec(new SwLabRec);
105  pRec->m_aMake = pRec->m_aType = SwResId(STR_CUSTOM_LABEL);
106  pRec->SetFromItem( aItem );
107 
108  bool bDouble = false;
109 
110  for (const std::unique_ptr<SwLabRec> & i : *m_pRecs)
111  {
112  if (pRec->m_aMake == i->m_aMake &&
113  pRec->m_aType == i->m_aType)
114  {
115  bDouble = true;
116  break;
117  }
118  }
119 
120  if (!bDouble)
121  m_pRecs->insert( m_pRecs->begin(), std::move(pRec));
122 
123  size_t nLstGroup = 0;
124  const std::vector<OUString>& rMan = aLabelsCfg.GetManufacturers();
125  for(size_t nMan = 0; nMan < rMan.size(); ++nMan)
126  {
127  aMakes.push_back(rMan[nMan]);
128  if ( rMan[nMan] == aItem.m_aLstMake )
129  nLstGroup = nMan;
130  }
131 
132  if ( !aMakes.empty() )
133  ReplaceGroup_( aMakes[nLstGroup] );
134 
135  if (m_xExampleSet)
136  m_xExampleSet->Put(aItem);
137 
138  AddTabPage("format", SwLabFormatPage::Create, nullptr);
139  AddTabPage("options", SwLabPrtPage::Create, nullptr);
140  m_sBusinessCardDlg = SwResId(STR_BUSINESS_CARDS);
141 
142  if (m_bLabel)
143  {
144  RemoveTabPage("business");
145  RemoveTabPage("private");
146  RemoveTabPage("medium");
147  AddTabPage("labels", SwLabPage::Create, nullptr);
148  }
149  else
150  {
151  RemoveTabPage("labels");
152  AddTabPage("medium", SwLabPage::Create, nullptr);
153  AddTabPage("business", SwBusinessDataPage::Create, nullptr );
154  AddTabPage("private", SwPrivateDataPage::Create, nullptr);
155  m_xDialog->set_title(m_sBusinessCardDlg);
156  }
157 }
158 
160 {
161  m_pRecs.reset();
162 }
163 
165 {
166  const SwLabItem& rActItem = static_cast<const SwLabItem&>(GetExampleSet()->Get(FN_LABEL));
167  const SwLabItem& rOldItem = static_cast<const SwLabItem&>(GetInputSetImpl()->Get(FN_LABEL));
168 
169  if (rActItem != rOldItem)
170  {
171  // Was already "put" with (hopefully) correct content
172  rItem = rActItem;
173  }
174  else
175  {
176  rItem = rOldItem;
177 
178  // In rItem there are only settings defined by users.
179  // Therefore get the real settings directly from Record
180  SwLabRec* pRec = GetRecord(rItem.m_aType, rItem.m_bCont);
181  pRec->FillItem( rItem );
182  }
183 }
184 
185 SwLabRec* SwLabDlg::GetRecord(std::u16string_view rRecName, bool bCont)
186 {
187  SwLabRec* pRec = nullptr;
188  bool bFound = false;
189  const OUString sCustom(SwResId(STR_CUSTOM_LABEL));
190 
191  const size_t nCount = Recs().size();
192  for (size_t i = 0; i < nCount; ++i)
193  {
194  pRec = Recs()[i].get();
195  if (pRec->m_aType != sCustom &&
196  rRecName == pRec->m_aType && bCont == pRec->m_bCont)
197  {
198  bFound = true;
199  break;
200  }
201  }
202  if (!bFound) // User defined
203  pRec = Recs()[0].get();
204 
205  return pRec;
206 }
207 
209 {
210  if (m_pPrtPage)
211  return m_pPrtPage->GetPrt();
212  else
213  return nullptr;
214 }
215 
217  : SfxTabPage(pPage, pController, "modules/swriter/ui/cardmediumpage.ui", "CardMediumPage", &rSet)
218  , pDBManager(nullptr)
219  , aItem(static_cast<const SwLabItem&>(rSet.Get(FN_LABEL)))
220  , m_xAddressFrame(m_xBuilder->weld_widget("addressframe"))
221  , m_xAddrBox(m_xBuilder->weld_check_button("address"))
222  , m_xWritingEdit(m_xBuilder->weld_text_view("textview"))
223  , m_xDatabaseLB(m_xBuilder->weld_combo_box("database"))
224  , m_xTableLB(m_xBuilder->weld_combo_box("table"))
225  , m_xInsertBT(m_xBuilder->weld_button("insert"))
226  , m_xDBFieldLB(m_xBuilder->weld_combo_box("field"))
227  , m_xContButton(m_xBuilder->weld_radio_button("continuous"))
228  , m_xSheetButton(m_xBuilder->weld_radio_button("sheet"))
229  , m_xMakeBox(m_xBuilder->weld_combo_box("brand"))
230  , m_xTypeBox(m_xBuilder->weld_combo_box("type"))
231  , m_xHiddenSortTypeBox(m_xBuilder->weld_combo_box("hiddentype"))
232  , m_xFormatInfo(m_xBuilder->weld_label("formatinfo"))
233 {
235 
236  m_xWritingEdit->set_size_request(m_xWritingEdit->get_approximate_digit_width() * 30,
237  m_xWritingEdit->get_height_rows(10));
238  m_xHiddenSortTypeBox->make_sorted();
239 
240  tools::Long nListBoxWidth = m_xWritingEdit->get_approximate_digit_width() * 25;
241  m_xTableLB->set_size_request(nListBoxWidth, -1);
242  m_xDatabaseLB->set_size_request(nListBoxWidth, -1);
243  m_xDBFieldLB->set_size_request(nListBoxWidth, -1);
244 
246 
247  // Install handlers
248  m_xAddrBox->connect_toggled(LINK(this, SwLabPage, AddrHdl));
249  m_xDatabaseLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
250  m_xTableLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
251  m_xDBFieldLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
252  m_xInsertBT->connect_clicked(LINK(this, SwLabPage, FieldHdl));
253  // Disable insert button first,
254  // it'll be enabled if m_xDatabaseLB, m_pTableLB and m_pInsertBT are filled
255  m_xInsertBT->set_sensitive(false);
256  m_xContButton->connect_toggled(LINK(this, SwLabPage, PageHdl));
257  m_xSheetButton->connect_toggled(LINK(this, SwLabPage, PageHdl));
258  auto nMaxWidth = m_xMakeBox->get_approximate_digit_width() * 32;
259  m_xMakeBox->set_size_request(nMaxWidth, -1);
260  m_xTypeBox->set_size_request(nMaxWidth, -1);
261  m_xMakeBox->connect_changed(LINK(this, SwLabPage, MakeHdl));
262  m_xTypeBox->connect_changed(LINK(this, SwLabPage, TypeHdl));
263 
264  InitDatabaseBox();
265 }
266 
268 {
269 }
270 
272 {
273  m_xContainer->set_help_id(HID_BUSINESS_FMT_PAGE);
278  m_xAddressFrame->hide();
279 };
280 
282 {
283  OUString aWriting;
284 
285  if (m_xAddrBox->get_active())
286  aWriting = convertLineEnd(MakeSender(), GetSystemLineEnd());
287 
288  m_xWritingEdit->set_text(aWriting);
289  m_xWritingEdit->grab_focus();
290 }
291 
292 IMPL_LINK( SwLabPage, DatabaseHdl, weld::ComboBox&, rListBox, void )
293 {
294  sActDBName = m_xDatabaseLB->get_active_text();
295 
296  weld::WaitObject aObj(GetParentSwLabDlg()->getDialog());
297 
298  if (&rListBox == m_xDatabaseLB.get())
299  GetDBManager()->GetTableNames(*m_xTableLB, sActDBName);
300 
301  if (&rListBox == m_xDatabaseLB.get() || &rListBox == m_xTableLB.get())
302  GetDBManager()->GetColumnNames(*m_xDBFieldLB, sActDBName, m_xTableLB->get_active_text());
303 
304  if (!m_xDatabaseLB->get_active_text().isEmpty() && !m_xTableLB->get_active_text().isEmpty()
305  && !m_xDBFieldLB->get_active_text().isEmpty())
306  m_xInsertBT->set_sensitive(true);
307  else
308  m_xInsertBT->set_sensitive(false);
309 }
310 
312 {
313  OUString aStr("<" + m_xDatabaseLB->get_active_text() + "." +
314  m_xTableLB->get_active_text() + "." +
315  m_xTableLB->get_active_id() + "." +
316  m_xDBFieldLB->get_active_text() + ">");
317  m_xWritingEdit->replace_selection(aStr);
318  int nStartPos, nEndPos;
319  m_xWritingEdit->get_selection_bounds(nStartPos, nEndPos);
320  m_xWritingEdit->grab_focus();
321  m_xWritingEdit->select_region(nStartPos, nEndPos);
322 }
323 
325 {
326  MakeHdl(*m_xMakeBox);
327 }
328 
330 {
331  weld::WaitObject aWait(GetParentSwLabDlg()->getDialog());
332 
333  m_xTypeBox->clear();
334  m_xHiddenSortTypeBox->clear();
335  GetParentSwLabDlg()->TypeIds().clear();
336 
337  const OUString aMake = m_xMakeBox->get_active_text();
338  GetParentSwLabDlg()->ReplaceGroup( aMake );
339  aItem.m_aLstMake = aMake;
340 
341  const bool bCont = m_xContButton->get_active();
342  const size_t nCount = GetParentSwLabDlg()->Recs().size();
343  size_t nLstType = 0;
344 
345  const OUString sCustom(SwResId(STR_CUSTOM_LABEL));
346  //insert the entries into the sorted list box
347  for ( size_t i = 0; i < nCount; ++i )
348  {
349  const OUString aType(GetParentSwLabDlg()->Recs()[i]->m_aType);
350  bool bInsert = false;
351  if (GetParentSwLabDlg()->Recs()[i]->m_aType == sCustom)
352  {
353  bInsert = true;
354  m_xTypeBox->append_text(aType );
355  }
356  else if (GetParentSwLabDlg()->Recs()[i]->m_bCont == bCont)
357  {
358  if (m_xHiddenSortTypeBox->find_text(aType) == -1)
359  {
360  bInsert = true;
361  m_xHiddenSortTypeBox->append_text( aType );
362  }
363  }
364  if(bInsert)
365  {
366  GetParentSwLabDlg()->TypeIds().push_back(i);
367  if ( !nLstType && aType == aItem.m_aLstType )
368  nLstType = GetParentSwLabDlg()->TypeIds().size();
369  }
370  }
371  for (int nEntry = 0; nEntry < m_xHiddenSortTypeBox->get_count(); ++nEntry)
372  {
373  m_xTypeBox->append_text(m_xHiddenSortTypeBox->get_text(nEntry));
374  }
375  if (nLstType)
376  m_xTypeBox->set_active_text(aItem.m_aLstType);
377  else
378  m_xTypeBox->set_active(0);
379  TypeHdl(*m_xTypeBox);
380 }
381 
383 {
384  DisplayFormat();
385  aItem.m_aType = m_xTypeBox->get_active_text();
386 }
387 
389 {
390  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/spinbox.ui"));
391  std::unique_ptr<weld::Dialog> xTopLevel(xBuilder->weld_dialog("SpinDialog"));
392  std::unique_ptr<weld::MetricSpinButton> xField(xBuilder->weld_metric_spin_button("spin", FieldUnit::CM));
393  SetFieldUnit(*xField, ::GetDfltMetric(false));
394  xField->set_digits(2);
395  xField->set_range(0, INT_MAX - 1, FieldUnit::NONE);
396 
397  SwLabRec* pRec = GetSelectedEntryPos();
398  aItem.m_aLstType = pRec->m_aType;
399  setfldval(*xField, pRec->m_nWidth);
400  xField->reformat();
401  const OUString aWString = xField->get_text();
402 
403  setfldval(*xField, pRec->m_nHeight);
404  xField->reformat();
405 
406  OUString aText = pRec->m_aType + ": " + aWString +
407  " x " + xField->get_text() +
408  " (" + OUString::number( pRec->m_nCols ) +
409  " x " + OUString::number( pRec->m_nRows ) + ")";
410  m_xFormatInfo->set_label(aText);
411 }
412 
414 {
415  OUString sSelEntry(m_xTypeBox->get_active_text());
416 
417  return GetParentSwLabDlg()->GetRecord(sSelEntry, m_xContButton->get_active());
418 }
419 
421 {
422  if( !GetDBManager() )
423  return;
424 
425  m_xDatabaseLB->clear();
426  const css::uno::Sequence<OUString> aDataNames = SwDBManager::GetExistingDatabaseNames();
427  for (const OUString& rDataName : aDataNames)
428  m_xDatabaseLB->append_text(rDataName);
429  sal_Int32 nIdx{ 0 };
430  OUString sDBName = sActDBName.getToken( 0, DB_DELIM, nIdx );
431  OUString sTableName = sActDBName.getToken( 0, DB_DELIM, nIdx );
432  m_xDatabaseLB->set_active_text(sDBName);
433  if( !sDBName.isEmpty() && GetDBManager()->GetTableNames(*m_xTableLB, sDBName))
434  {
435  m_xTableLB->set_active_text(sTableName);
437  }
438  else
439  m_xDBFieldLB->clear();
440 }
441 
442 std::unique_ptr<SfxTabPage> SwLabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
443 {
444  return std::make_unique<SwLabPage>(pPage, pController, *rSet);
445 }
446 
448 {
449  Reset( &rSet );
450 }
451 
453 {
454  if (_pSet)
455  FillItemSet(_pSet);
456 
457  return DeactivateRC::LeavePage;
458 }
459 
461 {
462  rItem.m_bAddr = m_xAddrBox->get_active();
463  rItem.m_aWriting = m_xWritingEdit->get_text();
464  rItem.m_bCont = m_xContButton->get_active();
465  rItem.m_aMake = m_xMakeBox->get_active_text();
466  rItem.m_aType = m_xTypeBox->get_active_text();
467  rItem.m_sDBName = sActDBName;
468 
469  SwLabRec* pRec = GetSelectedEntryPos();
470  pRec->FillItem( rItem );
471 
472  rItem.m_aLstMake = m_xMakeBox->get_active_text();
473  rItem.m_aLstType = m_xTypeBox->get_active_text();
474 }
475 
477 {
478  FillItem( aItem );
479  rSet->Put( aItem );
480 
481  return true;
482 }
483 
484 void SwLabPage::Reset(const SfxItemSet* rSet)
485 {
486  m_xMakeBox->clear();
487 
488  size_t nLstGroup = 0;
489 
490  const size_t nCount = GetParentSwLabDlg()->Makes().size();
491  for(size_t i = 0; i < nCount; ++i)
492  {
493  OUString& rStr = GetParentSwLabDlg()->Makes()[i];
494  m_xMakeBox->append_text(rStr);
495 
496  if ( rStr == aItem.m_aLstMake)
497  nLstGroup = i;
498  }
499 
500  m_xMakeBox->set_active( nLstGroup );
501  MakeHdl(*m_xMakeBox);
502 
503  aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL));
504  OUString sDBName = aItem.m_sDBName;
505 
506  OUString aWriting(convertLineEnd(aItem.m_aWriting, GetSystemLineEnd()));
507 
508  m_xAddrBox->set_active( aItem.m_bAddr );
509  m_xWritingEdit->set_text( aWriting );
510 
511  for(const auto& rMake : GetParentSwLabDlg()->Makes())
512  {
513  if (m_xMakeBox->find_text(rMake) == -1)
514  m_xMakeBox->append_text(rMake);
515  }
516 
517  m_xMakeBox->set_active_text(aItem.m_aMake);
518  //save the current type
519  OUString sType(aItem.m_aType);
520  MakeHdl(*m_xMakeBox);
521  aItem.m_aType = sType;
522  //#102806# a newly added make may not be in the type ListBox already
523  if (m_xTypeBox->find_text(aItem.m_aType) == -1 && !aItem.m_aMake.isEmpty())
525  if (m_xTypeBox->find_text(aItem.m_aType) != -1)
526  {
527  m_xTypeBox->set_active_text(aItem.m_aType);
528  TypeHdl(*m_xTypeBox);
529  }
530  if (m_xDatabaseLB->find_text(sDBName) != -1)
531  {
532  m_xDatabaseLB->set_active_text(sDBName);
533  DatabaseHdl(*m_xDatabaseLB);
534  }
535 
536  if (aItem.m_bCont)
537  m_xContButton->set_active(true);
538  else
539  m_xSheetButton->set_active(true);
540 }
541 
543  : SfxTabPage(pPage, pController, "modules/swriter/ui/privateuserpage.ui", "PrivateUserPage", &rSet)
544  , m_xFirstNameED(m_xBuilder->weld_entry("firstname"))
545  , m_xNameED(m_xBuilder->weld_entry("lastname"))
546  , m_xShortCutED(m_xBuilder->weld_entry("shortname"))
547  , m_xFirstName2ED(m_xBuilder->weld_entry("firstname2"))
548  , m_xName2ED(m_xBuilder->weld_entry("lastname2"))
549  , m_xShortCut2ED(m_xBuilder->weld_entry("shortname2"))
550  , m_xStreetED(m_xBuilder->weld_entry("street"))
551  , m_xZipED(m_xBuilder->weld_entry("izip"))
552  , m_xCityED(m_xBuilder->weld_entry("icity"))
553  , m_xCountryED(m_xBuilder->weld_entry("country"))
554  , m_xStateED(m_xBuilder->weld_entry("state"))
555  , m_xTitleED(m_xBuilder->weld_entry("title"))
556  , m_xProfessionED(m_xBuilder->weld_entry("job"))
557  , m_xPhoneED(m_xBuilder->weld_entry("phone"))
558  , m_xMobilePhoneED(m_xBuilder->weld_entry("mobile"))
559  , m_xFaxED(m_xBuilder->weld_entry("fax"))
560  , m_xHomePageED(m_xBuilder->weld_entry("url"))
561  , m_xMailED(m_xBuilder->weld_entry("email"))
562 {
564 }
565 
567 {
568 }
569 
570 std::unique_ptr<SfxTabPage> SwPrivateDataPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
571 {
572  return std::make_unique<SwPrivateDataPage>(pPage, pController, *rSet);
573 }
574 
576 {
577  Reset(&rSet);
578 }
579 
581 {
582  if (_pSet)
583  FillItemSet(_pSet);
584  return DeactivateRC::LeavePage;
585 }
586 
588 {
589  const SfxItemSet* pExampleSet = GetDialogExampleSet();
590  assert(pExampleSet);
591  SwLabItem aItem = static_cast<const SwLabItem&>(pExampleSet->Get(FN_LABEL));
592 
593  aItem.m_aPrivFirstName = m_xFirstNameED->get_text();
594  aItem.m_aPrivName = m_xNameED->get_text();
595  aItem.m_aPrivShortCut = m_xShortCutED->get_text();
596  aItem.m_aPrivFirstName2 = m_xFirstName2ED->get_text();
597  aItem.m_aPrivName2 = m_xName2ED->get_text();
598  aItem.m_aPrivShortCut2 = m_xShortCut2ED->get_text();
599  aItem.m_aPrivStreet = m_xStreetED->get_text();
600  aItem.m_aPrivZip = m_xZipED->get_text();
601  aItem.m_aPrivCity = m_xCityED->get_text();
602  aItem.m_aPrivCountry = m_xCountryED->get_text();
603  aItem.m_aPrivState = m_xStateED->get_text();
604  aItem.m_aPrivTitle = m_xTitleED->get_text();
605  aItem.m_aPrivProfession= m_xProfessionED->get_text();
606  aItem.m_aPrivPhone = m_xPhoneED->get_text();
607  aItem.m_aPrivMobile = m_xMobilePhoneED->get_text();
608  aItem.m_aPrivFax = m_xFaxED->get_text();
609  aItem.m_aPrivWWW = m_xHomePageED->get_text();
610  aItem.m_aPrivMail = m_xMailED->get_text();
611 
612  rSet->Put(aItem);
613  return true;
614 }
615 
617 {
618  const SwLabItem& aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL) );
619  m_xFirstNameED->set_text(aItem.m_aPrivFirstName);
620  m_xNameED->set_text(aItem.m_aPrivName);
621  m_xShortCutED->set_text(aItem.m_aPrivShortCut);
622  m_xFirstName2ED->set_text(aItem.m_aPrivFirstName2);
623  m_xName2ED->set_text(aItem.m_aPrivName2);
624  m_xShortCut2ED->set_text(aItem.m_aPrivShortCut2);
625  m_xStreetED->set_text(aItem.m_aPrivStreet);
626  m_xZipED->set_text(aItem.m_aPrivZip);
627  m_xCityED->set_text(aItem.m_aPrivCity);
628  m_xCountryED->set_text(aItem.m_aPrivCountry);
629  m_xStateED->set_text(aItem.m_aPrivState);
630  m_xTitleED->set_text(aItem.m_aPrivTitle);
631  m_xProfessionED->set_text(aItem.m_aPrivProfession);
632  m_xPhoneED->set_text(aItem.m_aPrivPhone);
633  m_xMobilePhoneED->set_text(aItem.m_aPrivMobile);
634  m_xFaxED->set_text(aItem.m_aPrivFax);
635  m_xHomePageED->set_text(aItem.m_aPrivWWW);
636  m_xMailED->set_text(aItem.m_aPrivMail);
637 }
638 
640  : SfxTabPage(pPage, pController, "modules/swriter/ui/businessdatapage.ui", "BusinessDataPage", &rSet)
641  , m_xCompanyED(m_xBuilder->weld_entry("company"))
642  , m_xCompanyExtED(m_xBuilder->weld_entry("company2"))
643  , m_xSloganED(m_xBuilder->weld_entry("slogan"))
644  , m_xStreetED(m_xBuilder->weld_entry("street"))
645  , m_xZipED(m_xBuilder->weld_entry("izip"))
646  , m_xCityED(m_xBuilder->weld_entry("icity"))
647  , m_xCountryED(m_xBuilder->weld_entry("country"))
648  , m_xStateED(m_xBuilder->weld_entry("state"))
649  , m_xPositionED(m_xBuilder->weld_entry("position"))
650  , m_xPhoneED(m_xBuilder->weld_entry("phone"))
651  , m_xMobilePhoneED(m_xBuilder->weld_entry("mobile"))
652  , m_xFaxED(m_xBuilder->weld_entry("fax"))
653  , m_xHomePageED(m_xBuilder->weld_entry("url"))
654  , m_xMailED(m_xBuilder->weld_entry("email"))
655 {
657 }
658 
660 {
661 }
662 
663 std::unique_ptr<SfxTabPage> SwBusinessDataPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
664 {
665  return std::make_unique<SwBusinessDataPage>(pPage, pController, *rSet);
666 }
667 
669 {
670  Reset(&rSet);
671 }
672 
674 {
675  if (_pSet)
676  FillItemSet(_pSet);
677  return DeactivateRC::LeavePage;
678 }
679 
681 {
682  const SfxItemSet* pExampleSet = GetDialogExampleSet();
683  assert(pExampleSet);
684  SwLabItem aItem = static_cast<const SwLabItem&>(pExampleSet->Get(FN_LABEL));
685 
686  aItem.m_aCompCompany = m_xCompanyED->get_text();
687  aItem.m_aCompCompanyExt= m_xCompanyExtED->get_text();
688  aItem.m_aCompSlogan = m_xSloganED->get_text();
689  aItem.m_aCompStreet = m_xStreetED->get_text();
690  aItem.m_aCompZip = m_xZipED->get_text();
691  aItem.m_aCompCity = m_xCityED->get_text();
692  aItem.m_aCompCountry = m_xCountryED->get_text();
693  aItem.m_aCompState = m_xStateED->get_text();
694  aItem.m_aCompPosition = m_xPositionED->get_text();
695  aItem.m_aCompPhone = m_xPhoneED->get_text();
696  aItem.m_aCompMobile = m_xMobilePhoneED->get_text();
697  aItem.m_aCompFax = m_xFaxED->get_text();
698  aItem.m_aCompWWW = m_xHomePageED->get_text();
699  aItem.m_aCompMail = m_xMailED->get_text();
700 
701  rSet->Put(aItem);
702  return true;
703 }
704 
706 {
707  const SwLabItem& aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL) );
708  m_xCompanyED->set_text(aItem.m_aCompCompany);
709  m_xCompanyExtED->set_text(aItem.m_aCompCompanyExt);
710  m_xSloganED->set_text(aItem.m_aCompSlogan);
711  m_xStreetED->set_text(aItem.m_aCompStreet);
712  m_xZipED->set_text(aItem.m_aCompZip);
713  m_xCityED->set_text(aItem.m_aCompCity);
714  m_xCountryED->set_text(aItem.m_aCompCountry);
715  m_xStateED->set_text(aItem.m_aCompState);
716  m_xPositionED->set_text(aItem.m_aCompPosition);
717  m_xPhoneED->set_text(aItem.m_aCompPhone);
718  m_xMobilePhoneED->set_text(aItem.m_aCompMobile);
719  m_xFaxED->set_text(aItem.m_aCompFax);
720  m_xHomePageED->set_text(aItem.m_aCompWWW);
721  m_xMailED->set_text(aItem.m_aCompMail);
722 }
723 
724 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString m_aMake
Definition: labimg.hxx:48
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: labprt.cxx:87
OUString m_aCompStreet
Definition: labimg.hxx:89
OUString m_aPrivCity
Definition: labimg.hxx:76
std::unique_ptr< weld::Entry > m_xCompanyED
Definition: swuilabimp.hxx:117
sal_Int32 m_lHeight
Definition: labimg.hxx:53
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: label1.cxx:452
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
sal_Int32 m_nRows
Definition: labrec.hxx:50
OUString m_aCompSlogan
Definition: labimg.hxx:88
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
#define HID_BUSINESS_FMT_PAGE_SHEET
Definition: helpids.h:104
sal_Int32 m_lVDist
Definition: labimg.hxx:51
Printer * GetPrt()
Definition: label1.cxx:208
SwLabRec * GetSelectedEntryPos()
Definition: label1.cxx:413
bool m_bAddr
Definition: labimg.hxx:62
std::unique_ptr< weld::Widget > m_xAddressFrame
Definition: swuilabimp.hxx:33
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: label1.cxx:570
bool GetTableNames(weld::ComboBox &rBox, const OUString &rDBName)
Fill listbox with all table names of a database.
Definition: dbmgr.cxx:619
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: label1.cxx:663
std::unique_ptr< weld::Entry > m_xStreetED
Definition: swuilabimp.hxx:88
OUString m_aPrivTitle
Definition: labimg.hxx:79
tools::Long m_nPWidth
Definition: labrec.hxx:47
std::unique_ptr< weld::Entry > m_xZipED
Definition: swuilabimp.hxx:121
void FillItem(SwLabItem &rItem)
Definition: label1.cxx:460
sal_Int32 m_lLeft
Definition: labimg.hxx:54
std::unique_ptr< weld::ComboBox > m_xDBFieldLB
Definition: swuilabimp.hxx:39
bool m_bLabel
Definition: label.hxx:44
long Long
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: label1.cxx:668
std::unique_ptr< weld::Entry > m_xCompanyExtED
Definition: swuilabimp.hxx:118
std::unique_ptr< weld::TextView > m_xWritingEdit
Definition: swuilabimp.hxx:35
std::unique_ptr< weld::ComboBox > m_xHiddenSortTypeBox
Definition: swuilabimp.hxx:44
std::unique_ptr< SfxItemSet > m_xExampleSet
void RemoveTabPage(const OString &rName)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: label1.cxx:580
std::unique_ptr< weld::ComboBox > m_xMakeBox
Definition: swuilabimp.hxx:42
void DisplayFormat()
Definition: label1.cxx:388
std::unique_ptr< weld::CheckButton > m_xAddrBox
Definition: swuilabimp.hxx:34
tools::Long m_nHDist
Definition: labrec.hxx:41
OUString sActDBName
Definition: swuilabimp.hxx:30
void setfldval(weld::MetricSpinButton &rField, int lValue)
Definition: labimp.hxx:29
SwLabItem aItem
Definition: swuilabimp.hxx:31
SfxItemSet * GetInputSetImpl()
std::unique_ptr< weld::ComboBox > m_xTypeBox
Definition: swuilabimp.hxx:43
OUString m_aCompCity
Definition: labimg.hxx:91
virtual ~SwLabPage() override
Definition: label1.cxx:267
OUString m_aPrivPhone
Definition: labimg.hxx:81
std::unique_ptr< weld::Entry > m_xPositionED
Definition: swuilabimp.hxx:125
OUString m_aCompMobile
Definition: labimg.hxx:96
IMPL_LINK_NOARG(SwLabPage, AddrHdl, weld::Toggleable &, void)
Definition: label1.cxx:281
OUString m_aPrivMobile
Definition: labimg.hxx:82
OUString m_aLstType
Definition: labimg.hxx:44
sal_Int32 m_lUpper
Definition: labimg.hxx:55
OUString m_aPrivMail
Definition: labimg.hxx:85
OUString m_aCompCompanyExt
Definition: labimg.hxx:87
OUString m_aPrivWWW
Definition: labimg.hxx:84
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
virtual void Reset(const SfxItemSet *rSet) override
Definition: label1.cxx:616
static css::uno::Sequence< OUString > GetExistingDatabaseNames()
Definition: dbmgr.cxx:2508
sal_Int32 m_lPWidth
Definition: labimg.hxx:61
Reference< XNameAccess > m_xContainer
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: label1.cxx:447
OUString m_aPrivShortCut2
Definition: labimg.hxx:73
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: label1.cxx:442
bool m_bCont
Definition: labrec.hxx:51
std::unique_ptr< weld::Entry > m_xShortCutED
Definition: swuilabimp.hxx:84
uno::Type m_aType
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: label1.cxx:575
tools::Long m_nPHeight
Definition: labrec.hxx:48
void SetExchangeSupport()
OUString m_aPrivStreet
Definition: labimg.hxx:74
int nCount
LineEnd GetSystemLineEnd()
std::unique_ptr< weld::Entry > m_xMobilePhoneED
Definition: swuilabimp.hxx:127
std::unique_ptr< weld::Entry > m_xName2ED
Definition: swuilabimp.hxx:86
OUString m_aPrivProfession
Definition: labimg.hxx:80
bool m_bCont
Definition: labimg.hxx:63
SwLabPrtPage * m_pPrtPage
Definition: label.hxx:36
void InitDatabaseBox()
Definition: label1.cxx:420
void SetFromItem(const SwLabItem &rItem)
Definition: label1.cxx:38
OUString m_aCompZip
Definition: labimg.hxx:90
OUString m_aPrivState
Definition: labimg.hxx:78
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: label1.cxx:587
OUString m_aPrivFax
Definition: labimg.hxx:83
virtual ~SwBusinessDataPage() override
Definition: label1.cxx:659
SwDBManager * GetDBManager() const
Definition: swuilabimp.hxx:77
OUString m_aPrivCountry
Definition: labimg.hxx:77
#define HID_BUSINESS_FMT_PAGE_BRAND
Definition: helpids.h:105
OUString m_aPrivZip
Definition: labimg.hxx:75
std::unique_ptr< weld::Entry > m_xShortCut2ED
Definition: swuilabimp.hxx:87
void ReplaceGroup_(const OUString &rMake)
Definition: label1.cxx:67
std::unique_ptr< weld::Button > m_xInsertBT
Definition: swuilabimp.hxx:38
std::unique_ptr< weld::Entry > m_xCityED
Definition: swuilabimp.hxx:90
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: label1.cxx:680
std::unique_ptr< weld::Entry > m_xStreetED
Definition: swuilabimp.hxx:120
std::unique_ptr< weld::Entry > m_xZipED
Definition: swuilabimp.hxx:89
std::vector< OUString > & Makes()
Definition: label.hxx:63
virtual void Reset(const SfxItemSet *rSet) override
Definition: label1.cxx:484
OptionalString sType
std::unique_ptr< weld::Entry > m_xNameED
Definition: swuilabimp.hxx:83
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:763
int i
OUString m_aPrivFirstName2
Definition: labimg.hxx:71
tools::Long m_nHeight
Definition: labrec.hxx:44
sal_Int32 m_lHDist
Definition: labimg.hxx:50
void SetToBusinessCard()
Definition: label1.cxx:271
Printer * GetPrt()
Definition: labprt.hxx:61
virtual ~SwPrivateDataPage() override
Definition: label1.cxx:566
sal_Int32 m_nRows
Definition: labimg.hxx:57
std::unique_ptr< weld::Entry > m_xProfessionED
Definition: swuilabimp.hxx:94
std::unique_ptr< weld::Entry > m_xPhoneED
Definition: swuilabimp.hxx:95
tools::Long m_nUpper
Definition: labrec.hxx:46
std::unique_ptr< weld::Entry > m_xCountryED
Definition: swuilabimp.hxx:123
OUString m_aType
Definition: labimg.hxx:49
OUString m_aCompFax
Definition: labimg.hxx:97
SwLabRec * GetRecord(std::u16string_view rRecName, bool bCont)
Definition: label1.cxx:185
std::unique_ptr< weld::Entry > m_xFirstNameED
Definition: swuilabimp.hxx:82
sal_Int32 m_nCols
Definition: labimg.hxx:56
#define HID_BUSINESS_FMT_PAGE_TYPE
Definition: helpids.h:106
SwPrivateDataPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: label1.cxx:542
OUString m_aCompWWW
Definition: labimg.hxx:98
OUString m_aCompPhone
Definition: labimg.hxx:95
std::unique_ptr< weld::Entry > m_xCityED
Definition: swuilabimp.hxx:122
OUString m_sBusinessCardDlg
Definition: label.hxx:43
OUString MakeSender()
Definition: envimg.cxx:48
void FillLabels(const OUString &rManufacturer, SwLabRecs &rLabArr)
Definition: labelcfg.cxx:242
OUString m_aPrivShortCut
Definition: labimg.hxx:70
OUString m_aCompMail
Definition: labimg.hxx:99
virtual void Reset(const SfxItemSet *rSet) override
Definition: label1.cxx:705
#define DB_DELIM
Definition: swtypes.hxx:131
const SfxItemSet * GetDialogExampleSet() const
#define HID_BUSINESS_FMT_PAGE
Definition: helpids.h:102
sal_Int32 m_lPHeight
Definition: labimg.hxx:60
std::unique_ptr< weld::RadioButton > m_xContButton
Definition: swuilabimp.hxx:40
#define HID_BUSINESS_FMT_PAGE_CONT
Definition: helpids.h:103
std::unique_ptr< SwLabRecs > m_pRecs
Definition: label.hxx:41
sal_Int32 m_nCols
Definition: labrec.hxx:49
SwLabDlg * GetParentSwLabDlg()
Definition: swuilabimp.hxx:71
std::unique_ptr< weld::Entry > m_xMobilePhoneED
Definition: swuilabimp.hxx:96
OUString m_aType
Definition: labrec.hxx:40
const std::vector< OUString > & GetManufacturers() const
Definition: labelcfg.hxx:50
std::unique_ptr< weld::Entry > m_xFaxED
Definition: swuilabimp.hxx:128
std::unique_ptr< weld::Entry > m_xMailED
Definition: swuilabimp.hxx:99
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: labfmt.cxx:405
tools::Long m_nVDist
Definition: labrec.hxx:42
std::unique_ptr< weld::Label > m_xFormatInfo
Definition: swuilabimp.hxx:45
OUString m_aCompState
Definition: labimg.hxx:93
std::unique_ptr< weld::Entry > m_xTitleED
Definition: swuilabimp.hxx:93
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::Entry > m_xStateED
Definition: swuilabimp.hxx:124
OUString aLstGroup
Definition: label.hxx:42
weld::Window * GetFrameWeld() const
SwLabelConfig aLabelsCfg
Definition: label.hxx:34
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
tools::Long m_nWidth
Definition: labrec.hxx:43
OUString m_aPrivName2
Definition: labimg.hxx:72
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: label1.cxx:75
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
SwDBManager * pDBManager
Definition: label.hxx:35
Reference< XExecutableDialog > m_xDialog
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: label1.cxx:673
virtual const SfxItemSet * GetExampleSet() const override
OUString m_aCompPosition
Definition: labimg.hxx:94
void UpdateGroup(const OUString &rMake)
Definition: label.hxx:73
IMPL_LINK(SwLabPage, DatabaseHdl, weld::ComboBox &, rListBox, void)
Definition: label1.cxx:292
virtual ~SwLabDlg() override
Definition: label1.cxx:159
std::unique_ptr< weld::Entry > m_xHomePageED
Definition: swuilabimp.hxx:98
tools::Long m_nLeft
Definition: labrec.hxx:45
OUString m_aLstMake
Definition: labimg.hxx:43
SwBusinessDataPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: label1.cxx:639
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: label1.cxx:476
DeactivateRC
std::vector< std::unique_ptr< SwLabRec > > SwLabRecs
Definition: labrec.hxx:54
OUString m_sDBName
Definition: labimg.hxx:45
std::vector< OUString > aMakes
Definition: label.hxx:39
std::unique_ptr< weld::Entry > m_xCountryED
Definition: swuilabimp.hxx:91
std::unique_ptr< weld::Entry > m_xHomePageED
Definition: swuilabimp.hxx:129
OUString m_aCompCompany
Definition: labimg.hxx:86
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
void FillItem(SwLabItem &rItem) const
Definition: label1.cxx:53
void GetColumnNames(weld::ComboBox &rBox, const OUString &rDBName, const OUString &rTableName)
Fill listbox with all column names of a database table.
Definition: dbmgr.cxx:659
std::unique_ptr< weld::Entry > m_xFaxED
Definition: swuilabimp.hxx:97
SwLabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: label1.cxx:216
std::unique_ptr< weld::Entry > m_xSloganED
Definition: swuilabimp.hxx:119
std::unique_ptr< weld::Entry > m_xPhoneED
Definition: swuilabimp.hxx:126
std::unique_ptr< weld::Entry > m_xFirstName2ED
Definition: swuilabimp.hxx:85
std::unique_ptr< weld::Entry > m_xStateED
Definition: swuilabimp.hxx:92
sal_Int32 m_lWidth
Definition: labimg.hxx:52
SwLabDlg(weld::Window *pParent, const SfxItemSet &rSet, SwDBManager *pDBManager, bool bLabel)
Definition: label1.cxx:91
std::unique_ptr< weld::Entry > m_xMailED
Definition: swuilabimp.hxx:130
OUString m_aPrivName
Definition: labimg.hxx:69
aStr
OUString m_aWriting
Definition: labimg.hxx:47
SwLabRecs & Recs()
Definition: label.hxx:57
OUString m_aCompCountry
Definition: labimg.hxx:92
OUString m_aPrivFirstName
Definition: labimg.hxx:68
void GetLabItem(SwLabItem &rItem)
Definition: label1.cxx:164
std::unique_ptr< weld::ComboBox > m_xDatabaseLB
Definition: swuilabimp.hxx:36
std::unique_ptr< weld::ComboBox > m_xTableLB
Definition: swuilabimp.hxx:37
std::unique_ptr< weld::RadioButton > m_xSheetButton
Definition: swuilabimp.hxx:41