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 OUStringLiteral HID_WIZARD_NEXT = u"SVT_HID_WIZARD_NEXT";
32constexpr OUStringLiteral HID_WIZARD_PREVIOUS = u"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 OUString& 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 pPage->Hide();
535 ImplWizPageData* pPageData = mpFirstPage;
536 while ( pPageData->mpNext )
537 pPageData = pPageData->mpNext;
538 pPageData->mpNext = pNewPageData;
539 }
540 }
541
543 {
544 ImplWizPageData* pPrevPageData = nullptr;
545 ImplWizPageData* pPageData = mpFirstPage;
546 while ( pPageData )
547 {
548 if ( pPageData->mpPage == pPage )
549 {
550 if ( pPrevPageData )
551 pPrevPageData->mpNext = pPageData->mpNext;
552 else
553 mpFirstPage = pPageData->mpNext;
554 if ( pPage == mpCurTabPage )
555 mpCurTabPage = nullptr;
556 delete pPageData;
557 return;
558 }
559
560 pPrevPageData = pPageData;
561 pPageData = pPageData->mpNext;
562 }
563
564 OSL_FAIL( "RoadmapWizard::RemovePage() - Page not in list" );
565 }
566
567 void RoadmapWizard::SetPage( sal_uInt16 nLevel, TabPage* pPage )
568 {
569 sal_uInt16 nTempLevel = 0;
570 ImplWizPageData* pPageData = mpFirstPage;
571 while ( pPageData )
572 {
573 if ( (nTempLevel == nLevel) || !pPageData->mpNext )
574 break;
575
576 nTempLevel++;
577 pPageData = pPageData->mpNext;
578 }
579
580 if ( pPageData )
581 {
582 if ( pPageData->mpPage == mpCurTabPage )
583 mpCurTabPage = nullptr;
584 pPageData->mpPage = pPage;
585 }
586 }
587
588 TabPage* RoadmapWizard::GetPage( sal_uInt16 nLevel ) const
589 {
590 sal_uInt16 nTempLevel = 0;
591
592 for (ImplWizPageData* pPageData = mpFirstPage; pPageData;
593 pPageData = pPageData->mpNext)
594 {
595 if ( nTempLevel == nLevel )
596 return pPageData->mpPage;
597 nTempLevel++;
598 }
599
600 return nullptr;
601 }
602
604 {
605 ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
606 pNewBtnData->mpNext = nullptr;
607 pNewBtnData->mpButton = pButton;
608 pNewBtnData->mnOffset = nOffset;
609
610 if ( !mpFirstBtn )
611 mpFirstBtn = pNewBtnData;
612 else
613 {
614 ImplWizButtonData* pBtnData = mpFirstBtn;
615 while ( pBtnData->mpNext )
616 pBtnData = pBtnData->mpNext;
617 pBtnData->mpNext = pNewBtnData;
618 }
619 }
620
622 {
623 ImplWizButtonData* pPrevBtnData = nullptr;
624 ImplWizButtonData* pBtnData = mpFirstBtn;
625 while ( pBtnData )
626 {
627 if ( pBtnData->mpButton == pButton )
628 {
629 if ( pPrevBtnData )
630 pPrevBtnData->mpNext = pBtnData->mpNext;
631 else
632 mpFirstBtn = pBtnData->mpNext;
633 delete pBtnData;
634 return;
635 }
636
637 pPrevBtnData = pBtnData;
638 pBtnData = pBtnData->mpNext;
639 }
640
641 OSL_FAIL( "RoadmapWizard::RemoveButton() - Button not in list" );
642 }
643
645 {
646 if ( isTravelingSuspended() )
647 return;
648 RoadmapWizardTravelSuspension aTravelGuard( *this );
649 Finish( RET_OK );
650 }
651
653 {
654 // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
655 std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
656 std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
657
658 WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
659 while ( nCurrentRollbackState != _nTargetState )
660 {
661 DBG_ASSERT( !aTravelVirtually.empty(), "RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" );
662 nCurrentRollbackState = aTravelVirtually.top();
663 aTravelVirtually.pop();
664 }
665 m_xWizardImpl->aStateHistory = aTravelVirtually;
666 if ( !ShowPage( _nTargetState ) )
667 {
668 m_xWizardImpl->aStateHistory = aOldStateHistory;
669 return false;
670 }
671 return true;
672 }
673
675 {
677
678 // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong
679 std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory;
680 std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory;
681 while ( nCurrentState != _nTargetState )
682 {
683 WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
684 if ( WZS_INVALID_STATE == nNextState )
685 {
686 OSL_FAIL( "RoadmapWizard::skipUntil: the given target state does not exist!" );
687 return false;
688 }
689
690 // remember the skipped state in the history
691 aTravelVirtually.push( nCurrentState );
692
693 // get the next state
694 nCurrentState = nNextState;
695 }
696 m_xWizardImpl->aStateHistory = aTravelVirtually;
697 // show the target page
698 if ( !ShowPage( nCurrentState ) )
699 {
700 // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
701 // but ShowPage doesn't? Somebody behaves very strange here...
702 OSL_FAIL( "RoadmapWizard::skipUntil: very unpolite..." );
703 m_xWizardImpl->aStateHistory = aOldStateHistory;
704 return false;
705 }
706 return true;
707 }
708
710 {
711 // determine the next state to travel to
713 WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
714 if (WZS_INVALID_STATE == nNextState)
715 return;
716
717 // the state history is used by the enterState method
718 // all fine
719 m_xWizardImpl->aStateHistory.push(nCurrentState);
720 if (!ShowPage(nNextState))
721 {
722 m_xWizardImpl->aStateHistory.pop();
723 }
724 }
725
727 {
728 DBG_ASSERT(!m_xWizardImpl->aStateHistory.empty(), "RoadmapWizard::travelPrevious: have no previous page!");
729
730 // the next state to switch to
731 WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
732
733 // the state history is used by the enterState method
734 m_xWizardImpl->aStateHistory.pop();
735 // show this page
736 if (!ShowPage(nPreviousState))
737 {
738 m_xWizardImpl->aStateHistory.push(nPreviousState);
739 }
740
741 // all fine
742 }
743
745 {
746
747 std::stack< WizardTypes::WizardState > aTemp;
748 while(!m_xWizardImpl->aStateHistory.empty())
749 {
750 WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top();
751 m_xWizardImpl->aStateHistory.pop();
752 if(nPreviousState != nToRemove)
753 aTemp.push( nPreviousState );
754 else
755 break;
756 }
757 while(!aTemp.empty())
758 {
759 m_xWizardImpl->aStateHistory.push( aTemp.top() );
760 aTemp.pop();
761 }
762 }
763
765 {
766 if ( isTravelingSuspended() )
767 return;
768 RoadmapWizardTravelSuspension aTravelGuard( *this );
769 travelPrevious();
770 }
771
773 {
774 if ( isTravelingSuspended() )
775 return;
776 RoadmapWizardTravelSuspension aTravelGuard( *this );
777 travelNext();
778 }
779
781 {
782 return m_xWizardImpl->m_bTravelingSuspended;
783 }
784
786 {
787 DBG_ASSERT( !m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::suspendTraveling: already suspended!" );
788 m_xWizardImpl->m_bTravelingSuspended = true;
789 }
790
792 {
793 DBG_ASSERT( m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::resumeTraveling: nothing to resume!" );
794 m_xWizardImpl->m_bTravelingSuspended = false;
795 }
796
798 : AssistantController(pParent, "vcl/ui/wizard.ui", "Wizard")
799 , m_pCurTabPage(nullptr)
800 , m_nCurState(0)
801 , m_pFirstPage(nullptr)
802 , m_xFinish(m_xAssistant->weld_widget_for_response(RET_OK))
803 , m_xCancel(m_xAssistant->weld_widget_for_response(RET_CANCEL))
804 , m_xNextPage(m_xAssistant->weld_widget_for_response(RET_YES))
805 , m_xPrevPage(m_xAssistant->weld_widget_for_response(RET_NO))
806 , m_xHelp(m_xAssistant->weld_widget_for_response(RET_HELP))
808 {
809 implConstruct(nButtonFlags);
810 }
811
813 {
814 m_pImpl->sTitleBase = m_xAssistant->get_title();
815
816 const bool bHideHelp = comphelper::LibreOfficeKit::isActive() &&
817 officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
818 // create the buttons according to the wizard button flags
819 // the help button
820 if (nButtonFlags & WizardButtonFlags::HELP && !bHideHelp)
821 m_xHelp->show();
822 else
823 m_xHelp->hide();
824
825 // the previous button
826 if (nButtonFlags & WizardButtonFlags::PREVIOUS)
827 {
828 m_xPrevPage->set_help_id( HID_WIZARD_PREVIOUS );
829 m_xPrevPage->show();
830
831 m_xPrevPage->connect_clicked( LINK( this, WizardMachine, OnPrevPage ) );
832 }
833 else
834 m_xPrevPage->hide();
835
836 // the next button
837 if (nButtonFlags & WizardButtonFlags::NEXT)
838 {
839 m_xNextPage->set_help_id( HID_WIZARD_NEXT );
840 m_xNextPage->show();
841
842 m_xNextPage->connect_clicked( LINK( this, WizardMachine, OnNextPage ) );
843 }
844 else
845 m_xNextPage->hide();
846
847 // the finish button
848 if (nButtonFlags & WizardButtonFlags::FINISH)
849 {
850 m_xFinish->show();
851
852 m_xFinish->connect_clicked( LINK( this, WizardMachine, OnFinish ) );
853 }
854 else
855 m_xFinish->hide();
856
857 // the cancel button
858 if (nButtonFlags & WizardButtonFlags::CANCEL)
859 {
860 m_xCancel->show();
861 m_xCancel->connect_clicked( LINK( this, WizardMachine, OnCancel ) );
862 }
863 else
864 m_xCancel->hide();
865 }
866
868 {
869 if (m_pImpl)
870 {
871 while (m_pFirstPage)
873 m_pImpl.reset();
874 }
875 }
876
878 {
879 OUString sCompleteTitle(m_pImpl->sTitleBase);
880
881 // append the page title
882 BuilderPage* pCurrentPage = GetPage(getCurrentState());
883 if ( pCurrentPage && !pCurrentPage->GetPageTitle().isEmpty() )
884 {
885 sCompleteTitle += " - " + pCurrentPage->GetPageTitle();
886 }
887
888 m_xAssistant->set_title(sCompleteTitle);
889 }
890
891 void WizardMachine::setTitleBase(const OUString& _rTitleBase)
892 {
893 m_pImpl->sTitleBase = _rTitleBase;
895 }
896
898 {
899 return OUString::number(nState);
900 }
901
903 {
904 return rIdent.toInt32();
905 }
906
908 {
909 if ( nullptr == GetPage( i_nState ) )
910 {
911 std::unique_ptr<BuilderPage> xNewPage = createPage( i_nState );
912 DBG_ASSERT( xNewPage, "WizardMachine::GetOrCreatePage: invalid new page (NULL)!" );
913
914 // fill up the page sequence of our base class (with dummies)
915 while ( m_pImpl->nFirstUnknownPage < i_nState )
916 {
917 AddPage( nullptr );
918 ++m_pImpl->nFirstUnknownPage;
919 }
920
921 if ( m_pImpl->nFirstUnknownPage == i_nState )
922 {
923 // encountered this page number the first time
924 AddPage(std::move(xNewPage));
925 ++m_pImpl->nFirstUnknownPage;
926 }
927 else
928 // already had this page - just change it
929 SetPage(i_nState, std::move(xNewPage));
930 }
931 return GetPage( i_nState );
932 }
933
935 {
937 GetOrCreatePage( nCurrentLevel );
938
939 enterState( nCurrentLevel );
940 }
941
943 {
945 return leaveState(nCurrentState);
946 }
947
949 {
950 // the new default button
951 weld::Button* pNewDefButton = nullptr;
952 if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
953 pNewDefButton = m_xFinish.get();
954 if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
955 pNewDefButton = m_xNextPage.get();
956 if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
957 pNewDefButton = m_xPrevPage.get();
958 if (_nWizardButtonFlags & WizardButtonFlags::HELP)
959 pNewDefButton = m_xHelp.get();
960 if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
961 pNewDefButton = m_xCancel.get();
962
963 defaultButton(pNewDefButton);
964 }
965
967 {
968 // loop through all (direct and indirect) descendants which participate in our tabbing order, and
969 // reset the WB_DEFBUTTON for every window which is a button and set _pNewDefButton as the new
970 // WB_DEFBUTTON
971 m_xAssistant->change_default_widget(nullptr, _pNewDefButton);
972 }
973
974 void WizardMachine::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
975 {
976 if (_nWizardButtonFlags & WizardButtonFlags::FINISH)
977 m_xFinish->set_sensitive(_bEnable);
978 if (_nWizardButtonFlags & WizardButtonFlags::NEXT)
979 m_xNextPage->set_sensitive(_bEnable);
980 if (_nWizardButtonFlags & WizardButtonFlags::PREVIOUS)
981 m_xPrevPage->set_sensitive(_bEnable);
982 if (_nWizardButtonFlags & WizardButtonFlags::HELP)
983 m_xHelp->set_sensitive(_bEnable);
984 if (_nWizardButtonFlags & WizardButtonFlags::CANCEL)
985 m_xCancel->set_sensitive(_bEnable);
986 }
987
989 {
990 // tell the page
991 IWizardPageController* pController = getPageController( GetPage( _nState ) );
992 OSL_ENSURE( pController, "WizardMachine::enterState: no controller for the given page!" );
993 if ( pController )
994 pController->initializePage();
995
998
999 enableButtons( WizardButtonFlags::PREVIOUS, !m_pImpl->aStateHistory.empty() );
1000
1001 // set the new title - it depends on the current page (i.e. state)
1003 }
1004
1006 {
1007 // no need to ask the page here.
1008 // If we reach this point, we already gave the current page the chance to commit it's data,
1009 // and it was allowed to commit it's data
1010
1011 return true;
1012 }
1013
1015 {
1016 return Finish(RET_OK);
1017 }
1018
1020 {
1021 if ( isTravelingSuspended() )
1022 return;
1023
1024 // prevent WizardTravelSuspension from using this instance
1025 // after will be destructed due to onFinish and async response call
1026 {
1027 WizardTravelSuspension aTravelGuard( *this );
1028 if (!prepareLeaveCurrentState(WizardTypes::eFinish))
1029 {
1030 return;
1031 }
1032 }
1033
1034 onFinish();
1035 }
1036
1038 {
1039 m_xAssistant->response(RET_CANCEL);
1040 }
1041
1043 {
1044 return _nCurrentState + 1;
1045 }
1046
1048 {
1049 IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) );
1050 ENSURE_OR_RETURN( pController != nullptr, "WizardMachine::prepareLeaveCurrentState: no controller for the current page!", true );
1051 return pController->commitPage( _eReason );
1052 }
1053
1055 {
1056 // allowed to leave the current page?
1058 return false;
1059
1060 // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1061 std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1062 std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1063
1064 WizardTypes::WizardState nCurrentRollbackState = getCurrentState();
1065 while ( nCurrentRollbackState != _nTargetState )
1066 {
1067 DBG_ASSERT( !aTravelVirtually.empty(), "WizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
1068 nCurrentRollbackState = aTravelVirtually.top();
1069 aTravelVirtually.pop();
1070 }
1071 m_pImpl->aStateHistory = aTravelVirtually;
1072 if ( !ShowPage( _nTargetState ) )
1073 {
1074 m_pImpl->aStateHistory = aOldStateHistory;
1075 return false;
1076 }
1077 return true;
1078 }
1079
1081 {
1082 WizardTypes::WizardState nCurrentState = getCurrentState();
1083
1084 // allowed to leave the current page?
1085 if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) )
1086 return false;
1087
1088 // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
1089 std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory;
1090 std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory;
1091 while ( nCurrentState != _nTargetState )
1092 {
1093 WizardTypes::WizardState nNextState = determineNextState( nCurrentState );
1094 if ( WZS_INVALID_STATE == nNextState )
1095 {
1096 OSL_FAIL( "WizardMachine::skipUntil: the given target state does not exist!" );
1097 return false;
1098 }
1099
1100 // remember the skipped state in the history
1101 aTravelVirtually.push( nCurrentState );
1102
1103 // get the next state
1104 nCurrentState = nNextState;
1105 }
1106 m_pImpl->aStateHistory = aTravelVirtually;
1107 // show the target page
1108 if ( !ShowPage( nCurrentState ) )
1109 {
1110 // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
1111 // but ShowPage doesn't? Somebody behaves very strange here...
1112 OSL_FAIL( "WizardMachine::skipUntil: very unpolite..." );
1113 m_pImpl->aStateHistory = aOldStateHistory;
1114 return false;
1115 }
1116 return true;
1117 }
1118
1120 {
1121 // allowed to leave the current page?
1123 return;
1124
1125 WizardTypes::WizardState nCurrentState = getCurrentState();
1126 WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1127
1128 if (WZS_INVALID_STATE == nNextState)
1129 return;
1130
1131 // remember the skipped state in the history
1132 m_pImpl->aStateHistory.push(nCurrentState);
1133
1134 // get the next state
1135 nCurrentState = nNextState;
1136
1137 // show the (n+1)th page
1138 if (!ShowPage(nCurrentState))
1139 {
1140 // TODO: this leaves us in a state where we have no current page and an inconsistent state history.
1141 // Perhaps we should rollback the skipping here...
1142 OSL_FAIL("RoadmapWizard::skip: very unpolite...");
1143 // if somebody does a skip and then does not allow to leave...
1144 // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here,
1145 // somebody behaves really strange ...)
1146 return;
1147 }
1148
1149 // all fine
1150 }
1151
1153 {
1154 // allowed to leave the current page?
1156 return false;
1157
1158 // determine the next state to travel to
1159 WizardTypes::WizardState nCurrentState = getCurrentState();
1160 WizardTypes::WizardState nNextState = determineNextState(nCurrentState);
1161 if (WZS_INVALID_STATE == nNextState)
1162 return false;
1163
1164 // the state history is used by the enterState method
1165 // all fine
1166 m_pImpl->aStateHistory.push(nCurrentState);
1167 if (!ShowPage(nNextState))
1168 {
1169 m_pImpl->aStateHistory.pop();
1170 return false;
1171 }
1172
1173 return true;
1174 }
1175
1177 {
1178 if (DeactivatePage())
1179 {
1180 BuilderPage* pOldTabPage = m_pCurTabPage;
1181
1183 ActivatePage();
1184
1185 if (pOldTabPage)
1186 pOldTabPage->Deactivate();
1187
1188 m_xAssistant->set_current_page(getPageIdentForState(nState));
1189
1192
1193 return true;
1194 }
1195 return false;
1196 }
1197
1199 {
1200 return ShowPage(m_nCurState + 1);
1201 }
1202
1204 {
1205 if (!m_nCurState)
1206 return false;
1207 return ShowPage(m_nCurState - 1);
1208 }
1209
1211 {
1212 DBG_ASSERT(!m_pImpl->aStateHistory.empty(), "WizardMachine::travelPrevious: have no previous page!");
1213
1214 // allowed to leave the current page?
1216 return false;
1217
1218 // the next state to switch to
1219 WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1220
1221 // the state history is used by the enterState method
1222 m_pImpl->aStateHistory.pop();
1223 // show this page
1224 if (!ShowPage(nPreviousState))
1225 {
1226 m_pImpl->aStateHistory.push(nPreviousState);
1227 return false;
1228 }
1229
1230 // all fine
1231 return true;
1232 }
1233
1234
1236 {
1237
1238 std::stack< WizardTypes::WizardState > aTemp;
1239 while(!m_pImpl->aStateHistory.empty())
1240 {
1241 WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top();
1242 m_pImpl->aStateHistory.pop();
1243 if(nPreviousState != nToRemove)
1244 aTemp.push( nPreviousState );
1245 else
1246 break;
1247 }
1248 while(!aTemp.empty())
1249 {
1250 m_pImpl->aStateHistory.push( aTemp.top() );
1251 aTemp.pop();
1252 }
1253 }
1254
1255
1257 {
1258 m_pImpl->m_bAutoNextButtonState = true;
1259 }
1260
1261
1263 {
1264 return m_pImpl->m_bAutoNextButtonState;
1265 }
1266
1268 {
1269 if ( isTravelingSuspended() )
1270 return;
1271 WizardTravelSuspension aTravelGuard( *this );
1272 travelPrevious();
1273 }
1274
1276 {
1277 if ( isTravelingSuspended() )
1278 return;
1279 WizardTravelSuspension aTravelGuard( *this );
1280 travelNext();
1281 }
1282
1283 IWizardPageController* WizardMachine::getPageController(BuilderPage* pCurrentPage) const
1284 {
1285 IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage);
1286 return pController;
1287 }
1288
1289 void WizardMachine::getStateHistory( std::vector< WizardTypes::WizardState >& _out_rHistory )
1290 {
1291 std::stack< WizardTypes::WizardState > aHistoryCopy( m_pImpl->aStateHistory );
1292 while ( !aHistoryCopy.empty() )
1293 {
1294 _out_rHistory.push_back( aHistoryCopy.top() );
1295 aHistoryCopy.pop();
1296 }
1297 }
1298
1300 {
1302 }
1303
1305 {
1306 const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) );
1307 OSL_ENSURE( pController != nullptr, "RoadmapWizard::updateTravelUI: no controller for the current page!" );
1308
1309 bool bCanAdvance =
1310 ( !pController || pController->canAdvance() ) // the current page allows to advance
1311 && canAdvance(); // the dialog as a whole allows to advance
1312 enableButtons( WizardButtonFlags::NEXT, bCanAdvance );
1313 }
1314
1316 {
1317 return m_pImpl->m_bTravelingSuspended;
1318 }
1319
1321 {
1322 DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "WizardMachine::suspendTraveling: already suspended!" );
1323 m_pImpl->m_bTravelingSuspended = true;
1324 }
1325
1327 {
1328 if (!m_pImpl)
1329 return;
1330
1331 DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "WizardMachine::resumeTraveling: nothing to resume!" );
1332 m_pImpl->m_bTravelingSuspended = false;
1333 }
1334
1335 bool WizardMachine::Finish(short nResult)
1336 {
1337 if ( DeactivatePage() )
1338 {
1339 if (m_pCurTabPage)
1341
1342 m_xAssistant->response(nResult);
1343 return true;
1344 }
1345 else
1346 return false;
1347 }
1348
1349 void WizardMachine::AddPage(std::unique_ptr<BuilderPage> xPage)
1350 {
1351 WizPageData* pNewPageData = new WizPageData;
1352 pNewPageData->mpNext = nullptr;
1353 pNewPageData->mxPage = std::move(xPage);
1354
1355 if ( !m_pFirstPage )
1356 m_pFirstPage = pNewPageData;
1357 else
1358 {
1359 WizPageData* pPageData = m_pFirstPage;
1360 while ( pPageData->mpNext )
1361 pPageData = pPageData->mpNext;
1362 pPageData->mpNext = pNewPageData;
1363 }
1364 }
1365
1367 {
1368 WizPageData* pPrevPageData = nullptr;
1369 WizPageData* pPageData = m_pFirstPage;
1370 while ( pPageData )
1371 {
1372 if (pPageData->mxPage.get() == pPage)
1373 {
1374 if (pPrevPageData)
1375 pPrevPageData->mpNext = pPageData->mpNext;
1376 else
1377 m_pFirstPage = pPageData->mpNext;
1378 if (pPage == m_pCurTabPage)
1379 m_pCurTabPage = nullptr;
1380 delete pPageData;
1381 return;
1382 }
1383
1384 pPrevPageData = pPageData;
1385 pPageData = pPageData->mpNext;
1386 }
1387
1388 OSL_FAIL( "WizardMachine::RemovePage() - Page not in list" );
1389 }
1390
1391 void WizardMachine::SetPage(WizardTypes::WizardState nLevel, std::unique_ptr<BuilderPage> xPage)
1392 {
1393 sal_uInt16 nTempLevel = 0;
1394 WizPageData* pPageData = m_pFirstPage;
1395 while ( pPageData )
1396 {
1397 if ( (nTempLevel == nLevel) || !pPageData->mpNext )
1398 break;
1399
1400 nTempLevel++;
1401 pPageData = pPageData->mpNext;
1402 }
1403
1404 if ( pPageData )
1405 {
1406 if (pPageData->mxPage.get() == m_pCurTabPage)
1407 m_pCurTabPage = nullptr;
1408 pPageData->mxPage = std::move(xPage);
1409 }
1410 }
1411
1413 {
1414 sal_uInt16 nTempLevel = 0;
1415
1416 for (WizPageData* pPageData = m_pFirstPage; pPageData;
1417 pPageData = pPageData->mpNext)
1418 {
1419 if ( nTempLevel == nLevel )
1420 return pPageData->mxPage.get();
1421 nTempLevel++;
1422 }
1423
1424 return nullptr;
1425 }
1426} // namespace svt
1427
1428
1429/* 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:98
bool IsInExecute() const
Definition: dialog.hxx:125
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:87
virtual void Resize() override
Definition: dialog.cxx:1406
void EndDialog(tools::Long nResult=RET_CANCEL)
Definition: dialog.cxx:1134
virtual bool Close() override
Definition: dialog.cxx:845
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:1683
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:1051
void SetMinOutputSizePixel(const Size &rSize)
Definition: syswin.cxx:365
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: tabpage.cxx:197
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
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
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual ~OWizardPage() override
OWizardPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OUString &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:264
wizard for a roadmap
Definition: wizdlg.hxx:65
VclPtr< OKButton > m_pFinish
Definition: wizdlg.hxx:96
bool ShowPage(sal_uInt16 nLevel)
sal_uInt16 GetCurLevel() const
Definition: wizdlg.hxx:122
void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
ImplWizPageData * mpFirstPage
Definition: wizdlg.hxx:69
std::unique_ptr< WizardMachineImplData > m_xWizardImpl
Definition: wizdlg.hxx:103
virtual void StateChanged(StateChangedType nStateChange) override
void GetOrCreatePage(const WizardTypes::WizardState i_nState)
Idle maWizardLayoutIdle
Definition: wizdlg.hxx:67
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:73
VclPtr< TabPage > mpCurTabPage
Definition: wizdlg.hxx:71
sal_Int16 mnLeftAlignCount
Definition: wizdlg.hxx:76
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:70
const Size & GetPageSizePixel() const
Definition: wizdlg.hxx:133
void RemoveButton(Button *pButton)
void Finish(tools::Long nResult=0)
void ImplCalcSize(Size &rSize)
VclPtr< CancelButton > m_pCancel
Definition: wizdlg.hxx:97
void SetPage(sal_uInt16 nLevel, TabPage *pPage)
bool mbEmptyViewMargin
Definition: wizdlg.hxx:77
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:74
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:72
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:98
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:75
VclPtr< PushButton > m_pPrevPage
Definition: wizdlg.hxx:99
void suspendTraveling(AccessGuard)
VclPtr< HelpButton > m_pHelp
Definition: wizdlg.hxx:100
TabPage * GetPage(sal_uInt16 nLevel) const
void implConstruct(const WizardButtonFlags _nButtonFlags)
bool IsReallyVisible() const
Definition: window2.cxx:1133
bool IsInputEnabled() const
Definition: window2.cxx:1153
Point LogicToPixel(const Point &rLogicPt) const
Definition: window3.cxx:131
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1288
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3930
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1300
WinBits GetStyle() const
Definition: window2.cxx:979
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
bool IsReallyShown() const
Definition: window2.cxx:1138
bool IsInInitShow() const
Definition: window2.cxx:1143
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2666
void Hide()
Definition: window.hxx:879
virtual Size GetSizePixel() const
Definition: window.cxx:2402
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsVisible() const
Definition: window2.cxx:1128
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1283
bool IsDefaultSize() const
Definition: window2.cxx:1179
bool IsEnabled() const
Definition: window2.cxx:1148
void SetHelpId(const OUString &)
Definition: window2.cxx:854
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
virtual WizardTypes::WizardState getStateFromPageIdent(const OUString &rIdent) const
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 OUString getPageIdentForState(WizardTypes::WizardState nState) 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:2718
#define DBG_ASSERT(sCon, aError)
#define ENSURE_OR_RETURN(c, m, r)
float u
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:32
VclPtr< Button > mpButton
Definition: wizimpldata.hxx:33
tools::Long mnOffset
Definition: wizimpldata.hxx:34
ImplWizPageData * mpNext
Definition: wizdlg.hxx:30
VclPtr< TabPage > mpPage
Definition: wizdlg.hxx:31
WizPageData * mpNext
Definition: wizimpldata.hxx:26
std::unique_ptr< BuilderPage > mxPage
Definition: wizimpldata.hxx:27
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:261
WizardButtonFlags
Definition: vclenum.hxx:250
@ RET_HELP
Definition: vclenum.hxx:212
@ RET_OK
Definition: vclenum.hxx:206
@ RET_CANCEL
Definition: vclenum.hxx:205
@ RET_NO
Definition: vclenum.hxx:208
@ RET_YES
Definition: vclenum.hxx:207
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
constexpr OUStringLiteral HID_WIZARD_PREVIOUS
#define WIZARDDIALOG_BUTTON_OFFSET_Y
constexpr OUStringLiteral HID_WIZARD_NEXT
#define WIZARDDIALOG_BUTTON_STDOFFSET_X
#define WZS_INVALID_STATE
#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X