Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / svtools / source / uno / wizard / wizardpagecontroller.cxx
blob3bf7e53092699f6a22feb0bcc87c539dc6709ff7
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 .
21 #include "wizardpagecontroller.hxx"
22 #include "wizardshell.hxx"
24 #include <toolkit/helper/vclunohelper.hxx>
25 #include <comphelper/diagnose_ex.hxx>
28 namespace svt::uno
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 )
47 ,m_xWizardPage()
49 ENSURE_OR_THROW( m_xController.is(), "no controller" );
50 try
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()
72 try
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() )
86 return;
88 try
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() )
101 return true;
105 return m_xWizardPage->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason ) );
107 catch( const Exception& )
109 DBG_UNHANDLED_EXCEPTION("svtools.uno");
112 return true;
115 bool WizardPageController::canAdvance() const
117 if ( !m_xWizardPage.is() )
118 return true;
122 return m_xWizardPage->canAdvance();
124 catch( const Exception& )
126 DBG_UNHANDLED_EXCEPTION("svtools.uno");
129 return true;
133 } // namespace svt::uno
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */