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 <o3tl/safeint.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/settings.hxx>
26 #include <vcl/weldutils.hxx>
27 #include <svtools/ctrlbox.hxx>
28 #include <unotools/textsearch.hxx>
32 #include <svx/ctredlin.hxx>
37 RedlinData::RedlinData()
38 : aDateTime(DateTime::EMPTY
)
40 , eType(RedlineType::Any
)
45 RedlinData::~RedlinData()
49 SvxRedlinTable::SvxRedlinTable(std::unique_ptr
<weld::TreeView
> xWriterControl
,
50 std::unique_ptr
<weld::TreeView
> xCalcControl
)
51 : xSorter(new comphelper::string::NaturalStringSorter(::comphelper::getProcessComponentContext(),
52 Application::GetSettings().GetUILanguageTag().getLocale()))
53 , xWriterTreeView(std::move(xWriterControl
))
54 , xCalcTreeView(std::move(xCalcControl
))
56 , nDatePos(WRITER_DATE
)
61 , nDaTiMode(SvxRedlinDateMode::BEFORE
)
62 , aDaTiFirst( DateTime::EMPTY
)
63 , aDaTiLast( DateTime::EMPTY
)
64 , aDaTiFilterFirst( DateTime::EMPTY
)
65 , aDaTiFilterLast( DateTime::EMPTY
)
69 xWriterTreeView
->set_size_request(-1, xWriterTreeView
->get_height_rows(8));
70 xWriterTreeView
->connect_column_clicked(LINK(this, SvxRedlinTable
, HeaderBarClick
));
71 xWriterTreeView
->set_sort_func([this](const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
){
72 return ColCompare(rLeft
, rRight
);
74 pTreeView
= xWriterTreeView
.get();
78 xCalcTreeView
->set_size_request(-1, xCalcTreeView
->get_height_rows(8));
79 xCalcTreeView
->connect_column_clicked(LINK(this, SvxRedlinTable
, HeaderBarClick
));
80 xCalcTreeView
->set_sort_func([this](const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
){
81 return ColCompare(rLeft
, rRight
);
83 pTreeView
= xCalcTreeView
.get();
87 SvxRedlinTable::~SvxRedlinTable()
91 IMPL_LINK(SvxRedlinTable
, HeaderBarClick
, int, nColumn
, void)
95 pTreeView
->make_sorted();
99 bool bSortAtoZ
= pTreeView
->get_sort_order();
101 //set new arrow positions in headerbar
102 if (nColumn
== pTreeView
->get_sort_column())
104 bSortAtoZ
= !bSortAtoZ
;
105 pTreeView
->set_sort_order(bSortAtoZ
);
109 int nOldSortColumn
= pTreeView
->get_sort_column();
110 if (nOldSortColumn
!= -1)
111 pTreeView
->set_sort_indicator(TRISTATE_INDET
, nOldSortColumn
);
112 pTreeView
->set_sort_column(nColumn
);
118 pTreeView
->set_sort_indicator(bSortAtoZ
? TRISTATE_TRUE
: TRISTATE_FALSE
, nColumn
);
122 int SvxRedlinTable::ColCompare(const weld::TreeIter
& rLeft
, const weld::TreeIter
& rRight
)
124 sal_Int32 nCompare
= 0;
126 int nSortCol
= pTreeView
->get_sort_column();
128 if (pTreeView
== xWriterTreeView
.get() && nSortCol
== 0)
130 RedlinData
*pLeftData
= weld::fromId
<RedlinData
*>(pTreeView
->get_id(rLeft
));
131 RedlinData
*pRightData
= weld::fromId
<RedlinData
*>(pTreeView
->get_id(rRight
));
133 if (pLeftData
&& pRightData
)
135 if (pLeftData
->eType
< pRightData
->eType
)
137 else if (pLeftData
->eType
> pRightData
->eType
)
143 if (nSortCol
== nDatePos
)
145 RedlinData
*pLeftData
= weld::fromId
<RedlinData
*>(pTreeView
->get_id(rLeft
));
146 RedlinData
*pRightData
= weld::fromId
<RedlinData
*>(pTreeView
->get_id(rRight
));
148 if (pLeftData
&& pRightData
)
150 if (pLeftData
->aDateTime
< pRightData
->aDateTime
)
152 else if (pLeftData
->aDateTime
> pRightData
->aDateTime
)
158 return xSorter
->compare(pTreeView
->get_text(rLeft
, nSortCol
),
159 pTreeView
->get_text(rRight
, nSortCol
));
162 void SvxRedlinTable::UpdateFilterTest()
164 Date
aDateMax( Date::SYSTEM
);
165 aDateMax
.AddYears(100);
166 Date
aDateMin(1,1,1989);
167 tools::Time
aTMin(0);
168 tools::Time
aTMax(23,59,59);
170 DateTime
aDTMin(aDateMin
);
171 DateTime
aDTMax(aDateMax
);
175 case SvxRedlinDateMode::BEFORE
:
176 aDaTiFilterFirst
=aDTMin
;
177 aDaTiFilterLast
=aDaTiFirst
;
179 case SvxRedlinDateMode::SAVE
:
180 case SvxRedlinDateMode::SINCE
:
181 aDaTiFilterFirst
=aDaTiFirst
;
182 aDaTiFilterLast
=aDTMax
;
184 case SvxRedlinDateMode::EQUAL
:
185 aDaTiFilterFirst
=aDaTiFirst
;
186 aDaTiFilterLast
=aDaTiFirst
;
187 aDaTiFilterFirst
.SetTime(aTMin
.GetTime());
188 aDaTiFilterLast
.SetTime(aTMax
.GetTime());
190 case SvxRedlinDateMode::NOTEQUAL
:
191 aDaTiFilterFirst
=aDaTiFirst
;
192 aDaTiFilterLast
=aDaTiFirst
;
193 aDaTiFilterFirst
.SetTime(aTMin
.GetTime());
194 aDaTiFilterLast
.SetTime(aTMax
.GetTime());
196 case SvxRedlinDateMode::BETWEEN
:
197 aDaTiFilterFirst
=aDaTiFirst
;
198 aDaTiFilterLast
=aDaTiLast
;
200 case SvxRedlinDateMode::NONE
:
205 void SvxRedlinTable::SetFilterDate(bool bFlag
)
210 void SvxRedlinTable::SetDateTimeMode(SvxRedlinDateMode nMode
)
215 void SvxRedlinTable::SetFirstDate(const Date
& aDate
)
217 aDaTiFirst
.SetDate(aDate
.GetDate());
220 void SvxRedlinTable::SetLastDate(const Date
& aDate
)
222 aDaTiLast
.SetDate(aDate
.GetDate());
225 void SvxRedlinTable::SetFirstTime(const tools::Time
& aTime
)
227 aDaTiFirst
.SetTime(aTime
.GetTime());
230 void SvxRedlinTable::SetLastTime(const tools::Time
& aTime
)
232 aDaTiLast
.SetTime(aTime
.GetTime());
235 void SvxRedlinTable::SetFilterAuthor(bool bFlag
)
240 void SvxRedlinTable::SetAuthor(const OUString
&aString
)
245 void SvxRedlinTable::SetFilterComment(bool bFlag
)
250 void SvxRedlinTable::SetCommentParams( const utl::SearchParam
* pSearchPara
)
252 if(pSearchPara
!=nullptr)
254 pCommentSearcher
.reset(new utl::TextSearch(*pSearchPara
, LANGUAGE_SYSTEM
));
258 bool SvxRedlinTable::IsValidEntry(std::u16string_view rAuthorStr
,
259 const DateTime
&rDateTime
,
260 const OUString
&rCommentStr
)
262 return IsValidEntry(rAuthorStr
, rDateTime
) && IsValidComment(rCommentStr
);
265 bool SvxRedlinTable::IsValidEntry(std::u16string_view rAuthorStr
, const DateTime
&rDateTime
)
267 if (bAuthor
&& aAuthor
!=rAuthorStr
)
273 const bool bRes
= rDateTime
.IsBetween(aDaTiFilterFirst
, aDaTiFilterLast
);
274 return nDaTiMode
!=SvxRedlinDateMode::NOTEQUAL
? bRes
: !bRes
;
277 bool SvxRedlinTable::IsValidComment(const OUString
&rCommentStr
)
282 sal_Int32 nStartPos
= 0;
283 sal_Int32 nEndPos
= rCommentStr
.getLength();
284 return pCommentSearcher
->SearchForward( rCommentStr
, &nStartPos
, &nEndPos
);
287 SvxTPage::~SvxTPage()
291 void SvxTPage::ActivatePage()
295 SvxTPView::SvxTPView(weld::Container
* pParent
)
296 : SvxTPage(pParent
, "svx/ui/redlineviewpage.ui", "RedlineViewPage")
297 , bEnableAccept(true)
298 , bEnableAcceptAll(true)
299 , bEnableReject(true)
300 , bEnableRejectAll(true)
302 , bEnableClearFormat(false)
303 , bEnableClearFormatAll(false)
304 , m_xAccept(m_xBuilder
->weld_button("accept"))
305 , m_xReject(m_xBuilder
->weld_button("reject"))
306 , m_xAcceptAll(m_xBuilder
->weld_button("acceptall"))
307 , m_xRejectAll(m_xBuilder
->weld_button("rejectall"))
308 , m_xUndo(m_xBuilder
->weld_button("undo"))
309 , m_xViewData(new SvxRedlinTable(m_xBuilder
->weld_tree_view("writerchanges"),
310 m_xBuilder
->weld_tree_view("calcchanges")))
312 Link
<weld::Button
&,void> aLink
=LINK( this, SvxTPView
, PbClickHdl
);
314 m_xAccept
->connect_clicked(aLink
);
315 m_xAcceptAll
->connect_clicked(aLink
);
316 m_xReject
->connect_clicked(aLink
);
317 m_xRejectAll
->connect_clicked(aLink
);
318 m_xUndo
->connect_clicked(aLink
);
321 void SvxTPView::ActivatePage()
323 m_xAccept
->set_sensitive(bEnableAccept
);
324 m_xReject
->set_sensitive(bEnableReject
);
325 m_xAcceptAll
->set_sensitive(bEnableAcceptAll
);
326 m_xRejectAll
->set_sensitive(bEnableRejectAll
);
327 m_xUndo
->set_sensitive(bEnableUndo
);
330 void SvxTPView::DeactivatePage()
332 m_xAccept
->set_sensitive(false);
333 m_xReject
->set_sensitive(false);
334 m_xAcceptAll
->set_sensitive(false);
335 m_xRejectAll
->set_sensitive(false);
336 m_xUndo
->set_sensitive(false);
339 SvxTPView::~SvxTPView()
343 void SvxRedlinTable::SetWriterView()
345 nDatePos
= WRITER_DATE
;
347 xCalcTreeView
->hide();
348 xWriterTreeView
->show();
349 pTreeView
= xWriterTreeView
.get();
351 auto nDigitWidth
= pTreeView
->get_approximate_digit_width();
352 std::vector
<int> aWidths
354 o3tl::narrowing
<int>(nDigitWidth
* 10),
355 o3tl::narrowing
<int>(nDigitWidth
* 20),
356 o3tl::narrowing
<int>(nDigitWidth
* 20)
358 pTreeView
->set_column_fixed_widths(aWidths
);
361 void SvxRedlinTable::SetCalcView()
363 nDatePos
= CALC_DATE
;
365 xWriterTreeView
->hide();
366 xCalcTreeView
->show();
367 pTreeView
= xCalcTreeView
.get();
369 auto nDigitWidth
= pTreeView
->get_approximate_digit_width();
370 std::vector
<int> aWidths
372 o3tl::narrowing
<int>(nDigitWidth
* 20),
373 o3tl::narrowing
<int>(nDigitWidth
* 20),
374 o3tl::narrowing
<int>(nDigitWidth
* 20),
375 o3tl::narrowing
<int>(nDigitWidth
* 20)
377 pTreeView
->set_column_fixed_widths(aWidths
);
380 void SvxTPView::EnableAccept(bool bFlag
)
382 bEnableAccept
= bFlag
;
383 m_xAccept
->set_sensitive(bFlag
);
386 void SvxTPView::EnableAcceptAll(bool bFlag
)
388 bEnableAcceptAll
= bFlag
;
389 m_xAcceptAll
->set_sensitive(bFlag
);
392 void SvxTPView::EnableReject(bool bFlag
)
394 bEnableReject
= bFlag
;
395 m_xReject
->set_sensitive(bFlag
);
398 void SvxTPView::EnableRejectAll(bool bFlag
)
400 bEnableRejectAll
= bFlag
;
401 m_xRejectAll
->set_sensitive(bFlag
);
404 void SvxTPView::EnableClearFormat(bool bFlag
)
406 if (bEnableClearFormat
== bFlag
)
408 bEnableClearFormat
= bFlag
;
411 void SvxTPView::EnableClearFormatAll(bool bFlag
)
413 if (bEnableClearFormatAll
== bFlag
)
415 bEnableClearFormatAll
= bFlag
;
418 void SvxTPView::ShowUndo()
423 void SvxTPView::EnableUndo(bool bFlag
)
426 m_xUndo
->set_sensitive(bFlag
);
429 IMPL_LINK( SvxTPView
, PbClickHdl
, weld::Button
&, rPushB
, void)
431 if (&rPushB
== m_xAccept
.get())
433 AcceptClickLk
.Call(this);
435 else if (&rPushB
== m_xAcceptAll
.get())
437 AcceptAllClickLk
.Call(this);
439 else if (&rPushB
== m_xReject
.get())
441 RejectClickLk
.Call(this);
443 else if (&rPushB
== m_xRejectAll
.get())
445 RejectAllClickLk
.Call(this);
447 else if (&rPushB
== m_xUndo
.get())
449 UndoClickLk
.Call(this);
453 SvxTPage::SvxTPage(weld::Container
* pParent
, const OUString
& rUIXMLDescription
, const OUString
& rID
)
454 : m_xBuilder(Application::CreateBuilder(pParent
, rUIXMLDescription
))
455 , m_xContainer(m_xBuilder
->weld_container(rID
))
459 SvxTPFilter::SvxTPFilter(weld::Container
* pParent
)
460 : SvxTPage(pParent
, "svx/ui/redlinefilterpage.ui", "RedlineFilterPage")
462 , m_pRedlinTable(nullptr)
463 , m_xCbDate(m_xBuilder
->weld_check_button("date"))
464 , m_xLbDate(m_xBuilder
->weld_combo_box("datecond"))
465 , m_xDfDate(new SvtCalendarBox(m_xBuilder
->weld_menu_button("startdate")))
466 , m_xTfDate(m_xBuilder
->weld_formatted_spin_button("starttime"))
467 , m_xTfDateFormatter(new weld::TimeFormatter(*m_xTfDate
))
468 , m_xIbClock(m_xBuilder
->weld_button("startclock"))
469 , m_xFtDate2(m_xBuilder
->weld_label("and"))
470 , m_xDfDate2(new SvtCalendarBox(m_xBuilder
->weld_menu_button("enddate")))
471 , m_xTfDate2(m_xBuilder
->weld_formatted_spin_button("endtime"))
472 , m_xTfDate2Formatter(new weld::TimeFormatter(*m_xTfDate2
))
473 , m_xIbClock2(m_xBuilder
->weld_button("endclock"))
474 , m_xCbAuthor(m_xBuilder
->weld_check_button("author"))
475 , m_xLbAuthor(m_xBuilder
->weld_combo_box("authorlist"))
476 , m_xCbRange(m_xBuilder
->weld_check_button("range"))
477 , m_xEdRange(m_xBuilder
->weld_entry("rangeedit"))
478 , m_xBtnRange(m_xBuilder
->weld_button("dotdotdot"))
479 , m_xCbAction(m_xBuilder
->weld_check_button("action"))
480 , m_xLbAction(m_xBuilder
->weld_combo_box("actionlist"))
481 , m_xCbComment(m_xBuilder
->weld_check_button("comment"))
482 , m_xEdComment(m_xBuilder
->weld_entry("commentedit"))
484 m_xTfDateFormatter
->EnableEmptyField(false);
485 m_xTfDate2Formatter
->EnableEmptyField(false);
487 m_xLbDate
->set_active(0);
488 m_xLbDate
->connect_changed( LINK( this, SvxTPFilter
, SelDateHdl
) );
489 m_xIbClock
->connect_clicked( LINK( this, SvxTPFilter
, TimeHdl
) );
490 m_xIbClock2
->connect_clicked( LINK( this, SvxTPFilter
,TimeHdl
) );
491 m_xBtnRange
->connect_clicked( LINK( this, SvxTPFilter
, RefHandle
));
493 Link
<weld::Toggleable
&,void> aLink
=LINK( this, SvxTPFilter
, RowEnableHdl
) ;
494 m_xCbDate
->connect_toggled(aLink
);
495 m_xCbAuthor
->connect_toggled(aLink
);
496 m_xCbRange
->connect_toggled(aLink
);
497 m_xCbAction
->connect_toggled(aLink
);
498 m_xCbComment
->connect_toggled(aLink
);
500 Link
<SvtCalendarBox
&,void> a2Link
=LINK(this, SvxTPFilter
, ModifyDate
);
501 m_xDfDate
->connect_activated(a2Link
);
502 m_xDfDate2
->connect_activated(a2Link
);
504 Link
<weld::FormattedSpinButton
&,void> a3Link
=LINK(this, SvxTPFilter
, ModifyTime
);
505 m_xTfDate
->connect_value_changed(a3Link
);
506 m_xTfDate2
->connect_value_changed(a3Link
);
508 Link
<weld::Entry
&,void> a4Link
=LINK( this, SvxTPFilter
, ModifyHdl
);
509 m_xEdRange
->connect_changed(a4Link
);
510 m_xEdComment
->connect_changed(a4Link
);
511 m_xLbAction
->connect_changed(LINK( this, SvxTPFilter
, ModifyListBoxHdl
));
512 m_xLbAuthor
->connect_changed(LINK( this, SvxTPFilter
, ModifyListBoxHdl
));
514 RowEnableHdl(*m_xCbDate
);
515 RowEnableHdl(*m_xCbAuthor
);
516 RowEnableHdl(*m_xCbRange
);
517 RowEnableHdl(*m_xCbAction
);
518 RowEnableHdl(*m_xCbComment
);
520 DateTime
aDateTime(DateTime::SYSTEM
);
521 SetFirstDate(aDateTime
);
522 SetLastDate(aDateTime
);
523 SetFirstTime(aDateTime
);
524 SetLastTime(aDateTime
);
530 SvxTPFilter::~SvxTPFilter()
534 void SvxTPFilter::SetRedlinTable(SvxRedlinTable
* pTable
)
536 m_pRedlinTable
= pTable
;
539 void SvxTPFilter::EnableDateLine1(bool bFlag
)
541 if(bFlag
&& m_xCbDate
->get_active())
543 m_xDfDate
->set_sensitive(true);
544 m_xTfDate
->set_sensitive(true);
545 m_xIbClock
->set_sensitive(true);
549 m_xDfDate
->set_sensitive(false);
550 m_xTfDate
->set_sensitive(false);
551 m_xIbClock
->set_sensitive(false);
554 void SvxTPFilter::EnableDateLine2(bool bFlag
)
556 if(bFlag
&& m_xCbDate
->get_active())
558 m_xFtDate2
->set_sensitive(true);
559 m_xDfDate2
->set_sensitive(true);
560 m_xTfDate2
->set_sensitive(true);
561 m_xIbClock2
->set_sensitive(true);
565 m_xFtDate2
->set_sensitive(false);
566 m_xDfDate2
->set_sensitive(false);
567 m_xDfDate2
->set_label(OUString());
568 m_xTfDate2
->set_sensitive(false);
569 m_xTfDate2
->set_text(OUString());
570 m_xIbClock2
->set_sensitive(false);
574 Date
SvxTPFilter::GetFirstDate() const
576 return m_xDfDate
->get_date();
579 void SvxTPFilter::SetFirstDate(const Date
&aDate
)
581 m_xDfDate
->set_date(aDate
);
584 tools::Time
SvxTPFilter::GetFirstTime() const
586 return m_xTfDateFormatter
->GetTime();
589 void SvxTPFilter::SetFirstTime(const tools::Time
&aTime
)
591 m_xTfDateFormatter
->SetTime(aTime
);
594 Date
SvxTPFilter::GetLastDate() const
596 return m_xDfDate2
->get_date();
599 void SvxTPFilter::SetLastDate(const Date
&aDate
)
601 m_xDfDate2
->set_date(aDate
);
604 tools::Time
SvxTPFilter::GetLastTime() const
606 return m_xTfDate2Formatter
->GetTime();
609 void SvxTPFilter::SetLastTime(const tools::Time
&aTime
)
611 m_xTfDate2Formatter
->SetTime(aTime
);
614 void SvxTPFilter::SetDateMode(sal_uInt16 nMode
)
616 m_xLbDate
->set_active(nMode
);
617 SelDateHdl(*m_xLbDate
);
620 SvxRedlinDateMode
SvxTPFilter::GetDateMode() const
622 return static_cast<SvxRedlinDateMode
>(m_xLbDate
->get_active());
624 void SvxTPFilter::ClearAuthors()
626 m_xLbAuthor
->clear();
629 void SvxTPFilter::InsertAuthor( const OUString
& rString
)
631 m_xLbAuthor
->append_text(rString
);
634 OUString
SvxTPFilter::GetSelectedAuthor() const
636 return m_xLbAuthor
->get_active_text();
639 void SvxTPFilter::SelectedAuthorPos(sal_Int32 nPos
)
641 m_xLbAuthor
->set_active(nPos
);
644 sal_Int32
SvxTPFilter::SelectAuthor(const OUString
& aString
)
646 m_xLbAuthor
->set_active_text(aString
);
647 return m_xLbAuthor
->get_active();
650 void SvxTPFilter::SetRange(const OUString
& rString
)
652 m_xEdRange
->set_text(rString
);
655 OUString
SvxTPFilter::GetRange() const
657 return m_xEdRange
->get_text();
660 void SvxTPFilter::SetFocusToRange()
662 m_xEdRange
->grab_focus();
665 void SvxTPFilter::HideRange(bool bHide
)
682 void SvxTPFilter::SetComment(const OUString
&rComment
)
684 m_xEdComment
->set_text(rComment
);
687 OUString
SvxTPFilter::GetComment()const
689 return m_xEdComment
->get_text();
692 bool SvxTPFilter::IsDate() const
694 return m_xCbDate
->get_active();
697 bool SvxTPFilter::IsAuthor() const
699 return m_xCbAuthor
->get_active();
702 bool SvxTPFilter::IsRange() const
704 return m_xCbRange
->get_active();
707 bool SvxTPFilter::IsAction() const
709 return m_xCbAction
->get_active();
712 bool SvxTPFilter::IsComment() const
714 return m_xCbComment
->get_active();
717 void SvxTPFilter::CheckDate(bool bFlag
)
719 m_xCbDate
->set_active(bFlag
);
720 RowEnableHdl(*m_xCbDate
);
724 void SvxTPFilter::CheckAuthor(bool bFlag
)
726 m_xCbAuthor
->set_active(bFlag
);
727 RowEnableHdl(*m_xCbAuthor
);
731 void SvxTPFilter::CheckRange(bool bFlag
)
733 m_xCbRange
->set_active(bFlag
);
734 RowEnableHdl(*m_xCbRange
);
738 void SvxTPFilter::CheckAction(bool bFlag
)
740 m_xCbAction
->set_active(bFlag
);
741 RowEnableHdl(*m_xCbAction
);
745 void SvxTPFilter::CheckComment(bool bFlag
)
747 m_xCbComment
->set_active(bFlag
);
748 RowEnableHdl(*m_xCbComment
);
752 void SvxTPFilter::ShowAction(bool bShow
)
767 IMPL_LINK_NOARG(SvxTPFilter
, SelDateHdl
, weld::ComboBox
&, void)
769 SvxRedlinDateMode nKind
= static_cast<SvxRedlinDateMode
>(m_xLbDate
->get_active());
772 case SvxRedlinDateMode::BEFORE
:
773 EnableDateLine1(true);
774 EnableDateLine2(false);
776 case SvxRedlinDateMode::SINCE
:
777 EnableDateLine1(true);
778 EnableDateLine2(false);
780 case SvxRedlinDateMode::EQUAL
:
781 EnableDateLine1(true);
782 m_xTfDate
->set_sensitive(false);
783 m_xTfDate
->set_text(OUString());
784 EnableDateLine2(false);
786 case SvxRedlinDateMode::NOTEQUAL
:
787 EnableDateLine1(true);
788 m_xTfDate
->set_sensitive(false);
789 m_xTfDate
->set_text(OUString());
790 EnableDateLine2(false);
792 case SvxRedlinDateMode::BETWEEN
:
793 EnableDateLine1(true);
794 EnableDateLine2(true);
796 case SvxRedlinDateMode::SAVE
:
797 EnableDateLine1(false);
798 EnableDateLine2(false);
800 case SvxRedlinDateMode::NONE
:
806 IMPL_LINK(SvxTPFilter
, RowEnableHdl
, weld::Toggleable
&, rCB
, void)
808 if (&rCB
== m_xCbDate
.get())
810 m_xLbDate
->set_sensitive(m_xCbDate
->get_active());
811 EnableDateLine1(false);
812 EnableDateLine2(false);
813 if(m_xCbDate
->get_active()) SelDateHdl(*m_xLbDate
);
815 else if (&rCB
== m_xCbAuthor
.get())
817 m_xLbAuthor
->set_sensitive(m_xCbAuthor
->get_active());
819 else if (&rCB
== m_xCbRange
.get())
821 m_xEdRange
->set_sensitive(m_xCbRange
->get_active());
822 m_xBtnRange
->set_sensitive(m_xCbRange
->get_active());
824 else if (&rCB
== m_xCbAction
.get())
826 m_xLbAction
->set_sensitive(m_xCbAction
->get_active());
828 else if (&rCB
== m_xCbComment
.get())
830 m_xEdComment
->set_sensitive(m_xCbComment
->get_active());
835 IMPL_LINK(SvxTPFilter
, TimeHdl
, weld::Button
&, rIB
, void)
837 DateTime
aDateTime( DateTime::SYSTEM
);
838 if (&rIB
== m_xIbClock
.get())
840 SetFirstDate(aDateTime
);
841 SetFirstTime(aDateTime
);
843 else if (&rIB
== m_xIbClock2
.get())
845 SetLastDate(aDateTime
);
846 SetLastTime(aDateTime
);
851 IMPL_LINK_NOARG(SvxTPFilter
, ModifyHdl
, weld::Entry
&, void)
856 IMPL_LINK_NOARG(SvxTPFilter
, ModifyListBoxHdl
, weld::ComboBox
&, void)
861 void SvxTPFilter::DeactivatePage()
867 m_pRedlinTable
->SetFilterDate(IsDate());
868 m_pRedlinTable
->SetDateTimeMode(GetDateMode());
869 m_pRedlinTable
->SetFirstDate(GetFirstDate());
870 m_pRedlinTable
->SetLastDate(GetLastDate());
871 m_pRedlinTable
->SetFirstTime(GetFirstTime());
872 m_pRedlinTable
->SetLastTime(GetLastTime());
873 m_pRedlinTable
->SetFilterAuthor(IsAuthor());
874 m_pRedlinTable
->SetAuthor(GetSelectedAuthor());
876 m_pRedlinTable
->SetFilterComment(IsComment());
878 utl::SearchParam
aSearchParam( m_xEdComment
->get_text(),
879 utl::SearchParam::SearchType::Regexp
,false );
881 m_pRedlinTable
->SetCommentParams(&aSearchParam
);
883 m_pRedlinTable
->UpdateFilterTest();
886 aReadyLink
.Call(this);
891 void SvxTPFilter::Enable(bool bEnable
)
893 m_xContainer
->set_sensitive(bEnable
);
894 if (m_xCbDate
->get_sensitive())
896 RowEnableHdl(*m_xCbDate
);
897 RowEnableHdl(*m_xCbAuthor
);
898 RowEnableHdl(*m_xCbRange
);
899 RowEnableHdl(*m_xCbComment
);
903 IMPL_LINK(SvxTPFilter
, ModifyDate
, SvtCalendarBox
&, rTF
, void)
905 Date
aDate( Date::SYSTEM
);
906 if (m_xDfDate
.get() == &rTF
)
908 if (m_xDfDate
->get_label().isEmpty())
909 m_xDfDate
->set_date(aDate
);
911 if(m_pRedlinTable
!=nullptr)
912 m_pRedlinTable
->SetFirstDate(m_xDfDate
->get_date());
914 else if (m_xDfDate2
.get() == &rTF
)
916 if (m_xDfDate2
->get_label().isEmpty())
917 m_xDfDate2
->set_date(aDate
);
920 m_pRedlinTable
->SetLastDate(m_xDfDate2
->get_date());
925 IMPL_LINK(SvxTPFilter
, ModifyTime
, weld::FormattedSpinButton
&, rTF
, void)
927 tools::Time
aTime(0);
928 if (m_xTfDate
.get() == &rTF
)
930 if (m_xTfDate
->get_text().isEmpty())
933 if (m_pRedlinTable
!=nullptr)
934 m_pRedlinTable
->SetFirstTime(GetFirstTime());
936 else if (m_xTfDate2
.get() == &rTF
)
938 if (m_xTfDate2
->get_text().isEmpty())
941 if (m_pRedlinTable
!=nullptr)
942 m_pRedlinTable
->SetLastTime(GetLastTime());
948 IMPL_LINK_NOARG(SvxTPFilter
, RefHandle
, weld::Button
&, void)
953 SvxAcceptChgCtr::SvxAcceptChgCtr(weld::Container
* pParent
)
954 : m_xBuilder(Application::CreateBuilder(pParent
, "svx/ui/redlinecontrol.ui"))
955 , m_xTabCtrl(m_xBuilder
->weld_notebook("tabcontrol"))
957 m_xTabCtrl
->connect_enter_page(LINK(this, SvxAcceptChgCtr
, ActivatePageHdl
));
958 m_xTabCtrl
->connect_leave_page(LINK(this, SvxAcceptChgCtr
, DeactivatePageHdl
));
960 m_xTPFilter
.reset(new SvxTPFilter(m_xTabCtrl
->get_page("filter")));
961 m_xTPView
.reset(new SvxTPView(m_xTabCtrl
->get_page("view")));
962 m_xTPFilter
->SetRedlinTable(m_xTPView
->GetTableControl());
963 m_xTabCtrl
->set_current_page("view");
964 m_xTabCtrl
->set_help_id(HID_REDLINE_CTRL_VIEW
);
968 SvxAcceptChgCtr::~SvxAcceptChgCtr()
974 void SvxAcceptChgCtr::ShowFilterPage()
976 m_xTabCtrl
->set_current_page("filter");
979 IMPL_LINK(SvxAcceptChgCtr
, ActivatePageHdl
, const OUString
&, rPage
, void)
981 if (rPage
== "filter")
983 m_xTPFilter
->ActivatePage();
984 m_xTabCtrl
->set_help_id(HID_REDLINE_CTRL_FILTER
);
986 else if (rPage
== "view")
988 m_xTPView
->ActivatePage();
989 m_xTabCtrl
->set_help_id(HID_REDLINE_CTRL_VIEW
);
993 IMPL_LINK(SvxAcceptChgCtr
, DeactivatePageHdl
, const OUString
&, rPage
, bool)
995 if (rPage
== "filter")
996 m_xTPFilter
->DeactivatePage();
997 else if (rPage
== "view")
998 m_xTPView
->DeactivatePage();
1002 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */