tdf#124953: Use rangelist's combined range top-left address...
[LibreOffice.git] / include / svx / ctredlin.hxx
blobcb0f854821b591fcbba73b531b87aed3c590eafa
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 <comphelper/string.hxx>
24 #include <rtl/ustring.hxx>
25 #include <sal/types.h>
26 #include <svx/svxdllapi.h>
27 #include <svtools/simptabl.hxx>
28 #include <svtools/ctrlbox.hxx>
29 #include <vcl/svlbitm.hxx>
30 #include <vcl/svtabbx.hxx>
31 #include <vcl/treelistbox.hxx>
32 #include <vcl/treelistentry.hxx>
33 #include <tools/color.hxx>
34 #include <tools/contnr.hxx>
35 #include <tools/date.hxx>
36 #include <tools/datetime.hxx>
37 #include <tools/link.hxx>
38 #include <tools/time.hxx>
39 #include <tools/wintypes.hxx>
40 #include <vcl/builder.hxx>
41 #include <vcl/vclptr.hxx>
42 #include <vcl/tabpage.hxx>
43 #include <vcl/tabctrl.hxx>
44 #include <memory>
46 namespace utl {
47 class SearchParam;
48 class TextSearch;
51 namespace vcl { class Window; }
53 class DateField;
54 class Edit;
55 class FixedText;
56 class ListBox;
57 class Point;
58 class SvViewDataEntry;
59 class TimeField;
60 struct SvSortData;
62 enum class SvxRedlinDateMode
64 BEFORE, SINCE, EQUAL, NOTEQUAL, BETWEEN, SAVE, NONE
67 /// Struct for sorting data.
68 class SAL_WARN_UNUSED SVX_DLLPUBLIC RedlinData
70 public:
71 RedlinData();
72 virtual ~RedlinData();
73 bool bDisabled;
74 DateTime aDateTime;
75 void* pData;
78 /// Entries for list.
79 class SAL_WARN_UNUSED SvxRedlinEntry : public SvTreeListEntry
81 public:
82 SvxRedlinEntry();
83 virtual ~SvxRedlinEntry() override;
86 /// Class for the representation of Strings depending on the font.
87 class SAL_WARN_UNUSED SvLBoxColorString : public SvLBoxString
89 private:
91 Color aPrivColor;
93 public:
94 SvLBoxColorString( const OUString& rStr, const Color& rCol);
95 SvLBoxColorString();
96 virtual ~SvLBoxColorString() override;
98 /** Paint function of the SvLBoxColorString class.
100 The relevant text with the selected color is drawn in the output device.
102 virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext,
103 const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override;
105 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override;
108 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRedlinTable
110 private:
111 std::unique_ptr<comphelper::string::NaturalStringSorter> xSorter;
112 std::unique_ptr<weld::TreeView> xWriterTreeView;
113 std::unique_ptr<weld::TreeView> xCalcTreeView;
114 weld::TreeView* pTreeView;
116 sal_uInt16 nDatePos;
117 bool bAuthor;
118 bool bDate;
119 bool bComment;
120 SvxRedlinDateMode nDaTiMode;
121 DateTime aDaTiFirst;
122 DateTime aDaTiLast;
123 DateTime aDaTiFilterFirst;
124 DateTime aDaTiFilterLast;
125 OUString aAuthor;
126 std::unique_ptr<utl::TextSearch> pCommentSearcher;
128 int ColCompare(const weld::TreeIter& rLeft, const weld::TreeIter& rRight);
130 public:
131 SvxRedlinTable(std::unique_ptr<weld::TreeView> xWriterControl,
132 std::unique_ptr<weld::TreeView> xCalcControl);
134 void set_size_request(int nWidth, int nHeight);
136 weld::TreeView& GetWidget() { return *pTreeView; }
138 ~SvxRedlinTable();
140 // For FilterPage only {
141 void SetFilterDate(bool bFlag);
142 void SetDateTimeMode(SvxRedlinDateMode nMode);
143 void SetFirstDate(const Date&);
144 void SetLastDate(const Date&);
145 void SetFirstTime(const tools::Time&);
146 void SetLastTime(const tools::Time&);
147 void SetFilterAuthor(bool bFlag);
148 void SetAuthor(const OUString &);
149 void SetFilterComment(bool bFlag);
150 void SetCommentParams( const utl::SearchParam* pSearchPara );
152 void UpdateFilterTest();
153 // } For FilterPage only
155 void SetCalcView();
156 void SetWriterView();
158 bool IsValidEntry(const OUString &rAuthor, const DateTime &rDateTime, const OUString &rComment);
159 bool IsValidEntry(const OUString &rAuthor, const DateTime &rDateTime);
160 bool IsValidComment(const OUString &rComment);
162 DECL_LINK(HeaderBarClick, int, void);
165 class SVX_DLLPUBLIC SvxTPage
167 protected:
168 std::unique_ptr<weld::Builder> m_xBuilder;
169 std::unique_ptr<weld::Container> m_xContainer;
170 public:
171 SvxTPage(weld::Container* pParent, const OUString& rUIXMLDescription, const OString& rID);
172 virtual ~SvxTPage();
173 virtual void ActivatePage();
174 virtual void DeactivatePage();
175 void Show() { m_xContainer->show(); }
178 /// Tabpage with the filter text entries etc.
179 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPFilter final : public SvxTPage
181 Link<SvxTPFilter*,void> aReadyLink;
182 Link<SvxTPFilter*,void> aRefLink;
184 bool bModified;
186 SvxRedlinTable* m_pRedlinTable;
187 std::unique_ptr<weld::CheckButton> m_xCbDate;
188 std::unique_ptr<weld::ComboBox> m_xLbDate;
189 std::unique_ptr<SvtCalendarBox> m_xDfDate;
190 std::unique_ptr<weld::TimeSpinButton> m_xTfDate;
191 std::unique_ptr<weld::Button> m_xIbClock;
192 std::unique_ptr<weld::Label> m_xFtDate2;
193 std::unique_ptr<SvtCalendarBox> m_xDfDate2;
194 std::unique_ptr<weld::TimeSpinButton> m_xTfDate2;
195 std::unique_ptr<weld::Button> m_xIbClock2;
196 std::unique_ptr<weld::CheckButton> m_xCbAuthor;
197 std::unique_ptr<weld::ComboBox> m_xLbAuthor;
198 std::unique_ptr<weld::CheckButton> m_xCbRange;
199 std::unique_ptr<weld::Entry> m_xEdRange;
200 std::unique_ptr<weld::Button> m_xBtnRange;
201 std::unique_ptr<weld::CheckButton> m_xCbAction;
202 std::unique_ptr<weld::ComboBox> m_xLbAction;
203 std::unique_ptr<weld::CheckButton> m_xCbComment;
204 std::unique_ptr<weld::Entry> m_xEdComment;
206 DECL_LINK( SelDateHdl, weld::ComboBox&, void );
207 DECL_LINK( RowEnableHdl, weld::Button&, void );
208 DECL_LINK( TimeHdl, weld::Button&, void );
209 DECL_LINK( ModifyHdl, weld::Entry&, void );
210 DECL_LINK( ModifyListBoxHdl, weld::ComboBox&, void );
211 DECL_LINK( ModifyDate, SvtCalendarBox&, void );
212 DECL_LINK( ModifyTime, weld::TimeSpinButton&, void );
213 DECL_LINK( RefHandle, weld::Button&, void );
215 void EnableDateLine1(bool bFlag);
216 void EnableDateLine2(bool bFlag);
218 public:
219 SvxTPFilter(weld::Container* pParent);
220 virtual ~SvxTPFilter() override;
222 virtual void DeactivatePage() override;
223 void SetRedlinTable(SvxRedlinTable*);
225 Date GetFirstDate() const;
226 void SetFirstDate(const Date &aDate);
227 tools::Time GetFirstTime() const;
228 void SetFirstTime(const tools::Time &aTime);
230 Date GetLastDate() const;
231 void SetLastDate(const Date &aDate);
232 tools::Time GetLastTime() const;
233 void SetLastTime(const tools::Time &aTime);
235 void SetDateMode(sal_uInt16 nMode);
236 SvxRedlinDateMode GetDateMode();
238 void ClearAuthors();
239 void InsertAuthor( const OUString& rString );
240 OUString GetSelectedAuthor()const;
241 void SelectedAuthorPos(sal_Int32 nPos);
242 sal_Int32 SelectAuthor(const OUString& aString);
243 void SetComment(const OUString& rComment);
244 OUString GetComment()const;
246 // Methods for Calc {
247 void SetRange(const OUString& rString);
248 OUString GetRange() const;
249 void HideRange(bool bHide=true);
250 void SetFocusToRange();
251 // } Methods for Calc
253 bool IsDate();
254 bool IsAuthor();
255 bool IsRange();
256 bool IsAction();
257 bool IsComment();
259 void ShowAction(bool bShow=true);
261 void CheckDate(bool bFlag);
262 void CheckAuthor(bool bFlag);
263 void CheckRange(bool bFlag);
264 void CheckAction(bool bFlag);
265 void CheckComment(bool bFlag);
267 weld::ComboBox* GetLbAction() { return m_xLbAction.get(); }
269 void SetReadyHdl( const Link<SvxTPFilter*,void>& rLink ) { aReadyLink= rLink; }
272 // Methods for Calc {
273 void SetRefHdl( const Link<SvxTPFilter*,void>& rLink ) { aRefLink = rLink; }
275 void Enable( bool bEnable = true );
276 void Disable();
277 // } Methods for Calc
280 /// Tabpage with the redlining entries.
281 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPView : public SvxTPage
283 private:
285 Link<SvxTPView*,void> AcceptClickLk;
286 Link<SvxTPView*,void> AcceptAllClickLk;
287 Link<SvxTPView*,void> RejectClickLk;
288 Link<SvxTPView*,void> RejectAllClickLk;
289 Link<SvxTPView*,void> UndoClickLk;
291 bool bEnableAccept;
292 bool bEnableAcceptAll;
293 bool bEnableReject;
294 bool bEnableRejectAll;
295 bool bEnableUndo;
297 std::unique_ptr<weld::Button> m_xAccept;
298 std::unique_ptr<weld::Button> m_xReject;
299 std::unique_ptr<weld::Button> m_xAcceptAll;
300 std::unique_ptr<weld::Button> m_xRejectAll;
301 std::unique_ptr<weld::Button> m_xUndo;
302 std::unique_ptr<SvxRedlinTable> m_xViewData;
304 DECL_LINK( PbClickHdl, weld::Button&, void );
306 public:
307 SvxTPView(weld::Container* pParent, weld::Builder* pTopLevel);
308 virtual ~SvxTPView() override;
310 void InsertWriterHeader();
311 void InsertCalcHeader();
312 SvxRedlinTable* GetTableControl() { return m_xViewData.get(); }
314 void EnableAccept(bool bFlag);
315 void EnableAcceptAll(bool bFlag);
316 void EnableReject(bool bFlag);
317 void EnableRejectAll(bool bFlag);
318 static void EnableClearFormatButton(weld::Button&, bool bFlag);
319 void EnableClearFormat(bool bFlag);
320 void EnableClearFormatAll(bool bFlag);
321 void EnableUndo(bool bFlag=true);
322 void DisableUndo() {EnableUndo(false);}
323 void ShowUndo();
325 void SetAcceptClickHdl( const Link<SvxTPView*,void>& rLink ) { AcceptClickLk = rLink; }
327 void SetAcceptAllClickHdl( const Link<SvxTPView*,void>& rLink ) { AcceptAllClickLk = rLink; }
329 void SetRejectClickHdl( const Link<SvxTPView*,void>& rLink ) { RejectClickLk = rLink; }
331 void SetRejectAllClickHdl( const Link<SvxTPView*,void>& rLink ) { RejectAllClickLk = rLink; }
333 void SetUndoClickHdl( const Link<SvxTPView*,void>& rLink ) { UndoClickLk = rLink; }
335 virtual void ActivatePage() override;
336 virtual void DeactivatePage() override;
339 // Redlining - Control (Accept- Changes)
340 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxAcceptChgCtr
342 private:
343 std::unique_ptr<weld::Builder> m_xBuilder;
344 std::unique_ptr<weld::Notebook> m_xTabCtrl;
346 std::unique_ptr<SvxTPFilter> m_xTPFilter;
347 std::unique_ptr<SvxTPView> m_xTPView;
349 DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void);
350 DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool);
352 public:
353 SvxAcceptChgCtr(weld::Container* pParent, weld::Builder* pTopLevel);
354 ~SvxAcceptChgCtr();
356 void ShowFilterPage();
358 SvxTPFilter* GetFilterPage() { return m_xTPFilter.get(); }
359 SvxTPView* GetViewPage() { return m_xTPView.get(); }
361 void set_help_id(const OString& rId) { m_xTabCtrl->set_help_id(rId); }
364 #endif // INCLUDED_SVX_CTREDLIN_HXX
366 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */