1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include "tableselectionpage.hxx" 31*cdf0e10cSrcweir #include "abptypes.hxx" 32*cdf0e10cSrcweir #include "addresssettings.hxx" 33*cdf0e10cSrcweir #include "abspilot.hxx" 34*cdf0e10cSrcweir #include <tools/debug.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir //......................................................................... 37*cdf0e10cSrcweir namespace abp 38*cdf0e10cSrcweir { 39*cdf0e10cSrcweir //......................................................................... 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir //===================================================================== 42*cdf0e10cSrcweir //= TableSelectionPage 43*cdf0e10cSrcweir //===================================================================== 44*cdf0e10cSrcweir //--------------------------------------------------------------------- 45*cdf0e10cSrcweir TableSelectionPage::TableSelectionPage( OAddessBookSourcePilot* _pParent ) 46*cdf0e10cSrcweir :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_TABLESELECTION_AB)) 47*cdf0e10cSrcweir ,m_aLabel ( this, ModuleRes( FL_TOOMUCHTABLES ) ) 48*cdf0e10cSrcweir ,m_aTableList ( this, ModuleRes( LB_TABLELIST ) ) 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir FreeResource(); 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir m_aTableList.SetSelectHdl( LINK( this, TableSelectionPage, OnTableSelected ) ); 53*cdf0e10cSrcweir m_aTableList.SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) ); 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //--------------------------------------------------------------------- 57*cdf0e10cSrcweir void TableSelectionPage::ActivatePage() 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir AddressBookSourcePage::ActivatePage(); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir m_aTableList.GrabFocus(); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir //--------------------------------------------------------------------- 65*cdf0e10cSrcweir void TableSelectionPage::DeactivatePage() 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir AddressBookSourcePage::DeactivatePage(); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir //--------------------------------------------------------------------- 71*cdf0e10cSrcweir void TableSelectionPage::initializePage() 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir AddressBookSourcePage::initializePage(); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir const AddressSettings& rSettings = getSettings(); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir m_aTableList.Clear(); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // get the table names 80*cdf0e10cSrcweir const StringBag& aTableNames = getDialog()->getDataSource().getTableNames(); 81*cdf0e10cSrcweir DBG_ASSERT( aTableNames.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!"); 82*cdf0e10cSrcweir // this page should never bother the user if there is 1 or less tables. 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // fill the list 85*cdf0e10cSrcweir for ( ConstStringBagIterator aTables = aTableNames.begin(); 86*cdf0e10cSrcweir aTables != aTableNames.end(); 87*cdf0e10cSrcweir ++aTables 88*cdf0e10cSrcweir ) 89*cdf0e10cSrcweir m_aTableList.InsertEntry( *aTables ); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // initially select the proper table 92*cdf0e10cSrcweir m_aTableList.SelectEntry( rSettings.sSelectedTable ); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir //--------------------------------------------------------------------- 96*cdf0e10cSrcweir IMPL_LINK( TableSelectionPage, OnTableDoubleClicked, void*, /*NOTINTERESTEDIN*/ ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir if ( 1 == m_aTableList.GetSelectEntryCount() ) 99*cdf0e10cSrcweir getDialog()->travelNext(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir return 0L; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir //--------------------------------------------------------------------- 105*cdf0e10cSrcweir IMPL_LINK( TableSelectionPage, OnTableSelected, void*, /*NOTINTERESTEDIN*/ ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir updateDialogTravelUI(); 108*cdf0e10cSrcweir return 0L; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir //--------------------------------------------------------------------- 112*cdf0e10cSrcweir sal_Bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir if (!AddressBookSourcePage::commitPage(_eReason)) 115*cdf0e10cSrcweir return sal_False; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir AddressSettings& rSettings = getSettings(); 118*cdf0e10cSrcweir rSettings.sSelectedTable = m_aTableList.GetSelectEntry(); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir return sal_True; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir //--------------------------------------------------------------------- 124*cdf0e10cSrcweir bool TableSelectionPage::canAdvance() const 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir return AddressBookSourcePage::canAdvance() 127*cdf0e10cSrcweir && ( 0 < m_aTableList.GetSelectEntryCount() ); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir //......................................................................... 131*cdf0e10cSrcweir } // namespace abp 132*cdf0e10cSrcweir //......................................................................... 133*cdf0e10cSrcweir 134