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 .
20 #ifndef SVT_UNO_WIZARD_SHELL
21 #define SVT_UNO_WIZARD_SHELL
23 #include <com/sun/star/ui/dialogs/XWizardController.hpp>
24 #include <com/sun/star/ui/dialogs/XWizard.hpp>
26 #include <svtools/roadmapwizard.hxx>
28 #include <boost/shared_ptr.hpp>
31 //......................................................................................................................
32 namespace svt
{ namespace uno
34 //......................................................................................................................
36 class WizardPageController
;
37 typedef ::boost::shared_ptr
< WizardPageController
> PWizardPageController
;
39 //==================================================================================================================
41 //==================================================================================================================
42 typedef ::svt::RoadmapWizard WizardShell_Base
;
43 class WizardShell
: public WizardShell_Base
48 const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XWizard
>& i_rWizard
,
49 const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XWizardController
>& i_rController
,
50 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< sal_Int16
> >& i_rPaths
52 virtual ~WizardShell();
54 // Dialog overridables
55 virtual short Execute();
57 // OWizardMachine overridables
58 virtual TabPage
* createPage( WizardState i_nState
);
59 virtual void enterState( WizardState i_nState
);
60 virtual sal_Bool
leaveState( WizardState i_nState
);
61 virtual OUString
getStateDisplayName( WizardState i_nState
) const;
62 virtual bool canAdvance() const;
63 virtual sal_Bool
onFinish();
64 virtual IWizardPageController
*
65 getPageController( TabPage
* _pCurrentPage
) const;
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XWizard
>&
69 getWizard() const { return m_xWizard
; }
71 static sal_Int16
convertCommitReasonToTravelType( const CommitPageReason i_eReason
);
74 sal_Bool
advanceTo( const sal_Int16 i_nPageId
)
76 return skipUntil( impl_pageIdToState( i_nPageId
) );
78 sal_Bool
goBackTo( const sal_Int16 i_nPageId
)
80 return skipBackwardUntil( impl_pageIdToState( i_nPageId
) );
82 sal_Bool
travelNext() { return WizardShell_Base::travelNext(); }
83 sal_Bool
travelPrevious() { return WizardShell_Base::travelPrevious(); }
85 void activatePath( const sal_Int16 i_nPathID
, const sal_Bool i_bFinal
)
87 WizardShell_Base::activatePath( PathId( i_nPathID
), i_bFinal
);
90 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XWizardPage
>
91 getCurrentWizardPage() const;
93 sal_Int16
getCurrentPage() const
95 return impl_stateToPageId( getCurrentState() );
98 void enablePage( const sal_Int16 i_PageID
, const sal_Bool i_Enable
);
100 bool knowsPage( const sal_Int16 i_nPageID
) const
102 return knowsState( impl_pageIdToState( i_nPageID
) );
106 sal_Int16
impl_stateToPageId( const WizardTypes::WizardState i_nState
) const
108 return static_cast< sal_Int16
>( i_nState
+ m_nFirstPageID
);
111 WizardState
impl_pageIdToState( const sal_Int16 i_nPageId
) const
113 return static_cast< WizardState
>( i_nPageId
- m_nFirstPageID
);
116 PWizardPageController
impl_getController( TabPage
* i_pPage
) const;
118 // prevent outside access to some base class members
119 using WizardShell_Base::skip
;
120 using WizardShell_Base::skipUntil
;
121 using WizardShell_Base::skipBackwardUntil
;
122 using WizardShell_Base::getCurrentState
;
123 using WizardShell_Base::activatePath
;
126 typedef ::std::map
< TabPage
*, PWizardPageController
> Page2ControllerMap
;
128 const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XWizard
> m_xWizard
;
129 const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XWizardController
> m_xController
;
130 const sal_Int16 m_nFirstPageID
;
131 Page2ControllerMap m_aPageControllers
;
134 //......................................................................................................................
135 } } // namespace svt::uno
136 //......................................................................................................................
138 #endif // SVT_UNO_WIZARD_SHELL
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */