[Libreoffice-commits] core.git: Branch 'feature/calc-data-table' - sc/inc sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Jun 30 08:12:02 PDT 2014


 sc/inc/dbdata.hxx                          |    5 +++
 sc/source/core/tool/dbdata.cxx             |   38 +++++++++++++++++++++++++++++
 sc/source/filter/oox/datatablebuffer.cxx   |   11 ++++++++
 sc/source/filter/oox/datatablebuffer.hxx   |    1 
 sc/source/filter/oox/worksheetfragment.cxx |    9 ++++++
 5 files changed, 64 insertions(+)

New commits:
commit 5e0ec00b02cc95341ef3c08f10aab4d9e46a9923
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Jun 30 17:07:47 2014 +0200

    set the data table info to the model
    
    Change-Id: I11c941ada1a5b9f23bfed2604f2a4f495e795b29

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index bb2684a..87a9580 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -34,6 +34,7 @@ struct ScSortParam;
 struct ScQueryParam;
 struct ScSubTotalParam;
 struct ScImportParam;
+struct ScTableData;
 
 class ScDBData : public ScRefreshTimer
 {
@@ -42,6 +43,7 @@ private:
     boost::scoped_ptr<ScQueryParam> mpQueryParam;
     boost::scoped_ptr<ScSubTotalParam> mpSubTotal;
     boost::scoped_ptr<ScImportParam> mpImportParam;
+    boost::scoped_ptr<ScTableData> mpTableData;
 
     /// DBParam
     const OUString aName;
@@ -79,6 +81,7 @@ public:
              SCTAB nTab,
              SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
              bool bByR = true, bool bHasH = true);
+    SC_DLLPUBLIC ScDBData(const OUString& rName, const ScRange& rRange);
     ScDBData(const ScDBData& rData);
     ScDBData(const OUString& rName, const ScDBData& rData);
     virtual ~ScDBData();
@@ -116,6 +119,8 @@ public:
     SC_DLLPUBLIC void       SetQueryParam(const ScQueryParam& rQueryParam);
     SC_DLLPUBLIC bool       GetAdvancedQuerySource(ScRange& rSource) const;
     SC_DLLPUBLIC void       SetAdvancedQuerySource(const ScRange* pSource);
+    SC_DLLPUBLIC void       SetTableData(const ScTableData& rData);
+    SC_DLLPUBLIC void       GetTableData(ScTableData& rData);
 
     void        GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
     void        SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index c5ba011..3573bf3 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -29,6 +29,7 @@
 #include "globstr.hrc"
 #include "subtotalparam.hxx"
 #include "sortparam.hxx"
+#include "tabledata.hxx"
 
 #include <memory>
 
@@ -44,6 +45,33 @@ bool ScDBData::less::operator() (const ScDBData& left, const ScDBData& right) co
     return ScGlobal::GetpTransliteration()->compareString(left.GetUpperName(), right.GetUpperName()) < 0;
 }
 
+ScDBData::ScDBData(const OUString& rName, const ScRange& rRange):
+    mpSortParam(new ScSortParam),
+    mpQueryParam(new ScQueryParam),
+    mpSubTotal(new ScSubTotalParam),
+    mpImportParam(new ScImportParam),
+    mpTableData(new ScTableData),
+    aName       (rName),
+    aUpper      (rName),
+    nTable      (rRange.aStart.Tab()),
+    nStartCol   (rRange.aStart.Col()),
+    nStartRow   (rRange.aStart.Row()),
+    nEndCol     (rRange.aEnd.Col()),
+    nEndRow     (rRange.aEnd.Row()),
+    bByRow      (false), // TODO: moggi: fix it
+    bHasHeader  (false), // TODO: moggi: fix it
+    bDoSize     (false),
+    bKeepFmt    (false),
+    bStripData  (false),
+    bIsAdvanced (false),
+    bDBSelection(false),
+    nIndex      (0),
+    bAutoFilter (false),
+    bModified   (false)
+{
+    aUpper = ScGlobal::pCharClass->uppercase(aUpper);
+}
+
 ScDBData::ScDBData( const OUString& rName,
                     SCTAB nTab,
                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
@@ -403,6 +431,16 @@ void ScDBData::SetImportParam(const ScImportParam& rImportParam)
     mpImportParam.reset(new ScImportParam(rImportParam));
 }
 
+void ScDBData::SetTableData(const ScTableData& rTableData)
+{
+    *mpTableData = rTableData;
+}
+
+void ScDBData::GetTableData(ScTableData& rTableData)
+{
+    rTableData = *mpTableData;
+}
+
 bool ScDBData::IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
 {
     if (nTab == nTable)
diff --git a/sc/source/filter/oox/datatablebuffer.cxx b/sc/source/filter/oox/datatablebuffer.cxx
index 843fb44..36b602e 100644
--- a/sc/source/filter/oox/datatablebuffer.cxx
+++ b/sc/source/filter/oox/datatablebuffer.cxx
@@ -19,6 +19,17 @@ ScTableData& TableDataBuffer::createDataTable(const OUString& rId)
     return aData.first->second;
 }
 
+ScTableData& TableDataBuffer::getTable(const OUString& rId)
+{
+    std::map<OUString, ScTableData>::iterator itr =
+        maTableData.find(rId);
+
+    if(itr != maTableData.end())
+        return itr->second;
+
+    throw std::exception();
+}
+
 }
 }
 
diff --git a/sc/source/filter/oox/datatablebuffer.hxx b/sc/source/filter/oox/datatablebuffer.hxx
index 59bac7a..13e366a 100644
--- a/sc/source/filter/oox/datatablebuffer.hxx
+++ b/sc/source/filter/oox/datatablebuffer.hxx
@@ -21,6 +21,7 @@ class TableDataBuffer
 {
 public:
     ScTableData& createDataTable(const OUString& rId);
+    ScTableData& getTable(const OUString& rId);
 private:
     std::map<OUString, ScTableData> maTableData;
 };
diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx
index 51e4013..70f6a57 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -44,6 +44,9 @@
 #include "worksheetsettings.hxx"
 #include "datatablefragment.hxx"
 
+#include "dbdata.hxx"
+#include "document.hxx"
+
 namespace oox {
 namespace xls {
 
@@ -518,6 +521,12 @@ void WorksheetFragment::importDataTable(const AttributeList& rAttribs)
 {
     OUString aId = rAttribs.getXString(R_TOKEN(id), OUString());
     SAL_INFO("sc.oox", aId);
+    ScTableData& rTableData = getTableDataBuffer().getTable(aId);
+    ScDBData* pDBData = new ScDBData(rTableData.maName, rTableData.maRange);
+    pDBData->SetTableData(rTableData);
+    bool bOk = getScDocument().GetDBCollection()->getNamedDBs().insert(pDBData);
+    if(!bOk)
+        delete pDBData;
 }
 
 void WorksheetFragment::importSheetFormatPr( const AttributeList& rAttribs )


More information about the Libreoffice-commits mailing list