/src/libreoffice/include/sfx2/passwd.hxx
Line | Count | Source (jump to first uncovered line) |
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 | | #pragma once |
20 | | |
21 | | #include <sal/config.h> |
22 | | #include <sfx2/dllapi.h> |
23 | | #include <vcl/weld.hxx> |
24 | | #include <o3tl/typed_flags_set.hxx> |
25 | | |
26 | | // defines --------------------------------------------------------------- |
27 | | |
28 | | enum class SfxShowExtras |
29 | | { |
30 | | NONE = 0x0000, |
31 | | USER = 0x0001, |
32 | | CONFIRM = 0x0002, |
33 | | PASSWORD2 = 0x0004, |
34 | | CONFIRM2 = 0x0008, |
35 | | ALL = USER | CONFIRM |
36 | | }; |
37 | | namespace o3tl |
38 | | { |
39 | | template<> struct typed_flags<SfxShowExtras> : is_typed_flags<SfxShowExtras, 0x0f> {}; |
40 | | } |
41 | | |
42 | | // class SfxPasswordDialog ----------------------------------------------- |
43 | | |
44 | | class SFX2_DLLPUBLIC SfxPasswordDialog final : public weld::GenericDialogController |
45 | | { |
46 | | private: |
47 | | std::unique_ptr<weld::Frame> m_xPassword1Box; |
48 | | std::unique_ptr<weld::Label> m_xUserFT; |
49 | | std::unique_ptr<weld::Entry> m_xUserED; |
50 | | std::unique_ptr<weld::Label> m_xPassword1FT; |
51 | | std::unique_ptr<weld::Entry> m_xPassword1ED; |
52 | | std::unique_ptr<weld::LevelBar> m_xPassword1StrengthBar; |
53 | | std::unique_ptr<weld::Label> m_xPassword1PolicyLabel; |
54 | | std::unique_ptr<weld::Label> m_xConfirm1FT; |
55 | | std::unique_ptr<weld::Entry> m_xConfirm1ED; |
56 | | |
57 | | std::unique_ptr<weld::Frame> m_xPassword2Box; |
58 | | std::unique_ptr<weld::Label> m_xPassword2FT; |
59 | | std::unique_ptr<weld::Entry> m_xPassword2ED; |
60 | | std::unique_ptr<weld::LevelBar> m_xPassword2StrengthBar; |
61 | | std::unique_ptr<weld::Label> m_xPassword2PolicyLabel; |
62 | | std::unique_ptr<weld::Label> m_xConfirm2FT; |
63 | | std::unique_ptr<weld::Entry> m_xConfirm2ED; |
64 | | |
65 | | std::unique_ptr<weld::Label> m_xMinLengthFT; |
66 | | std::unique_ptr<weld::Label> m_xOnlyAsciiFT; |
67 | | |
68 | | std::unique_ptr<weld::Button> m_xOKBtn; |
69 | | |
70 | | std::array<std::unique_ptr<weld::ToggleButton>, 4> m_xPass; |
71 | | |
72 | | std::shared_ptr<weld::MessageDialog> m_xConfirmFailedDialog; |
73 | | |
74 | | OUString maMinLenPwdStr; |
75 | | OUString maMinLenPwdStr1; |
76 | | OUString maEmptyPwdStr; |
77 | | OUString maMainPwdStr; |
78 | | sal_uInt16 mnMinLen; |
79 | | SfxShowExtras mnExtras; |
80 | | std::optional<OUString> moPasswordPolicy; |
81 | | |
82 | | bool mbAsciiOnly; |
83 | | DECL_DLLPRIVATE_LINK(OKHdl, weld::Button&, void); |
84 | | DECL_DLLPRIVATE_LINK(ShowHdl, weld::Toggleable&, void); |
85 | | DECL_DLLPRIVATE_LINK(InsertTextHdl, OUString&, bool); |
86 | | DECL_DLLPRIVATE_LINK(EditModifyHdl, weld::Entry&, void); |
87 | | void ModifyHdl(); |
88 | | |
89 | | void SetPasswdText(); |
90 | | |
91 | | public: |
92 | | SfxPasswordDialog(weld::Widget* pParent, const OUString* pGroupText = nullptr); |
93 | | |
94 | | OUString GetUser() const |
95 | 0 | { |
96 | 0 | return m_xUserED->get_text(); |
97 | 0 | } |
98 | | OUString GetPassword() const |
99 | 0 | { |
100 | 0 | return m_xPassword1ED->get_text(); |
101 | 0 | } |
102 | | OUString GetConfirm() const |
103 | 0 | { |
104 | 0 | return m_xConfirm1ED->get_text(); |
105 | 0 | } |
106 | | OUString GetPassword2() const |
107 | 0 | { |
108 | 0 | return m_xPassword2ED->get_text(); |
109 | 0 | } |
110 | | void SetGroup2Text(const OUString& i_rText) |
111 | 0 | { |
112 | 0 | m_xPassword2Box->set_label(i_rText); |
113 | 0 | } |
114 | | void SetMinLen(sal_uInt16 Len); |
115 | | void SetEditHelpId(const OUString& rId) |
116 | 0 | { |
117 | 0 | m_xPassword1ED->set_help_id(rId); |
118 | 0 | } |
119 | | /* tdf#60874 we need a custom help ID for the Confirm |
120 | | field of the Protect Document window */ |
121 | | void SetConfirmHelpId(const OUString& rId) |
122 | 0 | { |
123 | 0 | m_xConfirm1ED->set_help_id(rId); |
124 | 0 | } |
125 | | |
126 | | void ShowExtras(SfxShowExtras nExtras) |
127 | 0 | { |
128 | 0 | mnExtras = nExtras; |
129 | 0 | } |
130 | | |
131 | | void AllowAsciiOnly(); |
132 | | void ShowMinLengthText(bool bShow); |
133 | | |
134 | | void PreRun(); |
135 | | |
136 | | virtual short run() override; |
137 | | |
138 | | ~SfxPasswordDialog(); |
139 | | }; |
140 | | |
141 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |