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 Any
= USHRT_MAX
// special value to indicate any redline type in some method calls
65 /// Struct for sorting data.
66 class SAL_WARN_UNUSED SVX_DLLPUBLIC RedlinData
70 virtual ~RedlinData();
77 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRedlinTable
80 std::unique_ptr
<comphelper::string::NaturalStringSorter
> xSorter
;
81 std::unique_ptr
<weld::TreeView
> xWriterTreeView
;
82 std::unique_ptr
<weld::TreeView
> xCalcTreeView
;
83 weld::TreeView
* pTreeView
;
90 SvxRedlinDateMode nDaTiMode
;
93 DateTime aDaTiFilterFirst
;
94 DateTime aDaTiFilterLast
;
96 std::unique_ptr
<utl::TextSearch
> pCommentSearcher
;
98 int ColCompare(const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
);
101 SvxRedlinTable(std::unique_ptr
<weld::TreeView
> xWriterControl
,
102 std::unique_ptr
<weld::TreeView
> xCalcControl
);
104 void set_size_request(int nWidth
, int nHeight
);
106 weld::TreeView
& GetWidget() { return *pTreeView
; }
107 bool IsSorted() const { return bSorted
; }
111 // For FilterPage only {
112 void SetFilterDate(bool bFlag
);
113 void SetDateTimeMode(SvxRedlinDateMode nMode
);
114 void SetFirstDate(const Date
&);
115 void SetLastDate(const Date
&);
116 void SetFirstTime(const tools::Time
&);
117 void SetLastTime(const tools::Time
&);
118 void SetFilterAuthor(bool bFlag
);
119 void SetAuthor(const OUString
&);
120 void SetFilterComment(bool bFlag
);
121 void SetCommentParams( const utl::SearchParam
* pSearchPara
);
123 void UpdateFilterTest();
124 // } For FilterPage only
127 void SetWriterView();
129 bool IsValidEntry(const OUString
&rAuthor
, const DateTime
&rDateTime
, const OUString
&rComment
);
130 bool IsValidEntry(const OUString
&rAuthor
, const DateTime
&rDateTime
);
131 bool IsValidComment(const OUString
&rComment
);
133 DECL_LINK(HeaderBarClick
, int, void);
136 class SVX_DLLPUBLIC SvxTPage
139 std::unique_ptr
<weld::Builder
> m_xBuilder
;
140 std::unique_ptr
<weld::Container
> m_xContainer
;
142 SvxTPage(weld::Container
* pParent
, const OUString
& rUIXMLDescription
, const OString
& rID
);
144 virtual void ActivatePage();
145 void Show() { m_xContainer
->show(); }
148 /// Tabpage with the filter text entries etc.
149 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPFilter final
: public SvxTPage
151 Link
<SvxTPFilter
*,void> aReadyLink
;
152 Link
<SvxTPFilter
*,void> aRefLink
;
156 SvxRedlinTable
* m_pRedlinTable
;
157 std::unique_ptr
<weld::CheckButton
> m_xCbDate
;
158 std::unique_ptr
<weld::ComboBox
> m_xLbDate
;
159 std::unique_ptr
<SvtCalendarBox
> m_xDfDate
;
160 std::unique_ptr
<weld::TimeSpinButton
> m_xTfDate
;
161 std::unique_ptr
<weld::Button
> m_xIbClock
;
162 std::unique_ptr
<weld::Label
> m_xFtDate2
;
163 std::unique_ptr
<SvtCalendarBox
> m_xDfDate2
;
164 std::unique_ptr
<weld::TimeSpinButton
> m_xTfDate2
;
165 std::unique_ptr
<weld::Button
> m_xIbClock2
;
166 std::unique_ptr
<weld::CheckButton
> m_xCbAuthor
;
167 std::unique_ptr
<weld::ComboBox
> m_xLbAuthor
;
168 std::unique_ptr
<weld::CheckButton
> m_xCbRange
;
169 std::unique_ptr
<weld::Entry
> m_xEdRange
;
170 std::unique_ptr
<weld::Button
> m_xBtnRange
;
171 std::unique_ptr
<weld::CheckButton
> m_xCbAction
;
172 std::unique_ptr
<weld::ComboBox
> m_xLbAction
;
173 std::unique_ptr
<weld::CheckButton
> m_xCbComment
;
174 std::unique_ptr
<weld::Entry
> m_xEdComment
;
176 DECL_LINK( SelDateHdl
, weld::ComboBox
&, void );
177 DECL_LINK( RowEnableHdl
, weld::Button
&, void );
178 DECL_LINK( TimeHdl
, weld::Button
&, void );
179 DECL_LINK( ModifyHdl
, weld::Entry
&, void );
180 DECL_LINK( ModifyListBoxHdl
, weld::ComboBox
&, void );
181 DECL_LINK( ModifyDate
, SvtCalendarBox
&, void );
182 DECL_LINK( ModifyTime
, weld::TimeSpinButton
&, void );
183 DECL_LINK( RefHandle
, weld::Button
&, void );
185 void EnableDateLine1(bool bFlag
);
186 void EnableDateLine2(bool bFlag
);
189 SvxTPFilter(weld::Container
* pParent
);
190 virtual ~SvxTPFilter() override
;
192 void DeactivatePage();
193 void SetRedlinTable(SvxRedlinTable
*);
195 Date
GetFirstDate() const;
196 void SetFirstDate(const Date
&aDate
);
197 tools::Time
GetFirstTime() const;
198 void SetFirstTime(const tools::Time
&aTime
);
200 Date
GetLastDate() const;
201 void SetLastDate(const Date
&aDate
);
202 tools::Time
GetLastTime() const;
203 void SetLastTime(const tools::Time
&aTime
);
205 void SetDateMode(sal_uInt16 nMode
);
206 SvxRedlinDateMode
GetDateMode() const;
209 void InsertAuthor( const OUString
& rString
);
210 OUString
GetSelectedAuthor()const;
211 void SelectedAuthorPos(sal_Int32 nPos
);
212 sal_Int32
SelectAuthor(const OUString
& aString
);
213 void SetComment(const OUString
& rComment
);
214 OUString
GetComment()const;
216 // Methods for Calc {
217 void SetRange(const OUString
& rString
);
218 OUString
GetRange() const;
219 void HideRange(bool bHide
=true);
220 void SetFocusToRange();
221 // } Methods for Calc
224 bool IsAuthor() const;
225 bool IsRange() const;
226 bool IsAction() const;
227 bool IsComment() const;
229 void ShowAction(bool bShow
=true);
231 void CheckDate(bool bFlag
);
232 void CheckAuthor(bool bFlag
);
233 void CheckRange(bool bFlag
);
234 void CheckAction(bool bFlag
);
235 void CheckComment(bool bFlag
);
237 weld::ComboBox
* GetLbAction() { return m_xLbAction
.get(); }
239 void SetReadyHdl( const Link
<SvxTPFilter
*,void>& rLink
) { aReadyLink
= rLink
; }
242 // Methods for Calc {
243 void SetRefHdl( const Link
<SvxTPFilter
*,void>& rLink
) { aRefLink
= rLink
; }
245 void Enable( bool bEnable
= true );
246 // } Methods for Calc
249 /// Tabpage with the redlining entries.
250 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxTPView final
: public SvxTPage
254 Link
<SvxTPView
*,void> AcceptClickLk
;
255 Link
<SvxTPView
*,void> AcceptAllClickLk
;
256 Link
<SvxTPView
*,void> RejectClickLk
;
257 Link
<SvxTPView
*,void> RejectAllClickLk
;
258 Link
<SvxTPView
*,void> UndoClickLk
;
261 bool bEnableAcceptAll
;
263 bool bEnableRejectAll
;
266 bool bEnableClearFormat
;
267 bool bEnableClearFormatAll
;
269 weld::Window
* m_pDialog
;
270 std::unique_ptr
<weld::Button
> m_xAccept
;
271 std::unique_ptr
<weld::Button
> m_xReject
;
272 std::unique_ptr
<weld::Button
> m_xAcceptAll
;
273 std::unique_ptr
<weld::Button
> m_xRejectAll
;
274 std::unique_ptr
<weld::Button
> m_xUndo
;
275 std::unique_ptr
<SvxRedlinTable
> m_xViewData
;
277 DECL_LINK( PbClickHdl
, weld::Button
&, void );
279 void EnableClearFormatButton(weld::Button
&, bool bFlag
);
281 SvxTPView(weld::Container
* pParent
, weld::Window
* pDialog
, weld::Builder
* pTopLevel
);
282 virtual ~SvxTPView() override
;
284 SvxRedlinTable
* GetTableControl() { return m_xViewData
.get(); }
286 void EnableAccept(bool bFlag
);
287 void EnableAcceptAll(bool bFlag
);
288 void EnableReject(bool bFlag
);
289 void EnableRejectAll(bool bFlag
);
290 void EnableClearFormat(bool bFlag
);
291 void EnableClearFormatAll(bool bFlag
);
292 void EnableUndo(bool bFlag
=true);
293 void DisableUndo() {EnableUndo(false);}
296 void SetAcceptClickHdl( const Link
<SvxTPView
*,void>& rLink
) { AcceptClickLk
= rLink
; }
298 void SetAcceptAllClickHdl( const Link
<SvxTPView
*,void>& rLink
) { AcceptAllClickLk
= rLink
; }
300 void SetRejectClickHdl( const Link
<SvxTPView
*,void>& rLink
) { RejectClickLk
= rLink
; }
302 void SetRejectAllClickHdl( const Link
<SvxTPView
*,void>& rLink
) { RejectAllClickLk
= rLink
; }
304 void SetUndoClickHdl( const Link
<SvxTPView
*,void>& rLink
) { UndoClickLk
= rLink
; }
306 virtual void ActivatePage() override
;
307 void DeactivatePage();
310 // Redlining - Control (Accept- Changes)
311 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxAcceptChgCtr
314 std::unique_ptr
<weld::Builder
> m_xBuilder
;
315 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
317 std::unique_ptr
<SvxTPFilter
> m_xTPFilter
;
318 std::unique_ptr
<SvxTPView
> m_xTPView
;
320 DECL_DLLPRIVATE_LINK(ActivatePageHdl
, const OString
&, void);
321 DECL_DLLPRIVATE_LINK(DeactivatePageHdl
, const OString
&, bool);
324 SvxAcceptChgCtr(weld::Container
* pParent
, weld::Window
* pDialog
, weld::Builder
* pTopLevel
);
327 void ShowFilterPage();
329 SvxTPFilter
* GetFilterPage() { return m_xTPFilter
.get(); }
330 SvxTPView
* GetViewPage() { return m_xTPView
.get(); }
332 void set_help_id(const OString
& rId
) { m_xTabCtrl
->set_help_id(rId
); }
335 #endif // INCLUDED_SVX_CTREDLIN_HXX
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */