LibreOffice Module sfx2 (master) 1
autoredactdialog.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10#ifndef INCLUDED_SFX2_INC_AUTOREDACTDIALOG_HXX
11#define INCLUDED_SFX2_INC_AUTOREDACTDIALOG_HXX
12
13#include <memory>
14#include <sal/config.h>
15#include <sfx2/basedlgs.hxx>
16#include <sfx2/objsh.hxx>
17
18namespace weld
19{
20class Button;
21}
22namespace weld
23{
24class ComboBox;
25}
26namespace weld
27{
28class Label;
29}
30namespace weld
31{
32class Window;
33}
34namespace weld
35{
36class TreeView;
37}
38
40{
45};
46
49{
50 OUString sName;
52 OUString sContent;
55 sal_uInt32 nID;
56};
57
60{
61 std::unique_ptr<weld::TreeView> m_xControl;
62 int GetRowByTargetName(std::u16string_view sName);
63
64public:
65 TargetsTable(std::unique_ptr<weld::TreeView> xControl);
66 void InsertTarget(RedactionTarget* pTarget);
67 RedactionTarget* GetTargetByName(std::u16string_view sName);
68 OUString GetNameProposal() const;
69
70 int get_selected_index() const { return m_xControl->get_selected_index(); }
71 std::vector<int> get_selected_rows() const { return m_xControl->get_selected_rows(); }
72 void clear() { m_xControl->clear(); }
73 void remove(int nRow) { m_xControl->remove(nRow); }
74 void select(int nRow) { m_xControl->select(nRow); }
75 OUString get_id(int nRow) const { return m_xControl->get_id(nRow); }
76
77 // Sync data on the targets box with the data on the target
78 void setRowData(int nRowIndex, const RedactionTarget* pTarget);
79
81 {
82 m_xControl->connect_row_activated(rLink);
83 };
84};
85
86namespace sfx2
87{
88class FileDialogHelper;
89}
90
92{
93 Open,
94 SaveAs
95};
96
98{
100 std::vector<std::pair<std::unique_ptr<RedactionTarget>, OUString>> m_aTableTargets;
101 std::unique_ptr<sfx2::FileDialogHelper> m_pFileDlg;
104
106 std::unique_ptr<weld::Button> m_xLoadBtn;
107 std::unique_ptr<weld::Button> m_xSaveBtn;
108 std::unique_ptr<weld::Button> m_xAddBtn;
109 std::unique_ptr<weld::Button> m_xEditBtn;
110 std::unique_ptr<weld::Button> m_xDeleteBtn;
111
112 DECL_LINK(Load, weld::Button&, void);
113 DECL_LINK(Save, weld::Button&, void);
114 DECL_LINK(AddHdl, weld::Button&, void);
115 DECL_LINK(EditHdl, weld::Button&, void);
116 DECL_LINK(DeleteHdl, weld::Button&, void);
117 DECL_LINK(DoubleClickEditHdl, weld::TreeView&, bool);
120
121 void StartFileDialog(StartFileDialogType nType, const OUString& rTitle);
123 void addTarget(std::unique_ptr<RedactionTarget> pTarget);
125 void clearTargets();
126
127public:
129 virtual ~SfxAutoRedactDialog() override;
130
132 bool hasTargets() const;
134 bool isValidState() const { return m_bIsValidState; }
139 bool getTargets(std::vector<std::pair<RedactionTarget, OUString>>& r_aTargets);
140};
141
143{
144private:
145 std::unique_ptr<weld::Entry> m_xName;
146 std::unique_ptr<weld::ComboBox> m_xType;
147 std::unique_ptr<weld::Label> m_xLabelContent;
148 std::unique_ptr<weld::Entry> m_xContent;
149 std::unique_ptr<weld::Label> m_xLabelPredefContent;
150 std::unique_ptr<weld::ComboBox> m_xPredefContent;
151 std::unique_ptr<weld::CheckButton> m_xCaseSensitive;
152 std::unique_ptr<weld::CheckButton> m_xWholeWords;
153
154 DECL_LINK(SelectTypeHdl, weld::ComboBox&, void);
155
156public:
157 SfxAddTargetDialog(weld::Window* pWindow, const OUString& rName);
158 SfxAddTargetDialog(weld::Window* pWindow, const OUString& sName,
159 const RedactionTargetType& eTargetType, const OUString& sContent,
160 bool bCaseSensitive, bool bWholeWords);
161
162 OUString getName() const { return m_xName->get_text(); }
164 OUString getContent() const;
165 bool isCaseSensitive() const
166 {
167 return m_xCaseSensitive->get_state() == TriState::TRISTATE_TRUE;
168 }
169 bool isWholeWords() const { return m_xWholeWords->get_state() == TriState::TRISTATE_TRUE; }
170};
171
172#endif
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
StartFileDialogType
RedactionTargetType
@ REDACTION_TARGET_UNKNOWN
@ REDACTION_TARGET_REGEX
@ REDACTION_TARGET_TEXT
@ REDACTION_TARGET_PREDEFINED
std::unique_ptr< weld::Label > m_xLabelContent
std::unique_ptr< weld::CheckButton > m_xCaseSensitive
std::unique_ptr< weld::Entry > m_xContent
std::unique_ptr< weld::ComboBox > m_xType
OUString getContent() const
RedactionTargetType getType() const
SfxAddTargetDialog(weld::Window *pWindow, const OUString &rName)
std::unique_ptr< weld::Label > m_xLabelPredefContent
DECL_LINK(SelectTypeHdl, weld::ComboBox &, void)
std::unique_ptr< weld::ComboBox > m_xPredefContent
OUString getName() const
bool isCaseSensitive() const
std::unique_ptr< weld::Entry > m_xName
std::unique_ptr< weld::CheckButton > m_xWholeWords
DECL_LINK(DeleteHdl, weld::Button &, void)
std::unique_ptr< sfx2::FileDialogHelper > m_pFileDlg
void addTarget(std::unique_ptr< RedactionTarget > pTarget)
Carry out proper addition both to the targets box, and to the tabletargets vector.
std::vector< std::pair< std::unique_ptr< RedactionTarget >, OUString > > m_aTableTargets
void clearTargets()
Clear all targets both visually and from the targets vector.
std::unique_ptr< weld::Button > m_xEditBtn
DECL_LINK(DoubleClickEditHdl, weld::TreeView &, bool)
DECL_LINK(Load, weld::Button &, void)
std::unique_ptr< weld::Button > m_xSaveBtn
DECL_LINK(SaveHdl, sfx2::FileDialogHelper *, void)
virtual ~SfxAutoRedactDialog() override
bool hasTargets() const
Check if the dialog has any valid redaction targets.
DECL_LINK(Save, weld::Button &, void)
std::unique_ptr< weld::Button > m_xDeleteBtn
DECL_LINK(LoadHdl, sfx2::FileDialogHelper *, void)
DECL_LINK(AddHdl, weld::Button &, void)
SfxAutoRedactDialog(weld::Window *pParent)
SfxObjectShellLock m_xDocShell
void StartFileDialog(StartFileDialogType nType, const OUString &rTitle)
bool getTargets(std::vector< std::pair< RedactionTarget, OUString > > &r_aTargets)
Copies targets vector Does a shallow copy.
std::unique_ptr< weld::Button > m_xAddBtn
DECL_LINK(EditHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xLoadBtn
bool isValidState() const
Check if the dialog is in a valid state.
Used to display the targets list.
std::vector< int > get_selected_rows() const
void connect_row_activated(const Link< weld::TreeView &, bool > &rLink)
std::unique_ptr< weld::TreeView > m_xControl
int get_selected_index() const
int GetRowByTargetName(std::u16string_view sName)
OUString GetNameProposal() const
OUString get_id(int nRow) const
void setRowData(int nRowIndex, const RedactionTarget *pTarget)
void InsertTarget(RedactionTarget *pTarget)
void select(int nRow)
void remove(int nRow)
RedactionTarget * GetTargetByName(std::u16string_view sName)
TargetsTable(std::unique_ptr< weld::TreeView > xControl)
Keeps information for a single redaction target.
RedactionTargetType sType