1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <com/sun/star/ui/dialogs/XWizardController.hpp>
23 #include <com/sun/star/ui/dialogs/XWizard.hpp>
24 #include <vcl/roadmapwizard.hxx>
28 using vcl::WizardTypes::WizardState
;
29 using vcl::WizardTypes::CommitPageReason
;
35 class WizardPageController
;
36 typedef std::shared_ptr
< WizardPageController
> PWizardPageController
;
41 typedef ::vcl::RoadmapWizardMachine WizardShell_Base
;
42 class WizardShell
: public WizardShell_Base
46 weld::Window
* pParent
,
47 const css::uno::Reference
< css::ui::dialogs::XWizardController
>& i_rController
,
48 const css::uno::Sequence
< css::uno::Sequence
< sal_Int16
> >& i_rPaths
51 // Dialog overridables
52 virtual short run() override
;
54 // OWizardMachine overridables
55 virtual std::unique_ptr
<BuilderPage
> createPage( WizardState i_nState
) override
;
56 virtual void enterState( WizardState i_nState
) override
;
57 virtual bool leaveState( WizardState i_nState
) override
;
58 virtual OUString
getStateDisplayName( WizardState i_nState
) const override
;
59 virtual bool canAdvance() const override
;
60 virtual bool onFinish() override
;
61 virtual vcl::IWizardPageController
* getPageController(BuilderPage
* pCurrentPage
) const override
;
63 static sal_Int16
convertCommitReasonToTravelType( const CommitPageReason i_eReason
);
66 bool advanceTo( const sal_Int16 i_nPageId
)
68 return skipUntil( impl_pageIdToState( i_nPageId
) );
70 bool goBackTo( const sal_Int16 i_nPageId
)
72 return skipBackwardUntil( impl_pageIdToState( i_nPageId
) );
74 using WizardShell_Base::travelNext
;
75 using WizardShell_Base::travelPrevious
;
77 void activatePath( const sal_Int16 i_nPathID
, const bool i_bFinal
)
79 WizardShell_Base::activatePath( vcl::RoadmapWizardTypes::PathId( i_nPathID
), i_bFinal
);
82 css::uno::Reference
< css::ui::dialogs::XWizardPage
>
83 getCurrentWizardPage() const;
85 sal_Int16
getCurrentPage() const
87 return impl_stateToPageId( getCurrentState() );
90 void enablePage( const sal_Int16 i_PageID
, const bool i_Enable
);
92 bool knowsPage( const sal_Int16 i_nPageID
) const
94 return knowsState( impl_pageIdToState( i_nPageID
) );
98 sal_Int16
impl_stateToPageId( const WizardState i_nState
) const
100 return static_cast< sal_Int16
>( i_nState
+ m_nFirstPageID
);
103 WizardState
impl_pageIdToState( const sal_Int16 i_nPageId
) const
105 return static_cast<WizardState
>(i_nPageId
- m_nFirstPageID
);
108 PWizardPageController
impl_getController(BuilderPage
* i_pPage
) const;
110 // prevent outside access to some base class members
111 using WizardShell_Base::skip
;
112 using WizardShell_Base::skipUntil
;
113 using WizardShell_Base::skipBackwardUntil
;
114 using WizardShell_Base::getCurrentState
;
115 using WizardShell_Base::activatePath
;
118 typedef std::map
<BuilderPage
*, PWizardPageController
> Page2ControllerMap
;
120 const css::uno::Reference
< css::ui::dialogs::XWizardController
> m_xController
;
121 const sal_Int16 m_nFirstPageID
;
122 Page2ControllerMap m_aPageControllers
;
126 } // namespace svt::uno
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */