1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #include "precompiled_svtools.hxx" 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski #include "wizardpagecontroller.hxx" 27*b1cdbd2cSJim Jagielski #include "wizardshell.hxx" 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski /** === begin UNO includes === **/ 30*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XComponent.hpp> 31*b1cdbd2cSJim Jagielski #include <com/sun/star/awt/XControl.hpp> 32*b1cdbd2cSJim Jagielski /** === end UNO includes === **/ 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski #include <toolkit/helper/vclunohelper.hxx> 35*b1cdbd2cSJim Jagielski #include <tools/diagnose_ex.h> 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski //...................................................................................................................... 38*b1cdbd2cSJim Jagielski namespace svt { namespace uno 39*b1cdbd2cSJim Jagielski { 40*b1cdbd2cSJim Jagielski //...................................................................................................................... 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim Jagielski /** === begin UNO using === **/ 43*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Reference; 44*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::XInterface; 45*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::UNO_QUERY; 46*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::UNO_QUERY_THROW; 47*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::UNO_SET_THROW; 48*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Exception; 49*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::RuntimeException; 50*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Any; 51*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::makeAny; 52*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Sequence; 53*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Type; 54*b1cdbd2cSJim Jagielski using ::com::sun::star::ui::dialogs::XWizardController; 55*b1cdbd2cSJim Jagielski using ::com::sun::star::awt::XWindow; 56*b1cdbd2cSJim Jagielski using ::com::sun::star::lang::XComponent; 57*b1cdbd2cSJim Jagielski using ::com::sun::star::awt::XControl; 58*b1cdbd2cSJim Jagielski /** === end UNO using === **/ 59*b1cdbd2cSJim Jagielski using namespace ::com::sun::star; 60*b1cdbd2cSJim Jagielski 61*b1cdbd2cSJim Jagielski //================================================================================================================== 62*b1cdbd2cSJim Jagielski //= WizardPageController 63*b1cdbd2cSJim Jagielski //================================================================================================================== 64*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------------ WizardPageController(WizardShell & i_rParent,const Reference<XWizardController> & i_rController,const sal_Int16 i_nPageId)65*b1cdbd2cSJim Jagielski WizardPageController::WizardPageController( WizardShell& i_rParent, const Reference< XWizardController >& i_rController, 66*b1cdbd2cSJim Jagielski const sal_Int16 i_nPageId ) 67*b1cdbd2cSJim Jagielski :m_xController( i_rController ) 68*b1cdbd2cSJim Jagielski ,m_xWizardPage() 69*b1cdbd2cSJim Jagielski ,m_nPageId( i_nPageId ) 70*b1cdbd2cSJim Jagielski { 71*b1cdbd2cSJim Jagielski ENSURE_OR_THROW( m_xController.is(), "no controller" ); 72*b1cdbd2cSJim Jagielski try 73*b1cdbd2cSJim Jagielski { 74*b1cdbd2cSJim Jagielski m_xWizardPage.set( m_xController->createPage( 75*b1cdbd2cSJim Jagielski Reference< XWindow >( i_rParent.GetComponentInterface( sal_True ), UNO_QUERY_THROW ), 76*b1cdbd2cSJim Jagielski m_nPageId 77*b1cdbd2cSJim Jagielski ), UNO_SET_THROW ); 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski Reference< XWindow > xPageWindow( m_xWizardPage->getWindow(), UNO_SET_THROW ); 80*b1cdbd2cSJim Jagielski xPageWindow->setVisible( sal_True ); 81*b1cdbd2cSJim Jagielski 82*b1cdbd2cSJim Jagielski TabPage* pTabPage( getTabPage() ); 83*b1cdbd2cSJim Jagielski if ( pTabPage ) 84*b1cdbd2cSJim Jagielski pTabPage->SetStyle( pTabPage->GetStyle() | WB_CHILDDLGCTRL | WB_DIALOGCONTROL ); 85*b1cdbd2cSJim Jagielski } 86*b1cdbd2cSJim Jagielski catch( const Exception& ) 87*b1cdbd2cSJim Jagielski { 88*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION(); 89*b1cdbd2cSJim Jagielski } 90*b1cdbd2cSJim Jagielski } 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------------ ~WizardPageController()93*b1cdbd2cSJim Jagielski WizardPageController::~WizardPageController() 94*b1cdbd2cSJim Jagielski { 95*b1cdbd2cSJim Jagielski try 96*b1cdbd2cSJim Jagielski { 97*b1cdbd2cSJim Jagielski if ( m_xWizardPage.is() ) 98*b1cdbd2cSJim Jagielski m_xWizardPage->dispose(); 99*b1cdbd2cSJim Jagielski } 100*b1cdbd2cSJim Jagielski catch( const Exception& ) 101*b1cdbd2cSJim Jagielski { 102*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION(); 103*b1cdbd2cSJim Jagielski } 104*b1cdbd2cSJim Jagielski } 105*b1cdbd2cSJim Jagielski 106*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------------ getTabPage() const107*b1cdbd2cSJim Jagielski TabPage* WizardPageController::getTabPage() const 108*b1cdbd2cSJim Jagielski { 109*b1cdbd2cSJim Jagielski ENSURE_OR_RETURN( m_xWizardPage.is(), "WizardPageController::getTabPage: no external wizard page!", NULL ); 110*b1cdbd2cSJim Jagielski try 111*b1cdbd2cSJim Jagielski { 112*b1cdbd2cSJim Jagielski Reference< XWindow > xPageWindow( m_xWizardPage->getWindow(), UNO_SET_THROW ); 113*b1cdbd2cSJim Jagielski Window* pPageWindow = VCLUnoHelper::GetWindow( xPageWindow ); 114*b1cdbd2cSJim Jagielski if ( pPageWindow == NULL ) 115*b1cdbd2cSJim Jagielski { 116*b1cdbd2cSJim Jagielski // windows created via the XContainerWindowProvider might be controls, not real windows, so resolve 117*b1cdbd2cSJim Jagielski // that one indirection 118*b1cdbd2cSJim Jagielski const Reference< XControl > xPageControl( m_xWizardPage->getWindow(), UNO_QUERY_THROW ); 119*b1cdbd2cSJim Jagielski xPageWindow.set( xPageControl->getPeer(), UNO_QUERY_THROW ); 120*b1cdbd2cSJim Jagielski pPageWindow = VCLUnoHelper::GetWindow( xPageWindow ); 121*b1cdbd2cSJim Jagielski } 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski OSL_ENSURE( pPageWindow != NULL, "WizardPageController::getTabPage: unable to find the Window implementation for the page's window!" ); 124*b1cdbd2cSJim Jagielski return dynamic_cast< TabPage* >( pPageWindow ); 125*b1cdbd2cSJim Jagielski } 126*b1cdbd2cSJim Jagielski catch( const Exception& ) 127*b1cdbd2cSJim Jagielski { 128*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION(); 129*b1cdbd2cSJim Jagielski } 130*b1cdbd2cSJim Jagielski return NULL; 131*b1cdbd2cSJim Jagielski } 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------------ initializePage()134*b1cdbd2cSJim Jagielski void WizardPageController::initializePage() 135*b1cdbd2cSJim Jagielski { 136*b1cdbd2cSJim Jagielski if ( !m_xWizardPage.is() ) 137*b1cdbd2cSJim Jagielski return; 138*b1cdbd2cSJim Jagielski 139*b1cdbd2cSJim Jagielski try 140*b1cdbd2cSJim Jagielski { 141*b1cdbd2cSJim Jagielski m_xWizardPage->activatePage(); 142*b1cdbd2cSJim Jagielski } 143*b1cdbd2cSJim Jagielski catch( const Exception& ) 144*b1cdbd2cSJim Jagielski { 145*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION(); 146*b1cdbd2cSJim Jagielski } 147*b1cdbd2cSJim Jagielski } 148*b1cdbd2cSJim Jagielski 149*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------------ commitPage(WizardTypes::CommitPageReason i_eReason)150*b1cdbd2cSJim Jagielski sal_Bool WizardPageController::commitPage( WizardTypes::CommitPageReason i_eReason ) 151*b1cdbd2cSJim Jagielski { 152*b1cdbd2cSJim Jagielski if ( !m_xWizardPage.is() ) 153*b1cdbd2cSJim Jagielski return sal_True; 154*b1cdbd2cSJim Jagielski 155*b1cdbd2cSJim Jagielski try 156*b1cdbd2cSJim Jagielski { 157*b1cdbd2cSJim Jagielski return m_xWizardPage->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason ) ); 158*b1cdbd2cSJim Jagielski } 159*b1cdbd2cSJim Jagielski catch( const Exception& ) 160*b1cdbd2cSJim Jagielski { 161*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION(); 162*b1cdbd2cSJim Jagielski } 163*b1cdbd2cSJim Jagielski 164*b1cdbd2cSJim Jagielski return sal_True; 165*b1cdbd2cSJim Jagielski } 166*b1cdbd2cSJim Jagielski 167*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------------ canAdvance() const168*b1cdbd2cSJim Jagielski bool WizardPageController::canAdvance() const 169*b1cdbd2cSJim Jagielski { 170*b1cdbd2cSJim Jagielski if ( !m_xWizardPage.is() ) 171*b1cdbd2cSJim Jagielski return true; 172*b1cdbd2cSJim Jagielski 173*b1cdbd2cSJim Jagielski try 174*b1cdbd2cSJim Jagielski { 175*b1cdbd2cSJim Jagielski return m_xWizardPage->canAdvance(); 176*b1cdbd2cSJim Jagielski } 177*b1cdbd2cSJim Jagielski catch( const Exception& ) 178*b1cdbd2cSJim Jagielski { 179*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION(); 180*b1cdbd2cSJim Jagielski } 181*b1cdbd2cSJim Jagielski 182*b1cdbd2cSJim Jagielski return true; 183*b1cdbd2cSJim Jagielski } 184*b1cdbd2cSJim Jagielski 185*b1cdbd2cSJim Jagielski //...................................................................................................................... 186*b1cdbd2cSJim Jagielski } } // namespace svt::uno 187*b1cdbd2cSJim Jagielski //...................................................................................................................... 188