1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <comphelper/string.hxx>
21 #include <tools/shl.hxx>
22 #include <vcl/msgbox.hxx>
23 #include "svx/passwd.hxx"
24 #include <svx/dialmgr.hxx>
25 #include <svx/dialogs.hrc>
27 // class SvxPasswordDialog -----------------------------------------------
29 IMPL_LINK_NOARG(SvxPasswordDialog
, ButtonHdl
)
35 if ( m_pNewPasswdED
->GetText() != m_pRepeatPasswdED
->GetText() )
37 ErrorBox( this, WB_OK
, aRepeatPasswdErrStr
).Execute();
38 m_pNewPasswdED
->SetText( aEmpty
);
39 m_pRepeatPasswdED
->SetText( aEmpty
);
40 m_pNewPasswdED
->GrabFocus();
44 if ( bOK
&& aCheckPasswordHdl
.IsSet() && !aCheckPasswordHdl
.Call( this ) )
46 ErrorBox( this, WB_OK
, aOldPasswdErrStr
).Execute();
47 m_pOldPasswdED
->SetText( aEmpty
);
48 m_pOldPasswdED
->GrabFocus();
60 IMPL_LINK_NOARG(SvxPasswordDialog
, EditModifyHdl
)
64 OUString aPasswd
= comphelper::string::strip(m_pRepeatPasswdED
->GetText(), ' ');
65 if ( aPasswd
.isEmpty() && m_pOKBtn
->IsEnabled() )
67 else if ( !aPasswd
.isEmpty() && !m_pOKBtn
->IsEnabled() )
70 else if ( !m_pOKBtn
->IsEnabled() )
77 SvxPasswordDialog::SvxPasswordDialog(Window
* pParent
, bool bAllowEmptyPasswords
, bool bDisableOldPassword
)
78 : SfxModalDialog(pParent
, "PasswordDialog", "svx/ui/passwd.ui")
79 , aOldPasswdErrStr(SVX_RESSTR(RID_SVXSTR_ERR_OLD_PASSWD
))
80 , aRepeatPasswdErrStr(SVX_RESSTR(RID_SVXSTR_ERR_REPEAT_PASSWD
))
81 , bEmpty(bAllowEmptyPasswords
)
83 get(m_pOldFL
, "oldpass");
84 get(m_pOldPasswdFT
, "oldpassL");
85 get(m_pOldPasswdED
, "oldpassEntry");
86 get(m_pNewPasswdED
, "newpassEntry");
87 get(m_pRepeatPasswdED
, "confirmpassEntry");
90 m_pOKBtn
->SetClickHdl( LINK( this, SvxPasswordDialog
, ButtonHdl
) );
91 m_pRepeatPasswdED
->SetModifyHdl( LINK( this, SvxPasswordDialog
, EditModifyHdl
) );
94 if ( bDisableOldPassword
)
97 m_pOldPasswdFT
->Disable();
98 m_pOldPasswdED
->Disable();
99 m_pNewPasswdED
->GrabFocus();
105 SvxPasswordDialog::~SvxPasswordDialog()
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */