Bump version to 6.4.7.2.M8
[LibreOffice.git] / svx / source / dialog / ctredlin.cxx
blobf3243e0d1b4c5d4fa562bda43cfc819ddcce367e
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 #include <comphelper/processfactory.hxx>
21 #include <comphelper/string.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/settings.hxx>
24 #include <sfx2/app.hxx>
25 #include <sfx2/module.hxx>
26 #include <svtools/ctrlbox.hxx>
27 #include <unotools/textsearch.hxx>
28 #include <unotools/charclass.hxx>
30 #include <editeng/unolingu.hxx>
31 #include <svx/ctredlin.hxx>
32 #include <svx/dialmgr.hxx>
33 #include <svx/strings.hrc>
35 #define WRITER_DATE 2
36 #define CALC_DATE 3
38 RedlinData::RedlinData()
39 : aDateTime(DateTime::EMPTY)
40 , pData(nullptr)
41 , eType(RedlineType::Any)
42 , bDisabled(false)
46 RedlinData::~RedlinData()
50 SvxRedlinTable::SvxRedlinTable(std::unique_ptr<weld::TreeView> xWriterControl,
51 std::unique_ptr<weld::TreeView> xCalcControl)
52 : xSorter(new comphelper::string::NaturalStringSorter(::comphelper::getProcessComponentContext(),
53 Application::GetSettings().GetUILanguageTag().getLocale()))
54 , xWriterTreeView(std::move(xWriterControl))
55 , xCalcTreeView(std::move(xCalcControl))
56 , pTreeView(nullptr)
57 , nDatePos(WRITER_DATE)
58 , bAuthor(false)
59 , bDate(false)
60 , bComment(false)
61 , bSorted(false)
62 , nDaTiMode(SvxRedlinDateMode::BEFORE)
63 , aDaTiFirst( DateTime::EMPTY )
64 , aDaTiLast( DateTime::EMPTY )
65 , aDaTiFilterFirst( DateTime::EMPTY )
66 , aDaTiFilterLast( DateTime::EMPTY )
68 if (xWriterTreeView)
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);
73 });
74 pTreeView = xWriterTreeView.get();
76 if (xCalcTreeView)
78 xCalcTreeView->connect_column_clicked(LINK(this, SvxRedlinTable, HeaderBarClick));
79 xCalcTreeView->set_sort_func([this](const weld::TreeIter& rLeft, const weld::TreeIter& rRight){
80 return ColCompare(rLeft, rRight);
81 });
82 pTreeView = xCalcTreeView.get();
86 void SvxRedlinTable::set_size_request(int nWidth, int nHeight)
88 if (xWriterTreeView)
89 xWriterTreeView->set_size_request(nWidth, nHeight);
90 if (xCalcTreeView)
91 xCalcTreeView->set_size_request(nWidth, nHeight);
94 SvxRedlinTable::~SvxRedlinTable()
98 IMPL_LINK(SvxRedlinTable, HeaderBarClick, int, nColumn, void)
100 if (!bSorted)
102 pTreeView->make_sorted();
103 bSorted = true;
106 bool bSortAtoZ = pTreeView->get_sort_order();
108 //set new arrow positions in headerbar
109 if (nColumn == pTreeView->get_sort_column())
111 bSortAtoZ = !bSortAtoZ;
112 pTreeView->set_sort_order(bSortAtoZ);
114 else
116 int nOldSortColumn = pTreeView->get_sort_column();
117 if (nOldSortColumn != -1)
118 pTreeView->set_sort_indicator(TRISTATE_INDET, nOldSortColumn);
119 pTreeView->set_sort_column(nColumn);
122 if (nColumn != -1)
124 //sort lists
125 pTreeView->set_sort_indicator(bSortAtoZ ? TRISTATE_TRUE : TRISTATE_FALSE, nColumn);
129 int SvxRedlinTable::ColCompare(const weld::TreeIter& rLeft, const weld::TreeIter& rRight)
131 sal_Int32 nCompare = 0;
133 int nSortCol = pTreeView->get_sort_column();
135 if (pTreeView == xWriterTreeView.get() && nSortCol == 0)
137 RedlinData *pLeftData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rLeft).toInt64());
138 RedlinData *pRightData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rRight).toInt64());
140 if (pLeftData && pRightData)
142 if (pLeftData->eType < pRightData->eType)
143 nCompare = -1;
144 else if (pLeftData->eType > pRightData->eType)
145 nCompare = 1;
146 return nCompare;
150 if (nSortCol == nDatePos)
152 RedlinData *pLeftData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rLeft).toInt64());
153 RedlinData *pRightData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rRight).toInt64());
155 if (pLeftData && pRightData)
157 if (pLeftData->aDateTime < pRightData->aDateTime)
158 nCompare = -1;
159 else if (pLeftData->aDateTime > pRightData->aDateTime)
160 nCompare = 1;
161 return nCompare;
165 return xSorter->compare(pTreeView->get_text(rLeft, nSortCol),
166 pTreeView->get_text(rRight, nSortCol));
169 void SvxRedlinTable::UpdateFilterTest()
171 Date aDateMax( Date::SYSTEM );
172 aDateMax.AddYears(100);
173 Date aDateMin(1,1,1989);
174 tools::Time aTMin(0);
175 tools::Time aTMax(23,59,59);
177 DateTime aDTMin(aDateMin);
178 DateTime aDTMax(aDateMax);
180 switch(nDaTiMode)
182 case SvxRedlinDateMode::BEFORE:
183 aDaTiFilterFirst=aDTMin;
184 aDaTiFilterLast=aDaTiFirst;
185 break;
186 case SvxRedlinDateMode::SAVE:
187 case SvxRedlinDateMode::SINCE:
188 aDaTiFilterFirst=aDaTiFirst;
189 aDaTiFilterLast=aDTMax;
190 break;
191 case SvxRedlinDateMode::EQUAL:
192 aDaTiFilterFirst=aDaTiFirst;
193 aDaTiFilterLast=aDaTiFirst;
194 aDaTiFilterFirst.SetTime(aTMin.GetTime());
195 aDaTiFilterLast.SetTime(aTMax.GetTime());
196 break;
197 case SvxRedlinDateMode::NOTEQUAL:
198 aDaTiFilterFirst=aDaTiFirst;
199 aDaTiFilterLast=aDaTiFirst;
200 aDaTiFilterFirst.SetTime(aTMin.GetTime());
201 aDaTiFilterLast.SetTime(aTMax.GetTime());
202 break;
203 case SvxRedlinDateMode::BETWEEN:
204 aDaTiFilterFirst=aDaTiFirst;
205 aDaTiFilterLast=aDaTiLast;
206 break;
207 case SvxRedlinDateMode::NONE:
208 break;
212 void SvxRedlinTable::SetFilterDate(bool bFlag)
214 bDate=bFlag;
217 void SvxRedlinTable::SetDateTimeMode(SvxRedlinDateMode nMode)
219 nDaTiMode=nMode;
222 void SvxRedlinTable::SetFirstDate(const Date& aDate)
224 aDaTiFirst.SetDate(aDate.GetDate());
227 void SvxRedlinTable::SetLastDate(const Date& aDate)
229 aDaTiLast.SetDate(aDate.GetDate());
232 void SvxRedlinTable::SetFirstTime(const tools::Time& aTime)
234 aDaTiFirst.SetTime(aTime.GetTime());
237 void SvxRedlinTable::SetLastTime(const tools::Time& aTime)
239 aDaTiLast.SetTime(aTime.GetTime());
242 void SvxRedlinTable::SetFilterAuthor(bool bFlag)
244 bAuthor=bFlag;
247 void SvxRedlinTable::SetAuthor(const OUString &aString)
249 aAuthor=aString;
252 void SvxRedlinTable::SetFilterComment(bool bFlag)
254 bComment=bFlag;
257 void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
259 if(pSearchPara!=nullptr)
261 pCommentSearcher.reset(new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM ));
265 bool SvxRedlinTable::IsValidEntry(const OUString &rAuthorStr,
266 const DateTime &rDateTime,
267 const OUString &rCommentStr)
269 return IsValidEntry(rAuthorStr, rDateTime) && IsValidComment(rCommentStr);
272 bool SvxRedlinTable::IsValidEntry(const OUString &rAuthorStr, const DateTime &rDateTime)
274 if (bAuthor && aAuthor!=rAuthorStr)
275 return false;
277 if (!bDate)
278 return true;
280 const bool bRes = rDateTime.IsBetween(aDaTiFilterFirst, aDaTiFilterLast);
281 return nDaTiMode!=SvxRedlinDateMode::NOTEQUAL ? bRes : !bRes;
284 bool SvxRedlinTable::IsValidComment(const OUString &rCommentStr)
286 if (!bComment)
287 return true;
289 sal_Int32 nStartPos = 0;
290 sal_Int32 nEndPos = rCommentStr.getLength();
291 return pCommentSearcher->SearchForward( rCommentStr, &nStartPos, &nEndPos);
294 SvxTPage::~SvxTPage()
298 void SvxTPage::ActivatePage()
302 SvxTPView::SvxTPView(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel)
303 : SvxTPage(pParent, "svx/ui/redlineviewpage.ui", "RedlineViewPage")
304 , bEnableAccept(true)
305 , bEnableAcceptAll(true)
306 , bEnableReject(true)
307 , bEnableRejectAll(true)
308 , bEnableUndo(true)
309 , bEnableClearFormat(false)
310 , bEnableClearFormatAll(false)
311 , m_pDialog(pDialog)
312 , m_xAccept(pTopLevel->weld_button("accept"))
313 , m_xReject(pTopLevel->weld_button("reject"))
314 , m_xAcceptAll(pTopLevel->weld_button("acceptall"))
315 , m_xRejectAll(pTopLevel->weld_button("rejectall"))
316 , m_xUndo(pTopLevel->weld_button("undo"))
317 , m_xViewData(new SvxRedlinTable(m_xBuilder->weld_tree_view("writerchanges"),
318 m_xBuilder->weld_tree_view("calcchanges")))
320 Size aControlSize(80, 65);
321 m_xViewData->set_size_request(aControlSize.Width(), aControlSize.Height());
323 Link<weld::Button&,void> aLink=LINK( this, SvxTPView, PbClickHdl);
325 m_xAccept->connect_clicked(aLink);
326 m_xAcceptAll->connect_clicked(aLink);
327 m_xReject->connect_clicked(aLink);
328 m_xRejectAll->connect_clicked(aLink);
329 m_xUndo->connect_clicked(aLink);
332 void SvxTPView::ActivatePage()
334 m_xAccept->set_sensitive(bEnableAccept);
335 m_xReject->set_sensitive(bEnableReject);
336 m_xAcceptAll->set_sensitive(bEnableAcceptAll);
337 m_xRejectAll->set_sensitive(bEnableRejectAll);
338 m_xUndo->set_sensitive(bEnableUndo);
341 void SvxTPView::DeactivatePage()
343 m_xAccept->set_sensitive(false);
344 m_xReject->set_sensitive(false);
345 m_xAcceptAll->set_sensitive(false);
346 m_xRejectAll->set_sensitive(false);
347 m_xUndo->set_sensitive(false);
350 SvxTPView::~SvxTPView()
354 void SvxRedlinTable::SetWriterView()
356 nDatePos = WRITER_DATE;
357 if (xCalcTreeView)
358 xCalcTreeView->hide();
359 xWriterTreeView->show();
360 pTreeView = xWriterTreeView.get();
362 auto nDigitWidth = pTreeView->get_approximate_digit_width();
363 std::vector<int> aWidths;
364 aWidths.push_back(nDigitWidth * 10);
365 aWidths.push_back(nDigitWidth * 20);
366 aWidths.push_back(nDigitWidth * 20);
367 pTreeView->set_column_fixed_widths(aWidths);
370 void SvxRedlinTable::SetCalcView()
372 nDatePos = CALC_DATE;
373 if (xWriterTreeView)
374 xWriterTreeView->hide();
375 xCalcTreeView->show();
376 pTreeView = xCalcTreeView.get();
378 auto nDigitWidth = pTreeView->get_approximate_digit_width();
379 std::vector<int> aWidths;
380 aWidths.push_back(nDigitWidth * 20);
381 aWidths.push_back(nDigitWidth * 20);
382 aWidths.push_back(nDigitWidth * 20);
383 aWidths.push_back(nDigitWidth * 20);
384 pTreeView->set_column_fixed_widths(aWidths);
387 void SvxTPView::EnableAccept(bool bFlag)
389 bEnableAccept = bFlag;
390 m_xAccept->set_sensitive(bFlag);
393 void SvxTPView::EnableAcceptAll(bool bFlag)
395 bEnableAcceptAll = bFlag;
396 m_xAcceptAll->set_sensitive(bFlag);
399 void SvxTPView::EnableReject(bool bFlag)
401 bEnableReject = bFlag;
402 m_xReject->set_sensitive(bFlag);
405 void SvxTPView::EnableRejectAll(bool bFlag)
407 bEnableRejectAll = bFlag;
408 m_xRejectAll->set_sensitive(bFlag);
411 void SvxTPView::EnableClearFormatButton(weld::Button& rButton, bool bFlag)
413 OUString sText = rButton.get_label();
414 OUString sClearFormat = SvxResId(RID_SVXSTR_CLEARFORM);
415 sal_Int32 nPos = sText.indexOf(sClearFormat);
417 // add or remove "Clear formatting" to get "Reject" or "Reject/Clear formatting"
418 if (bFlag)
420 if (nPos == -1)
422 rButton.set_label(sText + "/" + sClearFormat);
425 else
427 if (nPos > 0)
429 rButton.set_label(sText.copy(0, nPos - 1));
433 if (m_pDialog)
435 // tdf#127218 allow dialog to shrink
436 m_pDialog->resize_to_request();
440 void SvxTPView::EnableClearFormat(bool bFlag)
442 if (bEnableClearFormat == bFlag)
443 return;
444 EnableClearFormatButton(*m_xReject, bFlag);
445 bEnableClearFormat = bFlag;
448 void SvxTPView::EnableClearFormatAll(bool bFlag)
450 if (bEnableClearFormatAll == bFlag)
451 return;
452 EnableClearFormatButton(*m_xRejectAll, bFlag);
453 bEnableClearFormatAll = bFlag;
456 void SvxTPView::ShowUndo()
458 m_xUndo->show();
461 void SvxTPView::EnableUndo(bool bFlag)
463 bEnableUndo = bFlag;
464 m_xUndo->set_sensitive(bFlag);
467 IMPL_LINK( SvxTPView, PbClickHdl, weld::Button&, rPushB, void)
469 if (&rPushB == m_xAccept.get())
471 AcceptClickLk.Call(this);
473 else if (&rPushB == m_xAcceptAll.get())
475 AcceptAllClickLk.Call(this);
477 else if (&rPushB == m_xReject.get())
479 RejectClickLk.Call(this);
481 else if (&rPushB == m_xRejectAll.get())
483 RejectAllClickLk.Call(this);
485 else if (&rPushB == m_xUndo.get())
487 UndoClickLk.Call(this);
491 SvxTPage::SvxTPage(weld::Container* pParent, const OUString& rUIXMLDescription, const OString& rID)
492 : m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription))
493 , m_xContainer(m_xBuilder->weld_container(rID))
497 SvxTPFilter::SvxTPFilter(weld::Container* pParent)
498 : SvxTPage(pParent, "svx/ui/redlinefilterpage.ui", "RedlineFilterPage")
499 , bModified(false)
500 , m_pRedlinTable(nullptr)
501 , m_xCbDate(m_xBuilder->weld_check_button("date"))
502 , m_xLbDate(m_xBuilder->weld_combo_box("datecond"))
503 , m_xDfDate(new SvtCalendarBox(m_xBuilder->weld_menu_button("startdate")))
504 , m_xTfDate(m_xBuilder->weld_time_spin_button("starttime", TimeFieldFormat::F_NONE))
505 , m_xIbClock(m_xBuilder->weld_button("startclock"))
506 , m_xFtDate2(m_xBuilder->weld_label("and"))
507 , m_xDfDate2(new SvtCalendarBox(m_xBuilder->weld_menu_button("enddate")))
508 , m_xTfDate2(m_xBuilder->weld_time_spin_button("endtime", TimeFieldFormat::F_NONE))
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_xLbDate->set_active(0);
521 m_xLbDate->connect_changed( LINK( this, SvxTPFilter, SelDateHdl ) );
522 m_xIbClock->connect_clicked( LINK( this, SvxTPFilter, TimeHdl) );
523 m_xIbClock2->connect_clicked( LINK( this, SvxTPFilter,TimeHdl) );
524 m_xBtnRange->connect_clicked( LINK( this, SvxTPFilter, RefHandle));
526 Link<weld::Button&,void> aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
527 m_xCbDate->connect_clicked(aLink);
528 m_xCbAuthor->connect_clicked(aLink);
529 m_xCbRange->connect_clicked(aLink);
530 m_xCbAction->connect_clicked(aLink);
531 m_xCbComment->connect_clicked(aLink);
533 Link<SvtCalendarBox&,void> a2Link=LINK(this, SvxTPFilter, ModifyDate);
534 m_xDfDate->connect_activated(a2Link);
535 m_xDfDate2->connect_activated(a2Link);
537 Link<weld::TimeSpinButton&,void> a3Link=LINK(this, SvxTPFilter, ModifyTime);
538 m_xTfDate->connect_value_changed(a3Link);
539 m_xTfDate2->connect_value_changed(a3Link);
541 Link<weld::Entry&,void> a4Link=LINK( this, SvxTPFilter, ModifyHdl);
542 m_xEdRange->connect_changed(a4Link);
543 m_xEdComment->connect_changed(a4Link);
544 m_xLbAction->connect_changed(LINK( this, SvxTPFilter, ModifyListBoxHdl));
545 m_xLbAuthor->connect_changed(LINK( this, SvxTPFilter, ModifyListBoxHdl));
547 RowEnableHdl(*m_xCbDate);
548 RowEnableHdl(*m_xCbAuthor);
549 RowEnableHdl(*m_xCbRange);
550 RowEnableHdl(*m_xCbAction);
551 RowEnableHdl(*m_xCbComment);
553 DateTime aDateTime( DateTime::SYSTEM );
554 m_xDfDate->set_date(aDateTime);
555 m_xDfDate2->set_date(aDateTime);
556 m_xTfDate->set_value(aDateTime);
557 m_xTfDate2->set_value(aDateTime);
558 HideRange();
559 ShowAction();
560 bModified=false;
563 SvxTPFilter::~SvxTPFilter()
567 void SvxTPFilter::SetRedlinTable(SvxRedlinTable* pTable)
569 m_pRedlinTable = pTable;
572 void SvxTPFilter::EnableDateLine1(bool bFlag)
574 if(bFlag && m_xCbDate->get_active())
576 m_xDfDate->set_sensitive(true);
577 m_xTfDate->set_sensitive(true);
578 m_xIbClock->set_sensitive(true);
580 else
582 m_xDfDate->set_sensitive(false);
583 m_xTfDate->set_sensitive(false);
584 m_xIbClock->set_sensitive(false);
587 void SvxTPFilter::EnableDateLine2(bool bFlag)
589 if(bFlag && m_xCbDate->get_active())
591 m_xFtDate2->set_sensitive(true);
592 m_xDfDate2->set_sensitive(true);
593 m_xTfDate2->set_sensitive(true);
594 m_xIbClock2->set_sensitive(true);
596 else
598 m_xFtDate2->set_sensitive(false);
599 m_xDfDate2->set_sensitive(false);
600 m_xDfDate2->set_label(OUString());
601 m_xTfDate2->set_sensitive(false);
602 m_xTfDate2->set_text(OUString());
603 m_xIbClock2->set_sensitive(false);
607 Date SvxTPFilter::GetFirstDate() const
609 return m_xDfDate->get_date();
612 void SvxTPFilter::SetFirstDate(const Date &aDate)
614 m_xDfDate->set_date(aDate);
617 tools::Time SvxTPFilter::GetFirstTime() const
619 return m_xTfDate->get_value();
622 void SvxTPFilter::SetFirstTime(const tools::Time &aTime)
624 m_xTfDate->set_value(aTime);
627 Date SvxTPFilter::GetLastDate() const
629 return m_xDfDate2->get_date();
632 void SvxTPFilter::SetLastDate(const Date &aDate)
634 m_xDfDate2->set_date(aDate);
637 tools::Time SvxTPFilter::GetLastTime() const
639 return m_xTfDate2->get_value();
642 void SvxTPFilter::SetLastTime(const tools::Time &aTime)
644 m_xTfDate2->set_value(aTime);
647 void SvxTPFilter::SetDateMode(sal_uInt16 nMode)
649 m_xLbDate->set_active(nMode);
650 SelDateHdl(*m_xLbDate);
653 SvxRedlinDateMode SvxTPFilter::GetDateMode() const
655 return static_cast<SvxRedlinDateMode>(m_xLbDate->get_active());
657 void SvxTPFilter::ClearAuthors()
659 m_xLbAuthor->clear();
662 void SvxTPFilter::InsertAuthor( const OUString& rString)
664 m_xLbAuthor->append_text(rString);
667 OUString SvxTPFilter::GetSelectedAuthor() const
669 return m_xLbAuthor->get_active_text();
672 void SvxTPFilter::SelectedAuthorPos(sal_Int32 nPos)
674 m_xLbAuthor->set_active(nPos);
677 sal_Int32 SvxTPFilter::SelectAuthor(const OUString& aString)
679 m_xLbAuthor->set_active_text(aString);
680 return m_xLbAuthor->get_active();
683 void SvxTPFilter::SetRange(const OUString& rString)
685 m_xEdRange->set_text(rString);
688 OUString SvxTPFilter::GetRange() const
690 return m_xEdRange->get_text();
693 void SvxTPFilter::SetFocusToRange()
695 m_xEdRange->grab_focus();
698 void SvxTPFilter::HideRange(bool bHide)
700 if (bHide)
702 m_xCbRange->hide();
703 m_xEdRange->hide();
704 m_xBtnRange->hide();
706 else
708 ShowAction(false);
709 m_xCbRange->show();
710 m_xEdRange->show();
711 m_xBtnRange->show();
715 void SvxTPFilter::SetComment(const OUString &rComment)
717 m_xEdComment->set_text(rComment);
720 OUString SvxTPFilter::GetComment()const
722 return m_xEdComment->get_text();
725 bool SvxTPFilter::IsDate() const
727 return m_xCbDate->get_active();
730 bool SvxTPFilter::IsAuthor() const
732 return m_xCbAuthor->get_active();
735 bool SvxTPFilter::IsRange() const
737 return m_xCbRange->get_active();
740 bool SvxTPFilter::IsAction() const
742 return m_xCbAction->get_active();
745 bool SvxTPFilter::IsComment() const
747 return m_xCbComment->get_active();
750 void SvxTPFilter::CheckDate(bool bFlag)
752 m_xCbDate->set_active(bFlag);
753 RowEnableHdl(*m_xCbDate);
754 bModified=false;
757 void SvxTPFilter::CheckAuthor(bool bFlag)
759 m_xCbAuthor->set_active(bFlag);
760 RowEnableHdl(*m_xCbAuthor);
761 bModified=false;
764 void SvxTPFilter::CheckRange(bool bFlag)
766 m_xCbRange->set_active(bFlag);
767 RowEnableHdl(*m_xCbRange);
768 bModified=false;
771 void SvxTPFilter::CheckAction(bool bFlag)
773 m_xCbAction->set_active(bFlag);
774 RowEnableHdl(*m_xCbAction);
775 bModified=false;
778 void SvxTPFilter::CheckComment(bool bFlag)
780 m_xCbComment->set_active(bFlag);
781 RowEnableHdl(*m_xCbComment);
782 bModified=false;
785 void SvxTPFilter::ShowAction(bool bShow)
787 if(!bShow)
789 m_xCbAction->hide();
790 m_xLbAction->hide();
792 else
794 HideRange();
795 m_xCbAction->show();
796 m_xLbAction->show();
800 IMPL_LINK_NOARG(SvxTPFilter, SelDateHdl, weld::ComboBox&, void)
802 SvxRedlinDateMode nKind = static_cast<SvxRedlinDateMode>(m_xLbDate->get_active());
803 switch(nKind)
805 case SvxRedlinDateMode::BEFORE:
806 EnableDateLine1(true);
807 EnableDateLine2(false);
808 break;
809 case SvxRedlinDateMode::SINCE:
810 EnableDateLine1(true);
811 EnableDateLine2(false);
812 break;
813 case SvxRedlinDateMode::EQUAL:
814 EnableDateLine1(true);
815 m_xTfDate->set_sensitive(false);
816 m_xTfDate->set_text(OUString());
817 EnableDateLine2(false);
818 break;
819 case SvxRedlinDateMode::NOTEQUAL:
820 EnableDateLine1(true);
821 m_xTfDate->set_sensitive(false);
822 m_xTfDate->set_text(OUString());
823 EnableDateLine2(false);
824 break;
825 case SvxRedlinDateMode::BETWEEN:
826 EnableDateLine1(true);
827 EnableDateLine2(true);
828 break;
829 case SvxRedlinDateMode::SAVE:
830 EnableDateLine1(false);
831 EnableDateLine2(false);
832 break;
833 case SvxRedlinDateMode::NONE:
834 break;
836 bModified = true;
839 IMPL_LINK(SvxTPFilter, RowEnableHdl, weld::Button&, rCB, void)
841 if (&rCB == m_xCbDate.get())
843 m_xLbDate->set_sensitive(m_xCbDate->get_active());
844 EnableDateLine1(false);
845 EnableDateLine2(false);
846 if(m_xCbDate->get_active()) SelDateHdl(*m_xLbDate);
848 else if (&rCB == m_xCbAuthor.get())
850 m_xLbAuthor->set_sensitive(m_xCbAuthor->get_active());
852 else if (&rCB == m_xCbRange.get())
854 m_xEdRange->set_sensitive(m_xCbRange->get_active());
855 m_xBtnRange->set_sensitive(m_xCbRange->get_active());
857 else if (&rCB == m_xCbAction.get())
859 m_xLbAction->set_sensitive(m_xCbAction->get_active());
861 else if (&rCB == m_xCbComment.get())
863 m_xEdComment->set_sensitive(m_xCbComment->get_active());
865 bModified = true;
868 IMPL_LINK(SvxTPFilter, TimeHdl, weld::Button&, rIB, void)
870 DateTime aDateTime( DateTime::SYSTEM );
871 if (&rIB == m_xIbClock.get())
873 m_xDfDate->set_date(aDateTime);
874 m_xTfDate->set_value(aDateTime);
876 else if (&rIB == m_xIbClock2.get())
878 m_xDfDate2->set_date(aDateTime);
879 m_xTfDate2->set_value(aDateTime);
881 bModified=true;
884 IMPL_LINK_NOARG(SvxTPFilter, ModifyHdl, weld::Entry&, void)
886 bModified=true;
889 IMPL_LINK_NOARG(SvxTPFilter, ModifyListBoxHdl, weld::ComboBox&, void)
891 bModified=true;
894 void SvxTPFilter::DeactivatePage()
896 if(bModified)
898 if (m_pRedlinTable)
900 m_pRedlinTable->SetFilterDate(IsDate());
901 m_pRedlinTable->SetDateTimeMode(GetDateMode());
902 m_pRedlinTable->SetFirstDate(m_xDfDate->get_date());
903 m_pRedlinTable->SetLastDate(m_xDfDate2->get_date());
904 m_pRedlinTable->SetFirstTime(m_xTfDate->get_value());
905 m_pRedlinTable->SetLastTime(m_xTfDate2->get_value());
906 m_pRedlinTable->SetFilterAuthor(IsAuthor());
907 m_pRedlinTable->SetAuthor(GetSelectedAuthor());
909 m_pRedlinTable->SetFilterComment(IsComment());
911 utl::SearchParam aSearchParam( m_xEdComment->get_text(),
912 utl::SearchParam::SearchType::Regexp,false );
914 m_pRedlinTable->SetCommentParams(&aSearchParam);
916 m_pRedlinTable->UpdateFilterTest();
919 aReadyLink.Call(this);
921 bModified=false;
924 void SvxTPFilter::Enable(bool bEnable)
926 m_xContainer->set_sensitive(bEnable);
927 if (m_xCbDate->get_sensitive())
929 RowEnableHdl(*m_xCbDate);
930 RowEnableHdl(*m_xCbAuthor);
931 RowEnableHdl(*m_xCbRange);
932 RowEnableHdl(*m_xCbComment);
936 IMPL_LINK(SvxTPFilter, ModifyDate, SvtCalendarBox&, rTF, void)
938 Date aDate( Date::SYSTEM );
939 if (m_xDfDate.get() == &rTF)
941 if (m_xDfDate->get_label().isEmpty())
942 m_xDfDate->set_date(aDate);
944 if(m_pRedlinTable!=nullptr)
945 m_pRedlinTable->SetFirstDate(m_xDfDate->get_date());
947 else if (m_xDfDate2.get() == &rTF)
949 if (m_xDfDate2->get_label().isEmpty())
950 m_xDfDate2->set_date(aDate);
952 if (m_pRedlinTable)
953 m_pRedlinTable->SetLastDate(m_xDfDate2->get_date());
955 bModified=true;
958 IMPL_LINK(SvxTPFilter, ModifyTime, weld::TimeSpinButton&, rTF, void)
960 tools::Time aTime(0);
961 if (m_xTfDate.get() == &rTF)
963 if (m_xTfDate->get_text().isEmpty())
964 m_xTfDate->set_value(aTime);
966 if(m_pRedlinTable!=nullptr)
967 m_pRedlinTable->SetFirstTime(m_xTfDate->get_value());
969 else if (m_xTfDate2.get() == &rTF)
971 if (m_xTfDate2->get_text().isEmpty())
972 m_xTfDate2->set_value(aTime);
974 if(m_pRedlinTable!=nullptr)
975 m_pRedlinTable->SetLastTime(m_xTfDate2->get_value());
978 bModified=true;
981 IMPL_LINK_NOARG(SvxTPFilter, RefHandle, weld::Button&, void)
983 aRefLink.Call(this);
986 SvxAcceptChgCtr::SvxAcceptChgCtr(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel)
987 : m_xBuilder(Application::CreateBuilder(pParent, "svx/ui/redlinecontrol.ui"))
988 , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
990 m_xTabCtrl->connect_enter_page(LINK(this, SvxAcceptChgCtr, ActivatePageHdl));
991 m_xTabCtrl->connect_leave_page(LINK(this, SvxAcceptChgCtr, DeactivatePageHdl));
993 m_xTPFilter.reset(new SvxTPFilter(m_xTabCtrl->get_page("filter")));
994 m_xTPView.reset(new SvxTPView(m_xTabCtrl->get_page("view"), pDialog, pTopLevel));
995 m_xTPFilter->SetRedlinTable(m_xTPView->GetTableControl());
996 m_xTabCtrl->set_current_page("view");
997 m_xTabCtrl->show();
1000 SvxAcceptChgCtr::~SvxAcceptChgCtr()
1004 void SvxAcceptChgCtr::ShowFilterPage()
1006 m_xTabCtrl->set_current_page("filter");
1009 IMPL_LINK(SvxAcceptChgCtr, ActivatePageHdl, const OString&, rPage, void)
1011 if (rPage == "filter")
1012 m_xTPFilter->ActivatePage();
1013 else if (rPage == "view")
1014 m_xTPView->ActivatePage();
1017 IMPL_LINK(SvxAcceptChgCtr, DeactivatePageHdl, const OString&, rPage, bool)
1019 if (rPage == "filter")
1020 m_xTPFilter->DeactivatePage();
1021 else if (rPage == "view")
1022 m_xTPView->DeactivatePage();
1023 return true;
1026 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */