tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / svtools / source / uno / wizard / wizardshell.hxx
blobeb2e8150bc7fc3cd033bee16d789839ba5924407
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <com/sun/star/ui/dialogs/XWizardController.hpp>
23 #include <vcl/roadmapwizard.hxx>
24 #include <map>
25 #include <memory>
27 using vcl::WizardTypes::WizardState;
28 using vcl::WizardTypes::CommitPageReason;
30 namespace svt::uno
34 class WizardPageController;
35 typedef std::shared_ptr< WizardPageController > PWizardPageController;
38 //= WizardShell
40 typedef ::vcl::RoadmapWizardMachine WizardShell_Base;
41 class WizardShell : public WizardShell_Base
43 public:
44 WizardShell(
45 weld::Window* pParent,
46 const css::uno::Reference< css::ui::dialogs::XWizardController >& i_rController,
47 const css::uno::Sequence< css::uno::Sequence< sal_Int16 > >& i_rPaths
50 // Dialog overridables
51 virtual short run() override;
53 // OWizardMachine overridables
54 virtual std::unique_ptr<BuilderPage> createPage( WizardState i_nState ) override;
55 virtual void enterState( WizardState i_nState ) override;
56 virtual bool leaveState( WizardState i_nState ) override;
57 virtual OUString getStateDisplayName( WizardState i_nState ) const override;
58 virtual bool canAdvance() const override;
59 virtual bool onFinish() override;
60 virtual vcl::IWizardPageController* getPageController(BuilderPage* pCurrentPage) const override;
62 static sal_Int16 convertCommitReasonToTravelType( const CommitPageReason i_eReason );
64 // operations
65 bool advanceTo( const sal_Int16 i_nPageId )
67 return skipUntil( impl_pageIdToState( i_nPageId ) );
69 bool goBackTo( const sal_Int16 i_nPageId )
71 return skipBackwardUntil( impl_pageIdToState( i_nPageId ) );
73 using WizardShell_Base::travelNext;
74 using WizardShell_Base::travelPrevious;
76 void activatePath( const sal_Int16 i_nPathID, const bool i_bFinal )
78 WizardShell_Base::activatePath( vcl::RoadmapWizardTypes::PathId( i_nPathID ), i_bFinal );
81 css::uno::Reference< css::ui::dialogs::XWizardPage >
82 getCurrentWizardPage() const;
84 sal_Int16 getCurrentPage() const
86 return impl_stateToPageId( getCurrentState() );
89 void enablePage( const sal_Int16 i_PageID, const bool i_Enable );
91 bool knowsPage( const sal_Int16 i_nPageID ) const
93 return knowsState( impl_pageIdToState( i_nPageID ) );
96 private:
97 sal_Int16 impl_stateToPageId( const WizardState i_nState ) const
99 return static_cast< sal_Int16 >( i_nState + m_nFirstPageID );
102 WizardState impl_pageIdToState( const sal_Int16 i_nPageId ) const
104 return static_cast<WizardState>(i_nPageId - m_nFirstPageID);
107 PWizardPageController impl_getController(BuilderPage* i_pPage) const;
109 virtual OUString getPageIdentForState(WizardState nState) const override;
110 virtual WizardState getStateFromPageIdent(const OUString& rIdent) const override;
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;
119 private:
120 typedef std::map<BuilderPage*, PWizardPageController> Page2ControllerMap;
122 const css::uno::Reference< css::ui::dialogs::XWizardController > m_xController;
123 const sal_Int16 m_nFirstPageID;
124 Page2ControllerMap m_aPageControllers;
128 } // namespace svt::uno
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */