bump product version to 5.0.4.1
[LibreOffice.git] / extensions / source / abpilot / tableselectionpage.cxx
blob065f2d1bc85e56434564421bfd239fafcf28c5d4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "tableselectionpage.hxx"
21 #include "abptypes.hxx"
22 #include "addresssettings.hxx"
23 #include "abspilot.hxx"
24 #include <tools/debug.hxx>
27 namespace abp
30 TableSelectionPage::TableSelectionPage( OAddessBookSourcePilot* _pParent )
31 :AddressBookSourcePage(_pParent, "SelectTablePage",
32 "modules/sabpilot/ui/selecttablepage.ui")
34 get(m_pTableList, "table");
35 m_pTableList->SetSelectHdl( LINK( this, TableSelectionPage, OnTableSelected ) );
36 m_pTableList->SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) );
39 TableSelectionPage::~TableSelectionPage()
41 disposeOnce();
44 void TableSelectionPage::dispose()
46 m_pTableList.clear();
47 AddressBookSourcePage::dispose();
50 void TableSelectionPage::ActivatePage()
52 AddressBookSourcePage::ActivatePage();
54 m_pTableList->GrabFocus();
58 void TableSelectionPage::DeactivatePage()
60 AddressBookSourcePage::DeactivatePage();
64 void TableSelectionPage::initializePage()
66 AddressBookSourcePage::initializePage();
68 const AddressSettings& rSettings = getSettings();
70 m_pTableList->Clear();
72 // get the table names
73 const StringBag& aTableNames = getDialog()->getDataSource().getTableNames();
74 DBG_ASSERT( aTableNames.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!");
75 // this page should never bother the user if there is 1 or less tables.
77 // fill the list
78 for ( StringBag::const_iterator aTables = aTableNames.begin();
79 aTables != aTableNames.end();
80 ++aTables
82 m_pTableList->InsertEntry( *aTables );
84 // initially select the proper table
85 m_pTableList->SelectEntry( rSettings.sSelectedTable );
89 IMPL_LINK( TableSelectionPage, OnTableDoubleClicked, void*, /*NOTINTERESTEDIN*/ )
91 if ( 1 == m_pTableList->GetSelectEntryCount() )
92 getDialog()->travelNext();
94 return 0L;
98 IMPL_LINK( TableSelectionPage, OnTableSelected, void*, /*NOTINTERESTEDIN*/ )
100 updateDialogTravelUI();
101 return 0L;
105 bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
107 if (!AddressBookSourcePage::commitPage(_eReason))
108 return false;
110 AddressSettings& rSettings = getSettings();
111 rSettings.sSelectedTable = m_pTableList->GetSelectEntry();
113 return true;
117 bool TableSelectionPage::canAdvance() const
119 return AddressBookSourcePage::canAdvance()
120 && ( 0 < m_pTableList->GetSelectEntryCount() );
124 } // namespace abp
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */