1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2000, 2010 Oracle and/or its affiliates. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 * 25 ************************************************************************/ 26 27 #ifndef SVT_UNO_WIZARD_SHELL 28 #define SVT_UNO_WIZARD_SHELL 29 30 /** === begin UNO includes === **/ 31 #include <com/sun/star/ui/dialogs/XWizardController.hpp> 32 #include <com/sun/star/ui/dialogs/XWizard.hpp> 33 /** === end UNO includes === **/ 34 35 #include <svtools/roadmapwizard.hxx> 36 37 #include <boost/shared_ptr.hpp> 38 #include <map> 39 40 //...................................................................................................................... 41 namespace svt { namespace uno 42 { 43 //...................................................................................................................... 44 45 class WizardPageController; 46 typedef ::boost::shared_ptr< WizardPageController > PWizardPageController; 47 48 //================================================================================================================== 49 //= WizardShell 50 //================================================================================================================== 51 typedef ::svt::RoadmapWizard WizardShell_Base; 52 class WizardShell : public WizardShell_Base 53 { 54 public: 55 WizardShell( 56 Window* _pParent, 57 const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard >& i_rWizard, 58 const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController >& i_rController, 59 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int16 > >& i_rPaths 60 ); 61 virtual ~WizardShell(); 62 63 // Dialog overridables 64 virtual short Execute(); 65 66 // OWizardMachine overridables 67 virtual TabPage* createPage( WizardState i_nState ); 68 virtual void enterState( WizardState i_nState ); 69 virtual sal_Bool leaveState( WizardState i_nState ); 70 virtual String getStateDisplayName( WizardState i_nState ) const; 71 virtual bool canAdvance() const; 72 virtual sal_Bool onFinish(); 73 virtual IWizardPageController* 74 getPageController( TabPage* _pCurrentPage ) const; 75 76 // attribute access 77 const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard >& 78 getWizard() const { return m_xWizard; } 79 80 static sal_Int16 convertCommitReasonToTravelType( const CommitPageReason i_eReason ); 81 82 // operations 83 sal_Bool advanceTo( const sal_Int16 i_nPageId ) 84 { 85 return skipUntil( impl_pageIdToState( i_nPageId ) ); 86 } 87 sal_Bool goBackTo( const sal_Int16 i_nPageId ) 88 { 89 return skipBackwardUntil( impl_pageIdToState( i_nPageId ) ); 90 } 91 sal_Bool travelNext() { return WizardShell_Base::travelNext(); } 92 sal_Bool travelPrevious() { return WizardShell_Base::travelPrevious(); } 93 94 void activatePath( const sal_Int16 i_nPathID, const sal_Bool i_bFinal ) 95 { 96 WizardShell_Base::activatePath( PathId( i_nPathID ), i_bFinal ); 97 } 98 99 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardPage > 100 getCurrentWizardPage() const; 101 102 sal_Int16 getCurrentPage() const 103 { 104 return impl_stateToPageId( getCurrentState() ); 105 } 106 107 void enablePage( const sal_Int16 i_PageID, const sal_Bool i_Enable ); 108 109 bool knowsPage( const sal_Int16 i_nPageID ) const 110 { 111 return knowsState( impl_pageIdToState( i_nPageID ) ); 112 } 113 114 private: 115 sal_Int16 impl_stateToPageId( const WizardTypes::WizardState i_nState ) const 116 { 117 return static_cast< sal_Int16 >( i_nState + m_nFirstPageID ); 118 } 119 120 WizardState impl_pageIdToState( const sal_Int16 i_nPageId ) const 121 { 122 return static_cast< WizardState >( i_nPageId - m_nFirstPageID ); 123 } 124 125 PWizardPageController impl_getController( TabPage* i_pPage ) const; 126 127 // prevent outside access to some base class members 128 using WizardShell_Base::skip; 129 using WizardShell_Base::skipUntil; 130 using WizardShell_Base::skipBackwardUntil; 131 using WizardShell_Base::getCurrentState; 132 using WizardShell_Base::activatePath; 133 134 private: 135 typedef ::std::map< TabPage*, PWizardPageController > Page2ControllerMap; 136 137 const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard > m_xWizard; 138 const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController > m_xController; 139 const sal_Int16 m_nFirstPageID; 140 Page2ControllerMap m_aPageControllers; 141 }; 142 143 //...................................................................................................................... 144 } } // namespace svt::uno 145 //...................................................................................................................... 146 147 #endif // SVT_UNO_WIZARD_SHELL 148