20#undef SC_DLLIMPLEMENTATION
25#include <com/sun/star/sheet/DataImportMode.hpp>
26#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
27#include <com/sun/star/sdb/DatabaseContext.hpp>
28#include <com/sun/star/sdb/XQueriesSupplier.hpp>
29#include <com/sun/star/sdb/XCompletedConnection.hpp>
30#include <com/sun/star/task/InteractionHandler.hpp>
38#define DP_TYPELIST_TABLE 0
39#define DP_TYPELIST_QUERY 1
40#define DP_TYPELIST_SQLNAT 3
43 : GenericDialogController(pParent,
"modules/scalc/ui/selectdatasource.ui",
"SelectDataSourceDialog")
44 , m_xLbDatabase(m_xBuilder->weld_combo_box(
"database"))
45 , m_xCbObject(m_xBuilder->weld_combo_box(
"datasource"))
46 , m_xLbType(m_xBuilder->weld_combo_box(
"type"))
54 uno::Reference<sdb::XDatabaseContext> xContext = sdb::DatabaseContext::create(
56 const uno::Sequence<OUString> aNames = xContext->getElementNames();
57 for(
const OUString&
aName : aNames )
62 catch(uno::Exception&)
82 const sal_Int32 nSelect =
m_xLbType->get_active();
88 rDesc.
nType = sheet::DataImportMode_NONE;
90 rDesc.
nType = sheet::DataImportMode_TABLE;
92 rDesc.
nType = sheet::DataImportMode_QUERY;
94 rDesc.
nType = sheet::DataImportMode_SQL;
109 if (aDatabaseName.isEmpty())
112 const int nSelect =
m_xLbType->get_active();
120 uno::Reference<sdb::XDatabaseContext> xContext = sdb::DatabaseContext::create(
123 uno::Any aSourceAny = xContext->getByName( aDatabaseName );
124 uno::Reference<sdb::XCompletedConnection> xSource(aSourceAny, uno::UNO_QUERY);
125 if ( !xSource.is() )
return;
127 uno::Reference<task::XInteractionHandler> xHandler(
129 uno::UNO_QUERY_THROW);
131 uno::Reference<sdbc::XConnection> xConnection = xSource->connectWithCompletion( xHandler );
133 uno::Reference<container::XNameAccess> xItems;
138 uno::Reference<sdbcx::XTablesSupplier> xTablesSupp( xConnection, uno::UNO_QUERY );
139 if ( !xTablesSupp.is() )
return;
141 xItems = xTablesSupp->getTables();
147 uno::Reference<sdb::XQueriesSupplier> xQueriesSupp( xConnection, uno::UNO_QUERY );
148 if ( !xQueriesSupp.is() )
return;
150 xItems = xQueriesSupp->getQueries();
153 if ( !xItems.is() )
return;
156 const uno::Sequence<OUString> aNames = xItems->getElementNames();
157 for(
const OUString&
aName : aNames )
162 catch(uno::Exception&)
virtual ~ScDataPilotDatabaseDlg() override
std::unique_ptr< weld::ComboBox > m_xCbObject
std::unique_ptr< weld::ComboBox > m_xLbType
void GetValues(ScImportSourceDesc &rDesc)
ScDataPilotDatabaseDlg(weld::Window *pParent)
std::unique_ptr< weld::ComboBox > m_xLbDatabase
IMPL_LINK_NOARG(ScDataPilotDatabaseDlg, SelectHdl, weld::ComboBox &, void)
#define DP_TYPELIST_QUERY
#define DP_TYPELIST_SQLNAT
#define DP_TYPELIST_TABLE
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LINK(Instance, Class, Member)
Reference< XComponentContext > getProcessComponentContext()
css::sheet::DataImportMode nType