1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: label1.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
38 #include <vcl/waitobj.hxx>
39 #include <rtl/ustring.hxx>
40 #include <com/sun/star/uno/Sequence.h>
41 #include <swtypes.hxx>
47 #include <unotools.hxx>
59 #include <globals.hrc>
66 extern SW_DLLPUBLIC String
MakeSender();
69 SV_IMPL_PTRARR( SwLabRecs
, SwLabRec
* );
71 void SwLabRec::SetFromItem( const SwLabItem
& rItem
)
73 lHDist
= rItem
.lHDist
;
74 lVDist
= rItem
.lVDist
;
75 lWidth
= rItem
.lWidth
;
76 lHeight
= rItem
.lHeight
;
78 lUpper
= rItem
.lUpper
;
84 void SwLabRec::FillItem( SwLabItem
& rItem
) const
86 rItem
.lHDist
= lHDist
;
87 rItem
.lVDist
= lVDist
;
88 rItem
.lWidth
= lWidth
;
89 rItem
.lHeight
= lHeight
;
91 rItem
.lUpper
= lUpper
;
96 // --------------------------------------------------------------------------
97 void SwLabDlg::_ReplaceGroup( const String
&rMake
)
99 //Die alten Eintraege vernichten.
100 pRecs
->Remove( 1, pRecs
->Count() - 1 );
101 aLabelsCfg
.FillLabels(rtl::OUString(rMake
), *pRecs
);
105 // --------------------------------------------------------------------------
109 void SwLabDlg::PageCreated(sal_uInt16 nId
, SfxTabPage
&rPage
)
111 if (nId
== TP_LAB_LAB
)
115 ((SwLabPage
*)&rPage
)->SetNewDBMgr(pNewDBMgr
);
116 ((SwLabPage
*)&rPage
)->InitDatabaseBox();
119 ((SwLabPage
*)&rPage
)->SetToBusinessCard();
121 else if (nId
== TP_LAB_PRT
)
122 pPrtPage
= (SwLabPrtPage
*)&rPage
;
125 // --------------------------------------------------------------------------
129 SwLabDlg::SwLabDlg(Window
* pParent
, const SfxItemSet
& rSet
,
130 SwNewDBMgr
* pDBMgr
, sal_Bool bLabel
) :
131 SfxTabDialog( pParent
, SW_RES(DLG_LAB
), &rSet
, sal_False
),
138 pRecs ( new SwLabRecs() ),
139 sBusinessCardDlg(SW_RES(ST_BUSINESSCARDDLG
)),
140 sFormat(SW_RES(ST_FIRSTPAGE_LAB
)),
141 sMedium(SW_RES(ST_FIRSTPAGE_BC
)),
144 WaitObject
aWait( pParent
);
148 GetOKButton().SetText(String(SW_RES(STR_BTN_NEW_DOC
)));
149 GetOKButton().SetHelpId(HID_LABEL_INSERT
);
150 GetOKButton().SetHelpText(aEmptyStr
); // Damit generierter Hilfetext verwendet wird
152 AddTabPage(TP_LAB_LAB
, m_bLabel
? sFormat
: sMedium
,SwLabPage ::Create
, 0, sal_False
, 0);
153 AddTabPage(TP_VISITING_CARDS
, SwVisitingCardPage::Create
, 0);
154 AddTabPage(TP_LAB_FMT
, SwLabFmtPage::Create
, 0);
155 AddTabPage(TP_LAB_PRT
, SwLabPrtPage::Create
, 0);
156 AddTabPage(TP_BUSINESS_DATA
, SwBusinessDataPage::Create
, 0 );
157 AddTabPage(TP_PRIVATE_DATA
, SwPrivateDataPage::Create
, 0);
162 RemoveTabPage(TP_BUSINESS_DATA
);
163 RemoveTabPage(TP_PRIVATE_DATA
);
164 RemoveTabPage(TP_VISITING_CARDS
);
168 SetText(sBusinessCardDlg
);
170 // Benutzer-Etikette aus writer.cfg lesen
171 SwLabItem
aItem((const SwLabItem
&)rSet
.Get( FN_LABEL
));
172 SwLabRec
* pRec
= new SwLabRec
;
173 const String
aTmp( SW_RES( STR_CUSTOM
) );
174 pRec
->aMake
= pRec
->aType
= aTmp
;
175 pRec
->SetFromItem( aItem
);
177 sal_Bool bDouble
= sal_False
;
179 for (sal_uInt16 nRecPos
= 0; nRecPos
< pRecs
->Count(); nRecPos
++)
181 if (pRec
->aMake
== pRecs
->GetObject(nRecPos
)->aMake
&&
182 pRec
->aType
== pRecs
->GetObject(nRecPos
)->aType
)
190 pRecs
->C40_INSERT( SwLabRec
, pRec
, 0 );
192 sal_uInt16 nLstGroup
= 0;
193 const UNO_NMSPC::Sequence
<rtl::OUString
>& rMan
= aLabelsCfg
.GetManufacturers();
194 const rtl::OUString
* pMan
= rMan
.getConstArray();
195 for(sal_Int32 nMan
= 0; nMan
< rMan
.getLength(); nMan
++)
197 aMakes
.Insert( new String(pMan
[nMan
]), aMakes
.Count() );
198 if ( pMan
[nMan
] == aItem
.aLstMake
)
199 nLstGroup
= (sal_uInt16
) nMan
;
202 if ( aMakes
.Count() )
203 _ReplaceGroup( *aMakes
[nLstGroup
] );
205 pExampleSet
->Put(aItem
);
208 // --------------------------------------------------------------------------
210 SwLabDlg::~SwLabDlg()
214 // --------------------------------------------------------------------------
216 void SwLabDlg::GetLabItem(SwLabItem
&rItem
)
218 const SwLabItem
& rActItem
= (const SwLabItem
&)GetExampleSet()->Get(FN_LABEL
);
219 const SwLabItem
& rOldItem
= (const SwLabItem
&)GetInputSetImpl()->Get(FN_LABEL
);
221 if (rActItem
!= rOldItem
)
222 { // Wurde schon mal mit (hoffentlich) korrektem Inhalt "geputtet"
229 // Im rItem stehen (vom Namen mal abgesehen) immer nur die
230 // benutzerdefinierbaren Einstellungen. Daher richtige Werte
231 // direkt aus dem Record besorgen:
232 SwLabRec
* pRec
= GetRecord(rItem
.aType
, rItem
.bCont
);
233 pRec
->FillItem( rItem
);
237 // --------------------------------------------------------------------------
239 SwLabRec
* SwLabDlg::GetRecord(const String
&rRecName
, sal_Bool bCont
)
241 SwLabRec
* pRec
= NULL
;
242 sal_Bool bFound
= sal_False
;
243 String
sCustom(SW_RES(STR_CUSTOM
));
245 const sal_uInt16 nCount
= Recs().Count();
246 for (sal_uInt16 i
= 0; i
< nCount
; i
++)
249 if (pRec
->aType
!= sCustom
&&
250 rRecName
== pRec
->aType
&& bCont
== pRec
->bCont
)
256 if (!bFound
) // Benutzerdefiniert
262 // --------------------------------------------------------------------------
264 Printer
*SwLabDlg::GetPrt()
267 return (pPrtPage
->GetPrt());
272 // --------------------------------------------------------------------------
273 SwLabPage::SwLabPage(Window
* pParent
, const SfxItemSet
& rSet
) :
274 SfxTabPage(pParent
, SW_RES(TP_LAB_LAB
), rSet
),
276 aItem ((const SwLabItem
&) rSet
.Get(FN_LABEL
)),
278 aWritingText (this, SW_RES(TXT_WRITING
)),
279 aAddrBox (this, SW_RES(BOX_ADDR
)),
280 aWritingEdit (this, SW_RES(EDT_WRITING
)),
281 aDatabaseFT (this, SW_RES(FT_DATABASE
)),
282 aDatabaseLB (this, SW_RES(LB_DATABASE
)),
283 aTableFT (this, SW_RES(FT_TABLE
)),
284 aTableLB (this, SW_RES(LB_TABLE
)),
285 aInsertBT (this, SW_RES(BTN_INSERT
)),
286 aDBFieldFT (this, SW_RES(FT_DBFIELD
)),
287 aDBFieldLB (this, SW_RES(LB_DBFIELD
)),
288 aWritingFL (this, SW_RES(FL_WRITING
)),
289 aContButton (this, SW_RES(BTN_CONT
)),
290 aSheetButton (this, SW_RES(BTN_SHEET
)),
291 aMakeText (this, SW_RES(TXT_MAKE
)),
292 aMakeBox (this, SW_RES(BOX_MAKE
)),
293 aTypeText (this, SW_RES(TXT_TYPE
)),
294 aTypeBox (this, SW_RES(BOX_TYPE
)),
295 aHiddenSortTypeBox(this, WB_SORT
|WB_HIDE
),
296 aFormatInfo (this, SW_RES(INF_FORMAT
)),
297 aFormatFL (this, SW_RES(FL_FORMAT
))
299 WaitObject
aWait( pParent
);
302 SetExchangeSupport();
305 // Handler installieren
306 aAddrBox
.SetClickHdl (LINK(this, SwLabPage
, AddrHdl
));
307 aDatabaseLB
.SetSelectHdl(LINK(this, SwLabPage
, DatabaseHdl
));
308 aTableLB
.SetSelectHdl(LINK(this, SwLabPage
, DatabaseHdl
));
309 aInsertBT
.SetClickHdl (LINK(this, SwLabPage
, FieldHdl
));
310 aContButton
.SetClickHdl (LINK(this, SwLabPage
, PageHdl
));
311 aSheetButton
.SetClickHdl (LINK(this, SwLabPage
, PageHdl
));
312 aMakeBox
.SetSelectHdl(LINK(this, SwLabPage
, MakeHdl
));
313 aTypeBox
.SetSelectHdl(LINK(this, SwLabPage
, TypeHdl
));
317 sal_uInt16 nLstGroup
= 0;
319 const sal_uInt16 nCount
= (sal_uInt16
)GetParent()->Makes().Count();
320 for (sal_uInt16 i
= 0; i
< nCount
; ++i
)
322 String
&rStr
= *GetParent()->Makes()[i
];
323 aMakeBox
.InsertEntry( rStr
);
324 if ( rStr
== String(aItem
.aLstMake
) )
328 aMakeBox
.SelectEntryPos( nLstGroup
);
329 aMakeBox
.GetSelectHdl().Call( &aMakeBox
);
332 // --------------------------------------------------------------------------
336 SwLabPage::~SwLabPage()
339 /* -----------------29.09.99 09:08-------------------
341 --------------------------------------------------*/
342 void lcl_ChgYPos(Window
& rWin
, long nDiff
)
344 Point
aTempPos(rWin
.GetPosPixel());
345 aTempPos
.Y() += nDiff
;
346 rWin
.SetPosPixel(aTempPos
);
349 void SwLabPage::SetToBusinessCard()
351 SetHelpId(HID_BUSINESS_FMT_PAGE
);
352 aContButton
.SetHelpId(HID_BUSINESS_FMT_PAGE_CONT
);
353 aSheetButton
.SetHelpId(HID_BUSINESS_FMT_PAGE_SHEET
);
354 aMakeBox
.SetHelpId(HID_BUSINESS_FMT_PAGE_BRAND
);
355 aTypeBox
.SetHelpId(HID_BUSINESS_FMT_PAGE_TYPE
);
356 m_bLabel
= sal_False
;
370 Point
aFLPos(aWritingFL
.GetPosPixel());
371 long nDiffPos
= aFormatFL
.GetPosPixel().Y() - aFLPos
.Y();
372 Size
aFLSz(aFormatFL
.GetSizePixel());
373 // aFLSz.Height() += nDiffPos;
374 aFormatFL
.SetPosSizePixel(aFLPos
, aFLSz
);
376 // move all controls up
377 lcl_ChgYPos(aContButton
, -nDiffPos
);
378 lcl_ChgYPos(aSheetButton
, -nDiffPos
);
379 lcl_ChgYPos(aMakeText
, -nDiffPos
);
381 lcl_ChgYPos(aTypeText
, -nDiffPos
);
382 lcl_ChgYPos(aFormatInfo
, -nDiffPos
);
385 aTmpSz
= LogicToPixel(aTmpSz
, MAP_APPFONT
);
387 lcl_ChgYPos(aMakeBox
, - nDiffPos
);
388 Point
aLBPos(aMakeBox
.GetPosPixel());
389 aLBPos
.Y() += aMakeBox
.GetSizePixel().Height() + aTmpSz
.Height();
390 aTypeBox
.SetPosPixel(aLBPos
);
393 // --------------------------------------------------------------------------
396 IMPL_LINK( SwLabPage
, AddrHdl
, Button
*, EMPTYARG
)
399 if ( aAddrBox
.IsChecked() )
400 aWriting
= MakeSender();
401 aWritingEdit
.SetText( aWriting
.ConvertLineEnd() );
402 aWritingEdit
.GrabFocus();
406 // --------------------------------------------------------------------------
410 IMPL_LINK( SwLabPage
, DatabaseHdl
, ListBox
*, pListBox
)
412 sActDBName
= aDatabaseLB
.GetSelectEntry();
414 WaitObject
aObj( GetParent() );
416 if (pListBox
== &aDatabaseLB
)
417 GetNewDBMgr()->GetTableNames(&aTableLB
, sActDBName
);
418 GetNewDBMgr()->GetColumnNames(&aDBFieldLB
, sActDBName
, aTableLB
.GetSelectEntry());
424 IMPL_LINK( SwLabPage
, FieldHdl
, Button
*, EMPTYARG
)
427 aStr
+= aDatabaseLB
.GetSelectEntry();
429 aStr
+= aTableLB
.GetSelectEntry();
431 aStr
+= aTableLB
.GetEntryData(aTableLB
.GetSelectEntryPos()) == 0 ? '0' : '1';
433 aStr
+= aDBFieldLB
.GetSelectEntry();
435 aWritingEdit
.ReplaceSelected(aStr
);
436 Selection aSel
= aWritingEdit
.GetSelection();
437 aWritingEdit
.GrabFocus();
438 aWritingEdit
.SetSelection(aSel
);
442 // --------------------------------------------------------------------------
446 IMPL_LINK_INLINE_START( SwLabPage
, PageHdl
, Button
*, EMPTYARG
)
448 aMakeBox
.GetSelectHdl().Call( &aMakeBox
);
451 IMPL_LINK_INLINE_END( SwLabPage
, PageHdl
, Button
*, EMPTYARG
)
453 // --------------------------------------------------------------------------
457 IMPL_LINK( SwLabPage
, MakeHdl
, ListBox
*, EMPTYARG
)
459 WaitObject
aWait( GetParent() );
462 aHiddenSortTypeBox
.Clear();
463 GetParent()->TypeIds().Remove( 0, GetParent()->TypeIds().Count() );
465 const String aMake
= aMakeBox
.GetSelectEntry();
466 GetParent()->ReplaceGroup( aMake
);
467 aItem
.aLstMake
= aMake
;
469 const sal_Bool bCont
= aContButton
.IsChecked();
470 const sal_uInt16 nCount
= GetParent()->Recs().Count();
471 sal_uInt16 nLstType
= 0;
473 const String
sCustom(SW_RES(STR_CUSTOM
));
474 //insert the entries into the sorted list box
475 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
477 const String
aType ( GetParent()->Recs()[i
]->aType
);
478 BOOL bInsert
= FALSE
;
479 if ( GetParent()->Recs()[i
]->aType
== sCustom
)
482 aTypeBox
.InsertEntry(aType
);
484 else if ( GetParent()->Recs()[i
]->bCont
== bCont
)
486 if ( aHiddenSortTypeBox
.GetEntryPos(aType
) == LISTBOX_ENTRY_NOTFOUND
)
489 aHiddenSortTypeBox
.InsertEntry( aType
);
494 GetParent()->TypeIds().Insert(i
, GetParent()->TypeIds().Count());
495 if ( !nLstType
&& aType
== String(aItem
.aLstType
) )
496 nLstType
= GetParent()->TypeIds().Count();
499 for(sal_uInt16 nEntry
= 0; nEntry
< aHiddenSortTypeBox
.GetEntryCount(); nEntry
++)
501 aTypeBox
.InsertEntry(aHiddenSortTypeBox
.GetEntry(nEntry
));
504 aTypeBox
.SelectEntry(aItem
.aLstType
);
506 aTypeBox
.SelectEntryPos(0);
507 aTypeBox
.GetSelectHdl().Call( &aTypeBox
);
511 // --------------------------------------------------------------------------
515 IMPL_LINK_INLINE_START( SwLabPage
, TypeHdl
, ListBox
*, EMPTYARG
)
518 aItem
.aType
= aTypeBox
.GetSelectEntry();
521 IMPL_LINK_INLINE_END( SwLabPage
, TypeHdl
, ListBox
*, EMPTYARG
)
523 // --------------------------------------------------------------------------
527 void SwLabPage::DisplayFormat()
529 MetricField
aField(this, WinBits(0));
530 FieldUnit aMetric
= ::GetDfltMetric(FALSE
);
531 SetMetric(aField
, aMetric
);
532 aField
.SetDecimalDigits(2);
534 aField
.SetMax (LONG_MAX
);
536 SwLabRec
* pRec
= GetSelectedEntryPos();
537 aItem
.aLstType
= pRec
->aType
;
538 SETFLDVAL(aField
, pRec
->lWidth
);
540 const String aWString
= aField
.GetText();
542 SETFLDVAL(aField
, pRec
->lHeight
);
545 String aText
= pRec
->aType
;
546 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": "));
548 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" x "));
549 aText
+= aField
.GetText();
550 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" ("));
551 aText
+= String::CreateFromInt32( pRec
->nCols
);
552 aText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" x "));
553 aText
+= String::CreateFromInt32( pRec
->nRows
);
555 aFormatInfo
.SetText(aText
);
558 // --------------------------------------------------------------------------
560 SwLabRec
* SwLabPage::GetSelectedEntryPos()
562 String
sSelEntry(aTypeBox
.GetSelectEntry());
564 return GetParent()->GetRecord(sSelEntry
, aContButton
.IsChecked());
567 // --------------------------------------------------------------------------
571 void SwLabPage::InitDatabaseBox()
576 UNO_NMSPC::Sequence
<rtl::OUString
> aDataNames
= SwNewDBMgr::GetExistingDatabaseNames();
577 const rtl::OUString
* pDataNames
= aDataNames
.getConstArray();
578 for (long i
= 0; i
< aDataNames
.getLength(); i
++)
579 aDatabaseLB
.InsertEntry(pDataNames
[i
]);
580 String sDBName
= sActDBName
.GetToken( 0, DB_DELIM
);
581 String sTableName
= sActDBName
.GetToken( 1, DB_DELIM
);
582 aDatabaseLB
.SelectEntry(sDBName
);
583 if( sDBName
.Len() && GetNewDBMgr()->GetTableNames(&aTableLB
, sDBName
))
585 aTableLB
.SelectEntry(sTableName
);
586 GetNewDBMgr()->GetColumnNames(&aDBFieldLB
, sActDBName
, sTableName
);
593 // --------------------------------------------------------------------------
594 SfxTabPage
* SwLabPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
596 return new SwLabPage(pParent
, rSet
);
599 // --------------------------------------------------------------------------
600 void SwLabPage::ActivatePage(const SfxItemSet
& rSet
)
604 // --------------------------------------------------------------------------
605 int SwLabPage::DeactivatePage(SfxItemSet
* _pSet
)
613 // --------------------------------------------------------------------------
617 void SwLabPage::FillItem(SwLabItem
& rItem
)
619 rItem
.bAddr
= aAddrBox
.IsChecked();
620 rItem
.aWriting
= aWritingEdit
.GetText();
621 rItem
.bCont
= aContButton
.IsChecked();
622 rItem
.aMake
= aMakeBox
.GetSelectEntry();
623 rItem
.aType
= aTypeBox
.GetSelectEntry();
624 rItem
.sDBName
= sActDBName
;
626 SwLabRec
* pRec
= GetSelectedEntryPos();
627 pRec
->FillItem( rItem
);
629 rItem
.aLstMake
= aMakeBox
.GetSelectEntry();
630 rItem
.aLstType
= aTypeBox
.GetSelectEntry();
633 // --------------------------------------------------------------------------
637 sal_Bool
SwLabPage::FillItemSet(SfxItemSet
& rSet
)
645 // --------------------------------------------------------------------------
647 void SwLabPage::Reset(const SfxItemSet
& rSet
)
649 aItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
650 String sDBName
= aItem
.sDBName
;
652 String
aWriting( aItem
.aWriting
);
654 aAddrBox
.Check ( aItem
.bAddr
);
655 aWritingEdit
.SetText ( aWriting
.ConvertLineEnd() );
657 const sal_uInt16 nCount
= (sal_uInt16
)GetParent()->Makes().Count();
658 for (sal_uInt16 i
= 0; i
< nCount
; ++i
)
660 String
&rStr
= *GetParent()->Makes()[i
];
661 if(aMakeBox
.GetEntryPos(String(rStr
)) == LISTBOX_ENTRY_NOTFOUND
)
662 aMakeBox
.InsertEntry( rStr
);
666 aMakeBox
.SelectEntry( aItem
.aMake
);
667 //save the current type
668 String
sType(aItem
.aType
);
669 aMakeBox
.GetSelectHdl().Call( &aMakeBox
);
671 //#102806# a newly added make may not be in the type ListBox already
672 if (aTypeBox
.GetEntryPos(String(aItem
.aType
)) == LISTBOX_ENTRY_NOTFOUND
&& aItem
.aMake
.getLength())
673 GetParent()->UpdateGroup( aItem
.aMake
);
674 if (aTypeBox
.GetEntryPos(String(aItem
.aType
)) != LISTBOX_ENTRY_NOTFOUND
)
676 aTypeBox
.SelectEntry(aItem
.aType
);
677 aTypeBox
.GetSelectHdl().Call(&aTypeBox
);
679 if (aDatabaseLB
.GetEntryPos(sDBName
) != LISTBOX_ENTRY_NOTFOUND
)
681 aDatabaseLB
.SelectEntry(sDBName
);
682 aDatabaseLB
.GetSelectHdl().Call(&aDatabaseLB
);
686 aContButton
.Check();
688 aSheetButton
.Check();
691 /*-- 08.07.99 14:00:02---------------------------------------------------
693 -----------------------------------------------------------------------*/
694 //-----------------------------------------------------------------------------
695 void SwVisitingCardPage::ClearUserData()
697 SvLBoxEntry
* pEntry
= aAutoTextLB
.First();
700 delete (String
*)pEntry
->GetUserData();
701 pEntry
= aAutoTextLB
.Next(pEntry
);
705 //-----------------------------------------------------------------------------
707 void SwVisitingCardPage::SetUserData( sal_uInt32 nCnt
,
708 const rtl::OUString
* pNames
, const rtl::OUString
* pValues
)
710 for( sal_uInt32 i
= 0; i
< nCnt
; ++i
)
712 SvLBoxEntry
* pEntry
= aAutoTextLB
.InsertEntry( pNames
[ i
] );
713 pEntry
->SetUserData( new String( pValues
[ i
] ));
717 //-----------------------------------------------------------------------------
719 SwVisitingCardPage::SwVisitingCardPage(Window
* pParent
, const SfxItemSet
& rSet
) :
720 SfxTabPage(pParent
, SW_RES(TP_VISITING_CARDS
), rSet
),
721 aAutoTextLB(this, SW_RES( LB_AUTO_TEXT
)),
722 aAutoTextGroupFT(this, SW_RES( FT_AUTO_TEXT_GROUP
)),
723 aAutoTextGroupLB(this, SW_RES( LB_AUTO_TEXT_GROUP
)),
724 aContentFL(this, SW_RES( FL_CONTENT
)),
725 aExampleWIN(this, SW_RES( WIN_EXAMPLE
)),
726 sVisCardGroup(SW_RES(ST_VISCARD_GROUP
)),
730 aAutoTextLB
.SetWindowBits( WB_HSCROLL
);
731 aAutoTextLB
.SetSpaceBetweenEntries(0);
732 aAutoTextLB
.SetSelectionMode( SINGLE_SELECTION
);
733 aAutoTextLB
.SetHelpId(HID_BUSINESS_CARD_CONTENT
);
735 SetExchangeSupport();
736 aAutoTextLB
.SetSelectHdl(LINK(this, SwVisitingCardPage
, AutoTextSelectHdl
));
737 aAutoTextGroupLB
.SetSelectHdl(LINK(this, SwVisitingCardPage
, AutoTextSelectHdl
));
742 aAutoTextGroupFT
.Show();
743 aAutoTextGroupLB
.Show();
746 /*-- 08.07.99 14:00:03---------------------------------------------------
748 -----------------------------------------------------------------------*/
749 SwVisitingCardPage::~SwVisitingCardPage()
751 for(sal_uInt16 i
= 0; i
< aAutoTextGroupLB
.GetEntryCount(); i
++)
752 delete (String
*)aAutoTextGroupLB
.GetEntryData( i
);
756 delete pExampleFrame
;
758 /*-- 08.07.99 14:00:03---------------------------------------------------
760 -----------------------------------------------------------------------*/
761 SfxTabPage
* SwVisitingCardPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
763 return new SwVisitingCardPage(pParent
, rSet
);
765 /*-- 08.07.99 14:00:03---------------------------------------------------
767 -----------------------------------------------------------------------*/
768 void SwVisitingCardPage::ActivatePage(const SfxItemSet
& rSet
)
773 /*-- 08.07.99 14:00:04---------------------------------------------------
775 -----------------------------------------------------------------------*/
776 int SwVisitingCardPage::DeactivatePage(SfxItemSet
* _pSet
)
782 /*-- 08.07.99 14:00:04---------------------------------------------------
784 -----------------------------------------------------------------------*/
785 sal_Bool
SwVisitingCardPage::FillItemSet(SfxItemSet
& rSet
)
787 String
* pGroup
= (String
*)aAutoTextGroupLB
.GetEntryData(
788 aAutoTextGroupLB
.GetSelectEntryPos());
789 DBG_ASSERT(pGroup
, "no group selected?");
791 aLabItem
.sGlossaryGroup
= *pGroup
;
793 SvLBoxEntry
* pSelEntry
= aAutoTextLB
.FirstSelected();
795 aLabItem
.sGlossaryBlockName
= *(String
*)pSelEntry
->GetUserData();
799 /*-- 08.07.99 14:00:05---------------------------------------------------
801 -----------------------------------------------------------------------*/
802 void lcl_SelectBlock(SvTreeListBox
& rAutoTextLB
, const String
& rBlockName
)
804 SvLBoxEntry
* pEntry
= rAutoTextLB
.First();
807 if(*(String
*)pEntry
->GetUserData() == rBlockName
)
809 rAutoTextLB
.Select(pEntry
);
810 rAutoTextLB
.MakeVisible(pEntry
);
813 pEntry
= rAutoTextLB
.Next(pEntry
);
816 //-----------------------------------------------------------------------------
817 sal_Bool
lcl_FindBlock(SvTreeListBox
& rAutoTextLB
, const String
& rBlockName
)
819 SvLBoxEntry
* pEntry
= rAutoTextLB
.First();
822 if(*(String
*)pEntry
->GetUserData() == rBlockName
)
824 rAutoTextLB
.Select(pEntry
);
827 pEntry
= rAutoTextLB
.Next(pEntry
);
832 //-----------------------------------------------------------------------------
833 void SwVisitingCardPage::Reset(const SfxItemSet
& rSet
)
835 aLabItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
837 sal_Bool bFound
= sal_False
;
839 for(i
= 0; i
< aAutoTextGroupLB
.GetEntryCount() && !bFound
; i
++)
840 if( String(aLabItem
.sGlossaryGroup
) ==
841 *(String
*)aAutoTextGroupLB
.GetEntryData( i
))
849 // initially search for a group starting with "crd" which is the name of the
850 // business card AutoTexts
851 for(i
= 0; i
< aAutoTextGroupLB
.GetEntryCount() && !bFound
; i
++)
852 if(0 == (*(String
*)aAutoTextGroupLB
.GetEntryData( i
)).SearchAscii( "crd") )
860 if(aAutoTextGroupLB
.GetSelectEntryPos() != i
)
862 aAutoTextGroupLB
.SelectEntryPos(i
);
863 AutoTextSelectHdl(&aAutoTextGroupLB
);
865 if(lcl_FindBlock(aAutoTextLB
, aLabItem
.sGlossaryBlockName
))
867 SvLBoxEntry
* pSelEntry
= aAutoTextLB
.FirstSelected();
869 *(String
*)pSelEntry
->GetUserData() != String(aLabItem
.sGlossaryBlockName
))
871 lcl_SelectBlock(aAutoTextLB
, aLabItem
.sGlossaryBlockName
);
872 AutoTextSelectHdl(&aAutoTextLB
);
878 /* -----------------29.09.99 08:55-------------------
880 --------------------------------------------------*/
881 SwPrivateDataPage::SwPrivateDataPage(Window
* pParent
, const SfxItemSet
& rSet
) :
882 SfxTabPage(pParent
, SW_RES(TP_PRIVATE_DATA
), rSet
),
883 aDataFL (this, SW_RES( FL_DATA
)),
885 aNameFT (this, SW_RES( FT_NAME
)),
886 aFirstNameED (this, SW_RES( ED_FIRSTNAME
)),
887 aNameED (this, SW_RES( ED_NAME
)),
888 aShortCutED (this, SW_RES( ED_SHORTCUT
)),
890 aName2FT (this, SW_RES( FT_NAME_2
)),
891 aFirstName2ED (this, SW_RES( ED_FIRSTNAME_2
)),
892 aName2ED (this, SW_RES( ED_NAME_2
)),
893 aShortCut2ED (this, SW_RES( ED_SHORTCUT_2
)),
895 aStreetFT (this, SW_RES( FT_STREET
)),
896 aStreetED (this, SW_RES( ED_STREET
)),
897 aZipCityFT (this, SW_RES( FT_ZIPCITY
)),
898 aZipED (this, SW_RES( ED_ZIP
)),
899 aCityED (this, SW_RES( ED_CITY
)),
900 aCountryStateFT (this, SW_RES( FT_COUNTRYSTATE
)),
901 aCountryED (this, SW_RES( ED_COUNTRY
)),
902 aStateED (this, SW_RES( ED_STATE
)),
903 aTitleProfessionFT (this, SW_RES( FT_TITLEPROF
)),
904 aTitleED (this, SW_RES( ED_TITLE
)),
905 aProfessionED (this, SW_RES( ED_PROFESSION
)),
906 aPhoneFT (this, SW_RES( FT_PHONE_MOBILE
)),
907 aPhoneED (this, SW_RES( ED_PHONE
)),
908 aMobilePhoneED (this, SW_RES( ED_MOBILE
)),
909 aFaxFT (this, SW_RES( FT_FAX
)),
910 aFaxED (this, SW_RES( ED_FAX
)),
911 aWWWMailFT (this, SW_RES( FT_WWWMAIL
)),
912 aHomePageED (this, SW_RES( ED_WWW
)),
913 aMailED (this, SW_RES( ED_MAIL
))
916 SetExchangeSupport();
919 /*-- 29.09.99 08:55:57---------------------------------------------------
921 -----------------------------------------------------------------------*/
922 SwPrivateDataPage::~SwPrivateDataPage()
925 /*-- 29.09.99 08:55:57---------------------------------------------------
927 -----------------------------------------------------------------------*/
928 SfxTabPage
* SwPrivateDataPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
930 return new SwPrivateDataPage(pParent
, rSet
);
932 /*-- 29.09.99 08:55:57---------------------------------------------------
934 -----------------------------------------------------------------------*/
935 void SwPrivateDataPage::ActivatePage(const SfxItemSet
& rSet
)
939 /*-- 29.09.99 08:55:58---------------------------------------------------
941 -----------------------------------------------------------------------*/
942 int SwPrivateDataPage::DeactivatePage(SfxItemSet
* _pSet
)
948 /*-- 29.09.99 08:55:58---------------------------------------------------
950 -----------------------------------------------------------------------*/
951 sal_Bool
SwPrivateDataPage::FillItemSet(SfxItemSet
& rSet
)
954 SwLabItem aItem
= (const SwLabItem
&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL
);
955 aItem
.aPrivFirstName
= aFirstNameED
.GetText();
956 aItem
.aPrivName
= aNameED
.GetText( );
957 aItem
.aPrivShortCut
= aShortCutED
.GetText( );
958 aItem
.aPrivFirstName2
= aFirstName2ED
.GetText();
959 aItem
.aPrivName2
= aName2ED
.GetText( );
960 aItem
.aPrivShortCut2
= aShortCut2ED
.GetText( );
961 aItem
.aPrivStreet
= aStreetED
.GetText( );
962 aItem
.aPrivZip
= aZipED
.GetText( );
963 aItem
.aPrivCity
= aCityED
.GetText( );
964 aItem
.aPrivCountry
= aCountryED
.GetText( );
965 aItem
.aPrivState
= aStateED
.GetText( );
966 aItem
.aPrivTitle
= aTitleED
.GetText( );
967 aItem
.aPrivProfession
= aProfessionED
.GetText( );
968 aItem
.aPrivPhone
= aPhoneED
.GetText( );
969 aItem
.aPrivMobile
= aMobilePhoneED
.GetText( );
970 aItem
.aPrivFax
= aFaxED
.GetText( );
971 aItem
.aPrivWWW
= aHomePageED
.GetText( );
972 aItem
.aPrivMail
= aMailED
.GetText( );
977 /*-- 29.09.99 08:55:59---------------------------------------------------
979 -----------------------------------------------------------------------*/
980 void SwPrivateDataPage::Reset(const SfxItemSet
& rSet
)
982 const SwLabItem
& aItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
983 aFirstNameED
.SetText(aItem
.aPrivFirstName
);
984 aNameED
.SetText(aItem
.aPrivName
);
985 aShortCutED
.SetText(aItem
.aPrivShortCut
);
986 aFirstName2ED
.SetText(aItem
.aPrivFirstName2
);
987 aName2ED
.SetText(aItem
.aPrivName2
);
988 aShortCut2ED
.SetText(aItem
.aPrivShortCut2
);
989 aStreetED
.SetText(aItem
.aPrivStreet
);
990 aZipED
.SetText(aItem
.aPrivZip
);
991 aCityED
.SetText(aItem
.aPrivCity
);
992 aCountryED
.SetText(aItem
.aPrivCountry
);
993 aStateED
.SetText(aItem
.aPrivState
);
994 aTitleED
.SetText(aItem
.aPrivTitle
);
995 aProfessionED
.SetText(aItem
.aPrivProfession
);
996 aPhoneED
.SetText(aItem
.aPrivPhone
);
997 aMobilePhoneED
.SetText(aItem
.aPrivMobile
);
998 aFaxED
.SetText(aItem
.aPrivFax
);
999 aHomePageED
.SetText(aItem
.aPrivWWW
);
1000 aMailED
.SetText(aItem
.aPrivMail
);
1002 /* -----------------29.09.99 08:56-------------------
1004 --------------------------------------------------*/
1005 SwBusinessDataPage::SwBusinessDataPage(Window
* pParent
, const SfxItemSet
& rSet
) :
1006 SfxTabPage(pParent
, SW_RES(TP_BUSINESS_DATA
), rSet
),
1007 aDataFL (this, SW_RES( FL_DATA
)),
1008 aCompanyFT (this, SW_RES( FT_COMP
)),
1009 aCompanyED (this, SW_RES( ED_COMP
)),
1010 aCompanyExtFT (this, SW_RES( FT_COMP_EXT
)),
1011 aCompanyExtED (this, SW_RES( ED_COMP_EXT
)),
1012 aSloganFT (this, SW_RES( FT_SLOGAN
)),
1013 aSloganED (this, SW_RES( ED_SLOGAN
)),
1014 aStreetFT (this, SW_RES( FT_STREET
)),
1015 aStreetED (this, SW_RES( ED_STREET
)),
1016 aZipCityFT (this, SW_RES( FT_ZIPCITY
)),
1017 aZipED (this, SW_RES( ED_ZIP
)),
1018 aCityED (this, SW_RES( ED_CITY
)),
1019 aCountryStateFT (this, SW_RES( FT_COUNTRYSTATE
)),
1020 aCountryED (this, SW_RES( ED_COUNTRY
)),
1021 aStateED (this, SW_RES( ED_STATE
)),
1022 aPositionFT (this, SW_RES( FT_POSITION
)),
1023 aPositionED (this, SW_RES( ED_POSITION
)),
1024 aPhoneFT (this, SW_RES( FT_PHONE_MOBILE
)),
1025 aPhoneED (this, SW_RES( ED_PHONE
)),
1026 aMobilePhoneED (this, SW_RES( ED_MOBILE
)),
1027 aFaxFT (this, SW_RES( FT_FAX
)),
1028 aFaxED (this, SW_RES( ED_FAX
)),
1029 aWWWMailFT (this, SW_RES( FT_WWWMAIL
)),
1030 aHomePageED (this, SW_RES( ED_WWW
)),
1031 aMailED (this, SW_RES( ED_MAIL
))
1034 SetExchangeSupport();
1037 /*-- 29.09.99 08:56:06---------------------------------------------------
1039 -----------------------------------------------------------------------*/
1040 SwBusinessDataPage::~SwBusinessDataPage()
1043 /*-- 29.09.99 08:56:06---------------------------------------------------
1045 -----------------------------------------------------------------------*/
1046 SfxTabPage
* SwBusinessDataPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
1048 return new SwBusinessDataPage(pParent
, rSet
);
1050 /*-- 29.09.99 08:56:06---------------------------------------------------
1052 -----------------------------------------------------------------------*/
1053 void SwBusinessDataPage::ActivatePage(const SfxItemSet
& rSet
)
1057 /*-- 29.09.99 08:56:06---------------------------------------------------
1059 -----------------------------------------------------------------------*/
1060 int SwBusinessDataPage::DeactivatePage(SfxItemSet
* _pSet
)
1063 FillItemSet(*_pSet
);
1066 /*-- 29.09.99 08:56:06---------------------------------------------------
1068 -----------------------------------------------------------------------*/
1069 sal_Bool
SwBusinessDataPage::FillItemSet(SfxItemSet
& rSet
)
1071 SwLabItem aItem
= (const SwLabItem
&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL
);
1073 aItem
.aCompCompany
= aCompanyED
.GetText();
1074 aItem
.aCompCompanyExt
= aCompanyExtED
.GetText();
1075 aItem
.aCompSlogan
= aSloganED
.GetText();
1076 aItem
.aCompStreet
= aStreetED
.GetText();
1077 aItem
.aCompZip
= aZipED
.GetText();
1078 aItem
.aCompCity
= aCityED
.GetText();
1079 aItem
.aCompCountry
= aCountryED
.GetText();
1080 aItem
.aCompState
= aStateED
.GetText();
1081 aItem
.aCompPosition
= aPositionED
.GetText();
1082 aItem
.aCompPhone
= aPhoneED
.GetText();
1083 aItem
.aCompMobile
= aMobilePhoneED
.GetText();
1084 aItem
.aCompFax
= aFaxED
.GetText();
1085 aItem
.aCompWWW
= aHomePageED
.GetText();
1086 aItem
.aCompMail
= aMailED
.GetText();
1091 /*-- 29.09.99 08:56:07---------------------------------------------------
1093 -----------------------------------------------------------------------*/
1094 void SwBusinessDataPage::Reset(const SfxItemSet
& rSet
)
1096 const SwLabItem
& aItem
= (const SwLabItem
&) rSet
.Get(FN_LABEL
);
1097 aCompanyED
.SetText(aItem
.aCompCompany
);
1098 aCompanyExtED
.SetText(aItem
.aCompCompanyExt
);
1099 aSloganED
.SetText(aItem
.aCompSlogan
);
1100 aStreetED
.SetText(aItem
.aCompStreet
);
1101 aZipED
.SetText(aItem
.aCompZip
);
1102 aCityED
.SetText(aItem
.aCompCity
);
1103 aCountryED
.SetText(aItem
.aCompCountry
);
1104 aStateED
.SetText(aItem
.aCompState
);
1105 aPositionED
.SetText(aItem
.aCompPosition
);
1106 aPhoneED
.SetText(aItem
.aCompPhone
);
1107 aMobilePhoneED
.SetText(aItem
.aCompMobile
);
1108 aFaxED
.SetText(aItem
.aCompFax
);
1109 aHomePageED
.SetText(aItem
.aCompWWW
);
1110 aMailED
.SetText(aItem
.aCompMail
);