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