remove assert looking for new compatibilityMode DOCX
[LibreOffice.git] / svx / source / dialog / passwd.cxx
blob46778d69d4cb74eb0476b951ab9451930117453e
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 <vcl/svapp.hxx>
21 #include <vcl/weld.hxx>
22 #include <svx/passwd.hxx>
23 #include <svx/dialmgr.hxx>
24 #include <svx/strings.hrc>
26 IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, weld::Button&, void)
28 bool bOK = true;
30 if (m_xNewPasswdED->get_text() != m_xRepeatPasswdED->get_text())
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(u""_ustr);
37 m_xRepeatPasswdED->set_text(u""_ustr);
38 m_xNewPasswdED->grab_focus();
39 bOK = false;
42 if (bOK && m_aCheckPasswordHdl.IsSet() && !m_aCheckPasswordHdl.Call(this))
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(u""_ustr);
49 m_xOldPasswdED->grab_focus();
50 bOK = false;
53 if (bOK)
54 m_xDialog->response(RET_OK);
57 IMPL_LINK_NOARG(SvxPasswordDialog, EditModifyHdl, weld::Entry&, void)
59 if (!m_xOKBtn->get_sensitive())
60 m_xOKBtn->set_sensitive(true);
63 SvxPasswordDialog::SvxPasswordDialog(weld::Window* pParent, bool bDisableOldPassword)
64 : SfxDialogController(pParent, u"svx/ui/passwd.ui"_ustr, u"PasswordDialog"_ustr)
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(u"oldpass"_ustr))
68 , m_xOldPasswdFT(m_xBuilder->weld_label(u"oldpassL"_ustr))
69 , m_xOldPasswdED(m_xBuilder->weld_entry(u"oldpassEntry"_ustr))
70 , m_xNewPasswdED(m_xBuilder->weld_entry(u"newpassEntry"_ustr))
71 , m_xRepeatPasswdED(m_xBuilder->weld_entry(u"confirmpassEntry"_ustr))
72 , m_xOKBtn(m_xBuilder->weld_button(u"ok"_ustr))
74 m_xOKBtn->connect_clicked(LINK(this, SvxPasswordDialog, ButtonHdl));
75 m_xRepeatPasswdED->connect_changed(LINK(this, SvxPasswordDialog, EditModifyHdl));
76 EditModifyHdl(*m_xRepeatPasswdED);
78 if (bDisableOldPassword)
80 m_xOldFL->set_sensitive(false);
81 m_xOldPasswdFT->set_sensitive(false);
82 m_xOldPasswdED->set_sensitive(false);
83 m_xNewPasswdED->grab_focus();
87 SvxPasswordDialog::~SvxPasswordDialog()
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */