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_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>
38 namespace comphelper::string
{ class NaturalStringSorter
; }
41 class SvViewDataEntry
;
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
71 virtual ~RedlinData();
78 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRedlinTable
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
;
91 SvxRedlinDateMode nDaTiMode
;
94 DateTime aDaTiFilterFirst
;
95 DateTime aDaTiFilterLast
;
97 std::unique_ptr
<utl::TextSearch
> pCommentSearcher
;
99 int ColCompare(const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
);
102 SvxRedlinTable(std::unique_ptr
<weld::TreeView
> xWriterControl
,
103 std::unique_ptr
<weld::TreeView
> xCalcControl
);
105 weld::TreeView
& GetWidget() { return *pTreeView
; }
106 bool IsSorted() const { return bSorted
; }
110 // For FilterPage only {
111 void SetFilterDate(bool bFlag
);
112 void SetDateTimeMode(SvxRedlinDateMode nMode
);
113 void SetFirstDate(const Date
&);
114 void SetLastDate(const Date
&);
115 void SetFirstTime(const tools::Time
&);
116 void SetLastTime(const tools::Time
&);
117 void SetFilterAuthor(bool bFlag
);
118 void SetAuthor(const OUString
&);
119 void SetFilterComment(bool bFlag
);
120 void SetCommentParams( const utl::SearchParam
* pSearchPara
);
122 void UpdateFilterTest();
123 // } For FilterPage only
126 void SetWriterView();
128 bool IsValidEntry(std::u16string_view rAuthor
, const DateTime
&rDateTime
, const OUString
&rComment
);
129 bool IsValidEntry(std::u16string_view rAuthor
, const DateTime
&rDateTime
);
130 bool IsValidComment(const OUString
&rComment
);
132 DECL_LINK(HeaderBarClick
, int, void);
135 class SVX_DLLPUBLIC SvxTPage
138 std::unique_ptr
<weld::Builder
> m_xBuilder
;
139 std::unique_ptr
<weld::Container
> m_xContainer
;
141 SvxTPage(weld::Container
* pParent
, const OUString
& rUIXMLDescription
, const OUString
& rID
);
143 virtual void ActivatePage();
144 void Show() { m_xContainer
->show(); }
152 /// Tabpage with the filter text entries etc.
153 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPFilter final
: public SvxTPage
155 Link
<SvxTPFilter
*,void> aReadyLink
;
156 Link
<SvxTPFilter
*,void> aRefLink
;
160 SvxRedlinTable
* m_pRedlinTable
;
161 std::unique_ptr
<weld::CheckButton
> m_xCbDate
;
162 std::unique_ptr
<weld::ComboBox
> m_xLbDate
;
163 std::unique_ptr
<SvtCalendarBox
> m_xDfDate
;
164 std::unique_ptr
<weld::FormattedSpinButton
> m_xTfDate
;
165 std::unique_ptr
<weld::TimeFormatter
> m_xTfDateFormatter
;
166 std::unique_ptr
<weld::Button
> m_xIbClock
;
167 std::unique_ptr
<weld::Label
> m_xFtDate2
;
168 std::unique_ptr
<SvtCalendarBox
> m_xDfDate2
;
169 std::unique_ptr
<weld::FormattedSpinButton
> m_xTfDate2
;
170 std::unique_ptr
<weld::TimeFormatter
> m_xTfDate2Formatter
;
171 std::unique_ptr
<weld::Button
> m_xIbClock2
;
172 std::unique_ptr
<weld::CheckButton
> m_xCbAuthor
;
173 std::unique_ptr
<weld::ComboBox
> m_xLbAuthor
;
174 std::unique_ptr
<weld::CheckButton
> m_xCbRange
;
175 std::unique_ptr
<weld::Entry
> m_xEdRange
;
176 std::unique_ptr
<weld::Button
> m_xBtnRange
;
177 std::unique_ptr
<weld::CheckButton
> m_xCbAction
;
178 std::unique_ptr
<weld::ComboBox
> m_xLbAction
;
179 std::unique_ptr
<weld::CheckButton
> m_xCbComment
;
180 std::unique_ptr
<weld::Entry
> m_xEdComment
;
182 DECL_DLLPRIVATE_LINK( SelDateHdl
, weld::ComboBox
&, void );
183 DECL_DLLPRIVATE_LINK( RowEnableHdl
, weld::Toggleable
&, void );
184 DECL_DLLPRIVATE_LINK( TimeHdl
, weld::Button
&, void );
185 DECL_DLLPRIVATE_LINK( ModifyHdl
, weld::Entry
&, void );
186 DECL_DLLPRIVATE_LINK( ModifyListBoxHdl
, weld::ComboBox
&, void );
187 DECL_DLLPRIVATE_LINK( ModifyDate
, SvtCalendarBox
&, void );
188 DECL_DLLPRIVATE_LINK( ModifyTime
, weld::FormattedSpinButton
&, void );
189 DECL_DLLPRIVATE_LINK( RefHandle
, weld::Button
&, void );
191 void EnableDateLine1(bool bFlag
);
192 void EnableDateLine2(bool bFlag
);
195 SvxTPFilter(weld::Container
* pParent
);
196 virtual ~SvxTPFilter() override
;
198 void DeactivatePage();
199 void SetRedlinTable(SvxRedlinTable
*);
201 Date
GetFirstDate() const;
202 void SetFirstDate(const Date
&aDate
);
203 tools::Time
GetFirstTime() const;
204 void SetFirstTime(const tools::Time
&aTime
);
206 Date
GetLastDate() const;
207 void SetLastDate(const Date
&aDate
);
208 tools::Time
GetLastTime() const;
209 void SetLastTime(const tools::Time
&aTime
);
211 void SetDateMode(sal_uInt16 nMode
);
212 SvxRedlinDateMode
GetDateMode() const;
215 void InsertAuthor( const OUString
& rString
);
216 OUString
GetSelectedAuthor()const;
217 void SelectedAuthorPos(sal_Int32 nPos
);
218 sal_Int32
SelectAuthor(const OUString
& aString
);
219 void SetComment(const OUString
& rComment
);
220 OUString
GetComment()const;
222 // Methods for Calc {
223 void SetRange(const OUString
& rString
);
224 OUString
GetRange() const;
225 void HideRange(bool bHide
=true);
226 void SetFocusToRange();
227 // } Methods for Calc
230 bool IsAuthor() const;
231 bool IsRange() const;
232 bool IsAction() const;
233 bool IsComment() const;
235 void ShowAction(bool bShow
=true);
237 void CheckDate(bool bFlag
);
238 void CheckAuthor(bool bFlag
);
239 void CheckRange(bool bFlag
);
240 void CheckAction(bool bFlag
);
241 void CheckComment(bool bFlag
);
243 weld::ComboBox
* GetLbAction() { return m_xLbAction
.get(); }
245 void SetReadyHdl( const Link
<SvxTPFilter
*,void>& rLink
) { aReadyLink
= rLink
; }
248 // Methods for Calc {
249 void SetRefHdl( const Link
<SvxTPFilter
*,void>& rLink
) { aRefLink
= rLink
; }
251 void Enable( bool bEnable
= true );
252 // } Methods for Calc
255 /// Tabpage with the redlining entries.
256 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPView final
: public SvxTPage
260 Link
<SvxTPView
*,void> AcceptClickLk
;
261 Link
<SvxTPView
*,void> AcceptAllClickLk
;
262 Link
<SvxTPView
*,void> RejectClickLk
;
263 Link
<SvxTPView
*,void> RejectAllClickLk
;
264 Link
<SvxTPView
*,void> UndoClickLk
;
267 bool bEnableAcceptAll
;
269 bool bEnableRejectAll
;
272 bool bEnableClearFormat
;
273 bool bEnableClearFormatAll
;
275 std::unique_ptr
<weld::Button
> m_xAccept
;
276 std::unique_ptr
<weld::Button
> m_xReject
;
277 std::unique_ptr
<weld::Button
> m_xAcceptAll
;
278 std::unique_ptr
<weld::Button
> m_xRejectAll
;
279 std::unique_ptr
<weld::Button
> m_xUndo
;
280 std::unique_ptr
<SvxRedlinTable
> m_xViewData
;
282 DECL_DLLPRIVATE_LINK( PbClickHdl
, weld::Button
&, void );
285 SvxTPView(weld::Container
* pParent
);
286 virtual ~SvxTPView() override
;
288 SvxRedlinTable
* GetTableControl() { return m_xViewData
.get(); }
290 void EnableAccept(bool bFlag
);
291 void EnableAcceptAll(bool bFlag
);
292 void EnableReject(bool bFlag
);
293 void EnableRejectAll(bool bFlag
);
294 void EnableClearFormat(bool bFlag
);
295 void EnableClearFormatAll(bool bFlag
);
296 void EnableUndo(bool bFlag
=true);
297 void DisableUndo() {EnableUndo(false);}
300 void SetAcceptClickHdl( const Link
<SvxTPView
*,void>& rLink
) { AcceptClickLk
= rLink
; }
302 void SetAcceptAllClickHdl( const Link
<SvxTPView
*,void>& rLink
) { AcceptAllClickLk
= rLink
; }
304 void SetRejectClickHdl( const Link
<SvxTPView
*,void>& rLink
) { RejectClickLk
= rLink
; }
306 void SetRejectAllClickHdl( const Link
<SvxTPView
*,void>& rLink
) { RejectAllClickLk
= rLink
; }
308 void SetUndoClickHdl( const Link
<SvxTPView
*,void>& rLink
) { UndoClickLk
= rLink
; }
310 virtual void ActivatePage() override
;
311 void DeactivatePage();
314 // Redlining - Control (Accept- Changes)
315 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxAcceptChgCtr
318 std::unique_ptr
<weld::Builder
> m_xBuilder
;
319 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
321 std::unique_ptr
<SvxTPFilter
> m_xTPFilter
;
322 std::unique_ptr
<SvxTPView
> m_xTPView
;
324 DECL_DLLPRIVATE_LINK(ActivatePageHdl
, const OUString
&, void);
325 DECL_DLLPRIVATE_LINK(DeactivatePageHdl
, const OUString
&, bool);
328 SvxAcceptChgCtr(weld::Container
* pParent
);
331 void ShowFilterPage();
333 SvxTPFilter
* GetFilterPage() { return m_xTPFilter
.get(); }
334 SvxTPView
* GetViewPage() { return m_xTPView
.get(); }
337 #endif // INCLUDED_SVX_CTREDLIN_HXX
339 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */