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  typedef std::shared_ptr<ScDocProtection> DocProtectionPtr;
44  typedef std::shared_ptr<ScTableProtection> TabProtectionPtr;
45 
46  explicit ScRetypePassDlg(weld::Window* pParent);
47  virtual ~ScRetypePassDlg() override;
48 
49  virtual short run() override;
50 
51  void SetDataFromDocument(const ScDocument& rDoc);
52  void SetDesiredHash(ScPasswordHash eHash);
53 
56  void WriteNewDataToDocument(ScDocument& rDoc) const;
57 
58 private:
59  void Init();
60  void PopulateDialog();
61  void SetDocData();
62  void SetTableData(size_t nRowPos, SCTAB nTab);
63 
66  void CheckHashStatus();
67 
68  void DeleteSheets();
69 
70 private:
73  OUString maTextHashBad;
74  OUString maTextHashGood;
75 
76  DECL_LINK(OKHdl, weld::Button&, void);
77  DECL_LINK(RetypeBtnHdl, weld::Button&, void);
78 
79  struct TableItem
80  {
81  OUString maName;
82  TabProtectionPtr mpProtect;
83  };
84  ::std::vector<TableItem> maTableItems;
85 
86  DocProtectionPtr mpDocItem;
88 
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;
95 };
96 
98 {
99 public:
100  ScRetypePassInputDlg() = delete;
101  explicit ScRetypePassInputDlg(weld::Window* pParent, ScPassHashProtectable* pProtected);
102  virtual ~ScRetypePassInputDlg() override;
103 
104  bool IsRemovePassword() const;
105  OUString GetNewPassword() const;
106 
107 private:
108  void Init();
109  void CheckPasswordInput();
110 
111 private:
113 
114  std::unique_ptr<weld::Button> m_xBtnOk;
115 
116  std::unique_ptr<weld::RadioButton> m_xBtnRetypePassword;
117 
118  std::unique_ptr<weld::Widget> m_xPasswordGrid;
119  std::unique_ptr<weld::Entry> m_xPassword1Edit;
120  std::unique_ptr<weld::Entry> m_xPassword2Edit;
121 
122  std::unique_ptr<weld::CheckButton> m_xBtnMatchOldPass;
123 
124  std::unique_ptr<weld::RadioButton> m_xBtnRemovePassword;
125 
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 );
130 };
131 
132 #endif
133 
134 /* 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
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
TabProtectionPtr mpProtect
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
void SetTableData(size_t nRowPos, SCTAB nTab)
std::unique_ptr< weld::RadioButton > m_xBtnRemovePassword
OUString maTextNotProtected
std::shared_ptr< ScDocProtection > DocProtectionPtr
std::unique_ptr< weld::Entry > m_xPassword1Edit
std::shared_ptr< ScTableProtection > TabProtectionPtr
DocProtectionPtr mpDocItem
DECL_LINK(OKHdl, weld::Button &, void)
sal_Int16 SCTAB
Definition: types.hxx:23
std::unique_ptr< weld::Label > mxTextDocStatus