Line data Source code
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 : #ifndef SVT_UNO_WIZARD_SHELL
21 : #define SVT_UNO_WIZARD_SHELL
22 :
23 : #include <com/sun/star/ui/dialogs/XWizardController.hpp>
24 : #include <com/sun/star/ui/dialogs/XWizard.hpp>
25 :
26 : #include <svtools/roadmapwizard.hxx>
27 :
28 : #include <boost/shared_ptr.hpp>
29 : #include <map>
30 :
31 :
32 : namespace svt { namespace uno
33 : {
34 :
35 :
36 : class WizardPageController;
37 : typedef ::boost::shared_ptr< WizardPageController > PWizardPageController;
38 :
39 :
40 : //= WizardShell
41 :
42 : typedef ::svt::RoadmapWizard WizardShell_Base;
43 : class WizardShell : public WizardShell_Base
44 : {
45 : public:
46 : WizardShell(
47 : Window* _pParent,
48 : const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController >& i_rController,
49 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int16 > >& i_rPaths
50 : );
51 : virtual ~WizardShell();
52 :
53 : // Dialog overridables
54 : virtual short Execute() SAL_OVERRIDE;
55 :
56 : // OWizardMachine overridables
57 : virtual TabPage* createPage( WizardState i_nState ) SAL_OVERRIDE;
58 : virtual void enterState( WizardState i_nState ) SAL_OVERRIDE;
59 : virtual bool leaveState( WizardState i_nState ) SAL_OVERRIDE;
60 : virtual OUString getStateDisplayName( WizardState i_nState ) const SAL_OVERRIDE;
61 : virtual bool canAdvance() const SAL_OVERRIDE;
62 : virtual bool onFinish() SAL_OVERRIDE;
63 : virtual IWizardPageController*
64 : getPageController( TabPage* _pCurrentPage ) const SAL_OVERRIDE;
65 :
66 : static sal_Int16 convertCommitReasonToTravelType( const CommitPageReason i_eReason );
67 :
68 : // operations
69 0 : sal_Bool advanceTo( const sal_Int16 i_nPageId )
70 : {
71 0 : return skipUntil( impl_pageIdToState( i_nPageId ) );
72 : }
73 0 : sal_Bool goBackTo( const sal_Int16 i_nPageId )
74 : {
75 0 : return skipBackwardUntil( impl_pageIdToState( i_nPageId ) );
76 : }
77 0 : sal_Bool travelNext() { return WizardShell_Base::travelNext(); }
78 0 : sal_Bool travelPrevious() { return WizardShell_Base::travelPrevious(); }
79 :
80 0 : void activatePath( const sal_Int16 i_nPathID, const sal_Bool i_bFinal )
81 : {
82 0 : WizardShell_Base::activatePath( PathId( i_nPathID ), i_bFinal );
83 0 : }
84 :
85 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardPage >
86 : getCurrentWizardPage() const;
87 :
88 0 : sal_Int16 getCurrentPage() const
89 : {
90 0 : return impl_stateToPageId( getCurrentState() );
91 : }
92 :
93 : void enablePage( const sal_Int16 i_PageID, const sal_Bool i_Enable );
94 :
95 0 : bool knowsPage( const sal_Int16 i_nPageID ) const
96 : {
97 0 : return knowsState( impl_pageIdToState( i_nPageID ) );
98 : }
99 :
100 : private:
101 0 : sal_Int16 impl_stateToPageId( const WizardTypes::WizardState i_nState ) const
102 : {
103 0 : return static_cast< sal_Int16 >( i_nState + m_nFirstPageID );
104 : }
105 :
106 0 : WizardState impl_pageIdToState( const sal_Int16 i_nPageId ) const
107 : {
108 0 : return static_cast< WizardState >( i_nPageId - m_nFirstPageID );
109 : }
110 :
111 : PWizardPageController impl_getController( TabPage* i_pPage ) const;
112 :
113 : // prevent outside access to some base class members
114 : using WizardShell_Base::skip;
115 : using WizardShell_Base::skipUntil;
116 : using WizardShell_Base::skipBackwardUntil;
117 : using WizardShell_Base::getCurrentState;
118 : using WizardShell_Base::activatePath;
119 :
120 : private:
121 : typedef ::std::map< TabPage*, PWizardPageController > Page2ControllerMap;
122 :
123 : const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController > m_xController;
124 : const sal_Int16 m_nFirstPageID;
125 : Page2ControllerMap m_aPageControllers;
126 : };
127 :
128 :
129 : } } // namespace svt::uno
130 :
131 :
132 : #endif // SVT_UNO_WIZARD_SHELL
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|