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 .
22 #include <vcl/weld.hxx>
23 #include <tabprotection.hxx>
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
;
36 PassFragment(weld::Widget
* pParent
);
39 class ScRetypePassDlg
: public weld::GenericDialogController
42 explicit ScRetypePassDlg(weld::Window
* pParent
);
43 virtual ~ScRetypePassDlg() override
;
45 virtual short run() override
;
47 void SetDataFromDocument(const ScDocument
& rDoc
);
48 void SetDesiredHash(ScPasswordHash eHash
);
50 /** Write the new set of password data to the document instance to
51 overwrite the current ones. */
52 void WriteNewDataToDocument(ScDocument
& rDoc
) const;
56 void PopulateDialog();
58 void SetTableData(size_t nRowPos
, SCTAB nTab
);
60 /** Check the status of all hash values to see if it's okay to enable
62 void CheckHashStatus();
67 OUString maTextNotProtected
;
68 OUString maTextNotPassProtected
;
69 OUString maTextHashBad
;
70 OUString maTextHashGood
;
72 DECL_LINK(OKHdl
, weld::Button
&, void);
73 DECL_LINK(RetypeBtnHdl
, weld::Button
&, void);
78 std::shared_ptr
<ScTableProtection
> mpProtect
;
80 ::std::vector
<TableItem
> maTableItems
;
82 std::shared_ptr
<ScDocProtection
> mpDocItem
;
83 ScPasswordHash meDesiredHash
;
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
;
93 class ScRetypePassInputDlg
: public weld::GenericDialogController
96 ScRetypePassInputDlg() = delete;
97 explicit ScRetypePassInputDlg(weld::Window
* pParent
, ScPassHashProtectable
* pProtected
);
98 virtual ~ScRetypePassInputDlg() override
;
100 bool IsRemovePassword() const;
101 OUString
GetNewPassword() const;
105 void CheckPasswordInput();
108 ScPassHashProtectable
* m_pProtected
;
110 std::unique_ptr
<weld::Button
> m_xBtnOk
;
112 std::unique_ptr
<weld::RadioButton
> m_xBtnRetypePassword
;
114 std::unique_ptr
<weld::Widget
> m_xPasswordGrid
;
115 std::unique_ptr
<weld::Entry
> m_xPassword1Edit
;
116 std::unique_ptr
<weld::Entry
> m_xPassword2Edit
;
118 std::unique_ptr
<weld::CheckButton
> m_xBtnMatchOldPass
;
120 std::unique_ptr
<weld::RadioButton
> m_xBtnRemovePassword
;
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);
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */