11#include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
12#include <com/sun/star/ucb/SimpleFileAccess.hpp>
13#include <com/sun/star/io/XInputStream.hpp>
15#include <rtl/strbuf.hxx>
39 uno::Reference< io::XInputStream >
xStream = xFileAccess->openFileRead( rURL );
41 const sal_Int32 BUF_LEN = 8000;
42 uno::Sequence< sal_Int8 > buffer( BUF_LEN );
45 while ( ( nRead =
xStream->readBytes( buffer, BUF_LEN ) ) == BUF_LEN )
47 rBuffer.append(
reinterpret_cast< const char*
>( buffer.getConstArray() ), nRead );
52 rBuffer.append(
reinterpret_cast< const char*
>( buffer.getConstArray() ), nRead );
57 SvStream* pStream =
new SvMemoryStream(
const_cast<char*
>(rBuffer.getStr()), rBuffer.getLength(), StreamMode::READ);
58 return std::unique_ptr<SvStream>(pStream);
70 , maProvider(
std::move(aProvider))
172 const std::shared_ptr<sc::DataTransformation>& mpDataTransformation)
207 mbDeterministic(false),
208 mrDataSource(rDataSource)
225 bool bShrunk =
false;
230 rDoc.
ShrinkToUsedDataArea(bShrunk, 0, nStartCol, nStartRow, nEndCol, nEndRow,
false,
true,
true);
231 ScRange aClipRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0);
251 maDBName(
std::move(aDBName)),
279 const OUString& rDataProvider = rDataSource.
getProvider();
283 if (rDataProvider ==
"org.libreoffice.calc.csv")
284 return std::make_shared<CSVDataProvider>(pDoc, rDataSource);
285 else if (rDataProvider ==
"org.libreoffice.calc.html")
286 return std::make_shared<HTMLDataProvider>(pDoc, rDataSource);
287 else if (rDataProvider ==
"org.libreoffice.calc.xml")
288 return std::make_shared<XMLDataProvider>(pDoc, rDataSource);
289 else if (rDataProvider ==
"org.libreoffice.calc.sql")
290 return std::make_shared<SQLDataProvider>(pDoc, rDataSource);
294 SAL_WARN(
"sc",
"no external data provider supported yet");
295 return std::shared_ptr<DataProvider>();
298 return std::shared_ptr<DataProvider>();
303 std::vector<OUString> aDataProviders;
304 aDataProviders.emplace_back(
"org.libreoffice.calc.csv");
305 aDataProviders.emplace_back(
"org.libreoffice.calc.html");
306 aDataProviders.emplace_back(
"org.libreoffice.calc.xml");
307 aDataProviders.emplace_back(
"org.libreoffice.calc.sql");
309 return aDataProviders;
ScDBData * findByUpperName(const OUString &rName)
const OUString & GetName() const
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC void CopyFromClip(const ScRange &rDestRange, const ScMarkData &rMark, InsertDeleteFlags nInsFlag, ScDocument *pRefUndoDoc, ScDocument *pClipDoc, bool bResetCut=true, bool bAsLink=false, bool bIncludeFiltered=true, bool bSkipEmptyCells=false, const ScRangeList *pDestRanges=nullptr)
Paste data from a clipboard document into this document.
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
void SetClipArea(const ScRange &rArea, bool bCut=false)
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, ScDataAreaExtras *pDataAreaExtras=nullptr) const
Shrink a range to only include used data area.
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
SfxObjectShell * GetDocumentShell() const
static SC_DLLPUBLIC const CharClass & getCharClass()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectTable(SCTAB nTab, bool bNew)
static std::vector< OUString > getDataProviders()
static std::shared_ptr< DataProvider > getDataProvider(ScDocument *pDoc, sc::ExternalDataSource &rDataSource)
static bool isInternalDataProvider(std::u16string_view rProvider)
static std::unique_ptr< SvStream > FetchStreamFromURL(const OUString &, OStringBuffer &rBuffer)
bool mbDeterministic
If true make the threaded import deterministic for the tests.
DataProvider(sc::ExternalDataSource &rDataSource)
void insertDataSource(const ExternalDataSource &rSource)
std::vector< ExternalDataSource > maDataSources
const std::vector< ExternalDataSource > & getDataSources() const
ExternalDataMapper(ScDocument &rDoc)
const ScOrcusImportXMLParam & getXMLImportParam() const
std::shared_ptr< DataProvider > mpDataProvider
const OUString & getProvider() const
void setXMLImportParam(const ScOrcusImportXMLParam &rParam)
void setID(const OUString &rID)
static double getUpdateFrequency()
std::vector< std::shared_ptr< sc::DataTransformation > > maDataTransformations
void setProvider(const OUString &rProvider)
void refresh(ScDocument *pDoc, bool bDeterministic=false)
const OUString & getID() const
const std::vector< std::shared_ptr< sc::DataTransformation > > & getDataTransformation() const
ScOrcusImportXMLParam maParam
void setURL(const OUString &rURL)
OUString maURL
The URL for the external data provider.
OUString maID
The ID allows the same data provider to support different data streams.
OUString getDBName() const
void setDBData(const OUString &rDBName)
std::shared_ptr< ScDBDataManager > mpDBDataManager
void AddDataTransformation(const std::shared_ptr< sc::DataTransformation > &mpDataTransformation)
ExternalDataSource(OUString aURL, OUString aProvider, ScDocument *pDoc)
OUString maProvider
The data provider is a unique identifier that will allow to identify and instantiate the required dat...
const OUString & getURL() const
ScDBDataManager * getDBManager()
This class handles the copying of the data from the imported temporary document to the actual documen...
void WriteToDoc(ScDocument &rDoc)
void SetDatabase(const OUString &rDBName)
ScDBDataManager(OUString aDBName, ScDocument *pDoc)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
CAUTION! The following defines must be in the same namespace as the respective type.