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