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::XWizardController >& i_rController,
55cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int16 > >& i_rPaths
56cdf0e10cSrcweir         );
57cdf0e10cSrcweir         virtual ~WizardShell();
58cdf0e10cSrcweir 
59cdf0e10cSrcweir         // Dialog overridables
60cdf0e10cSrcweir 	    virtual short	Execute();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         // OWizardMachine overridables
63cdf0e10cSrcweir 		virtual TabPage*	createPage( WizardState i_nState );
64cdf0e10cSrcweir 	    virtual void        enterState( WizardState i_nState );
65cdf0e10cSrcweir 		virtual	sal_Bool	leaveState( WizardState i_nState );
66cdf0e10cSrcweir         virtual String      getStateDisplayName( WizardState i_nState ) const;
67cdf0e10cSrcweir         virtual bool        canAdvance() const;
68cdf0e10cSrcweir 		virtual sal_Bool    onFinish();
69cdf0e10cSrcweir 		virtual IWizardPageController*
70cdf0e10cSrcweir                             getPageController( TabPage* _pCurrentPage ) const;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         static sal_Int16 convertCommitReasonToTravelType( const CommitPageReason i_eReason );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         // operations
advanceTo(const sal_Int16 i_nPageId)75cdf0e10cSrcweir         sal_Bool    advanceTo( const sal_Int16 i_nPageId )
76cdf0e10cSrcweir         {
77cdf0e10cSrcweir             return skipUntil( impl_pageIdToState( i_nPageId ) );
78cdf0e10cSrcweir         }
goBackTo(const sal_Int16 i_nPageId)79cdf0e10cSrcweir         sal_Bool    goBackTo( const sal_Int16 i_nPageId )
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             return skipBackwardUntil( impl_pageIdToState( i_nPageId ) );
82cdf0e10cSrcweir         }
travelNext()83cdf0e10cSrcweir 		sal_Bool    travelNext()        { return WizardShell_Base::travelNext(); }
travelPrevious()84cdf0e10cSrcweir 		sal_Bool    travelPrevious()    { return WizardShell_Base::travelPrevious(); }
85cdf0e10cSrcweir 
activatePath(const sal_Int16 i_nPathID,const sal_Bool i_bFinal)86cdf0e10cSrcweir         void        activatePath( const sal_Int16 i_nPathID, const sal_Bool i_bFinal )
87cdf0e10cSrcweir         {
88cdf0e10cSrcweir             WizardShell_Base::activatePath( PathId( i_nPathID ), i_bFinal );
89cdf0e10cSrcweir         }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardPage >
92cdf0e10cSrcweir                     getCurrentWizardPage() const;
93cdf0e10cSrcweir 
getCurrentPage() const94cdf0e10cSrcweir         sal_Int16   getCurrentPage() const
95cdf0e10cSrcweir         {
96cdf0e10cSrcweir             return impl_stateToPageId( getCurrentState() );
97cdf0e10cSrcweir         }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         void        enablePage( const sal_Int16 i_PageID, const sal_Bool i_Enable );
100cdf0e10cSrcweir 
knowsPage(const sal_Int16 i_nPageID) const101cdf0e10cSrcweir         bool        knowsPage( const sal_Int16 i_nPageID ) const
102cdf0e10cSrcweir         {
103cdf0e10cSrcweir             return knowsState( impl_pageIdToState( i_nPageID ) );
104cdf0e10cSrcweir         }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     private:
impl_stateToPageId(const WizardTypes::WizardState i_nState) const107cdf0e10cSrcweir         sal_Int16   impl_stateToPageId( const WizardTypes::WizardState i_nState ) const
108cdf0e10cSrcweir         {
109cdf0e10cSrcweir             return static_cast< sal_Int16 >( i_nState + m_nFirstPageID );
110cdf0e10cSrcweir         }
111cdf0e10cSrcweir 
impl_pageIdToState(const sal_Int16 i_nPageId) const112cdf0e10cSrcweir         WizardState impl_pageIdToState( const sal_Int16 i_nPageId ) const
113cdf0e10cSrcweir         {
114cdf0e10cSrcweir             return static_cast< WizardState >( i_nPageId - m_nFirstPageID );
115cdf0e10cSrcweir         }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         PWizardPageController impl_getController( TabPage* i_pPage ) const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         // prevent outside access to some base class members
120cdf0e10cSrcweir         using WizardShell_Base::skip;
121cdf0e10cSrcweir         using WizardShell_Base::skipUntil;
122cdf0e10cSrcweir         using WizardShell_Base::skipBackwardUntil;
123cdf0e10cSrcweir         using WizardShell_Base::getCurrentState;
124cdf0e10cSrcweir         using WizardShell_Base::activatePath;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     private:
127cdf0e10cSrcweir         typedef ::std::map< TabPage*, PWizardPageController > Page2ControllerMap;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController >  m_xController;
130cdf0e10cSrcweir         const sal_Int16                                                                             m_nFirstPageID;
131cdf0e10cSrcweir         Page2ControllerMap                                                                          m_aPageControllers;
132cdf0e10cSrcweir 	};
133cdf0e10cSrcweir 
134cdf0e10cSrcweir //......................................................................................................................
135cdf0e10cSrcweir } } // namespace svt::uno
136cdf0e10cSrcweir //......................................................................................................................
137cdf0e10cSrcweir 
138cdf0e10cSrcweir #endif // SVT_UNO_WIZARD_SHELL
139