1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "wizardpagecontroller.hxx"
22 #include "wizardshell.hxx"
24 #include <toolkit/helper/vclunohelper.hxx>
25 #include <comphelper/diagnose_ex.hxx>
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
;
38 using namespace ::com::sun::star
;
41 //= WizardPageController
44 WizardPageController::WizardPageController(weld::Container
* pParent
, const Reference
< XWizardController
>& i_rController
,
45 const sal_Int16 i_nPageId
)
46 :m_xController( i_rController
)
49 ENSURE_OR_THROW( m_xController
.is(), "no controller" );
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
);
56 css::uno::Reference
<css::awt::XWindow
> xPageWindow(m_xWizardPage
->getWindow(), UNO_SET_THROW
);
58 // tdf#132110 use the current size of the child as the size request
59 css::awt::Rectangle aChildRect
= xPageWindow
->getPosSize();
60 pParent
->set_size_request(aChildRect
.Width
, aChildRect
.Height
);
62 xPageWindow
->setVisible(true);
64 catch( const Exception
& )
66 DBG_UNHANDLED_EXCEPTION("svtools.uno");
70 WizardPageController::~WizardPageController()
74 if ( m_xWizardPage
.is() )
75 m_xWizardPage
->dispose();
77 catch( const Exception
& )
79 DBG_UNHANDLED_EXCEPTION("svtools.uno");
83 void WizardPageController::initializePage()
85 if ( !m_xWizardPage
.is() )
90 m_xWizardPage
->activatePage();
92 catch( const Exception
& )
94 DBG_UNHANDLED_EXCEPTION("svtools.uno");
98 bool WizardPageController::commitPage( vcl::WizardTypes::CommitPageReason i_eReason
)
100 if ( !m_xWizardPage
.is() )
105 return m_xWizardPage
->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason
) );
107 catch( const Exception
& )
109 DBG_UNHANDLED_EXCEPTION("svtools.uno");
115 bool WizardPageController::canAdvance() const
117 if ( !m_xWizardPage
.is() )
122 return m_xWizardPage
->canAdvance();
124 catch( const Exception
& )
126 DBG_UNHANDLED_EXCEPTION("svtools.uno");
133 } // namespace svt::uno
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */