diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/dataprovider.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/inc/dataprovider.hxx | 26 |
2 files changed, 53 insertions, 3 deletions
diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx index 9b4fba383d09..410178e80678 100644 --- a/sc/source/ui/docshell/dataprovider.cxx +++ b/sc/source/ui/docshell/dataprovider.cxx @@ -19,6 +19,30 @@ namespace sc { +ExternalDataMapper::ExternalDataMapper(ScDocShell* pDocShell, const OUString& rURL, const OUString& rName, SCTAB nTab, + SCCOL nCol1,SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool& bSuccess): + maRange (ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)), + mpDocShell(pDocShell), + mpDataProvider (new CSVDataProvider(mpDocShell, maURL, maRange)), + mpDBCollection (pDocShell->GetDocument().GetDBCollection()), + maURL(rURL) +{ + bSuccess = true; + ScDBCollection::NamedDBs& rNamedDBS = mpDBCollection->getNamedDBs(); + if(!rNamedDBS.insert (new ScDBData (rName, nTab, nCol1, nRow1, nCol2, nRow2))) + bSuccess = false; +} + +ExternalDataMapper::~ExternalDataMapper() +{ + delete mpDataProvider; +} + +void ExternalDataMapper::StartImport() +{ + mpDataProvider->StartImport(); +} + DataProvider::~DataProvider() { } @@ -124,9 +148,10 @@ void CSVFetchThread::execute() RequestTerminate(); } -CSVDataProvider::CSVDataProvider(const OUString& rURL, const ScRange& rRange): +CSVDataProvider::CSVDataProvider(ScDocShell* pDocShell, const OUString& rURL, const ScRange& rRange): maURL(rURL), mrRange(rRange), + mpDocShell(pDocShell), mbImportUnderway(false) { } @@ -172,7 +197,8 @@ void CSVDataProvider::StopImport() void CSVDataProvider::Refresh() { - + mpDocShell->DoHardRecalc(true); + mpDocShell->SetDocumentModified(); } } diff --git a/sc/source/ui/inc/dataprovider.hxx b/sc/source/ui/inc/dataprovider.hxx index 6e0a9ed49992..5a09900fb9ab 100644 --- a/sc/source/ui/inc/dataprovider.hxx +++ b/sc/source/ui/inc/dataprovider.hxx @@ -18,6 +18,10 @@ #include <osl/mutex.hxx> #include <osl/conditn.hxx> #include <vcl/timer.hxx> +#include <dbdata.hxx> +#include <document.hxx> + +#include "docsh.hxx" #include <queue> @@ -30,6 +34,25 @@ namespace sc { +class DataProvider; + +class ExternalDataMapper +{ + ScRange maRange; + ScDocShell* mpDocShell; + DataProvider* mpDataProvider; + ScDBCollection* mpDBCollection; + + OUString maURL; + +public: + ExternalDataMapper(ScDocShell* pDocShell, const OUString& rUrl, const OUString& rName, + SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCOL2, SCROW nRow2, bool& bSuccess); + ~ExternalDataMapper(); + + void StartImport(); +}; + struct Cell { struct Str @@ -100,11 +123,12 @@ class CSVDataProvider : public DataProvider ScRange mrRange; Timer maImportTimer; rtl::Reference<CSVFetchThread> mxCSVFetchThread; + ScDocShell* mpDocShell; bool mbImportUnderway; public: - CSVDataProvider (const OUString& rUrl, const ScRange& rRange); + CSVDataProvider (ScDocShell* pDocShell, const OUString& rUrl, const ScRange& rRange); virtual ~CSVDataProvider() override; virtual void StartImport() override; |