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