LibreOffice Module sc (master)  1
checklistmenu.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 
20 #include <checklistmenu.hxx>
21 #include <globstr.hrc>
22 #include <scresid.hxx>
23 #include <strings.hrc>
24 #include <bitmaps.hlst>
25 
26 #include <vcl/decoview.hxx>
27 #include <vcl/event.hxx>
28 #include <vcl/dockwin.hxx>
29 #include <vcl/settings.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/virdev.hxx>
32 #include <rtl/math.hxx>
33 #include <tools/wintypes.hxx>
34 #include <unotools/charclass.hxx>
35 
36 #include <document.hxx>
37 
38 using namespace com::sun::star;
39 using ::com::sun::star::uno::Reference;
40 
42  : mbEnabled(true)
43 {
44 }
45 
47  : mpSubMenu(nullptr)
48  , mnMenuPos(MENU_NOT_SELECTED)
49  , mpParent(pParent)
50 {
52  maTimer.SetTimeout(Application::GetSettings().GetMouseSettings().GetMenuDelay());
53 }
54 
56 {
57  mpSubMenu = nullptr;
58  mnMenuPos = MENU_NOT_SELECTED;
59  maTimer.Stop();
60 }
61 
63 {
64  mpParent->handleMenuTimeout(this);
65 }
66 
68 {
69  executeMenuItem(mxMenu->get_selected_index());
70  return true;
71 }
72 
73 IMPL_LINK(ScCheckListMenuControl, MenuKeyInputHdl, const KeyEvent&, rKEvt, bool)
74 {
75  const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
76 
77  switch (rKeyCode.GetCode())
78  {
79  case KEY_LEFT:
80  {
82  if (pParentMenu)
83  pParentMenu->get_widget().endSubMenu(*this);
84  break;
85  }
86  case KEY_RIGHT:
87  {
89  break;
90 
91  const MenuItemData& rMenu = maMenuItems[mnSelectedMenu];
92  if (!rMenu.mbEnabled || !rMenu.mxSubMenuWin)
93  break;
94 
96  maOpenTimer.mpSubMenu = rMenu.mxSubMenuWin.get();
97  launchSubMenu(true);
98  }
99  }
100 
101  return false;
102 }
103 
105 {
106  sal_uInt32 nSelectedMenu = MENU_NOT_SELECTED;
107  if (!mxMenu->get_selected(mxScratchIter.get()))
108  {
109  // reselect current item if its submenu is up and the launching item
110  // became unselected
111  if (mnSelectedMenu < maMenuItems.size() &&
112  maMenuItems[mnSelectedMenu].mxSubMenuWin &&
113  maMenuItems[mnSelectedMenu].mxSubMenuWin->IsVisible())
114  {
115  mxMenu->select(mnSelectedMenu);
116  return;
117  }
118  }
119  else
120  nSelectedMenu = mxMenu->get_iter_index_in_parent(*mxScratchIter);
121 
122  setSelectedMenuItem(nSelectedMenu, true);
123 }
124 
125 void ScCheckListMenuControl::addMenuItem(const OUString& rText, Action* pAction)
126 {
127  MenuItemData aItem;
128  aItem.mbEnabled = true;
129  aItem.mxAction.reset(pAction);
130  maMenuItems.emplace_back(std::move(aItem));
131 
132  mxMenu->append_text(rText);
133  if (mbCanHaveSubMenu)
134  mxMenu->set_image(mxMenu->n_children() - 1, css::uno::Reference<css::graphic::XGraphic>(), 1);
135 }
136 
138 {
139  MenuItemData aItem;
140  maMenuItems.emplace_back(std::move(aItem));
141 
142  mxMenu->append_separator("separator" + OUString::number(maMenuItems.size()));
143 }
144 
145 IMPL_LINK(ScCheckListMenuControl, TreeSizeAllocHdl, const Size&, rSize, void)
146 {
148  std::vector<int> aWidths;
149  aWidths.push_back(rSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6);
150  mxMenu->set_column_fixed_widths(aWidths);
151 }
152 
154 {
155  int nWidth = (mxMenu->get_text_height() * 3) / 4;
156  mxDropDown->SetOutputSizePixel(Size(nWidth, nWidth));
157  DecorationView aDecoView(mxDropDown.get());
158  aDecoView.DrawSymbol(tools::Rectangle(Point(0, 0), Size(nWidth, nWidth)),
159  SymbolType::SPIN_RIGHT, mxDropDown->GetTextColor(),
160  DrawSymbolFlags::NONE);
161 }
162 
163 ScCheckListMenuWindow* ScCheckListMenuControl::addSubMenuItem(const OUString& rText, bool bEnabled)
164 {
166 
167  MenuItemData aItem;
168  aItem.mbEnabled = bEnabled;
169  vcl::Window *pContainer = mxFrame->GetWindow(GetWindowType::FirstChild);
170  aItem.mxSubMenuWin.reset(VclPtr<ScCheckListMenuWindow>::Create(pContainer, mpDoc, false, -1, mxFrame.get()));
171  maMenuItems.emplace_back(std::move(aItem));
172 
173  mxMenu->append_text(rText);
174  if (mbCanHaveSubMenu)
175  mxMenu->set_image(mxMenu->n_children() - 1, *mxDropDown, 1);
176 
177  return maMenuItems.back().mxSubMenuWin.get();
178 }
179 
181 {
182  if (nPos >= maMenuItems.size())
183  return;
184 
185  if (!maMenuItems[nPos].mxAction)
186  // no action is defined.
187  return;
188 
190 
191  maMenuItems[nPos].mxAction->execute();
192 }
193 
194 void ScCheckListMenuControl::setSelectedMenuItem(size_t nPos, bool bSubMenuTimer)
195 {
196  if (mnSelectedMenu == nPos)
197  // nothing to do.
198  return;
199 
200  selectMenuItem(nPos, bSubMenuTimer);
201 }
202 
204 {
205  if (pTimer == &maOpenTimer)
206  {
207  // Close any open submenu immediately.
209  {
211  maCloseTimer.mpSubMenu = nullptr;
213  }
214 
215  launchSubMenu(false);
216  }
217  else if (pTimer == &maCloseTimer)
218  {
219  // end submenu.
221  {
222  maOpenTimer.mpSubMenu = nullptr;
223 
225  maCloseTimer.mpSubMenu = nullptr;
226 
228  }
229  }
230 }
231 
233 {
234  if (!pMenu)
235  return;
236 
237  // Set the submenu on launch queue.
239  {
240  if (maOpenTimer.mpSubMenu == pMenu)
241  {
242  if (pMenu == maCloseTimer.mpSubMenu)
244  return;
245  }
246 
247  // new submenu is being requested.
249  }
250 
251  maOpenTimer.mpSubMenu = pMenu;
252  maOpenTimer.mnMenuPos = nPos;
254 }
255 
257 {
258  if (!maOpenTimer.mpSubMenu)
259  // There is no submenu to close.
260  return;
261 
262  // Stop any submenu on queue for opening.
264 
268 }
269 
271 {
273  if (!pSubMenu)
274  return;
275 
276  if (!mxMenu->get_selected(mxScratchIter.get()))
277  return;
278 
279  tools::Rectangle aRect = mxMenu->get_row_area(*mxScratchIter);
280  ScCheckListMenuControl& rSubMenuControl = pSubMenu->get_widget();
281  rSubMenuControl.StartPopupMode(aRect, FloatWinPopupFlags::Right);
282  if (bSetMenuPos)
283  rSubMenuControl.setSelectedMenuItem(0, false); // select menu item after the popup becomes fully visible.
284 
285  mxMenu->select(*mxScratchIter);
286  rSubMenuControl.GrabFocus();
287 }
288 
289 IMPL_LINK_NOARG(ScCheckListMenuControl, PostPopdownHdl, void*, void)
290 {
291  mnAsyncPostPopdownId = nullptr;
292  mxMenu->grab_focus();
293 }
294 
296 {
297  rSubMenu.EndPopupMode();
298  maOpenTimer.reset();
299 
300  // EndPopup sends a user event, and we want this focus to be set after that has done its conflicting focus-setting work
303 
304  size_t nMenuPos = getSubMenuPos(&rSubMenu);
305  if (nMenuPos != MENU_NOT_SELECTED)
306  {
307  mnSelectedMenu = nMenuPos;
308  mxMenu->select(mnSelectedMenu);
309  }
310 }
311 
313 {
314  mxMenu->set_size_request(-1, mxMenu->get_preferred_size().Height() + 2);
315 }
316 
317 void ScCheckListMenuControl::selectMenuItem(size_t nPos, bool bSubMenuTimer)
318 {
319  mxMenu->select(nPos == MENU_NOT_SELECTED ? -1 : nPos);
320  mnSelectedMenu = nPos;
321 
322  if (nPos >= maMenuItems.size() || nPos == MENU_NOT_SELECTED)
323  {
325  return;
326  }
327 
328  if (!maMenuItems[nPos].mbEnabled)
329  {
331  return;
332  }
333 
334 
335  if (nPos == MENU_NOT_SELECTED)
336  return;
337 
338  ScCheckListMenuWindow* pParentMenu = mxFrame->GetParentMenu();
339  if (pParentMenu)
340  pParentMenu->get_widget().setSubMenuFocused(this);
341 
342  if (bSubMenuTimer)
343  {
344  if (maMenuItems[nPos].mxSubMenuWin)
345  {
346  ScCheckListMenuWindow* pSubMenu = maMenuItems[nPos].mxSubMenuWin.get();
347  queueLaunchSubMenu(nPos, pSubMenu);
348  }
349  else
351  }
352 }
353 
355 {
357 }
358 
360 {
361  size_t n = maMenuItems.size();
362  for (size_t i = 0; i < n; ++i)
363  {
364  if (!maMenuItems[i].mxSubMenuWin)
365  continue;
366  if (&maMenuItems[i].mxSubMenuWin->get_widget() == pSubMenu)
367  return i;
368  }
369  return MENU_NOT_SELECTED;
370 }
371 
373 {
375  size_t nMenuPos = getSubMenuPos(pSubMenu);
376  if (mnSelectedMenu != nMenuPos)
377  {
378  mnSelectedMenu = nMenuPos;
379  mxMenu->select(mnSelectedMenu);
380  }
381 }
382 
384 {
386  mxFrame->EnableDocking(false);
387 }
388 
390 {
391  mxFrame->EnableDocking(true);
392  DockingManager* pDockingManager = vcl::Window::GetDockingManager();
393  pDockingManager->SetPopupModeEndHdl(mxFrame, LINK(this, ScCheckListMenuControl, PopupModeEndHdl));
394  pDockingManager->StartPopupMode(mxFrame, rRect, (eFlags | FloatWinPopupFlags::GrabFocus));
395 }
396 
398 {
399  EndPopupMode();
400  ScCheckListMenuWindow* pParentMenu = mxFrame->GetParentMenu();
401  if (pParentMenu)
402  pParentMenu->get_widget().terminateAllPopupMenus();
403 }
404 
406  mbAllowEmptySet(true), mbRTL(false)
407 {
408 }
409 
411  : mbVisible(true)
412  , mbDate(false)
413  , mbLeaf(false)
414  , meDatePartType(YEAR)
415 {
416 }
417 
419  ScDocument* pDoc, bool bCanHaveSubMenu, int nWidth)
420  : mxFrame(pParent)
421  , mxBuilder(Application::CreateInterimBuilder(pContainer, "modules/scalc/ui/filterdropdown.ui"))
422  , mxContainer(mxBuilder->weld_container("FilterDropDown"))
423  , mxMenu(mxBuilder->weld_tree_view("menu"))
424  , mxScratchIter(mxMenu->make_iterator())
425  , mxEdSearch(mxBuilder->weld_entry("search_edit"))
426  , mxBox(mxBuilder->weld_widget("box"))
427  , mxChecks(mxBuilder->weld_tree_view("check_list_box"))
428  , mxChkToggleAll(mxBuilder->weld_check_button("toggle_all"))
429  , mxBtnSelectSingle(mxBuilder->weld_button("select_current"))
430  , mxBtnUnselectSingle(mxBuilder->weld_button("unselect_current"))
431  , mxButtonBox(mxBuilder->weld_box("buttonbox"))
432  , mxBtnOk(mxBuilder->weld_button("ok"))
433  , mxBtnCancel(mxBuilder->weld_button("cancel"))
434  , mxDropDown(mxMenu->create_virtual_device())
435  , mnCheckWidthReq(-1)
436  , mnWndWidth(0)
437  , mePrevToggleAllState(TRISTATE_INDET)
438  , mnSelectedMenu(MENU_NOT_SELECTED)
439  , mpDoc(pDoc)
440  , mnAsyncPostPopdownId(nullptr)
441  , mbHasDates(false)
442  , mbCanHaveSubMenu(bCanHaveSubMenu)
443  , maOpenTimer(this)
444  , maCloseTimer(this)
445 {
446  bool bIsSubMenu = pParent->GetParentMenu();
447 
448  int nChecksHeight = mxChecks->get_height_rows(9);
449  if (!bIsSubMenu && nWidth != -1)
450  {
451  mnCheckWidthReq = nWidth - mxFrame->get_border_width() * 2 - 4;
452  mxChecks->set_size_request(mnCheckWidthReq, nChecksHeight);
453  }
454 
455  // sort ok/cancel into native order, if this was a dialog they would be auto-sorted, but this
456  // popup isn't a true dialog
457  mxButtonBox->sort_native_button_order();
458 
459  if (!bIsSubMenu)
460  {
461  mxChecks->enable_toggle_buttons(weld::ColumnToggleType::Check);
462 
463  mxBox->show();
464  mxEdSearch->show();
465  mxButtonBox->show();
466  }
467 
468  mxContainer->connect_focus_in(LINK(this, ScCheckListMenuControl, FocusHdl));
469  mxMenu->connect_row_activated(LINK(this, ScCheckListMenuControl, RowActivatedHdl));
470  mxMenu->connect_changed(LINK(this, ScCheckListMenuControl, SelectHdl));
471  mxMenu->connect_key_press(LINK(this, ScCheckListMenuControl, MenuKeyInputHdl));
472 
473  if (!bIsSubMenu)
474  {
475  mxBtnOk->connect_clicked(LINK(this, ScCheckListMenuControl, ButtonHdl));
476  mxBtnCancel->connect_clicked(LINK(this, ScCheckListMenuControl, ButtonHdl));
477  mxEdSearch->connect_changed(LINK(this, ScCheckListMenuControl, EdModifyHdl));
478  mxEdSearch->connect_activate(LINK(this, ScCheckListMenuControl, EdActivateHdl));
479  mxChecks->connect_toggled(LINK(this, ScCheckListMenuControl, CheckHdl));
480  mxChecks->connect_key_press(LINK(this, ScCheckListMenuControl, KeyInputHdl));
481  mxChkToggleAll->connect_toggled(LINK(this, ScCheckListMenuControl, TriStateHdl));
482  mxBtnSelectSingle->connect_clicked(LINK(this, ScCheckListMenuControl, ButtonHdl));
483  mxBtnUnselectSingle->connect_clicked(LINK(this, ScCheckListMenuControl, ButtonHdl));
484  }
485 
486  if (mbCanHaveSubMenu)
487  {
488  CreateDropDown();
489  mxMenu->connect_size_allocate(LINK(this, ScCheckListMenuControl, TreeSizeAllocHdl));
490  }
491 
492  if (!bIsSubMenu)
493  {
494  // determine what width the checklist will end up with
495  mnCheckWidthReq = mxContainer->get_preferred_size().Width();
496  // make that size fixed now, we can now use mnCheckWidthReq to speed up
497  // bulk_insert_for_each
498  mxChecks->set_size_request(mnCheckWidthReq, nChecksHeight);
499  }
500 }
501 
503 {
504  GrabFocus();
505 }
506 
508 {
509  if (mxEdSearch->get_visible())
510  mxEdSearch->grab_focus();
511  else
512  {
513  mxMenu->set_cursor(0);
514  mxMenu->grab_focus();
515  }
516 }
517 
519 {
520  EndPopupMode();
521  for (auto& rMenuItem : maMenuItems)
522  rMenuItem.mxSubMenuWin.disposeAndClear();
524  {
526  mnAsyncPostPopdownId = nullptr;
527  }
528 }
529 
531  int nWidth, ScCheckListMenuWindow* pParentMenu)
532  : DockingWindow(pParent, "InterimDockParent", "svx/ui/interimdockparent.ui")
533  , mxParentMenu(pParentMenu)
534  , mxBox(get("box"))
535 {
537  mxControl.reset(new ScCheckListMenuControl(this, mxBox.get(), pDoc, bCanHaveSubMenu, nWidth));
538  SetBackground(Application::GetSettings().GetStyleSettings().GetMenuColor());
539  set_id("check_list_menu");
540 }
541 
543 {
544  if (rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE)
545  {
546  ScCheckListMenuControl& rMenuControl = get_widget();
547  rMenuControl.queueCloseSubMenu();
548  rMenuControl.clearSelectedMenuItem();
549  }
550  return DockingWindow::EventNotify(rNEvt);
551 }
552 
554 {
555  disposeOnce();
556 }
557 
559 {
560  mxControl.reset();
564 }
565 
567 {
569  if (!mxControl)
570  return;
571  mxControl->GrabFocus();
572 }
573 
575 {
576  mxMenu->set_size_request(-1, mxMenu->get_preferred_size().Height() + 2);
577  mnSelectedMenu = 0;
578  mxMenu->set_cursor(mnSelectedMenu);
579  mxMenu->unselect_all();
580 
581  mnWndWidth = mxContainer->get_preferred_size().Width() + mxFrame->get_border_width() * 2 + 4;
582 }
583 
585 {
586  CheckAllChildren(nullptr, bSet);
587 
589  {
590  // We need to have at least one member selected.
591  mxBtnOk->set_sensitive(GetCheckedEntryCount() != 0);
592  }
593 }
594 
596 {
597  setAllMemberState(!bSet);
598  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator();
599  if (!mxChecks->get_cursor(xEntry.get()))
600  return;
601  mxChecks->set_toggle(*xEntry, bSet ? TRISTATE_TRUE : TRISTATE_FALSE);
602 }
603 
605 {
606  if (&rBtn == mxBtnOk.get())
607  close(true);
608  else if (&rBtn == mxBtnCancel.get())
609  close(false);
610  else if (&rBtn == mxBtnSelectSingle.get() || &rBtn == mxBtnUnselectSingle.get())
611  {
612  selectCurrentMemberOnly(&rBtn == mxBtnSelectSingle.get());
613  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator();
614  if (!mxChecks->get_cursor(xEntry.get()))
615  xEntry.reset();
616  Check(xEntry.get());
617  }
618 }
619 
621 {
622  switch (mePrevToggleAllState)
623  {
624  case TRISTATE_FALSE:
625  mxChkToggleAll->set_state(TRISTATE_TRUE);
626  setAllMemberState(true);
627  break;
628  case TRISTATE_TRUE:
629  mxChkToggleAll->set_state(TRISTATE_FALSE);
630  setAllMemberState(false);
631  break;
632  case TRISTATE_INDET:
633  default:
634  mxChkToggleAll->set_state(TRISTATE_TRUE);
635  setAllMemberState(true);
636  break;
637  }
638 
639  mePrevToggleAllState = mxChkToggleAll->get_state();
640 }
641 
643 {
644  OUString aSearchText = mxEdSearch->get_text();
645  aSearchText = ScGlobal::getCharClassPtr()->lowercase( aSearchText );
646  bool bSearchTextEmpty = aSearchText.isEmpty();
647  size_t n = maMembers.size();
648  size_t nSelCount = 0;
649  bool bSomeDateDeletes = false;
650 
651  mxChecks->freeze();
652 
653  if (bSearchTextEmpty && !mbHasDates)
654  {
655  // when there are a lot of rows, it is cheaper to simply clear the tree and re-initialise
656  mxChecks->clear();
657  nSelCount = initMembers();
658  }
659  else
660  {
661  for (size_t i = 0; i < n; ++i)
662  {
663  bool bIsDate = maMembers[i].mbDate;
664  bool bPartialMatch = false;
665 
666  OUString aLabelDisp = maMembers[i].maName;
667  if ( aLabelDisp.isEmpty() )
668  aLabelDisp = ScResId( STR_EMPTYDATA );
669 
670  if ( !bSearchTextEmpty )
671  {
672  if ( !bIsDate )
673  bPartialMatch = ( ScGlobal::getCharClassPtr()->lowercase( aLabelDisp ).indexOf( aSearchText ) != -1 );
674  else if ( maMembers[i].meDatePartType == ScCheckListMember::DAY ) // Match with both numerical and text version of month
675  bPartialMatch = (ScGlobal::getCharClassPtr()->lowercase( OUString(
676  maMembers[i].maRealName + maMembers[i].maDateParts[1] )).indexOf( aSearchText ) != -1);
677  else
678  continue;
679  }
680  else if ( bIsDate && maMembers[i].meDatePartType != ScCheckListMember::DAY )
681  continue;
682 
683  if ( bSearchTextEmpty )
684  {
685  auto xLeaf = ShowCheckEntry(aLabelDisp, maMembers[i], true, maMembers[i].mbVisible);
686  updateMemberParents(xLeaf.get(), i);
687  if ( maMembers[i].mbVisible )
688  ++nSelCount;
689  continue;
690  }
691 
692  if ( bPartialMatch )
693  {
694  auto xLeaf = ShowCheckEntry(aLabelDisp, maMembers[i]);
695  updateMemberParents(xLeaf.get(), i);
696  ++nSelCount;
697  }
698  else
699  {
700  ShowCheckEntry(aLabelDisp, maMembers[i], false, false);
701  if( bIsDate )
702  bSomeDateDeletes = true;
703  }
704  }
705  }
706 
707  if ( bSomeDateDeletes )
708  {
709  for (size_t i = 0; i < n; ++i)
710  {
711  if (!maMembers[i].mbDate)
712  continue;
713  if (maMembers[i].meDatePartType != ScCheckListMember::DAY)
714  continue;
715  updateMemberParents(nullptr, i);
716  }
717  }
718 
719  mxChecks->thaw();
720 
721  if ( nSelCount == n )
722  mxChkToggleAll->set_state( TRISTATE_TRUE );
723  else if ( nSelCount == 0 )
724  mxChkToggleAll->set_state( TRISTATE_FALSE );
725  else
726  mxChkToggleAll->set_state( TRISTATE_INDET );
727 
728  if ( !maConfig.mbAllowEmptySet )
729  {
730  const bool bEmptySet( nSelCount == 0 );
731  mxChecks->set_sensitive(!bEmptySet);
732  mxChkToggleAll->set_sensitive(!bEmptySet);
733  mxBtnSelectSingle->set_sensitive(!bEmptySet);
734  mxBtnUnselectSingle->set_sensitive(!bEmptySet);
735  mxBtnOk->set_sensitive(!bEmptySet);
736  }
737 }
738 
740 {
741  if (mxBtnOk->get_sensitive())
742  close(true);
743  return true;
744 }
745 
746 IMPL_LINK( ScCheckListMenuControl, CheckHdl, const weld::TreeView::iter_col&, rRowCol, void )
747 {
748  Check(&rRowCol.first);
749 }
750 
752 {
753  if (pEntry)
754  CheckEntry(pEntry, mxChecks->get_toggle(*pEntry) == TRISTATE_TRUE);
755  size_t nNumChecked = GetCheckedEntryCount();
756  if (nNumChecked == maMembers.size())
757  // all members visible
758  mxChkToggleAll->set_state(TRISTATE_TRUE);
759  else if (nNumChecked == 0)
760  // no members visible
761  mxChkToggleAll->set_state(TRISTATE_FALSE);
762  else
763  mxChkToggleAll->set_state(TRISTATE_INDET);
764 
766  // We need to have at least one member selected.
767  mxBtnOk->set_sensitive(nNumChecked != 0);
768 
769  mePrevToggleAllState = mxChkToggleAll->get_state();
770 }
771 
773 {
774  if ( !maMembers[nIdx].mbDate || maMembers[nIdx].meDatePartType != ScCheckListMember::DAY )
775  return;
776 
777  OUString aYearName = maMembers[nIdx].maDateParts[0];
778  OUString aMonthName = maMembers[nIdx].maDateParts[1];
779  auto aItr = maYearMonthMap.find(aYearName + aMonthName);
780 
781  if ( pLeaf )
782  {
783  std::unique_ptr<weld::TreeIter> xYearEntry;
784  std::unique_ptr<weld::TreeIter> xMonthEntry = mxChecks->make_iterator(pLeaf);
785  if (!mxChecks->iter_parent(*xMonthEntry))
786  xMonthEntry.reset();
787  else
788  {
789  xYearEntry = mxChecks->make_iterator(xMonthEntry.get());
790  if (!mxChecks->iter_parent(*xYearEntry))
791  xYearEntry.reset();
792  }
793 
794  maMembers[nIdx].mxParent = std::move(xMonthEntry);
795  if ( aItr != maYearMonthMap.end() )
796  {
797  size_t nMonthIdx = aItr->second;
798  maMembers[nMonthIdx].mxParent = std::move(xYearEntry);
799  }
800  }
801  else
802  {
803  std::unique_ptr<weld::TreeIter> xYearEntry = FindEntry(nullptr, aYearName);
804  if (aItr != maYearMonthMap.end() && !xYearEntry)
805  {
806  size_t nMonthIdx = aItr->second;
807  maMembers[nMonthIdx].mxParent.reset();
808  maMembers[nIdx].mxParent.reset();
809  }
810  else if (xYearEntry && !FindEntry(xYearEntry.get(), aMonthName))
811  maMembers[nIdx].mxParent.reset();
812  }
813 }
814 
816 {
817  maMembers.reserve(n);
818 }
819 
820 void ScCheckListMenuControl::addDateMember(const OUString& rsName, double nVal, bool bVisible)
821 {
822  SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
823 
824  // Convert the numeric date value to a date object.
825  Date aDate = pFormatter->GetNullDate();
826  aDate.AddDays(rtl::math::approxFloor(nVal));
827 
828  sal_Int16 nYear = aDate.GetYear();
829  sal_uInt16 nMonth = aDate.GetMonth();
830  sal_uInt16 nDay = aDate.GetDay();
831 
832  // Get the localized month name list.
833  CalendarWrapper* pCalendar = ScGlobal::GetCalendar();
834  uno::Sequence<i18n::CalendarItem2> aMonths = pCalendar->getMonths();
835  if (aMonths.getLength() < nMonth)
836  return;
837 
838  OUString aYearName = OUString::number(nYear);
839  OUString aMonthName = aMonths[nMonth-1].FullName;
840  OUString aDayName = OUString::number(nDay);
841 
842  if ( aDayName.getLength() == 1 )
843  aDayName = "0" + aDayName;
844 
845  mxChecks->freeze();
846 
847  std::unique_ptr<weld::TreeIter> xYearEntry = FindEntry(nullptr, aYearName);
848  if (!xYearEntry)
849  {
850  xYearEntry = mxChecks->make_iterator();
851  mxChecks->insert(nullptr, -1, nullptr, nullptr, nullptr, nullptr, false, xYearEntry.get());
852  mxChecks->set_toggle(*xYearEntry, TRISTATE_FALSE);
853  mxChecks->set_text(*xYearEntry, aYearName, 0);
854  ScCheckListMember aMemYear;
855  aMemYear.maName = aYearName;
856  aMemYear.maRealName = rsName;
857  aMemYear.mbDate = true;
858  aMemYear.mbLeaf = false;
859  aMemYear.mbVisible = bVisible;
860  aMemYear.mxParent.reset();
862  maMembers.emplace_back(std::move(aMemYear));
863  }
864 
865  std::unique_ptr<weld::TreeIter> xMonthEntry = FindEntry(xYearEntry.get(), aMonthName);
866  if (!xMonthEntry)
867  {
868  xMonthEntry = mxChecks->make_iterator();
869  mxChecks->insert(xYearEntry.get(), -1, nullptr, nullptr, nullptr, nullptr, false, xMonthEntry.get());
870  mxChecks->set_toggle(*xMonthEntry, TRISTATE_FALSE);
871  mxChecks->set_text(*xMonthEntry, aMonthName, 0);
872  ScCheckListMember aMemMonth;
873  aMemMonth.maName = aMonthName;
874  aMemMonth.maRealName = rsName;
875  aMemMonth.mbDate = true;
876  aMemMonth.mbLeaf = false;
877  aMemMonth.mbVisible = bVisible;
878  aMemMonth.mxParent = std::move(xYearEntry);
880  maMembers.emplace_back(std::move(aMemMonth));
881  maYearMonthMap[aYearName + aMonthName] = maMembers.size() - 1;
882  }
883 
884  std::unique_ptr<weld::TreeIter> xDayEntry = FindEntry(xMonthEntry.get(), aDayName);
885  if (!xDayEntry)
886  {
887  xDayEntry = mxChecks->make_iterator();
888  mxChecks->insert(xMonthEntry.get(), -1, nullptr, nullptr, nullptr, nullptr, false, xDayEntry.get());
889  mxChecks->set_toggle(*xDayEntry, TRISTATE_FALSE);
890  mxChecks->set_text(*xDayEntry, aDayName, 0);
891  ScCheckListMember aMemDay;
892  aMemDay.maName = aDayName;
893  aMemDay.maRealName = rsName;
894  aMemDay.maDateParts.resize(2);
895  aMemDay.maDateParts[0] = aYearName;
896  aMemDay.maDateParts[1] = aMonthName;
897  aMemDay.mbDate = true;
898  aMemDay.mbLeaf = true;
899  aMemDay.mbVisible = bVisible;
900  aMemDay.mxParent = std::move(xMonthEntry);
902  maMembers.emplace_back(std::move(aMemDay));
903  }
904 
905  mxChecks->thaw();
906 }
907 
908 void ScCheckListMenuControl::addMember(const OUString& rName, bool bVisible)
909 {
910  ScCheckListMember aMember;
911  aMember.maName = rName;
912  aMember.mbDate = false;
913  aMember.mbLeaf = true;
914  aMember.mbVisible = bVisible;
915  aMember.mxParent.reset();
916  maMembers.emplace_back(std::move(aMember));
917 }
918 
919 std::unique_ptr<weld::TreeIter> ScCheckListMenuControl::FindEntry(const weld::TreeIter* pParent, const OUString& sNode)
920 {
921  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator(pParent);
922  bool bEntry = pParent ? mxChecks->iter_children(*xEntry) : mxChecks->get_iter_first(*xEntry);
923  while (bEntry)
924  {
925  if (sNode == mxChecks->get_text(*xEntry, 0))
926  return xEntry;
927  bEntry = mxChecks->iter_next_sibling(*xEntry);
928  }
929  return nullptr;
930 }
931 
932 void ScCheckListMenuControl::GetRecursiveChecked(const weld::TreeIter* pEntry, std::unordered_set<OUString>& vOut,
933  OUString& rLabel)
934 {
935  if (mxChecks->get_toggle(*pEntry) != TRISTATE_TRUE)
936  return;
937 
938  // We have to hash parents and children together.
939  // Per convention for easy access in getResult()
940  // "child;parent;grandparent" while descending.
941  if (rLabel.isEmpty())
942  rLabel = mxChecks->get_text(*pEntry, 0);
943  else
944  rLabel = mxChecks->get_text(*pEntry, 0) + ";" + rLabel;
945 
946  // Prerequisite: the selection mechanism guarantees that if a child is
947  // selected then also the parent is selected, so we only have to
948  // inspect the children in case the parent is selected.
949  if (!mxChecks->iter_has_child(*pEntry))
950  return;
951 
952  std::unique_ptr<weld::TreeIter> xChild(mxChecks->make_iterator(pEntry));
953  bool bChild = mxChecks->iter_children(*xChild);
954  while (bChild)
955  {
956  OUString aLabel = rLabel;
957  GetRecursiveChecked(xChild.get(), vOut, aLabel);
958  if (!aLabel.isEmpty() && aLabel != rLabel)
959  vOut.insert(aLabel);
960  bChild = mxChecks->iter_next_sibling(*xChild);
961  }
962  // Let the caller not add the parent alone.
963  rLabel.clear();
964 }
965 
966 std::unordered_set<OUString> ScCheckListMenuControl::GetAllChecked()
967 {
968  std::unordered_set<OUString> vResults(0);
969 
970  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator();
971  bool bEntry = mxChecks->get_iter_first(*xEntry);
972  while (bEntry)
973  {
974  OUString aLabel;
975  GetRecursiveChecked(xEntry.get(), vResults, aLabel);
976  if (!aLabel.isEmpty())
977  vResults.insert(aLabel);
978  bEntry = mxChecks->iter_next_sibling(*xEntry);
979  }
980 
981  return vResults;
982 }
983 
984 bool ScCheckListMenuControl::IsChecked(const OUString& sName, const weld::TreeIter* pParent)
985 {
986  std::unique_ptr<weld::TreeIter> xEntry = FindEntry(pParent, sName);
987  return xEntry && mxChecks->get_toggle(*xEntry) == TRISTATE_TRUE;
988 }
989 
990 void ScCheckListMenuControl::CheckEntry(const OUString& sName, const weld::TreeIter* pParent, bool bCheck)
991 {
992  std::unique_ptr<weld::TreeIter> xEntry = FindEntry(pParent, sName);
993  if (xEntry)
994  CheckEntry(xEntry.get(), bCheck);
995 }
996 
997 // Recursively check all children of pParent
999 {
1000  if (pParent)
1001  mxChecks->set_toggle(*pParent, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE);
1002  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator(pParent);
1003  bool bEntry = pParent ? mxChecks->iter_children(*xEntry) : mxChecks->get_iter_first(*xEntry);
1004  while (bEntry)
1005  {
1006  CheckAllChildren(xEntry.get(), bCheck);
1007  bEntry = mxChecks->iter_next_sibling(*xEntry);
1008  }
1009 }
1010 
1011 void ScCheckListMenuControl::CheckEntry(const weld::TreeIter* pParent, bool bCheck)
1012 {
1013  // recursively check all items below pParent
1014  CheckAllChildren(pParent, bCheck);
1015  // checking pParent can affect ancestors, e.g. if ancestor is unchecked and pParent is
1016  // now checked then the ancestor needs to be checked also
1017  if (!(pParent && mxChecks->get_iter_depth(*pParent)))
1018  return;
1019 
1020  std::unique_ptr<weld::TreeIter> xAncestor(mxChecks->make_iterator(pParent));
1021  bool bAncestor = mxChecks->iter_parent(*xAncestor);
1022  while (bAncestor)
1023  {
1024  // if any first level children checked then ancestor
1025  // needs to be checked, similarly if no first level children
1026  // checked then ancestor needs to be unchecked
1027  std::unique_ptr<weld::TreeIter> xChild(mxChecks->make_iterator(xAncestor.get()));
1028  bool bChild = mxChecks->iter_children(*xChild);
1029  bool bChildChecked = false;
1030 
1031  while (bChild)
1032  {
1033  if (mxChecks->get_toggle(*xChild) == TRISTATE_TRUE)
1034  {
1035  bChildChecked = true;
1036  break;
1037  }
1038  bChild = mxChecks->iter_next_sibling(*xChild);
1039  }
1040  mxChecks->set_toggle(*xAncestor, bChildChecked ? TRISTATE_TRUE : TRISTATE_FALSE);
1041  bAncestor = mxChecks->iter_parent(*xAncestor);
1042  }
1043 }
1044 
1045 std::unique_ptr<weld::TreeIter> ScCheckListMenuControl::ShowCheckEntry(const OUString& sName, ScCheckListMember& rMember, bool bShow, bool bCheck)
1046 {
1047  std::unique_ptr<weld::TreeIter> xEntry;
1048  if (!rMember.mbDate || rMember.mxParent)
1049  xEntry = FindEntry(rMember.mxParent.get(), sName);
1050 
1051  if ( bShow )
1052  {
1053  if (!xEntry)
1054  {
1055  if (rMember.mbDate)
1056  {
1057  if (rMember.maDateParts.empty())
1058  return nullptr;
1059 
1060  std::unique_ptr<weld::TreeIter> xYearEntry = FindEntry(nullptr, rMember.maDateParts[0]);
1061  if (!xYearEntry)
1062  {
1063  xYearEntry = mxChecks->make_iterator();
1064  mxChecks->insert(nullptr, -1, nullptr, nullptr, nullptr, nullptr, false, xYearEntry.get());
1065  mxChecks->set_toggle(*xYearEntry, TRISTATE_FALSE);
1066  mxChecks->set_text(*xYearEntry, rMember.maDateParts[0], 0);
1067  }
1068  std::unique_ptr<weld::TreeIter> xMonthEntry = FindEntry(xYearEntry.get(), rMember.maDateParts[1]);
1069  if (!xMonthEntry)
1070  {
1071  xMonthEntry = mxChecks->make_iterator();
1072  mxChecks->insert(xYearEntry.get(), -1, nullptr, nullptr, nullptr, nullptr, false, xMonthEntry.get());
1073  mxChecks->set_toggle(*xMonthEntry, TRISTATE_FALSE);
1074  mxChecks->set_text(*xMonthEntry, rMember.maDateParts[1], 0);
1075  }
1076  std::unique_ptr<weld::TreeIter> xDayEntry = FindEntry(xMonthEntry.get(), rMember.maName);
1077  if (!xDayEntry)
1078  {
1079  xDayEntry = mxChecks->make_iterator();
1080  mxChecks->insert(xMonthEntry.get(), -1, nullptr, nullptr, nullptr, nullptr, false, xDayEntry.get());
1081  mxChecks->set_toggle(*xDayEntry, TRISTATE_FALSE);
1082  mxChecks->set_text(*xDayEntry, rMember.maName, 0);
1083  }
1084  return xDayEntry; // Return leaf node
1085  }
1086 
1087  xEntry = mxChecks->make_iterator();
1088  mxChecks->append(xEntry.get());
1089  mxChecks->set_toggle(*xEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE);
1090  mxChecks->set_text(*xEntry, sName, 0);
1091  }
1092  else
1093  CheckEntry(xEntry.get(), bCheck);
1094  }
1095  else if (xEntry)
1096  {
1097  mxChecks->remove(*xEntry);
1098  if (rMember.mxParent)
1099  {
1100  std::unique_ptr<weld::TreeIter> xParent(mxChecks->make_iterator(rMember.mxParent.get()));
1101  while (xParent && !mxChecks->iter_has_child(*xParent))
1102  {
1103  std::unique_ptr<weld::TreeIter> xTmp(mxChecks->make_iterator(xParent.get()));
1104  if (!mxChecks->iter_parent(*xParent))
1105  xParent.reset();
1106  mxChecks->remove(*xTmp);
1107  }
1108  }
1109  }
1110  return nullptr;
1111 }
1112 
1114 {
1115  int nRet = 0;
1116 
1117  mxChecks->all_foreach([this, &nRet](weld::TreeIter& rEntry){
1118  if (mxChecks->get_toggle(rEntry) == TRISTATE_TRUE)
1119  ++nRet;
1120  return false;
1121  });
1122 
1123  return nRet;
1124 }
1125 
1126 IMPL_LINK(ScCheckListMenuControl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
1127 {
1128  const vcl::KeyCode& rKey = rKEvt.GetKeyCode();
1129 
1130  if ( rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_SPACE )
1131  {
1132  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator();
1133  bool bEntry = mxChecks->get_cursor(xEntry.get());
1134  if (bEntry)
1135  {
1136  bool bOldCheck = mxChecks->get_toggle(*xEntry) == TRISTATE_TRUE;
1137  CheckEntry(xEntry.get(), !bOldCheck);
1138  bool bNewCheck = mxChecks->get_toggle(*xEntry) == TRISTATE_TRUE;
1139  if (bOldCheck != bNewCheck)
1140  Check(xEntry.get());
1141  }
1142  return true;
1143  }
1144 
1145  return false;
1146 }
1147 
1149 {
1150  mbHasDates = bHasDates;
1151  mxChecks->set_show_expanders(mbHasDates);
1152 }
1153 
1154 namespace
1155 {
1156  void insertMember(weld::TreeView& rView, weld::TreeIter& rIter, const ScCheckListMember& rMember)
1157  {
1158  OUString aLabel = rMember.maName;
1159  if (aLabel.isEmpty())
1160  aLabel = ScResId(STR_EMPTYDATA);
1161  rView.set_toggle(rIter, rMember.mbVisible ? TRISTATE_TRUE : TRISTATE_FALSE);
1162  rView.set_text(rIter, aLabel, 0);
1163  }
1164 }
1165 
1167 {
1168  size_t n = maMembers.size();
1169  size_t nVisMemCount = 0;
1170 
1171  if (!mxChecks->n_children() && !mbHasDates)
1172  {
1173  std::vector<int> aFixedWidths { mnCheckWidthReq };
1174  // tdf#134038 insert in the fastest order, this might be backwards so only do it for
1175  // the !mbHasDates case where no entry depends on another to exist before getting
1176  // inserted. We cannot retain pre-existing treeview content, only clear and fill it.
1177  mxChecks->bulk_insert_for_each(n, [this, &nVisMemCount](weld::TreeIter& rIter, int i) {
1178  assert(!maMembers[i].mbDate);
1179  insertMember(*mxChecks, rIter, maMembers[i]);
1180  if (maMembers[i].mbVisible)
1181  ++nVisMemCount;
1182  }, &aFixedWidths);
1183  }
1184  else
1185  {
1186  mxChecks->freeze();
1187 
1188  std::unique_ptr<weld::TreeIter> xEntry = mxChecks->make_iterator();
1189  std::vector<std::unique_ptr<weld::TreeIter>> aExpandRows;
1190 
1191  for (size_t i = 0; i < n; ++i)
1192  {
1193  if (maMembers[i].mbDate)
1194  {
1195  CheckEntry(maMembers[i].maName, maMembers[i].mxParent.get(), maMembers[i].mbVisible);
1196  // Expand first node of checked dates
1197  if (!maMembers[i].mxParent && IsChecked(maMembers[i].maName, maMembers[i].mxParent.get()))
1198  {
1199  std::unique_ptr<weld::TreeIter> xDateEntry = FindEntry(nullptr, maMembers[i].maName);
1200  if (xDateEntry)
1201  aExpandRows.emplace_back(std::move(xDateEntry));
1202  }
1203  }
1204  else
1205  {
1206  mxChecks->append(xEntry.get());
1207  insertMember(*mxChecks, *xEntry, maMembers[i]);
1208  }
1209 
1210  if (maMembers[i].mbVisible)
1211  ++nVisMemCount;
1212  }
1213 
1214  mxChecks->thaw();
1215 
1216  for (auto& rRow : aExpandRows)
1217  mxChecks->expand_row(*rRow);
1218  }
1219 
1220  if (nVisMemCount == n)
1221  {
1222  // all members visible
1223  mxChkToggleAll->set_state(TRISTATE_TRUE);
1225  }
1226  else if (nVisMemCount == 0)
1227  {
1228  // no members visible
1229  mxChkToggleAll->set_state(TRISTATE_FALSE);
1231  }
1232  else
1233  {
1234  mxChkToggleAll->set_state(TRISTATE_INDET);
1236  }
1237 
1238  if (nVisMemCount)
1239  mxChecks->select(0);
1240 
1241  return nVisMemCount;
1242 }
1243 
1245 {
1246  maConfig = rConfig;
1247 }
1248 
1250 {
1251  return mxChkToggleAll->get_state() == TRISTATE_TRUE;
1252 }
1253 
1255 {
1256  ResultType aResult;
1257  std::unordered_set<OUString> vCheckeds = GetAllChecked();
1258  size_t n = maMembers.size();
1259  for (size_t i = 0; i < n; ++i)
1260  {
1261  if ( maMembers[i].mbLeaf )
1262  {
1263  OUStringBuffer aLabel = maMembers[i].maName;
1264  if (aLabel.isEmpty())
1265  aLabel = ScResId(STR_EMPTYDATA);
1266 
1267  /* TODO: performance-wise this looks suspicious, concatenating to
1268  * do the lookup for each leaf item seems wasteful. */
1269  // Checked labels are in the form "child;parent;grandparent".
1270  if (maMembers[i].mxParent)
1271  {
1272  std::unique_ptr<weld::TreeIter> xIter(mxChecks->make_iterator(maMembers[i].mxParent.get()));
1273  do
1274  {
1275  aLabel.append(";").append(mxChecks->get_text(*xIter));
1276  }
1277  while (mxChecks->iter_parent(*xIter));
1278  }
1279 
1280  bool bState = vCheckeds.find(aLabel.makeStringAndClear()) != vCheckeds.end();
1281 
1282  ResultEntry aResultEntry;
1283  aResultEntry.bValid = bState;
1284  if ( maMembers[i].mbDate )
1285  aResultEntry.aName = maMembers[i].maRealName;
1286  else
1287  aResultEntry.aName = maMembers[i].maName;
1288  aResultEntry.bDate = maMembers[i].mbDate;
1289  aResult.insert(aResultEntry);
1290  }
1291  }
1292  rResult.swap(aResult);
1293 }
1294 
1296 {
1297  prepWindow();
1299  // We need to have at least one member selected.
1300  mxBtnOk->set_sensitive(GetCheckedEntryCount() != 0);
1301 
1302  tools::Rectangle aRect(rRect);
1303  if (maConfig.mbRTL)
1304  {
1305  // In RTL mode, the logical "left" is visual "right".
1306  long nLeft = aRect.Left() - aRect.GetWidth();
1307  aRect.SetLeft( nLeft );
1308  }
1309  else if (mnWndWidth < aRect.GetWidth())
1310  {
1311  // Target rectangle (i.e. cell width) is wider than the window.
1312  // Simulate right-aligned launch by modifying the target rectangle
1313  // size.
1314  long nDiff = aRect.GetWidth() - mnWndWidth;
1315  aRect.AdjustLeft(nDiff );
1316  }
1317 
1318  StartPopupMode(aRect, FloatWinPopupFlags::Down);
1319 }
1320 
1322 {
1323  if (bOK && mxOKAction)
1324  mxOKAction->execute();
1325  EndPopupMode();
1326 }
1327 
1328 void ScCheckListMenuControl::setExtendedData(std::unique_ptr<ExtendedData> p)
1329 {
1330  mxExtendedData = std::move(p);
1331 }
1332 
1334 {
1335  return mxExtendedData.get();
1336 }
1337 
1339 {
1340  mxOKAction.reset(p);
1341 }
1342 
1344 {
1345  mxPopupEndAction.reset(p);
1346 }
1347 
1349 {
1350  clearSelectedMenuItem();
1351  if (mxPopupEndAction)
1352  mxPopupEndAction->execute();
1353 }
1354 
1355 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual void set_text(int row, const OUString &rText, int col=-1)=0
IMPL_LINK_NOARG(ScCheckListMenuControl::SubMenuItemData, TimeoutHdl, Timer *, void)
std::set< ResultEntry > ResultType
long GetWidth() const
void setDeferredProperties()
std::unique_ptr< weld::Button > mxBtnUnselectSingle
VclPtr< ScCheckListMenuWindow > mxParentMenu
void updateMemberParents(const weld::TreeIter *pLeaf, size_t nIdx)
void setOKAction(Action *p)
std::vector< MenuItemData > maMenuItems
void prepWindow()
Calculate the appropriate window size based on the menu items.
std::unique_ptr< weld::TreeIter > mxParent
std::unique_ptr< weld::Button > mxBtnSelectSingle
void executeMenuItem(size_t nPos)
int mnWndWidth
matching width request for mxChecks
long AdjustLeft(long nHorzMoveDelta)
WeakReference< XInterface > mxParent
static const AllSettings & GetSettings()
sal_Int64 n
VclPtr< ScCheckListMenuWindow > mxFrame
void SetPopupModeEndHdl(const vcl::Window *pWindow, const Link< FloatingWindow *, void > &rLink)
Reference< container::XNameAccess > mxContainer
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
std::unique_ptr< weld::TreeView > mxMenu
virtual ~ScCheckListMenuWindow() override
sal_uInt16 GetCode() const
ImplSVEvent * mnAsyncPostPopdownId
void queueLaunchSubMenu(size_t nPos, ScCheckListMenuWindow *pMenu)
std::unordered_set< OUString > GetAllChecked()
ScCheckListMenuWindow * GetParentMenu()
void selectMenuItem(size_t nPos, bool bSubMenuTimer)
VclPtr< vcl::Window > mxBox
bool IsChecked(const OUString &sName, const weld::TreeIter *pParent)
constexpr sal_uInt16 KEY_SPACE
void StartPopupMode(const tools::Rectangle &rRect, FloatWinPopupFlags eFlags)
TRISTATE_TRUE
TriState mePrevToggleAllState
whole window width.
void CheckAllChildren(const weld::TreeIter *pEntry, bool bCheck)
void CheckEntry(const OUString &sName, const weld::TreeIter *pParent, bool bCheck)
IMPL_LINK(ScCheckListMenuControl, MenuKeyInputHdl, const KeyEvent &, rKEvt, bool)
void setPopupEndAction(Action *p)
void SetBackground()
Action to perform when an event takes place.
Configuration options for this popup window.
std::unique_ptr< weld::TreeIter > mxScratchIter
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uInt16 GetMonth() const
std::unique_ptr< weld::TreeIter > ShowCheckEntry(const OUString &sName, ScCheckListMember &rMember, bool bShow=true, bool bCheck=true)
std::pair< const TreeIter &, int > iter_col
VclPtr< ScCheckListMenuWindow > mpSubMenu
void setAllMemberState(bool bSet)
static constexpr size_t MENU_NOT_SELECTED
TRISTATE_INDET
void addMenuItem(const OUString &rText, Action *pAction)
sal_Int16 GetYear() const
void handleMenuTimeout(const SubMenuItemData *pTimer)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
SubMenuItemData maOpenTimer
std::unique_ptr< Action > mxOKAction
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
void clear()
void getResult(ResultType &rResult)
virtual void dispose() override
std::vector< OUString > maDateParts
void setMemberSize(size_t n)
ScCheckListMenuControl(ScCheckListMenuWindow *pParent, vcl::Window *pContainer, ScDocument *pDoc, bool bCanHaveSubMenu, int nWidth)
int i
VclPtr< ScCheckListMenuWindow > mxSubMenuWin
virtual void set_toggle(int row, TriState eState, int col=-1)=0
int GetCheckedEntryCount() const
std::shared_ptr< Action > mxAction
std::unique_ptr< weld::CheckButton > mxChkToggleAll
std::vector< ScCheckListMember > maMembers
void setSubMenuFocused(const ScCheckListMenuControl *pSubMenu)
TRISTATE_FALSE
std::map< OUString, size_t > maYearMonthMap
std::unique_ptr< weld::Box > mxButtonBox
std::unique_ptr< weld::Button > mxBtnOk
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
virtual void GetFocus() override
virtual void Start() override
ExtendedData * getExtendedData()
Get the store auxiliary data, or NULL if no such data is stored.
sal_uInt16 GetDay() const
void setExtendedData(std::unique_ptr< ExtendedData > p)
Set auxiliary data that the client code might need.
MouseNotifyEvent GetType() const
void AddDays(sal_Int32 nAddDays)
virtual void dispose() override
ScCheckListMenuWindow * addSubMenuItem(const OUString &rText, bool bEnabled)
void endSubMenu(ScCheckListMenuControl &rSubMenu)
void setConfig(const Config &rConfig)
OUString lowercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
void SetTimeout(sal_uInt64 nTimeoutMs)
DatePartType meDatePartType
FloatWinPopupFlags
void launchSubMenu(bool bSetMenuPos)
std::unique_ptr< weld::TreeIter > FindEntry(const weld::TreeIter *pParent, const OUString &sNode)
std::unique_ptr< ExtendedData > mxExtendedData
constexpr sal_uInt16 KEY_RETURN
SubMenuItemData(ScCheckListMenuControl *pParent)
vcl::Window * GetWindow(GetWindowType nType) const
bool close
constexpr sal_uInt16 KEY_RIGHT
virtual bool EventNotify(NotifyEvent &rNEvt) override
void reset(reference_type *pBody)
void launch(const tools::Rectangle &rRect)
RegionData_Impl * mpParent
void addMember(const OUString &rName, bool bVisible)
void set_id(const OUString &rID)
ScopedVclPtr< VirtualDevice > mxDropDown
SubMenuItemData maCloseTimer
void EnableDocking(bool bEnable=true)
bool mbVisible
static CalendarWrapper * GetCalendar()
Definition: global.cxx:1027
void Stop()
virtual void GetFocus()
std::unique_ptr< weld::Widget > mxBox
void terminateAllPopupMenus()
Dismiss all visible popup menus and set focus back to the application window.
OUString maName
css::uno::Sequence< css::i18n::CalendarItem2 > getMonths() const
ScCheckListMenuWindow(vcl::Window *pParent, ScDocument *pDoc, bool bCanHaveSubMenu, int nWidth=-1, ScCheckListMenuWindow *pParentMenu=nullptr)
std::unique_ptr< weld::Container > mxContainer
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1018
OUString aLabel
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void EndPopupMode(const vcl::Window *pWin)
long Left() const
ScCheckListMenuControl & get_widget()
std::unique_ptr< Action > mxPopupEndAction
void selectCurrentMemberOnly(bool bSet)
This class implements a popup window for field button, for quick access of hide-item list...
void addDateMember(const OUString &rName, double nVal, bool bVisible)
VirtualDevice * get() const
void GetRecursiveChecked(const weld::TreeIter *pEntry, std::unordered_set< OUString > &vOut, OUString &rLabel)
void StartPopupMode(const vcl::Window *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags)
void SetLeft(long v)
void DrawSymbol(const tools::Rectangle &rRect, SymbolType eType, const Color &rColor, DrawSymbolFlags nStyle=DrawSymbolFlags::NONE)
constexpr sal_uInt16 KEY_LEFT
void setHasDates(bool bHasDates)
std::unique_ptr< ScCheckListMenuControl, o3tl::default_delete< ScCheckListMenuControl > > mxControl
std::unique_ptr< weld::TreeView > mxChecks
const Date & GetNullDate() const
void setSelectedMenuItem(size_t nPos, bool bSubMenuTimer)
Extended data that the client code may need to store.
sal_Int32 get_border_width() const
void Check(const weld::TreeIter *pIter)
std::unique_ptr< weld::Button > mxBtnCancel
std::unique_ptr< weld::Entry > mxEdSearch
static DockingManager * GetDockingManager()
size_t getSubMenuPos(const ScCheckListMenuControl *pSubMenu)
virtual bool EventNotify(NotifyEvent &rNEvt) override