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 <vcl/layout.hxx>
22 #include "svx/passwd.hxx"
23 #include <svx/dialmgr.hxx>
24 #include <svx/dialogs.hrc>
26 IMPL_LINK_NOARG(SvxPasswordDialog
, ButtonHdl
)
32 if ( m_pNewPasswdED
->GetText() != m_pRepeatPasswdED
->GetText() )
34 ScopedVclPtrInstance
<MessageDialog
>::Create(this, aRepeatPasswdErrStr
)->Execute();
35 m_pNewPasswdED
->SetText( aEmpty
);
36 m_pRepeatPasswdED
->SetText( aEmpty
);
37 m_pNewPasswdED
->GrabFocus();
41 if ( bOK
&& aCheckPasswordHdl
.IsSet() && !aCheckPasswordHdl
.Call( this ) )
43 ScopedVclPtrInstance
<MessageDialog
>::Create(this, aOldPasswdErrStr
)->Execute();
44 m_pOldPasswdED
->SetText( aEmpty
);
45 m_pOldPasswdED
->GrabFocus();
57 IMPL_LINK_NOARG(SvxPasswordDialog
, EditModifyHdl
)
61 OUString aPasswd
= comphelper::string::strip(m_pRepeatPasswdED
->GetText(), ' ');
62 if ( aPasswd
.isEmpty() && m_pOKBtn
->IsEnabled() )
64 else if ( !aPasswd
.isEmpty() && !m_pOKBtn
->IsEnabled() )
67 else if ( !m_pOKBtn
->IsEnabled() )
74 SvxPasswordDialog::SvxPasswordDialog(vcl::Window
* pParent
, bool bAllowEmptyPasswords
, bool bDisableOldPassword
)
75 : SfxModalDialog(pParent
, "PasswordDialog", "svx/ui/passwd.ui")
76 , aOldPasswdErrStr(SVX_RESSTR(RID_SVXSTR_ERR_OLD_PASSWD
))
77 , aRepeatPasswdErrStr(SVX_RESSTR(RID_SVXSTR_ERR_REPEAT_PASSWD
))
78 , bEmpty(bAllowEmptyPasswords
)
80 get(m_pOldFL
, "oldpass");
81 get(m_pOldPasswdFT
, "oldpassL");
82 get(m_pOldPasswdED
, "oldpassEntry");
83 get(m_pNewPasswdED
, "newpassEntry");
84 get(m_pRepeatPasswdED
, "confirmpassEntry");
87 m_pOKBtn
->SetClickHdl( LINK( this, SvxPasswordDialog
, ButtonHdl
) );
88 m_pRepeatPasswdED
->SetModifyHdl( LINK( this, SvxPasswordDialog
, EditModifyHdl
) );
91 if ( bDisableOldPassword
)
94 m_pOldPasswdFT
->Disable();
95 m_pOldPasswdED
->Disable();
96 m_pNewPasswdED
->GrabFocus();
100 SvxPasswordDialog::~SvxPasswordDialog()
105 void SvxPasswordDialog::dispose()
108 m_pOldPasswdFT
.clear();
109 m_pOldPasswdED
.clear();
110 m_pNewPasswdED
.clear();
111 m_pRepeatPasswdED
.clear();
113 SfxModalDialog::dispose();
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */