21 #include <officecfg/Office/Common.hxx>
25 #include <strings.hrc>
31 #define HID_WIZARD_NEXT "SVT_HID_WIZARD_NEXT"
32 #define HID_WIZARD_PREVIOUS "SVT_HID_WIZARD_PREVIOUS"
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
43 :
BuilderPage(pPage, pController, rUIXMLDescription, rID)
95 nBarWidth += nBtnWidth;
98 if ( nBtnHeight > nMaxHeight )
99 nMaxHeight = nBtnHeight;
100 pBtnData = pBtnData->
mpNext;
114 if (nBarWidth > rSize.
Width())
148 if ( nBtnHeight > nMaxHeight )
149 nMaxHeight = nBtnHeight;
150 nBtnWidth += aBtnSize.
Width();
153 pBtnData = pBtnData->
mpNext;
170 Point aPos( nOffX, nOffY+((nMaxHeight-aBtnSize.
Height())/2) );
172 nOffX += aBtnSize.
Width();
177 Point aPos( nOffLeftAlignX, nOffY+((nMaxHeight-aBtnSize.
Height())/2) );
179 nOffLeftAlignX += aBtnSize.
Width();
180 nOffLeftAlignX += pBtnData->
mnOffset;
183 pBtnData = pBtnData->
mpNext;
205 nViewHeight = nDlgHeight;
216 nViewWidth, nViewHeight,
222 int iPixelCoordinate = aLocSize.
Width();
223 return iPixelCoordinate;
245 if ( nBtnHeight > nMaxHeight )
246 nMaxHeight = nBtnHeight;
247 pBtnData = pBtnData->
mpNext;
262 nOffX += aViewSize.
Width() + nViewOffset;
265 Point aPos( nOffX, nOffY );
289 sal_uInt16 nTempLevel = 0;
293 if ( (nTempLevel == nLevel) || !pPageData->
mpNext )
297 pPageData = pPageData->
mpNext;
393 if ( pCurrentPage && !pCurrentPage->
GetText().isEmpty() )
395 sCompleteTitle +=
" - " + pCurrentPage->
GetText();
418 pPageData = pPageData->
mpNext;
449 sal_uInt16 nKeyCode = aKeyCode.
GetCode();
489 if (
nullptr ==
GetPage( i_nState ) )
492 DBG_ASSERT( pNewPage,
"RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" );
542 pNewPageData->
mpNext =
nullptr;
543 pNewPageData->
mpPage = pPage;
550 while ( pPageData->
mpNext )
551 pPageData = pPageData->
mpNext;
552 pPageData->
mpNext = pNewPageData;
562 if ( pPageData->
mpPage == pPage )
574 pPrevPageData = pPageData;
575 pPageData = pPageData->
mpNext;
578 OSL_FAIL(
"RoadmapWizard::RemovePage() - Page not in list" );
583 sal_uInt16 nTempLevel = 0;
587 if ( (nTempLevel == nLevel) || !pPageData->
mpNext )
591 pPageData = pPageData->
mpNext;
598 pPageData->
mpPage = pPage;
604 sal_uInt16 nTempLevel = 0;
607 pPageData = pPageData->
mpNext)
609 if ( nTempLevel == nLevel )
610 return pPageData->mpPage;
620 pNewBtnData->
mpNext =
nullptr;
629 while ( pBtnData->
mpNext )
630 pBtnData = pBtnData->
mpNext;
631 pBtnData->
mpNext = pNewBtnData;
641 if ( pBtnData->
mpButton == pButton )
651 pPrevBtnData = pBtnData;
652 pBtnData = pBtnData->
mpNext;
655 OSL_FAIL(
"RoadmapWizard::RemoveButton() - Button not in list" );
674 if ( isTravelingSuspended() )
687 ENSURE_OR_RETURN( pController !=
nullptr,
"RoadmapWizard::prepareLeaveCurrentState: no controller for the current page!",
true );
698 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_xWizardImpl->aStateHistory;
699 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_xWizardImpl->aStateHistory;
702 while ( nCurrentRollbackState != _nTargetState )
704 DBG_ASSERT( !aTravelVirtually.empty(),
"RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" );
705 nCurrentRollbackState = aTravelVirtually.top();
706 aTravelVirtually.pop();
726 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_xWizardImpl->aStateHistory;
727 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_xWizardImpl->aStateHistory;
728 while ( nCurrentState != _nTargetState )
733 OSL_FAIL(
"RoadmapWizard::skipUntil: the given target state does not exist!" );
738 aTravelVirtually.push( nCurrentState );
741 nCurrentState = nNextState;
749 OSL_FAIL(
"RoadmapWizard::skipUntil: very unpolite..." );
807 std::stack< WizardTypes::WizardState > aTemp;
812 if(nPreviousState != nToRemove)
813 aTemp.push( nPreviousState );
817 while(!aTemp.empty())
831 if ( isTravelingSuspended() )
839 if ( isTravelingSuspended() )
869 : AssistantController(pParent,
"vcl/ui/wizard.ui",
"Wizard")
870 , m_pCurTabPage(nullptr)
872 , m_pFirstPage(nullptr)
873 , m_xFinish(m_xAssistant->weld_widget_for_response(
RET_OK))
874 , m_xCancel(m_xAssistant->weld_widget_for_response(
RET_CANCEL))
875 , m_xNextPage(m_xAssistant->weld_widget_for_response(
RET_YES))
876 , m_xPrevPage(m_xAssistant->weld_widget_for_response(
RET_NO))
877 , m_xHelp(m_xAssistant->weld_widget_for_response(
RET_HELP))
888 officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
950 OUString sCompleteTitle(
m_pImpl->sTitleBase);
954 if ( pCurrentPage && !pCurrentPage->
GetPageTitle().isEmpty() )
964 m_pImpl->sTitleBase = _rTitleBase;
970 if (
nullptr ==
GetPage( i_nState ) )
972 std::unique_ptr<BuilderPage> xNewPage =
createPage( i_nState );
973 DBG_ASSERT( xNewPage,
"WizardMachine::GetOrCreatePage: invalid new page (NULL)!" );
976 while (
m_pImpl->nFirstUnknownPage < i_nState )
982 if (
m_pImpl->nFirstUnknownPage == i_nState )
990 SetPage(i_nState, std::move(xNewPage));
1020 pNewDefButton =
m_xHelp.get();
1024 if ( pNewDefButton )
1050 m_xHelp->set_sensitive(_bEnable);
1059 OSL_ENSURE( pController,
"WizardMachine::enterState: no controller for the given page!" );
1088 if ( isTravelingSuspended() )
1111 return _nCurrentState + 1;
1117 ENSURE_OR_RETURN( pController !=
nullptr,
"WizardMachine::prepareLeaveCurrentState: no controller for the current page!",
true );
1128 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_pImpl->aStateHistory;
1129 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_pImpl->aStateHistory;
1132 while ( nCurrentRollbackState != _nTargetState )
1134 DBG_ASSERT( !aTravelVirtually.empty(),
"WizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
1135 nCurrentRollbackState = aTravelVirtually.top();
1136 aTravelVirtually.pop();
1138 m_pImpl->aStateHistory = aTravelVirtually;
1141 m_pImpl->aStateHistory = aOldStateHistory;
1156 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_pImpl->aStateHistory;
1157 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_pImpl->aStateHistory;
1158 while ( nCurrentState != _nTargetState )
1163 OSL_FAIL(
"WizardMachine::skipUntil: the given target state does not exist!" );
1168 aTravelVirtually.push( nCurrentState );
1171 nCurrentState = nNextState;
1173 m_pImpl->aStateHistory = aTravelVirtually;
1179 OSL_FAIL(
"WizardMachine::skipUntil: very unpolite..." );
1180 m_pImpl->aStateHistory = aOldStateHistory;
1199 m_pImpl->aStateHistory.push(nCurrentState);
1202 nCurrentState = nNextState;
1209 OSL_FAIL(
"RoadmapWizard::skip: very unpolite...");
1233 m_pImpl->aStateHistory.push(nCurrentState);
1255 m_xAssistant->set_current_page(OString::number(nState));
1279 DBG_ASSERT(!
m_pImpl->aStateHistory.empty(),
"WizardMachine::travelPrevious: have no previous page!");
1293 m_pImpl->aStateHistory.push(nPreviousState);
1305 std::stack< WizardTypes::WizardState > aTemp;
1306 while(!
m_pImpl->aStateHistory.empty())
1310 if(nPreviousState != nToRemove)
1311 aTemp.push( nPreviousState );
1315 while(!aTemp.empty())
1317 m_pImpl->aStateHistory.push( aTemp.top() );
1325 m_pImpl->m_bAutoNextButtonState =
true;
1331 return m_pImpl->m_bAutoNextButtonState;
1336 if ( isTravelingSuspended() )
1344 if ( isTravelingSuspended() )
1358 std::stack< WizardTypes::WizardState > aHistoryCopy(
m_pImpl->aStateHistory );
1359 while ( !aHistoryCopy.empty() )
1361 _out_rHistory.push_back( aHistoryCopy.top() );
1374 OSL_ENSURE( pController !=
nullptr,
"RoadmapWizard::updateTravelUI: no controller for the current page!" );
1377 ( !pController || pController->
canAdvance() )
1384 return m_pImpl->m_bTravelingSuspended;
1389 DBG_ASSERT( !
m_pImpl->m_bTravelingSuspended,
"WizardMachine::suspendTraveling: already suspended!" );
1390 m_pImpl->m_bTravelingSuspended =
true;
1398 DBG_ASSERT(
m_pImpl->m_bTravelingSuspended,
"WizardMachine::resumeTraveling: nothing to resume!" );
1399 m_pImpl->m_bTravelingSuspended =
false;
1419 pNewPageData->
mpNext =
nullptr;
1420 pNewPageData->
mxPage = std::move(xPage);
1427 while ( pPageData->
mpNext )
1428 pPageData = pPageData->
mpNext;
1429 pPageData->
mpNext = pNewPageData;
1439 if (pPageData->
mxPage.get() == pPage)
1451 pPrevPageData = pPageData;
1452 pPageData = pPageData->
mpNext;
1455 OSL_FAIL(
"WizardMachine::RemovePage() - Page not in list" );
1460 sal_uInt16 nTempLevel = 0;
1464 if ( (nTempLevel == nLevel) || !pPageData->
mpNext )
1468 pPageData = pPageData->
mpNext;
1475 pPageData->
mxPage = std::move(xPage);
1481 sal_uInt16 nTempLevel = 0;
1484 pPageData = pPageData->
mpNext)
1486 if ( nTempLevel == nLevel )
1487 return pPageData->mxPage.get();
#define LINK(Instance, Class, Member)
std::unique_ptr< weld::Button > m_xPrevPage
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
bool IsInputEnabled() const
bool isTravelingSuspended() const
virtual bool canAdvance() const override
determines whether or not it is allowed to advance to a next page
void resumeTraveling(AccessGuard)
virtual bool leaveState(WizardTypes::WizardState nState)
will be called when the given state is left
virtual bool EventNotify(NotifyEvent &rNEvt) override
virtual bool Close() override
void setWidth(tools::Long nWidth)
VclPtr< vcl::Window > mpViewWindow
virtual void initializePage()=0
void EndDialog(tools::Long nResult=RET_CANCEL)
void suspendTraveling(AccessGuard)
virtual void ActivatePage()
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
std::unique_ptr< WizardMachineImplData > m_xWizardImpl
virtual void updateTravelUI() override
updates the user interface which deals with traveling in the wizard
#define WIZARDDIALOG_VIEW_DLGOFFSET_X
std::unique_ptr< WizardMachineImplData > m_pImpl
void ImplCalcSize(Size &rSize)
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
sal_Int16 mnLeftAlignCount
void enableAutomaticNextButtonState()
enables the automatic enabled/disabled state of the "Next" button
ImplWizPageData * mpFirstPage
sal_uInt16 GetCode() const
is - no, not a wizard for a roadmap, but the base class for wizards supporting a roadmap.
#define WIZARDDIALOG_BUTTON_OFFSET_Y
virtual bool canAdvance() const
determines whether there is a next state to which we can advance
const KeyEvent * GetKeyEvent() const
virtual ~WizardMachine() override
virtual IWizardPageController * getPageController(BuilderPage *pCurrentPage) const
void SetHelpId(const OString &)
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
TabPage * GetOrCreatePage(const WizardTypes::WizardState i_nState)
std::unique_ptr< weld::Button > m_xHelp
void defaultButton(WizardButtonFlags _nWizardButtonFlags)
set the default style for a button
void Enable(bool bEnable=true, bool bChild=true)
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
void SetPage(WizardTypes::WizardState nLevel, std::unique_ptr< BuilderPage > xPage)
const OUString & GetPageTitle() const
bool IsDefaultSize() const
constexpr sal_uInt16 KEY_PAGEUP
virtual void Start() override
Activates the timer task.
virtual void SetOutputSizePixel(const Size &rNewSize)
#define WZS_INVALID_STATE
virtual OUString GetText() const
tools::Long LogicalCoordinateToPixel(int iCoordinate)
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
VCL_DLLPRIVATE void implConstruct(const WizardButtonFlags _nButtonFlags)
virtual void Deactivate()
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
void SetLeftAlignedButtonCount(sal_Int16 _nCount)
sets the number of buttons which should be left-aligned.
std::unique_ptr< weld::Button > m_xCancel
VclPtr< TabPage > mpCurTabPage
void RemoveButton(Button *pButton)
VclPtr< TabPage > createPage(WizardTypes::WizardState nState)
to override to create new pages
void updateDialogTravelUI()
updates the travel-related UI elements of the OWizardMachine we live in (if any)
sal_uInt16 GetCurLevel() const
ImplWizButtonData * mpFirstBtn
void SetMinOutputSizePixel(const Size &rSize)
WizPageData * m_pFirstPage
std::unique_ptr< weld::Button > m_xNextPage
virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
bool isAutomaticNextButtonStateEnabled() const
virtual void Activate() override
virtual bool prepareLeaveCurrentState(WizardTypes::CommitPageReason eReason)
will be called when the current state is about to be left for the given reason
TabPage * GetPage(sal_uInt16 nLevel) const
#define DBG_ASSERT(sCon, aError)
VclPtr< PushButton > m_pNextPage
weld::DialogController * m_pDialogController
virtual bool canAdvance() const =0
determines whether or not it is allowed to advance to a next page
OWizardPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID)
virtual void SetText(const OUString &rStr) override
#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X
bool Finish(tools::Long nResult=0)
WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
virtual bool commitPage(WizardTypes::CommitPageReason _eReason)=0
virtual bool DeactivatePage()
tools::Long Width() const
#define ENSURE_OR_RETURN(c, m, r)
virtual bool EventNotify(NotifyEvent &rNEvt) override
bool IsInInitShow() const
constexpr sal_uInt16 KEY_PAGEDOWN
const Size & GetPageSizePixel() const
MouseNotifyEvent GetType() const
void AddButton(Button *pButton, tools::Long nOffset=0)
VclPtr< PushButton > mpNextBtn
virtual ~OWizardPage() override
virtual void Resize() override
Size GetOutputSizePixel() const
bool isTravelingSuspended() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
virtual void StateChanged(StateChangedType nStateChange) override
void RemovePage(const BuilderPage *pPage)
implements some kind of finite automata, where the states of the automata exactly correlate with tab ...
bool IsReallyShown() const
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
virtual bool onFinish()
called when the finish button is pressed
void AddPage(std::unique_ptr< BuilderPage > xPage)
void suspendTraveling(AccessGuard)
bool travelNext()
travel to the next state
Point LogicToPixel(const Point &rLogicPt) const
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
#define WIZARDDIALOG_VIEW_DLGOFFSET_Y
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
void set_id(const OUString &rID)
Sets an ID.
helper class to temporarily suspend any traveling in the wizard
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual void Resize() override
const vcl::KeyCode & GetKeyCode() const
VclPtr< PushButton > mpPrevBtn
virtual void StateChanged(StateChangedType nStateChange) override
std::unique_ptr< weld::Button > m_xFinish
WizardMachine(weld::Window *_pParent, WizardButtonFlags _nButtonFlags)
bool travelNext()
travel to the next state
void RemovePage(TabPage *pPage)
void implConstruct(const WizardButtonFlags _nButtonFlags)
void getStateHistory(std::vector< WizardTypes::WizardState > &out_rHistory)
retrieves a copy of the state history, i.e.
virtual OUString GetText() const override
#define WIZARDDIALOG_BUTTON_STDOFFSET_X
bool travelPrevious()
travel to the previous state
bool Finish(short nResult=RET_CANCEL)
void setTitleBase(const OUString &_rTitleBase)
set the base of the title to use - the title of the current page is appended
virtual void SetText(const OUString &rStr) override
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
VclPtr< CancelButton > m_pCancel
tools::Long Height() const
bool travelPrevious()
travel to the previous state
VCL_DLLPRIVATE void implUpdateTitle()
void resumeTraveling(AccessGuard)
void ImplShowTabPage(TabPage *pPage)
std::unique_ptr< BuilderPage > mxPage
void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
void AddPage(TabPage *pPage)
tools::Long AdjustHeight(tools::Long n)
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
bool ShowPage(sal_uInt16 nLevel)
void setHeight(tools::Long nHeight)
BuilderPage * m_pCurTabPage
#define HID_WIZARD_PREVIOUS
BuilderPage * GetPage(WizardTypes::WizardState eState) const
#define WIZARDDIALOG_BUTTON_DLGOFFSET_X
OUString VclResId(const char *pId)
WinBits const WB_CLOSEABLE
virtual std::unique_ptr< BuilderPage > createPage(WizardTypes::WizardState _nState)=0
to override to create new pages
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
virtual void updateTravelUI()
updates the user interface which deals with traveling in the wizard
VclPtr< PushButton > m_pPrevPage
bool IsReallyVisible() const
SAL_DLLPRIVATE bool IsInClose() const
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
BuilderPage * GetOrCreatePage(const WizardTypes::WizardState i_nState)
TabPage * ImplGetPage(sal_uInt16 nLevel) const
virtual void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
std::unique_ptr< weld::Assistant > m_xAssistant
bool ShowPage(WizardTypes::WizardState nState)
static IWizardPageController * getPageController(TabPage *_pCurrentPage)
VclPtr< OKButton > m_pFinish
virtual void SetPosPixel(const Point &rNewPos)
WizardTypes::WizardState m_nCurState
VclPtr< HelpButton > m_pHelp
bool isAutomaticNextButtonStateEnabled() const
enables the automatic enabled/disabled state of the "Next" button
constexpr sal_uInt16 KEY_TAB
helper class to temporarily suspend any traveling in the wizard
void SetPage(sal_uInt16 nLevel, TabPage *pPage)
bool prepareLeaveCurrentState(WizardTypes::CommitPageReason eReason)
will be called when the current state is about to be left for the given reason
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
virtual void initializePage() override