1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/waitobj.hxx>
21 #include <rtl/ustring.hxx>
22 #include "svtools/treelistentry.hxx"
23 #include <com/sun/star/uno/Sequence.h>
24 #include <swtypes.hxx>
30 #include <unotools.hxx>
35 #include <globals.hrc>
39 extern SW_DLLPUBLIC String
MakeSender();
42 void SwLabRec::SetFromItem( const SwLabItem
& rItem
)
44 lHDist
= rItem
.lHDist
;
45 lVDist
= rItem
.lVDist
;
46 lWidth
= rItem
.lWidth
;
47 lHeight
= rItem
.lHeight
;
49 lUpper
= rItem
.lUpper
;
52 lPWidth
= rItem
.lPWidth
;
53 lPHeight
= rItem
.lPHeight
;
57 void SwLabRec::FillItem( SwLabItem
& rItem
) const
59 rItem
.lHDist
= lHDist
;
60 rItem
.lVDist
= lVDist
;
61 rItem
.lWidth
= lWidth
;
62 rItem
.lHeight
= lHeight
;
64 rItem
.lUpper
= lUpper
;
66 rItem
.lPWidth
= lPWidth
;
67 rItem
.lPHeight
= lPHeight
;
71 void SwLabDlg::_ReplaceGroup( const String
&rMake
)
74 pRecs
->erase(pRecs
->begin() + 1, pRecs
->end());
75 aLabelsCfg
.FillLabels(OUString(rMake
), *pRecs
);
79 void SwLabDlg::PageCreated(sal_uInt16 nId
, SfxTabPage
&rPage
)
81 if (nId
== TP_LAB_LAB
)
85 ((SwLabPage
*)&rPage
)->SetNewDBMgr(pNewDBMgr
);
86 ((SwLabPage
*)&rPage
)->InitDatabaseBox();
89 ((SwLabPage
*)&rPage
)->SetToBusinessCard();
91 else if (nId
== TP_LAB_PRT
)
92 pPrtPage
= (SwLabPrtPage
*)&rPage
;
95 SwLabDlg::SwLabDlg(Window
* pParent
, const SfxItemSet
& rSet
,
96 SwNewDBMgr
* pDBMgr
, sal_Bool bLabel
) :
97 SfxTabDialog( pParent
, SW_RES(DLG_LAB
), &rSet
, sal_False
),
101 pRecs ( new SwLabRecs() ),
102 sBusinessCardDlg(SW_RES(ST_BUSINESSCARDDLG
)),
103 sFormat(SW_RES(ST_FIRSTPAGE_LAB
)),
104 sMedium(SW_RES(ST_FIRSTPAGE_BC
)),
107 WaitObject
aWait( pParent
);
111 GetOKButton().SetText(String(SW_RES(STR_BTN_NEW_DOC
)));
112 GetOKButton().SetHelpId(HID_LABEL_INSERT
);
113 GetOKButton().SetHelpText(aEmptyStr
); // in order for generated help text to get used
115 AddTabPage(TP_LAB_LAB
, m_bLabel
? sFormat
: sMedium
,SwLabPage ::Create
, 0, sal_False
, 0);
116 AddTabPage(TP_VISITING_CARDS
, SwVisitingCardPage::Create
, 0);
117 AddTabPage(TP_LAB_FMT
, SwLabFmtPage::Create
, 0);
118 AddTabPage(TP_LAB_PRT
, SwLabPrtPage::Create
, 0);
119 AddTabPage(TP_BUSINESS_DATA
, SwBusinessDataPage::Create
, 0 );
120 AddTabPage(TP_PRIVATE_DATA
, SwPrivateDataPage::Create
, 0);
125 RemoveTabPage(TP_BUSINESS_DATA
);
126 RemoveTabPage(TP_PRIVATE_DATA
);
127 RemoveTabPage(TP_VISITING_CARDS
);
131 SetText(sBusinessCardDlg
);
133 // Read user label from writer.cfg
134 SwLabItem
aItem((const SwLabItem
&)rSet
.Get( FN_LABEL
));
135 SwLabRec
* pRec
= new SwLabRec
;
136 const String
aTmp( SW_RES( STR_CUSTOM
) );
137 pRec
->aMake
= pRec
->aType
= aTmp
;
138 pRec
->SetFromItem( aItem
);
140 bool bDouble
= false;
142 for (sal_uInt16 nRecPos
= 0; nRecPos
< pRecs
->size(); nRecPos
++)
144 if (pRec
->aMake
== (*pRecs
)[nRecPos
]->aMake
&&
145 pRec
->aType
== (*pRecs
)[nRecPos
]->aType
)
153 pRecs
->insert( pRecs
->begin(), pRec
);
155 sal_uInt16 nLstGroup
= 0;
156 const std::vector
<OUString
>& rMan
= aLabelsCfg
.GetManufacturers();
157 for(sal_uInt16 nMan
= 0; nMan
< rMan
.size(); nMan
++)
159 aMakes
.push_back(rMan
[nMan
]);
160 if ( rMan
[nMan
] == aItem
.aLstMake
)
164 if ( !aMakes
.empty() )
165 _ReplaceGroup( aMakes
[nLstGroup
] );
168 pExampleSet
->Put(aItem
);
171 SwLabDlg::~SwLabDlg()
176 void SwLabDlg::GetLabItem(SwLabItem
&rItem
)
178 const SwLabItem
& rActItem
= (const SwLabItem
&)GetExampleSet()->Get(FN_LABEL
);
179 const SwLabItem
& rOldItem
= (const SwLabItem
&)GetInputSetImpl()->Get(FN_LABEL
);
181 if (rActItem
!= rOldItem
)
183 // Was already "put" with (hopefully) correct content
190 // In rItem there are only settings defined by users.
191 // Therefore get the real settings directly from Record
192 SwLabRec
* pRec
= GetRecord(rItem
.aType
, rItem
.bCont
);
193 pRec
->FillItem( rItem
);
197 SwLabRec
* SwLabDlg::GetRecord(const String
&rRecName
, sal_Bool bCont
)
199 SwLabRec
* pRec
= NULL
;
201 String
sCustom(SW_RES(STR_CUSTOM
));
203 const sal_uInt16 nCount
= Recs().size();
204 for (sal_uInt16 i
= 0; i
< nCount
; i
++)
207 if (pRec
->aType
!= sCustom
&&
208 rRecName
== pRec
->aType
&& bCont
== pRec
->bCont
)
214 if (!bFound
) // User defined
220 Printer
*SwLabDlg::GetPrt()
223 return (pPrtPage
->GetPrt());
228 SwLabPage::SwLabPage(Window
* pParent
, const SfxItemSet
& rSet
) :
229 SfxTabPage(pParent
, SW_RES(TP_LAB_LAB
), rSet
),
231 aItem ((const SwLabItem
&) rSet
.Get(FN_LABEL
)),
233 aWritingFL (this, SW_RES(FL_WRITING
)),
234 aWritingText (this, SW_RES(TXT_WRITING
)),
235 aAddrBox (this, SW_RES(BOX_ADDR
)),
236 aWritingEdit (this, SW_RES(EDT_WRITING
)),
237 aDatabaseFT (this, SW_RES(FT_DATABASE
)),
238 aDatabaseLB (this, SW_RES(LB_DATABASE
)),
239 aTableFT (this, SW_RES(FT_TABLE
)),
240 aTableLB (this, SW_RES(LB_TABLE
)),
241 aInsertBT (this, SW_RES(BTN_INSERT
)),
242 aDBFieldFT (this, SW_RES(FT_DBFIELD
)),
243 aDBFieldLB (this, SW_RES(LB_DBFIELD
)),
244 aFormatFL (this, SW_RES(FL_FORMAT
)),
245 aContButton (this, SW_RES(BTN_CONT
)),
246 aSheetButton (this, SW_RES(BTN_SHEET
)),
247 aMakeText (this, SW_RES(TXT_MAKE
)),
248 aMakeBox (this, SW_RES(BOX_MAKE
)),
249 aTypeText (this, SW_RES(TXT_TYPE
)),
250 aTypeBox (this, SW_RES(BOX_TYPE
)),
251 aHiddenSortTypeBox(this, WB_SORT
|WB_HIDE
),
252 aFormatInfo (this, SW_RES(INF_FORMAT
))
254 WaitObject
aWait( pParent
);
257 SetExchangeSupport();
261 aAddrBox
.SetClickHdl (LINK(this, SwLabPage
, AddrHdl
));
262 aDatabaseLB
.SetSelectHdl(LINK(this, SwLabPage
, DatabaseHdl
));
263 aTableLB
.SetSelectHdl(LINK(this, SwLabPage
, DatabaseHdl
));
264 aInsertBT
.SetClickHdl (LINK(this, SwLabPage
, FieldHdl
));
265 aContButton
.SetClickHdl (LINK(this, SwLabPage
, PageHdl
));
266 aSheetButton
.SetClickHdl (LINK(this, SwLabPage
, PageHdl
));
267 aMakeBox
.SetSelectHdl(LINK(this, SwLabPage
, MakeHdl
));
268 aTypeBox
.SetSelectHdl(LINK(this, SwLabPage
, TypeHdl
));
272 size_t nLstGroup
= 0;
274 const sal_uInt16 nCount
= (sal_uInt16
)GetParentSwLabDlg()->Makes().size();
275 for(size_t i
= 0; i
< nCount
; ++i
)
277 OUString
& rStr
= GetParentSwLabDlg()->Makes()[i
];
278 aMakeBox
.InsertEntry( rStr
);
280 if ( rStr
== aItem
.aLstMake
)
284 aMakeBox
.SelectEntryPos( nLstGroup
);
285 aMakeBox
.GetSelectHdl().Call( &aMakeBox
);
288 SwLabPage::~SwLabPage()
292 static void lcl_ChgYPos(Window
& rWin
, long nDiff
)
294 Point
aTempPos(rWin
.GetPosPixel());
295 aTempPos
.Y() += nDiff
;
296 rWin
.SetPosPixel(aTempPos
);
299 void SwLabPage::SetToBusinessCard()
301 SetHelpId(HID_BUSINESS_FMT_PAGE
);
302 aContButton
.SetHelpId(HID_BUSINESS_FMT_PAGE_CONT
);
303 aSheetButton
.SetHelpId(HID_BUSINESS_FMT_PAGE_SHEET
);
304 aMakeBox
.SetHelpId(HID_BUSINESS_FMT_PAGE_BRAND
);
305 aTypeBox
.SetHelpId(HID_BUSINESS_FMT_PAGE_TYPE
);
306 m_bLabel
= sal_False
;
320 Point
aFLPos(aWritingFL
.GetPosPixel());
321 long nDiffPos
= aFormatFL
.GetPosPixel().Y() - aFLPos
.Y();
322 Size
aFLSz(aFormatFL
.GetSizePixel());
323 aFormatFL
.SetPosSizePixel(aFLPos
, aFLSz
);
325 // move all controls up
326 lcl_ChgYPos(aContButton
, -nDiffPos
);
327 lcl_ChgYPos(aSheetButton
, -nDiffPos
);
328 lcl_ChgYPos(aMakeText
, -nDiffPos
);
330 lcl_ChgYPos(aTypeText
, -nDiffPos
);
331 lcl_ChgYPos(aFormatInfo
, -nDiffPos
);
334 aTmpSz
= LogicToPixel(aTmpSz
, MAP_APPFONT
);
336 lcl_ChgYPos(aMakeBox
, - nDiffPos
);
337 Point
aLBPos(aMakeBox
.GetPosPixel());
338 aLBPos
.Y() += aMakeBox
.GetSizePixel().Height() + aTmpSz
.Height();
339 aTypeBox
.SetPosPixel(aLBPos
);
342 IMPL_LINK_NOARG(SwLabPage
, AddrHdl
)
346 if ( aAddrBox
.IsChecked() )
347 aWriting
= convertLineEnd(MakeSender(), GetSystemLineEnd());
349 aWritingEdit
.SetText( aWriting
);
350 aWritingEdit
.GrabFocus();
354 IMPL_LINK( SwLabPage
, DatabaseHdl
, ListBox
*, pListBox
)
356 sActDBName
= aDatabaseLB
.GetSelectEntry();
358 WaitObject
aObj( GetParentSwLabDlg() );
360 if (pListBox
== &aDatabaseLB
)
361 GetNewDBMgr()->GetTableNames(&aTableLB
, sActDBName
);
363 GetNewDBMgr()->GetColumnNames(&aDBFieldLB
, sActDBName
, aTableLB
.GetSelectEntry());
367 IMPL_LINK_NOARG(SwLabPage
, FieldHdl
)
369 OUString
aStr("<" + OUString(aDatabaseLB
.GetSelectEntry()) + "." +
370 OUString(aTableLB
.GetSelectEntry()) + "." +
371 (aTableLB
.GetEntryData(aTableLB
.GetSelectEntryPos()) == 0 ? OUString("0") : OUString("1")) + "." +
372 aDBFieldLB
.GetSelectEntry() + ">");
373 aWritingEdit
.ReplaceSelected(aStr
);
374 Selection aSel
= aWritingEdit
.GetSelection();
375 aWritingEdit
.GrabFocus();
376 aWritingEdit
.SetSelection(aSel
);
380 IMPL_LINK_NOARG_INLINE_START(SwLabPage
, PageHdl
)
382 aMakeBox
.GetSelectHdl().Call( &aMakeBox
);
385 IMPL_LINK_NOARG_INLINE_END(SwLabPage
, PageHdl
)
387 IMPL_LINK_NOARG(SwLabPage
, MakeHdl
)
389 WaitObject
aWait( GetParentSwLabDlg() );
392 aHiddenSortTypeBox
.Clear();
393 GetParentSwLabDlg()->TypeIds().clear();
395 const String aMake
= aMakeBox
.GetSelectEntry();
396 GetParentSwLabDlg()->ReplaceGroup( aMake
);
397 aItem
.aLstMake
= aMake
;
399 const sal_Bool bCont
= aContButton
.IsChecked();
400 const sal_uInt16 nCount
= GetParentSwLabDlg()->Recs().size();
401 sal_uInt16 nLstType
= 0;
403 const String
sCustom(SW_RES(STR_CUSTOM
));
404 //insert the entries into the sorted list box
405 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
407 const String
aType ( GetParentSwLabDlg()->Recs()[i
]->aType
);
408 bool bInsert
= false;
409 if ( GetParentSwLabDlg()->Recs()[i
]->aType
== sCustom
)
412 aTypeBox
.InsertEntry(aType
);
414 else if ( GetParentSwLabDlg()->Recs()[i
]->bCont
== bCont
)
416 if ( aHiddenSortTypeBox
.GetEntryPos(aType
) == LISTBOX_ENTRY_NOTFOUND
)
419 aHiddenSortTypeBox
.InsertEntry( aType
);
424 GetParentSwLabDlg()->TypeIds().push_back(i
);
425 if ( !nLstType
&& aType
== String(aItem
.aLstType
) )
426 nLstType
= GetParentSwLabDlg()->TypeIds().size();
429 for(sal_uInt16 nEntry
= 0; nEntry
< aHiddenSortTypeBox
.GetEntryCount(); nEntry
++)
431 aTypeBox
.InsertEntry(aHiddenSortTypeBox
.GetEntry(nEntry
));
434 aTypeBox
.SelectEntry(aItem
.aLstType
);
436 aTypeBox
.SelectEntryPos(0);
437 aTypeBox
.GetSelectHdl().Call( &aTypeBox
);
441 IMPL_LINK_NOARG_INLINE_START(SwLabPage
, TypeHdl
)
444 aItem
.aType
= aTypeBox
.GetSelectEntry();
447 IMPL_LINK_NOARG_INLINE_END(SwLabPage
, TypeHdl
)
449 void SwLabPage::DisplayFormat()
451 MetricField
aField(this, WinBits(0));
452 FieldUnit aMetric
= ::GetDfltMetric(sal_False
);
453 SetMetric(aField
, aMetric
);
454 aField
.SetDecimalDigits(2);
456 aField
.SetMax (LONG_MAX
);
458 SwLabRec
* pRec
= GetSelectedEntryPos();
459 aItem
.aLstType
= pRec
->aType
;
460 SETFLDVAL(aField
, pRec
->lWidth
);
462 const String aWString
= aField
.GetText();
464 SETFLDVAL(aField
, pRec
->lHeight
);
467 String aText
= pRec
->aType
;
468 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": "));
470 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" x "));
471 aText
+= aField
.GetText();
472 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" ("));
473 aText
+= OUString::number( pRec
->nCols
);
474 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" x "));
475 aText
+= OUString::number( pRec
->nRows
);
477 aFormatInfo
.SetText(aText
);
480 SwLabRec
* SwLabPage::GetSelectedEntryPos()
482 String
sSelEntry(aTypeBox
.GetSelectEntry());
484 return GetParentSwLabDlg()->GetRecord(sSelEntry
, aContButton
.IsChecked());
487 void SwLabPage::InitDatabaseBox()
492 ::com::sun::star::uno::Sequence
<OUString
> aDataNames
= SwNewDBMgr::GetExistingDatabaseNames();
493 const OUString
* pDataNames
= aDataNames
.getConstArray();
494 for (long i
= 0; i
< aDataNames
.getLength(); i
++)
495 aDatabaseLB
.InsertEntry(pDataNames
[i
]);
496 String sDBName
= sActDBName
.GetToken( 0, DB_DELIM
);
497 String sTableName
= sActDBName
.GetToken( 1, DB_DELIM
);
498 aDatabaseLB
.SelectEntry(sDBName
);
499 if( sDBName
.Len() && GetNewDBMgr()->GetTableNames(&aTableLB
, sDBName
))
501 aTableLB
.SelectEntry(sTableName
);
502 GetNewDBMgr()->GetColumnNames(&aDBFieldLB
, sActDBName
, sTableName
);
509 SfxTabPage
* SwLabPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
511 return new SwLabPage(pParent
, rSet
);
514 void SwLabPage::ActivatePage(const SfxItemSet
& rSet
)
519 int SwLabPage::DeactivatePage(SfxItemSet
* _pSet
)
527 void SwLabPage::FillItem(SwLabItem
& rItem
)
529 rItem
.bAddr
= aAddrBox
.IsChecked();
530 rItem
.aWriting
= aWritingEdit
.GetText();
531 rItem
.bCont
= aContButton
.IsChecked();
532 rItem
.aMake
= aMakeBox
.GetSelectEntry();
533 rItem
.aType
= aTypeBox
.GetSelectEntry();
534 rItem
.sDBName
= sActDBName
;
536 SwLabRec
* pRec
= GetSelectedEntryPos();
537 pRec
->FillItem( rItem
);
539 rItem
.aLstMake
= aMakeBox
.GetSelectEntry();
540 rItem
.aLstType
= aTypeBox
.GetSelectEntry();
543 sal_Bool
SwLabPage::FillItemSet(SfxItemSet
& rSet
)
551 void SwLabPage::Reset(const SfxItemSet
& rSet
)
553 aItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
554 String sDBName
= aItem
.sDBName
;
556 String
aWriting(convertLineEnd(aItem
.aWriting
, GetSystemLineEnd()));
558 aAddrBox
.Check ( aItem
.bAddr
);
559 aWritingEdit
.SetText ( aWriting
);
561 for(std::vector
<OUString
>::const_iterator i
= GetParentSwLabDlg()->Makes().begin(); i
!= GetParentSwLabDlg()->Makes().end(); ++i
)
563 if(aMakeBox
.GetEntryPos(String(*i
)) == LISTBOX_ENTRY_NOTFOUND
)
564 aMakeBox
.InsertEntry(*i
);
567 aMakeBox
.SelectEntry( aItem
.aMake
);
568 //save the current type
569 String
sType(aItem
.aType
);
570 aMakeBox
.GetSelectHdl().Call( &aMakeBox
);
572 //#102806# a newly added make may not be in the type ListBox already
573 if (aTypeBox
.GetEntryPos(String(aItem
.aType
)) == LISTBOX_ENTRY_NOTFOUND
&& !aItem
.aMake
.isEmpty())
574 GetParentSwLabDlg()->UpdateGroup( aItem
.aMake
);
575 if (aTypeBox
.GetEntryPos(String(aItem
.aType
)) != LISTBOX_ENTRY_NOTFOUND
)
577 aTypeBox
.SelectEntry(aItem
.aType
);
578 aTypeBox
.GetSelectHdl().Call(&aTypeBox
);
580 if (aDatabaseLB
.GetEntryPos(sDBName
) != LISTBOX_ENTRY_NOTFOUND
)
582 aDatabaseLB
.SelectEntry(sDBName
);
583 aDatabaseLB
.GetSelectHdl().Call(&aDatabaseLB
);
587 aContButton
.Check();
589 aSheetButton
.Check();
592 void SwVisitingCardPage::ClearUserData()
594 SvTreeListEntry
* pEntry
= aAutoTextLB
.First();
597 delete (String
*)pEntry
->GetUserData();
598 pEntry
= aAutoTextLB
.Next(pEntry
);
602 void SwVisitingCardPage::SetUserData( sal_uInt32 nCnt
,
603 const OUString
* pNames
, const OUString
* pValues
)
605 for( sal_uInt32 i
= 0; i
< nCnt
; ++i
)
607 SvTreeListEntry
* pEntry
= aAutoTextLB
.InsertEntry( pNames
[ i
] );
608 pEntry
->SetUserData( new String( pValues
[ i
] ));
612 SwVisitingCardPage::SwVisitingCardPage(Window
* pParent
, const SfxItemSet
& rSet
) :
613 SfxTabPage(pParent
, SW_RES(TP_VISITING_CARDS
), rSet
),
614 aContentFL(this, SW_RES( FL_CONTENT
)),
615 aAutoTextLB(this, SW_RES( LB_AUTO_TEXT
)),
616 aAutoTextGroupFT(this, SW_RES( FT_AUTO_TEXT_GROUP
)),
617 aAutoTextGroupLB(this, SW_RES( LB_AUTO_TEXT_GROUP
)),
618 aExampleWIN(this, SW_RES( WIN_EXAMPLE
)),
619 sVisCardGroup(SW_RES(ST_VISCARD_GROUP
)),
623 aAutoTextLB
.SetStyle( aAutoTextLB
.GetStyle() | WB_HSCROLL
);
624 aAutoTextLB
.SetSpaceBetweenEntries(0);
625 aAutoTextLB
.SetSelectionMode( SINGLE_SELECTION
);
626 aAutoTextLB
.SetHelpId(HID_BUSINESS_CARD_CONTENT
);
628 SetExchangeSupport();
629 aAutoTextLB
.SetSelectHdl(LINK(this, SwVisitingCardPage
, AutoTextSelectHdl
));
630 aAutoTextGroupLB
.SetSelectHdl(LINK(this, SwVisitingCardPage
, AutoTextSelectHdl
));
635 aAutoTextGroupFT
.Show();
636 aAutoTextGroupLB
.Show();
640 SwVisitingCardPage::~SwVisitingCardPage()
642 for(sal_uInt16 i
= 0; i
< aAutoTextGroupLB
.GetEntryCount(); i
++)
643 delete (String
*)aAutoTextGroupLB
.GetEntryData( i
);
647 delete pExampleFrame
;
650 SfxTabPage
* SwVisitingCardPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
652 return new SwVisitingCardPage(pParent
, rSet
);
655 void SwVisitingCardPage::ActivatePage(const SfxItemSet
& rSet
)
661 int SwVisitingCardPage::DeactivatePage(SfxItemSet
* _pSet
)
668 sal_Bool
SwVisitingCardPage::FillItemSet(SfxItemSet
& rSet
)
670 String
* pGroup
= (String
*)aAutoTextGroupLB
.GetEntryData(
671 aAutoTextGroupLB
.GetSelectEntryPos());
672 OSL_ENSURE(pGroup
, "no group selected?");
675 aLabItem
.sGlossaryGroup
= *pGroup
;
677 SvTreeListEntry
* pSelEntry
= aAutoTextLB
.FirstSelected();
679 aLabItem
.sGlossaryBlockName
= *(String
*)pSelEntry
->GetUserData();
684 static void lcl_SelectBlock(SvTreeListBox
& rAutoTextLB
, const String
& rBlockName
)
686 SvTreeListEntry
* pEntry
= rAutoTextLB
.First();
689 if(*(String
*)pEntry
->GetUserData() == rBlockName
)
691 rAutoTextLB
.Select(pEntry
);
692 rAutoTextLB
.MakeVisible(pEntry
);
695 pEntry
= rAutoTextLB
.Next(pEntry
);
699 static bool lcl_FindBlock(SvTreeListBox
& rAutoTextLB
, const String
& rBlockName
)
701 SvTreeListEntry
* pEntry
= rAutoTextLB
.First();
704 if(*(String
*)pEntry
->GetUserData() == rBlockName
)
706 rAutoTextLB
.Select(pEntry
);
709 pEntry
= rAutoTextLB
.Next(pEntry
);
714 void SwVisitingCardPage::Reset(const SfxItemSet
& rSet
)
716 aLabItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
720 for(i
= 0; i
< aAutoTextGroupLB
.GetEntryCount() && !bFound
; i
++)
721 if( String(aLabItem
.sGlossaryGroup
) ==
722 *(String
*)aAutoTextGroupLB
.GetEntryData( i
))
730 // initially search for a group starting with "crd" which is the name of the
731 // business card AutoTexts
732 for(i
= 0; i
< aAutoTextGroupLB
.GetEntryCount() && !bFound
; i
++)
733 if(0 == (*(String
*)aAutoTextGroupLB
.GetEntryData( i
)).SearchAscii( "crd") )
741 if(aAutoTextGroupLB
.GetSelectEntryPos() != i
)
743 aAutoTextGroupLB
.SelectEntryPos(i
);
744 AutoTextSelectHdl(&aAutoTextGroupLB
);
746 if(lcl_FindBlock(aAutoTextLB
, aLabItem
.sGlossaryBlockName
))
748 SvTreeListEntry
* pSelEntry
= aAutoTextLB
.FirstSelected();
750 *(String
*)pSelEntry
->GetUserData() != String(aLabItem
.sGlossaryBlockName
))
752 lcl_SelectBlock(aAutoTextLB
, aLabItem
.sGlossaryBlockName
);
753 AutoTextSelectHdl(&aAutoTextLB
);
759 SwPrivateDataPage::SwPrivateDataPage(Window
* pParent
, const SfxItemSet
& rSet
) :
760 SfxTabPage(pParent
, SW_RES(TP_PRIVATE_DATA
), rSet
),
761 aDataFL (this, SW_RES( FL_DATA
)),
763 aNameFT (this, SW_RES( FT_NAME
)),
764 aFirstNameED (this, SW_RES( ED_FIRSTNAME
)),
765 aNameED (this, SW_RES( ED_NAME
)),
766 aShortCutED (this, SW_RES( ED_SHORTCUT
)),
768 aName2FT (this, SW_RES( FT_NAME_2
)),
769 aFirstName2ED (this, SW_RES( ED_FIRSTNAME_2
)),
770 aName2ED (this, SW_RES( ED_NAME_2
)),
771 aShortCut2ED (this, SW_RES( ED_SHORTCUT_2
)),
773 aStreetFT (this, SW_RES( FT_STREET
)),
774 aStreetED (this, SW_RES( ED_STREET
)),
775 aZipCityFT (this, SW_RES( FT_ZIPCITY
)),
776 aZipED (this, SW_RES( ED_ZIP
)),
777 aCityED (this, SW_RES( ED_CITY
)),
778 aCountryStateFT (this, SW_RES( FT_COUNTRYSTATE
)),
779 aCountryED (this, SW_RES( ED_COUNTRY
)),
780 aStateED (this, SW_RES( ED_STATE
)),
781 aTitleProfessionFT (this, SW_RES( FT_TITLEPROF
)),
782 aTitleED (this, SW_RES( ED_TITLE
)),
783 aProfessionED (this, SW_RES( ED_PROFESSION
)),
784 aPhoneFT (this, SW_RES( FT_PHONE_MOBILE
)),
785 aPhoneED (this, SW_RES( ED_PHONE
)),
786 aMobilePhoneED (this, SW_RES( ED_MOBILE
)),
787 aFaxFT (this, SW_RES( FT_FAX
)),
788 aFaxED (this, SW_RES( ED_FAX
)),
789 aWWWMailFT (this, SW_RES( FT_WWWMAIL
)),
790 aHomePageED (this, SW_RES( ED_WWW
)),
791 aMailED (this, SW_RES( ED_MAIL
))
794 SetExchangeSupport();
797 SwPrivateDataPage::~SwPrivateDataPage()
801 SfxTabPage
* SwPrivateDataPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
803 return new SwPrivateDataPage(pParent
, rSet
);
806 void SwPrivateDataPage::ActivatePage(const SfxItemSet
& rSet
)
811 int SwPrivateDataPage::DeactivatePage(SfxItemSet
* _pSet
)
818 sal_Bool
SwPrivateDataPage::FillItemSet(SfxItemSet
& rSet
)
821 SwLabItem aItem
= (const SwLabItem
&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL
);
822 aItem
.aPrivFirstName
= aFirstNameED
.GetText();
823 aItem
.aPrivName
= aNameED
.GetText( );
824 aItem
.aPrivShortCut
= aShortCutED
.GetText( );
825 aItem
.aPrivFirstName2
= aFirstName2ED
.GetText();
826 aItem
.aPrivName2
= aName2ED
.GetText( );
827 aItem
.aPrivShortCut2
= aShortCut2ED
.GetText( );
828 aItem
.aPrivStreet
= aStreetED
.GetText( );
829 aItem
.aPrivZip
= aZipED
.GetText( );
830 aItem
.aPrivCity
= aCityED
.GetText( );
831 aItem
.aPrivCountry
= aCountryED
.GetText( );
832 aItem
.aPrivState
= aStateED
.GetText( );
833 aItem
.aPrivTitle
= aTitleED
.GetText( );
834 aItem
.aPrivProfession
= aProfessionED
.GetText( );
835 aItem
.aPrivPhone
= aPhoneED
.GetText( );
836 aItem
.aPrivMobile
= aMobilePhoneED
.GetText( );
837 aItem
.aPrivFax
= aFaxED
.GetText( );
838 aItem
.aPrivWWW
= aHomePageED
.GetText( );
839 aItem
.aPrivMail
= aMailED
.GetText( );
845 void SwPrivateDataPage::Reset(const SfxItemSet
& rSet
)
847 const SwLabItem
& aItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
848 aFirstNameED
.SetText(aItem
.aPrivFirstName
);
849 aNameED
.SetText(aItem
.aPrivName
);
850 aShortCutED
.SetText(aItem
.aPrivShortCut
);
851 aFirstName2ED
.SetText(aItem
.aPrivFirstName2
);
852 aName2ED
.SetText(aItem
.aPrivName2
);
853 aShortCut2ED
.SetText(aItem
.aPrivShortCut2
);
854 aStreetED
.SetText(aItem
.aPrivStreet
);
855 aZipED
.SetText(aItem
.aPrivZip
);
856 aCityED
.SetText(aItem
.aPrivCity
);
857 aCountryED
.SetText(aItem
.aPrivCountry
);
858 aStateED
.SetText(aItem
.aPrivState
);
859 aTitleED
.SetText(aItem
.aPrivTitle
);
860 aProfessionED
.SetText(aItem
.aPrivProfession
);
861 aPhoneED
.SetText(aItem
.aPrivPhone
);
862 aMobilePhoneED
.SetText(aItem
.aPrivMobile
);
863 aFaxED
.SetText(aItem
.aPrivFax
);
864 aHomePageED
.SetText(aItem
.aPrivWWW
);
865 aMailED
.SetText(aItem
.aPrivMail
);
868 SwBusinessDataPage::SwBusinessDataPage(Window
* pParent
, const SfxItemSet
& rSet
) :
869 SfxTabPage(pParent
, SW_RES(TP_BUSINESS_DATA
), rSet
),
870 aDataFL (this, SW_RES( FL_DATA
)),
871 aCompanyFT (this, SW_RES( FT_COMP
)),
872 aCompanyED (this, SW_RES( ED_COMP
)),
873 aCompanyExtFT (this, SW_RES( FT_COMP_EXT
)),
874 aCompanyExtED (this, SW_RES( ED_COMP_EXT
)),
875 aSloganFT (this, SW_RES( FT_SLOGAN
)),
876 aSloganED (this, SW_RES( ED_SLOGAN
)),
877 aStreetFT (this, SW_RES( FT_STREET
)),
878 aStreetED (this, SW_RES( ED_STREET
)),
879 aZipCityFT (this, SW_RES( FT_ZIPCITY
)),
880 aZipED (this, SW_RES( ED_ZIP
)),
881 aCityED (this, SW_RES( ED_CITY
)),
882 aCountryStateFT (this, SW_RES( FT_COUNTRYSTATE
)),
883 aCountryED (this, SW_RES( ED_COUNTRY
)),
884 aStateED (this, SW_RES( ED_STATE
)),
885 aPositionFT (this, SW_RES( FT_POSITION
)),
886 aPositionED (this, SW_RES( ED_POSITION
)),
887 aPhoneFT (this, SW_RES( FT_PHONE_MOBILE
)),
888 aPhoneED (this, SW_RES( ED_PHONE
)),
889 aMobilePhoneED (this, SW_RES( ED_MOBILE
)),
890 aFaxFT (this, SW_RES( FT_FAX
)),
891 aFaxED (this, SW_RES( ED_FAX
)),
892 aWWWMailFT (this, SW_RES( FT_WWWMAIL
)),
893 aHomePageED (this, SW_RES( ED_WWW
)),
894 aMailED (this, SW_RES( ED_MAIL
))
897 SetExchangeSupport();
901 SwBusinessDataPage::~SwBusinessDataPage()
905 SfxTabPage
* SwBusinessDataPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
907 return new SwBusinessDataPage(pParent
, rSet
);
910 void SwBusinessDataPage::ActivatePage(const SfxItemSet
& rSet
)
915 int SwBusinessDataPage::DeactivatePage(SfxItemSet
* _pSet
)
922 sal_Bool
SwBusinessDataPage::FillItemSet(SfxItemSet
& rSet
)
924 SwLabItem aItem
= (const SwLabItem
&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL
);
926 aItem
.aCompCompany
= aCompanyED
.GetText();
927 aItem
.aCompCompanyExt
= aCompanyExtED
.GetText();
928 aItem
.aCompSlogan
= aSloganED
.GetText();
929 aItem
.aCompStreet
= aStreetED
.GetText();
930 aItem
.aCompZip
= aZipED
.GetText();
931 aItem
.aCompCity
= aCityED
.GetText();
932 aItem
.aCompCountry
= aCountryED
.GetText();
933 aItem
.aCompState
= aStateED
.GetText();
934 aItem
.aCompPosition
= aPositionED
.GetText();
935 aItem
.aCompPhone
= aPhoneED
.GetText();
936 aItem
.aCompMobile
= aMobilePhoneED
.GetText();
937 aItem
.aCompFax
= aFaxED
.GetText();
938 aItem
.aCompWWW
= aHomePageED
.GetText();
939 aItem
.aCompMail
= aMailED
.GetText();
945 void SwBusinessDataPage::Reset(const SfxItemSet
& rSet
)
947 const SwLabItem
& aItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
948 aCompanyED
.SetText(aItem
.aCompCompany
);
949 aCompanyExtED
.SetText(aItem
.aCompCompanyExt
);
950 aSloganED
.SetText(aItem
.aCompSlogan
);
951 aStreetED
.SetText(aItem
.aCompStreet
);
952 aZipED
.SetText(aItem
.aCompZip
);
953 aCityED
.SetText(aItem
.aCompCity
);
954 aCountryED
.SetText(aItem
.aCompCountry
);
955 aStateED
.SetText(aItem
.aCompState
);
956 aPositionED
.SetText(aItem
.aCompPosition
);
957 aPhoneED
.SetText(aItem
.aCompPhone
);
958 aMobilePhoneED
.SetText(aItem
.aCompMobile
);
959 aFaxED
.SetText(aItem
.aCompFax
);
960 aHomePageED
.SetText(aItem
.aCompWWW
);
961 aMailED
.SetText(aItem
.aCompMail
);
966 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */