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 #include <comphelper/processfactory.hxx>
21 #include <comphelper/string.hxx>
22 #include <i18nlangtag/languagetag.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/settings.hxx>
25 #include <vcl/weldutils.hxx>
26 #include <svtools/ctrlbox.hxx>
27 #include <unotools/textsearch.hxx>
29 #include <svx/ctredlin.hxx>
30 #include <svx/dialmgr.hxx>
31 #include <svx/strings.hrc>
36 RedlinData::RedlinData()
37 : aDateTime(DateTime::EMPTY
)
39 , eType(RedlineType::Any
)
44 RedlinData::~RedlinData()
48 SvxRedlinTable::SvxRedlinTable(std::unique_ptr
<weld::TreeView
> xWriterControl
,
49 std::unique_ptr
<weld::TreeView
> xCalcControl
)
50 : xSorter(new comphelper::string::NaturalStringSorter(::comphelper::getProcessComponentContext(),
51 Application::GetSettings().GetUILanguageTag().getLocale()))
52 , xWriterTreeView(std::move(xWriterControl
))
53 , xCalcTreeView(std::move(xCalcControl
))
55 , nDatePos(WRITER_DATE
)
60 , nDaTiMode(SvxRedlinDateMode::BEFORE
)
61 , aDaTiFirst( DateTime::EMPTY
)
62 , aDaTiLast( DateTime::EMPTY
)
63 , aDaTiFilterFirst( DateTime::EMPTY
)
64 , aDaTiFilterLast( DateTime::EMPTY
)
68 xWriterTreeView
->connect_column_clicked(LINK(this, SvxRedlinTable
, HeaderBarClick
));
69 xWriterTreeView
->set_sort_func([this](const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
){
70 return ColCompare(rLeft
, rRight
);
72 pTreeView
= xWriterTreeView
.get();
76 xCalcTreeView
->connect_column_clicked(LINK(this, SvxRedlinTable
, HeaderBarClick
));
77 xCalcTreeView
->set_sort_func([this](const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
){
78 return ColCompare(rLeft
, rRight
);
80 pTreeView
= xCalcTreeView
.get();
84 void SvxRedlinTable::set_size_request(int nWidth
, int nHeight
)
87 xWriterTreeView
->set_size_request(nWidth
, nHeight
);
89 xCalcTreeView
->set_size_request(nWidth
, nHeight
);
92 SvxRedlinTable::~SvxRedlinTable()
96 IMPL_LINK(SvxRedlinTable
, HeaderBarClick
, int, nColumn
, void)
100 pTreeView
->make_sorted();
104 bool bSortAtoZ
= pTreeView
->get_sort_order();
106 //set new arrow positions in headerbar
107 if (nColumn
== pTreeView
->get_sort_column())
109 bSortAtoZ
= !bSortAtoZ
;
110 pTreeView
->set_sort_order(bSortAtoZ
);
114 int nOldSortColumn
= pTreeView
->get_sort_column();
115 if (nOldSortColumn
!= -1)
116 pTreeView
->set_sort_indicator(TRISTATE_INDET
, nOldSortColumn
);
117 pTreeView
->set_sort_column(nColumn
);
123 pTreeView
->set_sort_indicator(bSortAtoZ
? TRISTATE_TRUE
: TRISTATE_FALSE
, nColumn
);
127 int SvxRedlinTable::ColCompare(const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
)
129 sal_Int32 nCompare
= 0;
131 int nSortCol
= pTreeView
->get_sort_column();
133 if (pTreeView
== xWriterTreeView
.get() && nSortCol
== 0)
135 RedlinData
*pLeftData
= reinterpret_cast<RedlinData
*>(pTreeView
->get_id(rLeft
).toInt64());
136 RedlinData
*pRightData
= reinterpret_cast<RedlinData
*>(pTreeView
->get_id(rRight
).toInt64());
138 if (pLeftData
&& pRightData
)
140 if (pLeftData
->eType
< pRightData
->eType
)
142 else if (pLeftData
->eType
> pRightData
->eType
)
148 if (nSortCol
== nDatePos
)
150 RedlinData
*pLeftData
= reinterpret_cast<RedlinData
*>(pTreeView
->get_id(rLeft
).toInt64());
151 RedlinData
*pRightData
= reinterpret_cast<RedlinData
*>(pTreeView
->get_id(rRight
).toInt64());
153 if (pLeftData
&& pRightData
)
155 if (pLeftData
->aDateTime
< pRightData
->aDateTime
)
157 else if (pLeftData
->aDateTime
> pRightData
->aDateTime
)
163 return xSorter
->compare(pTreeView
->get_text(rLeft
, nSortCol
),
164 pTreeView
->get_text(rRight
, nSortCol
));
167 void SvxRedlinTable::UpdateFilterTest()
169 Date
aDateMax( Date::SYSTEM
);
170 aDateMax
.AddYears(100);
171 Date
aDateMin(1,1,1989);
172 tools::Time
aTMin(0);
173 tools::Time
aTMax(23,59,59);
175 DateTime
aDTMin(aDateMin
);
176 DateTime
aDTMax(aDateMax
);
180 case SvxRedlinDateMode::BEFORE
:
181 aDaTiFilterFirst
=aDTMin
;
182 aDaTiFilterLast
=aDaTiFirst
;
184 case SvxRedlinDateMode::SAVE
:
185 case SvxRedlinDateMode::SINCE
:
186 aDaTiFilterFirst
=aDaTiFirst
;
187 aDaTiFilterLast
=aDTMax
;
189 case SvxRedlinDateMode::EQUAL
:
190 aDaTiFilterFirst
=aDaTiFirst
;
191 aDaTiFilterLast
=aDaTiFirst
;
192 aDaTiFilterFirst
.SetTime(aTMin
.GetTime());
193 aDaTiFilterLast
.SetTime(aTMax
.GetTime());
195 case SvxRedlinDateMode::NOTEQUAL
:
196 aDaTiFilterFirst
=aDaTiFirst
;
197 aDaTiFilterLast
=aDaTiFirst
;
198 aDaTiFilterFirst
.SetTime(aTMin
.GetTime());
199 aDaTiFilterLast
.SetTime(aTMax
.GetTime());
201 case SvxRedlinDateMode::BETWEEN
:
202 aDaTiFilterFirst
=aDaTiFirst
;
203 aDaTiFilterLast
=aDaTiLast
;
205 case SvxRedlinDateMode::NONE
:
210 void SvxRedlinTable::SetFilterDate(bool bFlag
)
215 void SvxRedlinTable::SetDateTimeMode(SvxRedlinDateMode nMode
)
220 void SvxRedlinTable::SetFirstDate(const Date
& aDate
)
222 aDaTiFirst
.SetDate(aDate
.GetDate());
225 void SvxRedlinTable::SetLastDate(const Date
& aDate
)
227 aDaTiLast
.SetDate(aDate
.GetDate());
230 void SvxRedlinTable::SetFirstTime(const tools::Time
& aTime
)
232 aDaTiFirst
.SetTime(aTime
.GetTime());
235 void SvxRedlinTable::SetLastTime(const tools::Time
& aTime
)
237 aDaTiLast
.SetTime(aTime
.GetTime());
240 void SvxRedlinTable::SetFilterAuthor(bool bFlag
)
245 void SvxRedlinTable::SetAuthor(const OUString
&aString
)
250 void SvxRedlinTable::SetFilterComment(bool bFlag
)
255 void SvxRedlinTable::SetCommentParams( const utl::SearchParam
* pSearchPara
)
257 if(pSearchPara
!=nullptr)
259 pCommentSearcher
.reset(new utl::TextSearch(*pSearchPara
, LANGUAGE_SYSTEM
));
263 bool SvxRedlinTable::IsValidEntry(const OUString
&rAuthorStr
,
264 const DateTime
&rDateTime
,
265 const OUString
&rCommentStr
)
267 return IsValidEntry(rAuthorStr
, rDateTime
) && IsValidComment(rCommentStr
);
270 bool SvxRedlinTable::IsValidEntry(const OUString
&rAuthorStr
, const DateTime
&rDateTime
)
272 if (bAuthor
&& aAuthor
!=rAuthorStr
)
278 const bool bRes
= rDateTime
.IsBetween(aDaTiFilterFirst
, aDaTiFilterLast
);
279 return nDaTiMode
!=SvxRedlinDateMode::NOTEQUAL
? bRes
: !bRes
;
282 bool SvxRedlinTable::IsValidComment(const OUString
&rCommentStr
)
287 sal_Int32 nStartPos
= 0;
288 sal_Int32 nEndPos
= rCommentStr
.getLength();
289 return pCommentSearcher
->SearchForward( rCommentStr
, &nStartPos
, &nEndPos
);
292 SvxTPage::~SvxTPage()
296 void SvxTPage::ActivatePage()
300 SvxTPView::SvxTPView(weld::Container
* pParent
, weld::Window
* pDialog
, weld::Builder
* pTopLevel
)
301 : SvxTPage(pParent
, "svx/ui/redlineviewpage.ui", "RedlineViewPage")
302 , bEnableAccept(true)
303 , bEnableAcceptAll(true)
304 , bEnableReject(true)
305 , bEnableRejectAll(true)
307 , bEnableClearFormat(false)
308 , bEnableClearFormatAll(false)
310 , m_xAccept(pTopLevel
->weld_button("accept"))
311 , m_xReject(pTopLevel
->weld_button("reject"))
312 , m_xAcceptAll(pTopLevel
->weld_button("acceptall"))
313 , m_xRejectAll(pTopLevel
->weld_button("rejectall"))
314 , m_xUndo(pTopLevel
->weld_button("undo"))
315 , m_xViewData(new SvxRedlinTable(m_xBuilder
->weld_tree_view("writerchanges"),
316 m_xBuilder
->weld_tree_view("calcchanges")))
318 Size
aControlSize(80, 65);
319 m_xViewData
->set_size_request(aControlSize
.Width(), aControlSize
.Height());
321 Link
<weld::Button
&,void> aLink
=LINK( this, SvxTPView
, PbClickHdl
);
323 m_xAccept
->connect_clicked(aLink
);
324 m_xAcceptAll
->connect_clicked(aLink
);
325 m_xReject
->connect_clicked(aLink
);
326 m_xRejectAll
->connect_clicked(aLink
);
327 m_xUndo
->connect_clicked(aLink
);
330 void SvxTPView::ActivatePage()
332 m_xAccept
->set_sensitive(bEnableAccept
);
333 m_xReject
->set_sensitive(bEnableReject
);
334 m_xAcceptAll
->set_sensitive(bEnableAcceptAll
);
335 m_xRejectAll
->set_sensitive(bEnableRejectAll
);
336 m_xUndo
->set_sensitive(bEnableUndo
);
339 void SvxTPView::DeactivatePage()
341 m_xAccept
->set_sensitive(false);
342 m_xReject
->set_sensitive(false);
343 m_xAcceptAll
->set_sensitive(false);
344 m_xRejectAll
->set_sensitive(false);
345 m_xUndo
->set_sensitive(false);
348 SvxTPView::~SvxTPView()
352 void SvxRedlinTable::SetWriterView()
354 nDatePos
= WRITER_DATE
;
356 xCalcTreeView
->hide();
357 xWriterTreeView
->show();
358 pTreeView
= xWriterTreeView
.get();
360 auto nDigitWidth
= pTreeView
->get_approximate_digit_width();
361 std::vector
<int> aWidths
;
362 aWidths
.push_back(nDigitWidth
* 10);
363 aWidths
.push_back(nDigitWidth
* 20);
364 aWidths
.push_back(nDigitWidth
* 20);
365 pTreeView
->set_column_fixed_widths(aWidths
);
368 void SvxRedlinTable::SetCalcView()
370 nDatePos
= CALC_DATE
;
372 xWriterTreeView
->hide();
373 xCalcTreeView
->show();
374 pTreeView
= xCalcTreeView
.get();
376 auto nDigitWidth
= pTreeView
->get_approximate_digit_width();
377 std::vector
<int> aWidths
;
378 aWidths
.push_back(nDigitWidth
* 20);
379 aWidths
.push_back(nDigitWidth
* 20);
380 aWidths
.push_back(nDigitWidth
* 20);
381 aWidths
.push_back(nDigitWidth
* 20);
382 pTreeView
->set_column_fixed_widths(aWidths
);
385 void SvxTPView::EnableAccept(bool bFlag
)
387 bEnableAccept
= bFlag
;
388 m_xAccept
->set_sensitive(bFlag
);
391 void SvxTPView::EnableAcceptAll(bool bFlag
)
393 bEnableAcceptAll
= bFlag
;
394 m_xAcceptAll
->set_sensitive(bFlag
);
397 void SvxTPView::EnableReject(bool bFlag
)
399 bEnableReject
= bFlag
;
400 m_xReject
->set_sensitive(bFlag
);
403 void SvxTPView::EnableRejectAll(bool bFlag
)
405 bEnableRejectAll
= bFlag
;
406 m_xRejectAll
->set_sensitive(bFlag
);
409 void SvxTPView::EnableClearFormatButton(weld::Button
& rButton
, bool bFlag
)
411 OUString sText
= rButton
.get_label();
412 OUString sClearFormat
= SvxResId(RID_SVXSTR_CLEARFORM
);
413 sal_Int32 nPos
= sText
.indexOf(sClearFormat
);
415 // add or remove "Clear formatting" to get "Reject" or "Reject/Clear formatting"
420 rButton
.set_label(sText
+ "/" + sClearFormat
);
427 rButton
.set_label(sText
.copy(0, nPos
- 1));
433 // tdf#127218 allow dialog to shrink
434 m_pDialog
->resize_to_request();
438 void SvxTPView::EnableClearFormat(bool bFlag
)
440 if (bEnableClearFormat
== bFlag
)
442 EnableClearFormatButton(*m_xReject
, bFlag
);
443 bEnableClearFormat
= bFlag
;
446 void SvxTPView::EnableClearFormatAll(bool bFlag
)
448 if (bEnableClearFormatAll
== bFlag
)
450 EnableClearFormatButton(*m_xRejectAll
, bFlag
);
451 bEnableClearFormatAll
= bFlag
;
454 void SvxTPView::ShowUndo()
459 void SvxTPView::EnableUndo(bool bFlag
)
462 m_xUndo
->set_sensitive(bFlag
);
465 IMPL_LINK( SvxTPView
, PbClickHdl
, weld::Button
&, rPushB
, void)
467 if (&rPushB
== m_xAccept
.get())
469 AcceptClickLk
.Call(this);
471 else if (&rPushB
== m_xAcceptAll
.get())
473 AcceptAllClickLk
.Call(this);
475 else if (&rPushB
== m_xReject
.get())
477 RejectClickLk
.Call(this);
479 else if (&rPushB
== m_xRejectAll
.get())
481 RejectAllClickLk
.Call(this);
483 else if (&rPushB
== m_xUndo
.get())
485 UndoClickLk
.Call(this);
489 SvxTPage::SvxTPage(weld::Container
* pParent
, const OUString
& rUIXMLDescription
, const OString
& rID
)
490 : m_xBuilder(Application::CreateBuilder(pParent
, rUIXMLDescription
))
491 , m_xContainer(m_xBuilder
->weld_container(rID
))
495 SvxTPFilter::SvxTPFilter(weld::Container
* pParent
)
496 : SvxTPage(pParent
, "svx/ui/redlinefilterpage.ui", "RedlineFilterPage")
498 , m_pRedlinTable(nullptr)
499 , m_xCbDate(m_xBuilder
->weld_check_button("date"))
500 , m_xLbDate(m_xBuilder
->weld_combo_box("datecond"))
501 , m_xDfDate(new SvtCalendarBox(m_xBuilder
->weld_menu_button("startdate")))
502 , m_xTfDate(m_xBuilder
->weld_formatted_spin_button("starttime"))
503 , m_xTfDateFormatter(new weld::TimeFormatter(*m_xTfDate
))
504 , m_xIbClock(m_xBuilder
->weld_button("startclock"))
505 , m_xFtDate2(m_xBuilder
->weld_label("and"))
506 , m_xDfDate2(new SvtCalendarBox(m_xBuilder
->weld_menu_button("enddate")))
507 , m_xTfDate2(m_xBuilder
->weld_formatted_spin_button("endtime"))
508 , m_xTfDate2Formatter(new weld::TimeFormatter(*m_xTfDate2
))
509 , m_xIbClock2(m_xBuilder
->weld_button("endclock"))
510 , m_xCbAuthor(m_xBuilder
->weld_check_button("author"))
511 , m_xLbAuthor(m_xBuilder
->weld_combo_box("authorlist"))
512 , m_xCbRange(m_xBuilder
->weld_check_button("range"))
513 , m_xEdRange(m_xBuilder
->weld_entry("rangeedit"))
514 , m_xBtnRange(m_xBuilder
->weld_button("dotdotdot"))
515 , m_xCbAction(m_xBuilder
->weld_check_button("action"))
516 , m_xLbAction(m_xBuilder
->weld_combo_box("actionlist"))
517 , m_xCbComment(m_xBuilder
->weld_check_button("comment"))
518 , m_xEdComment(m_xBuilder
->weld_entry("commentedit"))
520 m_xTfDateFormatter
->EnableEmptyField(false);
521 m_xTfDate2Formatter
->EnableEmptyField(false);
523 m_xLbDate
->set_active(0);
524 m_xLbDate
->connect_changed( LINK( this, SvxTPFilter
, SelDateHdl
) );
525 m_xIbClock
->connect_clicked( LINK( this, SvxTPFilter
, TimeHdl
) );
526 m_xIbClock2
->connect_clicked( LINK( this, SvxTPFilter
,TimeHdl
) );
527 m_xBtnRange
->connect_clicked( LINK( this, SvxTPFilter
, RefHandle
));
529 Link
<weld::Button
&,void> aLink
=LINK( this, SvxTPFilter
, RowEnableHdl
) ;
530 m_xCbDate
->connect_clicked(aLink
);
531 m_xCbAuthor
->connect_clicked(aLink
);
532 m_xCbRange
->connect_clicked(aLink
);
533 m_xCbAction
->connect_clicked(aLink
);
534 m_xCbComment
->connect_clicked(aLink
);
536 Link
<SvtCalendarBox
&,void> a2Link
=LINK(this, SvxTPFilter
, ModifyDate
);
537 m_xDfDate
->connect_activated(a2Link
);
538 m_xDfDate2
->connect_activated(a2Link
);
540 Link
<weld::FormattedSpinButton
&,void> a3Link
=LINK(this, SvxTPFilter
, ModifyTime
);
541 m_xTfDate
->connect_value_changed(a3Link
);
542 m_xTfDate2
->connect_value_changed(a3Link
);
544 Link
<weld::Entry
&,void> a4Link
=LINK( this, SvxTPFilter
, ModifyHdl
);
545 m_xEdRange
->connect_changed(a4Link
);
546 m_xEdComment
->connect_changed(a4Link
);
547 m_xLbAction
->connect_changed(LINK( this, SvxTPFilter
, ModifyListBoxHdl
));
548 m_xLbAuthor
->connect_changed(LINK( this, SvxTPFilter
, ModifyListBoxHdl
));
550 RowEnableHdl(*m_xCbDate
);
551 RowEnableHdl(*m_xCbAuthor
);
552 RowEnableHdl(*m_xCbRange
);
553 RowEnableHdl(*m_xCbAction
);
554 RowEnableHdl(*m_xCbComment
);
556 DateTime
aDateTime(DateTime::SYSTEM
);
557 SetFirstDate(aDateTime
);
558 SetLastDate(aDateTime
);
559 SetFirstTime(aDateTime
);
560 SetLastTime(aDateTime
);
566 SvxTPFilter::~SvxTPFilter()
570 void SvxTPFilter::SetRedlinTable(SvxRedlinTable
* pTable
)
572 m_pRedlinTable
= pTable
;
575 void SvxTPFilter::EnableDateLine1(bool bFlag
)
577 if(bFlag
&& m_xCbDate
->get_active())
579 m_xDfDate
->set_sensitive(true);
580 m_xTfDate
->set_sensitive(true);
581 m_xIbClock
->set_sensitive(true);
585 m_xDfDate
->set_sensitive(false);
586 m_xTfDate
->set_sensitive(false);
587 m_xIbClock
->set_sensitive(false);
590 void SvxTPFilter::EnableDateLine2(bool bFlag
)
592 if(bFlag
&& m_xCbDate
->get_active())
594 m_xFtDate2
->set_sensitive(true);
595 m_xDfDate2
->set_sensitive(true);
596 m_xTfDate2
->set_sensitive(true);
597 m_xIbClock2
->set_sensitive(true);
601 m_xFtDate2
->set_sensitive(false);
602 m_xDfDate2
->set_sensitive(false);
603 m_xDfDate2
->set_label(OUString());
604 m_xTfDate2
->set_sensitive(false);
605 m_xTfDate2
->set_text(OUString());
606 m_xIbClock2
->set_sensitive(false);
610 Date
SvxTPFilter::GetFirstDate() const
612 return m_xDfDate
->get_date();
615 void SvxTPFilter::SetFirstDate(const Date
&aDate
)
617 m_xDfDate
->set_date(aDate
);
620 tools::Time
SvxTPFilter::GetFirstTime() const
622 return m_xTfDateFormatter
->GetTime();
625 void SvxTPFilter::SetFirstTime(const tools::Time
&aTime
)
627 m_xTfDateFormatter
->SetTime(aTime
);
630 Date
SvxTPFilter::GetLastDate() const
632 return m_xDfDate2
->get_date();
635 void SvxTPFilter::SetLastDate(const Date
&aDate
)
637 m_xDfDate2
->set_date(aDate
);
640 tools::Time
SvxTPFilter::GetLastTime() const
642 return m_xTfDate2Formatter
->GetTime();
645 void SvxTPFilter::SetLastTime(const tools::Time
&aTime
)
647 m_xTfDate2Formatter
->SetTime(aTime
);
650 void SvxTPFilter::SetDateMode(sal_uInt16 nMode
)
652 m_xLbDate
->set_active(nMode
);
653 SelDateHdl(*m_xLbDate
);
656 SvxRedlinDateMode
SvxTPFilter::GetDateMode() const
658 return static_cast<SvxRedlinDateMode
>(m_xLbDate
->get_active());
660 void SvxTPFilter::ClearAuthors()
662 m_xLbAuthor
->clear();
665 void SvxTPFilter::InsertAuthor( const OUString
& rString
)
667 m_xLbAuthor
->append_text(rString
);
670 OUString
SvxTPFilter::GetSelectedAuthor() const
672 return m_xLbAuthor
->get_active_text();
675 void SvxTPFilter::SelectedAuthorPos(sal_Int32 nPos
)
677 m_xLbAuthor
->set_active(nPos
);
680 sal_Int32
SvxTPFilter::SelectAuthor(const OUString
& aString
)
682 m_xLbAuthor
->set_active_text(aString
);
683 return m_xLbAuthor
->get_active();
686 void SvxTPFilter::SetRange(const OUString
& rString
)
688 m_xEdRange
->set_text(rString
);
691 OUString
SvxTPFilter::GetRange() const
693 return m_xEdRange
->get_text();
696 void SvxTPFilter::SetFocusToRange()
698 m_xEdRange
->grab_focus();
701 void SvxTPFilter::HideRange(bool bHide
)
718 void SvxTPFilter::SetComment(const OUString
&rComment
)
720 m_xEdComment
->set_text(rComment
);
723 OUString
SvxTPFilter::GetComment()const
725 return m_xEdComment
->get_text();
728 bool SvxTPFilter::IsDate() const
730 return m_xCbDate
->get_active();
733 bool SvxTPFilter::IsAuthor() const
735 return m_xCbAuthor
->get_active();
738 bool SvxTPFilter::IsRange() const
740 return m_xCbRange
->get_active();
743 bool SvxTPFilter::IsAction() const
745 return m_xCbAction
->get_active();
748 bool SvxTPFilter::IsComment() const
750 return m_xCbComment
->get_active();
753 void SvxTPFilter::CheckDate(bool bFlag
)
755 m_xCbDate
->set_active(bFlag
);
756 RowEnableHdl(*m_xCbDate
);
760 void SvxTPFilter::CheckAuthor(bool bFlag
)
762 m_xCbAuthor
->set_active(bFlag
);
763 RowEnableHdl(*m_xCbAuthor
);
767 void SvxTPFilter::CheckRange(bool bFlag
)
769 m_xCbRange
->set_active(bFlag
);
770 RowEnableHdl(*m_xCbRange
);
774 void SvxTPFilter::CheckAction(bool bFlag
)
776 m_xCbAction
->set_active(bFlag
);
777 RowEnableHdl(*m_xCbAction
);
781 void SvxTPFilter::CheckComment(bool bFlag
)
783 m_xCbComment
->set_active(bFlag
);
784 RowEnableHdl(*m_xCbComment
);
788 void SvxTPFilter::ShowAction(bool bShow
)
803 IMPL_LINK_NOARG(SvxTPFilter
, SelDateHdl
, weld::ComboBox
&, void)
805 SvxRedlinDateMode nKind
= static_cast<SvxRedlinDateMode
>(m_xLbDate
->get_active());
808 case SvxRedlinDateMode::BEFORE
:
809 EnableDateLine1(true);
810 EnableDateLine2(false);
812 case SvxRedlinDateMode::SINCE
:
813 EnableDateLine1(true);
814 EnableDateLine2(false);
816 case SvxRedlinDateMode::EQUAL
:
817 EnableDateLine1(true);
818 m_xTfDate
->set_sensitive(false);
819 m_xTfDate
->set_text(OUString());
820 EnableDateLine2(false);
822 case SvxRedlinDateMode::NOTEQUAL
:
823 EnableDateLine1(true);
824 m_xTfDate
->set_sensitive(false);
825 m_xTfDate
->set_text(OUString());
826 EnableDateLine2(false);
828 case SvxRedlinDateMode::BETWEEN
:
829 EnableDateLine1(true);
830 EnableDateLine2(true);
832 case SvxRedlinDateMode::SAVE
:
833 EnableDateLine1(false);
834 EnableDateLine2(false);
836 case SvxRedlinDateMode::NONE
:
842 IMPL_LINK(SvxTPFilter
, RowEnableHdl
, weld::Button
&, rCB
, void)
844 if (&rCB
== m_xCbDate
.get())
846 m_xLbDate
->set_sensitive(m_xCbDate
->get_active());
847 EnableDateLine1(false);
848 EnableDateLine2(false);
849 if(m_xCbDate
->get_active()) SelDateHdl(*m_xLbDate
);
851 else if (&rCB
== m_xCbAuthor
.get())
853 m_xLbAuthor
->set_sensitive(m_xCbAuthor
->get_active());
855 else if (&rCB
== m_xCbRange
.get())
857 m_xEdRange
->set_sensitive(m_xCbRange
->get_active());
858 m_xBtnRange
->set_sensitive(m_xCbRange
->get_active());
860 else if (&rCB
== m_xCbAction
.get())
862 m_xLbAction
->set_sensitive(m_xCbAction
->get_active());
864 else if (&rCB
== m_xCbComment
.get())
866 m_xEdComment
->set_sensitive(m_xCbComment
->get_active());
871 IMPL_LINK(SvxTPFilter
, TimeHdl
, weld::Button
&, rIB
, void)
873 DateTime
aDateTime( DateTime::SYSTEM
);
874 if (&rIB
== m_xIbClock
.get())
876 SetFirstDate(aDateTime
);
877 SetFirstTime(aDateTime
);
879 else if (&rIB
== m_xIbClock2
.get())
881 SetLastDate(aDateTime
);
882 SetLastTime(aDateTime
);
887 IMPL_LINK_NOARG(SvxTPFilter
, ModifyHdl
, weld::Entry
&, void)
892 IMPL_LINK_NOARG(SvxTPFilter
, ModifyListBoxHdl
, weld::ComboBox
&, void)
897 void SvxTPFilter::DeactivatePage()
903 m_pRedlinTable
->SetFilterDate(IsDate());
904 m_pRedlinTable
->SetDateTimeMode(GetDateMode());
905 m_pRedlinTable
->SetFirstDate(GetFirstDate());
906 m_pRedlinTable
->SetLastDate(GetLastDate());
907 m_pRedlinTable
->SetFirstTime(GetFirstTime());
908 m_pRedlinTable
->SetLastTime(GetLastTime());
909 m_pRedlinTable
->SetFilterAuthor(IsAuthor());
910 m_pRedlinTable
->SetAuthor(GetSelectedAuthor());
912 m_pRedlinTable
->SetFilterComment(IsComment());
914 utl::SearchParam
aSearchParam( m_xEdComment
->get_text(),
915 utl::SearchParam::SearchType::Regexp
,false );
917 m_pRedlinTable
->SetCommentParams(&aSearchParam
);
919 m_pRedlinTable
->UpdateFilterTest();
922 aReadyLink
.Call(this);
927 void SvxTPFilter::Enable(bool bEnable
)
929 m_xContainer
->set_sensitive(bEnable
);
930 if (m_xCbDate
->get_sensitive())
932 RowEnableHdl(*m_xCbDate
);
933 RowEnableHdl(*m_xCbAuthor
);
934 RowEnableHdl(*m_xCbRange
);
935 RowEnableHdl(*m_xCbComment
);
939 IMPL_LINK(SvxTPFilter
, ModifyDate
, SvtCalendarBox
&, rTF
, void)
941 Date
aDate( Date::SYSTEM
);
942 if (m_xDfDate
.get() == &rTF
)
944 if (m_xDfDate
->get_label().isEmpty())
945 m_xDfDate
->set_date(aDate
);
947 if(m_pRedlinTable
!=nullptr)
948 m_pRedlinTable
->SetFirstDate(m_xDfDate
->get_date());
950 else if (m_xDfDate2
.get() == &rTF
)
952 if (m_xDfDate2
->get_label().isEmpty())
953 m_xDfDate2
->set_date(aDate
);
956 m_pRedlinTable
->SetLastDate(m_xDfDate2
->get_date());
961 IMPL_LINK(SvxTPFilter
, ModifyTime
, weld::FormattedSpinButton
&, rTF
, void)
963 tools::Time
aTime(0);
964 if (m_xTfDate
.get() == &rTF
)
966 if (m_xTfDate
->get_text().isEmpty())
969 if (m_pRedlinTable
!=nullptr)
970 m_pRedlinTable
->SetFirstTime(GetFirstTime());
972 else if (m_xTfDate2
.get() == &rTF
)
974 if (m_xTfDate2
->get_text().isEmpty())
977 if (m_pRedlinTable
!=nullptr)
978 m_pRedlinTable
->SetLastTime(GetLastTime());
984 IMPL_LINK_NOARG(SvxTPFilter
, RefHandle
, weld::Button
&, void)
989 SvxAcceptChgCtr::SvxAcceptChgCtr(weld::Container
* pParent
, weld::Window
* pDialog
, weld::Builder
* pTopLevel
)
990 : m_xBuilder(Application::CreateBuilder(pParent
, "svx/ui/redlinecontrol.ui"))
991 , m_xTabCtrl(m_xBuilder
->weld_notebook("tabcontrol"))
993 m_xTabCtrl
->connect_enter_page(LINK(this, SvxAcceptChgCtr
, ActivatePageHdl
));
994 m_xTabCtrl
->connect_leave_page(LINK(this, SvxAcceptChgCtr
, DeactivatePageHdl
));
996 m_xTPFilter
.reset(new SvxTPFilter(m_xTabCtrl
->get_page("filter")));
997 m_xTPView
.reset(new SvxTPView(m_xTabCtrl
->get_page("view"), pDialog
, pTopLevel
));
998 m_xTPFilter
->SetRedlinTable(m_xTPView
->GetTableControl());
999 m_xTabCtrl
->set_current_page("view");
1003 SvxAcceptChgCtr::~SvxAcceptChgCtr()
1007 void SvxAcceptChgCtr::ShowFilterPage()
1009 m_xTabCtrl
->set_current_page("filter");
1012 IMPL_LINK(SvxAcceptChgCtr
, ActivatePageHdl
, const OString
&, rPage
, void)
1014 if (rPage
== "filter")
1015 m_xTPFilter
->ActivatePage();
1016 else if (rPage
== "view")
1017 m_xTPView
->ActivatePage();
1020 IMPL_LINK(SvxAcceptChgCtr
, DeactivatePageHdl
, const OString
&, rPage
, bool)
1022 if (rPage
== "filter")
1023 m_xTPFilter
->DeactivatePage();
1024 else if (rPage
== "view")
1025 m_xTPView
->DeactivatePage();
1029 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */