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::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
51 : );
52 : virtual ~WizardShell();
53 :
54 : // Dialog overridables
55 : virtual short Execute();
56 :
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 String getStateDisplayName( WizardState i_nState ) const;
62 : virtual bool canAdvance() const;
63 : virtual sal_Bool onFinish();
64 : virtual IWizardPageController*
65 : getPageController( TabPage* _pCurrentPage ) const;
66 :
67 : // attribute access
68 : const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizard >&
69 : getWizard() const { return m_xWizard; }
70 :
71 : static sal_Int16 convertCommitReasonToTravelType( const CommitPageReason i_eReason );
72 :
73 : // operations
74 0 : sal_Bool advanceTo( const sal_Int16 i_nPageId )
75 : {
76 0 : return skipUntil( impl_pageIdToState( i_nPageId ) );
77 : }
78 0 : sal_Bool goBackTo( const sal_Int16 i_nPageId )
79 : {
80 0 : return skipBackwardUntil( impl_pageIdToState( i_nPageId ) );
81 : }
82 0 : sal_Bool travelNext() { return WizardShell_Base::travelNext(); }
83 0 : sal_Bool travelPrevious() { return WizardShell_Base::travelPrevious(); }
84 :
85 0 : void activatePath( const sal_Int16 i_nPathID, const sal_Bool i_bFinal )
86 : {
87 0 : WizardShell_Base::activatePath( PathId( i_nPathID ), i_bFinal );
88 0 : }
89 :
90 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardPage >
91 : getCurrentWizardPage() const;
92 :
93 0 : sal_Int16 getCurrentPage() const
94 : {
95 0 : return impl_stateToPageId( getCurrentState() );
96 : }
97 :
98 : void enablePage( const sal_Int16 i_PageID, const sal_Bool i_Enable );
99 :
100 0 : bool knowsPage( const sal_Int16 i_nPageID ) const
101 : {
102 0 : return knowsState( impl_pageIdToState( i_nPageID ) );
103 : }
104 :
105 : private:
106 0 : sal_Int16 impl_stateToPageId( const WizardTypes::WizardState i_nState ) const
107 : {
108 0 : return static_cast< sal_Int16 >( i_nState + m_nFirstPageID );
109 : }
110 :
111 0 : WizardState impl_pageIdToState( const sal_Int16 i_nPageId ) const
112 : {
113 0 : return static_cast< WizardState >( i_nPageId - m_nFirstPageID );
114 : }
115 :
116 : PWizardPageController impl_getController( TabPage* i_pPage ) const;
117 :
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;
124 :
125 : private:
126 : typedef ::std::map< TabPage*, PWizardPageController > Page2ControllerMap;
127 :
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;
132 : };
133 :
134 : //......................................................................................................................
135 : } } // namespace svt::uno
136 : //......................................................................................................................
137 :
138 : #endif // SVT_UNO_WIZARD_SHELL
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|