1*01aa44aaSAndrew Rist /**************************************************************
2*01aa44aaSAndrew Rist  *
3*01aa44aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*01aa44aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*01aa44aaSAndrew Rist  * distributed with this work for additional information
6*01aa44aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*01aa44aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*01aa44aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*01aa44aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*01aa44aaSAndrew Rist  *
11*01aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*01aa44aaSAndrew Rist  *
13*01aa44aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*01aa44aaSAndrew Rist  * software distributed under the License is distributed on an
15*01aa44aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*01aa44aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*01aa44aaSAndrew Rist  * specific language governing permissions and limitations
18*01aa44aaSAndrew Rist  * under the License.
19*01aa44aaSAndrew Rist  *
20*01aa44aaSAndrew Rist  *************************************************************/
21*01aa44aaSAndrew Rist 
22*01aa44aaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SVT_UNO_WIZARD_SHELL
25cdf0e10cSrcweir #define SVT_UNO_WIZARD_SHELL
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /** === begin UNO includes === **/
28cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XWizardController.hpp>
29cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XWizard.hpp>
30cdf0e10cSrcweir /** === end UNO includes === **/
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <svtools/roadmapwizard.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
35cdf0e10cSrcweir #include <map>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //......................................................................................................................
38cdf0e10cSrcweir namespace svt { namespace uno
39cdf0e10cSrcweir {
40cdf0e10cSrcweir //......................................................................................................................
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     class WizardPageController;
43cdf0e10cSrcweir     typedef ::boost::shared_ptr< WizardPageController > PWizardPageController;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 	//==================================================================================================================
46cdf0e10cSrcweir 	//= WizardShell
47cdf0e10cSrcweir 	//==================================================================================================================
48cdf0e10cSrcweir     typedef ::svt::RoadmapWizard    WizardShell_Base;
49cdf0e10cSrcweir     class WizardShell : public WizardShell_Base
50cdf0e10cSrcweir 	{
51cdf0e10cSrcweir     public:
52cdf0e10cSrcweir         WizardShell(
53cdf0e10cSrcweir             Window* _pParent,
54cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard >& i_rWizard,
55cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController >& i_rController,
56cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int16 > >& i_rPaths
57cdf0e10cSrcweir         );
58cdf0e10cSrcweir         virtual ~WizardShell();
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         // Dialog overridables
61cdf0e10cSrcweir 	    virtual short	Execute();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir         // OWizardMachine overridables
64cdf0e10cSrcweir 		virtual TabPage*	createPage( WizardState i_nState );
65cdf0e10cSrcweir 	    virtual void        enterState( WizardState i_nState );
66cdf0e10cSrcweir 		virtual	sal_Bool	leaveState( WizardState i_nState );
67cdf0e10cSrcweir         virtual String      getStateDisplayName( WizardState i_nState ) const;
68cdf0e10cSrcweir         virtual bool        canAdvance() const;
69cdf0e10cSrcweir 		virtual sal_Bool    onFinish();
70cdf0e10cSrcweir 		virtual IWizardPageController*
71cdf0e10cSrcweir                             getPageController( TabPage* _pCurrentPage ) const;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         // attribute access
74cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard >&
75cdf0e10cSrcweir             getWizard() const { return m_xWizard; }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         static sal_Int16 convertCommitReasonToTravelType( const CommitPageReason i_eReason );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir         // operations
80cdf0e10cSrcweir         sal_Bool    advanceTo( const sal_Int16 i_nPageId )
81cdf0e10cSrcweir         {
82cdf0e10cSrcweir             return skipUntil( impl_pageIdToState( i_nPageId ) );
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir         sal_Bool    goBackTo( const sal_Int16 i_nPageId )
85cdf0e10cSrcweir         {
86cdf0e10cSrcweir             return skipBackwardUntil( impl_pageIdToState( i_nPageId ) );
87cdf0e10cSrcweir         }
88cdf0e10cSrcweir 		sal_Bool    travelNext()        { return WizardShell_Base::travelNext(); }
89cdf0e10cSrcweir 		sal_Bool    travelPrevious()    { return WizardShell_Base::travelPrevious(); }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         void        activatePath( const sal_Int16 i_nPathID, const sal_Bool i_bFinal )
92cdf0e10cSrcweir         {
93cdf0e10cSrcweir             WizardShell_Base::activatePath( PathId( i_nPathID ), i_bFinal );
94cdf0e10cSrcweir         }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardPage >
97cdf0e10cSrcweir                     getCurrentWizardPage() const;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         sal_Int16   getCurrentPage() const
100cdf0e10cSrcweir         {
101cdf0e10cSrcweir             return impl_stateToPageId( getCurrentState() );
102cdf0e10cSrcweir         }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         void        enablePage( const sal_Int16 i_PageID, const sal_Bool i_Enable );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         bool        knowsPage( const sal_Int16 i_nPageID ) const
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir             return knowsState( impl_pageIdToState( i_nPageID ) );
109cdf0e10cSrcweir         }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     private:
112cdf0e10cSrcweir         sal_Int16   impl_stateToPageId( const WizardTypes::WizardState i_nState ) const
113cdf0e10cSrcweir         {
114cdf0e10cSrcweir             return static_cast< sal_Int16 >( i_nState + m_nFirstPageID );
115cdf0e10cSrcweir         }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         WizardState impl_pageIdToState( const sal_Int16 i_nPageId ) const
118cdf0e10cSrcweir         {
119cdf0e10cSrcweir             return static_cast< WizardState >( i_nPageId - m_nFirstPageID );
120cdf0e10cSrcweir         }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         PWizardPageController impl_getController( TabPage* i_pPage ) const;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         // prevent outside access to some base class members
125cdf0e10cSrcweir         using WizardShell_Base::skip;
126cdf0e10cSrcweir         using WizardShell_Base::skipUntil;
127cdf0e10cSrcweir         using WizardShell_Base::skipBackwardUntil;
128cdf0e10cSrcweir         using WizardShell_Base::getCurrentState;
129cdf0e10cSrcweir         using WizardShell_Base::activatePath;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     private:
132cdf0e10cSrcweir         typedef ::std::map< TabPage*, PWizardPageController > Page2ControllerMap;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard >            m_xWizard;
135cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController >  m_xController;
136cdf0e10cSrcweir         const sal_Int16                                                                             m_nFirstPageID;
137cdf0e10cSrcweir         Page2ControllerMap                                                                          m_aPageControllers;
138cdf0e10cSrcweir 	};
139cdf0e10cSrcweir 
140cdf0e10cSrcweir //......................................................................................................................
141cdf0e10cSrcweir } } // namespace svt::uno
142cdf0e10cSrcweir //......................................................................................................................
143cdf0e10cSrcweir 
144cdf0e10cSrcweir #endif // SVT_UNO_WIZARD_SHELL
145