LibreOffice Module sc (master)  1
retypepassdlg.hxx
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 #ifndef INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX
22 
23 #include <vcl/weld.hxx>
24 #include <tabprotection.hxx>
25 #include <memory>
26 
27 class ScDocument;
28 
30 {
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;
36 
37  PassFragment(weld::Widget* pParent);
38 };
39 
41 {
42 public:
43  explicit ScRetypePassDlg(weld::Window* pParent);
44  virtual ~ScRetypePassDlg() override;
45 
46  virtual short run() override;
47 
48  void SetDataFromDocument(const ScDocument& rDoc);
49  void SetDesiredHash(ScPasswordHash eHash);
50 
53  void WriteNewDataToDocument(ScDocument& rDoc) const;
54 
55 private:
56  void Init();
57  void PopulateDialog();
58  void SetDocData();
59  void SetTableData(size_t nRowPos, SCTAB nTab);
60 
63  void CheckHashStatus();
64 
65  void DeleteSheets();
66 
67 private:
70  OUString maTextHashBad;
71  OUString maTextHashGood;
72 
73  DECL_LINK(OKHdl, weld::Button&, void);
74  DECL_LINK(RetypeBtnHdl, weld::Button&, void);
75 
76  struct TableItem
77  {
78  OUString maName;
79  std::shared_ptr<ScTableProtection> mpProtect;
80  };
81  ::std::vector<TableItem> maTableItems;
82 
83  std::shared_ptr<ScDocProtection> mpDocItem;
85 
86  std::unique_ptr<weld::Button> mxBtnOk;
87  std::unique_ptr<weld::Label> mxTextDocStatus;
88  std::unique_ptr<weld::Button> mxBtnRetypeDoc;
89  std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow;
90  std::unique_ptr<weld::Container> mxSheetsBox;
91  std::vector<std::unique_ptr<PassFragment>> maSheets;
92 };
93 
95 {
96 public:
97  ScRetypePassInputDlg() = delete;
98  explicit ScRetypePassInputDlg(weld::Window* pParent, ScPassHashProtectable* pProtected);
99  virtual ~ScRetypePassInputDlg() override;
100 
101  bool IsRemovePassword() const;
102  OUString GetNewPassword() const;
103 
104 private:
105  void Init();
106  void CheckPasswordInput();
107 
108 private:
110 
111  std::unique_ptr<weld::Button> m_xBtnOk;
112 
113  std::unique_ptr<weld::RadioButton> m_xBtnRetypePassword;
114 
115  std::unique_ptr<weld::Widget> m_xPasswordGrid;
116  std::unique_ptr<weld::Entry> m_xPassword1Edit;
117  std::unique_ptr<weld::Entry> m_xPassword2Edit;
118 
119  std::unique_ptr<weld::CheckButton> m_xBtnMatchOldPass;
120 
121  std::unique_ptr<weld::RadioButton> m_xBtnRemovePassword;
122 
123  DECL_LINK(OKHdl, weld::Button&, void);
124  DECL_LINK(RadioBtnHdl, weld::ToggleButton&, void);
125  DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void);
126  DECL_LINK(PasswordModifyHdl, weld::Entry&, void);
127 };
128 
129 #endif
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Label > m_xName
PassFragment(weld::Widget *pParent)
std::vector< std::unique_ptr< PassFragment > > maSheets
std::unique_ptr< weld::Container > mxSheetsBox
std::unique_ptr< weld::Container > m_xSheetsBox
virtual ~ScRetypePassInputDlg() override
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
std::unique_ptr< weld::Button > m_xButton
bool IsRemovePassword() const
std::unique_ptr< weld::Button > m_xBtnOk
ScRetypePassInputDlg()=delete
std::unique_ptr< weld::Entry > m_xPassword2Edit
std::unique_ptr< weld::Widget > m_xPasswordGrid
DECL_LINK(OKHdl, weld::Button &, void)
std::unique_ptr< weld::Button > mxBtnRetypeDoc
std::unique_ptr< weld::Button > mxBtnOk
virtual ~ScRetypePassDlg() override
void SetDataFromDocument(const ScDocument &rDoc)
virtual short run() override
std::shared_ptr< ScDocProtection > mpDocItem
void SetDesiredHash(ScPasswordHash eHash)
std::unique_ptr< weld::RadioButton > m_xBtnRetypePassword
ScPasswordHash
OUString GetNewPassword() const
OUString maTextHashGood
void WriteNewDataToDocument(ScDocument &rDoc) const
Write the new set of password data to the document instance to overwrite the current ones...
::std::vector< TableItem > maTableItems
ScPasswordHash meDesiredHash
OUString maTextHashBad
ScPassHashProtectable * m_pProtected
OUString maTextNotPassProtected
ScRetypePassDlg(weld::Window *pParent)
void CheckHashStatus()
Check the status of all hash values to see if it's okay to enable the OK button.
std::unique_ptr< weld::CheckButton > m_xBtnMatchOldPass
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::Label > m_xStatus
std::shared_ptr< ScTableProtection > mpProtect
void SetTableData(size_t nRowPos, SCTAB nTab)
std::unique_ptr< weld::RadioButton > m_xBtnRemovePassword
OUString maTextNotProtected
std::unique_ptr< weld::Entry > m_xPassword1Edit
DECL_LINK(OKHdl, weld::Button &, void)
sal_Int16 SCTAB
Definition: types.hxx:23
std::unique_ptr< weld::Label > mxTextDocStatus