Bump version to 21.06.18.1
[LibreOffice.git] / include / svx / ctredlin.hxx
blob4dd80bafd7095d442fd98b790e7c1a60ad2b8ede
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SVX_CTREDLIN_HXX
21 #define INCLUDED_SVX_CTREDLIN_HXX
23 #include <rtl/ustring.hxx>
24 #include <sal/types.h>
25 #include <svx/svxdllapi.h>
26 #include <tools/date.hxx>
27 #include <tools/datetime.hxx>
28 #include <tools/link.hxx>
29 #include <tools/time.hxx>
30 #include <vcl/weld.hxx>
31 #include <memory>
33 namespace utl {
34 class SearchParam;
35 class TextSearch;
38 namespace comphelper::string { class NaturalStringSorter; }
40 class Point;
41 class SvViewDataEntry;
42 class SvtCalendarBox;
44 enum class SvxRedlinDateMode
46 BEFORE, SINCE, EQUAL, NOTEQUAL, BETWEEN, SAVE, NONE
49 enum class RedlineType : sal_uInt16
51 // Range of RedlineTypes is 0 to 127.
52 Insert = 0x0,// Content has been inserted.
53 Delete = 0x1,// Content has been deleted.
54 Format = 0x2,// Attributes have been applied.
55 Table = 0x3,// Table structure has been altered.
56 FmtColl = 0x4,// Style has been altered (Autoformat!).
57 ParagraphFormat = 0x5,// Paragraph attributes have been changed.
58 TableRowInsert = 0x6,// Table row has been inserted.
59 TableRowDelete = 0x7,// Table row has been deleted.
60 TableCellInsert = 0x8,// Table cell has been inserted.
61 TableCellDelete = 0x9,// Table cell has been deleted.
62 None = USHRT_MAX - 1, // special value to indicate missing redlining in some return value
63 Any = USHRT_MAX // special value to indicate any redline type in some method calls
66 /// Struct for sorting data.
67 class SAL_WARN_UNUSED SVX_DLLPUBLIC RedlinData
69 public:
70 RedlinData();
71 virtual ~RedlinData();
72 DateTime aDateTime;
73 void* pData;
74 RedlineType eType;
75 bool bDisabled;
78 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRedlinTable
80 private:
81 std::unique_ptr<comphelper::string::NaturalStringSorter> xSorter;
82 std::unique_ptr<weld::TreeView> xWriterTreeView;
83 std::unique_ptr<weld::TreeView> xCalcTreeView;
84 weld::TreeView* pTreeView;
86 sal_uInt16 nDatePos;
87 bool bAuthor;
88 bool bDate;
89 bool bComment;
90 bool bSorted;
91 SvxRedlinDateMode nDaTiMode;
92 DateTime aDaTiFirst;
93 DateTime aDaTiLast;
94 DateTime aDaTiFilterFirst;
95 DateTime aDaTiFilterLast;
96 OUString aAuthor;
97 std::unique_ptr<utl::TextSearch> pCommentSearcher;
99 int ColCompare(const weld::TreeIter& rLeft, const weld::TreeIter& rRight);
101 public:
102 SvxRedlinTable(std::unique_ptr<weld::TreeView> xWriterControl,
103 std::unique_ptr<weld::TreeView> xCalcControl);
105 void set_size_request(int nWidth, int nHeight);
107 weld::TreeView& GetWidget() { return *pTreeView; }
108 bool IsSorted() const { return bSorted; }
110 ~SvxRedlinTable();
112 // For FilterPage only {
113 void SetFilterDate(bool bFlag);
114 void SetDateTimeMode(SvxRedlinDateMode nMode);
115 void SetFirstDate(const Date&);
116 void SetLastDate(const Date&);
117 void SetFirstTime(const tools::Time&);
118 void SetLastTime(const tools::Time&);
119 void SetFilterAuthor(bool bFlag);
120 void SetAuthor(const OUString &);
121 void SetFilterComment(bool bFlag);
122 void SetCommentParams( const utl::SearchParam* pSearchPara );
124 void UpdateFilterTest();
125 // } For FilterPage only
127 void SetCalcView();
128 void SetWriterView();
130 bool IsValidEntry(const OUString &rAuthor, const DateTime &rDateTime, const OUString &rComment);
131 bool IsValidEntry(const OUString &rAuthor, const DateTime &rDateTime);
132 bool IsValidComment(const OUString &rComment);
134 DECL_LINK(HeaderBarClick, int, void);
137 class SVX_DLLPUBLIC SvxTPage
139 protected:
140 std::unique_ptr<weld::Builder> m_xBuilder;
141 std::unique_ptr<weld::Container> m_xContainer;
142 public:
143 SvxTPage(weld::Container* pParent, const OUString& rUIXMLDescription, const OString& rID);
144 virtual ~SvxTPage();
145 virtual void ActivatePage();
146 void Show() { m_xContainer->show(); }
149 namespace weld
151 class TimeFormatter;
154 /// Tabpage with the filter text entries etc.
155 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPFilter final : public SvxTPage
157 Link<SvxTPFilter*,void> aReadyLink;
158 Link<SvxTPFilter*,void> aRefLink;
160 bool bModified;
162 SvxRedlinTable* m_pRedlinTable;
163 std::unique_ptr<weld::CheckButton> m_xCbDate;
164 std::unique_ptr<weld::ComboBox> m_xLbDate;
165 std::unique_ptr<SvtCalendarBox> m_xDfDate;
166 std::unique_ptr<weld::FormattedSpinButton> m_xTfDate;
167 std::unique_ptr<weld::TimeFormatter> m_xTfDateFormatter;
168 std::unique_ptr<weld::Button> m_xIbClock;
169 std::unique_ptr<weld::Label> m_xFtDate2;
170 std::unique_ptr<SvtCalendarBox> m_xDfDate2;
171 std::unique_ptr<weld::FormattedSpinButton> m_xTfDate2;
172 std::unique_ptr<weld::TimeFormatter> m_xTfDate2Formatter;
173 std::unique_ptr<weld::Button> m_xIbClock2;
174 std::unique_ptr<weld::CheckButton> m_xCbAuthor;
175 std::unique_ptr<weld::ComboBox> m_xLbAuthor;
176 std::unique_ptr<weld::CheckButton> m_xCbRange;
177 std::unique_ptr<weld::Entry> m_xEdRange;
178 std::unique_ptr<weld::Button> m_xBtnRange;
179 std::unique_ptr<weld::CheckButton> m_xCbAction;
180 std::unique_ptr<weld::ComboBox> m_xLbAction;
181 std::unique_ptr<weld::CheckButton> m_xCbComment;
182 std::unique_ptr<weld::Entry> m_xEdComment;
184 DECL_LINK( SelDateHdl, weld::ComboBox&, void );
185 DECL_LINK( RowEnableHdl, weld::Button&, void );
186 DECL_LINK( TimeHdl, weld::Button&, void );
187 DECL_LINK( ModifyHdl, weld::Entry&, void );
188 DECL_LINK( ModifyListBoxHdl, weld::ComboBox&, void );
189 DECL_LINK( ModifyDate, SvtCalendarBox&, void );
190 DECL_LINK( ModifyTime, weld::FormattedSpinButton&, void );
191 DECL_LINK( RefHandle, weld::Button&, void );
193 void EnableDateLine1(bool bFlag);
194 void EnableDateLine2(bool bFlag);
196 public:
197 SvxTPFilter(weld::Container* pParent);
198 virtual ~SvxTPFilter() override;
200 void DeactivatePage();
201 void SetRedlinTable(SvxRedlinTable*);
203 Date GetFirstDate() const;
204 void SetFirstDate(const Date &aDate);
205 tools::Time GetFirstTime() const;
206 void SetFirstTime(const tools::Time &aTime);
208 Date GetLastDate() const;
209 void SetLastDate(const Date &aDate);
210 tools::Time GetLastTime() const;
211 void SetLastTime(const tools::Time &aTime);
213 void SetDateMode(sal_uInt16 nMode);
214 SvxRedlinDateMode GetDateMode() const;
216 void ClearAuthors();
217 void InsertAuthor( const OUString& rString );
218 OUString GetSelectedAuthor()const;
219 void SelectedAuthorPos(sal_Int32 nPos);
220 sal_Int32 SelectAuthor(const OUString& aString);
221 void SetComment(const OUString& rComment);
222 OUString GetComment()const;
224 // Methods for Calc {
225 void SetRange(const OUString& rString);
226 OUString GetRange() const;
227 void HideRange(bool bHide=true);
228 void SetFocusToRange();
229 // } Methods for Calc
231 bool IsDate() const;
232 bool IsAuthor() const;
233 bool IsRange() const;
234 bool IsAction() const;
235 bool IsComment() const;
237 void ShowAction(bool bShow=true);
239 void CheckDate(bool bFlag);
240 void CheckAuthor(bool bFlag);
241 void CheckRange(bool bFlag);
242 void CheckAction(bool bFlag);
243 void CheckComment(bool bFlag);
245 weld::ComboBox* GetLbAction() { return m_xLbAction.get(); }
247 void SetReadyHdl( const Link<SvxTPFilter*,void>& rLink ) { aReadyLink= rLink; }
250 // Methods for Calc {
251 void SetRefHdl( const Link<SvxTPFilter*,void>& rLink ) { aRefLink = rLink; }
253 void Enable( bool bEnable = true );
254 // } Methods for Calc
257 /// Tabpage with the redlining entries.
258 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPView final : public SvxTPage
260 private:
262 Link<SvxTPView*,void> AcceptClickLk;
263 Link<SvxTPView*,void> AcceptAllClickLk;
264 Link<SvxTPView*,void> RejectClickLk;
265 Link<SvxTPView*,void> RejectAllClickLk;
266 Link<SvxTPView*,void> UndoClickLk;
268 bool bEnableAccept;
269 bool bEnableAcceptAll;
270 bool bEnableReject;
271 bool bEnableRejectAll;
272 bool bEnableUndo;
274 bool bEnableClearFormat;
275 bool bEnableClearFormatAll;
277 weld::Window* m_pDialog;
278 std::unique_ptr<weld::Button> m_xAccept;
279 std::unique_ptr<weld::Button> m_xReject;
280 std::unique_ptr<weld::Button> m_xAcceptAll;
281 std::unique_ptr<weld::Button> m_xRejectAll;
282 std::unique_ptr<weld::Button> m_xUndo;
283 std::unique_ptr<SvxRedlinTable> m_xViewData;
285 DECL_LINK( PbClickHdl, weld::Button&, void );
287 void EnableClearFormatButton(weld::Button&, bool bFlag);
288 public:
289 SvxTPView(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel);
290 virtual ~SvxTPView() override;
292 SvxRedlinTable* GetTableControl() { return m_xViewData.get(); }
294 void EnableAccept(bool bFlag);
295 void EnableAcceptAll(bool bFlag);
296 void EnableReject(bool bFlag);
297 void EnableRejectAll(bool bFlag);
298 void EnableClearFormat(bool bFlag);
299 void EnableClearFormatAll(bool bFlag);
300 void EnableUndo(bool bFlag=true);
301 void DisableUndo() {EnableUndo(false);}
302 void ShowUndo();
304 void SetAcceptClickHdl( const Link<SvxTPView*,void>& rLink ) { AcceptClickLk = rLink; }
306 void SetAcceptAllClickHdl( const Link<SvxTPView*,void>& rLink ) { AcceptAllClickLk = rLink; }
308 void SetRejectClickHdl( const Link<SvxTPView*,void>& rLink ) { RejectClickLk = rLink; }
310 void SetRejectAllClickHdl( const Link<SvxTPView*,void>& rLink ) { RejectAllClickLk = rLink; }
312 void SetUndoClickHdl( const Link<SvxTPView*,void>& rLink ) { UndoClickLk = rLink; }
314 virtual void ActivatePage() override;
315 void DeactivatePage();
318 // Redlining - Control (Accept- Changes)
319 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxAcceptChgCtr
321 private:
322 std::unique_ptr<weld::Builder> m_xBuilder;
323 std::unique_ptr<weld::Notebook> m_xTabCtrl;
325 std::unique_ptr<SvxTPFilter> m_xTPFilter;
326 std::unique_ptr<SvxTPView> m_xTPView;
328 DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void);
329 DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool);
331 public:
332 SvxAcceptChgCtr(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel);
333 ~SvxAcceptChgCtr();
335 void ShowFilterPage();
337 SvxTPFilter* GetFilterPage() { return m_xTPFilter.get(); }
338 SvxTPView* GetViewPage() { return m_xTPView.get(); }
340 void set_help_id(const OString& rId) { m_xTabCtrl->set_help_id(rId); }
343 #endif // INCLUDED_SVX_CTREDLIN_HXX
345 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */