1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: passwd.cxx,v $
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>
40 #define _SVX_PASSWD_CXX
43 #include <svx/dialmgr.hxx>
44 #include <svx/dialogs.hrc>
47 // class SvxPasswordDialog -----------------------------------------------
49 IMPL_LINK( SvxPasswordDialog
, ButtonHdl
, OKButton
*, EMPTYARG
)
55 if ( aNewPasswdED
.GetText() != aRepeatPasswdED
.GetText() )
57 ErrorBox( this, WB_OK
, aRepeatPasswdErrStr
).Execute();
58 aNewPasswdED
.SetText( aEmpty
);
59 aRepeatPasswdED
.SetText( aEmpty
);
60 aNewPasswdED
.GrabFocus();
64 if ( bOK
&& aCheckPasswordHdl
.IsSet() && !aCheckPasswordHdl
.Call( this ) )
66 ErrorBox( this, WB_OK
, aOldPasswdErrStr
).Execute();
67 aOldPasswdED
.SetText( aEmpty
);
68 aOldPasswdED
.GrabFocus();
78 // -----------------------------------------------------------------------
80 IMPL_LINK( SvxPasswordDialog
, EditModifyHdl
, Edit
*, EMPTYARG
)
84 String aPasswd
= aRepeatPasswdED
.GetText();
85 aPasswd
.EraseLeadingChars().EraseTrailingChars();
87 if ( !aPasswd
.Len() && aOKBtn
.IsEnabled() )
89 else if ( aPasswd
.Len() && !aOKBtn
.IsEnabled() )
92 else if ( !aOKBtn
.IsEnabled() )
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
)
118 aOKBtn
.SetClickHdl( LINK( this, SvxPasswordDialog
, ButtonHdl
) );
119 aRepeatPasswdED
.SetModifyHdl( LINK( this, SvxPasswordDialog
, EditModifyHdl
) );
122 if ( bDisableOldPassword
)
125 aOldPasswdFT
.Disable();
126 aOldPasswdED
.Disable();
127 aNewPasswdED
.GrabFocus();
131 // -----------------------------------------------------------------------
133 SvxPasswordDialog::~SvxPasswordDialog()
137 // -----------------------------------------------------------------------