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