LibreOffice Module svtools (master) 1
wizardpagecontroller.cxx
Go to the documentation of this file.
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
22#include "wizardshell.hxx"
23
26
27
28namespace svt::uno
29{
30
31
32 using css::uno::Reference;
33 using css::uno::UNO_SET_THROW;
34 using css::uno::Exception;
35 using css::ui::dialogs::XWizardController;
36 using css::awt::XWindow;
37
38 using namespace ::com::sun::star;
39
40
41 //= WizardPageController
42
43
44 WizardPageController::WizardPageController(weld::Container* pParent, const Reference< XWizardController >& i_rController,
45 const sal_Int16 i_nPageId )
46 :m_xController( i_rController )
47 ,m_xWizardPage()
48 {
49 ENSURE_OR_THROW( m_xController.is(), "no controller" );
50 try
51 {
52 // Plug a toplevel SalFrame into the native page which can host our awt widgetry
53 css::uno::Reference<css::awt::XWindow> xChildFrame = pParent->CreateChildFrame();
54 m_xWizardPage.set(m_xController->createPage(xChildFrame, i_nPageId), UNO_SET_THROW);
55
56 css::uno::Reference<css::awt::XWindow> xPageWindow(m_xWizardPage->getWindow(), UNO_SET_THROW);
57
58 // tdf#132110 use the current size of the child as the size request
59 com::sun::star::awt::Rectangle aChildRect = xPageWindow->getPosSize();
60 pParent->set_size_request(aChildRect.Width, aChildRect.Height);
61
62 xPageWindow->setVisible(true);
63 }
64 catch( const Exception& )
65 {
66 DBG_UNHANDLED_EXCEPTION("svtools.uno");
67 }
68 }
69
71 {
72 try
73 {
74 if ( m_xWizardPage.is() )
75 m_xWizardPage->dispose();
76 }
77 catch( const Exception& )
78 {
79 DBG_UNHANDLED_EXCEPTION("svtools.uno");
80 }
81 }
82
84 {
85 if ( !m_xWizardPage.is() )
86 return;
87
88 try
89 {
90 m_xWizardPage->activatePage();
91 }
92 catch( const Exception& )
93 {
94 DBG_UNHANDLED_EXCEPTION("svtools.uno");
95 }
96 }
97
99 {
100 if ( !m_xWizardPage.is() )
101 return true;
102
103 try
104 {
105 return m_xWizardPage->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason ) );
106 }
107 catch( const Exception& )
108 {
109 DBG_UNHANDLED_EXCEPTION("svtools.uno");
110 }
111
112 return true;
113 }
114
116 {
117 if ( !m_xWizardPage.is() )
118 return true;
119
120 try
121 {
122 return m_xWizardPage->canAdvance();
123 }
124 catch( const Exception& )
125 {
126 DBG_UNHANDLED_EXCEPTION("svtools.uno");
127 }
128
129 return true;
130 }
131
132
133} // namespace svt::uno
134
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool commitPage(vcl::WizardTypes::CommitPageReason _eReason) override
virtual void initializePage() override
const css::uno::Reference< css::ui::dialogs::XWizardController > m_xController
css::uno::Reference< css::ui::dialogs::XWizardPage > m_xWizardPage
WizardPageController(weld::Container *pParent, const css::uno::Reference< css::ui::dialogs::XWizardController > &i_rController, const sal_Int16 i_nPageId)
virtual bool canAdvance() const override
static sal_Int16 convertCommitReasonToTravelType(const CommitPageReason i_eReason)
Definition: wizardshell.cxx:96
virtual css::uno::Reference< css::awt::XWindow > CreateChildFrame()=0
virtual void set_size_request(int nWidth, int nHeight)=0
#define ENSURE_OR_THROW(c, m)
#define DBG_UNHANDLED_EXCEPTION(...)
@ Exception