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 <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/awt/XControl.hpp>
27 #include <toolkit/helper/vclunohelper.hxx>
28 #include <tools/diagnose_ex.h>
30 //......................................................................................................................
31 namespace svt
{ namespace uno
33 //......................................................................................................................
35 using ::com::sun::star::uno::Reference
;
36 using ::com::sun::star::uno::XInterface
;
37 using ::com::sun::star::uno::UNO_QUERY
;
38 using ::com::sun::star::uno::UNO_QUERY_THROW
;
39 using ::com::sun::star::uno::UNO_SET_THROW
;
40 using ::com::sun::star::uno::Exception
;
41 using ::com::sun::star::uno::RuntimeException
;
42 using ::com::sun::star::uno::Any
;
43 using ::com::sun::star::uno::makeAny
;
44 using ::com::sun::star::uno::Sequence
;
45 using ::com::sun::star::uno::Type
;
46 using ::com::sun::star::ui::dialogs::XWizardController
;
47 using ::com::sun::star::awt::XWindow
;
48 using ::com::sun::star::lang::XComponent
;
49 using ::com::sun::star::awt::XControl
;
51 using namespace ::com::sun::star
;
53 //==================================================================================================================
54 //= WizardPageController
55 //==================================================================================================================
56 //------------------------------------------------------------------------------------------------------------------
57 WizardPageController::WizardPageController( WizardShell
& i_rParent
, const Reference
< XWizardController
>& i_rController
,
58 const sal_Int16 i_nPageId
)
59 :m_xController( i_rController
)
61 ,m_nPageId( i_nPageId
)
63 ENSURE_OR_THROW( m_xController
.is(), "no controller" );
66 m_xWizardPage
.set( m_xController
->createPage(
67 Reference
< XWindow
>( i_rParent
.GetComponentInterface( sal_True
), UNO_QUERY_THROW
),
71 Reference
< XWindow
> xPageWindow( m_xWizardPage
->getWindow(), UNO_SET_THROW
);
72 xPageWindow
->setVisible( sal_True
);
74 TabPage
* pTabPage( getTabPage() );
76 pTabPage
->SetStyle( pTabPage
->GetStyle() | WB_CHILDDLGCTRL
| WB_DIALOGCONTROL
);
78 catch( const Exception
& )
80 DBG_UNHANDLED_EXCEPTION();
84 //------------------------------------------------------------------------------------------------------------------
85 WizardPageController::~WizardPageController()
89 if ( m_xWizardPage
.is() )
90 m_xWizardPage
->dispose();
92 catch( const Exception
& )
94 DBG_UNHANDLED_EXCEPTION();
98 //------------------------------------------------------------------------------------------------------------------
99 TabPage
* WizardPageController::getTabPage() const
101 ENSURE_OR_RETURN( m_xWizardPage
.is(), "WizardPageController::getTabPage: no external wizard page!", NULL
);
104 Reference
< XWindow
> xPageWindow( m_xWizardPage
->getWindow(), UNO_SET_THROW
);
105 Window
* pPageWindow
= VCLUnoHelper::GetWindow( xPageWindow
);
106 if ( pPageWindow
== NULL
)
108 // windows created via the XContainerWindowProvider might be controls, not real windows, so resolve
109 // that one indirection
110 const Reference
< XControl
> xPageControl( m_xWizardPage
->getWindow(), UNO_QUERY_THROW
);
111 xPageWindow
.set( xPageControl
->getPeer(), UNO_QUERY_THROW
);
112 pPageWindow
= VCLUnoHelper::GetWindow( xPageWindow
);
115 OSL_ENSURE( pPageWindow
!= NULL
, "WizardPageController::getTabPage: unable to find the Window implementation for the page's window!" );
116 return dynamic_cast< TabPage
* >( pPageWindow
);
118 catch( const Exception
& )
120 DBG_UNHANDLED_EXCEPTION();
125 //------------------------------------------------------------------------------------------------------------------
126 void WizardPageController::initializePage()
128 if ( !m_xWizardPage
.is() )
133 m_xWizardPage
->activatePage();
135 catch( const Exception
& )
137 DBG_UNHANDLED_EXCEPTION();
141 //------------------------------------------------------------------------------------------------------------------
142 sal_Bool
WizardPageController::commitPage( WizardTypes::CommitPageReason i_eReason
)
144 if ( !m_xWizardPage
.is() )
149 return m_xWizardPage
->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason
) );
151 catch( const Exception
& )
153 DBG_UNHANDLED_EXCEPTION();
159 //------------------------------------------------------------------------------------------------------------------
160 bool WizardPageController::canAdvance() const
162 if ( !m_xWizardPage
.is() )
167 return m_xWizardPage
->canAdvance();
169 catch( const Exception
& )
171 DBG_UNHANDLED_EXCEPTION();
177 //......................................................................................................................
178 } } // namespace svt::uno
179 //......................................................................................................................
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */