LibreOffice Module svx (master)  1
ctredlin.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
21 #include <comphelper/string.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>
28 
29 #include <svx/ctredlin.hxx>
30 #include <svx/dialmgr.hxx>
31 #include <svx/strings.hrc>
32 
33 #define WRITER_DATE 2
34 #define CALC_DATE 3
35 
37  : aDateTime(DateTime::EMPTY)
38  , pData(nullptr)
40  , bDisabled(false)
41 {
42 }
43 
45 {
46 }
47 
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))
54  , pTreeView(nullptr)
55  , nDatePos(WRITER_DATE)
56  , bAuthor(false)
57  , bDate(false)
58  , bComment(false)
59  , bSorted(false)
60  , nDaTiMode(SvxRedlinDateMode::BEFORE)
61  , aDaTiFirst( DateTime::EMPTY )
62  , aDaTiLast( DateTime::EMPTY )
63  , aDaTiFilterFirst( DateTime::EMPTY )
64  , aDaTiFilterLast( DateTime::EMPTY )
65 {
66  if (xWriterTreeView)
67  {
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);
71  });
72  pTreeView = xWriterTreeView.get();
73  }
74  if (xCalcTreeView)
75  {
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);
79  });
80  pTreeView = xCalcTreeView.get();
81  }
82 }
83 
84 void SvxRedlinTable::set_size_request(int nWidth, int nHeight)
85 {
86  if (xWriterTreeView)
87  xWriterTreeView->set_size_request(nWidth, nHeight);
88  if (xCalcTreeView)
89  xCalcTreeView->set_size_request(nWidth, nHeight);
90 }
91 
93 {
94 }
95 
96 IMPL_LINK(SvxRedlinTable, HeaderBarClick, int, nColumn, void)
97 {
98  if (!bSorted)
99  {
100  pTreeView->make_sorted();
101  bSorted = true;
102  }
103 
104  bool bSortAtoZ = pTreeView->get_sort_order();
105 
106  //set new arrow positions in headerbar
107  if (nColumn == pTreeView->get_sort_column())
108  {
109  bSortAtoZ = !bSortAtoZ;
110  pTreeView->set_sort_order(bSortAtoZ);
111  }
112  else
113  {
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);
118  }
119 
120  if (nColumn != -1)
121  {
122  //sort lists
123  pTreeView->set_sort_indicator(bSortAtoZ ? TRISTATE_TRUE : TRISTATE_FALSE, nColumn);
124  }
125 }
126 
128 {
129  sal_Int32 nCompare = 0;
130 
131  int nSortCol = pTreeView->get_sort_column();
132 
133  if (pTreeView == xWriterTreeView.get() && nSortCol == 0)
134  {
135  RedlinData *pLeftData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rLeft).toInt64());
136  RedlinData *pRightData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rRight).toInt64());
137 
138  if (pLeftData && pRightData)
139  {
140  if (pLeftData->eType < pRightData->eType)
141  nCompare = -1;
142  else if (pLeftData->eType > pRightData->eType)
143  nCompare = 1;
144  return nCompare;
145  }
146  }
147 
148  if (nSortCol == nDatePos)
149  {
150  RedlinData *pLeftData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rLeft).toInt64());
151  RedlinData *pRightData = reinterpret_cast<RedlinData*>(pTreeView->get_id(rRight).toInt64());
152 
153  if (pLeftData && pRightData)
154  {
155  if (pLeftData->aDateTime < pRightData->aDateTime)
156  nCompare = -1;
157  else if (pLeftData->aDateTime > pRightData->aDateTime)
158  nCompare = 1;
159  return nCompare;
160  }
161  }
162 
163  return xSorter->compare(pTreeView->get_text(rLeft, nSortCol),
164  pTreeView->get_text(rRight, nSortCol));
165 }
166 
168 {
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);
174 
175  DateTime aDTMin(aDateMin);
176  DateTime aDTMax(aDateMax);
177 
178  switch(nDaTiMode)
179  {
181  aDaTiFilterFirst=aDTMin;
183  break;
187  aDaTiFilterLast=aDTMax;
188  break;
194  break;
200  break;
204  break;
206  break;
207  }
208 }
209 
211 {
212  bDate=bFlag;
213 }
214 
216 {
217  nDaTiMode=nMode;
218 }
219 
221 {
222  aDaTiFirst.SetDate(aDate.GetDate());
223 }
224 
226 {
227  aDaTiLast.SetDate(aDate.GetDate());
228 }
229 
231 {
232  aDaTiFirst.SetTime(aTime.GetTime());
233 }
234 
236 {
237  aDaTiLast.SetTime(aTime.GetTime());
238 }
239 
241 {
242  bAuthor=bFlag;
243 }
244 
245 void SvxRedlinTable::SetAuthor(const OUString &aString)
246 {
247  aAuthor=aString;
248 }
249 
251 {
252  bComment=bFlag;
253 }
254 
256 {
257  if(pSearchPara!=nullptr)
258  {
259  pCommentSearcher.reset(new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM ));
260  }
261 }
262 
263 bool SvxRedlinTable::IsValidEntry(std::u16string_view rAuthorStr,
264  const DateTime &rDateTime,
265  const OUString &rCommentStr)
266 {
267  return IsValidEntry(rAuthorStr, rDateTime) && IsValidComment(rCommentStr);
268 }
269 
270 bool SvxRedlinTable::IsValidEntry(std::u16string_view rAuthorStr, const DateTime &rDateTime)
271 {
272  if (bAuthor && aAuthor!=rAuthorStr)
273  return false;
274 
275  if (!bDate)
276  return true;
277 
278  const bool bRes = rDateTime.IsBetween(aDaTiFilterFirst, aDaTiFilterLast);
279  return nDaTiMode!=SvxRedlinDateMode::NOTEQUAL ? bRes : !bRes;
280 }
281 
282 bool SvxRedlinTable::IsValidComment(const OUString &rCommentStr)
283 {
284  if (!bComment)
285  return true;
286 
287  sal_Int32 nStartPos = 0;
288  sal_Int32 nEndPos = rCommentStr.getLength();
289  return pCommentSearcher->SearchForward( rCommentStr, &nStartPos, &nEndPos);
290 }
291 
293 {
294 }
295 
297 {
298 }
299 
301  : SvxTPage(pParent, "svx/ui/redlineviewpage.ui", "RedlineViewPage")
302  , bEnableAccept(true)
303  , bEnableAcceptAll(true)
304  , bEnableReject(true)
305  , bEnableRejectAll(true)
306  , bEnableUndo(true)
307  , bEnableClearFormat(false)
308  , bEnableClearFormatAll(false)
309  , m_pDialog(pDialog)
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")))
317 {
318  Size aControlSize(80, 65);
319  m_xViewData->set_size_request(aControlSize.Width(), aControlSize.Height());
320 
321  Link<weld::Button&,void> aLink=LINK( this, SvxTPView, PbClickHdl);
322 
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);
328 }
329 
331 {
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);
337 }
338 
340 {
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);
346 }
347 
349 {
350 }
351 
353 {
355  if (xCalcTreeView)
356  xCalcTreeView->hide();
357  xWriterTreeView->show();
358  pTreeView = xWriterTreeView.get();
359 
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);
366 }
367 
369 {
371  if (xWriterTreeView)
372  xWriterTreeView->hide();
373  xCalcTreeView->show();
374  pTreeView = xCalcTreeView.get();
375 
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);
383 }
384 
385 void SvxTPView::EnableAccept(bool bFlag)
386 {
387  bEnableAccept = bFlag;
388  m_xAccept->set_sensitive(bFlag);
389 }
390 
392 {
393  bEnableAcceptAll = bFlag;
394  m_xAcceptAll->set_sensitive(bFlag);
395 }
396 
397 void SvxTPView::EnableReject(bool bFlag)
398 {
399  bEnableReject = bFlag;
400  m_xReject->set_sensitive(bFlag);
401 }
402 
404 {
405  bEnableRejectAll = bFlag;
406  m_xRejectAll->set_sensitive(bFlag);
407 }
408 
410 {
411  OUString sText = rButton.get_label();
412  OUString sClearFormat = SvxResId(RID_SVXSTR_CLEARFORM);
413  sal_Int32 nPos = sText.indexOf(sClearFormat);
414 
415  // add or remove "Clear formatting" to get "Reject" or "Reject/Clear formatting"
416  if (bFlag)
417  {
418  if (nPos == -1)
419  {
420  rButton.set_label(sText + "/" + sClearFormat);
421  }
422  }
423  else
424  {
425  if (nPos > 0)
426  {
427  rButton.set_label(sText.copy(0, nPos - 1));
428  }
429  }
430 
431  if (m_pDialog)
432  {
433  // tdf#127218 allow dialog to shrink
435  }
436 }
437 
439 {
440  if (bEnableClearFormat == bFlag)
441  return;
443  bEnableClearFormat = bFlag;
444 }
445 
447 {
448  if (bEnableClearFormatAll == bFlag)
449  return;
451  bEnableClearFormatAll = bFlag;
452 }
453 
455 {
456  m_xUndo->show();
457 }
458 
459 void SvxTPView::EnableUndo(bool bFlag)
460 {
461  bEnableUndo = bFlag;
462  m_xUndo->set_sensitive(bFlag);
463 }
464 
465 IMPL_LINK( SvxTPView, PbClickHdl, weld::Button&, rPushB, void)
466 {
467  if (&rPushB == m_xAccept.get())
468  {
469  AcceptClickLk.Call(this);
470  }
471  else if (&rPushB == m_xAcceptAll.get())
472  {
473  AcceptAllClickLk.Call(this);
474  }
475  else if (&rPushB == m_xReject.get())
476  {
477  RejectClickLk.Call(this);
478  }
479  else if (&rPushB == m_xRejectAll.get())
480  {
481  RejectAllClickLk.Call(this);
482  }
483  else if (&rPushB == m_xUndo.get())
484  {
485  UndoClickLk.Call(this);
486  }
487 }
488 
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))
492 {
493 }
494 
496  : SvxTPage(pParent, "svx/ui/redlinefilterpage.ui", "RedlineFilterPage")
497  , bModified(false)
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"))
519 {
520  m_xTfDateFormatter->EnableEmptyField(false);
521  m_xTfDate2Formatter->EnableEmptyField(false);
522 
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));
528 
529  Link<weld::Toggleable&,void> aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
530  m_xCbDate->connect_toggled(aLink);
531  m_xCbAuthor->connect_toggled(aLink);
532  m_xCbRange->connect_toggled(aLink);
533  m_xCbAction->connect_toggled(aLink);
534  m_xCbComment->connect_toggled(aLink);
535 
536  Link<SvtCalendarBox&,void> a2Link=LINK(this, SvxTPFilter, ModifyDate);
537  m_xDfDate->connect_activated(a2Link);
538  m_xDfDate2->connect_activated(a2Link);
539 
540  Link<weld::FormattedSpinButton&,void> a3Link=LINK(this, SvxTPFilter, ModifyTime);
541  m_xTfDate->connect_value_changed(a3Link);
542  m_xTfDate2->connect_value_changed(a3Link);
543 
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));
549 
550  RowEnableHdl(*m_xCbDate);
551  RowEnableHdl(*m_xCbAuthor);
552  RowEnableHdl(*m_xCbRange);
553  RowEnableHdl(*m_xCbAction);
554  RowEnableHdl(*m_xCbComment);
555 
556  DateTime aDateTime(DateTime::SYSTEM);
557  SetFirstDate(aDateTime);
558  SetLastDate(aDateTime);
559  SetFirstTime(aDateTime);
560  SetLastTime(aDateTime);
561  HideRange();
562  ShowAction();
563  bModified=false;
564 }
565 
567 {
568 }
569 
571 {
572  m_pRedlinTable = pTable;
573 }
574 
576 {
577  if(bFlag && m_xCbDate->get_active())
578  {
579  m_xDfDate->set_sensitive(true);
580  m_xTfDate->set_sensitive(true);
581  m_xIbClock->set_sensitive(true);
582  }
583  else
584  {
585  m_xDfDate->set_sensitive(false);
586  m_xTfDate->set_sensitive(false);
587  m_xIbClock->set_sensitive(false);
588  }
589 }
591 {
592  if(bFlag && m_xCbDate->get_active())
593  {
594  m_xFtDate2->set_sensitive(true);
595  m_xDfDate2->set_sensitive(true);
596  m_xTfDate2->set_sensitive(true);
597  m_xIbClock2->set_sensitive(true);
598  }
599  else
600  {
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);
607  }
608 }
609 
611 {
612  return m_xDfDate->get_date();
613 }
614 
615 void SvxTPFilter::SetFirstDate(const Date &aDate)
616 {
617  m_xDfDate->set_date(aDate);
618 }
619 
621 {
622  return m_xTfDateFormatter->GetTime();
623 }
624 
626 {
627  m_xTfDateFormatter->SetTime(aTime);
628 }
629 
631 {
632  return m_xDfDate2->get_date();
633 }
634 
635 void SvxTPFilter::SetLastDate(const Date &aDate)
636 {
637  m_xDfDate2->set_date(aDate);
638 }
639 
641 {
642  return m_xTfDate2Formatter->GetTime();
643 }
644 
646 {
647  m_xTfDate2Formatter->SetTime(aTime);
648 }
649 
650 void SvxTPFilter::SetDateMode(sal_uInt16 nMode)
651 {
652  m_xLbDate->set_active(nMode);
653  SelDateHdl(*m_xLbDate);
654 }
655 
657 {
658  return static_cast<SvxRedlinDateMode>(m_xLbDate->get_active());
659 }
661 {
662  m_xLbAuthor->clear();
663 }
664 
665 void SvxTPFilter::InsertAuthor( const OUString& rString)
666 {
667  m_xLbAuthor->append_text(rString);
668 }
669 
671 {
672  return m_xLbAuthor->get_active_text();
673 }
674 
675 void SvxTPFilter::SelectedAuthorPos(sal_Int32 nPos)
676 {
677  m_xLbAuthor->set_active(nPos);
678 }
679 
680 sal_Int32 SvxTPFilter::SelectAuthor(const OUString& aString)
681 {
682  m_xLbAuthor->set_active_text(aString);
683  return m_xLbAuthor->get_active();
684 }
685 
686 void SvxTPFilter::SetRange(const OUString& rString)
687 {
688  m_xEdRange->set_text(rString);
689 }
690 
691 OUString SvxTPFilter::GetRange() const
692 {
693  return m_xEdRange->get_text();
694 }
695 
697 {
698  m_xEdRange->grab_focus();
699 }
700 
701 void SvxTPFilter::HideRange(bool bHide)
702 {
703  if (bHide)
704  {
705  m_xCbRange->hide();
706  m_xEdRange->hide();
707  m_xBtnRange->hide();
708  }
709  else
710  {
711  ShowAction(false);
712  m_xCbRange->show();
713  m_xEdRange->show();
714  m_xBtnRange->show();
715  }
716 }
717 
718 void SvxTPFilter::SetComment(const OUString &rComment)
719 {
720  m_xEdComment->set_text(rComment);
721 }
722 
723 OUString SvxTPFilter::GetComment()const
724 {
725  return m_xEdComment->get_text();
726 }
727 
729 {
730  return m_xCbDate->get_active();
731 }
732 
734 {
735  return m_xCbAuthor->get_active();
736 }
737 
739 {
740  return m_xCbRange->get_active();
741 }
742 
744 {
745  return m_xCbAction->get_active();
746 }
747 
749 {
750  return m_xCbComment->get_active();
751 }
752 
753 void SvxTPFilter::CheckDate(bool bFlag)
754 {
755  m_xCbDate->set_active(bFlag);
756  RowEnableHdl(*m_xCbDate);
757  bModified=false;
758 }
759 
760 void SvxTPFilter::CheckAuthor(bool bFlag)
761 {
762  m_xCbAuthor->set_active(bFlag);
763  RowEnableHdl(*m_xCbAuthor);
764  bModified=false;
765 }
766 
767 void SvxTPFilter::CheckRange(bool bFlag)
768 {
769  m_xCbRange->set_active(bFlag);
770  RowEnableHdl(*m_xCbRange);
771  bModified=false;
772 }
773 
774 void SvxTPFilter::CheckAction(bool bFlag)
775 {
776  m_xCbAction->set_active(bFlag);
777  RowEnableHdl(*m_xCbAction);
778  bModified=false;
779 }
780 
782 {
783  m_xCbComment->set_active(bFlag);
784  RowEnableHdl(*m_xCbComment);
785  bModified=false;
786 }
787 
788 void SvxTPFilter::ShowAction(bool bShow)
789 {
790  if(!bShow)
791  {
792  m_xCbAction->hide();
793  m_xLbAction->hide();
794  }
795  else
796  {
797  HideRange();
798  m_xCbAction->show();
799  m_xLbAction->show();
800  }
801 }
802 
804 {
805  SvxRedlinDateMode nKind = static_cast<SvxRedlinDateMode>(m_xLbDate->get_active());
806  switch(nKind)
807  {
809  EnableDateLine1(true);
810  EnableDateLine2(false);
811  break;
813  EnableDateLine1(true);
814  EnableDateLine2(false);
815  break;
817  EnableDateLine1(true);
818  m_xTfDate->set_sensitive(false);
819  m_xTfDate->set_text(OUString());
820  EnableDateLine2(false);
821  break;
823  EnableDateLine1(true);
824  m_xTfDate->set_sensitive(false);
825  m_xTfDate->set_text(OUString());
826  EnableDateLine2(false);
827  break;
829  EnableDateLine1(true);
830  EnableDateLine2(true);
831  break;
833  EnableDateLine1(false);
834  EnableDateLine2(false);
835  break;
837  break;
838  }
839  bModified = true;
840 }
841 
842 IMPL_LINK(SvxTPFilter, RowEnableHdl, weld::Toggleable&, rCB, void)
843 {
844  if (&rCB == m_xCbDate.get())
845  {
846  m_xLbDate->set_sensitive(m_xCbDate->get_active());
847  EnableDateLine1(false);
848  EnableDateLine2(false);
849  if(m_xCbDate->get_active()) SelDateHdl(*m_xLbDate);
850  }
851  else if (&rCB == m_xCbAuthor.get())
852  {
853  m_xLbAuthor->set_sensitive(m_xCbAuthor->get_active());
854  }
855  else if (&rCB == m_xCbRange.get())
856  {
857  m_xEdRange->set_sensitive(m_xCbRange->get_active());
858  m_xBtnRange->set_sensitive(m_xCbRange->get_active());
859  }
860  else if (&rCB == m_xCbAction.get())
861  {
862  m_xLbAction->set_sensitive(m_xCbAction->get_active());
863  }
864  else if (&rCB == m_xCbComment.get())
865  {
866  m_xEdComment->set_sensitive(m_xCbComment->get_active());
867  }
868  bModified = true;
869 }
870 
871 IMPL_LINK(SvxTPFilter, TimeHdl, weld::Button&, rIB, void)
872 {
873  DateTime aDateTime( DateTime::SYSTEM );
874  if (&rIB == m_xIbClock.get())
875  {
876  SetFirstDate(aDateTime);
877  SetFirstTime(aDateTime);
878  }
879  else if (&rIB == m_xIbClock2.get())
880  {
881  SetLastDate(aDateTime);
882  SetLastTime(aDateTime);
883  }
884  bModified=true;
885 }
886 
888 {
889  bModified=true;
890 }
891 
892 IMPL_LINK_NOARG(SvxTPFilter, ModifyListBoxHdl, weld::ComboBox&, void)
893 {
894  bModified=true;
895 }
896 
898 {
899  if(bModified)
900  {
901  if (m_pRedlinTable)
902  {
911 
913 
914  utl::SearchParam aSearchParam( m_xEdComment->get_text(),
916 
917  m_pRedlinTable->SetCommentParams(&aSearchParam);
918 
920  }
921 
922  aReadyLink.Call(this);
923  }
924  bModified=false;
925 }
926 
927 void SvxTPFilter::Enable(bool bEnable)
928 {
929  m_xContainer->set_sensitive(bEnable);
930  if (m_xCbDate->get_sensitive())
931  {
932  RowEnableHdl(*m_xCbDate);
933  RowEnableHdl(*m_xCbAuthor);
934  RowEnableHdl(*m_xCbRange);
935  RowEnableHdl(*m_xCbComment);
936  }
937 }
938 
939 IMPL_LINK(SvxTPFilter, ModifyDate, SvtCalendarBox&, rTF, void)
940 {
941  Date aDate( Date::SYSTEM );
942  if (m_xDfDate.get() == &rTF)
943  {
944  if (m_xDfDate->get_label().isEmpty())
945  m_xDfDate->set_date(aDate);
946 
947  if(m_pRedlinTable!=nullptr)
948  m_pRedlinTable->SetFirstDate(m_xDfDate->get_date());
949  }
950  else if (m_xDfDate2.get() == &rTF)
951  {
952  if (m_xDfDate2->get_label().isEmpty())
953  m_xDfDate2->set_date(aDate);
954 
955  if (m_pRedlinTable)
956  m_pRedlinTable->SetLastDate(m_xDfDate2->get_date());
957  }
958  bModified=true;
959 }
960 
962 {
963  tools::Time aTime(0);
964  if (m_xTfDate.get() == &rTF)
965  {
966  if (m_xTfDate->get_text().isEmpty())
967  SetFirstTime(aTime);
968 
969  if (m_pRedlinTable!=nullptr)
970  m_pRedlinTable->SetFirstTime(GetFirstTime());
971  }
972  else if (m_xTfDate2.get() == &rTF)
973  {
974  if (m_xTfDate2->get_text().isEmpty())
975  SetLastTime(aTime);
976 
977  if (m_pRedlinTable!=nullptr)
978  m_pRedlinTable->SetLastTime(GetLastTime());
979 
980  }
981  bModified=true;
982 }
983 
985 {
986  aRefLink.Call(this);
987 }
988 
990  : m_xBuilder(Application::CreateBuilder(pParent, "svx/ui/redlinecontrol.ui"))
991  , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
992 {
993  m_xTabCtrl->connect_enter_page(LINK(this, SvxAcceptChgCtr, ActivatePageHdl));
994  m_xTabCtrl->connect_leave_page(LINK(this, SvxAcceptChgCtr, DeactivatePageHdl));
995 
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");
1000  m_xTabCtrl->show();
1001 }
1002 
1004 {
1005 }
1006 
1008 {
1009  m_xTabCtrl->set_current_page("filter");
1010 }
1011 
1012 IMPL_LINK(SvxAcceptChgCtr, ActivatePageHdl, const OString&, rPage, void)
1013 {
1014  if (rPage == "filter")
1015  m_xTPFilter->ActivatePage();
1016  else if (rPage == "view")
1017  m_xTPView->ActivatePage();
1018 }
1019 
1020 IMPL_LINK(SvxAcceptChgCtr, DeactivatePageHdl, const OString&, rPage, bool)
1021 {
1022  if (rPage == "filter")
1023  m_xTPFilter->DeactivatePage();
1024  else if (rPage == "view")
1025  m_xTPView->DeactivatePage();
1026  return true;
1027 }
1028 
1029 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFilterDate(bool bFlag)
Definition: ctredlin.cxx:210
virtual ~SvxTPFilter() override
Definition: ctredlin.cxx:566
void SetDateMode(sal_uInt16 nMode)
Definition: ctredlin.cxx:650
std::unique_ptr< weld::Button > m_xReject
Definition: ctredlin.hxx:279
Link< SvxTPFilter *, void > aReadyLink
Definition: ctredlin.hxx:157
void SetFilterComment(bool bFlag)
Definition: ctredlin.cxx:250
virtual void set_label(const OUString &rText)=0
void SetFirstDate(const Date &aDate)
Definition: ctredlin.cxx:615
bool IsDate() const
Definition: ctredlin.cxx:728
std::unique_ptr< utl::TextSearch > pCommentSearcher
Definition: ctredlin.hxx:97
std::unique_ptr< weld::Entry > m_xEdComment
Definition: ctredlin.hxx:182
std::unique_ptr< weld::TreeView > xCalcTreeView
Definition: ctredlin.hxx:83
std::unique_ptr< weld::FormattedSpinButton > m_xTfDate
Definition: ctredlin.hxx:166
void SetCalcView()
Definition: ctredlin.cxx:368
void SetWriterView()
Definition: ctredlin.cxx:352
std::unique_ptr< ContentProperties > pData
void SetCommentParams(const utl::SearchParam *pSearchPara)
Definition: ctredlin.cxx:255
tools::Time GetFirstTime() const
Definition: ctredlin.cxx:620
std::unique_ptr< weld::CheckButton > m_xCbAction
Definition: ctredlin.hxx:179
SvxTPage(weld::Container *pParent, const OUString &rUIXMLDescription, const OString &rID)
Definition: ctredlin.cxx:489
void AddYears(sal_Int16 nAddYears)
void SetAuthor(const OUString &)
Definition: ctredlin.cxx:245
bool IsValidComment(const OUString &rComment)
Definition: ctredlin.cxx:282
std::unique_ptr< weld::ComboBox > m_xLbAction
Definition: ctredlin.hxx:180
std::unique_ptr< weld::Button > m_xAcceptAll
Definition: ctredlin.hxx:280
void Enable(bool bEnable=true)
Definition: ctredlin.cxx:927
void SetRange(const OUString &rString)
Definition: ctredlin.cxx:686
void CheckRange(bool bFlag)
Definition: ctredlin.cxx:767
std::unique_ptr< weld::Button > m_xRejectAll
Definition: ctredlin.hxx:281
std::unique_ptr< SvxRedlinTable > m_xViewData
Definition: ctredlin.hxx:283
SvxRedlinDateMode nDaTiMode
Definition: ctredlin.hxx:91
std::unique_ptr< weld::CheckButton > m_xCbAuthor
Definition: ctredlin.hxx:174
void EnableRejectAll(bool bFlag)
Definition: ctredlin.cxx:403
std::unique_ptr< SvtCalendarBox > m_xDfDate
Definition: ctredlin.hxx:165
void SetFirstTime(const tools::Time &)
Definition: ctredlin.cxx:230
std::unique_ptr< comphelper::string::NaturalStringSorter > xSorter
Definition: ctredlin.hxx:81
void EnableClearFormat(bool bFlag)
Definition: ctredlin.cxx:438
TRISTATE_TRUE
virtual ~SvxTPView() override
Definition: ctredlin.cxx:348
void ClearAuthors()
Definition: ctredlin.cxx:660
std::unique_ptr< weld::Entry > m_xEdRange
Definition: ctredlin.hxx:177
void SetRedlinTable(SvxRedlinTable *)
Definition: ctredlin.cxx:570
constexpr tools::Long Width() const
void SetTime(sal_Int64 nNewTime)
void HideRange(bool bHide=true)
Definition: ctredlin.cxx:701
bool bEnableRejectAll
Definition: ctredlin.hxx:271
Reference< XNameAccess > m_xContainer
SvxTPView(weld::Container *pParent, weld::Window *pDialog, weld::Builder *pTopLevel)
Definition: ctredlin.cxx:300
std::unique_ptr< SvxTPView > m_xTPView
Definition: ctredlin.hxx:326
void DeactivatePage()
Definition: ctredlin.cxx:339
void ShowFilterPage()
Definition: ctredlin.cxx:1007
void SetFilterAuthor(bool bFlag)
Definition: ctredlin.cxx:240
std::unique_ptr< weld::TreeView > xWriterTreeView
Definition: ctredlin.hxx:82
bool bEnableAccept
Definition: ctredlin.hxx:268
void ShowUndo()
Definition: ctredlin.cxx:454
virtual void set_column_fixed_widths(const std::vector< int > &rWidths)=0
DateTime aDateTime
Definition: ctredlin.hxx:72
virtual OUString get_id(int pos) const =0
sal_uInt16 nDatePos
Definition: ctredlin.hxx:86
virtual ~SvxTPage()
Definition: ctredlin.cxx:292
sal_Int32 GetDate() const
void DeactivatePage()
Definition: ctredlin.cxx:897
void SetDate(sal_Int32 nNewDate)
#define CALC_DATE
Definition: ctredlin.cxx:34
std::unique_ptr< weld::ComboBox > m_xLbAuthor
Definition: ctredlin.hxx:175
TRISTATE_INDET
OUString GetComment() const
Definition: ctredlin.cxx:723
virtual void ActivatePage() override
Definition: ctredlin.cxx:330
void CheckAuthor(bool bFlag)
Definition: ctredlin.cxx:760
DateTime aDaTiFilterLast
Definition: ctredlin.hxx:95
Tabpage with the filter text entries etc.
Definition: ctredlin.hxx:155
DocumentType eType
SvxRedlinTable(std::unique_ptr< weld::TreeView > xWriterControl, std::unique_ptr< weld::TreeView > xCalcControl)
Definition: ctredlin.cxx:48
void EnableDateLine1(bool bFlag)
Definition: ctredlin.cxx:575
OUString SvxResId(std::string_view aId)
Definition: dialmgr.cxx:25
OUString aAuthor
Definition: ctredlin.hxx:96
DateTime aDaTiFilterFirst
Definition: ctredlin.hxx:94
std::unique_ptr< weld::CheckButton > m_xCbComment
Definition: ctredlin.hxx:181
bool bEnableAcceptAll
Definition: ctredlin.hxx:269
void SetFirstDate(const Date &)
Definition: ctredlin.cxx:220
std::unique_ptr< weld::Button > m_xBtnRange
Definition: ctredlin.hxx:178
#define LANGUAGE_SYSTEM
tools::Time GetLastTime() const
Definition: ctredlin.cxx:640
bool IsAuthor() const
Definition: ctredlin.cxx:733
std::unique_ptr< weld::ComboBox > m_xLbDate
Definition: ctredlin.hxx:164
IMPL_LINK(SvxRedlinTable, HeaderBarClick, int, nColumn, void)
Definition: ctredlin.cxx:96
void EnableClearFormatAll(bool bFlag)
Definition: ctredlin.cxx:446
TRISTATE_FALSE
void SetLastTime(const tools::Time &aTime)
Definition: ctredlin.cxx:645
std::unique_ptr< weld::Button > m_xIbClock2
Definition: ctredlin.hxx:173
void set_size_request(int nWidth, int nHeight)
Definition: ctredlin.cxx:84
bool bModified
Definition: ctredlin.hxx:160
std::unique_ptr< weld::Button > m_xIbClock
Definition: ctredlin.hxx:168
bool bEnableReject
Definition: ctredlin.hxx:270
std::unique_ptr< weld::Button > m_xAccept
Definition: ctredlin.hxx:278
void CheckAction(bool bFlag)
Definition: ctredlin.cxx:774
OUString GetSelectedAuthor() const
Definition: ctredlin.cxx:670
std::unique_ptr< weld::Button > m_xUndo
Definition: ctredlin.hxx:282
virtual OUString get_text(int row, int col=-1) const =0
weld::TreeView * pTreeView
Definition: ctredlin.hxx:84
bool IsBetween(const DateTime &rFrom, const DateTime &rTo) const
std::unique_ptr< weld::Container > m_xContainer
Definition: ctredlin.hxx:141
SvxRedlinTable * m_pRedlinTable
Definition: ctredlin.hxx:162
bool IsComment() const
Definition: ctredlin.cxx:748
std::unique_ptr< weld::FormattedSpinButton > m_xTfDate2
Definition: ctredlin.hxx:171
void ShowAction(bool bShow=true)
Definition: ctredlin.cxx:788
void CheckComment(bool bFlag)
Definition: ctredlin.cxx:781
void SelectedAuthorPos(sal_Int32 nPos)
Definition: ctredlin.cxx:675
std::unique_ptr< weld::Label > m_xFtDate2
Definition: ctredlin.hxx:169
std::unique_ptr< weld::CheckButton > m_xCbDate
Definition: ctredlin.hxx:163
const LanguageTag & getLocale()
void EnableUndo(bool bFlag=true)
Definition: ctredlin.cxx:459
bool IsValidEntry(std::u16string_view rAuthor, const DateTime &rDateTime, const OUString &rComment)
Definition: ctredlin.cxx:263
void SetLastTime(const tools::Time &)
Definition: ctredlin.cxx:235
virtual void resize_to_request()=0
std::unique_ptr< weld::Notebook > m_xTabCtrl
Definition: ctredlin.hxx:323
SvxRedlinDateMode
Definition: ctredlin.hxx:44
void EnableReject(bool bFlag)
Definition: ctredlin.cxx:397
virtual int get_sort_column() const =0
SvxTPFilter(weld::Container *pParent)
Definition: ctredlin.cxx:495
bool IsRange() const
Definition: ctredlin.cxx:738
bool bEnableUndo
Definition: ctredlin.hxx:272
sal_Int32 SelectAuthor(const OUString &aString)
Definition: ctredlin.cxx:680
std::unique_ptr< SvxTPFilter > m_xTPFilter
Definition: ctredlin.hxx:325
bool IsAction() const
Definition: ctredlin.cxx:743
constexpr tools::Long Height() const
virtual OUString get_label() const =0
Tabpage with the redlining entries.
Definition: ctredlin.hxx:258
bool bEnableClearFormat
Definition: ctredlin.hxx:274
void EnableAccept(bool bFlag)
Definition: ctredlin.cxx:385
Date GetLastDate() const
Definition: ctredlin.cxx:630
void SetFirstTime(const tools::Time &aTime)
Definition: ctredlin.cxx:625
void SetLastDate(const Date &)
Definition: ctredlin.cxx:225
DateTime aDaTiFirst
Definition: ctredlin.hxx:92
void SetLastDate(const Date &aDate)
Definition: ctredlin.cxx:635
sal_Int64 GetTime() const
Reference< XComponentContext > getProcessComponentContext()
std::unique_ptr< SvtCalendarBox > m_xDfDate2
Definition: ctredlin.hxx:170
void SetDateTimeMode(SvxRedlinDateMode nMode)
Definition: ctredlin.cxx:215
virtual void ActivatePage()
Definition: ctredlin.cxx:296
SvxAcceptChgCtr(weld::Container *pParent, weld::Window *pDialog, weld::Builder *pTopLevel)
Definition: ctredlin.cxx:989
weld::Window * m_pDialog
Definition: ctredlin.hxx:277
DateTime aDaTiLast
Definition: ctredlin.hxx:93
void EnableDateLine2(bool bFlag)
Definition: ctredlin.cxx:590
#define WRITER_DATE
Definition: ctredlin.cxx:33
Date GetFirstDate() const
Definition: ctredlin.cxx:610
IMPL_LINK_NOARG(SvxTPFilter, SelDateHdl, weld::ComboBox &, void)
Definition: ctredlin.cxx:803
int ColCompare(const weld::TreeIter &rLeft, const weld::TreeIter &rRight)
Definition: ctredlin.cxx:127
SvxRedlinDateMode GetDateMode() const
Definition: ctredlin.cxx:656
RedlineType
Definition: ctredlin.hxx:49
void CheckDate(bool bFlag)
Definition: ctredlin.cxx:753
void SetComment(const OUString &rComment)
Definition: ctredlin.cxx:718
std::unique_ptr< weld::TimeFormatter > m_xTfDateFormatter
Definition: ctredlin.hxx:167
void SetFocusToRange()
Definition: ctredlin.cxx:696
void UpdateFilterTest()
Definition: ctredlin.cxx:167
void EnableClearFormatButton(weld::Button &, bool bFlag)
Definition: ctredlin.cxx:409
std::unique_ptr< weld::CheckButton > m_xCbRange
Definition: ctredlin.hxx:176
Struct for sorting data.
Definition: ctredlin.hxx:67
void InsertAuthor(const OUString &rString)
Definition: ctredlin.cxx:665
OUString GetRange() const
Definition: ctredlin.cxx:691
bool bEnableClearFormatAll
Definition: ctredlin.hxx:275
virtual ~RedlinData()
Definition: ctredlin.cxx:44
void EnableAcceptAll(bool bFlag)
Definition: ctredlin.cxx:391
std::unique_ptr< weld::TimeFormatter > m_xTfDate2Formatter
Definition: ctredlin.hxx:172
virtual float get_approximate_digit_width() const =0
RedlineType eType
Definition: ctredlin.hxx:74
sal_uInt16 nPos