[Libreoffice-commits] core.git: sc/source

Jaskaran Singh jvsg1303 at gmail.com
Thu Dec 29 19:56:58 UTC 2016


 sc/source/ui/docshell/dataprovider.cxx |   30 ++++++++++++++++++++++++++++--
 sc/source/ui/inc/dataprovider.hxx      |   26 +++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 3 deletions(-)

New commits:
commit adc506f22f2a52c120a298d41f697e6d45e1a982
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date:   Thu Dec 29 12:02:00 2016 +0530

    Add ExternalDataMapper class and Implement CSVDataProvider::Refresh()
    
    ExternalDataMapper Class binds ScDBData and Dataprovider together
    
    Change-Id: Ie38b76cf0ee5cbbe9b680b7f934b716e36645cfc
    Reviewed-on: https://gerrit.libreoffice.org/32489
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jaskaran singh <jvsg1303 at gmail.com>

diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx
index 9b4fba3..410178e 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 6e0a9ed..5a09900 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;


More information about the Libreoffice-commits mailing list