merge the formfield patch from ooo-build
[ooovba.git] / svx / source / dialog / passwd.cxx
blob7c101440485577835b843b8c1ef94cb99b76ab71
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: passwd.cxx,v $
10 * $Revision: 1.9 $
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_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/shl.hxx>
36 #ifndef _MSGBOX_HXX //autogen
37 #include <vcl/msgbox.hxx>
38 #endif
40 #define _SVX_PASSWD_CXX
42 #include "passwd.hxx"
43 #include <svx/dialmgr.hxx>
44 #include <svx/dialogs.hrc>
45 #include "passwd.hrc"
47 // class SvxPasswordDialog -----------------------------------------------
49 IMPL_LINK( SvxPasswordDialog, ButtonHdl, OKButton *, EMPTYARG )
51 BOOL bOK = TRUE;
52 short nRet = RET_OK;
53 String aEmpty;
55 if ( aNewPasswdED.GetText() != aRepeatPasswdED.GetText() )
57 ErrorBox( this, WB_OK, aRepeatPasswdErrStr ).Execute();
58 aNewPasswdED.SetText( aEmpty );
59 aRepeatPasswdED.SetText( aEmpty );
60 aNewPasswdED.GrabFocus();
61 bOK = FALSE;
64 if ( bOK && aCheckPasswordHdl.IsSet() && !aCheckPasswordHdl.Call( this ) )
66 ErrorBox( this, WB_OK, aOldPasswdErrStr ).Execute();
67 aOldPasswdED.SetText( aEmpty );
68 aOldPasswdED.GrabFocus();
69 bOK = FALSE;
72 if ( bOK )
73 EndDialog( nRet );
75 return 0;
78 // -----------------------------------------------------------------------
80 IMPL_LINK( SvxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG )
82 if ( !bEmpty )
84 String aPasswd = aRepeatPasswdED.GetText();
85 aPasswd.EraseLeadingChars().EraseTrailingChars();
87 if ( !aPasswd.Len() && aOKBtn.IsEnabled() )
88 aOKBtn.Disable();
89 else if ( aPasswd.Len() && !aOKBtn.IsEnabled() )
90 aOKBtn.Enable();
92 else if ( !aOKBtn.IsEnabled() )
93 aOKBtn.Enable();
94 return 0;
97 // -----------------------------------------------------------------------
99 SvxPasswordDialog::SvxPasswordDialog( Window* pParent, BOOL bAllowEmptyPasswords, BOOL bDisableOldPassword ) :
100 SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_PASSWORD ) ),
101 aOldFL ( this, SVX_RES( FL_OLD_PASSWD ) ),
102 aOldPasswdFT ( this, SVX_RES( FT_OLD_PASSWD ) ),
103 aOldPasswdED ( this, SVX_RES( ED_OLD_PASSWD ) ),
104 aNewFL ( this, SVX_RES( FL_NEW_PASSWD ) ),
105 aNewPasswdFT ( this, SVX_RES( FT_NEW_PASSWD ) ),
106 aNewPasswdED ( this, SVX_RES( ED_NEW_PASSWD ) ),
107 aRepeatPasswdFT ( this, SVX_RES( FT_REPEAT_PASSWD ) ),
108 aRepeatPasswdED ( this, SVX_RES( ED_REPEAT_PASSWD ) ),
109 aOKBtn ( this, SVX_RES( BTN_PASSWD_OK ) ),
110 aEscBtn ( this, SVX_RES( BTN_PASSWD_ESC ) ),
111 aHelpBtn ( this, SVX_RES( BTN_PASSWD_HELP ) ),
112 aOldPasswdErrStr ( SVX_RES( STR_ERR_OLD_PASSWD ) ),
113 aRepeatPasswdErrStr ( SVX_RES( STR_ERR_REPEAT_PASSWD ) ),
114 bEmpty ( bAllowEmptyPasswords )
116 FreeResource();
118 aOKBtn.SetClickHdl( LINK( this, SvxPasswordDialog, ButtonHdl ) );
119 aRepeatPasswdED.SetModifyHdl( LINK( this, SvxPasswordDialog, EditModifyHdl ) );
120 EditModifyHdl( 0 );
122 if ( bDisableOldPassword )
124 aOldFL.Disable();
125 aOldPasswdFT.Disable();
126 aOldPasswdED.Disable();
127 aNewPasswdED.GrabFocus();
131 // -----------------------------------------------------------------------
133 SvxPasswordDialog::~SvxPasswordDialog()
137 // -----------------------------------------------------------------------