xref: /aoo4110/main/sc/source/ui/inc/retypepassdlg.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_UI_RETYPEPASS_DLG_HXX
25 #define SC_UI_RETYPEPASS_DLG_HXX
26 
27 #include <vcl/dialog.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/edit.hxx>
31 #include <vcl/scrbar.hxx>
32 #include <svx/checklbx.hxx>
33 #include <svtools/stdctrl.hxx>
34 
35 #include "tabprotection.hxx"
36 
37 #include <boost/shared_ptr.hpp>
38 
39 class Window;
40 class ScDocProtection;
41 class ScTableProtection;
42 class ScDocument;
43 
44 class ScRetypePassDlg : public ModalDialog
45 {
46 public:
47     typedef ::boost::shared_ptr<ScDocProtection>    DocProtectionPtr;
48     typedef ::boost::shared_ptr<ScTableProtection>  TabProtectionPtr;
49 
50     explicit ScRetypePassDlg(Window* pParent);
51     virtual ~ScRetypePassDlg();
52 
53     virtual short Execute();
54 
55     void SetDataFromDocument(const ScDocument& rDoc);
56     void SetDesiredHash(ScPasswordHash eHash);
57 
58     /** Write the new set of password data to the document instance to
59         overwrite the current ones. */
60     void WriteNewDataToDocument(ScDocument& rDoc) const;
61 
62 private:
63     ScRetypePassDlg(); // disabled
64 
65     void Init();
66     void PopulateDialog();
67     void SetDocData();
68     void SetTableData(size_t nRowPos, SCTAB nTab);
69     void ResetTableRows();
70 
71     /** Check the status of all hash values to see if it's okay to enable
72         the OK button. */
73     void CheckHashStatus();
74 
75 private:
76     OKButton        maBtnOk;
77     CancelButton    maBtnCancel;
78     HelpButton      maBtnHelp;
79 
80     FixedInfo       maTextDescription;
81 
82     FixedLine       maLineDocument;
83     FixedText       maTextDocStatus;
84     PushButton      maBtnRetypeDoc;
85 
86     FixedLine       maLineSheet;
87     FixedText       maTextSheetName1;
88     FixedText       maTextSheetStatus1;
89     PushButton      maBtnRetypeSheet1;
90 
91     FixedText       maTextSheetName2;
92     FixedText       maTextSheetStatus2;
93     PushButton      maBtnRetypeSheet2;
94 
95     FixedText       maTextSheetName3;
96     FixedText       maTextSheetStatus3;
97     PushButton      maBtnRetypeSheet3;
98 
99     FixedText       maTextSheetName4;
100     FixedText       maTextSheetStatus4;
101     PushButton      maBtnRetypeSheet4;
102 
103     ScrollBar       maScrollBar;
104 
105     String          maTextNotProtected;
106     String          maTextNotPassProtected;
107     String          maTextHashBad;
108     String          maTextHashGood;
109     String          maTextHashRegen;
110 
111     DECL_LINK( OKHdl, OKButton* );
112     DECL_LINK( RetypeBtnHdl, PushButton* );
113     DECL_LINK( ScrollHdl, ScrollBar* );
114 
115     struct TableItem
116     {
117         String              maName;
118         TabProtectionPtr    mpProtect;
119     };
120     ::std::vector<TableItem> maTableItems;
121 
122     DocProtectionPtr    mpDocItem;
123     size_t              mnCurScrollPos;
124     ScPasswordHash      meDesiredHash;
125 };
126 
127 // ============================================================================
128 
129 class ScRetypePassInputDlg : public ModalDialog
130 {
131 public:
132     explicit ScRetypePassInputDlg(Window* pParent, ScPassHashProtectable* pProtected);
133     virtual ~ScRetypePassInputDlg();
134 
135     virtual short Execute();
136 
137     bool IsRemovePassword() const;
138     String GetNewPassword() const;
139 
140 private:
141     ScRetypePassInputDlg(); // disabled
142 
143     void Init();
144     void CheckPasswordInput();
145 
146 private:
147     OKButton        maBtnOk;
148     CancelButton    maBtnCancel;
149     HelpButton      maBtnHelp;
150 
151     RadioButton     maBtnRetypePassword;
152 
153     FixedText       maPassword1Text;
154     Edit            maPassword1Edit;
155     FixedText       maPassword2Text;
156     Edit            maPassword2Edit;
157 
158     CheckBox        maBtnMatchOldPass;
159 
160     RadioButton     maBtnRemovePassword;
161 
162     DECL_LINK( OKHdl, OKButton* );
163     DECL_LINK( RadioBtnHdl, RadioButton* );
164     DECL_LINK( CheckBoxHdl, CheckBox* );
165     DECL_LINK( PasswordModifyHdl, Edit* );
166 
167     ScPassHashProtectable* mpProtected;
168 };
169 
170 #endif
171