13#include <com/sun/star/sdb/DatabaseContext.hpp>
14#include <com/sun/star/sdb/XCompletedConnection.hpp>
15#include <com/sun/star/task/InteractionHandler.hpp>
16#include <com/sun/star/sdbc/XRow.hpp>
17#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
18#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
42 std::vector<std::shared_ptr<sc::DataTransformation>>&& rTransformations);
44 virtual void execute()
override;
48 ScDocument& rDoc,
const OUString& rID, std::function<
void()> aImportFinishedHdl,
49 std::vector<std::shared_ptr<sc::DataTransformation>>&& rTransformations)
53 , maDataTransformations(
std::move(rTransformations))
54 , maImportFinishedHdl(aImportFinishedHdl)
69 uno::Reference<sdb::XDatabaseContext> xContext
71 uno::Any aSourceAny = xContext->getByName(aDatabase);
73 uno::Reference<sdb::XCompletedConnection> xSource(aSourceAny, uno::UNO_QUERY);
77 uno::Reference<task::XInteractionHandler> xHandler(
80 uno::UNO_QUERY_THROW);
82 uno::Reference<sdbc::XConnection> xConnection = xSource->connectWithCompletion(xHandler);
84 uno::Reference<sdbc::XStatement> xStatement = xConnection->createStatement();
86 uno::Reference<sdbc::XResultSet> xResult
87 = xStatement->executeQuery(
"SELECT * FROM " + aTable);
91 Reference<sdbc::XResultSetMetaDataSupplier> xMetaDataSupplier(xResult, UNO_QUERY);
93 Reference<sdbc::XResultSetMetaData> xMetaData = xMetaDataSupplier->getMetaData();
95 Reference<XRow> xRow(xResult, UNO_QUERY);
97 SCCOL nColCount =
static_cast<SCCOL>(xMetaData->getColumnCount());
99 while (xResult->next())
101 SCROW nRow =
static_cast<SCROW>(xResult->getRow());
103 for (
SCCOL nCol = 0; nCol < nColCount; nCol++)
106 xMetaData->getColumnType(nCol + 1),
false);
111 catch (uno::Exception&)
static void PutData(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const css::uno::Reference< css::sdbc::XRow > &xRow, sal_Int32 nRowPos, tools::Long nType, bool bCurrency, StrData *pStrData=nullptr)
Abstract class for all data provider.
bool mbDeterministic
If true make the threaded import deterministic for the tests.
sc::ExternalDataSource & mrDataSource
const OUString & getID() const
const std::vector< std::shared_ptr< sc::DataTransformation > > & getDataTransformation() const
const OUString & getURL() const
ScDBDataManager * getDBManager()
SQLDataProvider(ScDocument *pDoc, sc::ExternalDataSource &rDataSource)
virtual const OUString & GetURL() const override
virtual ~SQLDataProvider() override
ScDocumentUniquePtr mpDoc
virtual void Import() override
rtl::Reference< SQLFetchThread > mxSQLFetchThread
SQLFetchThread(ScDocument &rDoc, const OUString &rID, std::function< void()> aImportFinishedHdl, std::vector< std::shared_ptr< sc::DataTransformation > > &&rTransformations)
std::function< void()> maImportFinishedHdl
virtual void execute() override
const std::vector< std::shared_ptr< sc::DataTransformation > > maDataTransformations
void WriteToDoc(ScDocument &rDoc)
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XComponentContext > getProcessComponentContext()
CAUTION! The following defines must be in the same namespace as the respective type.