1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 // include --------------------------------------------------------------- 28 #include <tools/shl.hxx> 29 #ifndef _MSGBOX_HXX //autogen 30 #include <vcl/msgbox.hxx> 31 #endif 32 33 #define _SVX_PASSWD_CXX 34 35 #include "svx/passwd.hxx" 36 #include <svx/dialmgr.hxx> 37 #include <svx/dialogs.hrc> 38 #include "passwd.hrc" 39 40 // class SvxPasswordDialog ----------------------------------------------- 41 42 IMPL_LINK( SvxPasswordDialog, ButtonHdl, OKButton *, EMPTYARG ) 43 { 44 sal_Bool bOK = sal_True; 45 short nRet = RET_OK; 46 String aEmpty; 47 48 if ( aNewPasswdED.GetText() != aRepeatPasswdED.GetText() ) 49 { 50 ErrorBox( this, WB_OK, aRepeatPasswdErrStr ).Execute(); 51 aNewPasswdED.SetText( aEmpty ); 52 aRepeatPasswdED.SetText( aEmpty ); 53 aNewPasswdED.GrabFocus(); 54 bOK = sal_False; 55 } 56 57 if ( bOK && aCheckPasswordHdl.IsSet() && !aCheckPasswordHdl.Call( this ) ) 58 { 59 ErrorBox( this, WB_OK, aOldPasswdErrStr ).Execute(); 60 aOldPasswdED.SetText( aEmpty ); 61 aOldPasswdED.GrabFocus(); 62 bOK = sal_False; 63 } 64 65 if ( bOK ) 66 EndDialog( nRet ); 67 68 return 0; 69 } 70 71 // ----------------------------------------------------------------------- 72 73 IMPL_LINK( SvxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG ) 74 { 75 if ( !bEmpty ) 76 { 77 String aPasswd = aRepeatPasswdED.GetText(); 78 aPasswd.EraseLeadingChars().EraseTrailingChars(); 79 80 if ( !aPasswd.Len() && aOKBtn.IsEnabled() ) 81 aOKBtn.Disable(); 82 else if ( aPasswd.Len() && !aOKBtn.IsEnabled() ) 83 aOKBtn.Enable(); 84 } 85 else if ( !aOKBtn.IsEnabled() ) 86 aOKBtn.Enable(); 87 return 0; 88 } 89 90 // ----------------------------------------------------------------------- 91 92 SvxPasswordDialog::SvxPasswordDialog( Window* pParent, sal_Bool bAllowEmptyPasswords, sal_Bool bDisableOldPassword ) : 93 SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_PASSWORD ) ), 94 aOldFL ( this, SVX_RES( FL_OLD_PASSWD ) ), 95 aOldPasswdFT ( this, SVX_RES( FT_OLD_PASSWD ) ), 96 aOldPasswdED ( this, SVX_RES( ED_OLD_PASSWD ) ), 97 aNewFL ( this, SVX_RES( FL_NEW_PASSWD ) ), 98 aNewPasswdFT ( this, SVX_RES( FT_NEW_PASSWD ) ), 99 aNewPasswdED ( this, SVX_RES( ED_NEW_PASSWD ) ), 100 aRepeatPasswdFT ( this, SVX_RES( FT_REPEAT_PASSWD ) ), 101 aRepeatPasswdED ( this, SVX_RES( ED_REPEAT_PASSWD ) ), 102 aOKBtn ( this, SVX_RES( BTN_PASSWD_OK ) ), 103 aEscBtn ( this, SVX_RES( BTN_PASSWD_ESC ) ), 104 aHelpBtn ( this, SVX_RES( BTN_PASSWD_HELP ) ), 105 aOldPasswdErrStr ( SVX_RES( STR_ERR_OLD_PASSWD ) ), 106 aRepeatPasswdErrStr ( SVX_RES( STR_ERR_REPEAT_PASSWD ) ), 107 bEmpty ( bAllowEmptyPasswords ) 108 { 109 FreeResource(); 110 111 aOKBtn.SetClickHdl( LINK( this, SvxPasswordDialog, ButtonHdl ) ); 112 aRepeatPasswdED.SetModifyHdl( LINK( this, SvxPasswordDialog, EditModifyHdl ) ); 113 EditModifyHdl( 0 ); 114 115 if ( bDisableOldPassword ) 116 { 117 aOldFL.Disable(); 118 aOldPasswdFT.Disable(); 119 aOldPasswdED.Disable(); 120 aNewPasswdED.GrabFocus(); 121 } 122 } 123 124 // ----------------------------------------------------------------------- 125 126 SvxPasswordDialog::~SvxPasswordDialog() 127 { 128 } 129 130 // ----------------------------------------------------------------------- 131 132 133