1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <tools/shl.hxx> 33 #ifndef _MSGBOX_HXX //autogen 34 #include <vcl/msgbox.hxx> 35 #endif 36 37 #define _SVX_PASSWD_CXX 38 39 #include "svx/passwd.hxx" 40 #include <svx/dialmgr.hxx> 41 #include <svx/dialogs.hrc> 42 #include "passwd.hrc" 43 44 // class SvxPasswordDialog ----------------------------------------------- 45 46 IMPL_LINK( SvxPasswordDialog, ButtonHdl, OKButton *, EMPTYARG ) 47 { 48 sal_Bool bOK = sal_True; 49 short nRet = RET_OK; 50 String aEmpty; 51 52 if ( aNewPasswdED.GetText() != aRepeatPasswdED.GetText() ) 53 { 54 ErrorBox( this, WB_OK, aRepeatPasswdErrStr ).Execute(); 55 aNewPasswdED.SetText( aEmpty ); 56 aRepeatPasswdED.SetText( aEmpty ); 57 aNewPasswdED.GrabFocus(); 58 bOK = sal_False; 59 } 60 61 if ( bOK && aCheckPasswordHdl.IsSet() && !aCheckPasswordHdl.Call( this ) ) 62 { 63 ErrorBox( this, WB_OK, aOldPasswdErrStr ).Execute(); 64 aOldPasswdED.SetText( aEmpty ); 65 aOldPasswdED.GrabFocus(); 66 bOK = sal_False; 67 } 68 69 if ( bOK ) 70 EndDialog( nRet ); 71 72 return 0; 73 } 74 75 // ----------------------------------------------------------------------- 76 77 IMPL_LINK( SvxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG ) 78 { 79 if ( !bEmpty ) 80 { 81 String aPasswd = aRepeatPasswdED.GetText(); 82 aPasswd.EraseLeadingChars().EraseTrailingChars(); 83 84 if ( !aPasswd.Len() && aOKBtn.IsEnabled() ) 85 aOKBtn.Disable(); 86 else if ( aPasswd.Len() && !aOKBtn.IsEnabled() ) 87 aOKBtn.Enable(); 88 } 89 else if ( !aOKBtn.IsEnabled() ) 90 aOKBtn.Enable(); 91 return 0; 92 } 93 94 // ----------------------------------------------------------------------- 95 96 SvxPasswordDialog::SvxPasswordDialog( Window* pParent, sal_Bool bAllowEmptyPasswords, sal_Bool bDisableOldPassword ) : 97 SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_PASSWORD ) ), 98 aOldFL ( this, SVX_RES( FL_OLD_PASSWD ) ), 99 aOldPasswdFT ( this, SVX_RES( FT_OLD_PASSWD ) ), 100 aOldPasswdED ( this, SVX_RES( ED_OLD_PASSWD ) ), 101 aNewFL ( this, SVX_RES( FL_NEW_PASSWD ) ), 102 aNewPasswdFT ( this, SVX_RES( FT_NEW_PASSWD ) ), 103 aNewPasswdED ( this, SVX_RES( ED_NEW_PASSWD ) ), 104 aRepeatPasswdFT ( this, SVX_RES( FT_REPEAT_PASSWD ) ), 105 aRepeatPasswdED ( this, SVX_RES( ED_REPEAT_PASSWD ) ), 106 aOKBtn ( this, SVX_RES( BTN_PASSWD_OK ) ), 107 aEscBtn ( this, SVX_RES( BTN_PASSWD_ESC ) ), 108 aHelpBtn ( this, SVX_RES( BTN_PASSWD_HELP ) ), 109 aOldPasswdErrStr ( SVX_RES( STR_ERR_OLD_PASSWD ) ), 110 aRepeatPasswdErrStr ( SVX_RES( STR_ERR_REPEAT_PASSWD ) ), 111 bEmpty ( bAllowEmptyPasswords ) 112 { 113 FreeResource(); 114 115 aOKBtn.SetClickHdl( LINK( this, SvxPasswordDialog, ButtonHdl ) ); 116 aRepeatPasswdED.SetModifyHdl( LINK( this, SvxPasswordDialog, EditModifyHdl ) ); 117 EditModifyHdl( 0 ); 118 119 if ( bDisableOldPassword ) 120 { 121 aOldFL.Disable(); 122 aOldPasswdFT.Disable(); 123 aOldPasswdED.Disable(); 124 aNewPasswdED.GrabFocus(); 125 } 126 } 127 128 // ----------------------------------------------------------------------- 129 130 SvxPasswordDialog::~SvxPasswordDialog() 131 { 132 } 133 134 // ----------------------------------------------------------------------- 135 136 137