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->Show();
281  }
282 
283  if ( pOldTabPage )
284  pOldTabPage->Hide();
285  }
286 
287  TabPage* RoadmapWizard::ImplGetPage( sal_uInt16 nLevel ) const
288  {
289  sal_uInt16 nTempLevel = 0;
290  ImplWizPageData* pPageData = mpFirstPage;
291  while ( pPageData )
292  {
293  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
294  break;
295 
296  nTempLevel++;
297  pPageData = pPageData->mpNext;
298  }
299 
300  if ( pPageData )
301  return pPageData->mpPage;
302  return nullptr;
303  }
304 
306  {
307  m_xWizardImpl->sTitleBase = GetText();
308 
309  // create the buttons according to the wizard button flags
310  // the help button
311  if (_nButtonFlags & WizardButtonFlags::HELP)
312  {
314  m_pHelp->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
315  m_pHelp->Show();
317  }
318 
319  // the previous button
320  if (_nButtonFlags & WizardButtonFlags::PREVIOUS)
321  {
324  m_pPrevPage->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
325  m_pPrevPage->SetText(VclResId(STR_WIZDLG_PREVIOUS));
326  m_pPrevPage->Show();
327  m_pPrevPage->set_id("previous");
328 
329  if (_nButtonFlags & WizardButtonFlags::NEXT)
330  AddButton( m_pPrevPage, ( WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X) ); // half x-offset to the next button
331  else
334  m_pPrevPage->SetClickHdl( LINK( this, RoadmapWizard, OnPrevPage ) );
335  }
336 
337  // the next button
338  if (_nButtonFlags & WizardButtonFlags::NEXT)
339  {
342  m_pNextPage->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
343  m_pNextPage->SetText(VclResId(STR_WIZDLG_NEXT));
344  m_pNextPage->Show();
345  m_pNextPage->set_id("next");
346 
349  m_pNextPage->SetClickHdl( LINK( this, RoadmapWizard, OnNextPage ) );
350  }
351 
352  // the finish button
353  if (_nButtonFlags & WizardButtonFlags::FINISH)
354  {
356  m_pFinish->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
357  m_pFinish->SetText(VclResId(STR_WIZDLG_FINISH));
358  m_pFinish->Show();
359  m_pFinish->set_id("finish");
360 
362  m_pFinish->SetClickHdl( LINK( this, RoadmapWizard, OnFinish ) );
363  }
364 
365  // the cancel button
366  if (_nButtonFlags & WizardButtonFlags::CANCEL)
367  {
369  m_pCancel->SetSizePixel(LogicToPixel(Size(50, 14), MapMode(MapUnit::MapAppFont)));
370  m_pCancel->Show();
371 
373  }
374  }
375 
377  {
378  if ( IsReallyShown() && !IsInInitShow() )
379  {
380  ImplPosCtrls();
381  ImplPosTabPage();
382  }
383 
384  Dialog::Resize();
385  }
386 
388  {
389  OUString sCompleteTitle(m_xWizardImpl->sTitleBase);
390 
391  // append the page title
392  TabPage* pCurrentPage = GetPage(getCurrentState());
393  if ( pCurrentPage && !pCurrentPage->GetText().isEmpty() )
394  {
395  sCompleteTitle += " - " + pCurrentPage->GetText();
396  }
397 
398  SetText(sCompleteTitle);
399  }
400 
402  {
403  Size aDlgSize = GetPageSizePixel();
404  if ( !aDlgSize.Width() || !aDlgSize.Height() )
405  {
406  ImplWizPageData* pPageData = mpFirstPage;
407  while ( pPageData )
408  {
409  if ( pPageData->mpPage )
410  {
411  Size aPageSize = pPageData->mpPage->GetSizePixel();
412  if ( aPageSize.Width() > aDlgSize.Width() )
413  aDlgSize.setWidth( aPageSize.Width() );
414  if ( aPageSize.Height() > aDlgSize.Height() )
415  aDlgSize.setHeight( aPageSize.Height() );
416  }
417 
418  pPageData = pPageData->mpNext;
419  }
420  }
421  ImplCalcSize( aDlgSize );
422  SetMinOutputSizePixel( aDlgSize );
423  SetOutputSizePixel( aDlgSize );
424  }
425 
427  {
428  if ( nType == StateChangedType::InitShow )
429  {
430  if ( IsDefaultSize() )
431  {
432  CalcAndSetSize();
433  }
434 
435  ImplPosCtrls();
436  ImplPosTabPage();
438  }
439 
440  Dialog::StateChanged( nType );
441  }
442 
444  {
445  if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && mpPrevBtn && mpNextBtn )
446  {
447  const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
448  vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
449  sal_uInt16 nKeyCode = aKeyCode.GetCode();
450 
451  if ( aKeyCode.IsMod1() )
452  {
453  if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
454  {
455  if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
456  {
457  if ( mpPrevBtn->IsVisible() &&
459  {
460  mpPrevBtn->SetPressed( true );
461  mpPrevBtn->SetPressed( false );
462  mpPrevBtn->Click();
463  }
464  return true;
465  }
466  }
467  else
468  {
469  if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
470  {
471  if ( mpNextBtn->IsVisible() &&
473  {
474  mpNextBtn->SetPressed( true );
475  mpNextBtn->SetPressed( false );
476  mpNextBtn->Click();
477  }
478  return true;
479  }
480  }
481  }
482  }
483 
484  return Dialog::EventNotify( rNEvt );
485  }
486 
488  {
489  if ( nullptr == GetPage( i_nState ) )
490  {
491  VclPtr<TabPage> pNewPage = createPage( i_nState );
492  DBG_ASSERT( pNewPage, "RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" );
493 
494  // fill up the page sequence of our base class (with dummies)
495  while ( m_xWizardImpl->nFirstUnknownPage < i_nState )
496  {
497  AddPage( nullptr );
498  ++m_xWizardImpl->nFirstUnknownPage;
499  }
500 
501  if ( m_xWizardImpl->nFirstUnknownPage == i_nState )
502  {
503  // encountered this page number the first time
504  AddPage( pNewPage );
505  ++m_xWizardImpl->nFirstUnknownPage;
506  }
507  else
508  // already had this page - just change it
509  SetPage( i_nState, pNewPage );
510  }
511  return GetPage( i_nState );
512  }
513 
515  {
516  WizardTypes::WizardState nCurrentLevel = GetCurLevel();
517  GetOrCreatePage( nCurrentLevel );
518 
519  enterState( nCurrentLevel );
520  }
521 
522  bool RoadmapWizard::ShowPage( sal_uInt16 nLevel )
523  {
524  mnCurLevel = nLevel;
525  ActivatePage();
527  return true;
528  }
529 
530  bool RoadmapWizard::Finish( long nResult )
531  {
532  if ( IsInExecute() )
533  EndDialog( nResult );
534  else if ( GetStyle() & WB_CLOSEABLE )
535  Close();
536  return true;
537  }
538 
540  {
541  ImplWizPageData* pNewPageData = new ImplWizPageData;
542  pNewPageData->mpNext = nullptr;
543  pNewPageData->mpPage = pPage;
544 
545  if ( !mpFirstPage )
546  mpFirstPage = pNewPageData;
547  else
548  {
549  ImplWizPageData* pPageData = mpFirstPage;
550  while ( pPageData->mpNext )
551  pPageData = pPageData->mpNext;
552  pPageData->mpNext = pNewPageData;
553  }
554  }
555 
557  {
558  ImplWizPageData* pPrevPageData = nullptr;
559  ImplWizPageData* pPageData = mpFirstPage;
560  while ( pPageData )
561  {
562  if ( pPageData->mpPage == pPage )
563  {
564  if ( pPrevPageData )
565  pPrevPageData->mpNext = pPageData->mpNext;
566  else
567  mpFirstPage = pPageData->mpNext;
568  if ( pPage == mpCurTabPage )
569  mpCurTabPage = nullptr;
570  delete pPageData;
571  return;
572  }
573 
574  pPrevPageData = pPageData;
575  pPageData = pPageData->mpNext;
576  }
577 
578  OSL_FAIL( "RoadmapWizard::RemovePage() - Page not in list" );
579  }
580 
581  void RoadmapWizard::SetPage( sal_uInt16 nLevel, TabPage* pPage )
582  {
583  sal_uInt16 nTempLevel = 0;
584  ImplWizPageData* pPageData = mpFirstPage;
585  while ( pPageData )
586  {
587  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
588  break;
589 
590  nTempLevel++;
591  pPageData = pPageData->mpNext;
592  }
593 
594  if ( pPageData )
595  {
596  if ( pPageData->mpPage == mpCurTabPage )
597  mpCurTabPage = nullptr;
598  pPageData->mpPage = pPage;
599  }
600  }
601 
602  TabPage* RoadmapWizard::GetPage( sal_uInt16 nLevel ) const
603  {
604  sal_uInt16 nTempLevel = 0;
605 
606  for (ImplWizPageData* pPageData = mpFirstPage; pPageData;
607  pPageData = pPageData->mpNext)
608  {
609  if ( nTempLevel == nLevel )
610  return pPageData->mpPage;
611  nTempLevel++;
612  }
613 
614  return nullptr;
615  }
616 
617  void RoadmapWizard::AddButton( Button* pButton, long nOffset )
618  {
619  ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
620  pNewBtnData->mpNext = nullptr;
621  pNewBtnData->mpButton = pButton;
622  pNewBtnData->mnOffset = nOffset;
623 
624  if ( !mpFirstBtn )
625  mpFirstBtn = pNewBtnData;
626  else
627  {
628  ImplWizButtonData* pBtnData = mpFirstBtn;
629  while ( pBtnData->mpNext )
630  pBtnData = pBtnData->mpNext;
631  pBtnData->mpNext = pNewBtnData;
632  }
633  }
634 
636  {
637  ImplWizButtonData* pPrevBtnData = nullptr;
638  ImplWizButtonData* pBtnData = mpFirstBtn;
639  while ( pBtnData )
640  {
641  if ( pBtnData->mpButton == pButton )
642  {
643  if ( pPrevBtnData )
644  pPrevBtnData->mpNext = pBtnData->mpNext;
645  else
646  mpFirstBtn = pBtnData->mpNext;
647  delete pBtnData;
648  return;
649  }
650 
651  pPrevBtnData = pBtnData;
652  pBtnData = pBtnData->mpNext;
653  }
654 
655  OSL_FAIL( "RoadmapWizard::RemoveButton() - Button not in list" );
656  }
657 
658  void RoadmapWizard::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
659  {
660  if (m_pFinish && (_nWizardButtonFlags & WizardButtonFlags::FINISH))
661  m_pFinish->Enable(_bEnable);
662  if (m_pNextPage && (_nWizardButtonFlags & WizardButtonFlags::NEXT))
663  m_pNextPage->Enable(_bEnable);
664  if (m_pPrevPage && (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS))
665  m_pPrevPage->Enable(_bEnable);
666  if (m_pHelp && (_nWizardButtonFlags & WizardButtonFlags::HELP))
667  m_pHelp->Enable(_bEnable);
668  if (m_pCancel && (_nWizardButtonFlags & WizardButtonFlags::CANCEL))
669  m_pCancel->Enable(_bEnable);
670  }
671 
673  {
674  if ( isTravelingSuspended() )
675  return;
676  RoadmapWizardTravelSuspension aTravelGuard( *this );
677  if (!prepareLeaveCurrentState(WizardTypes::eFinish))
678  {
679  return;
680  }
681  Finish( RET_OK );
682  }
683 
685  {
687  ENSURE_OR_RETURN( pController != nullptr, "RoadmapWizard::prepareLeaveCurrentState: no controller for the current page!", true );
688  return pController->commitPage( _eReason );
689  }
690 
692  {
693  // allowed to leave the current page?
695  return false;
696 
697  // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
698  std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
699  std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
700 
701  WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
702  while ( nCurrentRollbackState != _nTargetState )
703  {
704  DBG_ASSERT( !aTravelVirtually.empty(), "RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" );
705  nCurrentRollbackState = aTravelVirtually.top();
706  aTravelVirtually.pop();
707  }
708  m_xWizardImpl->aStateHistory = aTravelVirtually;
709  if ( !ShowPage( _nTargetState ) )
710  {
711  m_xWizardImpl->aStateHistory = aOldStateHistory;
712  return false;
713  }
714  return true;
715  }
716 
718  {
719  WizardTypes::WizardState nCurrentState = getCurrentState();
720 
721  // allowed to leave the current page?
722  if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
723  return false;
724 
725  // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
726  std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
727  std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
728  while ( nCurrentState != _nTargetState )
729  {
730  WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
731  if ( WZS_INVALID_STATE == nNextState )
732  {
733  OSL_FAIL( "RoadmapWizard::skipUntil: the given target state does not exist!" );
734  return false;
735  }
736 
737  // remember the skipped state in the history
738  aTravelVirtually.push( nCurrentState );
739 
740  // get the next state
741  nCurrentState = nNextState;
742  }
743  m_xWizardImpl->aStateHistory = aTravelVirtually;
744  // show the target page
745  if ( !ShowPage( nCurrentState ) )
746  {
747  // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
748  // but ShowPage doesn't? Somebody behaves very strange here...
749  OSL_FAIL( "RoadmapWizard::skipUntil: very unpolite..." );
750  m_xWizardImpl->aStateHistory = aOldStateHistory;
751  return false;
752  }
753  return true;
754  }
755 
757  {
758  // allowed to leave the current page?
760  return false;
761 
762  // determine the next state to travel to
763  WizardTypes::WizardState nCurrentState = getCurrentState();
764  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
765  if (WZS_INVALID_STATE == nNextState)
766  return false;
767 
768  // the state history is used by the enterState method
769  // all fine
770  m_xWizardImpl->aStateHistory.push(nCurrentState);
771  if (!ShowPage(nNextState))
772  {
773  m_xWizardImpl->aStateHistory.pop();
774  return false;
775  }
776 
777  return true;
778  }
779 
781  {
782  DBG_ASSERT(!m_xWizardImpl->aStateHistory.empty(), "RoadmapWizard::travelPrevious: have no previous page!");
783 
784  // allowed to leave the current page?
786  return false;
787 
788  // the next state to switch to
789  WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
790 
791  // the state history is used by the enterState method
792  m_xWizardImpl->aStateHistory.pop();
793  // show this page
794  if (!ShowPage(nPreviousState))
795  {
796  m_xWizardImpl->aStateHistory.push(nPreviousState);
797  return false;
798  }
799 
800  // all fine
801  return true;
802  }
803 
805  {
806 
807  std::stack< WizardTypes::WizardState > aTemp;
808  while(!m_xWizardImpl->aStateHistory.empty())
809  {
810  WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
811  m_xWizardImpl->aStateHistory.pop();
812  if(nPreviousState != nToRemove)
813  aTemp.push( nPreviousState );
814  else
815  break;
816  }
817  while(!aTemp.empty())
818  {
819  m_xWizardImpl->aStateHistory.push( aTemp.top() );
820  aTemp.pop();
821  }
822  }
823 
825  {
826  return m_xWizardImpl->m_bAutoNextButtonState;
827  }
828 
829  IMPL_LINK_NOARG(RoadmapWizard, OnPrevPage, Button*, void)
830  {
831  if ( isTravelingSuspended() )
832  return;
833  RoadmapWizardTravelSuspension aTravelGuard( *this );
834  travelPrevious();
835  }
836 
837  IMPL_LINK_NOARG(RoadmapWizard, OnNextPage, Button*, void)
838  {
839  if ( isTravelingSuspended() )
840  return;
841  RoadmapWizardTravelSuspension aTravelGuard( *this );
842  travelNext();
843  }
844 
846  {
847  IWizardPageController* pController = dynamic_cast< IWizardPageController* >( _pCurrentPage );
848  return pController;
849  }
850 
852  {
853  return m_xWizardImpl->m_bTravelingSuspended;
854  }
855 
857  {
858  DBG_ASSERT( !m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::suspendTraveling: already suspended!" );
859  m_xWizardImpl->m_bTravelingSuspended = true;
860  }
861 
863  {
864  DBG_ASSERT( m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::resumeTraveling: nothing to resume!" );
865  m_xWizardImpl->m_bTravelingSuspended = false;
866  }
867 
869  : AssistantController(pParent, "vcl/ui/wizard.ui", "Wizard")
870  , m_pCurTabPage(nullptr)
871  , m_nCurState(0)
872  , m_pFirstPage(nullptr)
873  , m_xFinish(m_xAssistant->weld_widget_for_response(RET_OK))
874  , m_xCancel(m_xAssistant->weld_widget_for_response(RET_CANCEL))
875  , m_xNextPage(m_xAssistant->weld_widget_for_response(RET_YES))
876  , m_xPrevPage(m_xAssistant->weld_widget_for_response(RET_NO))
877  , m_xHelp(m_xAssistant->weld_widget_for_response(RET_HELP))
879  {
880  implConstruct(nButtonFlags);
881  }
882 
884  {
885  m_pImpl->sTitleBase = m_xAssistant->get_title();
886 
887  const bool bHideHelp = comphelper::LibreOfficeKit::isActive() &&
888  officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
889  // create the buttons according to the wizard button flags
890  // the help button
891  if (nButtonFlags & WizardButtonFlags::HELP && !bHideHelp)
892  m_xHelp->show();
893  else
894  m_xHelp->hide();
895 
896  // the previous button
897  if (nButtonFlags & WizardButtonFlags::PREVIOUS)
898  {
899  m_xPrevPage->set_help_id( HID_WIZARD_PREVIOUS );
900  m_xPrevPage->show();
901 
902  m_xPrevPage->connect_clicked( LINK( this, WizardMachine, OnPrevPage ) );
903  }
904  else
905  m_xPrevPage->hide();
906 
907  // the next button
908  if (nButtonFlags & WizardButtonFlags::NEXT)
909  {
910  m_xNextPage->set_help_id( HID_WIZARD_NEXT );
911  m_xNextPage->show();
912 
913  m_xNextPage->connect_clicked( LINK( this, WizardMachine, OnNextPage ) );
914  }
915  else
916  m_xNextPage->hide();
917 
918  // the finish button
919  if (nButtonFlags & WizardButtonFlags::FINISH)
920  {
921  m_xFinish->show();
922 
923  m_xFinish->connect_clicked( LINK( this, WizardMachine, OnFinish ) );
924  }
925  else
926  m_xFinish->hide();
927 
928  // the cancel button
929  if (nButtonFlags & WizardButtonFlags::CANCEL)
930  {
931  m_xCancel->show();
932  m_xCancel->connect_clicked( LINK( this, WizardMachine, OnCancel ) );
933  }
934  else
935  m_xCancel->hide();
936  }
937 
939  {
940  if (m_pImpl)
941  {
942  while (m_pFirstPage)
944  m_pImpl.reset();
945  }
946  }
947 
949  {
950  OUString sCompleteTitle(m_pImpl->sTitleBase);
951 
952  // append the page title
953  BuilderPage* pCurrentPage = GetPage(getCurrentState());
954  if ( pCurrentPage && !pCurrentPage->GetPageTitle().isEmpty() )
955  {
956  sCompleteTitle += " - " + pCurrentPage->GetPageTitle();
957  }
958 
959  m_xAssistant->set_title(sCompleteTitle);
960  }
961 
962  void WizardMachine::setTitleBase(const OUString& _rTitleBase)
963  {
964  m_pImpl->sTitleBase = _rTitleBase;
965  implUpdateTitle();
966  }
967 
969  {
970  if ( nullptr == GetPage( i_nState ) )
971  {
972  std::unique_ptr<BuilderPage> xNewPage = createPage( i_nState );
973  DBG_ASSERT( xNewPage, "WizardMachine::GetOrCreatePage: invalid new page (NULL)!" );
974 
975  // fill up the page sequence of our base class (with dummies)
976  while ( m_pImpl->nFirstUnknownPage < i_nState )
977  {
978  AddPage( nullptr );
979  ++m_pImpl->nFirstUnknownPage;
980  }
981 
982  if ( m_pImpl->nFirstUnknownPage == i_nState )
983  {
984  // encountered this page number the first time
985  AddPage(std::move(xNewPage));
986  ++m_pImpl->nFirstUnknownPage;
987  }
988  else
989  // already had this page - just change it
990  SetPage(i_nState, std::move(xNewPage));
991  }
992  return GetPage( i_nState );
993  }
994 
996  {
997  WizardTypes::WizardState nCurrentLevel = m_nCurState;
998  GetOrCreatePage( nCurrentLevel );
999 
1000  enterState( nCurrentLevel );
1001  }
1002 
1004  {
1005  WizardTypes::WizardState nCurrentState = getCurrentState();
1006  return leaveState(nCurrentState);
1007  }
1008 
1010  {
1011  // the new default button
1012  weld::Button* pNewDefButton = nullptr;
1013  if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
1014  pNewDefButton = m_xFinish.get();
1015  if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
1016  pNewDefButton = m_xNextPage.get();
1017  if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
1018  pNewDefButton = m_xPrevPage.get();
1019  if (_nWizardButtonFlags & WizardButtonFlags::HELP)
1020  pNewDefButton = m_xHelp.get();
1021  if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
1022  pNewDefButton = m_xCancel.get();
1023 
1024  if ( pNewDefButton )
1025  defaultButton( pNewDefButton );
1026  else
1027  m_xAssistant->recursively_unset_default_buttons();
1028  }
1029 
1031  {
1032  // loop through all (direct and indirect) descendants which participate in our tabbing order, and
1033  // reset the WB_DEFBUTTON for every window which is a button
1034  m_xAssistant->recursively_unset_default_buttons();
1035 
1036  // set its new style
1037  if (_pNewDefButton)
1038  _pNewDefButton->set_has_default(true);
1039  }
1040 
1041  void WizardMachine::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
1042  {
1043  if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
1044  m_xFinish->set_sensitive(_bEnable);
1045  if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
1046  m_xNextPage->set_sensitive(_bEnable);
1047  if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
1048  m_xPrevPage->set_sensitive(_bEnable);
1049  if (_nWizardButtonFlags & WizardButtonFlags::HELP)
1050  m_xHelp->set_sensitive(_bEnable);
1051  if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
1052  m_xCancel->set_sensitive(_bEnable);
1053  }
1054 
1056  {
1057  // tell the page
1058  IWizardPageController* pController = getPageController( GetPage( _nState ) );
1059  OSL_ENSURE( pController, "WizardMachine::enterState: no controller for the given page!" );
1060  if ( pController )
1061  pController->initializePage();
1062 
1065 
1066  enableButtons( WizardButtonFlags::PREVIOUS, !m_pImpl->aStateHistory.empty() );
1067 
1068  // set the new title - it depends on the current page (i.e. state)
1069  implUpdateTitle();
1070  }
1071 
1073  {
1074  // no need to ask the page here.
1075  // If we reach this point, we already gave the current page the chance to commit it's data,
1076  // and it was allowed to commit it's data
1077 
1078  return true;
1079  }
1080 
1082  {
1083  return Finish(RET_OK);
1084  }
1085 
1087  {
1088  if ( isTravelingSuspended() )
1089  return;
1090 
1091  // prevent WizardTravelSuspension from using this instance
1092  // after will be destructed due to onFinish and async response call
1093  {
1094  WizardTravelSuspension aTravelGuard( *this );
1095  if (!prepareLeaveCurrentState(WizardTypes::eFinish))
1096  {
1097  return;
1098  }
1099  }
1100 
1101  onFinish();
1102  }
1103 
1105  {
1106  m_xAssistant->response(RET_CANCEL);
1107  }
1108 
1110  {
1111  return _nCurrentState + 1;
1112  }
1113 
1115  {
1117  ENSURE_OR_RETURN( pController != nullptr, "WizardMachine::prepareLeaveCurrentState: no controller for the current page!", true );
1118  return pController->commitPage( _eReason );
1119  }
1120 
1122  {
1123  // allowed to leave the current page?
1125  return false;
1126 
1127  // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1128  std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1129  std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1130 
1131  WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
1132  while ( nCurrentRollbackState != _nTargetState )
1133  {
1134  DBG_ASSERT( !aTravelVirtually.empty(), "WizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
1135  nCurrentRollbackState = aTravelVirtually.top();
1136  aTravelVirtually.pop();
1137  }
1138  m_pImpl->aStateHistory = aTravelVirtually;
1139  if ( !ShowPage( _nTargetState ) )
1140  {
1141  m_pImpl->aStateHistory = aOldStateHistory;
1142  return false;
1143  }
1144  return true;
1145  }
1146 
1148  {
1149  WizardTypes::WizardState nCurrentState = getCurrentState();
1150 
1151  // allowed to leave the current page?
1152  if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
1153  return false;
1154 
1155  // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1156  std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1157  std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1158  while ( nCurrentState != _nTargetState )
1159  {
1160  WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
1161  if ( WZS_INVALID_STATE == nNextState )
1162  {
1163  OSL_FAIL( "WizardMachine::skipUntil: the given target state does not exist!" );
1164  return false;
1165  }
1166 
1167  // remember the skipped state in the history
1168  aTravelVirtually.push( nCurrentState );
1169 
1170  // get the next state
1171  nCurrentState = nNextState;
1172  }
1173  m_pImpl->aStateHistory = aTravelVirtually;
1174  // show the target page
1175  if ( !ShowPage( nCurrentState ) )
1176  {
1177  // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
1178  // but ShowPage doesn't? Somebody behaves very strange here...
1179  OSL_FAIL( "WizardMachine::skipUntil: very unpolite..." );
1180  m_pImpl->aStateHistory = aOldStateHistory;
1181  return false;
1182  }
1183  return true;
1184  }
1185 
1187  {
1188  // allowed to leave the current page?
1190  return;
1191 
1192  WizardTypes::WizardState nCurrentState = getCurrentState();
1193  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1194 
1195  if (WZS_INVALID_STATE == nNextState)
1196  return;
1197 
1198  // remember the skipped state in the history
1199  m_pImpl->aStateHistory.push(nCurrentState);
1200 
1201  // get the next state
1202  nCurrentState = nNextState;
1203 
1204  // show the (n+1)th page
1205  if (!ShowPage(nCurrentState))
1206  {
1207  // TODO: this leaves us in a state where we have no current page and an inconsistent state history.
1208  // Perhaps we should rollback the skipping here...
1209  OSL_FAIL("RoadmapWizard::skip: very unpolite...");
1210  // if somebody does a skip and then does not allow to leave...
1211  // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here,
1212  // somebody behaves really strange ...)
1213  return;
1214  }
1215 
1216  // all fine
1217  }
1218 
1220  {
1221  // allowed to leave the current page?
1223  return false;
1224 
1225  // determine the next state to travel to
1226  WizardTypes::WizardState nCurrentState = getCurrentState();
1227  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1228  if (WZS_INVALID_STATE == nNextState)
1229  return false;
1230 
1231  // the state history is used by the enterState method
1232  // all fine
1233  m_pImpl->aStateHistory.push(nCurrentState);
1234  if (!ShowPage(nNextState))
1235  {
1236  m_pImpl->aStateHistory.pop();
1237  return false;
1238  }
1239 
1240  return true;
1241  }
1242 
1244  {
1245  if (DeactivatePage())
1246  {
1247  BuilderPage* pOldTabPage = m_pCurTabPage;
1248 
1249  m_nCurState = nState;
1250  ActivatePage();
1251 
1252  if (pOldTabPage)
1253  pOldTabPage->Deactivate();
1254 
1255  m_xAssistant->set_current_page(OString::number(nState));
1256 
1259 
1260  return true;
1261  }
1262  return false;
1263  }
1264 
1266  {
1267  return ShowPage(m_nCurState + 1);
1268  }
1269 
1271  {
1272  if (!m_nCurState)
1273  return false;
1274  return ShowPage(m_nCurState - 1);
1275  }
1276 
1278  {
1279  DBG_ASSERT(!m_pImpl->aStateHistory.empty(), "WizardMachine::travelPrevious: have no previous page!");
1280 
1281  // allowed to leave the current page?
1283  return false;
1284 
1285  // the next state to switch to
1286  WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1287 
1288  // the state history is used by the enterState method
1289  m_pImpl->aStateHistory.pop();
1290  // show this page
1291  if (!ShowPage(nPreviousState))
1292  {
1293  m_pImpl->aStateHistory.push(nPreviousState);
1294  return false;
1295  }
1296 
1297  // all fine
1298  return true;
1299  }
1300 
1301 
1303  {
1304 
1305  std::stack< WizardTypes::WizardState > aTemp;
1306  while(!m_pImpl->aStateHistory.empty())
1307  {
1308  WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1309  m_pImpl->aStateHistory.pop();
1310  if(nPreviousState != nToRemove)
1311  aTemp.push( nPreviousState );
1312  else
1313  break;
1314  }
1315  while(!aTemp.empty())
1316  {
1317  m_pImpl->aStateHistory.push( aTemp.top() );
1318  aTemp.pop();
1319  }
1320  }
1321 
1322 
1324  {
1325  m_pImpl->m_bAutoNextButtonState = true;
1326  }
1327 
1328 
1330  {
1331  return m_pImpl->m_bAutoNextButtonState;
1332  }
1333 
1335  {
1336  if ( isTravelingSuspended() )
1337  return;
1338  WizardTravelSuspension aTravelGuard( *this );
1339  travelPrevious();
1340  }
1341 
1343  {
1344  if ( isTravelingSuspended() )
1345  return;
1346  WizardTravelSuspension aTravelGuard( *this );
1347  travelNext();
1348  }
1349 
1351  {
1352  IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage);
1353  return pController;
1354  }
1355 
1356  void WizardMachine::getStateHistory( std::vector< WizardTypes::WizardState >& _out_rHistory )
1357  {
1358  std::stack< WizardTypes::WizardState > aHistoryCopy( m_pImpl->aStateHistory );
1359  while ( !aHistoryCopy.empty() )
1360  {
1361  _out_rHistory.push_back( aHistoryCopy.top() );
1362  aHistoryCopy.pop();
1363  }
1364  }
1365 
1367  {
1369  }
1370 
1372  {
1373  const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) );
1374  OSL_ENSURE( pController != nullptr, "RoadmapWizard::updateTravelUI: no controller for the current page!" );
1375 
1376  bool bCanAdvance =
1377  ( !pController || pController->canAdvance() ) // the current page allows to advance
1378  && canAdvance(); // the dialog as a whole allows to advance
1379  enableButtons( WizardButtonFlags::NEXT, bCanAdvance );
1380  }
1381 
1383  {
1384  return m_pImpl->m_bTravelingSuspended;
1385  }
1386 
1388  {
1389  DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "WizardMachine::suspendTraveling: already suspended!" );
1390  m_pImpl->m_bTravelingSuspended = true;
1391  }
1392 
1394  {
1395  if (!m_pImpl)
1396  return;
1397 
1398  DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "WizardMachine::resumeTraveling: nothing to resume!" );
1399  m_pImpl->m_bTravelingSuspended = false;
1400  }
1401 
1402  bool WizardMachine::Finish(short nResult)
1403  {
1404  if ( DeactivatePage() )
1405  {
1406  if (m_pCurTabPage)
1408 
1409  m_xAssistant->response(nResult);
1410  return true;
1411  }
1412  else
1413  return false;
1414  }
1415 
1416  void WizardMachine::AddPage(std::unique_ptr<BuilderPage> xPage)
1417  {
1418  WizPageData* pNewPageData = new WizPageData;
1419  pNewPageData->mpNext = nullptr;
1420  pNewPageData->mxPage = std::move(xPage);
1421 
1422  if ( !m_pFirstPage )
1423  m_pFirstPage = pNewPageData;
1424  else
1425  {
1426  WizPageData* pPageData = m_pFirstPage;
1427  while ( pPageData->mpNext )
1428  pPageData = pPageData->mpNext;
1429  pPageData->mpNext = pNewPageData;
1430  }
1431  }
1432 
1434  {
1435  WizPageData* pPrevPageData = nullptr;
1436  WizPageData* pPageData = m_pFirstPage;
1437  while ( pPageData )
1438  {
1439  if (pPageData->mxPage.get() == pPage)
1440  {
1441  if (pPrevPageData)
1442  pPrevPageData->mpNext = pPageData->mpNext;
1443  else
1444  m_pFirstPage = pPageData->mpNext;
1445  if (pPage == m_pCurTabPage)
1446  m_pCurTabPage = nullptr;
1447  delete pPageData;
1448  return;
1449  }
1450 
1451  pPrevPageData = pPageData;
1452  pPageData = pPageData->mpNext;
1453  }
1454 
1455  OSL_FAIL( "WizardMachine::RemovePage() - Page not in list" );
1456  }
1457 
1458  void WizardMachine::SetPage(WizardTypes::WizardState nLevel, std::unique_ptr<BuilderPage> xPage)
1459  {
1460  sal_uInt16 nTempLevel = 0;
1461  WizPageData* pPageData = m_pFirstPage;
1462  while ( pPageData )
1463  {
1464  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
1465  break;
1466 
1467  nTempLevel++;
1468  pPageData = pPageData->mpNext;
1469  }
1470 
1471  if ( pPageData )
1472  {
1473  if (pPageData->mxPage.get() == m_pCurTabPage)
1474  m_pCurTabPage = nullptr;
1475  pPageData->mxPage = std::move(xPage);
1476  }
1477  }
1478 
1480  {
1481  sal_uInt16 nTempLevel = 0;
1482 
1483  for (WizPageData* pPageData = m_pFirstPage; pPageData;
1484  pPageData = pPageData->mpNext)
1485  {
1486  if ( nTempLevel == nLevel )
1487  return pPageData->mxPage.get();
1488  nTempLevel++;
1489  }
1490 
1491  return nullptr;
1492  }
1493 } // namespace svt
1494 
1495 
1496 /* 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:642
virtual bool Close() override
Definition: dialog.cxx:821
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:2396
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:140
#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:311
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:310
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2713
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2427
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
Definition: wizdlg.hxx:239
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:122
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:3085
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
VCL_DLLPRIVATE void implConstruct(const WizardButtonFlags _nButtonFlags)
virtual void Deactivate()
Definition: weldutils.cxx:28
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
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:303
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:178
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:26
bool travelNext()
travel to the next state
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:942
#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:3900
helper class to temporarily suspend any traveling in the wizard
Definition: wizdlg.hxx:292
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual void Resize() override
Definition: dialog.cxx:1346
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:736
void SetPressed(bool bPressed)
Definition: button.cxx:1535
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:267
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:2421
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:1080
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:2182
void setHeight(long nHeight)
virtual void initializePage() override