1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_extensions.hxx" 26 #include "tableselectionpage.hxx" 27 #include "abptypes.hxx" 28 #include "addresssettings.hxx" 29 #include "abspilot.hxx" 30 #include <tools/debug.hxx> 31 32 //......................................................................... 33 namespace abp 34 { 35 //......................................................................... 36 37 //===================================================================== 38 //= TableSelectionPage 39 //===================================================================== 40 //--------------------------------------------------------------------- TableSelectionPage(OAddessBookSourcePilot * _pParent)41 TableSelectionPage::TableSelectionPage( OAddessBookSourcePilot* _pParent ) 42 :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_TABLESELECTION_AB)) 43 ,m_aLabel ( this, ModuleRes( FL_TOOMUCHTABLES ) ) 44 ,m_aTableList ( this, ModuleRes( LB_TABLELIST ) ) 45 { 46 FreeResource(); 47 48 m_aTableList.SetSelectHdl( LINK( this, TableSelectionPage, OnTableSelected ) ); 49 m_aTableList.SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) ); 50 } 51 52 //--------------------------------------------------------------------- ActivatePage()53 void TableSelectionPage::ActivatePage() 54 { 55 AddressBookSourcePage::ActivatePage(); 56 57 m_aTableList.GrabFocus(); 58 } 59 60 //--------------------------------------------------------------------- DeactivatePage()61 void TableSelectionPage::DeactivatePage() 62 { 63 AddressBookSourcePage::DeactivatePage(); 64 } 65 66 //--------------------------------------------------------------------- initializePage()67 void TableSelectionPage::initializePage() 68 { 69 AddressBookSourcePage::initializePage(); 70 71 const AddressSettings& rSettings = getSettings(); 72 73 m_aTableList.Clear(); 74 75 // get the table names 76 const StringBag& aTableNames = getDialog()->getDataSource().getTableNames(); 77 DBG_ASSERT( aTableNames.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!"); 78 // this page should never bother the user if there is 1 or less tables. 79 80 // fill the list 81 for ( ConstStringBagIterator aTables = aTableNames.begin(); 82 aTables != aTableNames.end(); 83 ++aTables 84 ) 85 m_aTableList.InsertEntry( *aTables ); 86 87 // initially select the proper table 88 m_aTableList.SelectEntry( rSettings.sSelectedTable ); 89 } 90 91 //--------------------------------------------------------------------- 92 IMPL_LINK( TableSelectionPage, OnTableDoubleClicked, void*, /*NOTINTERESTEDIN*/ ) 93 { 94 if ( 1 == m_aTableList.GetSelectEntryCount() ) 95 getDialog()->travelNext(); 96 97 return 0L; 98 } 99 100 //--------------------------------------------------------------------- 101 IMPL_LINK( TableSelectionPage, OnTableSelected, void*, /*NOTINTERESTEDIN*/ ) 102 { 103 updateDialogTravelUI(); 104 return 0L; 105 } 106 107 //--------------------------------------------------------------------- commitPage(::svt::WizardTypes::CommitPageReason _eReason)108 sal_Bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) 109 { 110 if (!AddressBookSourcePage::commitPage(_eReason)) 111 return sal_False; 112 113 AddressSettings& rSettings = getSettings(); 114 rSettings.sSelectedTable = m_aTableList.GetSelectEntry(); 115 116 return sal_True; 117 } 118 119 //--------------------------------------------------------------------- canAdvance() const120 bool TableSelectionPage::canAdvance() const 121 { 122 return AddressBookSourcePage::canAdvance() 123 && ( 0 < m_aTableList.GetSelectEntryCount() ); 124 } 125 126 //......................................................................... 127 } // namespace abp 128 //......................................................................... 129 130