xref: /aoo41x/main/cui/source/options/optgenrl.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_cui.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir #include <tools/shl.hxx>
33*cdf0e10cSrcweir #include <vcl/svapp.hxx>
34*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35*cdf0e10cSrcweir #include <unotools/saveopt.hxx>
36*cdf0e10cSrcweir #include <svl/intitem.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #define _SVX_OPTGENRL_CXX
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <cuires.hrc>
41*cdf0e10cSrcweir #include "optgenrl.hrc"
42*cdf0e10cSrcweir #include <unotools/useroptions.hxx>
43*cdf0e10cSrcweir #include "cuioptgenrl.hxx"
44*cdf0e10cSrcweir #include <dialmgr.hxx>
45*cdf0e10cSrcweir #include <svx/dlgutil.hxx>
46*cdf0e10cSrcweir #include <svx/strarray.hxx>
47*cdf0e10cSrcweir #include <svx/svxids.hrc> // SID_FIELD_GRABFOCUS
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #define TRIM(s) s.EraseLeadingChars().EraseTrailingChars()
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir // struct GeneralTabPage_Impl --------------------------------------------
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir struct GeneralTabPage_Impl
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir 	sal_Bool	mbStreetEnabled;
56*cdf0e10cSrcweir 	sal_Bool	mbPLZEnabled;
57*cdf0e10cSrcweir 	sal_Bool	mbCityEnabled;
58*cdf0e10cSrcweir 	sal_Bool	mbUsCityEnabled;
59*cdf0e10cSrcweir 	sal_Bool	mbUsZipEnabled;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 	String	maQueryStr;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	GeneralTabPage_Impl() :
64*cdf0e10cSrcweir 		mbStreetEnabled	( sal_False ),
65*cdf0e10cSrcweir 		mbPLZEnabled	( sal_False ),
66*cdf0e10cSrcweir 		mbCityEnabled	( sal_False ),
67*cdf0e10cSrcweir 		mbUsCityEnabled	( sal_False ),
68*cdf0e10cSrcweir 		mbUsZipEnabled	( sal_False ) {}
69*cdf0e10cSrcweir };
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir // -----------------------------------------------------------------------
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir SvxGeneralTabPage::SvxGeneralTabPage( Window* pParent, const SfxItemSet& rCoreSet ) :
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	SfxTabPage( pParent, CUI_RES(RID_SFXPAGE_GENERAL), rCoreSet ),
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	aAddrFrm		( this, CUI_RES( GB_ADDRESS ) ),
78*cdf0e10cSrcweir     aCompanyLbl     ( this, CUI_RES( FT_COMPANY ), true ),
79*cdf0e10cSrcweir     aCompanyEdit    ( this, CUI_RES( ED_COMPANY ), INDEX_NOTSET, &aCompanyLbl ),
80*cdf0e10cSrcweir     aNameLbl        ( this, CUI_RES( FT_NAME ), true ),
81*cdf0e10cSrcweir     aNameLblRuss    ( this, CUI_RES( FT_NAME_RUSS ), true ),
82*cdf0e10cSrcweir     aNameLblEastern ( this, CUI_RES( FT_NAME_EASTERN ), true ),
83*cdf0e10cSrcweir     aFirstName      ( this, CUI_RES( ED_FIRSTNAME ), 0, &aNameLbl ),
84*cdf0e10cSrcweir     aFatherName     ( this, CUI_RES( ED_FATHERNAME ) ),
85*cdf0e10cSrcweir     aName           ( this, CUI_RES( ED_NAME ), 1, &aNameLbl ),
86*cdf0e10cSrcweir     aShortName      ( this, CUI_RES( ED_SHORTNAME ), 2, &aNameLbl ),
87*cdf0e10cSrcweir     aStreetLbl      ( this, CUI_RES( FT_STREET ), true ),
88*cdf0e10cSrcweir     aStreetLblRuss  ( this, CUI_RES( FT_STREET_RUSS ), true ),
89*cdf0e10cSrcweir     aStreetEdit     ( this, CUI_RES( ED_STREET ), 0, &aStreetLbl ),
90*cdf0e10cSrcweir     aApartmentNrEdit( this, CUI_RES( ED_APARTMENTNR ), 1, &aStreetLblRuss ),
91*cdf0e10cSrcweir     aCityLbl        ( this, CUI_RES( FT_CITY ), true ),
92*cdf0e10cSrcweir     aPLZEdit        ( this, CUI_RES( ED_PLZ ), 0, &aCityLbl ),
93*cdf0e10cSrcweir     aCityEdit       ( this, CUI_RES( ED_CITY ), 1, &aCityLbl ),
94*cdf0e10cSrcweir     aUsCityEdit     ( this, CUI_RES( ED_US_CITY ), 0, &aCityLbl ),
95*cdf0e10cSrcweir     aUsStateEdit    ( this, CUI_RES( ED_US_STATE ), 1, &aCityLbl ),
96*cdf0e10cSrcweir     aUsZipEdit      ( this, CUI_RES( ED_US_ZIPCODE ), 2, &aCityLbl ),
97*cdf0e10cSrcweir     aCountryLbl     ( this, CUI_RES( FT_COUNTRY ), true ),
98*cdf0e10cSrcweir     aCountryEdit    ( this, CUI_RES( ED_COUNTRY ), INDEX_NOTSET, &aCountryLbl ),
99*cdf0e10cSrcweir     aTitlePosLbl    ( this, CUI_RES( FT_TITLEPOS ), true ),
100*cdf0e10cSrcweir     aTitleEdit      ( this, CUI_RES( ED_TITLE ), 0, &aTitlePosLbl ),
101*cdf0e10cSrcweir     aPositionEdit   ( this, CUI_RES( ED_POSITION ), 1, &aTitlePosLbl ),
102*cdf0e10cSrcweir     aPhoneLbl       ( this, CUI_RES( FT_PHONE ), true ),
103*cdf0e10cSrcweir     aTelPrivEdit    ( this, CUI_RES( ED_TELPRIVAT ), 0, &aPhoneLbl ),
104*cdf0e10cSrcweir     aTelCompanyEdit ( this, CUI_RES( ED_TELCOMPANY ), 1, &aPhoneLbl ),
105*cdf0e10cSrcweir     aFaxMailLbl     ( this, CUI_RES( FT_FAXMAIL ), true ),
106*cdf0e10cSrcweir     aFaxEdit        ( this, CUI_RES( ED_FAX ), 0, &aFaxMailLbl ),
107*cdf0e10cSrcweir     aEmailEdit      ( this, CUI_RES( ED_EMAIL ), 1, &aFaxMailLbl ),
108*cdf0e10cSrcweir 	aUseDataCB		( this, CUI_RES( CB_USEDATA ) ),
109*cdf0e10cSrcweir 	pImpl			( new GeneralTabPage_Impl )
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir     LanguageType eLang = Application::GetSettings().GetUILanguage();
113*cdf0e10cSrcweir 	pImpl->maQueryStr = String( CUI_RES( STR_QUERY_REG ) );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	if ( LANGUAGE_ENGLISH_US == eLang )
116*cdf0e10cSrcweir 	{
117*cdf0e10cSrcweir 		// amerikanische Postadresse aufbauen
118*cdf0e10cSrcweir 		aPLZEdit.Hide();
119*cdf0e10cSrcweir 		aCityEdit.Hide();
120*cdf0e10cSrcweir 		aCityLbl.SetText( CUI_RES( STR_US_STATE ) );
121*cdf0e10cSrcweir 	}
122*cdf0e10cSrcweir 	else if ( LANGUAGE_RUSSIAN == eLang )
123*cdf0e10cSrcweir 	{
124*cdf0e10cSrcweir 		aUsCityEdit.Hide();
125*cdf0e10cSrcweir 		aUsStateEdit.Hide();
126*cdf0e10cSrcweir 		aUsZipEdit.Hide();
127*cdf0e10cSrcweir 		aNameLbl.Hide();
128*cdf0e10cSrcweir 		aNameLblRuss.Show();
129*cdf0e10cSrcweir 		aStreetLbl.Hide();
130*cdf0e10cSrcweir 		aStreetLblRuss.Show();
131*cdf0e10cSrcweir 		aFatherName.Show();
132*cdf0e10cSrcweir         aName.SetIndex( 0 );
133*cdf0e10cSrcweir         aName.SetLabel( &aNameLblRuss );
134*cdf0e10cSrcweir         aFirstName.SetIndex( 1 );
135*cdf0e10cSrcweir         aFirstName.SetLabel( &aNameLblRuss );
136*cdf0e10cSrcweir         aFatherName.SetIndex( 2 );
137*cdf0e10cSrcweir         aFatherName.SetLabel( &aNameLblRuss );
138*cdf0e10cSrcweir         aShortName.SetIndex( 3 );
139*cdf0e10cSrcweir         aShortName.SetLabel( &aNameLblRuss );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 		Point aEditPoint = LogicToPixel( Point( MID, LINE(1) ), MAP_APPFONT );
142*cdf0e10cSrcweir 		Point aRightPoint = LogicToPixel( Point( RIGHT, LINE(1) ), MAP_APPFONT );
143*cdf0e10cSrcweir 		Size aEditSize = LogicToPixel( Size( 42, 12 ), MAP_APPFONT );
144*cdf0e10cSrcweir 		Size a2Size = LogicToPixel( Size( 2, 2 ), MAP_APPFONT );
145*cdf0e10cSrcweir 		long nDelta = aEditSize.Width() + a2Size.Width();
146*cdf0e10cSrcweir 		aName.SetPosSizePixel( aEditPoint, aEditSize );
147*cdf0e10cSrcweir 		aEditPoint.X() = aEditPoint.X() + nDelta;
148*cdf0e10cSrcweir 		aFirstName.SetPosSizePixel( aEditPoint, aEditSize );
149*cdf0e10cSrcweir 		aEditPoint.X() = aEditPoint.X() + nDelta;
150*cdf0e10cSrcweir 		aFatherName.SetPosSizePixel( aEditPoint, aEditSize );
151*cdf0e10cSrcweir 		aEditPoint.X() = aEditPoint.X() + nDelta;
152*cdf0e10cSrcweir 		aEditSize.Width() = aRightPoint.X() - aEditPoint.X();
153*cdf0e10cSrcweir 		aShortName.SetPosSizePixel( aEditPoint, aEditSize );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		Size aStreetSize = aStreetEdit.GetSizePixel();
156*cdf0e10cSrcweir 		aStreetSize.Width() = aStreetSize.Width() - aEditSize.Width() - a2Size.Width();
157*cdf0e10cSrcweir 		aStreetEdit.SetSizePixel( aStreetSize );
158*cdf0e10cSrcweir 		aApartmentNrEdit.Show();
159*cdf0e10cSrcweir 		Point aApartmentPoint = LogicToPixel( Point( MID, LINE(2) ), MAP_APPFONT );
160*cdf0e10cSrcweir 		aApartmentPoint.X() = aEditPoint.X();
161*cdf0e10cSrcweir 		aApartmentNrEdit.SetPosSizePixel( aApartmentPoint, aEditSize );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         aName.SetZOrder( &aNameLblRuss, WINDOW_ZORDER_BEHIND );
164*cdf0e10cSrcweir         aFirstName.SetZOrder( &aName, WINDOW_ZORDER_BEHIND );
165*cdf0e10cSrcweir         aFatherName.SetZOrder( &aFirstName, WINDOW_ZORDER_BEHIND );
166*cdf0e10cSrcweir 	}
167*cdf0e10cSrcweir 	else if ( LANGUAGE_JAPANESE == eLang ||
168*cdf0e10cSrcweir 		  LANGUAGE_KOREAN == eLang ||
169*cdf0e10cSrcweir 		  LANGUAGE_CHINESE_TRADITIONAL == eLang ||
170*cdf0e10cSrcweir 		  LANGUAGE_CHINESE_SIMPLIFIED == eLang)
171*cdf0e10cSrcweir 	{
172*cdf0e10cSrcweir 		aUsCityEdit.Hide();
173*cdf0e10cSrcweir 		aUsStateEdit.Hide();
174*cdf0e10cSrcweir 		aUsZipEdit.Hide();
175*cdf0e10cSrcweir 		aNameLbl.Hide();
176*cdf0e10cSrcweir 		aNameLblEastern.Show();
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 		// swap "first name" field and "last name" field
179*cdf0e10cSrcweir 		Point aPosTmp = aFirstName.GetPosPixel();
180*cdf0e10cSrcweir 		aFirstName.SetPosPixel( aName.GetPosPixel() );
181*cdf0e10cSrcweir 		aName.SetPosPixel( aPosTmp );
182*cdf0e10cSrcweir 		aFirstName.SetZOrder( &aName, WINDOW_ZORDER_BEHIND );
183*cdf0e10cSrcweir 	}
184*cdf0e10cSrcweir 	else
185*cdf0e10cSrcweir 	{
186*cdf0e10cSrcweir         aUsCityEdit.Hide();
187*cdf0e10cSrcweir         aUsStateEdit.Hide();
188*cdf0e10cSrcweir         aUsZipEdit.Hide();
189*cdf0e10cSrcweir 	}
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	FreeResource();
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	// diese Page braucht ExchangeSupport
194*cdf0e10cSrcweir 	SetExchangeSupport();
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	Link aLink = LINK( this, SvxGeneralTabPage, ModifyHdl_Impl );
197*cdf0e10cSrcweir 	aFirstName.SetModifyHdl( aLink );
198*cdf0e10cSrcweir 	aName.SetModifyHdl( aLink );
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     // because some labels have text for more than one edit field we have to split these texts
201*cdf0e10cSrcweir     // and set these texts as accessible name of the corresponding edit fields
202*cdf0e10cSrcweir     SvxUserEdit* pEdits[] =
203*cdf0e10cSrcweir     {
204*cdf0e10cSrcweir         &aCompanyEdit, &aFirstName, &aFatherName, &aName, &aShortName, &aStreetEdit,
205*cdf0e10cSrcweir         &aApartmentNrEdit, &aPLZEdit, &aCityEdit, &aUsCityEdit, &aUsStateEdit, &aUsZipEdit,
206*cdf0e10cSrcweir         &aCountryEdit, &aTitleEdit, &aPositionEdit, &aTelPrivEdit, &aTelCompanyEdit,
207*cdf0e10cSrcweir         &aFaxEdit, &aEmailEdit, NULL
208*cdf0e10cSrcweir     };
209*cdf0e10cSrcweir     SvxUserEdit** pCurrent = pEdits;
210*cdf0e10cSrcweir     while ( *pCurrent )
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir         Window* pLabel = (*pCurrent)->GetLabel();
213*cdf0e10cSrcweir         if ( pLabel )
214*cdf0e10cSrcweir         {
215*cdf0e10cSrcweir             String sName, sText = pLabel->GetDisplayText();
216*cdf0e10cSrcweir             sal_Int16 nIndex = (*pCurrent)->GetIndex();
217*cdf0e10cSrcweir             if ( INDEX_NOTSET == nIndex )
218*cdf0e10cSrcweir                 sName = sText;
219*cdf0e10cSrcweir             else
220*cdf0e10cSrcweir                 sName = sText.GetToken( nIndex, '/' );
221*cdf0e10cSrcweir             sName.EraseAllChars( '(' );
222*cdf0e10cSrcweir             sName.EraseAllChars( ')' );
223*cdf0e10cSrcweir             if ( sName.Len() > 0 )
224*cdf0e10cSrcweir                 (*pCurrent)->SetAccessibleName( sName );
225*cdf0e10cSrcweir         }
226*cdf0e10cSrcweir         pCurrent++;
227*cdf0e10cSrcweir     }
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir //------------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir SvxGeneralTabPage::~SvxGeneralTabPage()
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir 	delete pImpl;
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir //------------------------------------------------------------------------
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir SfxTabPage*	SvxGeneralTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir 	return ( new SvxGeneralTabPage( pParent, rAttrSet ) );
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir //------------------------------------------------------------------------
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir sal_Bool SvxGeneralTabPage::FillItemSet( SfxItemSet& )
247*cdf0e10cSrcweir {
248*cdf0e10cSrcweir 	// Eingaben trimmen (f"uhrende und nachfolgende Leerzeichen entfernen)
249*cdf0e10cSrcweir 	aCompanyEdit.SetText( TRIM(aCompanyEdit.GetText()) );
250*cdf0e10cSrcweir 	aFirstName.SetText( TRIM(aFirstName.GetText()) );
251*cdf0e10cSrcweir 	aName.SetText( TRIM(aName.GetText()) );
252*cdf0e10cSrcweir 	aShortName.SetText( TRIM(aShortName.GetText()) );
253*cdf0e10cSrcweir 	aStreetEdit.SetText( TRIM(aStreetEdit.GetText()) );
254*cdf0e10cSrcweir 	aCountryEdit.SetText( TRIM(aCountryEdit.GetText()) );
255*cdf0e10cSrcweir 	aPLZEdit.SetText( TRIM(aPLZEdit.GetText()) );
256*cdf0e10cSrcweir 	aCityEdit.SetText( TRIM(aCityEdit.GetText()) );
257*cdf0e10cSrcweir 	aUsCityEdit.SetText( TRIM(aUsCityEdit.GetText()) );
258*cdf0e10cSrcweir 	aUsStateEdit.SetText( TRIM(aUsStateEdit.GetText()) );
259*cdf0e10cSrcweir 	aUsZipEdit.SetText( TRIM(aUsZipEdit.GetText()) );
260*cdf0e10cSrcweir 	aTitleEdit.SetText( TRIM(aTitleEdit.GetText()) );
261*cdf0e10cSrcweir 	aPositionEdit.SetText( TRIM(aPositionEdit.GetText()) );
262*cdf0e10cSrcweir 	aTelPrivEdit.SetText( TRIM(aTelPrivEdit.GetText()) );
263*cdf0e10cSrcweir 	aTelCompanyEdit.SetText( TRIM(aTelCompanyEdit.GetText()) );
264*cdf0e10cSrcweir 	aFaxEdit.SetText( TRIM(aFaxEdit.GetText()) );
265*cdf0e10cSrcweir 	aEmailEdit.SetText( TRIM(aEmailEdit.GetText()) );
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     sal_Bool bModified = sal_False;
268*cdf0e10cSrcweir     bModified |= GetAddress_Impl();
269*cdf0e10cSrcweir 	SvtSaveOptions aSaveOpt;
270*cdf0e10cSrcweir 	if ( aUseDataCB.IsChecked() != aSaveOpt.IsUseUserData() )
271*cdf0e10cSrcweir 	{
272*cdf0e10cSrcweir 		aSaveOpt.SetUseUserData( aUseDataCB.IsChecked() );
273*cdf0e10cSrcweir 		bModified |= sal_True;
274*cdf0e10cSrcweir 	}
275*cdf0e10cSrcweir 	return bModified;
276*cdf0e10cSrcweir }
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir //------------------------------------------------------------------------
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir void SvxGeneralTabPage::Reset( const SfxItemSet& rSet )
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     SetAddress_Impl();
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     sal_uInt16 nWhich = GetWhich( SID_FIELD_GRABFOCUS );
285*cdf0e10cSrcweir 	if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET )
286*cdf0e10cSrcweir 	{
287*cdf0e10cSrcweir 		sal_uInt16 nField = ( (SfxUInt16Item&)rSet.Get( nWhich ) ).GetValue();
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 		switch ( nField )
290*cdf0e10cSrcweir 		{
291*cdf0e10cSrcweir 			case COMPANY_EDIT:		aCompanyEdit.GrabFocus(); break;
292*cdf0e10cSrcweir 			case FIRSTNAME_EDIT:    aFirstName.GrabFocus(); break;
293*cdf0e10cSrcweir 			case LASTNAME_EDIT:		aName.GrabFocus(); break;
294*cdf0e10cSrcweir 			case STREET_EDIT:		aStreetEdit.GrabFocus(); break;
295*cdf0e10cSrcweir 			case COUNTRY_EDIT:		aCountryEdit.GrabFocus(); break;
296*cdf0e10cSrcweir 			case PLZ_EDIT:
297*cdf0e10cSrcweir 				if ( aPLZEdit.IsVisible() )
298*cdf0e10cSrcweir 					aPLZEdit.GrabFocus();
299*cdf0e10cSrcweir 				else
300*cdf0e10cSrcweir 					aUsZipEdit.GrabFocus();
301*cdf0e10cSrcweir 				break;
302*cdf0e10cSrcweir 			case CITY_EDIT:
303*cdf0e10cSrcweir 				if ( aCityEdit.IsVisible() )
304*cdf0e10cSrcweir 					aCityEdit.GrabFocus();
305*cdf0e10cSrcweir 				else
306*cdf0e10cSrcweir 					aUsCityEdit.GrabFocus();
307*cdf0e10cSrcweir 				break;
308*cdf0e10cSrcweir 			case STATE_EDIT:
309*cdf0e10cSrcweir 				if ( aUsStateEdit.IsVisible() )
310*cdf0e10cSrcweir 					aUsStateEdit.GrabFocus();
311*cdf0e10cSrcweir 				else
312*cdf0e10cSrcweir 					aCityEdit.GrabFocus();
313*cdf0e10cSrcweir 				break;
314*cdf0e10cSrcweir 			case TITLE_EDIT:		aTitleEdit.GrabFocus(); break;
315*cdf0e10cSrcweir 			case POSITION_EDIT:		aPositionEdit.GrabFocus(); break;
316*cdf0e10cSrcweir 			case SHORTNAME_EDIT:	aShortName.GrabFocus(); break;
317*cdf0e10cSrcweir 			case TELPRIV_EDIT:		aTelPrivEdit.GrabFocus(); break;
318*cdf0e10cSrcweir 			case TELCOMPANY_EDIT:	aTelCompanyEdit.GrabFocus(); break;
319*cdf0e10cSrcweir 			case FAX_EDIT:			aFaxEdit.GrabFocus(); break;
320*cdf0e10cSrcweir 			case EMAIL_EDIT:		aEmailEdit.GrabFocus(); break;
321*cdf0e10cSrcweir 			default:				aCompanyEdit.GrabFocus();
322*cdf0e10cSrcweir 		}
323*cdf0e10cSrcweir 	}
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	aUseDataCB.Check( SvtSaveOptions().IsUseUserData() );
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir //------------------------------------------------------------------------
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir IMPL_LINK( SvxGeneralTabPage, ModifyHdl_Impl, Edit *, pEdit )
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir 	if ( aShortName.IsEnabled() )
333*cdf0e10cSrcweir 	{
334*cdf0e10cSrcweir 		String aShortStr( aShortName.GetText() );
335*cdf0e10cSrcweir 		switch ( aShortStr.Len() )
336*cdf0e10cSrcweir 		{
337*cdf0e10cSrcweir 			case 0:
338*cdf0e10cSrcweir 				aShortStr = String( RTL_CONSTASCII_STRINGPARAM("  ") );
339*cdf0e10cSrcweir 				break;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 			case 1:
342*cdf0e10cSrcweir 				aShortStr += ' ';
343*cdf0e10cSrcweir 				break;
344*cdf0e10cSrcweir 		}
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 		sal_uInt16 nPos = ( pEdit == &aFirstName ) ? 0 : 1;
347*cdf0e10cSrcweir 		String aTxt = pEdit->GetText();
348*cdf0e10cSrcweir 		sal_Unicode cChar = ( aTxt.Len() > 0 ) ? aTxt.GetChar(0) : ' ';
349*cdf0e10cSrcweir 		aShortStr.SetChar( nPos, cChar );
350*cdf0e10cSrcweir 		aShortStr.EraseTrailingChars();
351*cdf0e10cSrcweir 		aShortName.SetText( aShortStr );
352*cdf0e10cSrcweir 	}
353*cdf0e10cSrcweir 	return 0;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir //------------------------------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir sal_Bool SvxGeneralTabPage::GetAddress_Impl()
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir     sal_Bool bRet =
361*cdf0e10cSrcweir     (   aCompanyEdit.GetSavedValue()  !=        aCompanyEdit.GetText()  ||
362*cdf0e10cSrcweir         aFirstName.GetSavedValue()  !=          aFirstName.GetText()  ||
363*cdf0e10cSrcweir         aFatherName.GetSavedValue()  !=         aFatherName.GetText()  ||
364*cdf0e10cSrcweir         aName.GetSavedValue()  !=               aName.GetText()  ||
365*cdf0e10cSrcweir         aShortName.GetSavedValue()  !=          aShortName.GetText()  ||
366*cdf0e10cSrcweir         aStreetEdit.GetSavedValue()  !=         aStreetEdit.GetText()  ||
367*cdf0e10cSrcweir         aApartmentNrEdit.GetSavedValue()  !=    aApartmentNrEdit.GetText()  ||
368*cdf0e10cSrcweir         aPLZEdit.GetSavedValue()  !=            aPLZEdit.GetText()  ||
369*cdf0e10cSrcweir         aCityEdit.GetSavedValue()  !=           aCityEdit.GetText()  ||
370*cdf0e10cSrcweir         aUsCityEdit.GetSavedValue()  !=         aUsCityEdit.GetText()  ||
371*cdf0e10cSrcweir         aUsStateEdit.GetSavedValue()  !=        aUsStateEdit.GetText()  ||
372*cdf0e10cSrcweir         aUsZipEdit.GetSavedValue()  !=          aUsZipEdit.GetText()  ||
373*cdf0e10cSrcweir         aCountryEdit.GetSavedValue()  !=        aCountryEdit.GetText()  ||
374*cdf0e10cSrcweir         aTitleEdit.GetSavedValue()  !=          aTitleEdit.GetText()  ||
375*cdf0e10cSrcweir         aPositionEdit.GetSavedValue()  !=       aPositionEdit.GetText()  ||
376*cdf0e10cSrcweir         aTelPrivEdit.GetSavedValue()  !=        aTelPrivEdit.GetText()  ||
377*cdf0e10cSrcweir         aTelCompanyEdit.GetSavedValue()  !=     aTelCompanyEdit.GetText()  ||
378*cdf0e10cSrcweir         aFaxEdit.GetSavedValue()  !=            aFaxEdit.GetText()  ||
379*cdf0e10cSrcweir         aEmailEdit.GetSavedValue()  !=          aEmailEdit.GetText() );
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir     LanguageType eLang = Application::GetSettings().GetUILanguage();
382*cdf0e10cSrcweir     sal_Bool bUS = ( LANGUAGE_ENGLISH_US == eLang );
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     SvtUserOptions aUserOpt;
385*cdf0e10cSrcweir     aUserOpt.SetCompany(aCompanyEdit.GetText());
386*cdf0e10cSrcweir     aUserOpt.SetFirstName(aFirstName.GetText());
387*cdf0e10cSrcweir     aUserOpt.SetLastName(aName.GetText());
388*cdf0e10cSrcweir     aUserOpt.SetID( aShortName.GetText());
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir     aUserOpt.SetStreet(aStreetEdit.GetText() );
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     aUserOpt.SetCountry(aCountryEdit.GetText() );
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir     aUserOpt.SetZip(bUS ? aUsZipEdit.GetText() : aPLZEdit.GetText() );
395*cdf0e10cSrcweir     aUserOpt.SetCity(bUS ? aUsCityEdit.GetText() : aCityEdit.GetText() );
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir     aUserOpt.SetTitle( aTitleEdit.GetText() );
398*cdf0e10cSrcweir     aUserOpt.SetPosition(aPositionEdit.GetText() );
399*cdf0e10cSrcweir     aUserOpt.SetTelephoneHome( aTelPrivEdit.GetText() );
400*cdf0e10cSrcweir     aUserOpt.SetTelephoneWork( aTelCompanyEdit.GetText() );
401*cdf0e10cSrcweir     aUserOpt.SetFax( aFaxEdit.GetText() );
402*cdf0e10cSrcweir     aUserOpt.SetEmail( aEmailEdit.GetText() );
403*cdf0e10cSrcweir     aUserOpt.SetState( bUS ? aUsStateEdit.GetText() : String() );
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     if ( LANGUAGE_RUSSIAN == eLang )
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         aUserOpt.SetFathersName( aFatherName.GetText() );
408*cdf0e10cSrcweir         aUserOpt.SetApartment( aApartmentNrEdit.GetText() );
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir     return bRet;
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir //------------------------------------------------------------------------
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir void SvxGeneralTabPage::SetAddress_Impl()
416*cdf0e10cSrcweir {
417*cdf0e10cSrcweir     LanguageType eLang = Application::GetSettings().GetUILanguage();
418*cdf0e10cSrcweir     sal_Bool bUS = ( LANGUAGE_ENGLISH_US == eLang );
419*cdf0e10cSrcweir     SvtUserOptions aUserOpt;
420*cdf0e10cSrcweir     aCompanyEdit.SetText( aUserOpt.GetCompany() );
421*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_COMPANY ) )
422*cdf0e10cSrcweir     {
423*cdf0e10cSrcweir         aCompanyLbl.Disable();
424*cdf0e10cSrcweir         aCompanyEdit.Disable();
425*cdf0e10cSrcweir     }
426*cdf0e10cSrcweir     sal_Int16 nEditCount = 0;
427*cdf0e10cSrcweir     aFirstName.SetText( aUserOpt.GetFirstName() );
428*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_FIRSTNAME ) )
429*cdf0e10cSrcweir     {
430*cdf0e10cSrcweir         aFirstName.Disable();
431*cdf0e10cSrcweir         nEditCount++;
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir     aName.SetText( aUserOpt.GetLastName() );
434*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_LASTNAME ) )
435*cdf0e10cSrcweir     {
436*cdf0e10cSrcweir         aName.Disable();
437*cdf0e10cSrcweir         nEditCount++;
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir     aShortName.SetText( aUserOpt.GetID() );
440*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_ID ) )
441*cdf0e10cSrcweir     {
442*cdf0e10cSrcweir         aShortName.Disable();
443*cdf0e10cSrcweir         nEditCount++;
444*cdf0e10cSrcweir     }
445*cdf0e10cSrcweir     aNameLbl.Enable( ( nEditCount != 3 ) );
446*cdf0e10cSrcweir     aStreetEdit.SetText( aUserOpt.GetStreet() );
447*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_STREET ) )
448*cdf0e10cSrcweir     {
449*cdf0e10cSrcweir         aStreetLbl.Disable();
450*cdf0e10cSrcweir         aStreetEdit.Disable();
451*cdf0e10cSrcweir     }
452*cdf0e10cSrcweir     Edit* pPLZEdit = bUS ? &aUsZipEdit : &aPLZEdit;
453*cdf0e10cSrcweir     Edit* pCityEdit = bUS ? &aUsCityEdit : &aCityEdit;
454*cdf0e10cSrcweir     pPLZEdit->SetText( aUserOpt.GetZip() );
455*cdf0e10cSrcweir     pCityEdit->SetText( aUserOpt.GetCity() );
456*cdf0e10cSrcweir     nEditCount = 0;
457*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_ZIP ) )
458*cdf0e10cSrcweir     {
459*cdf0e10cSrcweir         pPLZEdit->Disable();
460*cdf0e10cSrcweir         nEditCount++;
461*cdf0e10cSrcweir     }
462*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_CITY ) )
463*cdf0e10cSrcweir     {
464*cdf0e10cSrcweir         pCityEdit->Disable();
465*cdf0e10cSrcweir         nEditCount++;
466*cdf0e10cSrcweir     }
467*cdf0e10cSrcweir     if ( bUS )
468*cdf0e10cSrcweir     {
469*cdf0e10cSrcweir         aUsStateEdit.SetText( aUserOpt.GetState() );
470*cdf0e10cSrcweir         if ( aUserOpt.IsTokenReadonly( USER_OPT_STATE ) )
471*cdf0e10cSrcweir         {
472*cdf0e10cSrcweir             aUsStateEdit.Disable();
473*cdf0e10cSrcweir             nEditCount++;
474*cdf0e10cSrcweir         }
475*cdf0e10cSrcweir     }
476*cdf0e10cSrcweir     aCityLbl.Enable( ( nEditCount != ( bUS ? 3 : 2 ) ) );
477*cdf0e10cSrcweir     aCountryEdit.SetText( aUserOpt.GetCountry() );
478*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_COUNTRY ) )
479*cdf0e10cSrcweir     {
480*cdf0e10cSrcweir         aCountryLbl.Disable();
481*cdf0e10cSrcweir         aCountryEdit.Disable();
482*cdf0e10cSrcweir     }
483*cdf0e10cSrcweir     aTitleEdit.SetText( aUserOpt.GetTitle() );
484*cdf0e10cSrcweir     aPositionEdit.SetText( aUserOpt.GetPosition() );
485*cdf0e10cSrcweir     nEditCount = 0;
486*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_TITLE ) )
487*cdf0e10cSrcweir     {
488*cdf0e10cSrcweir         aTitleEdit.Disable();
489*cdf0e10cSrcweir         nEditCount++;
490*cdf0e10cSrcweir     }
491*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_POSITION ) )
492*cdf0e10cSrcweir     {
493*cdf0e10cSrcweir         aPositionEdit.Disable();
494*cdf0e10cSrcweir         nEditCount++;
495*cdf0e10cSrcweir     }
496*cdf0e10cSrcweir     aTitlePosLbl.Enable( ( nEditCount != 2 ) );
497*cdf0e10cSrcweir     aTelPrivEdit.SetText( aUserOpt.GetTelephoneHome() );
498*cdf0e10cSrcweir     aTelCompanyEdit.SetText( aUserOpt.GetTelephoneWork() );
499*cdf0e10cSrcweir     nEditCount = 0;
500*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_TELEPHONEHOME ) )
501*cdf0e10cSrcweir     {
502*cdf0e10cSrcweir         aTelPrivEdit.Disable();
503*cdf0e10cSrcweir         nEditCount++;
504*cdf0e10cSrcweir     }
505*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_TELEPHONEWORK ) )
506*cdf0e10cSrcweir     {
507*cdf0e10cSrcweir         aTelCompanyEdit.Disable();
508*cdf0e10cSrcweir         nEditCount++;
509*cdf0e10cSrcweir     }
510*cdf0e10cSrcweir     aPhoneLbl.Enable( ( nEditCount != 2 ) );
511*cdf0e10cSrcweir     aFaxEdit.SetText( aUserOpt.GetFax() );
512*cdf0e10cSrcweir     aEmailEdit.SetText( aUserOpt.GetEmail() );
513*cdf0e10cSrcweir     nEditCount = 0;
514*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_FAX ) )
515*cdf0e10cSrcweir     {
516*cdf0e10cSrcweir         aFaxEdit.Disable();
517*cdf0e10cSrcweir         nEditCount++;
518*cdf0e10cSrcweir     }
519*cdf0e10cSrcweir     if ( aUserOpt.IsTokenReadonly( USER_OPT_EMAIL ) )
520*cdf0e10cSrcweir     {
521*cdf0e10cSrcweir         aEmailEdit.Disable();
522*cdf0e10cSrcweir         nEditCount++;
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir     aFaxMailLbl.Enable( ( nEditCount != 2 ) );
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir     if ( LANGUAGE_RUSSIAN == eLang )
527*cdf0e10cSrcweir     {
528*cdf0e10cSrcweir         aFatherName.SetText( aUserOpt.GetFathersName() );
529*cdf0e10cSrcweir         aApartmentNrEdit.SetText( aUserOpt.GetApartment() );
530*cdf0e10cSrcweir     }
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir     aCompanyEdit.SaveValue();
533*cdf0e10cSrcweir     aFirstName.SaveValue();
534*cdf0e10cSrcweir     aFatherName.SaveValue();
535*cdf0e10cSrcweir     aName.SaveValue();
536*cdf0e10cSrcweir     aShortName.SaveValue();
537*cdf0e10cSrcweir     aStreetEdit.SaveValue();
538*cdf0e10cSrcweir     aApartmentNrEdit.SaveValue();
539*cdf0e10cSrcweir     aPLZEdit.SaveValue();
540*cdf0e10cSrcweir     aCityEdit.SaveValue();
541*cdf0e10cSrcweir     aUsCityEdit.SaveValue();
542*cdf0e10cSrcweir     aUsStateEdit.SaveValue();
543*cdf0e10cSrcweir     aUsZipEdit.SaveValue();
544*cdf0e10cSrcweir     aCountryEdit.SaveValue();
545*cdf0e10cSrcweir     aTitleEdit.SaveValue();
546*cdf0e10cSrcweir     aPositionEdit.SaveValue();
547*cdf0e10cSrcweir     aTelPrivEdit.SaveValue();
548*cdf0e10cSrcweir     aTelCompanyEdit.SaveValue();
549*cdf0e10cSrcweir     aFaxEdit.SaveValue();
550*cdf0e10cSrcweir     aEmailEdit.SaveValue();
551*cdf0e10cSrcweir }
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir // -----------------------------------------------------------------------
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir int SvxGeneralTabPage::DeactivatePage( SfxItemSet* _pSet )
556*cdf0e10cSrcweir {
557*cdf0e10cSrcweir     if ( _pSet )
558*cdf0e10cSrcweir         FillItemSet( *_pSet );
559*cdf0e10cSrcweir 	return LEAVE_PAGE;
560*cdf0e10cSrcweir }
561*cdf0e10cSrcweir 
562