LibreOffice Module svx (master) 1
passwd.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <vcl/svapp.hxx>
21#include <vcl/weld.hxx>
22#include <svx/passwd.hxx>
23#include <svx/dialmgr.hxx>
24#include <svx/strings.hrc>
25
26IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, weld::Button&, void)
27{
28 bool bOK = true;
29
30 if (m_xNewPasswdED->get_text() != m_xRepeatPasswdED->get_text())
31 {
32 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
33 VclMessageType::Warning, VclButtonsType::Ok,
34 m_aRepeatPasswdErrStr));
35 xBox->run();
36 m_xNewPasswdED->set_text("");
37 m_xRepeatPasswdED->set_text("");
38 m_xNewPasswdED->grab_focus();
39 bOK = false;
40 }
41
42 if (bOK && m_aCheckPasswordHdl.IsSet() && !m_aCheckPasswordHdl.Call(this))
43 {
44 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
45 VclMessageType::Warning, VclButtonsType::Ok,
46 m_aOldPasswdErrStr));
47 xBox->run();
48 m_xOldPasswdED->set_text("");
49 m_xOldPasswdED->grab_focus();
50 bOK = false;
51 }
52
53 if (bOK)
54 m_xDialog->response(RET_OK);
55}
56
57IMPL_LINK_NOARG(SvxPasswordDialog, EditModifyHdl, weld::Entry&, void)
58{
59 if (!m_xOKBtn->get_sensitive())
60 m_xOKBtn->set_sensitive(true);
61}
62
63SvxPasswordDialog::SvxPasswordDialog(weld::Window* pParent, bool bDisableOldPassword)
64 : SfxDialogController(pParent, "svx/ui/passwd.ui", "PasswordDialog")
65 , m_aOldPasswdErrStr(SvxResId(RID_SVXSTR_ERR_OLD_PASSWD))
66 , m_aRepeatPasswdErrStr(SvxResId(RID_SVXSTR_ERR_REPEAT_PASSWD ))
67 , m_xOldFL(m_xBuilder->weld_label("oldpass"))
68 , m_xOldPasswdFT(m_xBuilder->weld_label("oldpassL"))
69 , m_xOldPasswdED(m_xBuilder->weld_entry("oldpassEntry"))
70 , m_xNewPasswdED(m_xBuilder->weld_entry("newpassEntry"))
71 , m_xRepeatPasswdED(m_xBuilder->weld_entry("confirmpassEntry"))
72 , m_xOKBtn(m_xBuilder->weld_button("ok"))
73{
74 m_xOKBtn->connect_clicked(LINK(this, SvxPasswordDialog, ButtonHdl));
75 m_xRepeatPasswdED->connect_changed(LINK(this, SvxPasswordDialog, EditModifyHdl));
76 EditModifyHdl(*m_xRepeatPasswdED);
77
78 if (bDisableOldPassword)
79 {
80 m_xOldFL->set_sensitive(false);
81 m_xOldPasswdFT->set_sensitive(false);
82 m_xOldPasswdED->set_sensitive(false);
83 m_xNewPasswdED->grab_focus();
84 }
85}
86
87SvxPasswordDialog::~SvxPasswordDialog()
88{
89}
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, weld::Button &, void)
Definition: passwd.cxx:26
RET_OK