From 5e0ec00b02cc95341ef3c08f10aab4d9e46a9923 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 30 Jun 2014 17:07:47 +0200 Subject: set the data table info to the model Change-Id: I11c941ada1a5b9f23bfed2604f2a4f495e795b29 --- 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(+) diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index bb2684a409f4..87a9580314e1 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 mpQueryParam; boost::scoped_ptr mpSubTotal; boost::scoped_ptr mpImportParam; + boost::scoped_ptr 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 c5ba011739ff..3573bf3e3571 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 @@ -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 843fb4488613..36b602ef1a18 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::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 59bac7a0937b..13e366ae5f54 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 maTableData; }; diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx index 51e401337e53..70f6a5756565 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 ) -- cgit