1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX
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>
32 #include "tabprotection.hxx"
36 namespace vcl
{ class Window
; }
37 class ScDocProtection
;
38 class ScTableProtection
;
41 class ScRetypePassDlg
: public ModalDialog
44 typedef std::shared_ptr
<ScDocProtection
> DocProtectionPtr
;
45 typedef std::shared_ptr
<ScTableProtection
> TabProtectionPtr
;
47 ScRetypePassDlg() = delete;
48 explicit ScRetypePassDlg(vcl::Window
* pParent
);
49 virtual ~ScRetypePassDlg();
50 virtual void dispose() override
;
52 virtual short Execute() override
;
54 void SetDataFromDocument(const ScDocument
& rDoc
);
55 void SetDesiredHash(ScPasswordHash eHash
);
57 /** Write the new set of password data to the document instance to
58 overwrite the current ones. */
59 void WriteNewDataToDocument(ScDocument
& rDoc
) const;
63 void PopulateDialog();
65 void SetTableData(size_t nRowPos
, SCTAB nTab
);
67 /** Check the status of all hash values to see if it's okay to enable
69 void CheckHashStatus();
74 VclPtr
<OKButton
> mpBtnOk
;
75 VclPtr
<FixedText
> mpTextDocStatus
;
76 VclPtr
<PushButton
> mpBtnRetypeDoc
;
77 VclPtr
<VclVBox
> mpSheetsBox
;
79 std::vector
<VclPtr
<VclHBox
>> maSheets
;
81 OUString maTextNotProtected
;
82 OUString maTextNotPassProtected
;
83 OUString maTextHashBad
;
84 OUString maTextHashGood
;
86 DECL_LINK_TYPED( OKHdl
, Button
*, void );
87 DECL_LINK_TYPED( RetypeBtnHdl
, Button
*, void );
92 TabProtectionPtr mpProtect
;
94 ::std::vector
<TableItem
> maTableItems
;
96 DocProtectionPtr mpDocItem
;
97 ScPasswordHash meDesiredHash
;
100 class ScRetypePassInputDlg
: public ModalDialog
103 ScRetypePassInputDlg() = delete;
104 explicit ScRetypePassInputDlg(vcl::Window
* pParent
, ScPassHashProtectable
* pProtected
);
105 virtual ~ScRetypePassInputDlg();
106 virtual void dispose() override
;
108 virtual short Execute() override
;
110 bool IsRemovePassword() const;
111 OUString
GetNewPassword() const;
115 void CheckPasswordInput();
118 VclPtr
<OKButton
> m_pBtnOk
;
120 VclPtr
<RadioButton
> m_pBtnRetypePassword
;
122 VclPtr
<VclContainer
> m_pPasswordGrid
;
123 VclPtr
<Edit
> m_pPassword1Edit
;
124 VclPtr
<Edit
> m_pPassword2Edit
;
126 VclPtr
<CheckBox
> m_pBtnMatchOldPass
;
128 VclPtr
<RadioButton
> m_pBtnRemovePassword
;
130 DECL_LINK_TYPED( OKHdl
, Button
*, void );
131 DECL_LINK_TYPED( RadioBtnHdl
, Button
*, void );
132 DECL_LINK_TYPED( CheckBoxHdl
, Button
*, void );
133 DECL_LINK_TYPED( PasswordModifyHdl
, Edit
&, void );
135 ScPassHashProtectable
* mpProtected
;
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */