LibreOffice Module vcl (master)  1
wizardmachine.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 <comphelper/lok.hxx>
21 #include <officecfg/Office/Common.hxx>
22 #include <vcl/event.hxx>
23 #include <tools/debug.hxx>
24 #include <tools/diagnose_ex.h>
25 #include <strings.hrc>
26 #include <svdata.hxx>
27 #include <wizdlg.hxx>
28 #include <stack>
29 #include "wizimpldata.hxx"
30 
31 #define HID_WIZARD_NEXT "SVT_HID_WIZARD_NEXT"
32 #define HID_WIZARD_PREVIOUS "SVT_HID_WIZARD_PREVIOUS"
33 
34 #define WIZARDDIALOG_BUTTON_OFFSET_Y 6
35 #define WIZARDDIALOG_BUTTON_DLGOFFSET_X 6
36 #define WIZARDDIALOG_VIEW_DLGOFFSET_X 6
37 #define WIZARDDIALOG_VIEW_DLGOFFSET_Y 6
38 
39 namespace vcl
40 {
41  //= WizardPageImplData
42  OWizardPage::OWizardPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID)
43  : BuilderPage(pPage, pController, rUIXMLDescription, rID)
44  {
45  }
46 
48  {
49  }
50 
52  {
53  }
54 
56  {
59  }
60 
62  {
63  auto pWizardMachine = dynamic_cast<RoadmapWizardMachine*>(m_pDialogController);
64  if (pWizardMachine)
65  pWizardMachine->updateTravelUI();
66  }
67 
69  {
70  return true;
71  }
72 
74  {
75  return true;
76  }
77 
78  void RoadmapWizard::SetLeftAlignedButtonCount( sal_Int16 _nCount )
79  {
80  mnLeftAlignCount = _nCount;
81  }
82 
84  {
85  // calculate ButtonBar height and width
86  long nMaxHeight = 0;
88  ImplWizButtonData* pBtnData = mpFirstBtn;
89  while (pBtnData)
90  {
91  auto nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
92  auto nBtnWidth = pBtnData->mpButton->GetSizePixel().Width();
93  if (pBtnData->mpButton->IsVisible())
94  {
95  nBarWidth += nBtnWidth;
96  nBarWidth += pBtnData->mnOffset;
97  }
98  if ( nBtnHeight > nMaxHeight )
99  nMaxHeight = nBtnHeight;
100  pBtnData = pBtnData->mpNext;
101  }
102  if ( nMaxHeight )
103  nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
104  rSize.AdjustHeight(nMaxHeight);
105 
106  // add in the view window size
107  if ( mpViewWindow && mpViewWindow->IsVisible() )
108  {
109  Size aViewSize = mpViewWindow->GetSizePixel();
110  // align left
111  rSize.AdjustWidth(aViewSize.Width() );
112  }
113 
114  if (nBarWidth > rSize.Width())
115  rSize.setWidth(nBarWidth);
116  }
117 
119  {
121  return;
122  if (IsInClose())
123  return;
125  }
126 
127  IMPL_LINK_NOARG(RoadmapWizard, ImplHandleWizardLayoutTimerHdl, Timer*, void)
128  {
129  ImplPosCtrls();
130  ImplPosTabPage();
131  }
132 
134  {
135  Size aDlgSize = GetOutputSizePixel();
136  long nBtnWidth = 0;
137  long nMaxHeight = 0;
138  long nOffY = aDlgSize.Height();
139 
140  ImplWizButtonData* pBtnData = mpFirstBtn;
141  int j = 0;
142  while ( pBtnData )
143  {
144  if (j >= mnLeftAlignCount)
145  {
146  Size aBtnSize = pBtnData->mpButton->GetSizePixel();
147  long nBtnHeight = aBtnSize.Height();
148  if ( nBtnHeight > nMaxHeight )
149  nMaxHeight = nBtnHeight;
150  nBtnWidth += aBtnSize.Width();
151  nBtnWidth += pBtnData->mnOffset;
152  }
153  pBtnData = pBtnData->mpNext;
154  j++;
155  }
156 
157  if ( nMaxHeight )
158  {
159  long nOffX = aDlgSize.Width()-nBtnWidth-WIZARDDIALOG_BUTTON_DLGOFFSET_X;
160  long nOffLeftAlignX = LogicalCoordinateToPixel(6);
161  nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y+nMaxHeight;
162 
163  pBtnData = mpFirstBtn;
164  int i = 0;
165  while ( pBtnData )
166  {
167  Size aBtnSize = pBtnData->mpButton->GetSizePixel();
168  if (i >= mnLeftAlignCount)
169  {
170  Point aPos( nOffX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
171  pBtnData->mpButton->SetPosPixel( aPos );
172  nOffX += aBtnSize.Width();
173  nOffX += pBtnData->mnOffset;
174  }
175  else
176  {
177  Point aPos( nOffLeftAlignX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
178  pBtnData->mpButton->SetPosPixel( aPos );
179  nOffLeftAlignX += aBtnSize.Width();
180  nOffLeftAlignX += pBtnData->mnOffset;
181  }
182 
183  pBtnData = pBtnData->mpNext;
184  i++;
185  }
186 
188  }
189 
190  if ( !(mpViewWindow && mpViewWindow->IsVisible()) )
191  return;
192 
193  long nViewOffX = 0;
194  long nViewOffY = 0;
195  long nViewWidth = 0;
196  long nViewHeight = 0;
197  long nDlgHeight = nOffY;
198  PosSizeFlags nViewPosFlags = PosSizeFlags::Pos;
199  // align left
200  {
201  if ( mbEmptyViewMargin )
202  {
203  nViewOffX = 0;
204  nViewOffY = 0;
205  nViewHeight = nDlgHeight;
206  }
207  else
208  {
209  nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
210  nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
211  nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
212  }
213  nViewPosFlags |= PosSizeFlags::Height;
214  }
215  mpViewWindow->setPosSizePixel( nViewOffX, nViewOffY,
216  nViewWidth, nViewHeight,
217  nViewPosFlags );
218  }
219 
221  Size aLocSize = LogicToPixel(Size(iCoordinate, 0), MapMode(MapUnit::MapAppFont));
222  int iPixelCoordinate = aLocSize.Width();
223  return iPixelCoordinate;
224  }
225 
227  {
228  if ( !mpCurTabPage )
229  return;
230 
231  if ( !IsInInitShow() )
232  {
233  // #100199# - On Unix initial size is equal to screen size, on Windows
234  // it's 0,0. One cannot calculate the size unless dialog is visible.
235  if ( !IsReallyVisible() )
236  return;
237  }
238 
239  // calculate height of ButtonBar
240  long nMaxHeight = 0;
241  ImplWizButtonData* pBtnData = mpFirstBtn;
242  while ( pBtnData )
243  {
244  long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
245  if ( nBtnHeight > nMaxHeight )
246  nMaxHeight = nBtnHeight;
247  pBtnData = pBtnData->mpNext;
248  }
249  if ( nMaxHeight )
250  nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
251 
252  // position TabPage
253  Size aDlgSize = GetOutputSizePixel();
254  aDlgSize.AdjustHeight( -nMaxHeight );
255  long nOffX = 0;
256  long nOffY = 0;
257  if ( mpViewWindow && mpViewWindow->IsVisible() )
258  {
259  Size aViewSize = mpViewWindow->GetSizePixel();
260  // align left
261  long nViewOffset = mbEmptyViewMargin ? 0 : WIZARDDIALOG_VIEW_DLGOFFSET_X;
262  nOffX += aViewSize.Width() + nViewOffset;
263  aDlgSize.AdjustWidth( -nOffX );
264  }
265  Point aPos( nOffX, nOffY );
266  mpCurTabPage->SetPosSizePixel( aPos, aDlgSize );
267  }
268 
270  {
271  if ( mpCurTabPage == pTabPage )
272  return;
273 
274  TabPage* pOldTabPage = mpCurTabPage;
275 
276  mpCurTabPage = pTabPage;
277  if ( pTabPage )
278  {
279  ImplPosTabPage();
280  pTabPage->ActivatePage();
281  pTabPage->Show();
282  }
283 
284  if ( pOldTabPage )
285  pOldTabPage->Hide();
286  }
287 
288  TabPage* RoadmapWizard::ImplGetPage( sal_uInt16 nLevel ) const
289  {
290  sal_uInt16 nTempLevel = 0;
291  ImplWizPageData* pPageData = mpFirstPage;
292  while ( pPageData )
293  {
294  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
295  break;
296 
297  nTempLevel++;
298  pPageData = pPageData->mpNext;
299  }
300 
301  if ( pPageData )
302  return pPageData->mpPage;
303  return nullptr;
304  }
305 
307  {
308  m_xWizardImpl->sTitleBase = GetText();
309 
310  // create the buttons according to the wizard button flags
311  // the help button
312  if (_nButtonFlags & WizardButtonFlags::HELP)
313  {
315  m_pHelp->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
316  m_pHelp->Show();
318  }
319 
320  // the previous button
321  if (_nButtonFlags & WizardButtonFlags::PREVIOUS)
322  {
325  m_pPrevPage->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
326  m_pPrevPage->SetText(VclResId(STR_WIZDLG_PREVIOUS));
327  m_pPrevPage->Show();
328  m_pPrevPage->set_id("previous");
329 
330  if (_nButtonFlags & WizardButtonFlags::NEXT)
331  AddButton( m_pPrevPage, ( WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X) ); // half x-offset to the next button
332  else
335  m_pPrevPage->SetClickHdl( LINK( this, RoadmapWizard, OnPrevPage ) );
336  }
337 
338  // the next button
339  if (_nButtonFlags & WizardButtonFlags::NEXT)
340  {
343  m_pNextPage->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
344  m_pNextPage->SetText(VclResId(STR_WIZDLG_NEXT));
345  m_pNextPage->Show();
346  m_pNextPage->set_id("next");
347 
350  m_pNextPage->SetClickHdl( LINK( this, RoadmapWizard, OnNextPage ) );
351  }
352 
353  // the finish button
354  if (_nButtonFlags & WizardButtonFlags::FINISH)
355  {
357  m_pFinish->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
358  m_pFinish->SetText(VclResId(STR_WIZDLG_FINISH));
359  m_pFinish->Show();
360  m_pFinish->set_id("finish");
361 
363  m_pFinish->SetClickHdl( LINK( this, RoadmapWizard, OnFinish ) );
364  }
365 
366  // the cancel button
367  if (_nButtonFlags & WizardButtonFlags::CANCEL)
368  {
370  m_pCancel->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
371  m_pCancel->Show();
372 
374  }
375  }
376 
378  {
379  if ( IsReallyShown() && !IsInInitShow() )
380  {
381  ImplPosCtrls();
382  ImplPosTabPage();
383  }
384 
385  Dialog::Resize();
386  }
387 
389  {
390  OUString sCompleteTitle(m_xWizardImpl->sTitleBase);
391 
392  // append the page title
393  TabPage* pCurrentPage = GetPage(getCurrentState());
394  if ( pCurrentPage && !pCurrentPage->GetText().isEmpty() )
395  {
396  sCompleteTitle += " - " + pCurrentPage->GetText();
397  }
398 
399  SetText(sCompleteTitle);
400  }
401 
403  {
404  Size aDlgSize = GetPageSizePixel();
405  if ( !aDlgSize.Width() || !aDlgSize.Height() )
406  {
407  ImplWizPageData* pPageData = mpFirstPage;
408  while ( pPageData )
409  {
410  if ( pPageData->mpPage )
411  {
412  Size aPageSize = pPageData->mpPage->GetSizePixel();
413  if ( aPageSize.Width() > aDlgSize.Width() )
414  aDlgSize.setWidth( aPageSize.Width() );
415  if ( aPageSize.Height() > aDlgSize.Height() )
416  aDlgSize.setHeight( aPageSize.Height() );
417  }
418 
419  pPageData = pPageData->mpNext;
420  }
421  }
422  ImplCalcSize( aDlgSize );
423  SetMinOutputSizePixel( aDlgSize );
424  SetOutputSizePixel( aDlgSize );
425  }
426 
428  {
429  if ( nType == StateChangedType::InitShow )
430  {
431  if ( IsDefaultSize() )
432  {
433  CalcAndSetSize();
434  }
435 
436  ImplPosCtrls();
437  ImplPosTabPage();
439  }
440 
441  Dialog::StateChanged( nType );
442  }
443 
445  {
446  if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && mpPrevBtn && mpNextBtn )
447  {
448  const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
449  vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
450  sal_uInt16 nKeyCode = aKeyCode.GetCode();
451 
452  if ( aKeyCode.IsMod1() )
453  {
454  if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
455  {
456  if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
457  {
458  if ( mpPrevBtn->IsVisible() &&
460  {
461  mpPrevBtn->SetPressed( true );
462  mpPrevBtn->SetPressed( false );
463  mpPrevBtn->Click();
464  }
465  return true;
466  }
467  }
468  else
469  {
470  if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
471  {
472  if ( mpNextBtn->IsVisible() &&
474  {
475  mpNextBtn->SetPressed( true );
476  mpNextBtn->SetPressed( false );
477  mpNextBtn->Click();
478  }
479  return true;
480  }
481  }
482  }
483  }
484 
485  return Dialog::EventNotify( rNEvt );
486  }
487 
489  {
490  if ( nullptr == GetPage( i_nState ) )
491  {
492  VclPtr<TabPage> pNewPage = createPage( i_nState );
493  DBG_ASSERT( pNewPage, "RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" );
494 
495  // fill up the page sequence of our base class (with dummies)
496  while ( m_xWizardImpl->nFirstUnknownPage < i_nState )
497  {
498  AddPage( nullptr );
499  ++m_xWizardImpl->nFirstUnknownPage;
500  }
501 
502  if ( m_xWizardImpl->nFirstUnknownPage == i_nState )
503  {
504  // encountered this page number the first time
505  AddPage( pNewPage );
506  ++m_xWizardImpl->nFirstUnknownPage;
507  }
508  else
509  // already had this page - just change it
510  SetPage( i_nState, pNewPage );
511  }
512  return GetPage( i_nState );
513  }
514 
516  {
517  WizardTypes::WizardState nCurrentLevel = GetCurLevel();
518  GetOrCreatePage( nCurrentLevel );
519 
520  enterState( nCurrentLevel );
521  }
522 
523  bool RoadmapWizard::ShowPage( sal_uInt16 nLevel )
524  {
525  mnCurLevel = nLevel;
526  ActivatePage();
528  return true;
529  }
530 
531  bool RoadmapWizard::Finish( long nResult )
532  {
533  if ( IsInExecute() )
534  EndDialog( nResult );
535  else if ( GetStyle() & WB_CLOSEABLE )
536  Close();
537  return true;
538  }
539 
541  {
542  ImplWizPageData* pNewPageData = new ImplWizPageData;
543  pNewPageData->mpNext = nullptr;
544  pNewPageData->mpPage = pPage;
545 
546  if ( !mpFirstPage )
547  mpFirstPage = pNewPageData;
548  else
549  {
550  ImplWizPageData* pPageData = mpFirstPage;
551  while ( pPageData->mpNext )
552  pPageData = pPageData->mpNext;
553  pPageData->mpNext = pNewPageData;
554  }
555  }
556 
558  {
559  ImplWizPageData* pPrevPageData = nullptr;
560  ImplWizPageData* pPageData = mpFirstPage;
561  while ( pPageData )
562  {
563  if ( pPageData->mpPage == pPage )
564  {
565  if ( pPrevPageData )
566  pPrevPageData->mpNext = pPageData->mpNext;
567  else
568  mpFirstPage = pPageData->mpNext;
569  if ( pPage == mpCurTabPage )
570  mpCurTabPage = nullptr;
571  delete pPageData;
572  return;
573  }
574 
575  pPrevPageData = pPageData;
576  pPageData = pPageData->mpNext;
577  }
578 
579  OSL_FAIL( "RoadmapWizard::RemovePage() - Page not in list" );
580  }
581 
582  void RoadmapWizard::SetPage( sal_uInt16 nLevel, TabPage* pPage )
583  {
584  sal_uInt16 nTempLevel = 0;
585  ImplWizPageData* pPageData = mpFirstPage;
586  while ( pPageData )
587  {
588  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
589  break;
590 
591  nTempLevel++;
592  pPageData = pPageData->mpNext;
593  }
594 
595  if ( pPageData )
596  {
597  if ( pPageData->mpPage == mpCurTabPage )
598  mpCurTabPage = nullptr;
599  pPageData->mpPage = pPage;
600  }
601  }
602 
603  TabPage* RoadmapWizard::GetPage( sal_uInt16 nLevel ) const
604  {
605  sal_uInt16 nTempLevel = 0;
606 
607  for (ImplWizPageData* pPageData = mpFirstPage; pPageData;
608  pPageData = pPageData->mpNext)
609  {
610  if ( nTempLevel == nLevel )
611  return pPageData->mpPage;
612  nTempLevel++;
613  }
614 
615  return nullptr;
616  }
617 
618  void RoadmapWizard::AddButton( Button* pButton, long nOffset )
619  {
620  ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
621  pNewBtnData->mpNext = nullptr;
622  pNewBtnData->mpButton = pButton;
623  pNewBtnData->mnOffset = nOffset;
624 
625  if ( !mpFirstBtn )
626  mpFirstBtn = pNewBtnData;
627  else
628  {
629  ImplWizButtonData* pBtnData = mpFirstBtn;
630  while ( pBtnData->mpNext )
631  pBtnData = pBtnData->mpNext;
632  pBtnData->mpNext = pNewBtnData;
633  }
634  }
635 
637  {
638  ImplWizButtonData* pPrevBtnData = nullptr;
639  ImplWizButtonData* pBtnData = mpFirstBtn;
640  while ( pBtnData )
641  {
642  if ( pBtnData->mpButton == pButton )
643  {
644  if ( pPrevBtnData )
645  pPrevBtnData->mpNext = pBtnData->mpNext;
646  else
647  mpFirstBtn = pBtnData->mpNext;
648  delete pBtnData;
649  return;
650  }
651 
652  pPrevBtnData = pBtnData;
653  pBtnData = pBtnData->mpNext;
654  }
655 
656  OSL_FAIL( "RoadmapWizard::RemoveButton() - Button not in list" );
657  }
658 
659  void RoadmapWizard::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
660  {
661  if (m_pFinish && (_nWizardButtonFlags & WizardButtonFlags::FINISH))
662  m_pFinish->Enable(_bEnable);
663  if (m_pNextPage && (_nWizardButtonFlags & WizardButtonFlags::NEXT))
664  m_pNextPage->Enable(_bEnable);
665  if (m_pPrevPage && (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS))
666  m_pPrevPage->Enable(_bEnable);
667  if (m_pHelp && (_nWizardButtonFlags & WizardButtonFlags::HELP))
668  m_pHelp->Enable(_bEnable);
669  if (m_pCancel && (_nWizardButtonFlags & WizardButtonFlags::CANCEL))
670  m_pCancel->Enable(_bEnable);
671  }
672 
674  {
675  if ( isTravelingSuspended() )
676  return;
677  RoadmapWizardTravelSuspension aTravelGuard( *this );
678  if (!prepareLeaveCurrentState(WizardTypes::eFinish))
679  {
680  return;
681  }
682  Finish( RET_OK );
683  }
684 
686  {
688  ENSURE_OR_RETURN( pController != nullptr, "RoadmapWizard::prepareLeaveCurrentState: no controller for the current page!", true );
689  return pController->commitPage( _eReason );
690  }
691 
693  {
694  // allowed to leave the current page?
696  return false;
697 
698  // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
699  std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
700  std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
701 
702  WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
703  while ( nCurrentRollbackState != _nTargetState )
704  {
705  DBG_ASSERT( !aTravelVirtually.empty(), "RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" );
706  nCurrentRollbackState = aTravelVirtually.top();
707  aTravelVirtually.pop();
708  }
709  m_xWizardImpl->aStateHistory = aTravelVirtually;
710  if ( !ShowPage( _nTargetState ) )
711  {
712  m_xWizardImpl->aStateHistory = aOldStateHistory;
713  return false;
714  }
715  return true;
716  }
717 
719  {
720  WizardTypes::WizardState nCurrentState = getCurrentState();
721 
722  // allowed to leave the current page?
723  if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
724  return false;
725 
726  // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
727  std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
728  std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
729  while ( nCurrentState != _nTargetState )
730  {
731  WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
732  if ( WZS_INVALID_STATE == nNextState )
733  {
734  OSL_FAIL( "RoadmapWizard::skipUntil: the given target state does not exist!" );
735  return false;
736  }
737 
738  // remember the skipped state in the history
739  aTravelVirtually.push( nCurrentState );
740 
741  // get the next state
742  nCurrentState = nNextState;
743  }
744  m_xWizardImpl->aStateHistory = aTravelVirtually;
745  // show the target page
746  if ( !ShowPage( nCurrentState ) )
747  {
748  // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
749  // but ShowPage doesn't? Somebody behaves very strange here...
750  OSL_FAIL( "RoadmapWizard::skipUntil: very unpolite..." );
751  m_xWizardImpl->aStateHistory = aOldStateHistory;
752  return false;
753  }
754  return true;
755  }
756 
758  {
759  // allowed to leave the current page?
761  return false;
762 
763  // determine the next state to travel to
764  WizardTypes::WizardState nCurrentState = getCurrentState();
765  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
766  if (WZS_INVALID_STATE == nNextState)
767  return false;
768 
769  // the state history is used by the enterState method
770  // all fine
771  m_xWizardImpl->aStateHistory.push(nCurrentState);
772  if (!ShowPage(nNextState))
773  {
774  m_xWizardImpl->aStateHistory.pop();
775  return false;
776  }
777 
778  return true;
779  }
780 
782  {
783  DBG_ASSERT(!m_xWizardImpl->aStateHistory.empty(), "RoadmapWizard::travelPrevious: have no previous page!");
784 
785  // allowed to leave the current page?
787  return false;
788 
789  // the next state to switch to
790  WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
791 
792  // the state history is used by the enterState method
793  m_xWizardImpl->aStateHistory.pop();
794  // show this page
795  if (!ShowPage(nPreviousState))
796  {
797  m_xWizardImpl->aStateHistory.push(nPreviousState);
798  return false;
799  }
800 
801  // all fine
802  return true;
803  }
804 
806  {
807 
808  std::stack< WizardTypes::WizardState > aTemp;
809  while(!m_xWizardImpl->aStateHistory.empty())
810  {
811  WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
812  m_xWizardImpl->aStateHistory.pop();
813  if(nPreviousState != nToRemove)
814  aTemp.push( nPreviousState );
815  else
816  break;
817  }
818  while(!aTemp.empty())
819  {
820  m_xWizardImpl->aStateHistory.push( aTemp.top() );
821  aTemp.pop();
822  }
823  }
824 
826  {
827  return m_xWizardImpl->m_bAutoNextButtonState;
828  }
829 
830  IMPL_LINK_NOARG(RoadmapWizard, OnPrevPage, Button*, void)
831  {
832  if ( isTravelingSuspended() )
833  return;
834  RoadmapWizardTravelSuspension aTravelGuard( *this );
835  travelPrevious();
836  }
837 
838  IMPL_LINK_NOARG(RoadmapWizard, OnNextPage, Button*, void)
839  {
840  if ( isTravelingSuspended() )
841  return;
842  RoadmapWizardTravelSuspension aTravelGuard( *this );
843  travelNext();
844  }
845 
847  {
848  IWizardPageController* pController = dynamic_cast< IWizardPageController* >( _pCurrentPage );
849  return pController;
850  }
851 
853  {
854  return m_xWizardImpl->m_bTravelingSuspended;
855  }
856 
858  {
859  DBG_ASSERT( !m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::suspendTraveling: already suspended!" );
860  m_xWizardImpl->m_bTravelingSuspended = true;
861  }
862 
864  {
865  DBG_ASSERT( m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::resumeTraveling: nothing to resume!" );
866  m_xWizardImpl->m_bTravelingSuspended = false;
867  }
868 
870  : AssistantController(pParent, "vcl/ui/wizard.ui", "Wizard")
871  , m_pCurTabPage(nullptr)
872  , m_nCurState(0)
873  , m_pFirstPage(nullptr)
874  , m_xFinish(m_xAssistant->weld_widget_for_response(RET_OK))
875  , m_xCancel(m_xAssistant->weld_widget_for_response(RET_CANCEL))
876  , m_xNextPage(m_xAssistant->weld_widget_for_response(RET_YES))
877  , m_xPrevPage(m_xAssistant->weld_widget_for_response(RET_NO))
878  , m_xHelp(m_xAssistant->weld_widget_for_response(RET_HELP))
880  {
881  implConstruct(nButtonFlags);
882  }
883 
885  {
886  m_pImpl->sTitleBase = m_xAssistant->get_title();
887 
888  const bool bHideHelp = comphelper::LibreOfficeKit::isActive() &&
889  officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
890  // create the buttons according to the wizard button flags
891  // the help button
892  if (nButtonFlags & WizardButtonFlags::HELP && !bHideHelp)
893  m_xHelp->show();
894  else
895  m_xHelp->hide();
896 
897  // the previous button
898  if (nButtonFlags & WizardButtonFlags::PREVIOUS)
899  {
900  m_xPrevPage->set_help_id( HID_WIZARD_PREVIOUS );
901  m_xPrevPage->show();
902 
903  m_xPrevPage->connect_clicked( LINK( this, WizardMachine, OnPrevPage ) );
904  }
905  else
906  m_xPrevPage->hide();
907 
908  // the next button
909  if (nButtonFlags & WizardButtonFlags::NEXT)
910  {
911  m_xNextPage->set_help_id( HID_WIZARD_NEXT );
912  m_xNextPage->show();
913 
914  m_xNextPage->connect_clicked( LINK( this, WizardMachine, OnNextPage ) );
915  }
916  else
917  m_xNextPage->hide();
918 
919  // the finish button
920  if (nButtonFlags & WizardButtonFlags::FINISH)
921  {
922  m_xFinish->show();
923 
924  m_xFinish->connect_clicked( LINK( this, WizardMachine, OnFinish ) );
925  }
926  else
927  m_xFinish->hide();
928 
929  // the cancel button
930  if (nButtonFlags & WizardButtonFlags::CANCEL)
931  {
932  m_xCancel->show();
933  m_xCancel->connect_clicked( LINK( this, WizardMachine, OnCancel ) );
934  }
935  else
936  m_xCancel->hide();
937  }
938 
940  {
941  if (m_pImpl)
942  {
943  while (m_pFirstPage)
945  m_pImpl.reset();
946  }
947  }
948 
950  {
951  OUString sCompleteTitle(m_pImpl->sTitleBase);
952 
953  // append the page title
954  BuilderPage* pCurrentPage = GetPage(getCurrentState());
955  if ( pCurrentPage && !pCurrentPage->GetPageTitle().isEmpty() )
956  {
957  sCompleteTitle += " - " + pCurrentPage->GetPageTitle();
958  }
959 
960  m_xAssistant->set_title(sCompleteTitle);
961  }
962 
963  void WizardMachine::setTitleBase(const OUString& _rTitleBase)
964  {
965  m_pImpl->sTitleBase = _rTitleBase;
966  implUpdateTitle();
967  }
968 
970  {
971  if ( nullptr == GetPage( i_nState ) )
972  {
973  std::unique_ptr<BuilderPage> xNewPage = createPage( i_nState );
974  DBG_ASSERT( xNewPage, "WizardMachine::GetOrCreatePage: invalid new page (NULL)!" );
975 
976  // fill up the page sequence of our base class (with dummies)
977  while ( m_pImpl->nFirstUnknownPage < i_nState )
978  {
979  AddPage( nullptr );
980  ++m_pImpl->nFirstUnknownPage;
981  }
982 
983  if ( m_pImpl->nFirstUnknownPage == i_nState )
984  {
985  // encountered this page number the first time
986  AddPage(std::move(xNewPage));
987  ++m_pImpl->nFirstUnknownPage;
988  }
989  else
990  // already had this page - just change it
991  SetPage(i_nState, std::move(xNewPage));
992  }
993  return GetPage( i_nState );
994  }
995 
997  {
998  WizardTypes::WizardState nCurrentLevel = m_nCurState;
999  GetOrCreatePage( nCurrentLevel );
1000 
1001  enterState( nCurrentLevel );
1002  }
1003 
1005  {
1006  WizardTypes::WizardState nCurrentState = getCurrentState();
1007  return leaveState(nCurrentState);
1008  }
1009 
1011  {
1012  // the new default button
1013  weld::Button* pNewDefButton = nullptr;
1014  if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
1015  pNewDefButton = m_xFinish.get();
1016  if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
1017  pNewDefButton = m_xNextPage.get();
1018  if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
1019  pNewDefButton = m_xPrevPage.get();
1020  if (_nWizardButtonFlags & WizardButtonFlags::HELP)
1021  pNewDefButton = m_xHelp.get();
1022  if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
1023  pNewDefButton = m_xCancel.get();
1024 
1025  if ( pNewDefButton )
1026  defaultButton( pNewDefButton );
1027  else
1028  m_xAssistant->recursively_unset_default_buttons();
1029  }
1030 
1032  {
1033  // loop through all (direct and indirect) descendants which participate in our tabbing order, and
1034  // reset the WB_DEFBUTTON for every window which is a button
1035  m_xAssistant->recursively_unset_default_buttons();
1036 
1037  // set its new style
1038  if (_pNewDefButton)
1039  _pNewDefButton->set_has_default(true);
1040  }
1041 
1042  void WizardMachine::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
1043  {
1044  if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
1045  m_xFinish->set_sensitive(_bEnable);
1046  if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
1047  m_xNextPage->set_sensitive(_bEnable);
1048  if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
1049  m_xPrevPage->set_sensitive(_bEnable);
1050  if (_nWizardButtonFlags & WizardButtonFlags::HELP)
1051  m_xHelp->set_sensitive(_bEnable);
1052  if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
1053  m_xCancel->set_sensitive(_bEnable);
1054  }
1055 
1057  {
1058  // tell the page
1059  IWizardPageController* pController = getPageController( GetPage( _nState ) );
1060  OSL_ENSURE( pController, "WizardMachine::enterState: no controller for the given page!" );
1061  if ( pController )
1062  pController->initializePage();
1063 
1066 
1067  enableButtons( WizardButtonFlags::PREVIOUS, !m_pImpl->aStateHistory.empty() );
1068 
1069  // set the new title - it depends on the current page (i.e. state)
1070  implUpdateTitle();
1071  }
1072 
1074  {
1075  // no need to ask the page here.
1076  // If we reach this point, we already gave the current page the chance to commit it's data,
1077  // and it was allowed to commit it's data
1078 
1079  return true;
1080  }
1081 
1083  {
1084  return Finish(RET_OK);
1085  }
1086 
1088  {
1089  if ( isTravelingSuspended() )
1090  return;
1091  WizardTravelSuspension aTravelGuard( *this );
1092  if (!prepareLeaveCurrentState(WizardTypes::eFinish))
1093  {
1094  return;
1095  }
1096  onFinish();
1097  }
1098 
1100  {
1101  m_xAssistant->response(RET_CANCEL);
1102  }
1103 
1105  {
1106  return _nCurrentState + 1;
1107  }
1108 
1110  {
1112  ENSURE_OR_RETURN( pController != nullptr, "WizardMachine::prepareLeaveCurrentState: no controller for the current page!", true );
1113  return pController->commitPage( _eReason );
1114  }
1115 
1117  {
1118  // allowed to leave the current page?
1120  return false;
1121 
1122  // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1123  std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1124  std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1125 
1126  WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
1127  while ( nCurrentRollbackState != _nTargetState )
1128  {
1129  DBG_ASSERT( !aTravelVirtually.empty(), "WizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
1130  nCurrentRollbackState = aTravelVirtually.top();
1131  aTravelVirtually.pop();
1132  }
1133  m_pImpl->aStateHistory = aTravelVirtually;
1134  if ( !ShowPage( _nTargetState ) )
1135  {
1136  m_pImpl->aStateHistory = aOldStateHistory;
1137  return false;
1138  }
1139  return true;
1140  }
1141 
1143  {
1144  WizardTypes::WizardState nCurrentState = getCurrentState();
1145 
1146  // allowed to leave the current page?
1147  if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
1148  return false;
1149 
1150  // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1151  std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1152  std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1153  while ( nCurrentState != _nTargetState )
1154  {
1155  WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
1156  if ( WZS_INVALID_STATE == nNextState )
1157  {
1158  OSL_FAIL( "WizardMachine::skipUntil: the given target state does not exist!" );
1159  return false;
1160  }
1161 
1162  // remember the skipped state in the history
1163  aTravelVirtually.push( nCurrentState );
1164 
1165  // get the next state
1166  nCurrentState = nNextState;
1167  }
1168  m_pImpl->aStateHistory = aTravelVirtually;
1169  // show the target page
1170  if ( !ShowPage( nCurrentState ) )
1171  {
1172  // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
1173  // but ShowPage doesn't? Somebody behaves very strange here...
1174  OSL_FAIL( "WizardMachine::skipUntil: very unpolite..." );
1175  m_pImpl->aStateHistory = aOldStateHistory;
1176  return false;
1177  }
1178  return true;
1179  }
1180 
1182  {
1183  // allowed to leave the current page?
1185  return;
1186 
1187  WizardTypes::WizardState nCurrentState = getCurrentState();
1188  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1189 
1190  if (WZS_INVALID_STATE == nNextState)
1191  return;
1192 
1193  // remember the skipped state in the history
1194  m_pImpl->aStateHistory.push(nCurrentState);
1195 
1196  // get the next state
1197  nCurrentState = nNextState;
1198 
1199  // show the (n+1)th page
1200  if (!ShowPage(nCurrentState))
1201  {
1202  // TODO: this leaves us in a state where we have no current page and an inconsistent state history.
1203  // Perhaps we should rollback the skipping here...
1204  OSL_FAIL("RoadmapWizard::skip: very unpolite...");
1205  // if somebody does a skip and then does not allow to leave...
1206  // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here,
1207  // somebody behaves really strange ...)
1208  return;
1209  }
1210 
1211  // all fine
1212  }
1213 
1215  {
1216  // allowed to leave the current page?
1218  return false;
1219 
1220  // determine the next state to travel to
1221  WizardTypes::WizardState nCurrentState = getCurrentState();
1222  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1223  if (WZS_INVALID_STATE == nNextState)
1224  return false;
1225 
1226  // the state history is used by the enterState method
1227  // all fine
1228  m_pImpl->aStateHistory.push(nCurrentState);
1229  if (!ShowPage(nNextState))
1230  {
1231  m_pImpl->aStateHistory.pop();
1232  return false;
1233  }
1234 
1235  return true;
1236  }
1237 
1239  {
1240  if (DeactivatePage())
1241  {
1242  BuilderPage* pOldTabPage = m_pCurTabPage;
1243 
1244  m_nCurState = nState;
1245  ActivatePage();
1246 
1247  if (pOldTabPage)
1248  pOldTabPage->Deactivate();
1249 
1250  m_xAssistant->set_current_page(OString::number(nState));
1251 
1254 
1255  return true;
1256  }
1257  return false;
1258  }
1259 
1261  {
1262  return ShowPage(m_nCurState + 1);
1263  }
1264 
1266  {
1267  if (!m_nCurState)
1268  return false;
1269  return ShowPage(m_nCurState - 1);
1270  }
1271 
1273  {
1274  DBG_ASSERT(!m_pImpl->aStateHistory.empty(), "WizardMachine::travelPrevious: have no previous page!");
1275 
1276  // allowed to leave the current page?
1278  return false;
1279 
1280  // the next state to switch to
1281  WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1282 
1283  // the state history is used by the enterState method
1284  m_pImpl->aStateHistory.pop();
1285  // show this page
1286  if (!ShowPage(nPreviousState))
1287  {
1288  m_pImpl->aStateHistory.push(nPreviousState);
1289  return false;
1290  }
1291 
1292  // all fine
1293  return true;
1294  }
1295 
1296 
1298  {
1299 
1300  std::stack< WizardTypes::WizardState > aTemp;
1301  while(!m_pImpl->aStateHistory.empty())
1302  {
1303  WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1304  m_pImpl->aStateHistory.pop();
1305  if(nPreviousState != nToRemove)
1306  aTemp.push( nPreviousState );
1307  else
1308  break;
1309  }
1310  while(!aTemp.empty())
1311  {
1312  m_pImpl->aStateHistory.push( aTemp.top() );
1313  aTemp.pop();
1314  }
1315  }
1316 
1317 
1319  {
1320  m_pImpl->m_bAutoNextButtonState = true;
1321  }
1322 
1323 
1325  {
1326  return m_pImpl->m_bAutoNextButtonState;
1327  }
1328 
1330  {
1331  if ( isTravelingSuspended() )
1332  return;
1333  WizardTravelSuspension aTravelGuard( *this );
1334  travelPrevious();
1335  }
1336 
1338  {
1339  if ( isTravelingSuspended() )
1340  return;
1341  WizardTravelSuspension aTravelGuard( *this );
1342  travelNext();
1343  }
1344 
1346  {
1347  IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage);
1348  return pController;
1349  }
1350 
1351  void WizardMachine::getStateHistory( std::vector< WizardTypes::WizardState >& _out_rHistory )
1352  {
1353  std::stack< WizardTypes::WizardState > aHistoryCopy( m_pImpl->aStateHistory );
1354  while ( !aHistoryCopy.empty() )
1355  {
1356  _out_rHistory.push_back( aHistoryCopy.top() );
1357  aHistoryCopy.pop();
1358  }
1359  }
1360 
1362  {
1364  }
1365 
1367  {
1368  const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) );
1369  OSL_ENSURE( pController != nullptr, "RoadmapWizard::updateTravelUI: no controller for the current page!" );
1370 
1371  bool bCanAdvance =
1372  ( !pController || pController->canAdvance() ) // the current page allows to advance
1373  && canAdvance(); // the dialog as a whole allows to advance
1374  enableButtons( WizardButtonFlags::NEXT, bCanAdvance );
1375  }
1376 
1378  {
1379  return m_pImpl->m_bTravelingSuspended;
1380  }
1381 
1383  {
1384  DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "WizardMachine::suspendTraveling: already suspended!" );
1385  m_pImpl->m_bTravelingSuspended = true;
1386  }
1387 
1389  {
1390  DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "WizardMachine::resumeTraveling: nothing to resume!" );
1391  m_pImpl->m_bTravelingSuspended = false;
1392  }
1393 
1394  bool WizardMachine::Finish(short nResult)
1395  {
1396  if ( DeactivatePage() )
1397  {
1398  if (m_pCurTabPage)
1400 
1401  m_xAssistant->response(nResult);
1402  return true;
1403  }
1404  else
1405  return false;
1406  }
1407 
1408  void WizardMachine::AddPage(std::unique_ptr<BuilderPage> xPage)
1409  {
1410  WizPageData* pNewPageData = new WizPageData;
1411  pNewPageData->mpNext = nullptr;
1412  pNewPageData->mxPage = std::move(xPage);
1413 
1414  if ( !m_pFirstPage )
1415  m_pFirstPage = pNewPageData;
1416  else
1417  {
1418  WizPageData* pPageData = m_pFirstPage;
1419  while ( pPageData->mpNext )
1420  pPageData = pPageData->mpNext;
1421  pPageData->mpNext = pNewPageData;
1422  }
1423  }
1424 
1426  {
1427  WizPageData* pPrevPageData = nullptr;
1428  WizPageData* pPageData = m_pFirstPage;
1429  while ( pPageData )
1430  {
1431  if (pPageData->mxPage.get() == pPage)
1432  {
1433  if (pPrevPageData)
1434  pPrevPageData->mpNext = pPageData->mpNext;
1435  else
1436  m_pFirstPage = pPageData->mpNext;
1437  if (pPage == m_pCurTabPage)
1438  m_pCurTabPage = nullptr;
1439  delete pPageData;
1440  return;
1441  }
1442 
1443  pPrevPageData = pPageData;
1444  pPageData = pPageData->mpNext;
1445  }
1446 
1447  OSL_FAIL( "WizardMachine::RemovePage() - Page not in list" );
1448  }
1449 
1450  void WizardMachine::SetPage(WizardTypes::WizardState nLevel, std::unique_ptr<BuilderPage> xPage)
1451  {
1452  sal_uInt16 nTempLevel = 0;
1453  WizPageData* pPageData = m_pFirstPage;
1454  while ( pPageData )
1455  {
1456  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
1457  break;
1458 
1459  nTempLevel++;
1460  pPageData = pPageData->mpNext;
1461  }
1462 
1463  if ( pPageData )
1464  {
1465  if (pPageData->mxPage.get() == m_pCurTabPage)
1466  m_pCurTabPage = nullptr;
1467  pPageData->mxPage = std::move(xPage);
1468  }
1469  }
1470 
1472  {
1473  sal_uInt16 nTempLevel = 0;
1474 
1475  for (WizPageData* pPageData = m_pFirstPage; pPageData;
1476  pPageData = pPageData->mpNext)
1477  {
1478  if ( nTempLevel == nLevel )
1479  return pPageData->mxPage.get();
1480  nTempLevel++;
1481  }
1482 
1483  return nullptr;
1484  }
1485 } // namespace svt
1486 
1487 
1488 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Button > m_xPrevPage
long Width() const
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
bool IsInputEnabled() const
Definition: window2.cxx:1127
bool isTravelingSuspended() const
wizard for a roadmap
Definition: wizdlg.hxx:65
virtual bool canAdvance() const override
determines whether or not it is allowed to advance to a next page
void resumeTraveling(AccessGuard)
virtual bool leaveState(WizardTypes::WizardState nState)
will be called when the given state is left
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dialog.cxx:641
virtual bool Close() override
Definition: dialog.cxx:820
long AdjustWidth(long n)
void SetClickHdl(const Link< Button *, void > &rLink)
Definition: button.hxx:70
VclPtr< vcl::Window > mpViewWindow
Definition: wizdlg.hxx:75
virtual void initializePage()=0
long Height() const
void suspendTraveling(AccessGuard)
sal_uInt16 mnCurLevel
Definition: wizdlg.hxx:76
virtual void ActivatePage()
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
std::unique_ptr< WizardMachineImplData > m_xWizardImpl
Definition: wizdlg.hxx:105
virtual void updateTravelUI() override
updates the user interface which deals with traveling in the wizard
#define WIZARDDIALOG_VIEW_DLGOFFSET_X
std::unique_ptr< WizardMachineImplData > m_pImpl
void ImplCalcSize(Size &rSize)
virtual Size GetSizePixel() const
Definition: window.cxx:2415
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1262
sal_Int16 mnLeftAlignCount
Definition: wizdlg.hxx:77
void enableAutomaticNextButtonState()
enables the automatic enabled/disabled state of the "Next" button
ImplWizPageData * mpFirstPage
Definition: wizdlg.hxx:70
sal_uInt16 GetCode() const
Definition: keycod.hxx:53
is - no, not a wizard for a roadmap, but the base class for wizards supporting a roadmap.
PosSizeFlags
Definition: window.hxx:141
#define WIZARDDIALOG_BUTTON_OFFSET_Y
virtual bool canAdvance() const
determines whether there is a next state to which we can advance
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:315
virtual ~WizardMachine() override
virtual IWizardPageController * getPageController(BuilderPage *pCurrentPage) const
void SetHelpId(const OString &)
Definition: window2.cxx:823
void AddButton(Button *pButton, long nOffset=0)
VclPtr< Button > mpButton
Definition: wizimpldata.hxx:34
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
TabPage * GetOrCreatePage(const WizardTypes::WizardState i_nState)
long AdjustHeight(long n)
std::unique_ptr< weld::Button > m_xHelp
void defaultButton(WizardButtonFlags _nWizardButtonFlags)
set the default style for a button
WizardButtonFlags
Definition: vclenum.hxx:279
#define HID_WIZARD_NEXT
bool IsActive() const
Definition: task.hxx:90
StateChangedType
Definition: window.hxx:311
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2732
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2446
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
Definition: wizdlg.hxx:237
void SetPage(WizardTypes::WizardState nLevel, std::unique_ptr< BuilderPage > xPage)
const OUString & GetPageTitle() const
Definition: builderpage.hxx:29
bool IsDefaultSize() const
Definition: window2.cxx:1153
virtual void set_has_default(bool has_default)=0
void Hide()
Definition: window.hxx:936
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
virtual void Start() override
Activates the timer task.
Definition: idle.cxx:34
WizPageData * mpNext
Definition: wizimpldata.hxx:27
virtual void Click()
Definition: button.cxx:121
VclPtr< TabPage > mpPage
Definition: wizdlg.hxx:32
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1274
#define WZS_INVALID_STATE
virtual OUString GetText() const
Definition: window.cxx:3110
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
VCL_DLLPRIVATE void implConstruct(const WizardButtonFlags _nButtonFlags)
virtual void Deactivate()
Definition: weldutils.cxx:26
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
virtual void ActivatePage()
Definition: tabpage.cxx:171
void SetLeftAlignedButtonCount(sal_Int16 _nCount)
sets the number of buttons which should be left-aligned.
std::unique_ptr< weld::Button > m_xCancel
ImplWizPageData * mpNext
Definition: wizdlg.hxx:31
VclPtr< TabPage > mpCurTabPage
Definition: wizdlg.hxx:72
void RemoveButton(Button *pButton)
VclPtr< TabPage > createPage(WizardTypes::WizardState nState)
to override to create new pages
void updateDialogTravelUI()
updates the travel-related UI elements of the OWizardMachine we live in (if any)
sal_uInt16 GetCurLevel() const
Definition: wizdlg.hxx:124
ImplWizButtonData * mpFirstBtn
Definition: wizdlg.hxx:71
void SetMinOutputSizePixel(const Size &rSize)
Definition: syswin.cxx:397
WizPageData * m_pFirstPage
std::unique_ptr< weld::Button > m_xNextPage
virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
bool isAutomaticNextButtonStateEnabled() const
bool Finish(long nResult=0)
virtual void Activate() override
virtual bool prepareLeaveCurrentState(WizardTypes::CommitPageReason eReason)
will be called when the current state is about to be left for the given reason
TabPage * GetPage(sal_uInt16 nLevel) const
#define DBG_ASSERT(sCon, aError)
int i
VclPtr< PushButton > m_pNextPage
Definition: wizdlg.hxx:100
weld::DialogController * m_pDialogController
Definition: builderpage.hxx:40
sal_Int16 WizardState
virtual bool canAdvance() const =0
determines whether or not it is allowed to advance to a next page
OWizardPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID)
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X
WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
virtual bool commitPage(WizardTypes::CommitPageReason _eReason)=0
virtual bool DeactivatePage()
#define ENSURE_OR_RETURN(c, m, r)
virtual bool EventNotify(NotifyEvent &rNEvt) override
bool IsInInitShow() const
Definition: window2.cxx:1117
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
const Size & GetPageSizePixel() const
Definition: wizdlg.hxx:135
MouseNotifyEvent GetType() const
Definition: event.hxx:307
VclPtr< PushButton > mpNextBtn
Definition: wizdlg.hxx:74
virtual ~OWizardPage() override
virtual void Resize() override
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
bool IsInExecute() const
Definition: dialog.hxx:119
bool isTravelingSuspended() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: tabpage.cxx:182
virtual void StateChanged(StateChangedType nStateChange) override
void RemovePage(const BuilderPage *pPage)
implements some kind of finite automata, where the states of the automata exactly correlate with tab ...
bool IsReallyShown() const
Definition: window2.cxx:1112
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
virtual bool onFinish()
called when the finish button is pressed
void AddPage(std::unique_ptr< BuilderPage > xPage)
void suspendTraveling(AccessGuard)
virtual void Activate()
Definition: weldutils.cxx:24
bool travelNext()
travel to the next state
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:934
#define WIZARDDIALOG_VIEW_DLGOFFSET_Y
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3933
helper class to temporarily suspend any traveling in the wizard
Definition: wizdlg.hxx:290
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual void Resize() override
Definition: dialog.cxx:1348
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
long LogicalCoordinateToPixel(int iCoordinate)
VclPtr< PushButton > mpPrevBtn
Definition: wizdlg.hxx:73
virtual void StateChanged(StateChangedType nStateChange) override
Definition: dialog.cxx:735
void SetPressed(bool bPressed)
Definition: button.cxx:1536
bool IsShift() const
Definition: keycod.hxx:58
std::unique_ptr< weld::Button > m_xFinish
WizardMachine(weld::Window *_pParent, WizardButtonFlags _nButtonFlags)
bool travelNext()
travel to the next state
void RemovePage(TabPage *pPage)
void implConstruct(const WizardButtonFlags _nButtonFlags)
void getStateHistory(std::vector< WizardTypes::WizardState > &out_rHistory)
retrieves a copy of the state history, i.e.
bool IsVisible() const
Definition: window2.cxx:1102
virtual OUString GetText() const override
Definition: syswin.cxx:1109
#define WIZARDDIALOG_BUTTON_STDOFFSET_X
bool travelPrevious()
travel to the previous state
bool Finish(short nResult=RET_CANCEL)
void setTitleBase(const OUString &_rTitleBase)
set the base of the title to use - the title of the current page is appended
virtual void SetText(const OUString &rStr) override
Definition: syswin.cxx:1103
bool IsMod1() const
Definition: keycod.hxx:60
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
VclPtr< CancelButton > m_pCancel
Definition: wizdlg.hxx:99
bool travelPrevious()
travel to the previous state
VCL_DLLPRIVATE void implUpdateTitle()
void resumeTraveling(AccessGuard)
void ImplShowTabPage(TabPage *pPage)
std::unique_ptr< BuilderPage > mxPage
Definition: wizimpldata.hxx:28
void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
void AddPage(TabPage *pPage)
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
WinBits const WB_TABSTOP
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
bool ShowPage(sal_uInt16 nLevel)
BuilderPage * m_pCurTabPage
bool IsEnabled() const
Definition: window2.cxx:1122
#define HID_WIZARD_PREVIOUS
BuilderPage * GetPage(WizardTypes::WizardState eState) const
#define WIZARDDIALOG_BUTTON_DLGOFFSET_X
OUString VclResId(const char *pId)
Definition: svdata.cxx:266
WinBits GetStyle() const
Definition: window2.cxx:953
Definition: timer.hxx:26
WinBits const WB_CLOSEABLE
void skip()
skip a state
virtual std::unique_ptr< BuilderPage > createPage(WizardTypes::WizardState _nState)=0
to override to create new pages
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
virtual void updateTravelUI()
updates the user interface which deals with traveling in the wizard
VclPtr< PushButton > m_pPrevPage
Definition: wizdlg.hxx:101
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
bool IsReallyVisible() const
Definition: window2.cxx:1107
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:82
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
bool mbEmptyViewMargin
Definition: wizdlg.hxx:78
BuilderPage * GetOrCreatePage(const WizardTypes::WizardState i_nState)
TabPage * ImplGetPage(sal_uInt16 nLevel) const
void setWidth(long nWidth)
virtual void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
std::unique_ptr< weld::Assistant > m_xAssistant
Definition: weld.hxx:2251
bool ShowPage(WizardTypes::WizardState nState)
static IWizardPageController * getPageController(TabPage *_pCurrentPage)
VclPtr< OKButton > m_pFinish
Definition: wizdlg.hxx:98
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1257
ImplWizButtonData * mpNext
Definition: wizimpldata.hxx:33
WizardTypes::WizardState m_nCurState
VclPtr< HelpButton > m_pHelp
Definition: wizdlg.hxx:102
bool isAutomaticNextButtonStateEnabled() const
enables the automatic enabled/disabled state of the "Next" button
constexpr sal_uInt16 KEY_TAB
Definition: keycodes.hxx:121
void EndDialog(long nResult=RET_CANCEL)
Definition: dialog.cxx:1082
Idle maWizardLayoutIdle
Definition: wizdlg.hxx:68
helper class to temporarily suspend any traveling in the wizard
void SetPage(sal_uInt16 nLevel, TabPage *pPage)
bool prepareLeaveCurrentState(WizardTypes::CommitPageReason eReason)
will be called when the current state is about to be left for the given reason
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2201
void setHeight(long nHeight)
virtual void initializePage() override