1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3*cdf0e10cSrcweir * 4*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 7*cdf0e10cSrcweir * 8*cdf0e10cSrcweir * This file is part of OpenOffice.org. 9*cdf0e10cSrcweir * 10*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 11*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 12*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 15*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 16*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 18*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 19*cdf0e10cSrcweir * 20*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 21*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 22*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 23*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 24*cdf0e10cSrcweir * 25*cdf0e10cSrcweir ************************************************************************/ 26*cdf0e10cSrcweir 27*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir #include "wizardpagecontroller.hxx" 30*cdf0e10cSrcweir #include "wizardshell.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir /** === begin UNO includes === **/ 33*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp> 35*cdf0e10cSrcweir /** === end UNO includes === **/ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 38*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir //...................................................................................................................... 41*cdf0e10cSrcweir namespace svt { namespace uno 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir //...................................................................................................................... 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir /** === begin UNO using === **/ 46*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 47*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 48*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 49*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 50*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_SET_THROW; 51*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 52*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 53*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 54*cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 55*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 56*cdf0e10cSrcweir using ::com::sun::star::uno::Type; 57*cdf0e10cSrcweir using ::com::sun::star::ui::dialogs::XWizardController; 58*cdf0e10cSrcweir using ::com::sun::star::awt::XWindow; 59*cdf0e10cSrcweir using ::com::sun::star::lang::XComponent; 60*cdf0e10cSrcweir using ::com::sun::star::awt::XControl; 61*cdf0e10cSrcweir /** === end UNO using === **/ 62*cdf0e10cSrcweir using namespace ::com::sun::star; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir //================================================================================================================== 65*cdf0e10cSrcweir //= WizardPageController 66*cdf0e10cSrcweir //================================================================================================================== 67*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 68*cdf0e10cSrcweir WizardPageController::WizardPageController( WizardShell& i_rParent, const Reference< XWizardController >& i_rController, 69*cdf0e10cSrcweir const sal_Int16 i_nPageId ) 70*cdf0e10cSrcweir :m_xController( i_rController ) 71*cdf0e10cSrcweir ,m_xWizardPage() 72*cdf0e10cSrcweir ,m_nPageId( i_nPageId ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir ENSURE_OR_THROW( m_xController.is(), "no controller" ); 75*cdf0e10cSrcweir try 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir m_xWizardPage.set( m_xController->createPage( 78*cdf0e10cSrcweir Reference< XWindow >( i_rParent.GetComponentInterface( sal_True ), UNO_QUERY_THROW ), 79*cdf0e10cSrcweir m_nPageId 80*cdf0e10cSrcweir ), UNO_SET_THROW ); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir Reference< XWindow > xPageWindow( m_xWizardPage->getWindow(), UNO_SET_THROW ); 83*cdf0e10cSrcweir xPageWindow->setVisible( sal_True ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir TabPage* pTabPage( getTabPage() ); 86*cdf0e10cSrcweir if ( pTabPage ) 87*cdf0e10cSrcweir pTabPage->SetStyle( pTabPage->GetStyle() | WB_CHILDDLGCTRL | WB_DIALOGCONTROL ); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir catch( const Exception& ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 96*cdf0e10cSrcweir WizardPageController::~WizardPageController() 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir try 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir if ( m_xWizardPage.is() ) 101*cdf0e10cSrcweir m_xWizardPage->dispose(); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir catch( const Exception& ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 110*cdf0e10cSrcweir TabPage* WizardPageController::getTabPage() const 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir ENSURE_OR_RETURN( m_xWizardPage.is(), "WizardPageController::getTabPage: no external wizard page!", NULL ); 113*cdf0e10cSrcweir try 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir Reference< XWindow > xPageWindow( m_xWizardPage->getWindow(), UNO_SET_THROW ); 116*cdf0e10cSrcweir Window* pPageWindow = VCLUnoHelper::GetWindow( xPageWindow ); 117*cdf0e10cSrcweir if ( pPageWindow == NULL ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir // windows created via the XContainerWindowProvider might be controls, not real windows, so resolve 120*cdf0e10cSrcweir // that one indirection 121*cdf0e10cSrcweir const Reference< XControl > xPageControl( m_xWizardPage->getWindow(), UNO_QUERY_THROW ); 122*cdf0e10cSrcweir xPageWindow.set( xPageControl->getPeer(), UNO_QUERY_THROW ); 123*cdf0e10cSrcweir pPageWindow = VCLUnoHelper::GetWindow( xPageWindow ); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir OSL_ENSURE( pPageWindow != NULL, "WizardPageController::getTabPage: unable to find the Window implementation for the page's window!" ); 127*cdf0e10cSrcweir return dynamic_cast< TabPage* >( pPageWindow ); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir catch( const Exception& ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir return NULL; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 137*cdf0e10cSrcweir void WizardPageController::initializePage() 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir if ( !m_xWizardPage.is() ) 140*cdf0e10cSrcweir return; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir try 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir m_xWizardPage->activatePage(); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir catch( const Exception& ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 153*cdf0e10cSrcweir sal_Bool WizardPageController::commitPage( WizardTypes::CommitPageReason i_eReason ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir if ( !m_xWizardPage.is() ) 156*cdf0e10cSrcweir return sal_True; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir try 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir return m_xWizardPage->commitPage( WizardShell::convertCommitReasonToTravelType( i_eReason ) ); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir catch( const Exception& ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir return sal_True; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 171*cdf0e10cSrcweir bool WizardPageController::canAdvance() const 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir if ( !m_xWizardPage.is() ) 174*cdf0e10cSrcweir return true; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir try 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir return m_xWizardPage->canAdvance(); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir catch( const Exception& ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir return true; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir //...................................................................................................................... 189*cdf0e10cSrcweir } } // namespace svt::uno 190*cdf0e10cSrcweir //...................................................................................................................... 191