Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / sfx2 / passwd.hxx
blob98c70787ca0eb156e6f64d858de34af92c6f08a2
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 .
19 #ifndef INCLUDED_SFX2_PASSWD_HXX
20 #define INCLUDED_SFX2_PASSWD_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <vcl/weld.hxx>
25 #include <o3tl/typed_flags_set.hxx>
27 // defines ---------------------------------------------------------------
29 enum class SfxShowExtras
31 NONE = 0x0000,
32 USER = 0x0001,
33 CONFIRM = 0x0002,
34 PASSWORD2 = 0x0004,
35 CONFIRM2 = 0x0008,
36 ALL = USER | CONFIRM
38 namespace o3tl
40 template<> struct typed_flags<SfxShowExtras> : is_typed_flags<SfxShowExtras, 0x0f> {};
43 // class SfxPasswordDialog -----------------------------------------------
45 class SFX2_DLLPUBLIC SfxPasswordDialog final : public weld::GenericDialogController
47 private:
48 std::unique_ptr<weld::Frame> m_xPassword1Box;
49 std::unique_ptr<weld::Label> m_xUserFT;
50 std::unique_ptr<weld::Entry> m_xUserED;
51 std::unique_ptr<weld::Label> m_xPassword1FT;
52 std::unique_ptr<weld::Entry> m_xPassword1ED;
53 std::unique_ptr<weld::Label> m_xConfirm1FT;
54 std::unique_ptr<weld::Entry> m_xConfirm1ED;
56 std::unique_ptr<weld::Frame> m_xPassword2Box;
57 std::unique_ptr<weld::Label> m_xPassword2FT;
58 std::unique_ptr<weld::Entry> m_xPassword2ED;
59 std::unique_ptr<weld::Label> m_xConfirm2FT;
60 std::unique_ptr<weld::Entry> m_xConfirm2ED;
62 std::unique_ptr<weld::Label> m_xMinLengthFT;
63 std::unique_ptr<weld::Label> m_xOnlyAsciiFT;
65 std::unique_ptr<weld::Button> m_xOKBtn;
67 std::shared_ptr<weld::MessageDialog> m_xConfirmFailedDialog;
69 OUString maMinLenPwdStr;
70 OUString maMinLenPwdStr1;
71 OUString maEmptyPwdStr;
72 OUString maMainPwdStr;
73 sal_uInt16 mnMinLen;
74 SfxShowExtras mnExtras;
76 bool mbAsciiOnly;
77 DECL_DLLPRIVATE_LINK(OKHdl, weld::Button&, void);
78 DECL_DLLPRIVATE_LINK(InsertTextHdl, OUString&, bool);
79 DECL_DLLPRIVATE_LINK(EditModifyHdl, weld::Entry&, void);
80 void ModifyHdl();
82 void SetPasswdText();
84 public:
85 SfxPasswordDialog(weld::Widget* pParent, const OUString* pGroupText = nullptr);
87 OUString GetUser() const
89 return m_xUserED->get_text();
91 OUString GetPassword() const
93 return m_xPassword1ED->get_text();
95 OUString GetConfirm() const
97 return m_xConfirm1ED->get_text();
99 OUString GetPassword2() const
101 return m_xPassword2ED->get_text();
103 void SetGroup2Text(const OUString& i_rText)
105 m_xPassword2Box->set_label(i_rText);
107 void SetMinLen(sal_uInt16 Len);
108 void SetEditHelpId(const OUString& rId)
110 m_xPassword1ED->set_help_id(rId);
112 /* tdf#60874 we need a custom help ID for the Confirm
113 field of the Protect Document window */
114 void SetConfirmHelpId(const OUString& rId)
116 m_xConfirm1ED->set_help_id(rId);
119 void ShowExtras(SfxShowExtras nExtras)
121 mnExtras = nExtras;
124 void AllowAsciiOnly();
125 void ShowMinLengthText(bool bShow);
127 void PreRun();
129 virtual short run() override;
131 ~SfxPasswordDialog();
134 #endif // INCLUDED_SFX2_PASSWD_HXX
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */