11 #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
12 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
13 #include <com/sun/star/io/XInputStream.hpp>
14 #include <rtl/strbuf.hxx>
31 std::unique_ptr<SvStream> DataProvider::FetchStreamFromURL(
const OUString& rURL, OStringBuffer& rBuffer)
37 uno::Reference< io::XInputStream >
xStream = xFileAccess->openFileRead( rURL );
39 const sal_Int32 BUF_LEN = 8000;
40 uno::Sequence< sal_Int8 > buffer( BUF_LEN );
43 while ( ( nRead = xStream->readBytes( buffer, BUF_LEN ) ) == BUF_LEN )
45 rBuffer.append( reinterpret_cast< const char* >( buffer.getConstArray() ), nRead );
50 rBuffer.append( reinterpret_cast< const char* >( buffer.getConstArray() ), nRead );
53 xStream->closeInput();
55 SvStream* pStream =
new SvMemoryStream(const_cast<char*>(rBuffer.getStr()), rBuffer.getLength(), StreamMode::READ);
56 return std::unique_ptr<SvStream>(pStream);
65 ExternalDataSource::ExternalDataSource(
const OUString& rURL,
68 , maProvider(rProvider)
170 const std::shared_ptr<sc::DataTransformation>& mpDataTransformation)
205 mbDeterministic(false),
206 mrDataSource(rDataSource)
223 bool bShrunk =
false;
228 rDoc.
ShrinkToUsedDataArea(bShrunk, 0, nStartCol, nStartRow, nEndCol, nEndRow,
false,
true,
true);
229 ScRange aClipRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0);
271 return rProvider.startsWith(
"org.libreoffice.calc");
277 const OUString& rDataProvider = rDataSource.
getProvider();
281 if (rDataProvider ==
"org.libreoffice.calc.csv")
282 return std::make_shared<CSVDataProvider>(pDoc, rDataSource);
283 else if (rDataProvider ==
"org.libreoffice.calc.html")
284 return std::make_shared<HTMLDataProvider>(pDoc, rDataSource);
285 else if (rDataProvider ==
"org.libreoffice.calc.xml")
286 return std::make_shared<XMLDataProvider>(pDoc, rDataSource);
287 else if (rDataProvider ==
"org.libreoffice.calc.sql")
288 return std::make_shared<SQLDataProvider>(pDoc, rDataSource);
292 SAL_WARN(
"sc",
"no external data provider supported yet");
293 return std::shared_ptr<DataProvider>();
296 return std::shared_ptr<DataProvider>();
301 std::vector<OUString> aDataProviders;
302 aDataProviders.emplace_back(
"org.libreoffice.calc.csv");
303 aDataProviders.emplace_back(
"org.libreoffice.calc.html");
304 aDataProviders.emplace_back(
"org.libreoffice.calc.xml");
305 aDataProviders.emplace_back(
"org.libreoffice.calc.sql");
307 return aDataProviders;
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
static std::vector< OUString > getDataProviders()
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 bSkipAttrForEmpty=false, const ScRangeList *pDestRanges=nullptr)
If pDestRanges is given it overrides rDestRange, rDestRange in this case is the overall encompassing ...
ScDBDataManager(const OUString &rDBName, ScDocument *pDoc)
bool mbDeterministic
If true make the threaded import deterministic for the tests.
void AddDataTransformation(const std::shared_ptr< sc::DataTransformation > &mpDataTransformation)
void setProvider(const OUString &rProvider)
This class handles the copying of the data from the imported temporary document to the actual documen...
std::shared_ptr< DataProvider > mpDataProvider
SC_DLLPUBLIC SCROW MaxRow() const
OUString maProvider
The data provider is a unique identifier that will allow to identify and instantiate the required dat...
void setID(const OUString &rID)
void WriteToDoc(ScDocument &rDoc)
void SetClipArea(const ScRange &rArea, bool bCut=false)
SC_DLLPUBLIC SCCOL MaxCol() const
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, bool bConsiderCellNotes=false, bool bConsiderCellDrawObjects=false) const
Shrink a range to only include used data area.
const std::vector< ExternalDataSource > & getDataSources() const
static std::shared_ptr< DataProvider > getDataProvider(ScDocument *pDoc, sc::ExternalDataSource &rDataSource)
std::vector< ExternalDataSource > maDataSources
void SelectTable(SCTAB nTab, bool bNew)
OUString getDBName() const
ScSheetLimits & GetSheetLimits() const
const OUString & getURL() const
void SetDatabase(const OUString &rDBName)
void refresh(ScDocument *pDoc, bool bDeterministic=false)
const OUString & GetName() const
ExternalDataMapper(ScDocument &rDoc)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
std::vector< std::shared_ptr< sc::DataTransformation > > maDataTransformations
const OUString & getProvider() const
ScDBData * findByUpperName(const OUString &rName)
ScDBDataManager * getDBManager()
const ScOrcusImportXMLParam & getXMLImportParam() const
void insertDataSource(const ExternalDataSource &rSource)
DataProvider(sc::ExternalDataSource &rDataSource)
OUString maID
The ID allows the same data provider to support different data streams.
void setURL(const OUString &rURL)
OUString maURL
The URL for the external data provider.
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
static double getUpdateFrequency()
Reference< XComponentContext > getProcessComponentContext()
void setXMLImportParam(const ScOrcusImportXMLParam &rParam)
SfxObjectShell * GetDocumentShell() const
#define SAL_WARN(area, stream)
static bool isInternalDataProvider(const OUString &rProvider)
const std::vector< std::shared_ptr< sc::DataTransformation > > & getDataTransformation() const
const OUString & getID() const
void setDBData(const OUString &rDBName)
std::shared_ptr< ScDBDataManager > mpDBDataManager
ScOrcusImportXMLParam maParam