Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "tableselectionpage.hxx"
21 : #include "abptypes.hxx"
22 : #include "addresssettings.hxx"
23 : #include "abspilot.hxx"
24 : #include <tools/debug.hxx>
25 :
26 : //.........................................................................
27 : namespace abp
28 : {
29 : //.........................................................................
30 :
31 : //=====================================================================
32 : //= TableSelectionPage
33 : //=====================================================================
34 : //---------------------------------------------------------------------
35 0 : TableSelectionPage::TableSelectionPage( OAddessBookSourcePilot* _pParent )
36 : :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_TABLESELECTION_AB))
37 : ,m_aLabel ( this, ModuleRes( FL_TOOMUCHTABLES ) )
38 0 : ,m_aTableList ( this, ModuleRes( LB_TABLELIST ) )
39 : {
40 0 : FreeResource();
41 :
42 0 : m_aTableList.SetSelectHdl( LINK( this, TableSelectionPage, OnTableSelected ) );
43 0 : m_aTableList.SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) );
44 0 : }
45 :
46 : //---------------------------------------------------------------------
47 0 : void TableSelectionPage::ActivatePage()
48 : {
49 0 : AddressBookSourcePage::ActivatePage();
50 :
51 0 : m_aTableList.GrabFocus();
52 0 : }
53 :
54 : //---------------------------------------------------------------------
55 0 : void TableSelectionPage::DeactivatePage()
56 : {
57 0 : AddressBookSourcePage::DeactivatePage();
58 0 : }
59 :
60 : //---------------------------------------------------------------------
61 0 : void TableSelectionPage::initializePage()
62 : {
63 0 : AddressBookSourcePage::initializePage();
64 :
65 0 : const AddressSettings& rSettings = getSettings();
66 :
67 0 : m_aTableList.Clear();
68 :
69 : // get the table names
70 0 : const StringBag& aTableNames = getDialog()->getDataSource().getTableNames();
71 : DBG_ASSERT( aTableNames.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!");
72 : // this page should never bother the user if there is 1 or less tables.
73 :
74 : // fill the list
75 0 : for ( ConstStringBagIterator aTables = aTableNames.begin();
76 0 : aTables != aTableNames.end();
77 : ++aTables
78 : )
79 0 : m_aTableList.InsertEntry( *aTables );
80 :
81 : // initially select the proper table
82 0 : m_aTableList.SelectEntry( rSettings.sSelectedTable );
83 0 : }
84 :
85 : //---------------------------------------------------------------------
86 0 : IMPL_LINK( TableSelectionPage, OnTableDoubleClicked, void*, /*NOTINTERESTEDIN*/ )
87 : {
88 0 : if ( 1 == m_aTableList.GetSelectEntryCount() )
89 0 : getDialog()->travelNext();
90 :
91 0 : return 0L;
92 : }
93 :
94 : //---------------------------------------------------------------------
95 0 : IMPL_LINK( TableSelectionPage, OnTableSelected, void*, /*NOTINTERESTEDIN*/ )
96 : {
97 0 : updateDialogTravelUI();
98 0 : return 0L;
99 : }
100 :
101 : //---------------------------------------------------------------------
102 0 : sal_Bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
103 : {
104 0 : if (!AddressBookSourcePage::commitPage(_eReason))
105 0 : return sal_False;
106 :
107 0 : AddressSettings& rSettings = getSettings();
108 0 : rSettings.sSelectedTable = m_aTableList.GetSelectEntry();
109 :
110 0 : return sal_True;
111 : }
112 :
113 : //---------------------------------------------------------------------
114 0 : bool TableSelectionPage::canAdvance() const
115 : {
116 0 : return AddressBookSourcePage::canAdvance()
117 0 : && ( 0 < m_aTableList.GetSelectEntryCount() );
118 : }
119 :
120 : //.........................................................................
121 : } // namespace abp
122 : //.........................................................................
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|