Line data Source code
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/button.hxx>
24 : #include <vcl/dialog.hxx>
25 : #include <vcl/edit.hxx>
26 : #include <vcl/fixed.hxx>
27 : #include <vcl/layout.hxx>
28 : #include <vcl/scrbar.hxx>
29 : #include <svx/checklbx.hxx>
30 : #include <svtools/stdctrl.hxx>
31 :
32 : #include "tabprotection.hxx"
33 :
34 : #include <boost/shared_ptr.hpp>
35 :
36 : namespace vcl { class Window; }
37 : class ScDocProtection;
38 : class ScTableProtection;
39 : class ScDocument;
40 :
41 : class ScRetypePassDlg : public ModalDialog
42 : {
43 : public:
44 : typedef ::boost::shared_ptr<ScDocProtection> DocProtectionPtr;
45 : typedef ::boost::shared_ptr<ScTableProtection> TabProtectionPtr;
46 :
47 : explicit ScRetypePassDlg(vcl::Window* pParent);
48 : virtual ~ScRetypePassDlg();
49 : virtual void dispose() SAL_OVERRIDE;
50 :
51 : virtual short Execute() SAL_OVERRIDE;
52 :
53 : void SetDataFromDocument(const ScDocument& rDoc);
54 : void SetDesiredHash(ScPasswordHash eHash);
55 :
56 : /** Write the new set of password data to the document instance to
57 : overwrite the current ones. */
58 : void WriteNewDataToDocument(ScDocument& rDoc) const;
59 :
60 : private:
61 : ScRetypePassDlg(); // disabled
62 :
63 : void Init();
64 : void PopulateDialog();
65 : void SetDocData();
66 : void SetTableData(size_t nRowPos, SCTAB nTab);
67 :
68 : /** Check the status of all hash values to see if it's okay to enable
69 : the OK button. */
70 : void CheckHashStatus();
71 :
72 : void DeleteSheets();
73 :
74 : private:
75 : VclPtr<OKButton> mpBtnOk;
76 : VclPtr<FixedText> mpTextDocStatus;
77 : VclPtr<PushButton> mpBtnRetypeDoc;
78 : VclPtr<VclVBox> mpSheetsBox;
79 :
80 : std::vector<VclPtr<VclHBox>> maSheets;
81 :
82 : OUString maTextNotProtected;
83 : OUString maTextNotPassProtected;
84 : OUString maTextHashBad;
85 : OUString maTextHashGood;
86 : OUString maTextHashRegen;
87 :
88 : DECL_LINK( OKHdl, void* );
89 : DECL_LINK( RetypeBtnHdl, PushButton* );
90 :
91 0 : struct TableItem
92 : {
93 : OUString maName;
94 : TabProtectionPtr mpProtect;
95 : };
96 : ::std::vector<TableItem> maTableItems;
97 :
98 : DocProtectionPtr mpDocItem;
99 : size_t mnCurScrollPos;
100 : ScPasswordHash meDesiredHash;
101 : };
102 :
103 : class ScRetypePassInputDlg : public ModalDialog
104 : {
105 : public:
106 : explicit ScRetypePassInputDlg(vcl::Window* pParent, ScPassHashProtectable* pProtected);
107 : virtual ~ScRetypePassInputDlg();
108 : virtual void dispose() SAL_OVERRIDE;
109 :
110 : virtual short Execute() SAL_OVERRIDE;
111 :
112 : bool IsRemovePassword() const;
113 : OUString GetNewPassword() const;
114 :
115 : private:
116 : ScRetypePassInputDlg(); // disabled
117 :
118 : void Init();
119 : void CheckPasswordInput();
120 :
121 : private:
122 : VclPtr<OKButton> m_pBtnOk;
123 :
124 : VclPtr<RadioButton> m_pBtnRetypePassword;
125 :
126 : VclPtr<VclContainer> m_pPasswordGrid;
127 : VclPtr<Edit> m_pPassword1Edit;
128 : VclPtr<Edit> m_pPassword2Edit;
129 :
130 : VclPtr<CheckBox> m_pBtnMatchOldPass;
131 :
132 : VclPtr<RadioButton> m_pBtnRemovePassword;
133 :
134 : DECL_LINK( OKHdl, void* );
135 : DECL_LINK( RadioBtnHdl, RadioButton* );
136 : DECL_LINK( CheckBoxHdl, void* );
137 : DECL_LINK( PasswordModifyHdl, void* );
138 :
139 : ScPassHashProtectable* mpProtected;
140 : };
141 :
142 : #endif
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|