fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / svx / source / dialog / passwd.cxx
blob5139bafe8bb1dd7ac3aa806c39516e14e45ee94c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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)
28 bool bOK = true;
29 short nRet = RET_OK;
30 OUString aEmpty;
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();
38 bOK = false;
41 if ( bOK && aCheckPasswordHdl.IsSet() && !aCheckPasswordHdl.Call( this ) )
43 ScopedVclPtrInstance<MessageDialog>::Create(this, aOldPasswdErrStr)->Execute();
44 m_pOldPasswdED->SetText( aEmpty );
45 m_pOldPasswdED->GrabFocus();
46 bOK = false;
49 if ( bOK )
50 EndDialog( nRet );
52 return 0;
57 IMPL_LINK_NOARG(SvxPasswordDialog, EditModifyHdl)
59 if ( !bEmpty )
61 OUString aPasswd = comphelper::string::strip(m_pRepeatPasswdED->GetText(), ' ');
62 if ( aPasswd.isEmpty() && m_pOKBtn->IsEnabled() )
63 m_pOKBtn->Disable();
64 else if ( !aPasswd.isEmpty() && !m_pOKBtn->IsEnabled() )
65 m_pOKBtn->Enable();
67 else if ( !m_pOKBtn->IsEnabled() )
68 m_pOKBtn->Enable();
69 return 0;
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");
85 get(m_pOKBtn, "ok");
87 m_pOKBtn->SetClickHdl( LINK( this, SvxPasswordDialog, ButtonHdl ) );
88 m_pRepeatPasswdED->SetModifyHdl( LINK( this, SvxPasswordDialog, EditModifyHdl ) );
89 EditModifyHdl( 0 );
91 if ( bDisableOldPassword )
93 m_pOldFL->Disable();
94 m_pOldPasswdFT->Disable();
95 m_pOldPasswdED->Disable();
96 m_pNewPasswdED->GrabFocus();
100 SvxPasswordDialog::~SvxPasswordDialog()
102 disposeOnce();
105 void SvxPasswordDialog::dispose()
107 m_pOldFL.clear();
108 m_pOldPasswdFT.clear();
109 m_pOldPasswdED.clear();
110 m_pNewPasswdED.clear();
111 m_pRepeatPasswdED.clear();
112 m_pOKBtn.clear();
113 SfxModalDialog::dispose();
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */