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  tools::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  tools::Long nBtnWidth = 0;
137  tools::Long nMaxHeight = 0;
138  tools::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  tools::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  tools::Long nOffX = aDlgSize.Width()-nBtnWidth-WIZARDDIALOG_BUTTON_DLGOFFSET_X;
160  tools::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  tools::Long nViewOffX = 0;
194  tools::Long nViewOffY = 0;
195  tools::Long nViewWidth = 0;
196  tools::Long nViewHeight = 0;
197  tools::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  tools::Long nMaxHeight = 0;
241  ImplWizButtonData* pBtnData = mpFirstBtn;
242  while ( pBtnData )
243  {
244  tools::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  tools::Long nOffX = 0;
256  tools::Long nOffY = 0;
257  if ( mpViewWindow && mpViewWindow->IsVisible() )
258  {
259  Size aViewSize = mpViewWindow->GetSizePixel();
260  // align left
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  }
512 
514  {
515  WizardTypes::WizardState nCurrentLevel = GetCurLevel();
516  GetOrCreatePage( nCurrentLevel );
517 
518  enterState( nCurrentLevel );
519  }
520 
521  bool RoadmapWizard::ShowPage( sal_uInt16 nLevel )
522  {
523  mnCurLevel = nLevel;
524  ActivatePage();
526  return true;
527  }
528 
530  {
531  if ( IsInExecute() )
532  EndDialog( nResult );
533  else if ( GetStyle() & WB_CLOSEABLE )
534  Close();
535  }
536 
538  {
539  ImplWizPageData* pNewPageData = new ImplWizPageData;
540  pNewPageData->mpNext = nullptr;
541  pNewPageData->mpPage = pPage;
542 
543  if ( !mpFirstPage )
544  mpFirstPage = pNewPageData;
545  else
546  {
547  ImplWizPageData* pPageData = mpFirstPage;
548  while ( pPageData->mpNext )
549  pPageData = pPageData->mpNext;
550  pPageData->mpNext = pNewPageData;
551  }
552  }
553 
555  {
556  ImplWizPageData* pPrevPageData = nullptr;
557  ImplWizPageData* pPageData = mpFirstPage;
558  while ( pPageData )
559  {
560  if ( pPageData->mpPage == pPage )
561  {
562  if ( pPrevPageData )
563  pPrevPageData->mpNext = pPageData->mpNext;
564  else
565  mpFirstPage = pPageData->mpNext;
566  if ( pPage == mpCurTabPage )
567  mpCurTabPage = nullptr;
568  delete pPageData;
569  return;
570  }
571 
572  pPrevPageData = pPageData;
573  pPageData = pPageData->mpNext;
574  }
575 
576  OSL_FAIL( "RoadmapWizard::RemovePage() - Page not in list" );
577  }
578 
579  void RoadmapWizard::SetPage( sal_uInt16 nLevel, TabPage* pPage )
580  {
581  sal_uInt16 nTempLevel = 0;
582  ImplWizPageData* pPageData = mpFirstPage;
583  while ( pPageData )
584  {
585  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
586  break;
587 
588  nTempLevel++;
589  pPageData = pPageData->mpNext;
590  }
591 
592  if ( pPageData )
593  {
594  if ( pPageData->mpPage == mpCurTabPage )
595  mpCurTabPage = nullptr;
596  pPageData->mpPage = pPage;
597  }
598  }
599 
600  TabPage* RoadmapWizard::GetPage( sal_uInt16 nLevel ) const
601  {
602  sal_uInt16 nTempLevel = 0;
603 
604  for (ImplWizPageData* pPageData = mpFirstPage; pPageData;
605  pPageData = pPageData->mpNext)
606  {
607  if ( nTempLevel == nLevel )
608  return pPageData->mpPage;
609  nTempLevel++;
610  }
611 
612  return nullptr;
613  }
614 
615  void RoadmapWizard::AddButton( Button* pButton, tools::Long nOffset )
616  {
617  ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
618  pNewBtnData->mpNext = nullptr;
619  pNewBtnData->mpButton = pButton;
620  pNewBtnData->mnOffset = nOffset;
621 
622  if ( !mpFirstBtn )
623  mpFirstBtn = pNewBtnData;
624  else
625  {
626  ImplWizButtonData* pBtnData = mpFirstBtn;
627  while ( pBtnData->mpNext )
628  pBtnData = pBtnData->mpNext;
629  pBtnData->mpNext = pNewBtnData;
630  }
631  }
632 
634  {
635  ImplWizButtonData* pPrevBtnData = nullptr;
636  ImplWizButtonData* pBtnData = mpFirstBtn;
637  while ( pBtnData )
638  {
639  if ( pBtnData->mpButton == pButton )
640  {
641  if ( pPrevBtnData )
642  pPrevBtnData->mpNext = pBtnData->mpNext;
643  else
644  mpFirstBtn = pBtnData->mpNext;
645  delete pBtnData;
646  return;
647  }
648 
649  pPrevBtnData = pBtnData;
650  pBtnData = pBtnData->mpNext;
651  }
652 
653  OSL_FAIL( "RoadmapWizard::RemoveButton() - Button not in list" );
654  }
655 
656  void RoadmapWizard::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
657  {
658  if (m_pFinish && (_nWizardButtonFlags & WizardButtonFlags::FINISH))
659  m_pFinish->Enable(_bEnable);
660  if (m_pNextPage && (_nWizardButtonFlags & WizardButtonFlags::NEXT))
661  m_pNextPage->Enable(_bEnable);
662  if (m_pPrevPage && (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS))
663  m_pPrevPage->Enable(_bEnable);
664  if (m_pHelp && (_nWizardButtonFlags & WizardButtonFlags::HELP))
665  m_pHelp->Enable(_bEnable);
666  if (m_pCancel && (_nWizardButtonFlags & WizardButtonFlags::CANCEL))
667  m_pCancel->Enable(_bEnable);
668  }
669 
671  {
672  if ( isTravelingSuspended() )
673  return;
674  RoadmapWizardTravelSuspension aTravelGuard( *this );
675  if (!prepareLeaveCurrentState(WizardTypes::eFinish))
676  {
677  return;
678  }
679  Finish( RET_OK );
680  }
681 
683  {
685  ENSURE_OR_RETURN( pController != nullptr, "RoadmapWizard::prepareLeaveCurrentState: no controller for the current page!", true );
686  return pController->commitPage( _eReason );
687  }
688 
690  {
691  // allowed to leave the current page?
693  return false;
694 
695  // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
696  std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
697  std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
698 
699  WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
700  while ( nCurrentRollbackState != _nTargetState )
701  {
702  DBG_ASSERT( !aTravelVirtually.empty(), "RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" );
703  nCurrentRollbackState = aTravelVirtually.top();
704  aTravelVirtually.pop();
705  }
706  m_xWizardImpl->aStateHistory = aTravelVirtually;
707  if ( !ShowPage( _nTargetState ) )
708  {
709  m_xWizardImpl->aStateHistory = aOldStateHistory;
710  return false;
711  }
712  return true;
713  }
714 
716  {
717  WizardTypes::WizardState nCurrentState = getCurrentState();
718 
719  // allowed to leave the current page?
720  if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
721  return false;
722 
723  // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
724  std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
725  std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
726  while ( nCurrentState != _nTargetState )
727  {
728  WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
729  if ( WZS_INVALID_STATE == nNextState )
730  {
731  OSL_FAIL( "RoadmapWizard::skipUntil: the given target state does not exist!" );
732  return false;
733  }
734 
735  // remember the skipped state in the history
736  aTravelVirtually.push( nCurrentState );
737 
738  // get the next state
739  nCurrentState = nNextState;
740  }
741  m_xWizardImpl->aStateHistory = aTravelVirtually;
742  // show the target page
743  if ( !ShowPage( nCurrentState ) )
744  {
745  // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
746  // but ShowPage doesn't? Somebody behaves very strange here...
747  OSL_FAIL( "RoadmapWizard::skipUntil: very unpolite..." );
748  m_xWizardImpl->aStateHistory = aOldStateHistory;
749  return false;
750  }
751  return true;
752  }
753 
755  {
756  // allowed to leave the current page?
758  return;
759 
760  // determine the next state to travel to
761  WizardTypes::WizardState nCurrentState = getCurrentState();
762  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
763  if (WZS_INVALID_STATE == nNextState)
764  return;
765 
766  // the state history is used by the enterState method
767  // all fine
768  m_xWizardImpl->aStateHistory.push(nCurrentState);
769  if (!ShowPage(nNextState))
770  {
771  m_xWizardImpl->aStateHistory.pop();
772  }
773  }
774 
776  {
777  DBG_ASSERT(!m_xWizardImpl->aStateHistory.empty(), "RoadmapWizard::travelPrevious: have no previous page!");
778 
779  // allowed to leave the current page?
781  return;
782 
783  // the next state to switch to
784  WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
785 
786  // the state history is used by the enterState method
787  m_xWizardImpl->aStateHistory.pop();
788  // show this page
789  if (!ShowPage(nPreviousState))
790  {
791  m_xWizardImpl->aStateHistory.push(nPreviousState);
792  }
793 
794  // all fine
795  }
796 
798  {
799 
800  std::stack< WizardTypes::WizardState > aTemp;
801  while(!m_xWizardImpl->aStateHistory.empty())
802  {
803  WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
804  m_xWizardImpl->aStateHistory.pop();
805  if(nPreviousState != nToRemove)
806  aTemp.push( nPreviousState );
807  else
808  break;
809  }
810  while(!aTemp.empty())
811  {
812  m_xWizardImpl->aStateHistory.push( aTemp.top() );
813  aTemp.pop();
814  }
815  }
816 
818  {
819  return m_xWizardImpl->m_bAutoNextButtonState;
820  }
821 
822  IMPL_LINK_NOARG(RoadmapWizard, OnPrevPage, Button*, void)
823  {
824  if ( isTravelingSuspended() )
825  return;
826  RoadmapWizardTravelSuspension aTravelGuard( *this );
827  travelPrevious();
828  }
829 
830  IMPL_LINK_NOARG(RoadmapWizard, OnNextPage, Button*, void)
831  {
832  if ( isTravelingSuspended() )
833  return;
834  RoadmapWizardTravelSuspension aTravelGuard( *this );
835  travelNext();
836  }
837 
839  {
840  IWizardPageController* pController = dynamic_cast< IWizardPageController* >( _pCurrentPage );
841  return pController;
842  }
843 
845  {
846  return m_xWizardImpl->m_bTravelingSuspended;
847  }
848 
850  {
851  DBG_ASSERT( !m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::suspendTraveling: already suspended!" );
852  m_xWizardImpl->m_bTravelingSuspended = true;
853  }
854 
856  {
857  DBG_ASSERT( m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::resumeTraveling: nothing to resume!" );
858  m_xWizardImpl->m_bTravelingSuspended = false;
859  }
860 
862  : AssistantController(pParent, "vcl/ui/wizard.ui", "Wizard")
863  , m_pCurTabPage(nullptr)
864  , m_nCurState(0)
865  , m_pFirstPage(nullptr)
866  , m_xFinish(m_xAssistant->weld_widget_for_response(RET_OK))
867  , m_xCancel(m_xAssistant->weld_widget_for_response(RET_CANCEL))
868  , m_xNextPage(m_xAssistant->weld_widget_for_response(RET_YES))
869  , m_xPrevPage(m_xAssistant->weld_widget_for_response(RET_NO))
870  , m_xHelp(m_xAssistant->weld_widget_for_response(RET_HELP))
872  {
873  implConstruct(nButtonFlags);
874  }
875 
877  {
878  m_pImpl->sTitleBase = m_xAssistant->get_title();
879 
880  const bool bHideHelp = comphelper::LibreOfficeKit::isActive() &&
881  officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
882  // create the buttons according to the wizard button flags
883  // the help button
884  if (nButtonFlags & WizardButtonFlags::HELP && !bHideHelp)
885  m_xHelp->show();
886  else
887  m_xHelp->hide();
888 
889  // the previous button
890  if (nButtonFlags & WizardButtonFlags::PREVIOUS)
891  {
892  m_xPrevPage->set_help_id( HID_WIZARD_PREVIOUS );
893  m_xPrevPage->show();
894 
895  m_xPrevPage->connect_clicked( LINK( this, WizardMachine, OnPrevPage ) );
896  }
897  else
898  m_xPrevPage->hide();
899 
900  // the next button
901  if (nButtonFlags & WizardButtonFlags::NEXT)
902  {
903  m_xNextPage->set_help_id( HID_WIZARD_NEXT );
904  m_xNextPage->show();
905 
906  m_xNextPage->connect_clicked( LINK( this, WizardMachine, OnNextPage ) );
907  }
908  else
909  m_xNextPage->hide();
910 
911  // the finish button
912  if (nButtonFlags & WizardButtonFlags::FINISH)
913  {
914  m_xFinish->show();
915 
916  m_xFinish->connect_clicked( LINK( this, WizardMachine, OnFinish ) );
917  }
918  else
919  m_xFinish->hide();
920 
921  // the cancel button
922  if (nButtonFlags & WizardButtonFlags::CANCEL)
923  {
924  m_xCancel->show();
925  m_xCancel->connect_clicked( LINK( this, WizardMachine, OnCancel ) );
926  }
927  else
928  m_xCancel->hide();
929  }
930 
932  {
933  if (m_pImpl)
934  {
935  while (m_pFirstPage)
937  m_pImpl.reset();
938  }
939  }
940 
942  {
943  OUString sCompleteTitle(m_pImpl->sTitleBase);
944 
945  // append the page title
946  BuilderPage* pCurrentPage = GetPage(getCurrentState());
947  if ( pCurrentPage && !pCurrentPage->GetPageTitle().isEmpty() )
948  {
949  sCompleteTitle += " - " + pCurrentPage->GetPageTitle();
950  }
951 
952  m_xAssistant->set_title(sCompleteTitle);
953  }
954 
955  void WizardMachine::setTitleBase(const OUString& _rTitleBase)
956  {
957  m_pImpl->sTitleBase = _rTitleBase;
958  implUpdateTitle();
959  }
960 
962  {
963  if ( nullptr == GetPage( i_nState ) )
964  {
965  std::unique_ptr<BuilderPage> xNewPage = createPage( i_nState );
966  DBG_ASSERT( xNewPage, "WizardMachine::GetOrCreatePage: invalid new page (NULL)!" );
967 
968  // fill up the page sequence of our base class (with dummies)
969  while ( m_pImpl->nFirstUnknownPage < i_nState )
970  {
971  AddPage( nullptr );
972  ++m_pImpl->nFirstUnknownPage;
973  }
974 
975  if ( m_pImpl->nFirstUnknownPage == i_nState )
976  {
977  // encountered this page number the first time
978  AddPage(std::move(xNewPage));
979  ++m_pImpl->nFirstUnknownPage;
980  }
981  else
982  // already had this page - just change it
983  SetPage(i_nState, std::move(xNewPage));
984  }
985  return GetPage( i_nState );
986  }
987 
989  {
990  WizardTypes::WizardState nCurrentLevel = m_nCurState;
991  GetOrCreatePage( nCurrentLevel );
992 
993  enterState( nCurrentLevel );
994  }
995 
997  {
998  WizardTypes::WizardState nCurrentState = getCurrentState();
999  return leaveState(nCurrentState);
1000  }
1001 
1003  {
1004  // the new default button
1005  weld::Button* pNewDefButton = nullptr;
1006  if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
1007  pNewDefButton = m_xFinish.get();
1008  if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
1009  pNewDefButton = m_xNextPage.get();
1010  if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
1011  pNewDefButton = m_xPrevPage.get();
1012  if (_nWizardButtonFlags & WizardButtonFlags::HELP)
1013  pNewDefButton = m_xHelp.get();
1014  if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
1015  pNewDefButton = m_xCancel.get();
1016 
1017  if ( pNewDefButton )
1018  defaultButton( pNewDefButton );
1019  else
1020  m_xAssistant->recursively_unset_default_buttons();
1021  }
1022 
1024  {
1025  // loop through all (direct and indirect) descendants which participate in our tabbing order, and
1026  // reset the WB_DEFBUTTON for every window which is a button
1027  m_xAssistant->recursively_unset_default_buttons();
1028 
1029  // set its new style
1030  if (_pNewDefButton)
1031  _pNewDefButton->set_has_default(true);
1032  }
1033 
1034  void WizardMachine::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
1035  {
1036  if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
1037  m_xFinish->set_sensitive(_bEnable);
1038  if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
1039  m_xNextPage->set_sensitive(_bEnable);
1040  if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
1041  m_xPrevPage->set_sensitive(_bEnable);
1042  if (_nWizardButtonFlags & WizardButtonFlags::HELP)
1043  m_xHelp->set_sensitive(_bEnable);
1044  if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
1045  m_xCancel->set_sensitive(_bEnable);
1046  }
1047 
1049  {
1050  // tell the page
1051  IWizardPageController* pController = getPageController( GetPage( _nState ) );
1052  OSL_ENSURE( pController, "WizardMachine::enterState: no controller for the given page!" );
1053  if ( pController )
1054  pController->initializePage();
1055 
1058 
1059  enableButtons( WizardButtonFlags::PREVIOUS, !m_pImpl->aStateHistory.empty() );
1060 
1061  // set the new title - it depends on the current page (i.e. state)
1062  implUpdateTitle();
1063  }
1064 
1066  {
1067  // no need to ask the page here.
1068  // If we reach this point, we already gave the current page the chance to commit it's data,
1069  // and it was allowed to commit it's data
1070 
1071  return true;
1072  }
1073 
1075  {
1076  return Finish(RET_OK);
1077  }
1078 
1080  {
1081  if ( isTravelingSuspended() )
1082  return;
1083 
1084  // prevent WizardTravelSuspension from using this instance
1085  // after will be destructed due to onFinish and async response call
1086  {
1087  WizardTravelSuspension aTravelGuard( *this );
1088  if (!prepareLeaveCurrentState(WizardTypes::eFinish))
1089  {
1090  return;
1091  }
1092  }
1093 
1094  onFinish();
1095  }
1096 
1098  {
1099  m_xAssistant->response(RET_CANCEL);
1100  }
1101 
1103  {
1104  return _nCurrentState + 1;
1105  }
1106 
1108  {
1110  ENSURE_OR_RETURN( pController != nullptr, "WizardMachine::prepareLeaveCurrentState: no controller for the current page!", true );
1111  return pController->commitPage( _eReason );
1112  }
1113 
1115  {
1116  // allowed to leave the current page?
1118  return false;
1119 
1120  // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1121  std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1122  std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1123 
1124  WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
1125  while ( nCurrentRollbackState != _nTargetState )
1126  {
1127  DBG_ASSERT( !aTravelVirtually.empty(), "WizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
1128  nCurrentRollbackState = aTravelVirtually.top();
1129  aTravelVirtually.pop();
1130  }
1131  m_pImpl->aStateHistory = aTravelVirtually;
1132  if ( !ShowPage( _nTargetState ) )
1133  {
1134  m_pImpl->aStateHistory = aOldStateHistory;
1135  return false;
1136  }
1137  return true;
1138  }
1139 
1141  {
1142  WizardTypes::WizardState nCurrentState = getCurrentState();
1143 
1144  // allowed to leave the current page?
1145  if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
1146  return false;
1147 
1148  // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1149  std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1150  std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1151  while ( nCurrentState != _nTargetState )
1152  {
1153  WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
1154  if ( WZS_INVALID_STATE == nNextState )
1155  {
1156  OSL_FAIL( "WizardMachine::skipUntil: the given target state does not exist!" );
1157  return false;
1158  }
1159 
1160  // remember the skipped state in the history
1161  aTravelVirtually.push( nCurrentState );
1162 
1163  // get the next state
1164  nCurrentState = nNextState;
1165  }
1166  m_pImpl->aStateHistory = aTravelVirtually;
1167  // show the target page
1168  if ( !ShowPage( nCurrentState ) )
1169  {
1170  // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
1171  // but ShowPage doesn't? Somebody behaves very strange here...
1172  OSL_FAIL( "WizardMachine::skipUntil: very unpolite..." );
1173  m_pImpl->aStateHistory = aOldStateHistory;
1174  return false;
1175  }
1176  return true;
1177  }
1178 
1180  {
1181  // allowed to leave the current page?
1183  return;
1184 
1185  WizardTypes::WizardState nCurrentState = getCurrentState();
1186  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1187 
1188  if (WZS_INVALID_STATE == nNextState)
1189  return;
1190 
1191  // remember the skipped state in the history
1192  m_pImpl->aStateHistory.push(nCurrentState);
1193 
1194  // get the next state
1195  nCurrentState = nNextState;
1196 
1197  // show the (n+1)th page
1198  if (!ShowPage(nCurrentState))
1199  {
1200  // TODO: this leaves us in a state where we have no current page and an inconsistent state history.
1201  // Perhaps we should rollback the skipping here...
1202  OSL_FAIL("RoadmapWizard::skip: very unpolite...");
1203  // if somebody does a skip and then does not allow to leave...
1204  // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here,
1205  // somebody behaves really strange ...)
1206  return;
1207  }
1208 
1209  // all fine
1210  }
1211 
1213  {
1214  // allowed to leave the current page?
1216  return false;
1217 
1218  // determine the next state to travel to
1219  WizardTypes::WizardState nCurrentState = getCurrentState();
1220  WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1221  if (WZS_INVALID_STATE == nNextState)
1222  return false;
1223 
1224  // the state history is used by the enterState method
1225  // all fine
1226  m_pImpl->aStateHistory.push(nCurrentState);
1227  if (!ShowPage(nNextState))
1228  {
1229  m_pImpl->aStateHistory.pop();
1230  return false;
1231  }
1232 
1233  return true;
1234  }
1235 
1237  {
1238  if (DeactivatePage())
1239  {
1240  BuilderPage* pOldTabPage = m_pCurTabPage;
1241 
1242  m_nCurState = nState;
1243  ActivatePage();
1244 
1245  if (pOldTabPage)
1246  pOldTabPage->Deactivate();
1247 
1248  m_xAssistant->set_current_page(OString::number(nState));
1249 
1252 
1253  return true;
1254  }
1255  return false;
1256  }
1257 
1259  {
1260  return ShowPage(m_nCurState + 1);
1261  }
1262 
1264  {
1265  if (!m_nCurState)
1266  return false;
1267  return ShowPage(m_nCurState - 1);
1268  }
1269 
1271  {
1272  DBG_ASSERT(!m_pImpl->aStateHistory.empty(), "WizardMachine::travelPrevious: have no previous page!");
1273 
1274  // allowed to leave the current page?
1276  return false;
1277 
1278  // the next state to switch to
1279  WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1280 
1281  // the state history is used by the enterState method
1282  m_pImpl->aStateHistory.pop();
1283  // show this page
1284  if (!ShowPage(nPreviousState))
1285  {
1286  m_pImpl->aStateHistory.push(nPreviousState);
1287  return false;
1288  }
1289 
1290  // all fine
1291  return true;
1292  }
1293 
1294 
1296  {
1297 
1298  std::stack< WizardTypes::WizardState > aTemp;
1299  while(!m_pImpl->aStateHistory.empty())
1300  {
1301  WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1302  m_pImpl->aStateHistory.pop();
1303  if(nPreviousState != nToRemove)
1304  aTemp.push( nPreviousState );
1305  else
1306  break;
1307  }
1308  while(!aTemp.empty())
1309  {
1310  m_pImpl->aStateHistory.push( aTemp.top() );
1311  aTemp.pop();
1312  }
1313  }
1314 
1315 
1317  {
1318  m_pImpl->m_bAutoNextButtonState = true;
1319  }
1320 
1321 
1323  {
1324  return m_pImpl->m_bAutoNextButtonState;
1325  }
1326 
1328  {
1329  if ( isTravelingSuspended() )
1330  return;
1331  WizardTravelSuspension aTravelGuard( *this );
1332  travelPrevious();
1333  }
1334 
1336  {
1337  if ( isTravelingSuspended() )
1338  return;
1339  WizardTravelSuspension aTravelGuard( *this );
1340  travelNext();
1341  }
1342 
1344  {
1345  IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage);
1346  return pController;
1347  }
1348 
1349  void WizardMachine::getStateHistory( std::vector< WizardTypes::WizardState >& _out_rHistory )
1350  {
1351  std::stack< WizardTypes::WizardState > aHistoryCopy( m_pImpl->aStateHistory );
1352  while ( !aHistoryCopy.empty() )
1353  {
1354  _out_rHistory.push_back( aHistoryCopy.top() );
1355  aHistoryCopy.pop();
1356  }
1357  }
1358 
1360  {
1362  }
1363 
1365  {
1366  const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) );
1367  OSL_ENSURE( pController != nullptr, "RoadmapWizard::updateTravelUI: no controller for the current page!" );
1368 
1369  bool bCanAdvance =
1370  ( !pController || pController->canAdvance() ) // the current page allows to advance
1371  && canAdvance(); // the dialog as a whole allows to advance
1372  enableButtons( WizardButtonFlags::NEXT, bCanAdvance );
1373  }
1374 
1376  {
1377  return m_pImpl->m_bTravelingSuspended;
1378  }
1379 
1381  {
1382  DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "WizardMachine::suspendTraveling: already suspended!" );
1383  m_pImpl->m_bTravelingSuspended = true;
1384  }
1385 
1387  {
1388  if (!m_pImpl)
1389  return;
1390 
1391  DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "WizardMachine::resumeTraveling: nothing to resume!" );
1392  m_pImpl->m_bTravelingSuspended = false;
1393  }
1394 
1395  bool WizardMachine::Finish(short nResult)
1396  {
1397  if ( DeactivatePage() )
1398  {
1399  if (m_pCurTabPage)
1401 
1402  m_xAssistant->response(nResult);
1403  return true;
1404  }
1405  else
1406  return false;
1407  }
1408 
1409  void WizardMachine::AddPage(std::unique_ptr<BuilderPage> xPage)
1410  {
1411  WizPageData* pNewPageData = new WizPageData;
1412  pNewPageData->mpNext = nullptr;
1413  pNewPageData->mxPage = std::move(xPage);
1414 
1415  if ( !m_pFirstPage )
1416  m_pFirstPage = pNewPageData;
1417  else
1418  {
1419  WizPageData* pPageData = m_pFirstPage;
1420  while ( pPageData->mpNext )
1421  pPageData = pPageData->mpNext;
1422  pPageData->mpNext = pNewPageData;
1423  }
1424  }
1425 
1427  {
1428  WizPageData* pPrevPageData = nullptr;
1429  WizPageData* pPageData = m_pFirstPage;
1430  while ( pPageData )
1431  {
1432  if (pPageData->mxPage.get() == pPage)
1433  {
1434  if (pPrevPageData)
1435  pPrevPageData->mpNext = pPageData->mpNext;
1436  else
1437  m_pFirstPage = pPageData->mpNext;
1438  if (pPage == m_pCurTabPage)
1439  m_pCurTabPage = nullptr;
1440  delete pPageData;
1441  return;
1442  }
1443 
1444  pPrevPageData = pPageData;
1445  pPageData = pPageData->mpNext;
1446  }
1447 
1448  OSL_FAIL( "WizardMachine::RemovePage() - Page not in list" );
1449  }
1450 
1451  void WizardMachine::SetPage(WizardTypes::WizardState nLevel, std::unique_ptr<BuilderPage> xPage)
1452  {
1453  sal_uInt16 nTempLevel = 0;
1454  WizPageData* pPageData = m_pFirstPage;
1455  while ( pPageData )
1456  {
1457  if ( (nTempLevel == nLevel) || !pPageData->mpNext )
1458  break;
1459 
1460  nTempLevel++;
1461  pPageData = pPageData->mpNext;
1462  }
1463 
1464  if ( pPageData )
1465  {
1466  if (pPageData->mxPage.get() == m_pCurTabPage)
1467  m_pCurTabPage = nullptr;
1468  pPageData->mxPage = std::move(xPage);
1469  }
1470  }
1471 
1473  {
1474  sal_uInt16 nTempLevel = 0;
1475 
1476  for (WizPageData* pPageData = m_pFirstPage; pPageData;
1477  pPageData = pPageData->mpNext)
1478  {
1479  if ( nTempLevel == nLevel )
1480  return pPageData->mxPage.get();
1481  nTempLevel++;
1482  }
1483 
1484  return nullptr;
1485  }
1486 } // namespace svt
1487 
1488 
1489 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Button > m_xPrevPage
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
bool IsInputEnabled() const
Definition: window2.cxx:1125
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:654
virtual bool Close() override
Definition: dialog.cxx:842
void setWidth(tools::Long nWidth)
void SetClickHdl(const Link< Button *, void > &rLink)
Definition: button.hxx:79
VclPtr< vcl::Window > mpViewWindow
Definition: wizdlg.hxx:75
virtual void initializePage()=0
void EndDialog(tools::Long nResult=RET_CANCEL)
Definition: dialog.cxx:1098
void suspendTraveling(AccessGuard)
sal_uInt16 mnCurLevel
Definition: wizdlg.hxx:76
void Finish(tools::Long nResult=0)
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
long Long
#define WIZARDDIALOG_VIEW_DLGOFFSET_X
std::unique_ptr< WizardMachineImplData > m_pImpl
void ImplCalcSize(Size &rSize)
virtual Size GetSizePixel() const
Definition: window.cxx:2397
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1260
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:51
tools::Long mnOffset
Definition: wizimpldata.hxx:35
is - no, not a wizard for a roadmap, but the base class for wizards supporting a roadmap.
PosSizeFlags
Definition: window.hxx:125
#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:308
virtual ~WizardMachine() override
virtual IWizardPageController * getPageController(BuilderPage *pCurrentPage) const
void SetHelpId(const OString &)
Definition: window2.cxx:821
VclPtr< Button > mpButton
Definition: wizimpldata.hxx:34
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
std::unique_ptr< weld::Button > m_xHelp
void defaultButton(WizardButtonFlags _nWizardButtonFlags)
set the default style for a button
WizardButtonFlags
Definition: vclenum.hxx:278
#define HID_WIZARD_NEXT
bool IsActive() const
Definition: task.hxx:91
StateChangedType
Definition: window.hxx:289
constexpr tools::Long Width() const
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2428
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:1151
virtual void set_has_default(bool has_default)=0
void Hide()
Definition: window.hxx:897
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:126
VclPtr< TabPage > mpPage
Definition: wizdlg.hxx:32
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1272
#define WZS_INVALID_STATE
virtual OUString GetText() const
Definition: window.cxx:3050
tools::Long LogicalCoordinateToPixel(int iCoordinate)
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
VCL_DLLPRIVATE void implConstruct(const WizardButtonFlags _nButtonFlags)
virtual void Deactivate()
Definition: weldutils.cxx:34
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:369
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
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
Point LogicToPixel(const Point &rLogicPt) const
Definition: window3.cxx:131
#define DBG_ASSERT(sCon, aError)
int i
VclPtr< PushButton > m_pNextPage
Definition: wizdlg.hxx:100
weld::DialogController * m_pDialogController
Definition: builderpage.hxx:40
void travelNext()
travel to the next state
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:1115
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
const Size & GetPageSizePixel() const
Definition: wizdlg.hxx:135
MouseNotifyEvent GetType() const
Definition: event.hxx:300
void AddButton(Button *pButton, tools::Long nOffset=0)
VclPtr< PushButton > mpNextBtn
Definition: wizdlg.hxx:74
virtual ~OWizardPage() override
virtual void Resize() override
bool IsInExecute() const
Definition: dialog.hxx:122
bool isTravelingSuspended() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: tabpage.cxx:199
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:1110
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:32
bool travelNext()
travel to the next state
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2661
#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:3913
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:1362
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
VclPtr< PushButton > mpPrevBtn
Definition: wizdlg.hxx:73
virtual void StateChanged(StateChangedType nStateChange) override
Definition: dialog.cxx:753
void SetPressed(bool bPressed)
Definition: button.cxx:1588
bool IsShift() const
Definition: keycod.hxx:56
std::unique_ptr< weld::Button > m_xFinish
WizardMachine(weld::Window *_pParent, WizardButtonFlags _nButtonFlags)
constexpr tools::Long Height() const
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:1100
virtual OUString GetText() const override
Definition: syswin.cxx:1063
#define WIZARDDIALOG_BUTTON_STDOFFSET_X
void GetOrCreatePage(const WizardTypes::WizardState i_nState)
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:1057
tools::Long AdjustWidth(tools::Long n)
bool IsMod1() const
Definition: keycod.hxx:58
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)
tools::Long AdjustHeight(tools::Long n)
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
WinBits const WB_TABSTOP
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
bool ShowPage(sal_uInt16 nLevel)
void setHeight(tools::Long nHeight)
BuilderPage * m_pCurTabPage
bool IsEnabled() const
Definition: window2.cxx:1120
#define HID_WIZARD_PREVIOUS
BuilderPage * GetPage(WizardTypes::WizardState eState) const
#define WIZARDDIALOG_BUTTON_DLGOFFSET_X
OUString VclResId(const char *pId)
Definition: svdata.cxx:259
WinBits GetStyle() const
Definition: window2.cxx:951
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
void travelPrevious()
travel to the previous state
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:1105
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:84
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
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:2551
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:1255
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
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:2183
virtual void initializePage() override