Branch data Line data Source code
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 : :
21 : : #include "wizardpagecontroller.hxx"
22 : : #include "wizardshell.hxx"
23 : :
24 : : #include <com/sun/star/lang/XComponent.hpp>
25 : : #include <com/sun/star/awt/XControl.hpp>
26 : :
27 : : #include <toolkit/helper/vclunohelper.hxx>
28 : : #include <tools/diagnose_ex.h>
29 : :
30 : : //......................................................................................................................
31 : : namespace svt { namespace uno
32 : : {
33 : : //......................................................................................................................
34 : :
35 : : /** === begin UNO using === **/
36 : : using ::com::sun::star::uno::Reference;
37 : : using ::com::sun::star::uno::XInterface;
38 : : using ::com::sun::star::uno::UNO_QUERY;
39 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
40 : : using ::com::sun::star::uno::UNO_SET_THROW;
41 : : using ::com::sun::star::uno::Exception;
42 : : using ::com::sun::star::uno::RuntimeException;
43 : : using ::com::sun::star::uno::Any;
44 : : using ::com::sun::star::uno::makeAny;
45 : : using ::com::sun::star::uno::Sequence;
46 : : using ::com::sun::star::uno::Type;
47 : : using ::com::sun::star::ui::dialogs::XWizardController;
48 : : using ::com::sun::star::awt::XWindow;
49 : : using ::com::sun::star::lang::XComponent;
50 : : using ::com::sun::star::awt::XControl;
51 : : /** === end UNO using === **/
52 : : using namespace ::com::sun::star;
53 : :
54 : : //==================================================================================================================
55 : : //= WizardPageController
56 : : //==================================================================================================================
57 : : //------------------------------------------------------------------------------------------------------------------
58 : 0 : WizardPageController::WizardPageController( WizardShell& i_rParent, const Reference< XWizardController >& i_rController,
59 : : const sal_Int16 i_nPageId )
60 : : :m_xController( i_rController )
61 : : ,m_xWizardPage()
62 : 0 : ,m_nPageId( i_nPageId )
63 : : {
64 [ # # ][ # # ]: 0 : ENSURE_OR_THROW( m_xController.is(), "no controller" );
[ # # ][ # # ]
65 : : try
66 : : {
67 [ # # ]: 0 : m_xWizardPage.set( m_xController->createPage(
68 : 0 : Reference< XWindow >( i_rParent.GetComponentInterface( sal_True ), UNO_QUERY_THROW ),
69 : : m_nPageId
70 [ # # ][ # # ]: 0 : ), UNO_SET_THROW );
[ # # ][ # # ]
71 : :
72 [ # # ][ # # ]: 0 : Reference< XWindow > xPageWindow( m_xWizardPage->getWindow(), UNO_SET_THROW );
[ # # ]
73 [ # # ][ # # ]: 0 : xPageWindow->setVisible( sal_True );
74 : :
75 [ # # ]: 0 : TabPage* pTabPage( getTabPage() );
76 [ # # ]: 0 : if ( pTabPage )
77 [ # # ][ # # ]: 0 : pTabPage->SetStyle( pTabPage->GetStyle() | WB_CHILDDLGCTRL | WB_DIALOGCONTROL );
[ # # ]
78 : : }
79 [ # # ]: 0 : catch( const Exception& )
80 : : {
81 : : DBG_UNHANDLED_EXCEPTION();
82 : : }
83 : 0 : }
84 : :
85 : : //------------------------------------------------------------------------------------------------------------------
86 : 0 : WizardPageController::~WizardPageController()
87 : : {
88 : : try
89 : : {
90 [ # # ]: 0 : if ( m_xWizardPage.is() )
91 [ # # ][ # # ]: 0 : m_xWizardPage->dispose();
92 : : }
93 [ # # ]: 0 : catch( const Exception& )
94 : : {
95 : : DBG_UNHANDLED_EXCEPTION();
96 : : }
97 [ # # ][ # # ]: 0 : }
98 : :
99 : : //------------------------------------------------------------------------------------------------------------------
100 : 0 : TabPage* WizardPageController::getTabPage() const
101 : : {
102 [ # # ]: 0 : ENSURE_OR_RETURN( m_xWizardPage.is(), "WizardPageController::getTabPage: no external wizard page!", NULL );
103 : : try
104 : : {
105 [ # # ][ # # ]: 0 : Reference< XWindow > xPageWindow( m_xWizardPage->getWindow(), UNO_SET_THROW );
[ # # ]
106 [ # # ]: 0 : Window* pPageWindow = VCLUnoHelper::GetWindow( xPageWindow );
107 [ # # ]: 0 : if ( pPageWindow == NULL )
108 : : {
109 : : // windows created via the XContainerWindowProvider might be controls, not real windows, so resolve
110 : : // that one indirection
111 [ # # ][ # # ]: 0 : const Reference< XControl > xPageControl( m_xWizardPage->getWindow(), UNO_QUERY_THROW );
[ # # ]
112 [ # # ][ # # ]: 0 : xPageWindow.set( xPageControl->getPeer(), UNO_QUERY_THROW );
[ # # ]
113 [ # # ]: 0 : pPageWindow = VCLUnoHelper::GetWindow( xPageWindow );
114 : : }
115 : :
116 : : OSL_ENSURE( pPageWindow != NULL, "WizardPageController::getTabPage: unable to find the Window implementation for the page's window!" );
117 [ # # ][ # # ]: 0 : return dynamic_cast< TabPage* >( pPageWindow );
118 : : }
119 : 0 : catch( const Exception& )
120 : : {
121 : : DBG_UNHANDLED_EXCEPTION();
122 : : }
123 : 0 : return NULL;
124 : : }
125 : :
126 : : //------------------------------------------------------------------------------------------------------------------
127 : 0 : void WizardPageController::initializePage()
128 : : {
129 [ # # ]: 0 : if ( !m_xWizardPage.is() )
130 [ # # ]: 0 : return;
131 : :
132 : : try
133 : : {
134 [ # # ][ # # ]: 0 : m_xWizardPage->activatePage();
135 : : }
136 : 0 : catch( const Exception& )
137 : : {
138 : : DBG_UNHANDLED_EXCEPTION();
139 : : }
140 : : }
141 : :
142 : : //------------------------------------------------------------------------------------------------------------------
143 : 0 : sal_Bool WizardPageController::commitPage( WizardTypes::CommitPageReason i_eReason )
144 : : {
145 [ # # ]: 0 : if ( !m_xWizardPage.is() )
146 : 0 : return sal_True;
147 : :
148 : : try
149 : : {
150 [ # # ][ # # ]: 0 : return m_xWizardPage->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason ) );
[ # # ][ # # ]
151 : : }
152 : 0 : catch( const Exception& )
153 : : {
154 : : DBG_UNHANDLED_EXCEPTION();
155 : : }
156 : :
157 : 0 : return sal_True;
158 : : }
159 : :
160 : : //------------------------------------------------------------------------------------------------------------------
161 : 0 : bool WizardPageController::canAdvance() const
162 : : {
163 [ # # ]: 0 : if ( !m_xWizardPage.is() )
164 : 0 : return true;
165 : :
166 : : try
167 : : {
168 [ # # ][ # # ]: 0 : return m_xWizardPage->canAdvance();
[ # # ]
169 : : }
170 : 0 : catch( const Exception& )
171 : : {
172 : : DBG_UNHANDLED_EXCEPTION();
173 : : }
174 : :
175 : 0 : return true;
176 : : }
177 : :
178 : : //......................................................................................................................
179 : : } } // namespace svt::uno
180 : : //......................................................................................................................
181 : :
182 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|