Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / ui / inc / retypepassdlg.hxx
blob967d5bb839c0beb09b1292096a2f0bbe9fa51fcc
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 #ifndef INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX
23 #include <vcl/weld.hxx>
24 #include <tabprotection.hxx>
25 #include <memory>
27 class ScDocument;
29 struct PassFragment
31 std::unique_ptr<weld::Builder> m_xBuilder;
32 std::unique_ptr<weld::Container> m_xSheetsBox;
33 std::unique_ptr<weld::Label> m_xName;
34 std::unique_ptr<weld::Label> m_xStatus;
35 std::unique_ptr<weld::Button> m_xButton;
37 PassFragment(weld::Widget* pParent);
40 class ScRetypePassDlg : public weld::GenericDialogController
42 public:
43 typedef std::shared_ptr<ScDocProtection> DocProtectionPtr;
44 typedef std::shared_ptr<ScTableProtection> TabProtectionPtr;
46 explicit ScRetypePassDlg(weld::Window* pParent);
47 virtual ~ScRetypePassDlg() override;
49 virtual short run() override;
51 void SetDataFromDocument(const ScDocument& rDoc);
52 void SetDesiredHash(ScPasswordHash eHash);
54 /** Write the new set of password data to the document instance to
55 overwrite the current ones. */
56 void WriteNewDataToDocument(ScDocument& rDoc) const;
58 private:
59 void Init();
60 void PopulateDialog();
61 void SetDocData();
62 void SetTableData(size_t nRowPos, SCTAB nTab);
64 /** Check the status of all hash values to see if it's okay to enable
65 the OK button. */
66 void CheckHashStatus();
68 void DeleteSheets();
70 private:
71 OUString const maTextNotProtected;
72 OUString const maTextNotPassProtected;
73 OUString const maTextHashBad;
74 OUString const maTextHashGood;
76 DECL_LINK(OKHdl, weld::Button&, void);
77 DECL_LINK(RetypeBtnHdl, weld::Button&, void);
79 struct TableItem
81 OUString maName;
82 TabProtectionPtr mpProtect;
84 ::std::vector<TableItem> maTableItems;
86 DocProtectionPtr mpDocItem;
87 ScPasswordHash meDesiredHash;
89 std::unique_ptr<weld::Button> mxBtnOk;
90 std::unique_ptr<weld::Label> mxTextDocStatus;
91 std::unique_ptr<weld::Button> mxBtnRetypeDoc;
92 std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow;
93 std::unique_ptr<weld::Container> mxSheetsBox;
94 std::vector<std::unique_ptr<PassFragment>> maSheets;
97 class ScRetypePassInputDlg : public weld::GenericDialogController
99 public:
100 ScRetypePassInputDlg() = delete;
101 explicit ScRetypePassInputDlg(weld::Window* pParent, ScPassHashProtectable* pProtected);
102 virtual ~ScRetypePassInputDlg() override;
104 bool IsRemovePassword() const;
105 OUString GetNewPassword() const;
107 private:
108 void Init();
109 void CheckPasswordInput();
111 private:
112 ScPassHashProtectable* const m_pProtected;
114 std::unique_ptr<weld::Button> m_xBtnOk;
116 std::unique_ptr<weld::RadioButton> m_xBtnRetypePassword;
118 std::unique_ptr<weld::Widget> m_xPasswordGrid;
119 std::unique_ptr<weld::Entry> m_xPassword1Edit;
120 std::unique_ptr<weld::Entry> m_xPassword2Edit;
122 std::unique_ptr<weld::CheckButton> m_xBtnMatchOldPass;
124 std::unique_ptr<weld::RadioButton> m_xBtnRemovePassword;
126 DECL_LINK( OKHdl, weld::Button&, void );
127 DECL_LINK( RadioBtnHdl, weld::ToggleButton&, void );
128 DECL_LINK( CheckBoxHdl, weld::ToggleButton&, void );
129 DECL_LINK( PasswordModifyHdl, weld::Entry&, void );
132 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */