1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "tableselectionpage.hxx"
31 #include "abptypes.hxx"
32 #include "addresssettings.hxx"
33 #include "abspilot.hxx"
34 #include <tools/debug.hxx>
36 //.........................................................................
39 //.........................................................................
41 //=====================================================================
42 //= TableSelectionPage
43 //=====================================================================
44 //---------------------------------------------------------------------
45 TableSelectionPage::TableSelectionPage( OAddessBookSourcePilot
* _pParent
)
46 :AddressBookSourcePage(_pParent
, ModuleRes(RID_PAGE_TABLESELECTION_AB
))
47 ,m_aLabel ( this, ModuleRes( FL_TOOMUCHTABLES
) )
48 ,m_aTableList ( this, ModuleRes( LB_TABLELIST
) )
52 m_aTableList
.SetSelectHdl( LINK( this, TableSelectionPage
, OnTableSelected
) );
53 m_aTableList
.SetDoubleClickHdl( LINK( this, TableSelectionPage
, OnTableDoubleClicked
) );
56 //---------------------------------------------------------------------
57 void TableSelectionPage::ActivatePage()
59 AddressBookSourcePage::ActivatePage();
61 m_aTableList
.GrabFocus();
64 //---------------------------------------------------------------------
65 void TableSelectionPage::DeactivatePage()
67 AddressBookSourcePage::DeactivatePage();
70 //---------------------------------------------------------------------
71 void TableSelectionPage::initializePage()
73 AddressBookSourcePage::initializePage();
75 const AddressSettings
& rSettings
= getSettings();
79 // get the table names
80 const StringBag
& aTableNames
= getDialog()->getDataSource().getTableNames();
81 DBG_ASSERT( aTableNames
.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!");
82 // this page should never bother the user if there is 1 or less tables.
85 for ( ConstStringBagIterator aTables
= aTableNames
.begin();
86 aTables
!= aTableNames
.end();
89 m_aTableList
.InsertEntry( *aTables
);
91 // initially select the proper table
92 m_aTableList
.SelectEntry( rSettings
.sSelectedTable
);
95 //---------------------------------------------------------------------
96 IMPL_LINK( TableSelectionPage
, OnTableDoubleClicked
, void*, /*NOTINTERESTEDIN*/ )
98 if ( 1 == m_aTableList
.GetSelectEntryCount() )
99 getDialog()->travelNext();
104 //---------------------------------------------------------------------
105 IMPL_LINK( TableSelectionPage
, OnTableSelected
, void*, /*NOTINTERESTEDIN*/ )
107 updateDialogTravelUI();
111 //---------------------------------------------------------------------
112 sal_Bool
TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason
)
114 if (!AddressBookSourcePage::commitPage(_eReason
))
117 AddressSettings
& rSettings
= getSettings();
118 rSettings
.sSelectedTable
= m_aTableList
.GetSelectEntry();
123 //---------------------------------------------------------------------
124 bool TableSelectionPage::canAdvance() const
126 return AddressBookSourcePage::canAdvance()
127 && ( 0 < m_aTableList
.GetSelectEntryCount() );
130 //.........................................................................
132 //.........................................................................