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