[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Thu Mar 28 15:47:29 PDT 2013
sc/inc/column.hxx | 2 ++
sc/inc/document.hxx | 4 ++++
sc/inc/table.hxx | 2 ++
sc/source/core/data/cellvalue.cxx | 35 ++++++++++-------------------------
sc/source/core/data/column2.cxx | 30 ++++++++++++++++++++++++++++++
sc/source/core/data/documen2.cxx | 7 +++++++
sc/source/core/data/formulacell.cxx | 1 +
sc/source/core/data/table1.cxx | 9 +++++++++
8 files changed, 65 insertions(+), 25 deletions(-)
New commits:
commit b7135b061d98a16ad821edcbee5899e3410f909b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Mar 28 18:49:05 2013 -0400
Slightly more efficient assign().
The old code performed array lookup twice; once for the cell type and twice
for the value fetch. The new code does lookup only once.
Change-Id: Ic6f5927b5536a73cb0a5c00a6c3a12ff0cd1f1e0
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index b5d95a4..fec98d9 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -442,6 +442,8 @@ public:
ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
+ ScRefCellValue GetRefCellValue( SCROW );
+
void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
private:
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d83f044..7a35f98 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -144,6 +144,7 @@ class SvtListener;
class ScNotes;
class ScEditDataArray;
class EditTextObject;
+class ScRefCellValue;
namespace com { namespace sun { namespace star {
namespace lang {
@@ -217,6 +218,7 @@ friend class ScDocRowHeightUpdater;
friend class ScColumnTextWidthIterator;
friend class ScFormulaCell;
friend class ScTable;
+friend class ScRefCellValue;
typedef ::std::vector<ScTable*> TableContainer;
private:
@@ -1976,6 +1978,8 @@ private: // CLOOK-Impl-methods
void PutCell( const ScAddress&, ScBaseCell* pCell, bool bForceTab = false );
void PutCell(SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell, sal_uLong nFormatIndex, bool bForceTab = false );
+ ScRefCellValue GetRefCellValue( const ScAddress& rPos );
+
std::map< SCTAB, ScSortParam > mSheetSortParams;
};
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index b5d692c..316c7f2 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -818,6 +818,8 @@ public:
ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
+ ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
+
private:
void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index c3a333c..588ccfb 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -188,20 +188,24 @@ void ScCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos )
{
clear();
- meType = rDoc.GetCellType(rPos);
+ ScRefCellValue aRefVal;
+ aRefVal.assign(const_cast<ScDocument&>(rDoc), rPos);
+
+ meType = aRefVal.meType;
switch (meType)
{
case CELLTYPE_STRING:
- mpString = new OUString(rDoc.GetString(rPos));
+ mpString = new OUString(*aRefVal.mpString);
break;
case CELLTYPE_EDIT:
- mpEditText = rDoc.GetEditText(rPos)->Clone();
+ if (aRefVal.mpEditText)
+ mpEditText = aRefVal.mpEditText->Clone();
break;
case CELLTYPE_VALUE:
- mfValue = rDoc.GetValue(rPos);
+ mfValue = aRefVal.mfValue;
break;
case CELLTYPE_FORMULA:
- mpFormula = rDoc.GetFormulaCell(rPos)->Clone();
+ mpFormula = aRefVal.mpFormula->Clone();
break;
default:
meType = CELLTYPE_NONE; // reset to empty.
@@ -398,26 +402,7 @@ void ScRefCellValue::clear()
void ScRefCellValue::assign( ScDocument& rDoc, const ScAddress& rPos )
{
- clear();
-
- meType = rDoc.GetCellType(rPos);
- switch (meType)
- {
- case CELLTYPE_STRING:
- mpString = rDoc.GetStringCell(rPos);
- break;
- case CELLTYPE_EDIT:
- mpEditText = rDoc.GetEditText(rPos);
- break;
- case CELLTYPE_VALUE:
- mfValue = rDoc.GetValue(rPos);
- break;
- case CELLTYPE_FORMULA:
- mpFormula = rDoc.GetFormulaCell(rPos);
- break;
- default:
- meType = CELLTYPE_NONE; // reset to empty.
- }
+ *this = rDoc.GetRefCellValue(rPos);
}
void ScRefCellValue::assign( ScBaseCell& rCell )
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index afd0cff..47013b7 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1543,6 +1543,36 @@ ScFormulaVectorState ScColumn::GetFormulaVectorState( SCROW nRow ) const
return pCell ? pCell->GetVectorState() : FormulaVectorUnknown;
}
+ScRefCellValue ScColumn::GetRefCellValue( SCROW nRow )
+{
+ ScRefCellValue aCell; // start empty
+ SCSIZE nIndex;
+ if (!Search(nRow, nIndex))
+ return aCell;
+
+ ScBaseCell* pCell = maItems[nIndex].pCell;
+ aCell.meType = pCell->GetCellType();
+ switch (aCell.meType)
+ {
+ case CELLTYPE_STRING:
+ aCell.mpString = static_cast<const ScStringCell*>(pCell)->GetStringPtr();
+ break;
+ case CELLTYPE_EDIT:
+ aCell.mpEditText = static_cast<const ScEditCell*>(pCell)->GetData();
+ break;
+ case CELLTYPE_VALUE:
+ aCell.mfValue = static_cast<const ScValueCell*>(pCell)->GetValue();
+ break;
+ case CELLTYPE_FORMULA:
+ aCell.mpFormula = static_cast<ScFormulaCell*>(pCell);
+ break;
+ default:
+ aCell.meType = CELLTYPE_NONE; // reset to empty.
+ }
+
+ return aCell;
+}
+
void ScColumn::SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat )
{
short eOldType = pDocument->GetFormatTable()->GetType(
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index bc61740..74cb9f1 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -599,6 +599,13 @@ void ScDocument::PutCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
}
}
+ScRefCellValue ScDocument::GetRefCellValue( const ScAddress& rPos )
+{
+ if (!TableExists(rPos.Tab()))
+ return ScRefCellValue(); // empty
+
+ return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row());
+}
bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
bool bNotes ) const
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 2044014..1004a7c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -45,6 +45,7 @@
#include "colorscale.hxx"
#include "conditio.hxx"
#include "globalnames.hxx"
+#include "cellvalue.hxx"
#include <vector>
@@ -2112,6 +2113,14 @@ ScFormulaVectorState ScTable::GetFormulaVectorState( SCCOL nCol, SCROW nRow ) co
return aCol[nCol].GetFormulaVectorState(nRow);
}
+ScRefCellValue ScTable::GetRefCellValue( SCCOL nCol, SCROW nRow )
+{
+ if (!ValidColRow(nCol, nRow))
+ return ScRefCellValue();
+
+ return aCol[nCol].GetRefCellValue(nRow);
+}
+
void ScTable::DeleteConditionalFormat( sal_uLong nIndex )
{
mpCondFormatList->erase(nIndex);
commit e9acedd5bcdc746076b21fd98edf1c433809f6a5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Mar 28 18:05:32 2013 -0400
Fix for the debug build.
Change-Id: Ie0f24d9f7edf3e79f94d32b1ec2d14e2a33691fc
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index dc01d58..f6bf3a1 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -41,6 +41,7 @@
#include "formula/errorcodes.hxx"
#include "svl/intitem.hxx"
+#include "rtl/strbuf.hxx"
#include <boost/bind.hpp>
More information about the Libreoffice-commits
mailing list