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 #pragma once
21 
22 #include <vcl/weld.hxx>
23 #include <tabprotection.hxx>
24 #include <memory>
25 
26 class ScDocument;
27 
29 {
30  std::unique_ptr<weld::Builder> m_xBuilder;
31  std::unique_ptr<weld::Container> m_xSheetsBox;
32  std::unique_ptr<weld::Label> m_xName;
33  std::unique_ptr<weld::Label> m_xStatus;
34  std::unique_ptr<weld::Button> m_xButton;
35 
36  PassFragment(weld::Widget* pParent);
37 };
38 
40 {
41 public:
42  explicit ScRetypePassDlg(weld::Window* pParent);
43  virtual ~ScRetypePassDlg() override;
44 
45  virtual short run() override;
46 
47  void SetDataFromDocument(const ScDocument& rDoc);
48  void SetDesiredHash(ScPasswordHash eHash);
49 
52  void WriteNewDataToDocument(ScDocument& rDoc) const;
53 
54 private:
55  void Init();
56  void PopulateDialog();
57  void SetDocData();
58  void SetTableData(size_t nRowPos, SCTAB nTab);
59 
62  void CheckHashStatus();
63 
64  void DeleteSheets();
65 
66 private:
69  OUString maTextHashBad;
70  OUString maTextHashGood;
71 
72  DECL_LINK(OKHdl, weld::Button&, void);
73  DECL_LINK(RetypeBtnHdl, weld::Button&, void);
74 
75  struct TableItem
76  {
77  OUString maName;
78  std::shared_ptr<ScTableProtection> mpProtect;
79  };
80  ::std::vector<TableItem> maTableItems;
81 
82  std::shared_ptr<ScDocProtection> mpDocItem;
84 
85  std::unique_ptr<weld::Button> mxBtnOk;
86  std::unique_ptr<weld::Label> mxTextDocStatus;
87  std::unique_ptr<weld::Button> mxBtnRetypeDoc;
88  std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow;
89  std::unique_ptr<weld::Container> mxSheetsBox;
90  std::vector<std::unique_ptr<PassFragment>> maSheets;
91 };
92 
94 {
95 public:
96  ScRetypePassInputDlg() = delete;
97  explicit ScRetypePassInputDlg(weld::Window* pParent, ScPassHashProtectable* pProtected);
98  virtual ~ScRetypePassInputDlg() override;
99 
100  bool IsRemovePassword() const;
101  OUString GetNewPassword() const;
102 
103 private:
104  void Init();
105  void CheckPasswordInput();
106 
107 private:
109 
110  std::unique_ptr<weld::Button> m_xBtnOk;
111 
112  std::unique_ptr<weld::RadioButton> m_xBtnRetypePassword;
113 
114  std::unique_ptr<weld::Widget> m_xPasswordGrid;
115  std::unique_ptr<weld::Entry> m_xPassword1Edit;
116  std::unique_ptr<weld::Entry> m_xPassword2Edit;
117 
118  std::unique_ptr<weld::CheckButton> m_xBtnMatchOldPass;
119 
120  std::unique_ptr<weld::RadioButton> m_xBtnRemovePassword;
121 
122  DECL_LINK(OKHdl, weld::Button&, void);
123  DECL_LINK(RadioBtnHdl, weld::Toggleable&, void);
124  DECL_LINK(CheckBoxHdl, weld::Toggleable&, void);
125  DECL_LINK(PasswordModifyHdl, weld::Entry&, void);
126 };
127 
128 /* 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:22
std::unique_ptr< weld::Label > mxTextDocStatus