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