[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-08-12 Thread Kohei Yoshida
 sc/inc/sharedformula.hxx  |   10 +-
 sc/source/core/data/column.cxx|9 -
 sc/source/core/tool/sharedformula.cxx |   28 ++--
 sc/source/core/tool/token.cxx |2 +-
 4 files changed, 40 insertions(+), 9 deletions(-)

New commits:
commit 5a29e5b6cebfc4be2856f23807a26f2507995989
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Aug 12 15:23:28 2013 -0400

Do the splitting of formula groups.

Change-Id: I5a8661895b558b67abc19cdc39de9eb027bc1c34

diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index 9423384..0b49751 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -63,7 +63,15 @@ public:
  */
 static void splitFormulaCellGroup(const CellStoreType::position_type 
aPos);
 
-static void splitFormulaCellGroups(CellStoreType rCells, const 
std::vectorSCROW rBounds);
+/**
+ * Split existing shared formula ranges at specified row positions.
+ *
+ * @param rCells cell storage container
+ * @param rBounds row positions at which to split existing shared formula
+ *ranges. Note that this method will directly modify this
+ *parameter to sort and remove duplicates.
+ */
+static void splitFormulaCellGroups(CellStoreType rCells, 
std::vectorSCROW rBounds);
 
 /**
  * See if two specified adjacent formula cells can be merged, and if they
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index a395c78..e4ad8c7 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2364,6 +2364,10 @@ bool ScColumn::UpdateReference( const 
sc::RefUpdateContext rCxt, ScDocument* pU
 if (rCxt.meMode == URM_COPY)
 return UpdateReferenceOnCopy(rCxt, pUndoDoc);
 
+if (IsEmptyData())
+// Cells in this column are all empty.
+return false;
+
 std::vectorSCROW aBounds;
 
 bool bThisColShifted = (rCxt.maRange.aStart.Tab() = nTab  nTab = 
rCxt.maRange.aEnd.Tab() 
@@ -2387,11 +2391,6 @@ bool ScColumn::UpdateReference( const 
sc::RefUpdateContext rCxt, ScDocument* pU
 UpdateRefGroupBoundChecker aBoundChecker(rCxt, aBounds);
 std::for_each(maCells.begin(), maCells.end(), aBoundChecker);
 
-// Sort and remove duplicates.
-std::sort(aBounds.begin(), aBounds.end());
-std::vectorSCROW::iterator it = std::unique(aBounds.begin(), 
aBounds.end());
-aBounds.erase(it, aBounds.end());
-
 // Do the actual splitting.
 sc::SharedFormulaUtil::splitFormulaCellGroups(maCells, aBounds);
 
diff --git a/sc/source/core/tool/sharedformula.cxx 
b/sc/source/core/tool/sharedformula.cxx
index d9f3a25..9299e33 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -64,9 +64,33 @@ void SharedFormulaUtil::splitFormulaCellGroup(const 
CellStoreType::position_type
 }
 }
 
-void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType rCells, const 
std::vectorSCROW rBounds)
+void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType rCells, 
std::vectorSCROW rBounds)
 {
-// TODO: Implement this.
+if (rBounds.empty())
+return;
+
+// Sort and remove duplicates.
+std::sort(rBounds.begin(), rBounds.end());
+std::vectorSCROW::iterator it = std::unique(rBounds.begin(), 
rBounds.end());
+rBounds.erase(it, rBounds.end());
+
+it = rBounds.begin();
+SCROW nRow = *it;
+CellStoreType::position_type aPos = rCells.position(nRow);
+if (aPos.first == rCells.end())
+return;
+
+splitFormulaCellGroup(aPos);
+std::vectorSCROW::iterator itEnd = rBounds.end();
+for (++it; it != itEnd; ++it)
+{
+nRow = *it;
+aPos = rCells.position(aPos.first, nRow);
+if (aPos.first == rCells.end())
+return;
+
+splitFormulaCellGroup(aPos);
+}
 }
 
 void SharedFormulaUtil::joinFormulaCells(const CellStoreType::position_type 
rPos, ScFormulaCell rCell1, ScFormulaCell rCell2)
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1fbf325..e5627ff 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2981,7 +2981,7 @@ void checkBounds(
 SCROW nOffset = rCxt.maRange.aStart.Row() - aAbs.aStart.Row();
 rBounds.push_back(rPos.Row()+nOffset);
 // Ditto.
-nOffset = rCxt.maRange.aEnd.Row() - aAbs.aStart.Row();
+nOffset = rCxt.maRange.aEnd.Row() + 1 - aAbs.aStart.Row();
 rBounds.push_back(rPos.Row()+nOffset);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-08-12 Thread Kohei Yoshida
 sc/inc/formulacell.hxx  |2 +
 sc/source/core/data/formulacell.cxx |   48 +++-
 2 files changed, 38 insertions(+), 12 deletions(-)

New commits:
commit 70216f4fe287a4da04cc895f18a1b4f549c1b392
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Aug 12 15:48:50 2013 -0400

We still need to update cell positions for non-top cells.

Change-Id: If967247ed5d916535e7b52af14b00090b7c9d0d2

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 3318dd2..2e7c724 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -112,6 +112,8 @@ private:
 };
 voidInterpretTail( ScInterpretTailParameter );
 
+bool UpdatePosOnShift( const sc::RefUpdateContext rCxt );
+
 /**
  * Update reference in response to cell insertion or deletion.
  */
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 1753153..1e120ee 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2173,6 +2173,29 @@ bool ScFormulaCell::HasColRowName() const
 return (pCode-GetNextColRowName() != NULL);
 }
 
+bool ScFormulaCell::UpdatePosOnShift( const sc::RefUpdateContext rCxt )
+{
+if (rCxt.meMode != URM_INSDEL)
+// Just in case...
+return false;
+
+if (!rCxt.mnColDelta  !rCxt.mnRowDelta  !rCxt.mnTabDelta)
+// No movement.
+return false;
+
+if (!rCxt.maRange.In(aPos))
+return false;
+
+// This formula cell itself is being shifted during cell range
+// insertion or deletion. Update its position.
+if (mxGroup  mxGroup-mnStart == aPos.Row())
+mxGroup-mnStart += rCxt.mnRowDelta;
+
+aPos.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
+
+return true;
+}
+
 namespace {
 
 /**
@@ -2290,17 +2313,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 if ( pUndoCellPos )
 aUndoPos = *pUndoCellPos;
 ScAddress aOldPos( aPos );
-
-if (rCxt.maRange.In(aPos))
-{
-// This formula cell itself is being shifted during cell range
-// insertion or deletion. Update its position.
-aPos.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
-if (mxGroup  mxGroup-mnStart == aOldPos.Row())
-mxGroup-mnStart += rCxt.mnRowDelta;
-
-bCellStateChanged = aPos != aOldPos;
-}
+bCellStateChanged = UpdatePosOnShift(rCxt);
 
 // Check presence of any references or column row names.
 pCode-Reset();
@@ -2599,8 +2612,19 @@ bool ScFormulaCell::UpdateReference(
 return false;
 
 if (mxGroup  mxGroup-mnStart != aPos.Row())
-// Update only the top cell in case the cell is part of a formula 
group.
+{
+// This is not a top cell of a formula group. Don't update references.
+
+switch (rCxt.meMode)
+{
+case URM_INSDEL:
+return UpdatePosOnShift(rCxt);
+break;
+default:
+;
+}
 return false;
+}
 
 switch (rCxt.meMode)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-08-10 Thread Kohei Yoshida
 sc/inc/formulacell.hxx|1 
 sc/inc/sharedformula.hxx  |4 +
 sc/inc/tokenarray.hxx |3 +
 sc/source/core/data/column.cxx|   63 +++---
 sc/source/core/data/formulacell.cxx   |8 +++
 sc/source/core/tool/sharedformula.cxx |5 ++
 sc/source/core/tool/token.cxx |   82 ++
 7 files changed, 160 insertions(+), 6 deletions(-)

New commits:
commit beb1881c4b82680a63add95dcf6697b38b978c12
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Sat Aug 10 23:31:38 2013 -0400

Collect all boundaries at which to split the formula group.

Change-Id: Ic78d7a06991b983e625b161f11fbbabce02334f3

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 0d258a0..3318dd2 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -336,6 +336,7 @@ public:
 
 bool IsShared() const;
 bool IsSharedInvariant() const;
+bool IsSharedTop() const;
 SCROW GetSharedTopRow() const;
 SCROW GetSharedLength() const;
 ScTokenArray* GetSharedCode();
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index 232c4bc..9423384 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -13,6 +13,8 @@
 #include formulacell.hxx
 #include mtvelements.hxx
 
+#include vector
+
 namespace sc {
 
 class SharedFormulaUtil
@@ -61,6 +63,8 @@ public:
  */
 static void splitFormulaCellGroup(const CellStoreType::position_type 
aPos);
 
+static void splitFormulaCellGroups(CellStoreType rCells, const 
std::vectorSCROW rBounds);
+
 /**
  * See if two specified adjacent formula cells can be merged, and if they
  * can, merge them into the same group.
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 09a9798..00f192d 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -166,6 +166,9 @@ public:
 
 sc::RefUpdateResult AdjustReferenceOnMovedTab( 
sc::RefUpdateMoveTabContext rCxt, const ScAddress rOldPos );
 
+void CheckRelativeReferenceBounds(
+const sc::RefUpdateContext rCxt, const ScAddress rPos, SCROW 
nGroupLen, std::vectorSCROW rBounds ) const;
+
 #if DEBUG_FORMULA_COMPILER
 void Dump() const;
 #endif
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 0171fab..a395c78 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2295,6 +2295,46 @@ public:
 bool isUpdated() const { return mbUpdated; }
 };
 
+class UpdateRefGroupBoundChecker : 
std::unary_functionsc::CellStoreType::value_type, void
+{
+const sc::RefUpdateContext mrCxt;
+std::vectorSCROW mrBounds;
+public:
+UpdateRefGroupBoundChecker(const sc::RefUpdateContext rCxt, 
std::vectorSCROW rBounds) :
+mrCxt(rCxt), mrBounds(rBounds) {}
+
+void operator() (const sc::CellStoreType::value_type node)
+{
+if (node.type != sc::element_type_formula)
+return;
+
+sc::formula_block::const_iterator it = 
sc::formula_block::begin(*node.data);
+sc::formula_block::const_iterator itEnd = 
sc::formula_block::end(*node.data);
+
+// Only pick shared formula cells that are the top cells of their
+// respective shared ranges.
+for (; it != itEnd; ++it)
+{
+const ScFormulaCell rCell = **it;
+if (!rCell.IsShared())
+continue;
+
+if (rCell.IsSharedTop())
+{
+// Check its tokens and record its reference boundaries.
+const ScTokenArray rCode = *rCell.GetCode();
+rCode.CheckRelativeReferenceBounds(
+mrCxt, rCell.aPos, rCell.GetSharedLength(), mrBounds);
+
+// Move to the last cell in the group, to get incremented to
+// the next cell in the next iteration.
+size_t nOffsetToLast = rCell.GetSharedLength() - 1;
+std::advance(it, nOffsetToLast);
+}
+}
+}
+};
+
 }
 
 bool ScColumn::UpdateReferenceOnCopy( const sc::RefUpdateContext rCxt, 
ScDocument* pUndoDoc )
@@ -2324,6 +2364,8 @@ bool ScColumn::UpdateReference( const 
sc::RefUpdateContext rCxt, ScDocument* pU
 if (rCxt.meMode == URM_COPY)
 return UpdateReferenceOnCopy(rCxt, pUndoDoc);
 
+std::vectorSCROW aBounds;
+
 bool bThisColShifted = (rCxt.maRange.aStart.Tab() = nTab  nTab = 
rCxt.maRange.aEnd.Tab() 
 rCxt.maRange.aStart.Col() = nCol  nCol = 
rCxt.maRange.aEnd.Col());
 if (bThisColShifted)
@@ -2333,17 +2375,26 @@ bool ScColumn::UpdateReference( const 
sc::RefUpdateContext rCxt, ScDocument* pU
 SCROW nSplitPos = rCxt.maRange.aStart.Row();
 if (ValidRow(nSplitPos))
 {
-sc::CellStoreType::position_type aPos = 
maCells.position(nSplitPos);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+aBounds.push_back(nSplitPos);

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-30 Thread Kohei Yoshida
 sc/inc/column.hxx|3 +-
 sc/inc/formulacell.hxx   |3 +-
 sc/inc/rangenam.hxx  |7 ++--
 sc/inc/refupdatecontext.hxx  |9 ++
 sc/inc/table.hxx |4 +-
 sc/inc/tokenarray.hxx|3 +-
 sc/source/core/data/colorscale.cxx   |3 +-
 sc/source/core/data/column.cxx   |   14 -
 sc/source/core/data/conditio.cxx |5 ++-
 sc/source/core/data/documen2.cxx |   18 +++-
 sc/source/core/data/formulacell.cxx  |7 +++-
 sc/source/core/data/refupdatecontext.cxx |3 ++
 sc/source/core/data/table1.cxx   |   44 ---
 sc/source/core/tool/rangenam.cxx |   29 ++--
 sc/source/core/tool/token.cxx|   44 +++
 15 files changed, 115 insertions(+), 81 deletions(-)

New commits:
commit 8083253443099269469c7070fd617bef67585e62
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 30 11:45:37 2013 -0400

Adjust named range references on sheet move.

Change-Id: I3b20f79d9c2f373c93a34ccdb308c6d5c09f69e7

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 88b1266..a42ac8f 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -50,6 +50,7 @@ namespace sc {
 struct RefUpdateContext;
 struct RefUpdateInsertTabContext;
 struct RefUpdateDeleteTabContext;
+struct RefUpdateMoveTabContext;
 }
 
 class Fraction;
@@ -327,7 +328,7 @@ public:
 void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt );
 void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext rCxt );
 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt );
-voidUpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
+void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt, SCTAB nTabNo );
 voidUpdateCompile( bool bForceIfNameInUse = false );
 voidUpdateTranspose( const ScRange rSource, const ScAddress 
rDest,
 ScDocument* pUndoDoc );
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 28dbde5..1213959 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -35,6 +35,7 @@ class EndListeningContext;
 struct RefUpdateContext;
 struct RefUpdateInsertTabContext;
 struct RefUpdateDeleteTabContext;
+struct RefUpdateMoveTabContext;
 
 }
 
@@ -214,7 +215,7 @@ public:
 void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt );
 voidUpdateInsertTabAbs(SCTAB nTable);
 bool UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt );
-voidUpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
+void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt, SCTAB nTabNo );
 voidUpdateRenameTab(SCTAB nTable, const OUString rName);
 boolTestTabRefAbs(SCTAB nTable);
 voidUpdateCompile( bool bForceIfNameInUse = false );
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index d18c0a7..4a56ea1 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -37,6 +37,7 @@ namespace sc {
 struct RefUpdateContext;
 struct RefUpdateInsertTabContext;
 struct RefUpdateDeleteTabContext;
+struct RefUpdateMoveTabContext;
 }
 
 typedef sal_uInt16 RangeType;
@@ -75,8 +76,6 @@ private:
 void InitCode();
 public:
 
-enum TabRefUpdateMode { Insert = 1, Delete = 2, Move = 3 };
-
 typedef ::std::mapsal_uInt16, sal_uInt16 IndexMap;
 
 SC_DLLPUBLICScRangeData( ScDocument* pDoc,
@@ -142,9 +141,9 @@ public:
 SC_DLLPUBLIC bool   IsValidReference( ScRange rRef ) const;
 boolIsRangeAtBlock( const ScRange ) const;
 
-void UpdateTabRef(SCTAB nOldTable, TabRefUpdateMode eMode, SCTAB 
nNewTable, SCTAB nNewSheets);
 void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt, SCTAB nLocalTab 
= -1 );
 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt, SCTAB nLocalTab 
= -1 );
+void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt, SCTAB nLocalTab = 
-1 );
 
 voidValidateTabRefs();
 
@@ -195,7 +194,7 @@ public:
 void UpdateReference( sc::RefUpdateContext rCxt, SCTAB nLocalTab = -1 );
 void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt, SCTAB nLocalTab 
= -1 );
 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt, SCTAB nLocalTab 
= -1 );
-void UpdateTabRef(SCTAB nTable, ScRangeData::TabRefUpdateMode eMode, SCTAB 
nNewTable = 0, SCTAB nNewSheets = 1);
+void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt, SCTAB nLocalTab = 
-1 );
 void UpdateTranspose(const ScRange rSource, const ScAddress rDest);
 void UpdateGrow(const ScRange rArea, SCCOL nGrowX, SCROW nGrowY);
 
diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx
index 88ef9d2..380bc84 100644
--- a/sc/inc/refupdatecontext.hxx
+++ b/sc/inc/refupdatecontext.hxx
@@ -101,6 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-30 Thread Kohei Yoshida
 sc/inc/colorscale.hxx|   27 ++-
 sc/inc/conditio.hxx  |   44 --
 sc/inc/refupdatecontext.hxx  |2 
 sc/inc/validat.hxx   |   13 +
 sc/source/core/data/colorscale.cxx   |  125 --
 sc/source/core/data/conditio.cxx |  211 ++-
 sc/source/core/data/documen2.cxx |   26 +--
 sc/source/core/data/documen3.cxx |2 
 sc/source/core/data/document.cxx |   18 +-
 sc/source/core/data/refupdatecontext.cxx |   24 +++
 sc/source/core/data/table1.cxx   |   16 --
 sc/source/core/data/table2.cxx   |8 +
 sc/source/core/data/validat.cxx  |   23 ++-
 sc/source/core/tool/token.cxx|   36 +
 14 files changed, 324 insertions(+), 251 deletions(-)

New commits:
commit 2f9d3f6ba8facbb2a6eac9a8e13b84fdfc7e8932
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 30 15:27:02 2013 -0400

Rework reference update in conditional formatting and cell validation.

No tests are written for this yet.

Change-Id: Ic26a7f19d6ce6e6d7059035dc9c99ae5bcb9d77b

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index e220426..1264f27 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -69,8 +69,10 @@ public:
 formula::FormulaGrammar::Grammar eGrammar = 
formula::FormulaGrammar::GRAM_DEFAULT);
 
 void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab, SCTAB nTabNo);
-void UpdateReference( ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
-const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+void UpdateReference( sc::RefUpdateContext rCxt );
+void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt );
+void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt );
+void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt );
 
 const ScTokenArray* GetFormula() const;
 OUString GetFormula( formula::FormulaGrammar::Grammar eGrammar ) const;
@@ -249,9 +251,10 @@ public:
 void AddEntry(ScColorScaleEntry* pEntry);
 
 virtual void DataChanged(const ScRange rRange);
-virtual void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab);
-virtual void UpdateReference( UpdateRefMode eUpdateRefMode,
-const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+virtual void UpdateReference( sc::RefUpdateContext rCxt );
+virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt );
+virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt );
+virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt );
 
 virtual bool NeedsRepaint() const;
 
@@ -279,9 +282,10 @@ public:
 const ScDataBarFormatData* GetDataBarData() const;
 
 virtual void DataChanged(const ScRange rRange);
-virtual void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab);
-virtual void UpdateReference( UpdateRefMode eUpdateRefMode,
-const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+virtual void UpdateReference( sc::RefUpdateContext rCxt );
+virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt );
+virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt );
+virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt );
 
 virtual bool NeedsRepaint() const;
 
@@ -323,9 +327,10 @@ public:
 const ScIconSetFormatData* GetIconSetData() const;
 
 virtual void DataChanged(const ScRange rRange);
-virtual void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab);
-virtual void UpdateReference( UpdateRefMode eUpdateRefMode,
-const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+virtual void UpdateReference( sc::RefUpdateContext rCxt );
+virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt );
+virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt );
+virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext rCxt );
 
 virtual bool NeedsRepaint() const;
 
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 42ad1f7..7f50a27 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -40,6 +40,15 @@ class ScFormulaCell;
 class ScTokenArray;
 struct ScRefCellValue;
 
+namespace sc {
+
+struct RefUpdateContext;
+struct RefUpdateInsertTabContext;
+struct RefUpdateDeleteTabContext;
+struct RefUpdateMoveTabContext;
+
+}
+
 //  nOptions Flags
 #define SC_COND_NOBLANKS1
 
@@ -111,9 +120,10 @@ public:
 virtual ~ScFormatEntry() {}
 
 virtual condformat::ScFormatEntryType GetType() const = 0;
-virtual void UpdateReference( UpdateRefMode eUpdateRefMode,
-const ScRange rRange, SCsCOL nDx, SCsROW nDy, 
SCsTAB nDz ) = 0;
-virtual void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) = 0;
+virtual void UpdateReference( sc::RefUpdateContext rCxt ) = 0;
+virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt ) = 0;
+virtual void UpdateDeleteTab( 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-30 Thread Kohei Yoshida
 sc/inc/compiler.hxx  |5 
 sc/source/core/inc/refupdat.hxx  |   26 --
 sc/source/core/tool/compiler.cxx |  134 ---
 sc/source/core/tool/refupdat.cxx |  347 ---
 4 files changed, 512 deletions(-)

New commits:
commit badf6557902067afc074f81bdf02c49fde02c045
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 30 15:47:51 2013 -0400

These methods are now unused. Chuck them.

Change-Id: Ib9b0ad855142434e45bcb4d805fc32e7c76b01b8

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 9ecb893..46606d8 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -441,11 +441,6 @@ public:
 static void MoveRelWrap( ScTokenArray rArr, ScDocument* pDoc, const 
ScAddress rPos,
  SCCOL nMaxCol, SCROW nMaxRow );
 
-void UpdateReference( UpdateRefMode eUpdateRefMode,
-  const ScAddress rOldPos, const ScRange,
-  SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-  bool rChanged, bool rRefSizeChanged );
-
 /** If the character is allowed as first character in sheet names or
 references, includes '$' and '?'. */
 static inline bool IsCharWordChar( String const  rStr,
diff --git a/sc/source/core/inc/refupdat.hxx b/sc/source/core/inc/refupdat.hxx
index 8252005..099b173 100644
--- a/sc/source/core/inc/refupdat.hxx
+++ b/sc/source/core/inc/refupdat.hxx
@@ -58,32 +58,6 @@ public:
 sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz,
 ScBigRange rWhat );
 
-/**
- * Update range reference in response to row / column insertion / removal,
- * copy-n-pasting of formula cell, moving of cells etc.
- *
- * @param pDoc
- * @param eUpdateRefMode
- * @param rPos position of formula cell that has the range reference.
- * @param rRange range of cells being shifted.
- * @param nDx
- * @param nDy
- * @param nDz
- * @param rRef range reference object
- * @param eWhat
- *
- * @return ScRefUpdateRes
- */
-static ScRefUpdateRes Update(
-ScDocument* pDoc, UpdateRefMode eUpdateRefMode, const ScAddress rPos,
-const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-ScComplexRefData rRef, ScRange rRefRange, WhatType eWhat = ALL );
-
-/// Before calling, the absolute references must be up-to-date!
-static ScRefUpdateRes Move(
-ScDocument* pDoc, const ScAddress rPos, SCsCOL nDx, SCsROW nDy, 
SCsTAB nDz,
-ScComplexRefData rRef, ScRange rRefRange, bool bWrap, bool bAbsolute 
);
-
 static void MoveRelWrap( ScDocument* pDoc, const ScAddress rPos,
  SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData 
rRef );
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index ed60c30..55668cc 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4137,140 +4137,6 @@ void ScCompiler::MoveRelWrap( ScTokenArray rArr, 
ScDocument* pDoc, const ScAddr
 }
 }
 
-void ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
- const ScAddress rOldPos, const ScRange r,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- bool rChanged, bool rRefSizeChanged )
-{
-rChanged = rRefSizeChanged = false;
-if ( eUpdateRefMode == URM_COPY )
-{   // Normally nothing has to be done here since RelRefs are used, also
-// SharedFormulas don't need any special handling, except if they
-// wrapped around sheet borders.
-// But ColRowName tokens pointing to a ColRow header which was
-// copied along with this formula need to be updated to point to the
-// copied header instead of the old position's new intersection.
-ScToken* t;
-pArr-Reset();
-while( (t = static_castScToken*(pArr-GetNextColRowName())) != NULL )
-{
-ScSingleRefData rRef = t-GetSingleRef();
-ScAddress aNewRef = rRef.toAbs(rOldPos);
-aNewRef.IncCol(nDx);
-aNewRef.IncRow(nDy);
-aNewRef.IncTab(nDz);
-if ( r.In( aNewRef ) )
-{
-SingleDoubleRefModifier aMod(rRef);
-ScComplexRefData rRef2 = aMod.Ref();
-ScRange aRefRange = rRef2.toAbs(rOldPos);
-// yes, this is URM_MOVE
-if (ScRefUpdate::Update(pDoc, URM_MOVE, aPos, r, nDx, nDy, 
nDz, rRef2, aRefRange) != UR_NOTHING)
-{
-rRef2.SetRange(aRefRange, rOldPos);
-rChanged = true;
-}
-}
-}
-
-return;
-}
-
-ScToken* t;
-pArr-Reset();
-while( (t = static_castScToken*(pArr-GetNextReferenceOrName())) != NULL 
)
-{
-if (t-GetType() == svIndex)
-

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-29 Thread Kohei Yoshida
 sc/inc/compiler.hxx  |7 ---
 sc/source/core/tool/compiler.cxx |   88 ---
 2 files changed, 95 deletions(-)

New commits:
commit 804ed5ab354a328a2efbbaf45ab02c5feb971a5e
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jul 29 19:47:46 2013 -0400

These methods are now unused.

Change-Id: Ief17166537b78efb6401f0a310e3acaaae217a65

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 4792f79..9ecb893 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -441,18 +441,11 @@ public:
 static void MoveRelWrap( ScTokenArray rArr, ScDocument* pDoc, const 
ScAddress rPos,
  SCCOL nMaxCol, SCROW nMaxRow );
 
-bool UpdateNameReference( UpdateRefMode eUpdateRefMode,
-  const ScRange,
-  SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-  bool rChanged, bool bSharedFormula = false, 
bool bLocal = false);
-
 void UpdateReference( UpdateRefMode eUpdateRefMode,
   const ScAddress rOldPos, const ScRange,
   SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
   bool rChanged, bool rRefSizeChanged );
 
-bool HasModifiedRange();
-
 /** If the character is allowed as first character in sheet names or
 references, includes '$' and '?'. */
 static inline bool IsCharWordChar( String const  rStr,
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 5e020d5..ed60c30 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4071,50 +4071,6 @@ bool ScCompiler::HandleExternalReference(const 
FormulaToken _aToken)
 return true;
 }
 
-
-//---
-
-
-//---
-// Append token to RPN code
-//---
-
-
-//-
-
-//---
-// RPN creation by recursion
-//---
-
-
-
-//-
-
-bool ScCompiler::HasModifiedRange()
-{
-pArr-Reset();
-for ( FormulaToken* t = pArr-Next(); t; t = pArr-Next() )
-{
-OpCode eOpCode = t-GetOpCode();
-if ( eOpCode == ocName )
-{
-const ScRangeData* pRangeData = GetRangeData( *t);
-if (pRangeData  pRangeData-IsModified())
-return true;
-}
-else if ( eOpCode == ocDBArea )
-{
-ScDBData* pDBData = 
pDoc-GetDBCollection()-getNamedDBs().findByIndex(t-GetIndex());
-if (pDBData  pDBData-IsModified())
-return true;
-}
-}
-return false;
-}
-
-
-//---
-
 template typename T, typename S 
 static S lcl_adjval( S n, T pos, T max, bool bRel )
 {
@@ -4315,50 +4271,6 @@ void ScCompiler::UpdateReference(UpdateRefMode 
eUpdateRefMode,
 }
 }
 
-bool ScCompiler::UpdateNameReference(UpdateRefMode eUpdateRefMode,
- const ScRange r,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- bool rChanged, bool bSharedFormula, bool 
bLocal)
-{
-bool bRelRef = false;   // set if relative reference
-rChanged = false;
-pArr-Reset();
-ScToken* t;
-while ( (t = static_castScToken*(pArr-GetNextReference())) != NULL )
-{
-SingleDoubleRefModifier aMod( *t );
-ScComplexRefData rRef = aMod.Ref();
-bRelRef = rRef.Ref1.IsColRel() || rRef.Ref1.IsRowRel() ||
-rRef.Ref1.IsTabRel();
-if (!bRelRef  t-GetType() == svDoubleRef)
-bRelRef = rRef.Ref2.IsColRel() || rRef.Ref2.IsRowRel() ||
-rRef.Ref2.IsTabRel();
-bool bUpdate = !rRef.Ref1.IsColRel() || !rRef.Ref1.IsRowRel() ||
-!rRef.Ref1.IsTabRel();
-if (!bUpdate  t-GetType() == svDoubleRef)
-bUpdate = !rRef.Ref2.IsColRel() || !rRef.Ref2.IsRowRel() ||
-!rRef.Ref2.IsTabRel();
-if (!bSharedFormula  !bLocal)
-{
-// We cannot update names with sheet-relative references, they may
-// be used on other sheets as well and the resulting reference
-// would be wrong. This is a dilemma if col/row would need to be
-// updated for the current usage.
-bUpdate = bUpdate  !rRef.Ref1.IsTabRel()  
!rRef.Ref2.IsTabRel();
-}
-if (bUpdate)
-{
-ScRange aRefRange = rRef.toAbs(aPos);
-if 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/column.hxx   |2 +-
 sc/inc/document.hxx |4 ++--
 sc/inc/formulacell.hxx  |2 +-
 sc/inc/table.hxx|2 +-
 sc/source/core/data/column.cxx  |   10 --
 sc/source/core/data/document.cxx|   10 --
 sc/source/core/data/formulacell.cxx |2 +-
 sc/source/core/data/table1.cxx  |9 +++--
 sc/source/ui/docshell/docfunc.cxx   |2 +-
 sc/source/ui/view/viewfun2.cxx  |4 ++--
 10 files changed, 20 insertions(+), 27 deletions(-)

New commits:
commit 1af0c0be7cb58bbdbaa0984c7d22498ea8039edb
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 25 21:47:39 2013 -0400

Remove unused parameters to clean it up a bit.

Change-Id: Ief629aea8b0df0b5a340871e13bc1a6e7c244816

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 5ef6cce..9850840 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -324,7 +324,7 @@ public:
 
 void UpdateInsertTab(SCTAB nInsPos, SCTAB nNewSheets = 1);
 void UpdateInsertTabOnlyCells(SCTAB nInsPos, SCTAB nNewSheets = 1);
-void UpdateDeleteTab(SCTAB nDelPos, bool bIsMove, ScColumn* pRefUndo = 
NULL, SCTAB nSheets = 1);
+void UpdateDeleteTab(SCTAB nDelPos, SCTAB nSheets = 1);
 voidUpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
 voidUpdateCompile( bool bForceIfNameInUse = false );
 voidUpdateTranspose( const ScRange rSource, const ScAddress 
rDest,
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d730a6f..09f0874 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -589,8 +589,8 @@ public:
 bool bExternalDocument = false );
 SC_DLLPUBLIC bool   InsertTabs( SCTAB nPos, const 
std::vectorOUString rNames,
 bool bExternalDocument = false, bool 
bNamesValid = false );
-SC_DLLPUBLIC bool   DeleteTabs( SCTAB nTab, SCTAB nSheets, 
ScDocument* pRefUndoDoc = NULL );
-SC_DLLPUBLIC bool   DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc 
= NULL );
+SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets );
+SC_DLLPUBLIC bool DeleteTab( SCTAB nTab );
 SC_DLLPUBLIC bool   RenameTab( SCTAB nTab, const OUString rName,
 bool bUpdateRef = true,
 bool bExternalDocument = false );
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 7260ea0..d19c01c 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -211,7 +211,7 @@ public:
 
 voidUpdateInsertTab(SCTAB nTable, SCTAB nNewSheets = 1);
 voidUpdateInsertTabAbs(SCTAB nTable);
-boolUpdateDeleteTab(SCTAB nTable, bool bIsMove = false, SCTAB 
nSheets = 1);
+bool UpdateDeleteTab(SCTAB nTable, SCTAB nSheets = 1);
 voidUpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
 voidUpdateRenameTab(SCTAB nTable, const OUString rName);
 boolTestTabRefAbs(SCTAB nTable);
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 00cc7e5..2ce8cac 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -515,7 +515,7 @@ public:
 voidUpdateGrow( const ScRange rArea, SCCOL nGrowX, SCROW nGrowY );
 
 voidUpdateInsertTab(SCTAB nTable, SCTAB nNewSheets = 1);
-voidUpdateDeleteTab( SCTAB nTable, bool bIsMove, ScTable* pRefUndo 
= NULL, SCTAB nSheets = 1 );
+void UpdateDeleteTab( SCTAB nTable, SCTAB nSheets = 1 );
 voidUpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, 
ScProgress* pProgress );
 voidUpdateCompile( bool bForceIfNameInUse = false );
 voidSetTabNo(SCTAB nNewTab);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index da3cb49..2e63c90 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2443,21 +2443,19 @@ class DeleteTabUpdater
 SCTAB mnDelPos;
 SCTAB mnSheets;
 SCTAB mnTab;
-bool mbIsMove;
 bool mbModified;
 public:
-DeleteTabUpdater(sc::CellTextAttrStoreType rTextAttrs, SCTAB nDelPos, 
SCTAB nSheets, SCTAB nTab, bool bIsMove) :
+DeleteTabUpdater(sc::CellTextAttrStoreType rTextAttrs, SCTAB nDelPos, 
SCTAB nSheets, SCTAB nTab) :
 mrTextAttrs(rTextAttrs),
 miAttrPos(rTextAttrs.begin()),
 mnDelPos(nDelPos),
 mnSheets(nSheets),
 mnTab(nTab),
-mbIsMove(bIsMove),
 mbModified(false) {}
 
 void operator() (size_t, ScFormulaCell* pCell)
 {
-pCell-UpdateDeleteTab(mnDelPos, mbIsMove, mnSheets);
+pCell-UpdateDeleteTab(mnDelPos, mnSheets);
 mbModified = true;
 }
 
@@ -2892,7 +2890,7 @@ void ScColumn::UpdateInsertTabOnlyCells(SCTAB nInsPos, 
SCTAB nNewSheets)
 CellStorageModified();
 }
 
-void ScColumn::UpdateDeleteTab(SCTAB nDelPos, bool bIsMove, ScColumn* 
/*pRefUndo*/, SCTAB 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/rangenam.hxx  |   18 --
 sc/source/core/data/documen2.cxx |4 +--
 sc/source/core/data/document.cxx |8 +++---
 sc/source/core/data/table1.cxx   |   19 +-
 sc/source/core/tool/rangenam.cxx |   50 ++-
 5 files changed, 37 insertions(+), 62 deletions(-)

New commits:
commit df1e34997beb78fcd2622678209571469dc6bdc1
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 25 22:17:28 2013 -0400

Let's not use numerical magic numbers. Prefer enum.

Change-Id: I84d14dd06a2b28d7a8a1544f26eae180b6ea86b5

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 436f82a..4a5944f 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -30,13 +30,8 @@
 #include boost/ptr_container/ptr_set.hpp
 #include boost/ptr_container/ptr_map.hpp
 
-//
-
 class ScDocument;
-
-
-
-//
+class ScTokenArray;
 
 typedef sal_uInt16 RangeType;
 
@@ -52,10 +47,6 @@ typedef sal_uInt16 RangeType;
 #define RT_SHARED   ((RangeType)0x0100)
 #define RT_SHAREDMOD((RangeType)0x0200)
 
-//
-
-class ScTokenArray;
-
 class ScRangeData
 {
 private:
@@ -77,6 +68,9 @@ private:
 void CompileRangeData( const String rSymbol, bool bSetError );
 void InitCode();
 public:
+
+enum TabRefUpdateMode { Insert = 1, Delete = 2, Move = 3 };
+
 typedef ::std::mapsal_uInt16, sal_uInt16 IndexMap;
 
 SC_DLLPUBLICScRangeData( ScDocument* pDoc,
@@ -139,7 +133,7 @@ public:
 SC_DLLPUBLIC bool   IsValidReference( ScRange rRef ) const;
 boolIsRangeAtBlock( const ScRange ) const;
 
-voidUpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB 
nNewTable, SCTAB nNewSheets);
+void UpdateTabRef(SCTAB nOldTable, TabRefUpdateMode eMode, SCTAB 
nNewTable, SCTAB nNewSheets);
 
 voidValidateTabRefs();
 
@@ -189,7 +183,7 @@ public:
 SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i) const;
 void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange rRange,
  SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bLocal = 
false);
-void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0, 
SCTAB nNewSheets = 1);
+void UpdateTabRef(SCTAB nTable, ScRangeData::TabRefUpdateMode eMode, SCTAB 
nNewTable = 0, SCTAB nNewSheets = 1);
 void UpdateTranspose(const ScRange rSource, const ScAddress rDest);
 void UpdateGrow(const ScRange rArea, SCCOL nGrowX, SCROW nGrowY);
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d5ddbd4..72f912f 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -712,7 +712,7 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, 
ScProgress* pProgress )
 SCsTAB nDz = ((SCsTAB)nNewPos) - (SCsTAB)nOldPos;
 ScRange aSourceRange( 0,0,nOldPos, MAXCOL,MAXROW,nOldPos );
 if (pRangeName)
-pRangeName-UpdateTabRef(nOldPos, 3, nNewPos);
+pRangeName-UpdateTabRef(nOldPos, ScRangeData::Move, nNewPos);
 pDBCollection-UpdateMoveTab( nOldPos, nNewPos );
 xColNameRanges-UpdateReference( URM_REORDER, this, aSourceRange, 
0,0,nDz );
 xRowNameRanges-UpdateReference( URM_REORDER, this, aSourceRange, 
0,0,nDz );
@@ -799,7 +799,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, 
const ScMarkData* pOnlyM
 xColNameRanges-UpdateReference( URM_INSDEL, this, aRange, 
0,0,1 );
 xRowNameRanges-UpdateReference( URM_INSDEL, this, aRange, 
0,0,1 );
 if (pRangeName)
-pRangeName-UpdateTabRef(nNewPos, 1);
+pRangeName-UpdateTabRef(nNewPos, ScRangeData::Insert);
 pDBCollection-UpdateReference(
 URM_INSDEL, 0,0,nNewPos, 
MAXCOL,MAXROW,MAXTAB, 0,0,1 );
 if (pDPCollection)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1a4d379..8cbb01f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -461,7 +461,7 @@ bool ScDocument::InsertTab( SCTAB nPos, const OUString 
rName,
 xColNameRanges-UpdateReference( URM_INSDEL, this, aRange, 
0,0,1 );
 xRowNameRanges-UpdateReference( URM_INSDEL, this, aRange, 
0,0,1 );
 if (pRangeName)
-pRangeName-UpdateTabRef( nPos, 1 );
+pRangeName-UpdateTabRef(nPos, ScRangeData::Insert);
 pDBCollection-UpdateReference(
 URM_INSDEL, 0,0,nPos, 
MAXCOL,MAXROW,MAXTAB, 0,0,1 );
 if (pDPCollection)
@@ -546,7 +546,7 @@ bool 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/compiler.hxx  |1 
 sc/source/core/tool/compiler.cxx |  109 ---
 2 files changed, 110 deletions(-)

New commits:
commit 76936cc9045e8d663d43edb670cd0369b61400d2
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 25 22:24:47 2013 -0400

Nobody uses this method now. Chuck it.

Change-Id: I2d55b2e43cf87895f29fd69226ec96c5d75e3696

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 5cc2498..adaa339 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -457,7 +457,6 @@ public:
   const ScAddress rOldPos, const ScRange,
   SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
 
-ScRangeData* UpdateInsertTab(SCTAB nTable, bool bIsName, SCTAB nNewSheets 
= 1 );
 ScRangeData* UpdateDeleteTab(SCTAB nTable, bool bIsMove, bool bIsName, 
bool bCompile, SCTAB nSheets = 1);
 ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, bool bIsName );
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 77793da..a2cc262 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4424,115 +4424,6 @@ void ScCompiler::UpdateSharedFormulaReference( 
UpdateRefMode eUpdateRefMode,
 }
 }
 
-
-ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, bool bIsName , SCTAB 
nNewSheets)
-{
-ScRangeData* pRangeData = NULL;
-SCTAB nPosTab = aPos.Tab(); // _after_ incremented!
-SCTAB nOldPosTab = ((nPosTab  nTable) ? (nPosTab - nNewSheets) : nPosTab);
-bool bIsRel = false;
-ScToken* t;
-pArr-Reset();
-if (bIsName)
-t = static_castScToken*(pArr-GetNextReference());
-else
-t = static_castScToken*(pArr-GetNextReferenceOrName());
-while( t )
-{
-if( t-GetOpCode() == ocName )
-{
-if (!bIsName)
-{
-ScRangeData* pName = GetRangeData( *t);
-if (pName  pName-HasType(RT_SHAREDMOD))
-pRangeData = pName;
-}
-}
-else if( t-GetType() != svIndex )  // it may be a DB area!!!
-{
-if ( !(bIsName  t-GetSingleRef().IsTabRel()) )
-{   // of names only adjust absolute references
-ScSingleRefData rRef = t-GetSingleRef();
-if ( rRef.IsTabRel() )
-{
-rRef.nTab = rRef.nRelTab + nOldPosTab;
-if ( rRef.nTab  0 )
-rRef.nTab = sal::static_int_castSCsTAB( rRef.nTab + 
pDoc-GetTableCount() );  // was a wrap
-}
-if (nTable = rRef.nTab)
-rRef.nTab += nNewSheets;
-rRef.nRelTab = rRef.nTab - nPosTab;
-}
-else
-bIsRel = true;
-if ( t-GetType() == svDoubleRef )
-{
-if ( !(bIsName  t-GetDoubleRef().Ref2.IsTabRel()) )
-{   // of names only adjust absolute references
-ScSingleRefData rRef = t-GetDoubleRef().Ref2;
-if ( rRef.IsTabRel() )
-{
-rRef.nTab = rRef.nRelTab + nOldPosTab;
-if ( rRef.nTab  0 )
-rRef.nTab = sal::static_int_castSCsTAB( 
rRef.nTab + pDoc-GetTableCount() );  // was a wrap
-}
-if (nTable = rRef.nTab)
-rRef.nTab += nNewSheets;
-rRef.nRelTab = rRef.nTab - nPosTab;
-}
-else
-bIsRel = true;
-}
-if ( bIsName  bIsRel )
-pRangeData = (ScRangeData*) this;   // not dereferenced in 
rangenam
-}
-if (bIsName)
-t = static_castScToken*(pArr-GetNextReference());
-else
-t = static_castScToken*(pArr-GetNextReferenceOrName());
-}
-if ( !bIsName )
-{
-pArr-Reset();
-while ( (t = static_castScToken*(pArr-GetNextReferenceRPN())) != 
NULL )
-{
-if ( t-GetRef() == 1 )
-{
-ScSingleRefData rRef1 = t-GetSingleRef();
-if ( !(rRef1.IsRelName()  rRef1.IsTabRel()) )
-{   // of names only adjust absolute references
-if ( rRef1.IsTabRel() )
-{
-rRef1.nTab = rRef1.nRelTab + nOldPosTab;
-if ( rRef1.nTab  0 )
-rRef1.nTab = sal::static_int_castSCsTAB( 
rRef1.nTab + pDoc-GetTableCount() );  // was a wrap
-}
-if (nTable = rRef1.nTab)
-rRef1.nTab += nNewSheets;
-rRef1.nRelTab = rRef1.nTab - nPosTab;
-}
-if ( t-GetType() == svDoubleRef )
-{
-ScSingleRefData rRef2 = 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/compiler.hxx  |1 
 sc/source/core/data/conditio.cxx |   12 +-
 sc/source/core/tool/compiler.cxx |  188 ---
 3 files changed, 6 insertions(+), 195 deletions(-)

New commits:
commit 27aed32209a71d86c32ee352538f9c9731f89cb2
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 25 22:35:47 2013 -0400

Make this guy unused, and remove it.

Change-Id: Ib4a2f195b3ff1d291b0ffe99c27b1d3e807252d5

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index adaa339..687d544 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -457,7 +457,6 @@ public:
   const ScAddress rOldPos, const ScRange,
   SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
 
-ScRangeData* UpdateDeleteTab(SCTAB nTable, bool bIsMove, bool bIsName, 
bool bCompile, SCTAB nSheets = 1);
 ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, bool bIsName );
 
 bool HasModifiedRange();
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 9f1db33..0d7cf36 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -544,12 +544,12 @@ void ScConditionEntry::UpdateReference( UpdateRefMode 
eUpdateRefMode,
 lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), 
bChanged1, nDz );
 else
 {
-ScCompiler aComp( mpDoc, aSrcPos, *pFormula1 );
-aComp.SetGrammar(mpDoc-GetGrammar());
 if ( bDeleteTab )
-aComp.UpdateDeleteTab( rRange.aStart.Tab(), false, true, 
bChanged1, static_castSCTAB(-1 * nDz) );
+pFormula1-AdjustReferenceOnDeletedTab(rRange.aStart.Tab(), 
static_castSCTAB(-1*nDz), aSrcPos);
 else
 {
+ScCompiler aComp( mpDoc, aSrcPos, *pFormula1 );
+aComp.SetGrammar(mpDoc-GetGrammar());
 bool bSizeChanged;
 aComp.UpdateReference( eUpdateRefMode, aOldSrcPos, rRange, nDx,
 nDy, nDz, bChanged1, bSizeChanged );
@@ -566,12 +566,12 @@ void ScConditionEntry::UpdateReference( UpdateRefMode 
eUpdateRefMode,
 lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), 
bChanged2, nDz );
 else
 {
-ScCompiler aComp( mpDoc, aSrcPos, *pFormula2);
-aComp.SetGrammar(mpDoc-GetGrammar());
 if ( bDeleteTab )
-aComp.UpdateDeleteTab( rRange.aStart.Tab(), false, true, 
bChanged2, static_castSCTAB(-1*nDz) );
+pFormula2-AdjustReferenceOnDeletedTab(rRange.aStart.Tab(), 
static_castSCTAB(-1*nDz), aSrcPos);
 else
 {
+ScCompiler aComp( mpDoc, aSrcPos, *pFormula2);
+aComp.SetGrammar(mpDoc-GetGrammar());
 bool bSizeChanged;
 aComp.UpdateReference( eUpdateRefMode, aOldSrcPos, rRange, nDx,
 nDy, nDz, bChanged2, bSizeChanged );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a2cc262..6c5107b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4424,194 +4424,6 @@ void ScCompiler::UpdateSharedFormulaReference( 
UpdateRefMode eUpdateRefMode,
 }
 }
 
-ScRangeData* ScCompiler::UpdateDeleteTab(SCTAB nTable, bool /* bIsMove */, 
bool bIsName,
- bool rChanged, SCTAB nSheets)
-{
-ScRangeData* pRangeData = NULL;
-SCTAB nTab, nTab2;
-SCTAB nPosTab = aPos.Tab();  // _after_ decremented!
-SCTAB nOldPosTab = ((nPosTab = nTable) ? (nPosTab + nSheets) : nPosTab);
-rChanged = false;
-bool bIsRel = false;
-ScToken* t;
-pArr-Reset();
-if (bIsName)
-t = static_castScToken*(pArr-GetNextReference());
-else
-t = static_castScToken*(pArr-GetNextReferenceOrName());
-while( t )
-{
-if( t-GetOpCode() == ocName )
-{
-if (!bIsName)
-{
-ScRangeData* pName = GetRangeData( *t);
-if (pName  pName-HasType(RT_SHAREDMOD))
-pRangeData = pName;
-}
-rChanged = true;
-}
-else if( t-GetType() != svIndex )  // it may be a DB area!!!
-{
-if ( !(bIsName  t-GetSingleRef().IsTabRel()) )
-{   // of names only adjust absolute references
-ScSingleRefData rRef = t-GetSingleRef();
-if ( rRef.IsTabRel() )
-nTab = rRef.nTab = rRef.nRelTab + nOldPosTab;
-else
-nTab = rRef.nTab;
-if ( nTable  nTab )
-{
-rRef.nTab = nTab - nSheets;
-rChanged = true;
-}
-else if ( nTable == nTab )
-{
-if ( t-GetType() == svDoubleRef )
-{
- 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/compiler.hxx  |8 -
 sc/source/core/data/conditio.cxx |9 -
 sc/source/core/tool/compiler.cxx |  250 ---
 3 files changed, 3 insertions(+), 264 deletions(-)

New commits:
commit 4ba6b270c25f373f5c21b4b3302d83219654ee3c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 25 22:45:15 2013 -0400

More on removing unused methods after some adjustments.

Change-Id: Ib838f25094c7c90a6623293e61f56b66b659

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 687d544..4792f79 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -451,14 +451,6 @@ public:
   SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
   bool rChanged, bool rRefSizeChanged );
 
-/// Only once for converted shared formulas,
-/// token array has to be compiled afterwards.
-void UpdateSharedFormulaReference( UpdateRefMode eUpdateRefMode,
-  const ScAddress rOldPos, const ScRange,
-  SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
-
-ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, bool bIsName );
-
 bool HasModifiedRange();
 
 /** If the character is allowed as first character in sheet names or
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 0d7cf36..3fb8a5f 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -587,16 +587,13 @@ void ScConditionEntry::UpdateMoveTab( SCTAB nOldPos, 
SCTAB nNewPos )
 {
 if (pFormula1)
 {
-ScCompiler aComp( mpDoc, aSrcPos, *pFormula1);
-aComp.SetGrammar(mpDoc-GetGrammar());
-aComp.UpdateMoveTab(nOldPos, nNewPos, true );
+pFormula1-AdjustReferenceOnMovedTab(nOldPos, nNewPos, aSrcPos);
 DELETEZ(pFCell1);
 }
+
 if (pFormula2)
 {
-ScCompiler aComp( mpDoc, aSrcPos, *pFormula2);
-aComp.SetGrammar(mpDoc-GetGrammar());
-aComp.UpdateMoveTab(nOldPos, nNewPos, true );
+pFormula2-AdjustReferenceOnMovedTab(nOldPos, nNewPos, aSrcPos);
 DELETEZ(pFCell2);
 }
 }
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 6c5107b..4c17edf 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4359,256 +4359,6 @@ bool ScCompiler::UpdateNameReference(UpdateRefMode 
eUpdateRefMode,
 return bRelRef;
 }
 
-
-void ScCompiler::UpdateSharedFormulaReference( UpdateRefMode eUpdateRefMode,
-  const ScAddress rOldPos, const ScRange r,
-  SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
-{
-if ( eUpdateRefMode == URM_COPY )
-return ;
-else
-{
-ScToken* t;
-pArr-Reset();
-while ( (t = static_castScToken*(pArr-GetNextReference())) != NULL )
-{
-if( t-GetType() != svIndex )   // it may be a DB area!!!
-{
-// Absolute references have been already adjusted in the named
-// shared formula itself prior to breaking the shared formula
-// and calling this function. Don't readjust them again.
-SingleDoubleRefModifier aMod( *t );
-ScComplexRefData rRef = aMod.Ref();
-ScComplexRefData aBkp = rRef;
-ScRange aRefRange = rRef.toAbs(rOldPos);
-ScRange aBkpRange = aRefRange;
-ScRefUpdate::Update(pDoc, eUpdateRefMode, aPos, r, nDx, nDy, 
nDz, rRef, aRefRange);
-rRef.SetRange(aRefRange, rOldPos);
-
-// restore absolute parts
-if ( !aBkp.Ref1.IsColRel() )
-{
-rRef.Ref1.nCol = aBkpRange.aStart.Col();
-rRef.Ref1.SetColDeleted( aBkp.Ref1.IsColDeleted() );
-}
-if ( !aBkp.Ref1.IsRowRel() )
-{
-rRef.Ref1.nRow = aBkpRange.aStart.Row();
-rRef.Ref1.SetRowDeleted( aBkp.Ref1.IsRowDeleted() );
-}
-if ( !aBkp.Ref1.IsTabRel() )
-{
-rRef.Ref1.nTab = aBkpRange.aStart.Tab();
-rRef.Ref1.SetTabDeleted( aBkp.Ref1.IsTabDeleted() );
-}
-if ( t-GetType() == svDoubleRef )
-{
-if ( !aBkp.Ref2.IsColRel() )
-{
-rRef.Ref2.nCol = aBkpRange.aEnd.Col();
-rRef.Ref2.SetColDeleted( aBkp.Ref2.IsColDeleted() );
-}
-if ( !aBkp.Ref2.IsRowRel() )
-{
-rRef.Ref2.nRow = aBkpRange.aEnd.Row();
-rRef.Ref2.SetRowDeleted( aBkp.Ref2.IsRowDeleted() );
-}
-if ( !aBkp.Ref2.IsTabRel() )
-{
- 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/refdata.hxx |3 
 sc/source/core/data/column3.cxx|7 -
 sc/source/core/data/conditio.cxx   |4 
 sc/source/core/data/documen4.cxx   |   12 +-
 sc/source/core/tool/chgtrack.cxx   |6 -
 sc/source/core/tool/compiler.cxx   |6 -
 sc/source/core/tool/refdata.cxx|   24 
 sc/source/filter/excel/excform.cxx |   14 +-
 sc/source/ui/unoobj/chart2uno.cxx  |  197 ++---
 9 files changed, 144 insertions(+), 129 deletions(-)

New commits:
commit 73724a9b99346f4e6f55c76b2f1e52acfb4f6774
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jul 26 00:41:07 2013 -0400

More on avoiding direct access to data members.

Change-Id: I5fdc0d248fe9c36418fd02a1e652e4e35a638c8a

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 629e8ae..337b66c 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -67,10 +67,13 @@ struct SC_DLLPUBLIC ScSingleRefData
 
 void SetAbsCol( SCCOL nVal );
 void SetRelCol( SCCOL nVal );
+void IncCol( SCCOL nInc );
 void SetAbsRow( SCROW nVal );
 void SetRelRow( SCROW nVal );
+void IncRow( SCROW nInc );
 void SetAbsTab( SCTAB nVal );
 void SetRelTab( SCTAB nVal );
+void IncTab( SCTAB nInc );
 
 void SetColDeleted( bool bVal );
 bool IsColDeleted() const;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 1e0ec16..f7cc15e 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -909,15 +909,14 @@ void ScColumn::CopyFromClip(
 
 //  Create reference (Source Position)
 ScSingleRefData aRef;
-aRef.nCol = rColumn.nCol;
-//  Adapt nRow
-aRef.nTab = rColumn.nTab;
 aRef.InitFlags(); // - All absolute
+aRef.SetAbsCol(rColumn.nCol);
+aRef.SetAbsTab(rColumn.nTab);
 aRef.SetFlag3D(true);
 
 for (SCROW nDestRow = nRow1; nDestRow = nRow2; nDestRow++)
 {
-aRef.nRow = nDestRow - nDy; // Source row
+aRef.SetAbsRow(nDestRow - nDy); // Source row
 aDestPos.SetRow( nDestRow );
 
 ScTokenArray aArr;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 3fb8a5f..e56f75b 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1389,7 +1389,7 @@ void ScConditionEntry::SourceChanged( const ScAddress 
rChanged )
 nCol2 = rChanged.Col() - aProv.Ref1.Col();
 else
 {
-bHit = ( rChanged.Col() = aProv.Ref1.nCol );
+bHit = (rChanged.Col() = aProv.Ref1.Col());
 nCol2 = MAXCOL;
 }
 if ( aProv.Ref1.IsRowRel() )
@@ -1411,7 +1411,7 @@ void ScConditionEntry::SourceChanged( const ScAddress 
rChanged )
 nCol1 = rChanged.Col() - aProv.Ref2.Col();
 else
 {
-bHit = ( rChanged.Col() = aProv.Ref2.nCol );
+bHit = ( rChanged.Col() = aProv.Ref2.Col() );
 nCol1 = 0;
 }
 if ( aProv.Ref2.IsRowRel() )
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 9499fa0..38f012a 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -74,9 +74,9 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
 {
 ScSingleRefData aRefData;
 aRefData.InitFlags();
-aRefData.nCol = nVCol;
-aRefData.nRow = nVRow;
-aRefData.nTab = nVTab;
+aRefData.SetAbsCol(nVCol);
+aRefData.SetAbsRow(nVRow);
+aRefData.SetAbsTab(nVTab);
 
 ScTokenArray aArr;
 aArr.AddOpCode( ocBackSolver );
@@ -84,9 +84,9 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
 aArr.AddSingleReference( aRefData );
 aArr.AddOpCode( ocSep );
 
-aRefData.nCol = nFCol;
-aRefData.nRow = nFRow;
-aRefData.nTab = nFTab;
+aRefData.SetAbsCol(nFCol);
+aRefData.SetAbsRow(nFRow);
+aRefData.SetAbsTab(nFTab);
 
 aArr.AddSingleReference( aRefData );
 aArr.AddOpCode( ocSep );
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 5265722..e4bb249 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1976,17 +1976,14 @@ static void lcl_InvalidateReference( ScToken rTok, 
const ScBigAddress rPos )
 ScSingleRefData rRef1 = rTok.GetSingleRef();
 if ( rPos.Col()  0 || MAXCOL  rPos.Col() )
 {
-rRef1.nCol = SCCOL_MAX;
 rRef1.SetColDeleted( true );
 }
 if ( rPos.Row()  0 || MAXROW  rPos.Row() )
 {
-rRef1.nRow = SCROW_MAX;
 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-23 Thread Kohei Yoshida
 sc/inc/refdata.hxx  |   36 +++-
 sc/source/core/tool/refdata.cxx |   32 
 2 files changed, 39 insertions(+), 29 deletions(-)

New commits:
commit d46a4ac204ff0d85f94d64d196c75e701d9187d0
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 23 11:16:46 2013 -0400

Make these non-inline.

Change-Id: I99cf45edfe584f69fb6465de84cdcff5842e37a6

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 145da50..ccbc1c5 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -78,9 +78,9 @@ struct SC_DLLPUBLIC ScSingleRefData
 inline  void SetRelName( bool bVal ){ Flags.bRelName = (bVal ? true : 
false ); }
 inline  bool IsRelName() const  { return Flags.bRelName; }
 
-inline  bool Valid() const;
+bool Valid() const;
 /// In external references nTab is -1
-inline  bool ValidExternal() const;
+bool ValidExternal() const;
 
 ScAddress toAbs( const ScAddress rPos ) const;
 void SetAddress( const ScAddress rAddr, const ScAddress rPos );
@@ -96,20 +96,6 @@ struct SC_DLLPUBLIC ScSingleRefData
 #endif
 };
 
-inline bool ScSingleRefData::Valid() const
-{
-return  nCol = 0  nCol = MAXCOL 
-nRow = 0  nRow = MAXROW 
-nTab = 0  nTab = MAXTAB;
-}
-
-inline bool ScSingleRefData::ValidExternal() const
-{
-return  nCol = 0  nCol = MAXCOL 
-nRow = 0  nRow = MAXROW 
-nTab == -1;
-}
-
 /// Complex reference (a range) into the sheet
 struct ScComplexRefData
 {
@@ -134,13 +120,13 @@ struct ScComplexRefData
 Ref1.InitAddress( nCol1, nRow1, nTab1 );
 Ref2.InitAddress( nCol2, nRow2, nTab2 );
 }
-inline bool IsDeleted() const
-{ return Ref1.IsDeleted() || Ref2.IsDeleted(); }
-inline bool Valid() const
-{ return Ref1.Valid()  Ref2.Valid(); }
+
+bool IsDeleted() const;
+bool Valid() const;
+
 /** In external references nTab is -1 for the start tab and -1 for the end
 tab if one sheet, or =0 if more than one sheets. */
-inline  bool ValidExternal() const;
+bool ValidExternal() const;
 
 SC_DLLPUBLIC ScRange toAbs( const ScAddress rPos ) const;
 void SetRange( const ScRange rRange, const ScAddress rPos );
@@ -160,14 +146,6 @@ struct ScComplexRefData
 #endif
 };
 
-inline bool ScComplexRefData::ValidExternal() const
-{
-return Ref1.ValidExternal() 
-Ref2.nCol = 0  Ref2.nCol = MAXCOL 
-Ref2.nRow = 0  Ref2.nRow = MAXROW 
-Ref2.nTab = Ref1.nTab;
-}
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 3d49fa8..a804838 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -75,6 +75,20 @@ bool ScSingleRefData::IsDeleted() const
 return IsColDeleted() || IsRowDeleted() || IsTabDeleted();
 }
 
+bool ScSingleRefData::Valid() const
+{
+return  nCol = 0  nCol = MAXCOL 
+nRow = 0  nRow = MAXROW 
+nTab = 0  nTab = MAXTAB;
+}
+
+bool ScSingleRefData::ValidExternal() const
+{
+return  nCol = 0  nCol = MAXCOL 
+nRow = 0  nRow = MAXROW 
+nTab == -1;
+}
+
 ScAddress ScSingleRefData::toAbs( const ScAddress rPos ) const
 {
 SCCOL nRetCol = Flags.bColRel ? nRelCol + rPos.Col() : nCol;
@@ -292,6 +306,24 @@ ScComplexRefData ScComplexRefData::Extend( const 
ScComplexRefData  rRef, const
 return Extend( rRef.Ref1, rPos).Extend( rRef.Ref2, rPos);
 }
 
+bool ScComplexRefData::IsDeleted() const
+{
+return Ref1.IsDeleted() || Ref2.IsDeleted();
+}
+
+bool ScComplexRefData::Valid() const
+{
+return Ref1.Valid()  Ref2.Valid();
+}
+
+bool ScComplexRefData::ValidExternal() const
+{
+return Ref1.ValidExternal() 
+Ref2.nCol = 0  Ref2.nCol = MAXCOL 
+Ref2.nRow = 0  Ref2.nRow = MAXROW 
+Ref2.nTab = Ref1.nTab;
+}
+
 ScRange ScComplexRefData::toAbs( const ScAddress rPos ) const
 {
 return ScRange(Ref1.toAbs(rPos), Ref2.toAbs(rPos));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-23 Thread Kohei Yoshida
 sc/inc/column.hxx|1 
 sc/inc/table.hxx |   20 ++-
 sc/source/core/data/column.cxx   |   30 ++-
 sc/source/core/data/document.cxx |   50 ++-
 sc/source/core/data/table2.cxx   |7 +
 5 files changed, 94 insertions(+), 14 deletions(-)

New commits:
commit fd340291c4ef579ee42850f9b7842d6afe98877d
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 23 16:02:37 2013 -0400

Broadcast on formula cells containing COLUMN functions on column insertion.

To ensure that the change gets propagated properly. This fixes
testFuncCOLUMN() cppunit test.

Change-Id: Ia1ffc2880b7dae530ceb11c617c3963f7bfaeb00

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 00b2a63..5ef6cce 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -431,6 +431,7 @@ public:
 voidStartAllListeners();
 voidStartNeededListeners(); // only for cells where 
NeedsListening()==true
 voidSetRelNameDirty();
+void BroadcastRecalcOnRefMove();
 
 voidCompileDBFormula();
 voidCompileDBFormula( bool bCreateFormulaString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 0e4305a..00cc7e5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -862,6 +862,24 @@ public:
 
 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, 
size_t nLen );
 
+/**
+ * Have formula cells with NeedsListening() == true start listening to the
+ * document.
+ */
+void StartNeededListeners();
+
+/**
+ * Mark dirty those formula cells that has named ranges with relative
+ * references.
+ */
+void SetRelNameDirty();
+
+/**
+ * Broadcast dirty formula cells that contain functions such as CELL(),
+ * COLUMN() or ROW() which may change its value on move.
+ */
+void BroadcastRecalcOnRefMove();
+
 #if DEBUG_COLUMN_STORAGE
 void DumpFormulaGroups( SCCOL nCol ) const;
 #endif
@@ -968,8 +986,6 @@ private:
 void StartListening( sc::StartListeningContext rCxt, SCCOL nCol, SCROW 
nRow, SvtListener rListener );
 void EndListening( sc::EndListeningContext rCxt, SCCOL nCol, SCROW nRow, 
SvtListener rListener );
 voidStartAllListeners();
-voidStartNeededListeners(); // only for cells where 
NeedsListening()==TRUE
-voidSetRelNameDirty();
 
 voidSetLoadingMedium(bool bLoading);
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 23a740f..da3cb49 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2144,6 +2144,7 @@ void resetColumnPosition(sc::CellStoreType rCells, SCCOL 
nCol)
 
 void ScColumn::SwapCol(ScColumn rCol)
 {
+maBroadcasters.swap(rCol.maBroadcasters);
 maCells.swap(rCol.maCells);
 maCellTextAttrs.swap(rCol.maCellTextAttrs);
 
@@ -2163,7 +2164,6 @@ void ScColumn::SwapCol(ScColumn rCol)
 
 CellStorageModified();
 rCol.CellStorageModified();
-
 }
 
 void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn rCol)
@@ -3004,6 +3004,26 @@ void ScColumn::SetDirtyAfterLoad()
 sc::ProcessFormula(maCells, aFunc);
 }
 
+namespace {
+
+class RecalcOnRefMoveCollector
+{
+std::vectorSCROW maDirtyRows;
+public:
+void operator() (size_t nRow, ScFormulaCell* pCell)
+{
+if (pCell-GetDirty()  pCell-GetCode()-IsRecalcModeOnRefMove())
+maDirtyRows.push_back(nRow);
+}
+
+const std::vectorSCROW getDirtyRows() const
+{
+return maDirtyRows;
+}
+};
+
+}
+
 void ScColumn::SetRelNameDirty()
 {
 sc::AutoCalcSwitch aSwitch(*pDocument, false);
@@ -3011,6 +3031,14 @@ void ScColumn::SetRelNameDirty()
 sc::ProcessFormula(maCells, aFunc);
 }
 
+void ScColumn::BroadcastRecalcOnRefMove()
+{
+sc::AutoCalcSwitch aSwitch(*pDocument, false);
+RecalcOnRefMoveCollector aFunc;
+sc::ProcessFormula(maCells, aFunc);
+BroadcastCells(aFunc.getDirtyRows());
+}
+
 void ScColumn::CalcAll()
 {
 CalcAllHandler aFunc;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index dfc17cf..9cba374 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1334,6 +1334,36 @@ bool ScDocument::CanInsertCol( const ScRange rRange ) 
const
 return bTest;
 }
 
+namespace {
+
+struct StartNeededListenersHandler : std::unary_functionScTable*, void
+{
+void operator() (ScTable* p)
+{
+if (p)
+p-StartNeededListeners();
+}
+};
+
+struct SetRelNameDirtyHandler : std::unary_functionScTable*, void
+{
+void operator() (ScTable* p)
+{
+if (p)
+p-SetRelNameDirty();
+}
+};
+
+struct BroadcastRecalcOnRefMoveHandler : std::unary_functionScTable*, void
+{
+void operator() (ScTable* p)
+{
+if (p)
+p-BroadcastRecalcOnRefMove();
+}
+};
+
+}
 
 bool ScDocument::InsertCol( SCROW 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-22 Thread Kohei Yoshida
 sc/inc/refupdatecontext.hxx  |2 +-
 sc/source/core/data/formulacell.cxx  |5 +++--
 sc/source/core/data/refupdatecontext.cxx |4 ++--
 sc/source/core/tool/token.cxx|   12 +---
 4 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 0c5aed287731f2546fbc73e00786dff9c87a3fb1
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jul 22 19:55:09 2013 -0400

Flag cell state modified when a reference points to a different position.

This fixes testStreamValid() test failure.

Change-Id: Ife406957a723930efb419ba8c566485f4b089d97

diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx
index 8067c3b..af47851 100644
--- a/sc/inc/refupdatecontext.hxx
+++ b/sc/inc/refupdatecontext.hxx
@@ -51,7 +51,7 @@ struct RefUpdateContext
 struct RefUpdateResult
 {
 bool mbValueChanged;
-bool mbRangeSizeModified;
+bool mbReferenceModified;
 
 RefUpdateResult();
 RefUpdateResult(const RefUpdateResult r);
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index e57d5dd..a99041d 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2274,11 +2274,12 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 {
 // Update cell or range references.
 sc::RefUpdateResult aRes = pCode-AdjustReferenceOnShift(rCxt, 
aOldPos);
-bRangeModified = aRes.mbRangeSizeModified;
+bRangeModified = aRes.mbReferenceModified;
 bValChanged = aRes.mbValueChanged;
 }
 
-bCellStateChanged |= bValChanged;
+if (bValChanged || bRangeModified)
+bCellStateChanged = true;
 
 if (bOnRefMove)
 // Cell may reference itself, e.g. ocColumn, ocRow without parameter
diff --git a/sc/source/core/data/refupdatecontext.cxx 
b/sc/source/core/data/refupdatecontext.cxx
index f1ad64c..67e1242 100644
--- a/sc/source/core/data/refupdatecontext.cxx
+++ b/sc/source/core/data/refupdatecontext.cxx
@@ -24,9 +24,9 @@ bool RefUpdateContext::isDeleted() const
 return (meMode == URM_INSDEL)  (mnColDelta  0 || mnRowDelta  0 || 
mnTabDelta  0);
 }
 
-RefUpdateResult::RefUpdateResult() : mbValueChanged(false), 
mbRangeSizeModified(false) {}
+RefUpdateResult::RefUpdateResult() : mbValueChanged(false), 
mbReferenceModified(false) {}
 RefUpdateResult::RefUpdateResult(const RefUpdateResult r) :
-mbValueChanged(r.mbValueChanged), 
mbRangeSizeModified(r.mbRangeSizeModified) {}
+mbValueChanged(r.mbValueChanged), 
mbReferenceModified(r.mbReferenceModified) {}
 
 }
 
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4c8e595..64beedf 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2392,7 +2392,10 @@ sc::RefUpdateResult 
ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
 }
 
 if (rCxt.maRange.In(aAbs))
+{
 aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, 
rCxt.mnTabDelta);
+aRes.mbReferenceModified = true;
+}
 
 rRef.SetAddress(aAbs, aNewPos);
 }
@@ -2419,7 +2422,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( 
const sc::RefUpdateCon
 // The reference range has been shrunk.
 rRef.SetRange(aAbs, aNewPos);
 aRes.mbValueChanged = true;
-aRes.mbRangeSizeModified = true;
+aRes.mbReferenceModified = true;
 break;
 }
 }
@@ -2432,7 +2435,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( 
const sc::RefUpdateCon
 // The reference range has been expanded.
 rRef.SetRange(aAbs, aNewPos);
 aRes.mbValueChanged = true;
-aRes.mbRangeSizeModified = true;
+aRes.mbReferenceModified = true;
 break;
 }
 
@@ -2441,13 +2444,16 @@ sc::RefUpdateResult 
ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
 // The reference range has been expanded on the edge.
 rRef.SetRange(aAbs, aNewPos);
 aRes.mbValueChanged = true;
-aRes.mbRangeSizeModified = true;
+aRes.mbReferenceModified = true;
 break;
 }
 }
 
 if (rCxt.maRange.In(aAbs))
+{
 aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, 
rCxt.mnTabDelta);
+aRes.mbReferenceModified = true;
+}
 else if (rCxt.maRange.Intersects(aAbs))
 {
 // Part of the referenced range is being shifted. This

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-18 Thread Kohei Yoshida
 sc/inc/token.hxx  |6 --
 sc/source/core/tool/token.cxx |   24 
 2 files changed, 30 deletions(-)

New commits:
commit 328f49abc1b5f3a5f5e3c86216e05c91bb89289b
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 18 22:05:00 2013 -0400

Remove CalcAbsIfRel() virtual method from ScToken and all its children.

Change-Id: I8d9c869161356a7adad9c57d34b001ebcf8992ce

diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index e9ddc88..9603a87 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -74,7 +74,6 @@ public:
 virtual ScComplexRefData   GetDoubleRef();
 virtual const ScSingleRefDataGetSingleRef2() const;
 virtual ScSingleRefData  GetSingleRef2();
-virtual voidCalcAbsIfRel( const ScAddress );
 virtual const ScMatrix* GetMatrix() const;
 virtual ScMatrix*   GetMatrix();
 virtual ScJumpMatrix*   GetJumpMatrix() const;
@@ -124,7 +123,6 @@ public:
 ScToken( r ), aSingleRef( r.aSingleRef ) {}
 virtual const ScSingleRefDataGetSingleRef() const;
 virtual ScSingleRefData  GetSingleRef();
-virtual voidCalcAbsIfRel( const ScAddress );
 virtual booloperator==( const formula::FormulaToken 
rToken ) const;
 virtual FormulaToken*   Clone() const { return new 
ScSingleRefToken(*this); }
 
@@ -155,7 +153,6 @@ public:
 virtual ScComplexRefData   GetDoubleRef();
 virtual const ScSingleRefDataGetSingleRef2() const;
 virtual ScSingleRefData  GetSingleRef2();
-virtual voidCalcAbsIfRel( const ScAddress );
 virtual booloperator==( const formula::FormulaToken 
rToken ) const;
 virtual FormulaToken*   Clone() const { return new 
ScDoubleRefToken(*this); }
 
@@ -197,7 +194,6 @@ public:
 virtual const String   GetString() const;
 virtual const ScSingleRefData  GetSingleRef() const;
 virtual ScSingleRefData  GetSingleRef();
-virtual voidCalcAbsIfRel( const ScAddress );
 virtual booloperator==( const formula::FormulaToken 
rToken ) const;
 virtual FormulaToken*   Clone() const { return new 
ScExternalSingleRefToken(*this); }
 };
@@ -224,7 +220,6 @@ public:
 virtual ScSingleRefData   GetSingleRef2();
 virtual const ScComplexRefDataGetDoubleRef() const;
 virtual ScComplexRefData  GetDoubleRef();
-virtual voidCalcAbsIfRel( const ScAddress );
 virtual booloperator==( const formula::FormulaToken 
rToken ) const;
 virtual FormulaToken*   Clone() const { return new 
ScExternalDoubleRefToken(*this); }
 };
@@ -276,7 +271,6 @@ public:
 ScToken( formula::svRefList ) {}
 ScRefListToken( const ScRefListToken  r ) :
 ScToken( r ), aRefList( r.aRefList ) {}
-virtual voidCalcAbsIfRel( const ScAddress );
 virtual const ScRefList*GetRefList() const;
 virtual   ScRefList*GetRefList();
 virtual booloperator==( const formula::FormulaToken 
rToken ) const;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 04a161a..2d1a236 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -704,11 +704,6 @@ ScSingleRefData ScToken::GetSingleRef2()
 return aDummySingleRef;
 }
 
-void ScToken::CalcAbsIfRel( const ScAddress /* rPos */ )
-{
-OSL_FAIL( ScToken::CalcAbsIfRel: virtual dummy called );
-}
-
 const ScMatrix* ScToken::GetMatrix() const
 {
 OSL_FAIL( ScToken::GetMatrix: virtual dummy called );
@@ -747,8 +742,6 @@ ScRefList* ScToken::GetRefList()
 
 const ScSingleRefDataScSingleRefToken::GetSingleRef() const  { return 
aSingleRef; }
 ScSingleRefData  ScSingleRefToken::GetSingleRef(){ return 
aSingleRef; }
-voidScSingleRefToken::CalcAbsIfRel( const ScAddress rPos )
-{ aSingleRef.CalcAbsIfRel( rPos ); }
 bool ScSingleRefToken::operator==( const FormulaToken r ) const
 {
 return FormulaToken::operator==( r )  aSingleRef == static_castconst 
ScToken(r).GetSingleRef();
@@ -770,8 +763,6 @@ const ScComplexRefData 
ScDoubleRefToken::GetDoubleRef() const  { return aDo
 ScComplexRefData   ScDoubleRefToken::GetDoubleRef(){ return 
aDoubleRef; }
 const ScSingleRefDataScDoubleRefToken::GetSingleRef2() const { return 
aDoubleRef.Ref2; }
 ScSingleRefData  ScDoubleRefToken::GetSingleRef2()   { return 
aDoubleRef.Ref2; }
-voidScDoubleRefToken::CalcAbsIfRel( const ScAddress rPos )
-{ aDoubleRef.CalcAbsIfRel( rPos ); }
 bool ScDoubleRefToken::operator==( const FormulaToken r ) const
 {
 return FormulaToken::operator==( r )  aDoubleRef == 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-17 Thread Kohei Yoshida
 sc/inc/compiler.hxx |2 
 sc/source/core/data/formulacell.cxx |   74 +++
 sc/source/core/tool/compiler.cxx|  135 +---
 3 files changed, 51 insertions(+), 160 deletions(-)

New commits:
commit 05bad95ef4e9a501397e492c6ff11707f9908676
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jul 17 23:19:16 2013 -0400

Remove the current shared formula bits.

I'll re-implement this from scratch.

Change-Id: Ib3a80266a89afc0dd581fcf1e1c37790498205e4

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0ab4c68..5cc2498 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -446,7 +446,7 @@ public:
   SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
   bool rChanged, bool bSharedFormula = false, 
bool bLocal = false);
 
-ScRangeData* UpdateReference( UpdateRefMode eUpdateRefMode,
+void UpdateReference( UpdateRefMode eUpdateRefMode,
   const ScAddress rOldPos, const ScRange,
   SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
   bool rChanged, bool rRefSizeChanged );
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 08ea44b..1bafd7b 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2264,7 +2264,6 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 if (pUndoDoc)
 pOldCode.reset(pCode-Clone());
 
-ScRangeData* pSharedCode = NULL;
 bool bValChanged = false;
 bool bRangeModified = false;// any range, not only shared formula
 bool bRefSizeChanged = false;
@@ -2274,7 +2273,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 // Update cell or range references.
 ScCompiler aComp(pDocument, aPos, *pCode);
 aComp.SetGrammar(pDocument-GetGrammar());
-pSharedCode = aComp.UpdateReference(
+aComp.UpdateReference(
 URM_INSDEL, aPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, 
rCxt.mnTabDelta,
 bValChanged, bRefSizeChanged);
 bRangeModified = aComp.HasModifiedRange();
@@ -2305,7 +2304,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 bHasRelName = HasRelNameReference();
 // Reference changed and new listening needed?
 // Except in Insert/Delete without specialties.
-bNewListening = (bRangeModified || pSharedCode || bColRowNameCompile
+bNewListening = (bRangeModified || bColRowNameCompile
 || (bValChanged  (bInDeleteUndo || bRefSizeChanged)) || 
bHasRelName);
 
 if ( bNewListening )
@@ -2314,30 +2313,15 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 
 bool bNeedDirty = false;
 // NeedDirty for changes except for Copy and Move/Insert without RelNames
-if (bRangeModified || pSharedCode || bColRowNameCompile ||
+if (bRangeModified || bColRowNameCompile ||
 (bValChanged  (bHasRelName || bInDeleteUndo || bRefSizeChanged)) || 
bOnRefMove)
 bNeedDirty = true;
 
-if (pUndoDoc  (bValChanged || pSharedCode || bOnRefMove))
+if (pUndoDoc  (bValChanged || bOnRefMove))
 setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, 
cMatrixFlag);
 
 bValChanged = false;
 
-if ( pSharedCode )
-{   // Replace shared formula with own formula
-pDocument-RemoveFromFormulaTree( this );   // update formula count
-delete pCode;
-pCode = pSharedCode-GetCode()-Clone();
-// #i18937# #i110008# call MoveRelWrap, but with the old position
-ScCompiler::MoveRelWrap(*pCode, pDocument, aPos, 
pSharedCode-GetMaxCol(), pSharedCode-GetMaxRow());
-ScCompiler aComp2(pDocument, aPos, *pCode);
-aComp2.SetGrammar(pDocument-GetGrammar());
-aComp2.UpdateSharedFormulaReference(
-URM_INSDEL, aPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, 
rCxt.mnTabDelta);
-bValChanged = true;
-bNeedDirty = true;
-}
-
 if ( ( bCompile = (bCompile || bValChanged || bRangeModified || 
bColRowNameCompile) ) != 0 )
 {
 CompileTokenArray( bNewListening ); // no Listening
@@ -2357,7 +2341,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 }
 }
 
-if ( bNeedDirty  (!bHasRelName || pSharedCode) )
+if (bNeedDirty  !bHasRelName)
 {   // Cut off references, invalid or similar?
 sc::AutoCalcSwitch(*pDocument, false);
 SetDirty();
@@ -2409,7 +2393,6 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 if (pUndoDoc)
 pOldCode.reset(pCode-Clone());
 
-ScRangeData* pSharedCode = NULL;
 bool bValChanged = false;
 bool bRangeModified = false;// any range, not only shared formula
 bool bRefSizeChanged = false;
@@ -2419,7 +2402,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 // Update cell or range references.
 ScCompiler aComp(pDocument, aPos, *pCode);
 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-16 Thread Kohei Yoshida
 sc/inc/reftokenhelper.hxx  |7 ---
 sc/source/core/tool/chartlis.cxx   |8 
 sc/source/core/tool/detfunc.cxx|3 +--
 sc/source/core/tool/reftokenhelper.cxx |   32 +++-
 sc/source/core/tool/token.cxx  |3 +--
 sc/source/ui/unoobj/chart2uno.cxx  |   20 ++--
 sc/source/ui/view/viewfun6.cxx |8 
 7 files changed, 35 insertions(+), 46 deletions(-)

New commits:
commit c24999695d4ba9caec91c7cb2cf8dd02341b0ff0
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 16 10:46:11 2013 -0400

More of the same.

Change-Id: I65902231e714f9b18b2d1ef61434913cb79af847

diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index 0451dad..d7cfa8e 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -45,9 +45,9 @@ public:
 ::std::vectorScTokenRef rRefTokens, const OUString rRangeStr, 
ScDocument* pDoc,
 const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar, 
bool bOnly3DRef = false);
 
-static bool getRangeFromToken(ScRange rRange, const ScTokenRef pToken, 
bool bExternal = false);
+static bool getRangeFromToken(ScRange rRange, const ScTokenRef pToken, 
const ScAddress rPos, bool bExternal = false);
 
-static void getRangeListFromTokens(ScRangeList rRangeList, const 
::std::vectorScTokenRef pTokens);
+static void getRangeListFromTokens(ScRangeList rRangeList, const 
::std::vectorScTokenRef pTokens, const ScAddress rPos);
 
 /**
  * Create a double reference token from a range object.
@@ -59,7 +59,8 @@ public:
 static bool SC_DLLPUBLIC isRef(const ScTokenRef pToken);
 static bool SC_DLLPUBLIC isExternalRef(const ScTokenRef pToken);
 
-static bool SC_DLLPUBLIC intersects(const ::std::vectorScTokenRef 
rTokens, const ScTokenRef pToken);
+static bool SC_DLLPUBLIC intersects(
+const ::std::vectorScTokenRef rTokens, const ScTokenRef pToken, 
const ScAddress rPos);
 
 static void SC_DLLPUBLIC join(::std::vectorScTokenRef rTokens, const 
ScTokenRef pToken);
 
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index df584d4..db5096a 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -245,7 +245,7 @@ void ScChartListener::Update()
 ScRangeListRef ScChartListener::GetRangeList() const
 {
 ScRangeListRef aRLRef(new ScRangeList);
-ScRefTokenHelper::getRangeListFromTokens(*aRLRef, *mpTokens);
+ScRefTokenHelper::getRangeListFromTokens(*aRLRef, *mpTokens, ScAddress());
 return aRLRef;
 }
 
@@ -289,7 +289,7 @@ public:
 else
 {
 ScRange aRange;
-ScRefTokenHelper::getRangeFromToken(aRange, pToken, bExternal);
+ScRefTokenHelper::getRangeFromToken(aRange, pToken, ScAddress(), 
bExternal);
 if (mbStart)
 startListening(aRange);
 else
@@ -365,7 +365,7 @@ void ScChartListener::UpdateChartIntersecting( const 
ScRange rRange )
 ScTokenRef pToken;
 ScRefTokenHelper::getTokenFromRange(pToken, rRange);
 
-if (ScRefTokenHelper::intersects(*mpTokens, pToken))
+if (ScRefTokenHelper::intersects(*mpTokens, pToken, ScAddress()))
 {
 // force update (chart has to be loaded), don't use 
ScChartListener::Update
 mpDoc-UpdateChart(GetName());
@@ -376,7 +376,7 @@ void ScChartListener::UpdateChartIntersecting( const 
ScRange rRange )
 void ScChartListener::UpdateSeriesRanges()
 {
 ScRangeListRef pRangeList(new ScRangeList);
-ScRefTokenHelper::getRangeListFromTokens(*pRangeList, *mpTokens);
+ScRefTokenHelper::getRangeListFromTokens(*pRangeList, *mpTokens, 
ScAddress());
 mpDoc-SetChartRangeList(GetName(), pRangeList);
 }
 
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 517a892..9240811 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1426,8 +1426,7 @@ void ScDetectiveFunc::GetAllSuccs(SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW n
 {
 const ScAddress aPos = aIter.GetPos();
 ScTokenRef pRef(static_castScToken*(p-Clone()));
-pRef-CalcAbsIfRel(aPos);
-if (ScRefTokenHelper::intersects(aSrcRange, pRef))
+if (ScRefTokenHelper::intersects(aSrcRange, pRef, aPos))
 {
 // This address is absolute.
 pRef = ScRefTokenHelper::createRefToken(aPos);
diff --git a/sc/source/core/tool/reftokenhelper.cxx 
b/sc/source/core/tool/reftokenhelper.cxx
index dbacb44..4580c4f 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -121,19 +121,8 @@ void ScRefTokenHelper::compileRangeRepresentation(
 rRefTokens.clear();
 }
 
-namespace {
-
-//may return a relative address
-void singleRefToAddr(const ScSingleRefData rRef, ScAddress rAddr)
-{
-rAddr.SetCol(rRef.nCol);
-

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-16 Thread Kohei Yoshida
 sc/inc/address.hxx   |1 
 sc/source/core/inc/refupdat.hxx  |   32 +++--
 sc/source/core/tool/address.cxx  |   18 ++
 sc/source/core/tool/compiler.cxx |  114 +-
 sc/source/core/tool/refupdat.cxx |  242 +--
 5 files changed, 229 insertions(+), 178 deletions(-)

New commits:
commit d944f0a90527452f0ad15ff3151b295407643908
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 16 23:31:51 2013 -0400

More on removing CalcAbsIfRel().

One test fails. I'll look into that next.

Change-Id: I4a40104187a73953769740fd47d7a917c83bf337

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 84c62cb..2a38827 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -507,6 +507,7 @@ public:
 SC_DLLPUBLIC void Justify();
 SC_DLLPUBLIC void ExtendTo( const ScRange rRange );
 SC_DLLPUBLIC bool Intersects( const ScRange ) const;// do two ranges 
intersect?
+void PutInOrder();
 inline bool operator==( const ScRange r ) const;
 inline bool operator!=( const ScRange r ) const;
 inline bool operator( const ScRange r ) const;
diff --git a/sc/source/core/inc/refupdat.hxx b/sc/source/core/inc/refupdat.hxx
index 1d9f4c2..8252005 100644
--- a/sc/source/core/inc/refupdat.hxx
+++ b/sc/source/core/inc/refupdat.hxx
@@ -58,17 +58,31 @@ public:
 sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz,
 ScBigRange rWhat );
 
-/// Before calling, the absolute references must be up-to-date!
-static ScRefUpdateRes Update( ScDocument* pDoc,
-  UpdateRefMode eUpdateRefMode,
-  const ScAddress rPos, const ScRange rRange,
-  SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-  ScComplexRefData rRef, WhatType eWhat = ALL 
);
+/**
+ * Update range reference in response to row / column insertion / removal,
+ * copy-n-pasting of formula cell, moving of cells etc.
+ *
+ * @param pDoc
+ * @param eUpdateRefMode
+ * @param rPos position of formula cell that has the range reference.
+ * @param rRange range of cells being shifted.
+ * @param nDx
+ * @param nDy
+ * @param nDz
+ * @param rRef range reference object
+ * @param eWhat
+ *
+ * @return ScRefUpdateRes
+ */
+static ScRefUpdateRes Update(
+ScDocument* pDoc, UpdateRefMode eUpdateRefMode, const ScAddress rPos,
+const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
+ScComplexRefData rRef, ScRange rRefRange, WhatType eWhat = ALL );
 
 /// Before calling, the absolute references must be up-to-date!
-static ScRefUpdateRes Move( ScDocument* pDoc, const ScAddress rPos,
-SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-ScComplexRefData rRef, bool bWrap, bool 
bAbsolute );
+static ScRefUpdateRes Move(
+ScDocument* pDoc, const ScAddress rPos, SCsCOL nDx, SCsROW nDy, 
SCsTAB nDz,
+ScComplexRefData rRef, ScRange rRefRange, bool bWrap, bool bAbsolute 
);
 
 static void MoveRelWrap( ScDocument* pDoc, const ScAddress rPos,
  SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData 
rRef );
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index e21aa19..33c653e 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1337,6 +1337,24 @@ bool ScRange::Intersects( const ScRange r ) const
 );
 }
 
+void ScRange::PutInOrder()
+{
+SCCOL nCol1 = aStart.Col(), nCol2 = aEnd.Col();
+SCROW nRow1 = aStart.Row(), nRow2 = aEnd.Row();
+SCTAB nTab1 = aStart.Tab(), nTab2 = aEnd.Tab();
+
+::PutInOrder(nCol1, nCol2);
+::PutInOrder(nRow1, nRow2);
+::PutInOrder(nTab1, nTab2);
+
+aStart.SetCol(nCol1);
+aStart.SetRow(nRow1);
+aStart.SetTab(nTab1);
+
+aEnd.SetCol(nCol2);
+aEnd.SetRow(nRow2);
+aEnd.SetTab(nTab2);
+}
 
 void ScRange::Justify()
 {
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index cd5cef0..494ed65 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4206,13 +4206,16 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode 
eUpdateRefMode,
 aNewRef.IncRow(nDy);
 aNewRef.IncTab(nDz);
 if ( r.In( aNewRef ) )
-{   // yes, this is URM_MOVE
-if ( ScRefUpdate::Update( pDoc, URM_MOVE, aPos,
-r, nDx, nDy, nDz,
-SingleDoubleRefModifier( rRef ).Ref() )
-!= UR_NOTHING
-)
+{
+SingleDoubleRefModifier aMod(rRef);
+ScComplexRefData rRef2 = aMod.Ref();
+ScRange aRefRange = rRef2.toAbs(rOldPos);
+// yes, this is URM_MOVE
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-15 Thread Kohei Yoshida
 sc/inc/refdata.hxx  |   96 
 sc/source/core/tool/refdata.cxx |8 +--
 sc/source/core/tool/token.cxx   |4 -
 3 files changed, 54 insertions(+), 54 deletions(-)

New commits:
commit 651943c037fd2c3afb8942e94033c261f14df338
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jul 15 18:45:02 2013 -0400

Bool cleanup in refdata.?xx.

Change-Id: Ibe5471b909f32939fac5e8a80e67faa0863ea2c4

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 00dbf9b..a742dbf 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -32,7 +32,7 @@ struct OldSingleRefBools
 sal_uInt8bRelCol;/// Flag values (see further down), 2 bits each 
in file format
 sal_uInt8bRelRow;
 sal_uInt8bRelTab;
-sal_uInt8bOldFlag3D; /// two sal_Bool flags (see further down)
+sal_uInt8bOldFlag3D; /// two bool flags (see further down)
 };
 
 /// Single reference (one address) into the sheet
@@ -47,48 +47,48 @@ struct SC_DLLPUBLIC ScSingleRefData
 
 union
 {
-sal_Bool bFlags;
+sal_uInt8 mnFlagValue;
 struct
 {
-sal_BoolbColRel :1;
-sal_BoolbColDeleted :1;
-sal_BoolbRowRel :1;
-sal_BoolbRowDeleted :1;
-sal_BoolbTabRel :1;
-sal_BoolbTabDeleted :1;
-sal_BoolbFlag3D :1; /// 3D-Ref
-sal_BoolbRelName:1; /// Reference derived from 
RangeName with relative values
-}Flags;
+bool bColRel :1;
+bool bColDeleted :1;
+bool bRowRel :1;
+bool bRowDeleted :1;
+bool bTabRel :1;
+bool bTabDeleted :1;
+bool bFlag3D :1; /// 3D-Ref
+bool bRelName:1; /// Reference derived from RangeName 
with relative values
+} Flags;
 };
 
 /// No default ctor, because used in ScRawToken union, set InitFlags!
-inline  void InitFlags() { bFlags = 0; }/// all FALSE
+inline  void InitFlags() { mnFlagValue = 0; }/// all FALSE
 /// InitAddress: InitFlags and set address
 inline  void InitAddress( const ScAddress rAdr );
 inline  void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
 /// InitAddressRel: InitFlags and set address, everything relative to rPos
 inline  void InitAddressRel( const ScAddress rAdr, const ScAddress rPos 
);
-inline  void SetColRel( sal_Bool bVal ) { Flags.bColRel = (bVal ? sal_True 
: false ); }
-inline  sal_Bool IsColRel() const   { return Flags.bColRel; }
-inline  void SetRowRel( sal_Bool bVal ) { Flags.bRowRel = (bVal ? sal_True 
: false ); }
-inline  sal_Bool IsRowRel() const   { return Flags.bRowRel; }
-inline  void SetTabRel( sal_Bool bVal ) { Flags.bTabRel = (bVal ? sal_True 
: false ); }
-inline  sal_Bool IsTabRel() const   { return Flags.bTabRel; }
-
-inline  void SetColDeleted( sal_Bool bVal ) { Flags.bColDeleted = (bVal ? 
sal_True : false ); }
-inline  sal_Bool IsColDeleted() const   { return Flags.bColDeleted; }
-inline  void SetRowDeleted( sal_Bool bVal ) { Flags.bRowDeleted = (bVal ? 
sal_True : false ); }
-inline  sal_Bool IsRowDeleted() const   { return Flags.bRowDeleted; }
-inline  void SetTabDeleted( sal_Bool bVal ) { Flags.bTabDeleted = (bVal ? 
sal_True : false ); }
-inline  sal_Bool IsTabDeleted() const   { return Flags.bTabDeleted; }
-sal_Bool IsDeleted() const;
-
-inline  void SetFlag3D( sal_Bool bVal ) { Flags.bFlag3D = (bVal ? sal_True 
: false ); }
-inline  sal_Bool IsFlag3D() const   { return Flags.bFlag3D; }
-inline  void SetRelName( sal_Bool bVal ){ Flags.bRelName = (bVal ? 
sal_True : false ); }
-inline  sal_Bool IsRelName() const  { return Flags.bRelName; }
-
-inline  sal_Bool Valid() const;
+inline  void SetColRel( bool bVal ) { Flags.bColRel = (bVal ? true : false 
); }
+inline  bool IsColRel() const{ return Flags.bColRel; }
+inline  void SetRowRel( bool bVal ) { Flags.bRowRel = (bVal ? true : false 
); }
+inline  bool IsRowRel() const { return Flags.bRowRel; }
+inline  void SetTabRel( bool bVal ) { Flags.bTabRel = (bVal ? true : false 
); }
+inline  bool IsTabRel() const   { return Flags.bTabRel; }
+
+inline  void SetColDeleted( bool bVal ) { Flags.bColDeleted = (bVal ? true 
: false ); }
+inline  bool IsColDeleted() const   { return Flags.bColDeleted; }
+inline  void SetRowDeleted( bool bVal ) { Flags.bRowDeleted = (bVal ? true 
: false ); }
+inline  bool IsRowDeleted() const   { return Flags.bRowDeleted; }
+inline  void SetTabDeleted( bool bVal ) { Flags.bTabDeleted = (bVal ? true 
: false ); }
+inline  bool IsTabDeleted() const   { return Flags.bTabDeleted; }
+bool IsDeleted() const;
+
+inline  void SetFlag3D( bool bVal ) { Flags.bFlag3D = (bVal ? true : 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-15 Thread Kohei Yoshida
 sc/inc/refdata.hxx  |5 ++---
 sc/source/core/tool/refdata.cxx |   24 +---
 sc/source/core/tool/token.cxx   |   12 ++--
 3 files changed, 9 insertions(+), 32 deletions(-)

New commits:
commit 2d399787bb705324d53cfba74ff08f65f51ae002
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jul 15 20:17:19 2013 -0400

SmartRelAbs() is no more.

Change-Id: I8822d6dc36f49fe1e77100275616d8017b0a7627

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 2e5b5c7..0eef078 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -83,7 +83,6 @@ struct SC_DLLPUBLIC ScSingleRefData
 
 ScAddress toAbs( const ScAddress rPos ) const;
 
-void SmartRelAbs( const ScAddress rPos );
 void CalcRelFromAbs( const ScAddress rPos );
 void CalcAbsIfRel( const ScAddress rPos );
 bool operator==( const ScSingleRefData ) const;
@@ -151,8 +150,6 @@ struct ScComplexRefData
 Ref1.InitAddress( nCol1, nRow1, nTab1 );
 Ref2.InitAddress( nCol2, nRow2, nTab2 );
 }
-inline void SmartRelAbs( const ScAddress rPos )
-{ Ref1.SmartRelAbs( rPos ); Ref2.SmartRelAbs( rPos ); }
 inline void CalcRelFromAbs( const ScAddress rPos )
 { Ref1.CalcRelFromAbs( rPos ); Ref2.CalcRelFromAbs( rPos ); }
 inline void CalcAbsIfRel( const ScAddress rPos )
@@ -165,6 +162,8 @@ struct ScComplexRefData
 tab if one sheet, or =0 if more than one sheets. */
 inline  bool ValidExternal() const;
 
+ScRange toAbs( const ScAddress rPos ) const;
+
 /// Absolute references have to be up-to-date when calling this!
 void PutInOrder();
 inline bool operator==( const ScComplexRefData r ) const
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index cdfaded..fa479d0 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -43,25 +43,6 @@ ScAddress ScSingleRefData::toAbs( const ScAddress rPos ) 
const
 return ScAddress(nRetCol, nRetRow, nRetTab);
 }
 
-void ScSingleRefData::SmartRelAbs( const ScAddress rPos )
-{
-if ( Flags.bColRel )
-nCol = nRelCol + rPos.Col();
-else
-nRelCol = nCol - rPos.Col();
-
-if ( Flags.bRowRel )
-nRow = nRelRow + rPos.Row();
-else
-nRelRow = nRow - rPos.Row();
-
-if ( Flags.bTabRel )
-nTab = nRelTab + rPos.Tab();
-else
-nRelTab = nTab - rPos.Tab();
-}
-
-
 void ScSingleRefData::CalcAbsIfRel( const ScAddress rPos )
 {
 if ( Flags.bColRel )
@@ -269,4 +250,9 @@ ScComplexRefData ScComplexRefData::Extend( const 
ScComplexRefData  rRef, const
 return Extend( rRef.Ref1, rPos).Extend( rRef.Ref2, rPos);
 }
 
+ScRange ScComplexRefData::toAbs( const ScAddress rPos ) const
+{
+return ScRange(Ref1.toAbs(rPos), Ref2.toAbs(rPos));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f8e3e3b..5dccc7c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -496,19 +496,11 @@ bool ScToken::TextEqual( const FormulaToken _rToken ) 
const
 aTemp2 = rToken.GetDoubleRef();
 
 ScAddress aPos;
-aTemp1.SmartRelAbs(aPos);
-aTemp2.SmartRelAbs(aPos);
+ScRange aRange1 = aTemp1.toAbs(aPos), aRange2 = aTemp2.toAbs(aPos);
 
 //  memcmp doesn't work because of the alignment byte after bFlags.
 //  After SmartRelAbs only absolute parts have to be compared.
-return aTemp1.Ref1.nCol   == aTemp2.Ref1.nCol   
-   aTemp1.Ref1.nRow   == aTemp2.Ref1.nRow   
-   aTemp1.Ref1.nTab   == aTemp2.Ref1.nTab   
-   aTemp1.Ref1.mnFlagValue == aTemp2.Ref1.mnFlagValue 
-   aTemp1.Ref2.nCol   == aTemp2.Ref2.nCol   
-   aTemp1.Ref2.nRow   == aTemp2.Ref2.nRow   
-   aTemp1.Ref2.nTab   == aTemp2.Ref2.nTab   
-   aTemp1.Ref2.mnFlagValue == aTemp2.Ref2.mnFlagValue;
+return aRange1 == aRange2  aTemp1.Ref1.mnFlagValue == 
aTemp2.Ref1.mnFlagValue  aTemp1.Ref2.mnFlagValue == aTemp2.Ref2.mnFlagValue;
 }
 else
 return *this == _rToken; // else normal operator==
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-15 Thread Kohei Yoshida
 sc/inc/refdata.hxx   |2 +-
 sc/source/core/data/formulacell.cxx  |   25 +++--
 sc/source/filter/excel/xeformula.cxx |   12 ++--
 sc/source/filter/excel/xelink.cxx|   35 ---
 sc/source/filter/inc/xelink.hxx  |4 ++--
 sc/source/filter/lotus/lotform.cxx   |3 ---
 6 files changed, 36 insertions(+), 45 deletions(-)

New commits:
commit 79074d1b32057bef6ae8982d5eb63d3672d89b46
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 16 00:17:08 2013 -0400

More on replacing CalcAbsIfRel() with toAbs().

Change-Id: I7f658e15a1ab6bdabd5f774e129e12c48a032f1a

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index d619f4f..74028ac 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -166,7 +166,7 @@ struct ScComplexRefData
 tab if one sheet, or =0 if more than one sheets. */
 inline  bool ValidExternal() const;
 
-ScRange toAbs( const ScAddress rPos ) const;
+SC_DLLPUBLIC ScRange toAbs( const ScAddress rPos ) const;
 
 /// Absolute references have to be up-to-date when calling this!
 void PutInOrder();
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 570b55c..3b756cb 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -643,10 +643,9 @@ void ScFormulaCell::GetFormula( OUStringBuffer rBuffer,
  * Can we live without in all cases? */
 ScFormulaCell* pCell = NULL;
 ScSingleRefData rRef = p-GetSingleRef();
-rRef.CalcAbsIfRel( aPos );
-if ( rRef.Valid() )
-pCell = pDocument-GetFormulaCell(
-ScAddress(rRef.nCol, rRef.nRow, rRef.nTab));
+ScAddress aAbs = rRef.toAbs(aPos);
+if (ValidAddress(aAbs))
+pCell = pDocument-GetFormulaCell(aAbs);
 
 if (pCell)
 {
@@ -1842,10 +1841,10 @@ bool ScFormulaCell::GetMatrixOrigin( ScAddress rPos ) 
const
 if( t )
 {
 ScSingleRefData rRef = t-GetSingleRef();
-rRef.CalcAbsIfRel( aPos );
-if ( rRef.Valid() )
+ScAddress aAbs = rRef.toAbs(aPos);
+if (ValidAddress(aAbs))
 {
-rPos.Set( rRef.nCol, rRef.nRow, rRef.nTab );
+rPos = aAbs;
 return true;
 }
 }
@@ -2229,8 +2228,7 @@ bool ScFormulaCell::UpdateReference(
 ScSingleRefData rRef = t-GetSingleRef();
 if ( nDy  0  rRef.IsColRel() )
 {   // ColName
-rRef.CalcAbsIfRel( aPos );
-ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab );
+ScAddress aAdr = rRef.toAbs(aPos);
 ScRangePair* pR = pColList-Find( aAdr );
 if ( pR )
 {   // defined
@@ -2246,7 +2244,7 @@ bool ScFormulaCell::UpdateReference(
 if ( nDx  0  rRef.IsRowRel() )
 {   // RowName
 rRef.CalcAbsIfRel( aPos );
-ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab );
+ScAddress aAdr = rRef.toAbs(aPos);
 ScRangePair* pR = pRowList-Find( aAdr );
 if ( pR )
 {   // defined
@@ -2275,11 +2273,10 @@ bool ScFormulaCell::UpdateReference(
 while ( t  !bColRowNameCompile )
 {
 ScSingleRefData rRef = t-GetSingleRef();
-rRef.CalcAbsIfRel( aPos );
-if ( rRef.Valid() )
+ScAddress aAbs = rRef.toAbs(aPos);
+if (ValidAddress(aAbs))
 {
-ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab );
-if ( rRange.In( aAdr ) )
+if (rRange.In(aAbs))
 bColRowNameCompile = true;
 }
 t = static_castScToken*(pCode-GetNextColRowName());
diff --git a/sc/source/filter/excel/xeformula.cxx 
b/sc/source/filter/excel/xeformula.cxx
index 97a11cb..a862ae4 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -2005,7 +2005,7 @@ void XclExpFmlaCompImpl::ProcessExternalCellRef( const 
XclExpScToken rTokData )
 sal_uInt16 nFileId = rTokData.mpScToken-GetIndex();
 const String rTabName = rTokData.mpScToken-GetString();
 if( mxData-mrCfg.mbFromCell  mxData-mpScBasePos )
-mxData-mpLinkMgr-StoreCell( nFileId, rTabName, aRefData );
+mxData-mpLinkMgr-StoreCell(nFileId, rTabName, 
aRefData.toAbs(*mxData-mpScBasePos));
 
 // 1-based EXTERNSHEET index and 0-based Excel sheet indexes
 sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab;
@@ -2041,7 +2041,7 @@ void 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-15 Thread Kohei Yoshida
Rebased ref, commits from common ancestor:
commit 729105faf8a1aa82f2437e8b8d78e21f3b93aa7d
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 16 00:17:08 2013 -0400

More on replacing CalcAbsIfRel() with toAbs().

Change-Id: I7f658e15a1ab6bdabd5f774e129e12c48a032f1a

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index d619f4f..74028ac 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -166,7 +166,7 @@ struct ScComplexRefData
 tab if one sheet, or =0 if more than one sheets. */
 inline  bool ValidExternal() const;
 
-ScRange toAbs( const ScAddress rPos ) const;
+SC_DLLPUBLIC ScRange toAbs( const ScAddress rPos ) const;
 
 /// Absolute references have to be up-to-date when calling this!
 void PutInOrder();
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 570b55c..41a53f1 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -643,10 +643,9 @@ void ScFormulaCell::GetFormula( OUStringBuffer rBuffer,
  * Can we live without in all cases? */
 ScFormulaCell* pCell = NULL;
 ScSingleRefData rRef = p-GetSingleRef();
-rRef.CalcAbsIfRel( aPos );
-if ( rRef.Valid() )
-pCell = pDocument-GetFormulaCell(
-ScAddress(rRef.nCol, rRef.nRow, rRef.nTab));
+ScAddress aAbs = rRef.toAbs(aPos);
+if (ValidAddress(aAbs))
+pCell = pDocument-GetFormulaCell(aAbs);
 
 if (pCell)
 {
@@ -1842,10 +1841,10 @@ bool ScFormulaCell::GetMatrixOrigin( ScAddress rPos ) 
const
 if( t )
 {
 ScSingleRefData rRef = t-GetSingleRef();
-rRef.CalcAbsIfRel( aPos );
-if ( rRef.Valid() )
+ScAddress aAbs = rRef.toAbs(aPos);
+if (ValidAddress(aAbs))
 {
-rPos.Set( rRef.nCol, rRef.nRow, rRef.nTab );
+rPos = aAbs;
 return true;
 }
 }
@@ -2229,8 +2228,7 @@ bool ScFormulaCell::UpdateReference(
 ScSingleRefData rRef = t-GetSingleRef();
 if ( nDy  0  rRef.IsColRel() )
 {   // ColName
-rRef.CalcAbsIfRel( aPos );
-ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab );
+ScAddress aAdr = rRef.toAbs(aPos);
 ScRangePair* pR = pColList-Find( aAdr );
 if ( pR )
 {   // defined
@@ -2239,14 +2237,13 @@ bool ScFormulaCell::UpdateReference(
 }
 else
 {   // on the fly
-if ( rRef.nRow + 1 == nRow1 )
+if (aAdr.Row() + 1 == nRow1)
 bColRowNameCompile = true;
 }
 }
 if ( nDx  0  rRef.IsRowRel() )
 {   // RowName
-rRef.CalcAbsIfRel( aPos );
-ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab );
+ScAddress aAdr = rRef.toAbs(aPos);
 ScRangePair* pR = pRowList-Find( aAdr );
 if ( pR )
 {   // defined
@@ -2255,7 +2252,7 @@ bool ScFormulaCell::UpdateReference(
 }
 else
 {   // on the fly
-if ( rRef.nCol + 1 == nCol1 )
+if (aAdr.Col() + 1 == nCol1)
 bColRowNameCompile = true;
 }
 }
@@ -2275,11 +2272,10 @@ bool ScFormulaCell::UpdateReference(
 while ( t  !bColRowNameCompile )
 {
 ScSingleRefData rRef = t-GetSingleRef();
-rRef.CalcAbsIfRel( aPos );
-if ( rRef.Valid() )
+ScAddress aAbs = rRef.toAbs(aPos);
+if (ValidAddress(aAbs))
 {
-ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab );
-if ( rRange.In( aAdr ) )
+if (rRange.In(aAbs))
 bColRowNameCompile = true;
 }
 t = static_castScToken*(pCode-GetNextColRowName());
diff --git a/sc/source/filter/excel/xeformula.cxx 
b/sc/source/filter/excel/xeformula.cxx
index 97a11cb..a862ae4 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -2005,7 +2005,7 @@ void XclExpFmlaCompImpl::ProcessExternalCellRef( const 
XclExpScToken rTokData )
 sal_uInt16 nFileId = rTokData.mpScToken-GetIndex();
 const String rTabName = rTokData.mpScToken-GetString();
 if( mxData-mrCfg.mbFromCell  mxData-mpScBasePos )
-mxData-mpLinkMgr-StoreCell( nFileId, 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-15 Thread Kohei Yoshida
 sc/inc/tokenarray.hxx   |6 +++---
 sc/source/core/data/formulaiter.cxx |   17 ++---
 sc/source/core/data/validat.cxx |3 +--
 sc/source/core/tool/rangenam.cxx|   14 +++---
 sc/source/core/tool/token.cxx   |   20 ++--
 sc/source/filter/excel/xiname.cxx   |4 ++--
 sc/source/ui/vba/vbanames.cxx   |2 +-
 7 files changed, 26 insertions(+), 40 deletions(-)

New commits:
commit 4e9d0c5ee1918a8ea730372d43c742ed687bb983
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 16 01:37:01 2013 -0400

More of the same.

Change-Id: I6a5f94723b5efb916abc88d0de9f972e142199df

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 4582c96..726dac6 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -34,7 +34,7 @@ class SC_DLLPUBLIC ScTokenArray : public 
formula::FormulaTokenArray
 {
 friend class ScCompiler;
 
-boolImplGetReference( ScRange rRange, bool bValidOnly 
) const;
+bool ImplGetReference( ScRange rRange, const ScAddress rPos, bool 
bValidOnly ) const;
 
 size_t mnHashValue;
 ScFormulaVectorState meVectorState;
@@ -52,9 +52,9 @@ public:
 ScFormulaVectorState GetVectorState() const;
 
 /// Exactly and only one range (valid or deleted)
-boolIsReference( ScRange rRange ) const;
+bool IsReference( ScRange rRange, const ScAddress rPos ) const;
 /// Exactly and only one valid range (no #REF!s)
-boolIsValidReference( ScRange rRange ) const;
+bool IsValidReference( ScRange rRange, const ScAddress rPos ) const;
 
 
 /** Determines the extent of direct adjacent
diff --git a/sc/source/core/data/formulaiter.cxx 
b/sc/source/core/data/formulaiter.cxx
index 5a7152d..f14817d 100644
--- a/sc/source/core/data/formulaiter.cxx
+++ b/sc/source/core/data/formulaiter.cxx
@@ -32,17 +32,17 @@ ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* 
pCell )
 aPos = pCell-aPos;
 }
 
-static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p )
+static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p, const ScAddress rPos )
 {
 ScSingleRefData rRef1 = p-GetSingleRef();
-if ( rRef1.IsColDeleted() || rRef1.IsRowDeleted() || rRef1.IsTabDeleted()
-|| !rRef1.Valid() )
+ScAddress aAbs1 = rRef1.toAbs(rPos);
+if (!ValidAddress(aAbs1))
 return true;
 if ( p-GetType() == svDoubleRef || p-GetType() == svExternalDoubleRef )
 {
 ScSingleRefData rRef2 = p-GetDoubleRef().Ref2;
-if ( rRef2.IsColDeleted() || rRef2.IsRowDeleted() || 
rRef2.IsTabDeleted()
-|| !rRef2.Valid() )
+ScAddress aAbs2 = rRef2.toAbs(rPos);
+if (!ValidAddress(aAbs2))
 return true;
 }
 return false;
@@ -66,14 +66,9 @@ bool ScDetectiveRefIter::GetNextRef( ScRange rRange )
 ScToken* ScDetectiveRefIter::GetNextRefToken()
 {
 ScToken* p = static_castScToken*(pCode-GetNextReferenceRPN());
-if (p)
-p-CalcAbsIfRel( aPos );
-
-while ( p  lcl_ScDetectiveRefIter_SkipRef( p ) )
+while (p  lcl_ScDetectiveRefIter_SkipRef(p, aPos))
 {
 p = static_castScToken*(pCode-GetNextReferenceRPN());
-if (p)
-p-CalcAbsIfRel( aPos );
 }
 return p;
 }
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 4d72c98..ea65bb5 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -704,8 +704,7 @@ bool ScValidationData::GetSelectionFromFormula(
 }
 else if (t-GetType() != svIndex)
 {
-t-CalcAbsIfRel(rPos);
-if (pArr-IsValidReference(aRange))
+if (pArr-IsValidReference(aRange, rPos))
 {
 bRef = true;
 }
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 4d81099..42662ae 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -387,7 +387,7 @@ bool ScRangeData::IsRangeAtBlock( const ScRange rBlock ) 
const
 bool ScRangeData::IsReference( ScRange rRange ) const
 {
 if ( (eType  ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ))  pCode )
-return pCode-IsReference( rRange );
+return pCode-IsReference(rRange, aPos);
 
 return false;
 }
@@ -395,15 +395,7 @@ bool ScRangeData::IsReference( ScRange rRange ) const
 bool ScRangeData::IsReference( ScRange rRange, const ScAddress rPos ) const
 {
 if ( (eType  ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) )  pCode )
-{
-SAL_WNODEPRECATED_DECLARATIONS_PUSH
-::std::auto_ptrScTokenArray pTemp( pCode-Clone() );
-SAL_WNODEPRECATED_DECLARATIONS_POP
-ScCompiler aComp( pDoc, rPos, *pTemp);
-aComp.SetGrammar(pDoc-GetGrammar());
-aComp.MoveRelWrap(MAXCOL, MAXROW);
-return pTemp-IsReference( rRange );
-}
+return pCode-IsReference(rRange, rPos);
 
 return false;
 }
@@ -411,7 +403,7 @@ bool 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-10 Thread Kohei Yoshida
 sc/inc/formulagroup.hxx  |3 +++
 sc/source/core/opencl/formulagroupcl.cxx |8 +---
 sc/source/core/tool/formulagroup.cxx |   13 ++---
 3 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit 517a3eadb523a904db69802945fc25bfcff9b93c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jul 10 11:58:49 2013 -0400

Generate Reverse Polish token array (RPN) at the start.

Change-Id: Idcac01820fab536cebebcc437e206b6900511600

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index e645968..9963fc9 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -39,6 +39,9 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
  protected:
 FormulaGroupInterpreter() {}
 virtual ~FormulaGroupInterpreter() {}
+
+static void generateRPNCode(ScDocument rDoc, const ScAddress rPos, 
ScTokenArray rCode);
+
  public:
 static FormulaGroupInterpreter *getStatic();
 
diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 8bc0224..04a67d2 100755
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -65,6 +65,8 @@ ScMatrixRef 
FormulaGroupInterpreterOpenCL::inverseMatrix(const ScMatrix /* rMat
 bool FormulaGroupInterpreterOpenCL::interpret(ScDocument rDoc, const 
ScAddress rTopPos,
   const ScFormulaCellGroupRef 
xGroup, ScTokenArray rCode)
 {
+generateRPNCode(rDoc, rTopPos, rCode);
+
 size_t rowSize = xGroup-mnLength;
 fprintf(stderr,rowSize at begin is ...%ld.\n,(long)rowSize);
 // The row quantity can be gotten from p2-GetArrayLength()
@@ -193,9 +195,7 @@ bool FormulaGroupInterpreterOpenCL::interpret(ScDocument 
rDoc, const ScAddress
 if(!getenv(SC_GPU)||!ocl_calc.GetOpenclState())
 {
 fprintf(stderr,ccCPU flow...\n\n);
-ScCompiler aComp(rDoc, aTmpPos, aCode2);
-aComp.SetGrammar(rDoc.GetGrammar());
-aComp.CompileTokenArray(); // Create RPN token array.
+generateRPNCode(rDoc, aTmpPos, aCode2);
 ScInterpreter aInterpreter(pDest, rDoc, aTmpPos, aCode2);
 aInterpreter.Interpret();
 pDest-SetResultToken(aInterpreter.GetResultToken().get());
@@ -306,6 +306,8 @@ bool 
FormulaGroupInterpreterGroundwater::interpret(ScDocument rDoc, const ScAdd
const 
ScFormulaCellGroupRef xGroup,
ScTokenArray rCode)
 {
+generateRPNCode(rDoc, rTopPos, rCode);
+
 // Inputs: both of length xGroup-mnLength
 OpCode eOp; // type of operation: ocAverage, ocMax, ocMin
 const double *pArrayToSubtractOneElementFrom;
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 627c5f5..5a23511 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -96,9 +96,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument 
rDoc, const ScAddres
 if (!pDest)
 return false;
 
-ScCompiler aComp(rDoc, aTmpPos, aCode2);
-aComp.SetGrammar(rDoc.GetGrammar());
-aComp.CompileTokenArray(); // Create RPN token array.
+generateRPNCode(rDoc, aTmpPos, aCode2);
 ScInterpreter aInterpreter(pDest, rDoc, aTmpPos, aCode2);
 aInterpreter.Interpret();
 aResults.push_back(aInterpreter.GetResultToken()-GetDouble());
@@ -190,6 +188,15 @@ FormulaGroupInterpreter 
*FormulaGroupInterpreter::getStatic()
 return msInstance;
 }
 
+void FormulaGroupInterpreter::generateRPNCode(ScDocument rDoc, const 
ScAddress rPos, ScTokenArray rCode)
+{
+// First, generate an RPN (reverse polish notation) token array.
+ScCompiler aComp(rDoc, rPos, rCode);
+aComp.SetGrammar(rDoc.GetGrammar());
+aComp.CompileTokenArray(); // Create RPN token array.
+// Now, calling FirstRPN() and NextRPN() will return tokens from the RPN 
token array.
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-09 Thread Kohei Yoshida
 sc/inc/column.hxx   |7 ---
 sc/source/core/data/column2.cxx |4 
 2 files changed, 11 deletions(-)

New commits:
commit c76af15da344696e93226c256a160338f3d248cf
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 9 23:47:03 2013 -0400

Nobody uses this marker method now.

Change-Id: I06aea5100280c6dee756d8023e6e2fadb09662d7

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9f96975..d024007 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -516,13 +516,6 @@ public:
 void RegroupFormulaCells();
 
 /**
- * Regroup existing formula cells when a new cell is inserted.
- *
- * @param nRow row at which a new cell is inserted.
- */
-void RegroupFormulaCells( SCROW nRow );
-
-/**
  * Regroup existing formula cells when a range of new cells are inserted.
  *
  * @param nRow1 first row of inserted new cell span.
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 512dc8b7..aa4dd0e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1530,10 +1530,6 @@ void ScColumn::CellStorageModified()
 #endif
 }
 
-void ScColumn::RegroupFormulaCells( SCROW /*nRow*/ )
-{
-}
-
 void ScColumn::RegroupFormulaCells( SCROW /*nRow1*/, SCROW /*nRow2*/ )
 {
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-08 Thread Kohei Yoshida
 sc/inc/column.hxx  |3 ++
 sc/source/core/data/column.cxx |   51 +
 2 files changed, 30 insertions(+), 24 deletions(-)

New commits:
commit a448c8e7ff13b16be8b6a5ce23080fd9215e0c1e
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jul 8 15:29:40 2013 -0400

Make update ref on copy a separate method.

Change-Id: I95cb42845535532fca5622d8d4f8b394ff22d4d3

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6bbfb6a..37f67d5 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -310,6 +310,9 @@ public:
 
 voidResetChanged( SCROW nStartRow, SCROW nEndRow );
 
+bool UpdateReferenceOnCopy(
+const ScRange rRange, SCCOL nDx, SCROW nDy, SCTAB nDz, ScDocument* 
pUndoDoc = NULL );
+
 /**
  * Update reference addresses in formula cell in response to mass cell
  * movement.
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index fad7edd..4372688 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1991,8 +1991,7 @@ void ScColumn::CopyScenarioFrom( const ScColumn rSrcCol )
 //  UpdateUsed not needed, already done in TestCopyScenario 
(obsolete comment ?)
 
 SCsTAB nDz = nTab - rSrcCol.nTab;
-UpdateReference(
-URM_COPY, ScRange(nCol, nStart, nTab, nCol, nEnd, nTab), 0, 0, 
nDz, NULL);
+UpdateReferenceOnCopy(ScRange(nCol, nStart, nTab, nCol, nEnd, 
nTab), 0, 0, nDz, NULL);
 UpdateCompile();
 }
 
@@ -2020,8 +2019,8 @@ void ScColumn::CopyScenarioTo( ScColumn rDestCol ) const
 //  UpdateUsed not needed, is already done in TestCopyScenario 
(obsolete comment ?)
 
 SCsTAB nDz = rDestCol.nTab - nTab;
-rDestCol.UpdateReference(
-URM_COPY, ScRange(rDestCol.nCol, nStart, rDestCol.nTab, 
rDestCol.nCol, nEnd, rDestCol.nTab),
+rDestCol.UpdateReferenceOnCopy(
+ScRange(rDestCol.nCol, nStart, rDestCol.nTab, rDestCol.nCol, 
nEnd, rDestCol.nTab),
 0, 0, nDz, NULL);
 rDestCol.UpdateCompile();
 }
@@ -2261,32 +2260,36 @@ public:
 
 }
 
-bool ScColumn::UpdateReference(
-UpdateRefMode eUpdateRefMode, const ScRange rRange, SCsCOL nDx, SCsROW 
nDy, SCsTAB nDz,
-ScDocument* pUndoDoc )
+bool ScColumn::UpdateReferenceOnCopy(
+const ScRange rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, ScDocument* 
pUndoDoc )
 {
-if (eUpdateRefMode == URM_COPY)
-{
-// When copying, the range equals the destination range where cells
-// are pasted, and the dx, dy, dz refer to the distance from the
-// source range.
+// When copying, the range equals the destination range where cells
+// are pasted, and the dx, dy, dz refer to the distance from the
+// source range.
 
-UpdateRefOnCopy aHandler(rRange, nDx, nDy, nDz, pUndoDoc);
-sc::CellStoreType::position_type aPos = 
maCells.position(rRange.aStart.Row());
-sc::ProcessBlock(aPos.first, maCells, aHandler, rRange.aStart.Row(), 
rRange.aEnd.Row());
+UpdateRefOnCopy aHandler(rRange, nDx, nDy, nDz, pUndoDoc);
+sc::CellStoreType::position_type aPos = 
maCells.position(rRange.aStart.Row());
+sc::ProcessBlock(aPos.first, maCells, aHandler, rRange.aStart.Row(), 
rRange.aEnd.Row());
 
-// The formula groups at the top and bottom boundaries are expected to
-// have been split prior to this call. Here, we only do the joining.
+// The formula groups at the top and bottom boundaries are expected to
+// have been split prior to this call. Here, we only do the joining.
+JoinFormulaCellAbove(aPos);
+if (rRange.aEnd.Row()  MAXROW)
+{
+aPos = maCells.position(aPos.first, rRange.aEnd.Row()+1);
 JoinFormulaCellAbove(aPos);
-if (rRange.aEnd.Row()  MAXROW)
-{
-aPos = maCells.position(aPos.first, rRange.aEnd.Row()+1);
-JoinFormulaCellAbove(aPos);
-}
-
-return aHandler.isUpdated();
 }
 
+return aHandler.isUpdated();
+}
+
+bool ScColumn::UpdateReference(
+UpdateRefMode eUpdateRefMode, const ScRange rRange, SCsCOL nDx, SCsROW 
nDy, SCsTAB nDz,
+ScDocument* pUndoDoc )
+{
+if (eUpdateRefMode == URM_COPY)
+return UpdateReferenceOnCopy(rRange, nDx, nDy, nDz, pUndoDoc);
+
 bool bThisColShifted = (rRange.aStart.Tab() = nTab  nTab = 
rRange.aEnd.Tab()  rRange.aStart.Col() = nCol  nCol = rRange.aEnd.Col());
 if (bThisColShifted)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-08 Thread Kohei Yoshida
 sc/inc/column.hxx   |2 --
 sc/source/core/data/column2.cxx |4 
 2 files changed, 6 deletions(-)

New commits:
commit afa540665867b0365718ff1e21b3a1235a951d06
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jul 8 15:32:42 2013 -0400

Nobody uses this marker now.

Change-Id: Ib7c8a7b7b1ce7f2b9afbb17a50848ae1d8e28907

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 37f67d5..9f96975 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -530,8 +530,6 @@ public:
  */
 void RegroupFormulaCells( SCROW nRow1, SCROW nRow2 );
 
-void FormulaCellsUndecided( SCROW nRow1, SCROW nRow2 );
-
 #if DEBUG_COLUMN_STORAGE
 void DumpFormulaGroups() const;
 #endif
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index a651fa6..512dc8b7 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1538,10 +1538,6 @@ void ScColumn::RegroupFormulaCells( SCROW /*nRow1*/, 
SCROW /*nRow2*/ )
 {
 }
 
-void ScColumn::FormulaCellsUndecided( SCROW /*nRow1*/, SCROW /*nRow2*/ )
-{
-}
-
 #if DEBUG_COLUMN_STORAGE
 
 namespace {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-04 Thread Kohei Yoshida
 sc/inc/column.hxx   |2 +
 sc/source/core/data/column.cxx  |   77 +---
 sc/source/core/data/column2.cxx |4 --
 sc/source/core/data/column3.cxx |   66 ++
 4 files changed, 109 insertions(+), 40 deletions(-)

New commits:
commit 724077098c35e7edd4231ae95e7cddb1a1b95a0c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 4 02:17:03 2013 -0400

More on regrouping of formula cells.

Change-Id: Icd3403e759841dce351c932ea8915ba9819e5a29

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 62e1ddf..6bbfb6a 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -505,6 +505,8 @@ public:
  */
 void SplitFormulaCellGroup( const sc::CellStoreType::position_type aPos ) 
const;
 
+void JoinFormulaCellAbove( const sc::CellStoreType::position_type aPos ) 
const;
+
 /**
  * Regroup formula cells for the entire column.
  */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index bdfde88..7ce8668 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2127,13 +2127,29 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, 
ScColumn rCol)
 sc::SingleColumnSpanSet::SpansType aRanges;
 aNonEmpties.getSpans(aRanges);
 
+// Split the formula grouping at the top and bottom boundaries.
+sc::CellStoreType::position_type aPos = maCells.position(nStartRow);
+SplitFormulaCellGroup(aPos);
+aPos = maCells.position(aPos.first, nEndRow+1);
+SplitFormulaCellGroup(aPos);
+
+// Do the same with the destination column.
+aPos = rCol.maCells.position(nStartRow);
+rCol.SplitFormulaCellGroup(aPos);
+aPos = rCol.maCells.position(aPos.first, nEndRow+1);
+rCol.SplitFormulaCellGroup(aPos);
+
 // Move the broadcasters to the destination column.
 maBroadcasters.transfer(nStartRow, nEndRow, rCol.maBroadcasters, 
nStartRow);
 maCells.transfer(nStartRow, nEndRow, rCol.maCells, nStartRow);
 maCellTextAttrs.transfer(nStartRow, nEndRow, rCol.maCellTextAttrs, 
nStartRow);
 
-RegroupFormulaCells(nStartRow, nEndRow);
-rCol.RegroupFormulaCells(nStartRow, nEndRow);
+// Re-group transferred formula cells.
+aPos = rCol.maCells.position(nStartRow);
+rCol.JoinFormulaCellAbove(aPos);
+aPos = rCol.maCells.position(aPos.first, nEndRow+1);
+rCol.JoinFormulaCellAbove(aPos);
+
 CellStorageModified();
 rCol.CellStorageModified();
 
@@ -2267,31 +2283,47 @@ namespace {
 
 class UpdateTransHandler
 {
+ScColumn mrColumn;
+sc::CellStoreType::iterator miPos;
 ScRange maSource;
 ScAddress maDest;
 ScDocument* mpUndoDoc;
 public:
-UpdateTransHandler(const ScRange rSource, const ScAddress rDest, 
ScDocument* pUndoDoc) :
+UpdateTransHandler(ScColumn rColumn, const ScRange rSource, const 
ScAddress rDest, ScDocument* pUndoDoc) :
+mrColumn(rColumn),
+miPos(rColumn.GetCellStore().begin()),
 maSource(rSource), maDest(rDest), mpUndoDoc(pUndoDoc) {}
 
-void operator() (size_t, ScFormulaCell* pCell)
+void operator() (size_t nRow, ScFormulaCell* pCell)
 {
+sc::CellStoreType::position_type aPos = 
mrColumn.GetCellStore().position(miPos, nRow);
+miPos = aPos.first;
+mrColumn.UnshareFormulaCell(aPos, *pCell);
 pCell-UpdateTranspose(maSource, maDest, mpUndoDoc);
+mrColumn.JoinNewFormulaCell(aPos, *pCell);
 }
 };
 
 class UpdateGrowHandler
 {
+ScColumn mrColumn;
+sc::CellStoreType::iterator miPos;
 ScRange maArea;
 SCCOL mnGrowX;
 SCROW mnGrowY;
 public:
-UpdateGrowHandler(const ScRange rArea, SCCOL nGrowX, SCROW nGrowY) :
+UpdateGrowHandler(ScColumn rColumn, const ScRange rArea, SCCOL nGrowX, 
SCROW nGrowY) :
+mrColumn(rColumn),
+miPos(rColumn.GetCellStore().begin()),
 maArea(rArea), mnGrowX(nGrowX), mnGrowY(nGrowY) {}
 
-void operator() (size_t, ScFormulaCell* pCell)
+void operator() (size_t nRow, ScFormulaCell* pCell)
 {
+sc::CellStoreType::position_type aPos = 
mrColumn.GetCellStore().position(miPos, nRow);
+miPos = aPos.first;
+mrColumn.UnshareFormulaCell(aPos, *pCell);
 pCell-UpdateGrow(maArea, mnGrowX, mnGrowY);
+mrColumn.JoinNewFormulaCell(aPos, *pCell);
 }
 };
 
@@ -2638,14 +2670,22 @@ public:
 
 class CompileErrorCellsHandler
 {
+ScColumn mrColumn;
+sc::CellStoreType::iterator miPos;
 sal_uInt16 mnErrCode;
 FormulaGrammar::Grammar meGram;
 bool mbCompiled;
 public:
-CompileErrorCellsHandler(sal_uInt16 nErrCode, FormulaGrammar::Grammar 
eGram) :
-mnErrCode(nErrCode), meGram(eGram), mbCompiled(false) {}
+CompileErrorCellsHandler(ScColumn rColumn, sal_uInt16 nErrCode, 
FormulaGrammar::Grammar eGram) :
+mrColumn(rColumn),
+miPos(mrColumn.GetCellStore().begin()),
+mnErrCode(nErrCode),
+meGram(eGram),
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-02 Thread Kohei Yoshida
 sc/inc/formulacell.hxx|1 +
 sc/inc/formularesult.hxx  |2 ++
 sc/source/core/data/column.cxx|2 +-
 sc/source/core/data/formulacell.cxx   |9 +
 sc/source/core/tool/formularesult.cxx |   12 
 5 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit b82237c146284c3e3d88a30552eb820be071fbca
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 2 01:12:27 2013 -0400

COUNT should skip formula cells with error.

Change-Id: I829eaf309056403f77949526877888315a2ad720

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index a63025c..52a1474 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -202,6 +202,7 @@ public:
 // display as empty string if formula::svEmptyCell result
 boolIsEmptyDisplayedAsString();
 boolIsValue();  // also true if formula::svEmptyCell
+bool IsValueNoError();
 boolIsHybridValueCell(); // for cells after import to deal 
with inherited number formats
 double  GetValue();
 double  GetValueAlways();   // ignore errors
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 6736a10..f1f7b5d 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -128,6 +128,8 @@ public:
 details instead. */
 bool IsValue() const;
 
+bool IsValueNoError() const;
+
 /** Determines whether or not the result is a string containing more than
 one paragraph */
 bool IsMultiline() const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 64aae03..61f57ab 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -511,7 +511,7 @@ public:
 for (; it != itEnd; ++it)
 {
 ScFormulaCell rCell = const_castScFormulaCell(**it);
-if (rCell.IsValue())
+if (rCell.IsValueNoError())
 ++mnCount;
 }
 }
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 1e86cfc..a129726 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1711,6 +1711,15 @@ bool ScFormulaCell::IsValue()
 return aResult.IsValue();
 }
 
+bool ScFormulaCell::IsValueNoError()
+{
+MaybeInterpret();
+if (pCode-GetCodeError())
+return false;
+
+return aResult.IsValueNoError();
+}
+
 bool ScFormulaCell::IsHybridValueCell()
 {
 return aResult.GetType() == formula::svHybridValueCell;
diff --git a/sc/source/core/tool/formularesult.cxx 
b/sc/source/core/tool/formularesult.cxx
index a20963b..72944a0 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -265,6 +265,18 @@ bool ScFormulaResult::IsValue() const
 return isValue(GetCellResultType());
 }
 
+bool ScFormulaResult::IsValueNoError() const
+{
+switch (GetCellResultType())
+{
+case formula::svDouble:
+case formula::svEmptyCell:
+case formula::svHybridValueCell:
+return true;
+}
+return false;
+}
+
 bool ScFormulaResult::IsMultiline() const
 {
 if (meMultiline == MULTILINE_UNKNOWN)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-02 Thread Kohei Yoshida
 sc/inc/formulagroup.hxx  |2 ++
 sc/source/core/opencl/formulagroupcl.cxx |7 +++
 sc/source/core/tool/formulagroup.cxx |5 +
 sc/source/core/tool/interpr5.cxx |   12 
 4 files changed, 26 insertions(+)

New commits:
commit 3262cac1a8e55d9525b7a0e8192947caa96cd7e8
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 2 12:26:16 2013 -0400

Add a way to inverse matrix using openCL. It's an no-op for now.

Change-Id: I4659d57505c3dccf872e124b8b569e680b307b71

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index e5839e4..1c573c4 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -43,6 +43,7 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
  public:
 static FormulaGroupInterpreter *getStatic();
 
+virtual ScMatrixRef inverseMatrix(const ScMatrix rMat) = 0;
 virtual bool interpret(ScDocument rDoc, const ScAddress rTopPos, const 
ScFormulaCellGroupRef xGroup, ScTokenArray rCode) = 0;
 };
 
@@ -54,6 +55,7 @@ public:
 FormulaGroupInterpreter() {}
 virtual ~FormulaGroupInterpreterSoftware() {}
 
+virtual ScMatrixRef inverseMatrix(const ScMatrix rMat);
 virtual bool interpret(ScDocument rDoc, const ScAddress rTopPos, const 
ScFormulaCellGroupRef xGroup, ScTokenArray rCode);
 };
 
diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 41e439c..9530276 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -51,10 +51,17 @@ public:
 {
 OclCalc::ReleaseOpenclRunEnv();
 }
+
+virtual ScMatrixRef inverseMatrix(const ScMatrix rMat);
 virtual bool interpret(ScDocument rDoc, const ScAddress rTopPos,
const ScFormulaCellGroupRef xGroup, ScTokenArray 
rCode);
 };
 
+ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix 
rMat)
+{
+return ScMatrixRef();
+}
+
 bool FormulaGroupInterpreterOpenCL::interpret(ScDocument rDoc, const 
ScAddress rTopPos,
   const ScFormulaCellGroupRef 
xGroup, ScTokenArray rCode)
 {
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 4a04f79..4754bd0 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -20,6 +20,11 @@
 
 namespace sc {
 
+ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix 
/*rMat*/)
+{
+return ScMatrixRef();
+}
+
 bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const 
ScAddress rTopPos,
 const ScFormulaCellGroupRef 
xGroup,
 ScTokenArray rCode)
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 26c2378..d48cfe7 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -35,6 +35,7 @@
 #include scmatrix.hxx
 #include globstr.hrc
 #include cellkeytranslator.hxx
+#include formulagroup.hxx
 
 #include vector
 
@@ -850,6 +851,17 @@ void ScInterpreter::ScMatInv()
 }
 SCSIZE nC, nR;
 pMat-GetDimensions(nC, nR);
+
+if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
+{
+ScMatrixRef xResMat = 
sc::FormulaGroupInterpreter::getStatic()-inverseMatrix(*pMat);
+if (xResMat)
+{
+PushMatrix(xResMat);
+return;
+}
+}
+
 if ( nC != nR || nC == 0 || (sal_uLong) nC * nC  
ScMatrix::GetElementsMax() )
 PushIllegalArgument();
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-07-02 Thread Kohei Yoshida
 sc/inc/column.hxx|3 -
 sc/source/core/data/column.cxx   |   74 ---
 sc/source/core/tool/interpr6.cxx |   65 +-
 3 files changed, 63 insertions(+), 79 deletions(-)

New commits:
commit 9e802714b3c1e6d618c833ff0bc89016afed2131
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 2 16:02:59 2013 -0400

Move this code from the column code back into the interpreter code.

Change-Id: I7830cdf3f09ed7b6ae6221212bfb84abcdeac523

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 359b8ac..62e1ddf 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -409,9 +409,6 @@ public:
 voidClearSelectionItems( const sal_uInt16* pWhich, const 
ScMarkData rMark );
 voidChangeSelectionIndent( bool bIncrement, const ScMarkData 
rMark );
 
-double SumNumericCells( sc::ColumnBlockConstPosition rPos, SCROW nRow1, 
SCROW nRow2 ) const;
-size_t CountNumericCells( sc::ColumnBlockConstPosition rPos, SCROW nRow1, 
SCROW nRow2 ) const;
-
 long GetNeededSize(
 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
 const Fraction rZoomX, const Fraction rZoomY,
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 61f57ab..6a2dbd3 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -466,80 +466,6 @@ void ScColumn::ChangeSelectionIndent( bool bIncrement, 
const ScMarkData rMark )
 }
 }
 
-namespace {
-
-class NumericCellAccumulator
-{
-double mfSum;
-public:
-NumericCellAccumulator() : mfSum(0.0) {}
-
-void operator() (size_t, double fVal)
-{
-mfSum += fVal;
-}
-
-void operator() (size_t, const ScFormulaCell* pCell)
-{
-ScFormulaCell rCell = const_castScFormulaCell(*pCell);
-if (rCell.IsValue())
-mfSum += rCell.GetValue();
-}
-
-double getSum() const { return mfSum; }
-};
-
-class NumericCellCounter
-{
-size_t mnCount;
-public:
-NumericCellCounter() : mnCount(0) {}
-
-void operator() (const sc::CellStoreType::value_type rNode, size_t 
nOffset, size_t nDataSize)
-{
-switch (rNode.type)
-{
-case sc::element_type_numeric:
-mnCount += nDataSize;
-break;
-case sc::element_type_formula:
-{
-sc::formula_block::const_iterator it = 
sc::formula_block::begin(*rNode.data);
-std::advance(it, nOffset);
-sc::formula_block::const_iterator itEnd = it;
-std::advance(itEnd, nDataSize);
-for (; it != itEnd; ++it)
-{
-ScFormulaCell rCell = const_castScFormulaCell(**it);
-if (rCell.IsValueNoError())
-++mnCount;
-}
-}
-break;
-default:
-;
-}
-}
-
-size_t getCount() const { return mnCount; }
-};
-
-}
-
-double ScColumn::SumNumericCells( sc::ColumnBlockConstPosition rPos, SCROW 
nRow1, SCROW nRow2 ) const
-{
-NumericCellAccumulator aFunc;
-rPos.miCellPos = sc::ParseFormulaNumeric(rPos.miCellPos, maCells, nRow1, 
nRow2, aFunc);
-return aFunc.getSum();
-}
-
-size_t ScColumn::CountNumericCells( sc::ColumnBlockConstPosition rPos, SCROW 
nRow1, SCROW nRow2 ) const
-{
-NumericCellCounter aFunc;
-rPos.miCellPos = sc::ParseBlock(rPos.miCellPos, maCells, aFunc, nRow1, 
nRow2);
-return aFunc.getCount();
-}
-
 void ScColumn::ClearSelectionItems( const sal_uInt16* pWhich,const ScMarkData 
rMark )
 {
 SCROW nTop;
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index e31a062..03d87a9 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -24,6 +24,7 @@
 #include document.hxx
 #include cellvalue.hxx
 #include dociter.hxx
+#include mtvcellfunc.hxx
 
 #include formula/token.hxx
 #include rtl/logfile.hxx
@@ -213,6 +214,62 @@ double ScInterpreter::GetGammaDist( double fX, double 
fAlpha, double fLambda )
 
 namespace {
 
+class NumericCellAccumulator
+{
+double mfSum;
+public:
+NumericCellAccumulator() : mfSum(0.0) {}
+
+void operator() (size_t, double fVal)
+{
+mfSum += fVal;
+}
+
+void operator() (size_t, const ScFormulaCell* pCell)
+{
+ScFormulaCell rCell = const_castScFormulaCell(*pCell);
+if (rCell.IsValue())
+mfSum += rCell.GetValue();
+}
+
+double getSum() const { return mfSum; }
+};
+
+class NumericCellCounter
+{
+size_t mnCount;
+public:
+NumericCellCounter() : mnCount(0) {}
+
+void operator() (const sc::CellStoreType::value_type rNode, size_t 
nOffset, size_t nDataSize)
+{
+switch (rNode.type)
+{
+case sc::element_type_numeric:
+mnCount += nDataSize;
+break;
+case 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-28 Thread Kohei Yoshida
 sc/inc/column.hxx   |2 
 sc/inc/document.hxx |2 
 sc/inc/table.hxx|2 
 sc/source/core/data/column2.cxx |  188 +---
 sc/source/core/data/document.cxx|2 
 sc/source/core/data/formulacell.cxx |   13 +-
 sc/source/core/data/table1.cxx  |2 
 7 files changed, 188 insertions(+), 23 deletions(-)

New commits:
commit 49c16e6060b4323c79d33abfa163d4e5aae2bc15
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 28 11:29:14 2013 -0400

Have FetchDoubleArray() to optionally calculate dependent formula cells.

Change-Id: Ide29df664ff002f9cd8fe3edbf9512dd0cbb9eb6

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index b119d3d..4601ae2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -471,7 +471,7 @@ public:
 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
 bool ResolveStaticReference( ScMatrix rMat, SCCOL nMatCol, SCROW nRow1, 
SCROW nRow2 );
 void FillMatrix( ScMatrix rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 
) const;
-const double* FetchDoubleArray( sc::FormulaGroupContext rCxt, SCROW 
nRow1, SCROW nRow2 ) const;
+const double* FetchDoubleArray( sc::FormulaGroupContext rCxt, SCROW 
nRow1, SCROW nRow2 );
 void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
 
 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index fd8f61f..8d942b7 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1973,7 +1973,7 @@ public:
 formula::FormulaTokenRef ResolveStaticReference( const ScRange rRange );
 
 const double* FetchDoubleArray(
-sc::FormulaGroupContext rCxt, const ScAddress rPos, SCROW nLength ) 
const;
+sc::FormulaGroupContext rCxt, const ScAddress rPos, SCROW nLength );
 
 SvtBroadcaster* GetBroadcaster( const ScAddress rPos );
 const SvtBroadcaster* GetBroadcaster( const ScAddress rPos ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index bae3818..bda039f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -842,7 +842,7 @@ public:
 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 );
 const double* FetchDoubleArray(
-sc::FormulaGroupContext rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) 
const;
+sc::FormulaGroupContext rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
 
 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 3704c6d..82990ab 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2073,23 +2073,189 @@ void ScColumn::FillMatrix( ScMatrix rMat, size_t 
nMatCol, SCROW nRow1, SCROW nR
 sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
 }
 
-const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext /*rCxt*/, 
SCROW nRow1, SCROW nRow2 ) const
+namespace {
+
+bool appendDouble(
+sc::FormulaGroupContext::DoubleArrayType rArray, size_t nLen,
+sc::CellStoreType::iterator it, const sc::CellStoreType::iterator itEnd )
 {
-// TODO: I'll use the context object later.
-if (nRow1  nRow2)
-return NULL;
+size_t nLenRemain = nLen;
+for (; it != itEnd; ++it)
+{
+switch (it-type)
+{
+case sc::element_type_numeric:
+{
+sc::numeric_block::iterator itData = 
sc::numeric_block::begin(*it-data);
+sc::numeric_block::iterator itDataEnd;
+if (nLenRemain = it-size)
+{
+// Block is shorter than the remaining requested length.
+itDataEnd = sc::numeric_block::end(*it-data);
+nLenRemain -= it-size;
+}
+else
+{
+itDataEnd = itData;
+std::advance(itDataEnd, nLenRemain);
+nLenRemain = 0;
+}
 
-std::pairsc::CellStoreType::const_iterator,size_t aPos = 
maCells.position(nRow1);
-if (aPos.first-type != sc::element_type_numeric)
-// This is not a numeric cell block.
+for (; itData != itDataEnd; ++itData)
+rArray.push_back(*itData);
+}
+break;
+case sc::element_type_formula:
+{
+sc::formula_block::iterator itData = 
sc::formula_block::begin(*it-data);
+sc::formula_block::iterator itDataEnd;
+if (nLenRemain = it-size)
+{
+// Block is shorter than the remaining requested length.
+itDataEnd = sc::formula_block::end(*it-data);
+nLenRemain -= it-size;
+}
+else

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-28 Thread Kohei Yoshida
 sc/inc/calcmacros.hxx|   24 
 sc/inc/dpcache.hxx   |2 +-
 sc/inc/dpfilteredcache.hxx   |2 +-
 sc/inc/dpitemdata.hxx|2 +-
 sc/inc/dpmacros.hxx  |   23 ---
 sc/inc/dpnumgroupinfo.hxx|2 +-
 sc/inc/dpobject.hxx  |2 +-
 sc/inc/dptabdat.hxx  |2 +-
 sc/inc/dptabres.hxx  |2 +-
 sc/inc/mtvelements.hxx   |3 +--
 sc/inc/pivot.hxx |2 +-
 sc/source/core/data/dptabsrc.cxx |2 +-
 sc/source/ui/dbgui/fieldwnd.cxx  |2 +-
 13 files changed, 35 insertions(+), 35 deletions(-)

New commits:
commit 289867cc31e484766ff911a313453323987280e6
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 28 15:22:05 2013 -0400

Start moving all these DEBUG_FOO into calcmacros.hxx.

This header was formerly dpmacros.hxx, now renamed to calcmacros.hxx.

Change-Id: I2ed768b7c5678f5216b1e93df2c0cede0c548be4

diff --git a/sc/inc/dpmacros.hxx b/sc/inc/calcmacros.hxx
similarity index 86%
rename from sc/inc/dpmacros.hxx
rename to sc/inc/calcmacros.hxx
index 72659cc..03ca590 100644
--- a/sc/inc/dpmacros.hxx
+++ b/sc/inc/calcmacros.hxx
@@ -7,9 +7,10 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#ifndef __SC_DPMACROS_HXX__
-#define __SC_DPMACROS_HXX__
+#ifndef SC_CALCMACROS_HXX
+#define SC_CALCMACROS_HXX
 
+#define DEBUG_COLUMN_STORAGE 0
 #define DEBUG_PIVOT_TABLE 0
 
 #if DEBUG_PIVOT_TABLE
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 5a75463..707749c 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -21,7 +21,7 @@
 
 #include global.hxx
 #include dpnumgroupinfo.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 #include tools/date.hxx
 
 #include boost/noncopyable.hpp
diff --git a/sc/inc/dpfilteredcache.hxx b/sc/inc/dpfilteredcache.hxx
index c65b95c..bff1e18 100644
--- a/sc/inc/dpfilteredcache.hxx
+++ b/sc/inc/dpfilteredcache.hxx
@@ -24,7 +24,7 @@
 #include osl/mutex.hxx
 #include global.hxx
 #include dpitemdata.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 #include vector
 #include boost/unordered_set.hpp
diff --git a/sc/inc/dpitemdata.hxx b/sc/inc/dpitemdata.hxx
index 9137e2a..823a6c1 100644
--- a/sc/inc/dpitemdata.hxx
+++ b/sc/inc/dpitemdata.hxx
@@ -16,7 +16,7 @@
 #include sal/types.h
 #include tools/solar.h
 #include rtl/ustring.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 #include dpglobal.hxx
 
 /**
diff --git a/sc/inc/dpnumgroupinfo.hxx b/sc/inc/dpnumgroupinfo.hxx
index 523b792..6989fff 100644
--- a/sc/inc/dpnumgroupinfo.hxx
+++ b/sc/inc/dpnumgroupinfo.hxx
@@ -11,7 +11,7 @@
 #define __SC_DPNUMGROUPINFO_HXX__
 
 #include scdllapi.h
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 struct ScDPNumGroupInfo
 {
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 735b033..bbd3ba8 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -26,7 +26,7 @@
 #include dpoutput.hxx
 #include dptypes.hxx
 #include pivot.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 #include com/sun/star/sheet/XDimensionsSupplier.hpp
 
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 22a8ffb..3239a80 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -24,7 +24,7 @@
 #include dpoutput.hxx
 #include dpfilteredcache.hxx
 #include dpcache.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 #include svl/zforlist.hxx
 
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index e6289be..cab2da8 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -22,7 +22,7 @@
 
 #include global.hxx
 #include dpfilteredcache.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 #include tools/string.hxx
 #include com/sun/star/sheet/MemberResult.hpp
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 0ebf8be..ad65418 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -14,8 +14,7 @@
 #include formulacell.hxx
 #include svl/broadcast.hxx
 #include editeng/editobj.hxx
-
-#define DEBUG_COLUMN_STORAGE 0
+#include calcmacros.hxx
 
 #if DEBUG_COLUMN_STORAGE
 #ifdef NDEBUG
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 85e19e0..12ed637 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -40,7 +40,7 @@
 #include global.hxx
 #include address.hxx
 #include dpglobal.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 #include vector
 #include boost/ptr_container/ptr_vector.hpp
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index c38ee38..76ec9f5 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -45,7 +45,7 @@
 #include dpitemdata.hxx
 #include dputil.hxx
 #include dpresfilter.hxx
-#include dpmacros.hxx
+#include calcmacros.hxx
 
 #include com/sun/star/beans/PropertyAttribute.hpp
 #include com/sun/star/sheet/DataPilotFieldFilter.hpp
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
index 3701081..8673e7f 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-28 Thread Kohei Yoshida
 sc/inc/column.hxx|4 +++
 sc/inc/document.hxx  |5 
 sc/inc/table.hxx |5 
 sc/source/core/data/column2.cxx  |   40 +++
 sc/source/core/data/document.cxx |   11 ++
 sc/source/core/data/table1.cxx   |   10 +
 6 files changed, 75 insertions(+)

New commits:
commit 96e92dc1677f3884ec6a1ec3b67148c28b24bd24
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 28 15:49:43 2013 -0400

Add a convenient way to dump formula group states for a single column.

Useful when debugging.

Change-Id: I4e408ad9a3dc2046557d152fcd067c1b0c5645c0

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4601ae2..6cc3c4b 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -525,6 +525,10 @@ public:
 
 void FormulaCellsUndecided( SCROW nRow1, SCROW nRow2 );
 
+#if DEBUG_COLUMN_STORAGE
+void DumpFormulaGroups() const;
+#endif
+
 private:
 
 sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 8d942b7..806fb77 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -36,6 +36,7 @@
 #include com/sun/star/chart2/XChartDocument.hpp
 #include typedstrdata.hxx
 #include compressedarray.hxx
+#include calcmacros.hxx
 #include tools/fract.hxx
 #include tools/gen.hxx
 
@@ -1984,6 +1985,10 @@ public:
  */
 bool HasBroadcaster( SCTAB nTab, SCCOL nCol ) const;
 
+#if DEBUG_COLUMN_STORAGE
+void DumpFormulaGroups( SCTAB nTab, SCCOL nCol ) const;
+#endif
+
 private: // CLOOK-Impl-methods
 
 /**
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index bda039f..03060bb 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -32,6 +32,7 @@
 #include types.hxx
 #include cellvalue.hxx
 #include formula/types.hxx
+#include calcmacros.hxx
 
 #include set
 #include map
@@ -857,6 +858,10 @@ public:
 
 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, 
size_t nLen );
 
+#if DEBUG_COLUMN_STORAGE
+void DumpFormulaGroups( SCCOL nCol ) const;
+#endif
+
 /** Replace behaves differently to the Search; adjust the rCol and rRow 
accordingly.
 
 'Replace' replaces at the 'current' position, but in order to achieve
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index a7056d0..ae20e44 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1544,6 +1544,46 @@ void ScColumn::FormulaCellsUndecided( SCROW /*nRow1*/, 
SCROW /*nRow2*/ )
 {
 }
 
+#if DEBUG_COLUMN_STORAGE
+
+namespace {
+
+struct FormulaGroupDumper : std::unary_functionsc::CellStoreType::value_type, 
void
+{
+void operator() (const sc::CellStoreType::value_type rNode) const
+{
+if (rNode.type != sc::element_type_formula)
+return;
+
+sc::formula_block::const_iterator it = 
sc::formula_block::begin(*rNode.data);
+sc::formula_block::const_iterator itEnd = 
sc::formula_block::end(*rNode.data);
+
+for (; it != itEnd; ++it)
+{
+const ScFormulaCell rCell = **it;
+if (!rCell.IsShared())
+continue;
+
+if (rCell.GetSharedTopRow() != rCell.aPos.Row())
+continue;
+
+SCROW nLen = rCell.GetSharedLength();
+cout* group: start=  rCell.aPos.Row()  , length=  
nLen  endl;
+std::advance(it, nLen-1);
+}
+}
+};
+
+}
+
+void ScColumn::DumpFormulaGroups() const
+{
+cout  -- formua groups  endl;
+std::for_each(maCells.begin(), maCells.end(), FormulaGroupDumper());
+cout  --  endl;
+}
+#endif
+
 void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn 
rDestCol) const
 {
 rDestCol.maCellTextAttrs.set_empty(nRow1, nRow2); // Empty the destination 
range first.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3ce424f..9d3c72f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2266,6 +2266,17 @@ bool ScDocument::HasBroadcaster( SCTAB nTab, SCCOL nCol 
) const
 return pTab-HasBroadcaster(nCol);
 }
 
+#if DEBUG_COLUMN_STORAGE
+void ScDocument::DumpFormulaGroups( SCTAB nTab, SCCOL nCol ) const
+{
+const ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+return;
+
+pTab-DumpFormulaGroups(nCol);
+}
+#endif
+
 bool ScDocument::TableExists( SCTAB nTab ) const
 {
 return ValidTab(nTab)  static_castsize_t(nTab)  maTabs.size()  
maTabs[nTab];
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index dcd0344..02c8952 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2221,6 +2221,16 @@ void ScTable::SetFormulaResults( SCCOL nCol, SCROW nRow, 
const double* pResults,
 aCol[nCol].SetFormulaResults(nRow, pResults, nLen);
 }
 
+#if DEBUG_COLUMN_STORAGE
+void ScTable::DumpFormulaGroups( SCCOL nCol ) const
+{
+if 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-28 Thread Kohei Yoshida
 sc/inc/scmatrix.hxx  |3 +
 sc/source/core/tool/interpr1.cxx |   65 --
 sc/source/core/tool/scmatrix.cxx |  111 +++
 3 files changed, 116 insertions(+), 63 deletions(-)

New commits:
commit c91c3d161561e6d8e43527b0211ab67de54d47cf
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 28 17:54:34 2013 -0400

Better to calculate max and min value of matrix *in* the matrix itself.

Change-Id: I410b345ac32550a188aa356e133ef8e0e9b13d9f

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 66b271b..d6ac279 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -349,6 +349,9 @@ public:
 IterateResult Product(bool bTextAsZero) const;
 size_t Count(bool bCountStrings) const;
 
+double GetMaxValue( bool bTextAsZero ) const;
+double GetMinValue( bool bTextAsZero ) const;
+
 // All other matrix functions  MatMult, MInv, ...  are in ScInterpreter
 // to be numerically safe.
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index aa55dcb..9cb89ae 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3729,39 +3729,7 @@ void ScInterpreter::ScMin( bool bTextAsZero )
 {
 ScMatrixRef pMat = GetMatrix();
 if (pMat)
-{
-SCSIZE nC, nR;
-nFuncFmtType = NUMBERFORMAT_NUMBER;
-pMat-GetDimensions(nC, nR);
-if (pMat-IsNumeric())
-{
-for (SCSIZE nMatCol = 0; nMatCol  nC; nMatCol++)
-for (SCSIZE nMatRow = 0; nMatRow  nR; nMatRow++)
-{
-nVal = pMat-GetDouble(nMatCol,nMatRow);
-if (nMin  nVal) nMin = nVal;
-}
-}
-else
-{
-for (SCSIZE nMatCol = 0; nMatCol  nC; nMatCol++)
-{
-for (SCSIZE nMatRow = 0; nMatRow  nR; nMatRow++)
-{
-if (!pMat-IsString(nMatCol,nMatRow))
-{
-nVal = pMat-GetDouble(nMatCol,nMatRow);
-if (nMin  nVal) nMin = nVal;
-}
-else if ( bTextAsZero )
-{
-if ( nMin  0.0 )
-nMin = 0.0;
-}
-}
- }
-}
-}
+nMin = pMat-GetMinValue(bTextAsZero);
 }
 break;
 case svString :
@@ -3855,36 +3823,7 @@ void ScInterpreter::ScMax( bool bTextAsZero )
 if (pMat)
 {
 nFuncFmtType = NUMBERFORMAT_NUMBER;
-SCSIZE nC, nR;
-pMat-GetDimensions(nC, nR);
-if (pMat-IsNumeric())
-{
-for (SCSIZE nMatCol = 0; nMatCol  nC; nMatCol++)
-for (SCSIZE nMatRow = 0; nMatRow  nR; nMatRow++)
-{
-nVal = pMat-GetDouble(nMatCol,nMatRow);
-if (nMax  nVal) nMax = nVal;
-}
-}
-else
-{
-for (SCSIZE nMatCol = 0; nMatCol  nC; nMatCol++)
-{
-for (SCSIZE nMatRow = 0; nMatRow  nR; nMatRow++)
-{
-if (!pMat-IsString(nMatCol,nMatRow))
-{
-nVal = pMat-GetDouble(nMatCol,nMatRow);
-if (nMax  nVal) nMax = nVal;
-}
-else if ( bTextAsZero )
-{
-if ( nMax  0.0 )
-nMax = 0.0;
-}
-}
-}
-}
+nMax = pMat-GetMaxValue(bTextAsZero);
 }
 }
 break;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 26fe7d3..bf3ea63 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -223,6 +223,9 @@ public:
 ScMatrix::IterateResult Product(bool bTextAsZero) const;
 size_t Count(bool bCountStrings) const;
 
+double GetMaxValue( bool bTextAsZero ) const;
+ 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-27 Thread Kohei Yoshida
 sc/inc/column.hxx  |   25 +
 sc/source/core/data/column.cxx |   27 ---
 sc/source/core/data/table1.cxx |8 +++-
 3 files changed, 36 insertions(+), 24 deletions(-)

New commits:
commit e51a3433290912a1d491f3fac8109edbae98986b
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jun 27 11:29:46 2013 -0400

ScColumn::UpdateReference to take ScRange as a parameter.

To reduce the number of parameters by 5.  Also add *some* description
of this method esp what the range means when updating formula references.

Change-Id: Iccde58d6ecde6f0c09c111cf9b4f551ce392effb

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index c0dea00..fce1348 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -301,10 +301,27 @@ public:
 
 voidResetChanged( SCROW nStartRow, SCROW nEndRow );
 
-boolUpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, 
SCROW nRow1, SCTAB nTab1,
- SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- ScDocument* pUndoDoc = NULL );
+/**
+ * Update reference addresses in formula cell in response to mass cell
+ * movement.
+ *
+ * @param eUpdateRefMode update mode - insert/delete, copy, move,
+ *   reorder...
+ * @param rRange range of cells that are about to be moved or copied.
+ *   (TODO: find out what this range means for the reorder
+ *   mode).
+ * @param nDx moved by how many cells in the column direction.
+ * @param nDy moved by how many cells in the row direction.
+ * @param nDz moved by how many sheets in the sheet direction.
+ * @param pUndoDoc undo document instance.
+ *
+ * @return true if reference of at least one formula cell has been
+ * updated, false otherwise.
+ */
+bool UpdateReference(
+UpdateRefMode eUpdateRefMode, const ScRange rRange, SCsCOL nDx, 
SCsROW nDy, SCsTAB nDz,
+ScDocument* pUndoDoc = NULL );
+
 void UpdateInsertTab(SCTAB nInsPos, SCTAB nNewSheets = 1);
 void UpdateInsertTabOnlyCells(SCTAB nInsPos, SCTAB nNewSheets = 1);
 void UpdateDeleteTab(SCTAB nDelPos, bool bIsMove, ScColumn* pRefUndo = 
NULL, SCTAB nSheets = 1);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 26edaa9..1a00a15 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1992,9 +1992,8 @@ void ScColumn::CopyScenarioFrom( const ScColumn rSrcCol )
 //  UpdateUsed not needed, already done in TestCopyScenario 
(obsolete comment ?)
 
 SCsTAB nDz = nTab - rSrcCol.nTab;
-UpdateReference(URM_COPY, nCol, nStart, nTab,
-  nCol, nEnd,   nTab,
-  0, 0, nDz, NULL);
+UpdateReference(
+URM_COPY, ScRange(nCol, nStart, nTab, nCol, nEnd, nTab), 0, 0, 
nDz, NULL);
 UpdateCompile();
 }
 
@@ -2023,9 +2022,9 @@ void ScColumn::CopyScenarioTo( ScColumn rDestCol ) const
 //  UpdateUsed not needed, is already done in TestCopyScenario 
(obsolete comment ?)
 
 SCsTAB nDz = rDestCol.nTab - nTab;
-rDestCol.UpdateReference(URM_COPY, rDestCol.nCol, nStart, 
rDestCol.nTab,
-   rDestCol.nCol, nEnd,   
rDestCol.nTab,
-   0, 0, nDz, NULL);
+rDestCol.UpdateReference(
+URM_COPY, ScRange(rDestCol.nCol, nStart, rDestCol.nTab, 
rDestCol.nCol, nEnd, rDestCol.nTab),
+0, 0, nDz, NULL);
 rDestCol.UpdateCompile();
 }
 
@@ -2221,21 +2220,19 @@ public:
 
 }
 
-bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, 
SCROW nRow1, SCTAB nTab1,
- SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, 
SCsTAB nDz,
- ScDocument* pUndoDoc )
+bool ScColumn::UpdateReference(
+UpdateRefMode eUpdateRefMode, const ScRange rRange, SCsCOL nDx, SCsROW 
nDy, SCsTAB nDz,
+ScDocument* pUndoDoc )
 {
-ScRange aRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
-
 if (eUpdateRefMode == URM_COPY)
 {
-UpdateRefOnCopy aHandler(aRange, nDx, nDy, nDz, pUndoDoc);
-FormulaCellsUndecided(nRow1, nRow2);
-sc::ProcessBlock(maCells.begin(), maCells, aHandler, nRow1, nRow2);
+UpdateRefOnCopy aHandler(rRange, nDx, nDy, nDz, pUndoDoc);
+FormulaCellsUndecided(rRange.aStart.Row(), rRange.aEnd.Row());
+sc::ProcessBlock(maCells.begin(), maCells, aHandler, 
rRange.aStart.Row(), rRange.aEnd.Row());
 return aHandler.isUpdated();
 }
 
-UpdateRefOnNonCopy aHandler(nCol, nTab, aRange, nDx, nDy, nDz, 
eUpdateRefMode, pUndoDoc);
+UpdateRefOnNonCopy 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-27 Thread Kohei Yoshida
 sc/inc/formulacell.hxx  |9 
 sc/source/core/data/formulacell.cxx |  399 ++--
 2 files changed, 208 insertions(+), 200 deletions(-)

New commits:
commit f0be3d0ed15179b82910041b827a6313be367a02
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jun 27 14:57:32 2013 -0400

Some attempt to clean ScFormulaCell::UpdateReference() a bit.

This method is still a monster, however...

Change-Id: I4aaa2d20c8ae6132a75c7c92c0a1b58882d8a261

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index b724d02..1f9b960 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -176,11 +176,10 @@ public:
 boolHasRelNameReference() const;
 boolHasColRowName() const;
 
-boolUpdateReference(UpdateRefMode eUpdateRefMode,
-const ScRange r,
-SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-ScDocument* pUndoDoc = NULL,
-const ScAddress* pUndoCellPos = NULL );
+bool UpdateReference(
+UpdateRefMode eUpdateRefMode, const ScRange rRange,
+SCsCOL nDx, SCsROW nDy, SCsTAB nDz, ScDocument* pUndoDoc = NULL,
+const ScAddress* pUndoCellPos = NULL );
 
 voidTransposeReference();
 voidUpdateTranspose( const ScRange rSource, const ScAddress 
rDest,
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 96efc40..224bbea 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -46,8 +46,10 @@
 #include formulagroup.hxx
 #include listenercontext.hxx
 #include types.hxx
+#include scopetools.hxx
 
 #include boost/bind.hpp
+#include boost/scoped_ptr.hpp
 
 using namespace formula;
 
@@ -2039,15 +2041,14 @@ bool ScFormulaCell::HasColRowName() const
 return (pCode-GetNextColRowName() != NULL);
 }
 
-bool ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
-const ScRange r,
-SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-ScDocument* pUndoDoc, const ScAddress* 
pUndoCellPos )
+bool ScFormulaCell::UpdateReference(
+UpdateRefMode eUpdateRefMode, const ScRange rRange, SCsCOL nDx, SCsROW 
nDy, SCsTAB nDz,
+ScDocument* pUndoDoc, const ScAddress* pUndoCellPos )
 {
 bool bCellStateChanged = false;
 
-SCCOL nCol1 = r.aStart.Col();
-SCROW nRow1 = r.aStart.Row();
+SCCOL nCol1 = rRange.aStart.Col();
+SCROW nRow1 = rRange.aStart.Row();
 SCCOL nCol = aPos.Col();
 SCROW nRow = aPos.Row();
 SCTAB nTab = aPos.Tab();
@@ -2055,15 +2056,21 @@ bool ScFormulaCell::UpdateReference(UpdateRefMode 
eUpdateRefMode,
 if ( pUndoCellPos )
 aUndoPos = *pUndoCellPos;
 ScAddress aOldPos( aPos );
-bool bIsInsert = (eUpdateRefMode == URM_INSDEL 
-nDx = 0  nDy = 0  nDz = 0);
-if (eUpdateRefMode == URM_INSDEL  r.In( aPos ))
+bool bIsInsert = (eUpdateRefMode == URM_INSDEL  nDx = 0  nDy = 0  
nDz = 0);
+
+if (eUpdateRefMode == URM_INSDEL  rRange.In(aPos))
 {
+// This formula cell itself is being shifted during cell range
+// insertion or deletion. Update its position.
 aPos.Move(nDx, nDy, nDz);
 bCellStateChanged = aPos != aOldPos;
 }
-else if ( r.In( aPos ) )
+else if (rRange.In(aPos))
 {
+// The cell is being moved or copied to a new position. I guess the
+// position has been updated prior to this call?  Determine
+// its original position before the move which will be used to adjust
+// relative references later.
 aOldPos.Set( nCol - nDx, nRow - nDy, nTab - nDz );
 }
 
@@ -2072,6 +2079,7 @@ bool ScFormulaCell::UpdateReference(UpdateRefMode 
eUpdateRefMode,
 bool bOnRefMove = false;
 if ( !pDocument-IsClipOrUndo() )
 {
+// Check presence of any references or column row names.
 pCode-Reset();
 bHasRefs = (pCode-GetNextReferenceRPN() != NULL);
 if ( !bHasRefs || eUpdateRefMode == URM_COPY )
@@ -2082,218 +2090,219 @@ bool ScFormulaCell::UpdateReference(UpdateRefMode 
eUpdateRefMode,
 }
 bOnRefMove = pCode-IsRecalcModeOnRefMove();
 }
-if( bHasRefs || bOnRefMove )
+
+if (!bHasRefs  !bOnRefMove)
+// This formula cell contains no references, nor needs recalculating
+// on reference update. Bail out.
+return bCellStateChanged;
+
+boost::scoped_ptrScTokenArray pOldCode;
+if (pUndoDoc)
+pOldCode.reset(pCode-Clone());
+
+ScRangeData* pRangeData = NULL;
+bool bValChanged = false;
+bool bRangeModified = false;// any range, not only shared formula
+bool bRefSizeChanged = false;
+
+if (bHasRefs)
 {
-ScTokenArray* pOld = pUndoDoc ? pCode-Clone() : NULL;
-

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-27 Thread Kohei Yoshida
 sc/inc/mtvelements.hxx  |2 +-
 sc/source/core/data/column2.cxx |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 1ebf50a6fc3f444fe04ff53dc7eb68090821d640
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jun 27 15:38:34 2013 -0400

Turn off column debug and remove warnings.

Change-Id: Ic7dd79c1e420e87dcaff4126d60763ff8cbe9344

diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 2c58997..0ebf8be 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -15,7 +15,7 @@
 #include svl/broadcast.hxx
 #include editeng/editobj.hxx
 
-#define DEBUG_COLUMN_STORAGE 1
+#define DEBUG_COLUMN_STORAGE 0
 
 #if DEBUG_COLUMN_STORAGE
 #ifdef NDEBUG
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 7205672..3704c6d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1532,15 +1532,15 @@ void ScColumn::RegroupFormulaCells()
 {
 }
 
-void ScColumn::RegroupFormulaCells( SCROW nRow )
+void ScColumn::RegroupFormulaCells( SCROW /*nRow*/ )
 {
 }
 
-void ScColumn::RegroupFormulaCells( SCROW nRow1, SCROW nRow2 )
+void ScColumn::RegroupFormulaCells( SCROW /*nRow1*/, SCROW /*nRow2*/ )
 {
 }
 
-void ScColumn::FormulaCellsUndecided( SCROW nRow1, SCROW nRow2 )
+void ScColumn::FormulaCellsUndecided( SCROW /*nRow1*/, SCROW /*nRow2*/ )
 {
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-26 Thread Kohei Yoshida
 sc/inc/column.hxx|1 +
 sc/inc/document.hxx  |   10 ++
 sc/inc/table.hxx |2 ++
 sc/source/core/data/column2.cxx  |   26 ++
 sc/source/core/data/documen8.cxx |9 +
 sc/source/core/data/table1.cxx   |8 
 sc/source/core/tool/formulagroup.cxx |9 ++---
 7 files changed, 62 insertions(+), 3 deletions(-)

New commits:
commit d8b0903ef194c78a05541d45dc05c2f860dc7cbf
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jun 26 11:45:28 2013 -0400

Implement a way to set an array of formula results to formula cell group.

Change-Id: Ifdea531e963339607a5066f81af32ffedfd408aa

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 93d292d..974a934 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -447,6 +447,7 @@ public:
 bool ResolveStaticReference( ScMatrix rMat, SCCOL nMatCol, SCROW nRow1, 
SCROW nRow2 );
 void FillMatrix( ScMatrix rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 
) const;
 const double* FetchDoubleArray( sc::FormulaGroupContext rCxt, SCROW 
nRow1, SCROW nRow2 ) const;
+void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
 
 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5069ccc..87975ad 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1703,6 +1703,16 @@ public:
 
 void FillMatrix( ScMatrix rMat, SCTAB nTab, SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 ) const;
 
+/**
+ * Set an array of numerical formula results to a group of contiguous
+ * formula cells.
+ *
+ * @param rTopPos position of the top formula cell of a group.
+ * @param pResults array of numeric results.
+ * @param nLen length of numeric results.
+ */
+void SetFormulaResults( const ScAddress rTopPos, const double* pResults, 
size_t nLen );
+
 private:
 ScDocument(const ScDocument r); // disabled with no definition
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e945477..0d0aa8e 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -849,6 +849,8 @@ public:
 
 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2 );
 
+void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, 
size_t nLen );
+
 /** Replace behaves differently to the Search; adjust the rCol and rRow 
accordingly.
 
 'Replace' replaces at the 'current' position, but in order to achieve
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 80491b5..7205672 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2092,6 +2092,32 @@ const double* ScColumn::FetchDoubleArray( 
sc::FormulaGroupContext /*rCxt*/, SCR
 return sc::numeric_block::at(*aPos.first-data, aPos.second);
 }
 
+void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t 
nLen )
+{
+sc::CellStoreType::position_type aPos = maCells.position(nRow);
+sc::CellStoreType::iterator it = aPos.first;
+if (it-type != sc::element_type_formula)
+// This is not a formula block.
+return;
+
+size_t nBlockLen = it-size - aPos.second;
+if (nBlockLen  nLen)
+// Result array is longer than the length of formula cells. Not good.
+return;
+
+sc::formula_block::iterator itCell = sc::formula_block::begin(*it-data);
+std::advance(itCell, aPos.second);
+
+const double* pResEnd = pResults + nLen;
+for (; pResults != pResEnd; ++pResults, ++itCell)
+{
+ScFormulaCell rCell = **itCell;
+rCell.SetResultDouble(*pResults);
+rCell.ResetDirty();
+rCell.SetChanged(true);
+}
+}
+
 void ScColumn::SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat )
 {
 short eOldType = pDocument-GetFormatTable()-GetType(
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 694b398..71e1878 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -449,6 +449,15 @@ void ScDocument::FillMatrix(
 pTab-FillMatrix(rMat, nCol1, nRow1, nCol2, nRow2);
 }
 
+void ScDocument::SetFormulaResults( const ScAddress rTopPos, const double* 
pResults, size_t nLen )
+{
+ScTable* pTab = FetchTable(rTopPos.Tab());
+if (!pTab)
+return;
+
+pTab-SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen);
+}
+
 
 //
 
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 2de23b1..be6f4ae 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2215,6 +2215,14 @@ void ScTable::InterpretDirtyCells( SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW
 aCol[nCol].InterpretDirtyCells(nRow1, nRow2);
 }
 
+void ScTable::SetFormulaResults( SCCOL nCol, SCROW nRow, const 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-25 Thread Kohei Yoshida
 sc/inc/column.hxx|2 ++
 sc/inc/table.hxx |2 ++
 sc/source/core/data/column3.cxx  |   15 +++
 sc/source/core/data/document.cxx |   18 ++
 sc/source/core/data/table1.cxx   |6 ++
 5 files changed, 35 insertions(+), 8 deletions(-)

New commits:
commit 5873c22ed9b634b4b97d5932f305ae2f5e080b0d
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 25 12:29:46 2013 -0400

Replace ScCellIterator with sc::ProcessFormula.

Change-Id: I0adf57e5e80972175633dd0c69d465544aa7d7a9

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 79c37fc..3cbd7b8 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -455,6 +455,8 @@ public:
 void BroadcastCells( const std::vectorSCROW rRows );
 void EndFormulaListening( sc::ColumnBlockPosition rBlockPos, SCROW nRow1, 
SCROW nRow2 );
 
+void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
+
 private:
 
 void CopyCellsInRangeToColumn(
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index fe88f09..e945477 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -847,6 +847,8 @@ public:
 
 void FillMatrix( ScMatrix rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 ) const;
 
+void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2 );
+
 /** Replace behaves differently to the Search; adjust the rCol and rRow 
accordingly.
 
 'Replace' replaces at the 'current' position, but in order to achieve
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index c85f914..16a4d0a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -115,6 +115,21 @@ void ScColumn::EndFormulaListening( 
sc::ColumnBlockPosition rBlockPos, SCROW nR
 sc::ProcessFormula(rBlockPos.miCellPos, maCells, nRow1, nRow2, aFunc);
 }
 
+struct DirtyCellInterpreter
+{
+void operator() (size_t, ScFormulaCell* p)
+{
+if (p-GetDirty())
+p-Interpret();
+}
+};
+
+void ScColumn::InterpretDirtyCells( SCROW nRow1, SCROW nRow2 )
+{
+DirtyCellInterpreter aFunc;
+sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
+}
+
 void ScColumn::Delete( SCROW nRow )
 {
 std::pairsc::CellStoreType::iterator,size_t aPos = 
maCells.position(nRow);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f40e416..3ed67c3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3482,20 +3482,22 @@ void ScDocument::SetTableOpDirty( const ScRange rRange 
)
 SetAutoCalc( bOldAutoCalc );
 }
 
-
 void ScDocument::InterpretDirtyCells( const ScRangeList rRanges )
 {
+if (!GetAutoCalc())
+return;
+
 for (size_t nPos=0, nRangeCount = rRanges.size(); nPos  nRangeCount; 
nPos++)
 {
-ScCellIterator aIter( this, *rRanges[ nPos ] );
-for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
+const ScRange rRange = *rRanges[nPos];
+for (SCTAB nTab = rRange.aStart.Tab(); nTab = rRange.aEnd.Tab(); 
++nTab)
 {
-if (aIter.getType() != CELLTYPE_FORMULA)
-continue;
+ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+return;
 
-ScFormulaCell* p = aIter.getFormulaCell();
-if (p-GetDirty()  GetAutoCalc())
-p-Interpret();
+pTab-InterpretDirtyCells(
+rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), 
rRange.aEnd.Row());
 }
 }
 }
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index d3d26a8..2de23b1 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2209,6 +2209,12 @@ void ScTable::FillMatrix( ScMatrix rMat, SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2,
 aCol[nCol].FillMatrix(rMat, nMatCol, nRow1, nRow2);
 }
 
+void ScTable::InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 )
+{
+for (SCCOL nCol = nCol1; nCol = nCol2; ++nCol)
+aCol[nCol].InterpretDirtyCells(nRow1, nRow2);
+}
+
 const SvtBroadcaster* ScTable::GetBroadcaster( SCCOL nCol, SCROW nRow ) const
 {
 if (!ValidColRow(nCol, nRow))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-25 Thread Kohei Yoshida
 sc/inc/validat.hxx|1 -
 sc/source/core/inc/interpre.hxx   |1 -
 sc/source/filter/xml/xmlexprt.cxx |   13 +
 sc/source/ui/view/tabview4.cxx|   11 +--
 4 files changed, 2 insertions(+), 24 deletions(-)

New commits:
commit 4f34a4019cc006adfad3332dd05b1c4025da12a2
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 25 12:39:27 2013 -0400

Remove duplicate code blocks.

Change-Id: Ie014ec8866d9e3055a6e67bd20503fc6fc26f503

diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx
index 85737a3..904279a 100644
--- a/sc/inc/validat.hxx
+++ b/sc/inc/validat.hxx
@@ -29,7 +29,6 @@ namespace ValidListType = 
::com::sun::star::sheet::TableValidationVisibility;
 class ScPatternAttr;
 class ScTokenArray;
 class ScTypedStrData;
-class ScCellIterator;
 
 enum ScValidationMode
 {
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 4c8dd4b..75947d6 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -49,7 +49,6 @@ struct ScComplexRefData;
 
 class ScToken;
 class ScJumpMatrix;
-class ScCellIterator;
 struct ScRefCellValue;
 
 #define MAXSTACK  (4096 / sizeof(formula::FormulaToken*))
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 2b72e89..ac5d4b3 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2052,18 +2052,7 @@ void ScXMLExport::_ExportAutoStyles()
 SCTAB nTabCount = pDoc-GetTableCount();
 for (SCTAB nTab=0; nTabnTabCount; ++nTab)
 if (pDoc-IsStreamValid(nTab))
-{
-ScCellIterator aIter( pDoc, ScRange(0, 0, nTab, MAXCOL, 
MAXROW, nTab) );
-for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
-{
-if (aIter.getType() != CELLTYPE_FORMULA)
-continue;
-
-ScFormulaCell* pFC = aIter.getFormulaCell();
-if (pFC)
-pFC-IsValue(); // interpret if dirty
-}
-}
+pDoc-InterpretDirtyCells(ScRange(0, 0, nTab, MAXCOL, 
MAXROW, nTab));
 
 // stored cell styles
 const std::vectorScCellStyleEntry rCellEntries = 
pSheetData-GetCellStyles();
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 227d3d5..8140d51 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -506,16 +506,7 @@ void ScTabView::InterpretVisible()
 if (nX2  MAXCOL) nX2 = MAXCOL;
 if (nY2  MAXROW) nY2 = MAXROW;
 
-ScCellIterator aIter(pDoc, ScRange(nX1, nY1, nTab, nX2, nY2, 
nTab));
-for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
-{
-if (aIter.getType() != CELLTYPE_FORMULA)
-continue;
-
-ScFormulaCell* p = aIter.getFormulaCell();
-if (p-GetDirty())
-p-Interpret();
-}
+pDoc-InterpretDirtyCells(ScRange(nX1, nY1, nTab, nX2, nY2, nTab));
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-25 Thread Kohei Yoshida
 sc/inc/column.hxx   |   22 +
 sc/source/core/data/column.cxx  |   63 +++-
 sc/source/core/data/column2.cxx |   24 ++-
 sc/source/core/data/column3.cxx |   32 
 4 files changed, 127 insertions(+), 14 deletions(-)

New commits:
commit 8406603b8e73b7ac169d569f82d423b34b4745f5
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 25 17:06:45 2013 -0400

Identify spots where we may need to regroup formula cells.

Change-Id: Ib448480bb3a3e39638dd42cafc272934a226cc1e

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 3cbd7b8..69f3420 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -457,6 +457,28 @@ public:
 
 void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
 
+/**
+ * Regroup formula cells for the entire column.
+ */
+void RegroupFormulaCells();
+
+/**
+ * Regroup existing formula cells when a new cell is inserted.
+ *
+ * @param nRow row at which a new cell is inserted.
+ */
+void RegroupFormulaCells( SCROW nRow );
+
+/**
+ * Regroup existing formula cells when a range of new cells are inserted.
+ *
+ * @param nRow1 first row of inserted new cell span.
+ * @param nRow2 last row of inserted new cell span.
+ */
+void RegroupFormulaCells( SCROW nRow1, SCROW nRow2 );
+
+void FormulaCellsUndecided( SCROW nRow1, SCROW nRow2 );
+
 private:
 
 void CopyCellsInRangeToColumn(
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index bd1eeae..ac3ab98 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -886,6 +886,9 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 ScFormulaCell* pNew2 = cloneFormulaCell(pDocument, 
ScAddress(nCol, nRow2, nTab), *pOld1);
 *itf1 = pNew1;
 *itf2 = pNew2;
+
+RegroupFormulaCells(nRow1);
+RegroupFormulaCells(nRow2);
 }
 break;
 default:
@@ -930,6 +933,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 ScFormulaCell* pNew = cloneFormulaCell(pDocument, 
ScAddress(nCol, nRow1, nTab), *aCell2.mpFormula);
 it1 = maCells.set(it1, nRow1, pNew);
 maCells.set_empty(it1, nRow2, nRow2); // original formula cell 
gets deleted.
+
+RegroupFormulaCells(nRow2);
 }
 break;
 default:
@@ -971,6 +976,9 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 ScFormulaCell* pNew = cloneFormulaCell(pDocument, 
ScAddress(nCol, nRow2, nTab), *aCell1.mpFormula);
 it1 = maCells.set_empty(it1, nRow1, nRow1); // original 
formula cell is gone.
 maCells.set(it1, nRow2, pNew);
+
+RegroupFormulaCells(nRow1);
+RegroupFormulaCells(nRow2);
 }
 break;
 default:
@@ -1012,6 +1020,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 }
 
 maCells.set(it1, nRow2, aCell1.mfValue);
+
 }
 break;
 case CELLTYPE_STRING:
@@ -1101,6 +1110,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 }
 
 SwapCellTextAttrs(nRow1, nRow2);
+RegroupFormulaCells(nRow1);
+RegroupFormulaCells(nRow2);
 CellStorageModified();
 BroadcastCells(aRows);
 }
@@ -1125,6 +1136,7 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn rCol)
 ScFormulaCell* pCell2 = rCol.maCells.getScFormulaCell*(nRow);
 if (pCell1)
 updateRefInFormulaCell(*pCell1, rCol.nCol, nTab, rCol.nCol - nCol);
+
 if (pCell2)
 updateRefInFormulaCell(*pCell2, nCol, nTab, nCol - rCol.nCol);
 
@@ -1133,6 +1145,13 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn rCol)
 
 CellStorageModified();
 rCol.CellStorageModified();
+
+if (pCell1 || pCell2)
+{
+// At least one of the two cells is a formula cell. Regroup them.
+RegroupFormulaCells(nRow);
+rCol.RegroupFormulaCells(nRow);
+}
 }
 
 
@@ -1200,15 +1219,18 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize 
)
 maCellTextAttrs.insert_empty(nStartRow, nSize);
 maCellTextAttrs.resize(MAXROWCOUNT);
 
-maCells.insert_empty(nStartRow, nSize);
+// Check if this insertion will split an existing formula block.
+sc::CellStoreType::position_type aPos = maCells.position(nStartRow);
+bool bSplitFormulaBlock = aPos.second != 0;
+
+sc::CellStoreType::iterator it = maCells.insert_empty(aPos.first, 
nStartRow, nSize);
 maCells.resize(MAXROWCOUNT);
 
-bool bOldAutoCalc = pDocument-GetAutoCalc();
-pDocument-SetAutoCalc( false );// avoid recalculations
+sc::AutoCalcSwitch aSwitch(*pDocument, false);
 
 // Get the position of the first affected cell.
-std::pairsc::CellStoreType::iterator,size_t aPos = 
maCells.position(nStartRow+nSize);
-sc::CellStoreType::iterator it = 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-25 Thread Kohei Yoshida
 sc/inc/column.hxx  |4 +
 sc/source/core/data/column.cxx |  104 ++---
 2 files changed, 102 insertions(+), 6 deletions(-)

New commits:
commit 892e74227d872178a3c93682d92a9252d8f5d182
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 25 23:07:25 2013 -0400

Replace CopyCellsInRangeToColumn() with ParseBlock().

Change-Id: I7b7f827fcdb9e31956d0b123ecee8751d791e54f

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 69f3420..c6b3945 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -144,6 +144,10 @@ public:
 const ScDocument GetDoc() const;
 SCTAB GetTab() const { return nTab; }
 SCCOL GetCol() const { return nCol; }
+sc::CellStoreType GetCellStore() { return maCells; }
+const sc::CellStoreType GetCellStore() const { return maCells; }
+sc::CellTextAttrStoreType GetCellAttrStore() { return maCellTextAttrs; }
+const sc::CellTextAttrStoreType GetCellAttrStore() const { return 
maCellTextAttrs; }
 
 ScRefCellValue GetCellValue( SCROW nRow ) const;
 ScRefCellValue GetCellValue( sc::CellStoreType::const_iterator itPos, 
SCROW nRow ) const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index cfea95d..600eb58 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1270,12 +1270,102 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE 
nSize )
 
 namespace {
 
-class CopyToClipHandler : public sc::CellBlockCloneHandler
+class CopyToClipHandler
 {
+const ScColumn mrSrcCol;
+ScColumn mrDestCol;
+sc::ColumnBlockPosition maDestPos;
+
+void setDefaultAttrsToDest(size_t nRow, size_t nSize)
+{
+std::vectorsc::CellTextAttr aAttrs(nSize); // default values
+maDestPos.miCellTextAttrPos = mrDestCol.GetCellAttrStore().set(
+maDestPos.miCellTextAttrPos, nRow, aAttrs.begin(), aAttrs.end());
+}
+
 public:
-CopyToClipHandler(ScDocument rSrcDoc, ScDocument rDestDoc,
-  sc::CellStoreType rDestCellStore, 
sc::CellTextAttrStoreType rDestAttrStore) :
-sc::CellBlockCloneHandler(rSrcDoc, rDestDoc, rDestCellStore, 
rDestAttrStore) {}
+CopyToClipHandler(const ScColumn rSrcCol, ScColumn rDestCol, 
sc::ColumnBlockPosition* pDestPos) :
+mrSrcCol(rSrcCol), mrDestCol(rDestCol)
+{
+if (pDestPos)
+maDestPos = *pDestPos;
+else
+mrDestCol.InitBlockPosition(maDestPos);
+}
+
+void operator() (const sc::CellStoreType::value_type aNode, size_t 
nOffset, size_t nDataSize)
+{
+size_t nTopRow = aNode.position;
+
+switch (aNode.type)
+{
+case sc::element_type_numeric:
+{
+sc::numeric_block::const_iterator it = 
sc::numeric_block::begin(*aNode.data);
+std::advance(it, nOffset);
+sc::numeric_block::const_iterator itEnd = it;
+std::advance(itEnd, nDataSize);
+maDestPos.miCellPos = 
mrDestCol.GetCellStore().set(maDestPos.miCellPos, nTopRow, it, itEnd);
+setDefaultAttrsToDest(nTopRow, nDataSize);
+}
+break;
+case sc::element_type_string:
+{
+sc::string_block::const_iterator it = 
sc::string_block::begin(*aNode.data);
+std::advance(it, nOffset);
+sc::string_block::const_iterator itEnd = it;
+std::advance(itEnd, nDataSize);
+maDestPos.miCellPos = 
mrDestCol.GetCellStore().set(maDestPos.miCellPos, nTopRow, it, itEnd);
+setDefaultAttrsToDest(nTopRow, nDataSize);
+}
+break;
+case sc::element_type_edittext:
+{
+sc::edittext_block::const_iterator it = 
sc::edittext_block::begin(*aNode.data);
+std::advance(it, nOffset);
+sc::edittext_block::const_iterator itEnd = it;
+std::advance(itEnd, nDataSize);
+
+std::vectorEditTextObject* aCloned;
+aCloned.reserve(nDataSize);
+for (; it != itEnd; ++it)
+aCloned.push_back(ScEditUtil::Clone(**it, 
mrDestCol.GetDoc()));
+
+maDestPos.miCellPos = mrDestCol.GetCellStore().set(
+maDestPos.miCellPos, nTopRow, aCloned.begin(), 
aCloned.end());
+
+setDefaultAttrsToDest(nTopRow, nDataSize);
+}
+break;
+case sc::element_type_formula:
+{
+sc::formula_block::const_iterator it = 
sc::formula_block::begin(*aNode.data);
+std::advance(it, nOffset);
+sc::formula_block::const_iterator itEnd = it;
+std::advance(itEnd, nDataSize);
+
+std::vectorScFormulaCell* aCloned;
+aCloned.reserve(nDataSize);
+ScAddress aDestPos(mrDestCol.GetCol(), nTopRow, 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-24 Thread Kohei Yoshida
 sc/inc/formulacell.hxx  |1 +
 sc/source/core/data/dociter.cxx |8 +++-
 sc/source/core/data/formulacell.cxx |   19 +++
 3 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit 3f92f7dc8983b04db104eb0f00aaad5c6810c520
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jun 24 20:46:37 2013 -0400

Avoid redundant if branches.

Instead of calling GetErrCode(), IsValue() and GetValue() individually,
do it all at once. This alone cuts about 12 seconds off in the calculation
involving a large spreadsheet document.

Change-Id: Iee94ca9dae00a2c33c0306cdf41bd7832e7ecd03

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 1c40939..2ac8412 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -213,6 +213,7 @@ public:
 sal_uInt16 GetMatrixEdge( ScAddress rOrgPos ) const;
 sal_uInt16  GetErrCode();   // interpret first if necessary
 sal_uInt16  GetRawError();  // don't interpret, just return code or 
result error
+bool GetErrorOrValue( sal_uInt16 rErr, double rVal );
 sal_uInt8   GetMatrixFlag() const   { return 
cMatrixFlag; }
 ScTokenArray*   GetCode() const { return pCode; }
 
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 3fa15cf..b5b0e4f 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -220,18 +220,16 @@ bool ScValueIterator::GetThis(double rValue, sal_uInt16 
rErr)
 break;
 case sc::element_type_formula:
 {
-ScFormulaCell* pCell = 
sc::formula_block::at(*maCurPos.first-data, maCurPos.second);
-if (bSubTotal  pCell-IsSubTotal())
+ScFormulaCell rCell = 
*sc::formula_block::at(*maCurPos.first-data, maCurPos.second);
+if (bSubTotal  rCell.IsSubTotal())
 {
 // Skip subtotal formula cells.
 IncPos();
 break;
 }
 
-rErr = pCell-GetErrCode();
-if (rErr || pCell-IsValue())
+if (rCell.GetErrorOrValue(rErr, rValue))
 {
-rValue = pCell-GetValue();
 bNumValid = false;
 return true; // Found it!
 }
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 68d242d..15652b5 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1934,6 +1934,25 @@ sal_uInt16 ScFormulaCell::GetRawError()
 return aResult.GetResultError();
 }
 
+bool ScFormulaCell::GetErrorOrValue( sal_uInt16 rErr, double rVal )
+{
+MaybeInterpret();
+
+rErr = pCode-GetCodeError();
+if (rErr)
+return true;
+
+rErr = aResult.GetResultError();
+if (rErr)
+return true;
+
+if (!aResult.IsValue())
+return false;
+
+rVal = aResult.GetDouble();
+return true;
+}
+
 bool ScFormulaCell::HasOneReference( ScRange r ) const
 {
 pCode-Reset();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-24 Thread Kohei Yoshida
 sc/inc/formularesult.hxx  |2 +
 sc/source/core/data/formulacell.cxx   |   10 ---
 sc/source/core/tool/formularesult.cxx |   45 --
 3 files changed, 46 insertions(+), 11 deletions(-)

New commits:
commit 6ff3d0a234635455b9665d9925c609d793ea3185
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Jun 24 21:33:40 2013 -0400

Avoid redundant calls to GetCellResultType().

Change-Id: I105b9f555037b1750af6aaff6fc10d2301afde7c

diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index a88f82d..6736a10 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -132,6 +132,8 @@ public:
 one paragraph */
 bool IsMultiline() const;
 
+bool GetErrorOrDouble( sal_uInt16 rErr, double rVal ) const;
+
 /** Get error code if set or GetCellResultType() is formula::svError or 
svUnknown,
 else 0. */
 sal_uInt16 GetResultError() const;
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 15652b5..e554df4 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1942,15 +1942,7 @@ bool ScFormulaCell::GetErrorOrValue( sal_uInt16 rErr, 
double rVal )
 if (rErr)
 return true;
 
-rErr = aResult.GetResultError();
-if (rErr)
-return true;
-
-if (!aResult.IsValue())
-return false;
-
-rVal = aResult.GetDouble();
-return true;
+return aResult.GetErrorOrDouble(rErr, rVal);
 }
 
 bool ScFormulaCell::HasOneReference( ScRange r ) const
diff --git a/sc/source/core/tool/formularesult.cxx 
b/sc/source/core/tool/formularesult.cxx
index a7c70e6..a106e5f 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -249,13 +249,21 @@ bool ScFormulaResult::IsEmptyDisplayedAsString() const
 return false;
 }
 
-bool ScFormulaResult::IsValue() const
+namespace {
+
+inline bool isValue( formula::StackVar sv )
 {
-formula::StackVar sv = GetCellResultType();
 return sv == formula::svDouble || sv == formula::svError
 || sv == formula::svEmptyCell || sv == formula::svHybridValueCell;
 }
 
+}
+
+bool ScFormulaResult::IsValue() const
+{
+return isValue(GetCellResultType());
+}
+
 bool ScFormulaResult::IsMultiline() const
 {
 if (meMultiline == MULTILINE_UNKNOWN)
@@ -269,6 +277,39 @@ bool ScFormulaResult::IsMultiline() const
 return meMultiline == MULTILINE_TRUE;
 }
 
+bool ScFormulaResult::GetErrorOrDouble( sal_uInt16 rErr, double rVal ) const
+{
+if (mnError)
+{
+rErr = mnError;
+return true;
+}
+
+formula::StackVar sv = GetCellResultType();
+if (sv == formula::svError)
+{
+if (GetType() == formula::svMatrixCell)
+{
+// don't need to test for mpToken here, GetType() already did it
+rErr = static_castconst ScMatrixCellResultToken*(mpToken)-
+GetUpperLeftToken()-GetError();
+}
+else if (mpToken)
+{
+rErr = mpToken-GetError();
+}
+}
+
+if (rErr)
+return true;
+
+if (!isValue(sv))
+return false;
+
+rVal = GetDouble();
+return true;
+}
+
 sal_uInt16 ScFormulaResult::GetResultError() const
 {
 if (mnError)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-24 Thread Kohei Yoshida
 sc/inc/column.hxx|1 
 sc/inc/document.hxx  |2 
 sc/inc/table.hxx |2 
 sc/source/core/data/column2.cxx  |  156 +++
 sc/source/core/data/documen8.cxx |   19 
 sc/source/core/data/table1.cxx   |7 +
 sc/source/core/tool/interpr5.cxx |  125 ---
 7 files changed, 188 insertions(+), 124 deletions(-)

New commits:
commit 792aa859ca22aa151dd2e3bfc9dd570cd2717731
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 25 00:03:11 2013 -0400

Use double and string arrays directly when creating matrix from cells.

Change-Id: Ib251075418baeb7d884696c54504b8851bc9f65e

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index e7c58c1..79c37fc 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -442,6 +442,7 @@ public:
 ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
 bool ResolveStaticReference( ScMatrix rMat, SCCOL nMatCol, SCROW nRow1, 
SCROW nRow2 );
+void FillMatrix( ScMatrix rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 
) const;
 const double* FetchDoubleArray( sc::FormulaGroupContext rCxt, SCROW 
nRow1, SCROW nRow2 ) const;
 
 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 08c4ab6..5069ccc 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1701,6 +1701,8 @@ public:
  */
 bool IsEmptyData( SCTAB nTab, SCCOL nCol ) const;
 
+void FillMatrix( ScMatrix rMat, SCTAB nTab, SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 ) const;
+
 private:
 ScDocument(const ScDocument r); // disabled with no definition
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 65cb180..fe88f09 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -845,6 +845,8 @@ public:
 void DeleteBroadcasters( sc::ColumnBlockPosition rBlockPos, SCCOL nCol, 
SCROW nRow1, SCROW nRow2 );
 bool HasBroadcaster( SCCOL nCol ) const;
 
+void FillMatrix( ScMatrix rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 ) const;
+
 /** Replace behaves differently to the Search; adjust the rCol and rRow 
accordingly.
 
 'Replace' replaces at the 'current' position, but in order to achieve
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 5a0badf..a946e93 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1899,6 +1899,162 @@ bool ScColumn::ResolveStaticReference( ScMatrix rMat, 
SCCOL nMatCol, SCROW nRow
 return aFunc.isSuccess();
 }
 
+namespace {
+
+struct CellBucket
+{
+SCSIZE mnNumValStart;
+SCSIZE mnStrValStart;
+std::vectordouble maNumVals;
+std::vectorOUString maStrVals;
+
+CellBucket() : mnNumValStart(0), mnStrValStart(0) {}
+
+void flush(ScMatrix rMat, SCSIZE nCol)
+{
+if (!maNumVals.empty())
+{
+const double* p = maNumVals[0];
+rMat.PutDouble(p, maNumVals.size(), nCol, mnNumValStart);
+reset();
+}
+else if (!maStrVals.empty())
+{
+const OUString* p = maStrVals[0];
+rMat.PutString(p, maStrVals.size(), nCol, mnStrValStart);
+reset();
+}
+}
+
+void reset()
+{
+mnNumValStart = mnStrValStart = 0;
+maNumVals.clear();
+maStrVals.clear();
+}
+};
+
+class FillMatrixHandler
+{
+ScMatrix mrMat;
+size_t mnMatCol;
+size_t mnTopRow;
+
+SCCOL mnCol;
+SCTAB mnTab;
+
+public:
+FillMatrixHandler(ScMatrix rMat, size_t nMatCol, size_t nTopRow, SCCOL 
nCol, SCTAB nTab) :
+mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), 
mnTab(nTab) {}
+
+void operator() (const sc::CellStoreType::value_type node, size_t 
nOffset, size_t nDataSize)
+{
+size_t nMatRow = node.position + nOffset - mnTopRow;
+
+switch (node.type)
+{
+case sc::element_type_numeric:
+{
+const double* p = sc::numeric_block::at(*node.data, nOffset);
+mrMat.PutDouble(p, nDataSize, mnMatCol, nMatRow);
+}
+break;
+case sc::element_type_string:
+{
+const OUString* p = sc::string_block::at(*node.data, nOffset);
+mrMat.PutString(p, nDataSize, mnMatCol, nMatRow);
+}
+break;
+case sc::element_type_edittext:
+{
+std::vectorOUString aStrs;
+aStrs.reserve(nDataSize);
+sc::edittext_block::const_iterator it = 
sc::edittext_block::begin(*node.data);
+std::advance(it, nOffset);
+sc::edittext_block::const_iterator itEnd = it;
+std::advance(itEnd, nDataSize);
+for (; it != itEnd; ++it)
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-21 Thread Kohei Yoshida
 sc/inc/fillinfo.hxx  |8 +---
 sc/source/core/data/fillinfo.cxx |1 -
 2 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit f8421c030d5c22d17e16fdbf3c99154a41cb9156
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 21 16:16:24 2013 -0400

Make them officially non-copyable.

Change-Id: Ie8f8c2227b35ffb81f902458ce1b0a732b430b53

diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index a55d638..a89 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -25,6 +25,8 @@
 #include colorscale.hxx
 #include cellvalue.hxx
 
+#include boost/noncopyable.hpp
+
 class SfxItemSet;
 class SvxBrushItem;
 class SvxBoxItem;
@@ -90,7 +92,7 @@ struct ScIconSetInfo
 bool mbShowValue;
 };
 
-struct CellInfo
+struct CellInfo : boost::noncopyable
 {
 ScRefCellValue  maCell;
 
@@ -145,7 +147,7 @@ struct CellInfo
 
 const SCCOL SC_ROTMAX_NONE = SCCOL_MAX;
 
-struct RowInfo
+struct RowInfo : boost::noncopyable
 {
 CellInfo*   pCellInfo;
 
@@ -166,7 +168,7 @@ private:
 RowInfooperator=( const RowInfo );
 };
 
-struct ScTableInfo
+struct ScTableInfo : boost::noncopyable
 {
 svx::frame::Array   maArray;
 RowInfo*mpRowInfo;
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index c0c02d6..34c2562 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -323,7 +323,6 @@ void ScDocument::FillInfo(
 //! Conditionals auch bei HASATTR_ROTATE abfragen 
 
 OSL_ENSURE( nArrCount2, nArrCount too small );
-//  FindMaxRotCol( nTab, pRowInfo[1], nArrCount-2, nX1, nX2 );
 FindMaxRotCol( nTab, pRowInfo[1], nArrCount-1, nCol1, nCol2 );
 //  FindMaxRotCol setzt nRotMaxCol
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-19 Thread Kohei Yoshida
 sc/inc/cellclonehandler.hxx  |   17 +++--
 sc/source/core/data/cellclonehandler.cxx |   47 +++---
 sc/source/core/data/column.cxx   |  101 +++
 sc/source/core/data/column2.cxx  |4 +
 sc/source/core/data/column3.cxx  |   18 +
 5 files changed, 120 insertions(+), 67 deletions(-)

New commits:
commit 854176b039e41ba12c56c311699b514b4e625784
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jun 19 11:19:26 2013 -0400

Have the clone handler handle the text attr array as well.

In order to handle the special case of cell removal.

Change-Id: I7782232ce0fe6c0248c40482ec62d909d2dfe621

diff --git a/sc/inc/cellclonehandler.hxx b/sc/inc/cellclonehandler.hxx
index a08383c..4ae8123 100644
--- a/sc/inc/cellclonehandler.hxx
+++ b/sc/inc/cellclonehandler.hxx
@@ -25,32 +25,39 @@ class CellBlockCloneHandler
 ScDocument mrSrcDoc;
 ScDocument mrDestDoc;
 CellStoreType mrDestCellStore;
+CellTextAttrStoreType mrDestAttrStore;
 
 protected:
 ScDocument getSrcDoc();
 ScDocument getDestDoc();
 const ScDocument getDestDoc() const;
 CellStoreType getDestCellStore();
+CellTextAttrStoreType getDestAttrStore();
+
+void setDefaultAttrToDest(ColumnBlockPosition rPos, SCROW nRow);
+void setDefaultAttrsToDest(ColumnBlockPosition rPos, SCROW nRow, size_t 
nSize);
 
 public:
 CellBlockCloneHandler(
-ScDocument rSrcDoc, ScDocument rDestDoc, CellStoreType 
rDestCellStore);
+ScDocument rSrcDoc, ScDocument rDestDoc,
+CellStoreType rDestCellStore, CellTextAttrStoreType rDestAttrStore);
+
 virtual ~CellBlockCloneHandler();
 
 virtual void cloneDoubleBlock(
-CellStoreType::iterator itPos, const ScAddress rSrcPos, const 
ScAddress rDestPos,
+ColumnBlockPosition rPos, const ScAddress rSrcPos, const ScAddress 
rDestPos,
 const numeric_block::const_iterator itBegin, const 
numeric_block::const_iterator itEnd);
 
 virtual void cloneStringBlock(
-CellStoreType::iterator itPos, const ScAddress rSrcPos, const 
ScAddress rDestPos,
+ColumnBlockPosition rPos, const ScAddress rSrcPos, const ScAddress 
rDestPos,
 const string_block::const_iterator itBegin, const 
string_block::const_iterator itEnd);
 
 virtual void cloneEditTextBlock(
-CellStoreType::iterator itPos, const ScAddress rSrcPos, const 
ScAddress rDestPos,
+ColumnBlockPosition rPos, const ScAddress rSrcPos, const ScAddress 
rDestPos,
 const edittext_block::const_iterator itBegin, const 
edittext_block::const_iterator itEnd);
 
 virtual void cloneFormulaBlock(
-CellStoreType::iterator itPos, const ScAddress rSrcPos, const 
ScAddress rDestPos,
+ColumnBlockPosition rPos, const ScAddress rSrcPos, const ScAddress 
rDestPos,
 const formula_block::const_iterator itBegin, const 
formula_block::const_iterator itEnd);
 };
 
diff --git a/sc/source/core/data/cellclonehandler.cxx 
b/sc/source/core/data/cellclonehandler.cxx
index 1f1d75c..8f5bd17 100644
--- a/sc/source/core/data/cellclonehandler.cxx
+++ b/sc/source/core/data/cellclonehandler.cxx
@@ -14,8 +14,10 @@
 namespace sc {
 
 CellBlockCloneHandler::CellBlockCloneHandler(
-ScDocument rSrcDoc, ScDocument rDestDoc, CellStoreType rDestCellStore) :
-mrSrcDoc(rSrcDoc), mrDestDoc(rDestDoc), mrDestCellStore(rDestCellStore) {}
+ScDocument rSrcDoc, ScDocument rDestDoc,
+CellStoreType rDestCellStore, CellTextAttrStoreType rDestAttrStore) :
+mrSrcDoc(rSrcDoc), mrDestDoc(rDestDoc),
+mrDestCellStore(rDestCellStore), mrDestAttrStore(rDestAttrStore) {}
 
 CellBlockCloneHandler::~CellBlockCloneHandler() {}
 
@@ -39,22 +41,41 @@ CellStoreType CellBlockCloneHandler::getDestCellStore()
 return mrDestCellStore;
 }
 
+CellTextAttrStoreType CellBlockCloneHandler::getDestAttrStore()
+{
+return mrDestAttrStore;
+}
+
+void CellBlockCloneHandler::setDefaultAttrToDest(ColumnBlockPosition rPos, 
SCROW nRow)
+{
+rPos.miCellTextAttrPos = mrDestAttrStore.set(rPos.miCellTextAttrPos, nRow, 
CellTextAttr());
+}
+
+void CellBlockCloneHandler::setDefaultAttrsToDest(ColumnBlockPosition rPos, 
SCROW nRow, size_t nSize)
+{
+std::vectorsc::CellTextAttr aAttrs(nSize); // default values
+rPos.miCellTextAttrPos = mrDestAttrStore.set(
+rPos.miCellTextAttrPos, nRow, aAttrs.begin(), aAttrs.end());
+}
+
 void CellBlockCloneHandler::cloneDoubleBlock(
-CellStoreType::iterator itPos, const ScAddress /*rSrcPos*/, const 
ScAddress rDestPos,
+ColumnBlockPosition rPos, const ScAddress /*rSrcPos*/, const ScAddress 
rDestPos,
 const numeric_block::const_iterator itBegin, const 
numeric_block::const_iterator itEnd)
 {
-itPos = mrDestCellStore.set(itPos, rDestPos.Row(), itBegin, itEnd);
+rPos.miCellPos = mrDestCellStore.set(rPos.miCellPos, rDestPos.Row(), 
itBegin, itEnd);
+setDefaultAttrsToDest(rPos, rDestPos.Row(), std::distance(itBegin, 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-19 Thread Kohei Yoshida
 sc/inc/dociter.hxx  |2 
 sc/source/core/data/dociter.cxx |   83 +---
 2 files changed, 61 insertions(+), 24 deletions(-)

New commits:
commit a859bb34457b8c20839a2790ff9bb954b11adf53
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jun 19 16:48:32 2013 -0400

Fix the horizontal cell iterator.

I got its logic totally wrong. Now it works.

Change-Id: I79e556da19c7c0b0d8cecbb4875d6d21d5ec4208

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 87d17b2..2452a60 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -410,8 +410,6 @@ public:
 
 class ScHorizontalCellIterator  // walk through all non empty cells in an 
area
 {   // row by row
-typedef std::pairsc::CellStoreType::const_iterator,size_t PositionType;
-
 struct ColParam
 {
 sc::CellStoreType::const_iterator maPos;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 7479097..207c305 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1686,7 +1686,7 @@ bool ScQueryCellIterator::BinarySearch()
 
 ScHorizontalCellIterator::ScHorizontalCellIterator(ScDocument* pDocument, 
SCTAB nTable,
 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 ) :
-maColPositions(nCol2-nCol2+1),
+maColPositions(nCol2-nCol1+1),
 pDoc( pDocument ),
 mnTab( nTable ),
 nStartCol( nCol1 ),
@@ -1782,35 +1782,74 @@ void ScHorizontalCellIterator::Advance()
 }
 
 // Move to the next row that has at least one non-empty cell.
-size_t nMinRow = MAXROW+1;
-size_t nMinRowCol = maColPositions.size();
-for (size_t i = 0, n = maColPositions.size(); i  n; ++i)
+++mnRow;
+while (mnRow = nEndRow)
 {
-ColParam r = maColPositions[i];
-if (r.maPos == r.maEnd)
-// This column has ended.
-continue;
+size_t nRow = static_castsize_t(mnRow);
+size_t nNextRow = MAXROW+1;
+size_t nNextRowPos = 0;
+for (size_t i = nNextRowPos, n = maColPositions.size(); i  n; ++i)
+{
+ColParam r = maColPositions[i];
+if (r.maPos == r.maEnd)
+// This column has ended.
+continue;
 
-// Move to the next block.
-++r.maPos;
+if (nRow  r.maPos-position)
+{
+// This block is ahread of the current row position. Skip it.
+if (r.maPos-position  nNextRow)
+{
+nNextRow = r.maPos-position;
+nNextRowPos = i;
+}
+continue;
+}
+
+if (r.maPos-position + r.maPos-size = nRow)
+{
+// This block is behind the current row position. Advance the 
block.
+for (++r.maPos; r.maPos != r.maEnd; ++r.maPos)
+{
+if (nRow  r.maPos-position + r.maPos-size)
+break;
+}
 
-if (r.maPos != r.maEnd  r.maPos-position  nMinRow)
+if (r.maPos == r.maEnd)
+// This column has ended.
+continue;
+}
+
+if (r.maPos-type == sc::element_type_empty)
+{
+// Empty block. Move to the next block and try next column.
+++r.maPos;
+if (r.maPos-position  nNextRow)
+{
+nNextRow = r.maPos-position;
+nNextRowPos = i;
+}
+continue;
+}
+
+// Found a non-empty cell block!
+mnCol = i + nStartCol;
+mnRow = nRow;
+bMore = true;
+return;
+}
+
+if (nNextRow  MAXROW)
 {
-nMinRow = r.maPos-position;
-nMinRowCol = i;
+// No more blocks to search.
+bMore = false;
+return;
 }
-}
 
-if (nMinRowCol == maColPositions.size() || static_castSCROW(nMinRow)  
nEndRow)
-{
-// No more cells found.
-bMore = false;
-return;
+mnRow = nNextRow; // move to the next non-empty row.
 }
 
-mnCol = nMinRowCol + nStartCol;
-mnRow = nMinRow;
-bMore = true;
+bMore = false;
 }
 
 //
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-18 Thread Kohei Yoshida
 sc/inc/cell.hxx |4 
 sc/inc/formulacell.hxx  |6 ++
 sc/source/core/data/attarray.cxx|1 +
 sc/source/core/data/cell.cxx|   26 --
 sc/source/core/data/cellvalue.cxx   |2 +-
 sc/source/core/data/colorscale.cxx  |4 ++--
 sc/source/core/data/documen2.cxx|2 +-
 sc/source/core/data/formulacell.cxx |6 +-
 sc/source/core/data/table2.cxx  |2 +-
 sc/source/core/data/validat.cxx |2 +-
 sc/source/ui/undo/undoblk3.cxx  |1 +
 sc/source/ui/unoobj/chart2uno.cxx   |2 +-
 12 files changed, 12 insertions(+), 46 deletions(-)

New commits:
commit 2bd775d61e3cf0b7cc68004cd4ff6807b5edb8c2
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 18 15:11:30 2013 -0400

ScFormulaCell is no longer a child class of ScBaseCell.

Change-Id: Id33072f193045e2eaf51373b47dac803f9a5d52c

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 597feb8..860104b 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -55,10 +55,6 @@ public:
 broadcaster will not be cloned. */
 ScBaseCell* Clone( ScDocument rDestDoc, const ScAddress rDestPos, 
int nCloneFlags = SC_CLONECELL_DEFAULT ) const;
 
-/** Due to the fact that ScBaseCell does not have a vtable, this function
-deletes the cell by calling the appropriate d'tor of the derived 
class. */
-voidDelete();
-
 inline CellType GetCellType() const { return (CellType)eCellType; }
 
 /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may 
have been
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index af9067e..196e6bf 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -20,7 +20,6 @@
 #ifndef SC_FORMULACELL_HXX
 #define SC_FORMULACELL_HXX
 
-#include cell.hxx
 #include formularesult.hxx
 
 #include formula/tokenarray.hxx
@@ -35,6 +34,7 @@ class EndListeningContext;
 
 }
 
+class ScProgress;
 class ScTokenArray;
 struct ScSimilarFormulaDelta;
 
@@ -65,7 +65,7 @@ enum ScMatrixMode {
 MM_FAKE  = 3// Interpret as-if matrix formula 
(legacy)
 };
 
-class SC_DLLPUBLIC ScFormulaCell : public ScBaseCell, public SvtListener
+class SC_DLLPUBLIC ScFormulaCell : public SvtListener
 {
 private:
 ScFormulaResult aResult;
@@ -113,8 +113,6 @@ public:
 
 ~ScFormulaCell();
 
-using ScBaseCell::Clone;
-
 ScFormulaCell* Clone() const;
 
 /** Empty formula cell, or with a preconstructed token array. */
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 7ef3103..9447bb9 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -40,6 +40,7 @@
 #include rechead.hxx
 #include globstr.hrc
 #include segmenttree.hxx
+#include cell.hxx
 #include formulacell.hxx
 #include cellvalue.hxx
 #include editutil.hxx
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 6ccc80a..9010752 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -60,8 +60,6 @@ ScBaseCell* lclCloneCell( const ScBaseCell rSrcCell, 
ScDocument rDestDoc, cons
 return new ScStringCell( static_cast const ScStringCell ( 
rSrcCell ) );
 case CELLTYPE_EDIT:
 return new ScEditCell(static_castconst ScEditCell(rSrcCell), 
rDestDoc, rDestPos);
-case CELLTYPE_FORMULA:
-return new ScFormulaCell( static_cast const ScFormulaCell ( 
rSrcCell ), rDestDoc, rDestPos, nCloneFlags );
 default:;
 }
 OSL_FAIL( lclCloneCell - unknown cell type );
@@ -74,8 +72,6 @@ ScBaseCell* ScBaseCell::Clone( ScDocument rDestDoc, int 
nCloneFlags ) const
 {
 // notes will not be cloned - cell address only needed for formula cells
 ScAddress aDestPos;
-if( eCellType == CELLTYPE_FORMULA )
-aDestPos = static_cast const ScFormulaCell* ( this )-aPos;
 return lclCloneCell( *this, rDestDoc, aDestPos, nCloneFlags );
 }
 
@@ -84,28 +80,6 @@ ScBaseCell* ScBaseCell::Clone( ScDocument rDestDoc, const 
ScAddress rDestPos,
 return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags );
 }
 
-void ScBaseCell::Delete()
-{
-switch (eCellType)
-{
-case CELLTYPE_VALUE:
-delete (ScValueCell*) this;
-break;
-case CELLTYPE_STRING:
-delete (ScStringCell*) this;
-break;
-case CELLTYPE_EDIT:
-delete (ScEditCell*) this;
-break;
-case CELLTYPE_FORMULA:
-delete (ScFormulaCell*) this;
-break;
-default:
-OSL_FAIL(Attempt to Delete() an unknown CELLTYPE);
-break;
-}
-}
-
 bool ScBaseCell::HasEmptyData() const
 {
 switch ( eCellType )
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index 169d2f7..abc1bbc 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -172,7 +172,7 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-18 Thread Kohei Yoshida
 sc/inc/global.hxx |3 ---
 sc/source/core/data/autonamecache.cxx |3 ---
 sc/source/core/data/cell.cxx  |   13 +
 sc/source/core/data/formulacell.cxx   |3 ---
 sc/source/core/tool/interpr4.cxx  |6 --
 sc/source/ui/unoobj/chart2uno.cxx |3 ---
 6 files changed, 5 insertions(+), 26 deletions(-)

New commits:
commit 56df91ba3887a25e43661cc77b155a2149a6217a
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 18 15:24:59 2013 -0400

CELLTYPE_DESTROYED no longer relevant. Chuck it.

Change-Id: Ie56cf8dc87eebd801cdb68ce70ffae7bcd16e4d7

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index f823232..dd60c4b 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -287,9 +287,6 @@ enum CellType
 CELLTYPE_STRING,
 CELLTYPE_FORMULA,
 CELLTYPE_EDIT,
-#if OSL_DEBUG_LEVEL  0
-CELLTYPE_DESTROYED
-#endif
 };
 
 enum DelCellCmd
diff --git a/sc/source/core/data/autonamecache.cxx 
b/sc/source/core/data/autonamecache.cxx
index ab03a95..5d2257b 100644
--- a/sc/source/core/data/autonamecache.cxx
+++ b/sc/source/core/data/autonamecache.cxx
@@ -81,9 +81,6 @@ const ScAutoNameAddresses 
ScAutoNameCache::GetNameOccurrences( const String rN
 break;
 case CELLTYPE_NONE:
 case CELLTYPE_VALUE:
-#if OSL_DEBUG_LEVEL  0
-case CELLTYPE_DESTROYED:
-#endif
 ;   // nothing, prevent compiler warning
 break;
 }
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 9010752..102daef 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -45,12 +45,11 @@ ScBaseCell::ScBaseCell( const ScBaseCell rCell ) :
 
 ScBaseCell::~ScBaseCell()
 {
-OSL_ENSURE( eCellType == CELLTYPE_DESTROYED, BaseCell Destructor );
 }
 
 namespace {
 
-ScBaseCell* lclCloneCell( const ScBaseCell rSrcCell, ScDocument rDestDoc, 
const ScAddress rDestPos, int nCloneFlags )
+ScBaseCell* lclCloneCell( const ScBaseCell rSrcCell, ScDocument rDestDoc, 
const ScAddress rDestPos )
 {
 switch( rSrcCell.GetCellType() )
 {
@@ -68,16 +67,16 @@ ScBaseCell* lclCloneCell( const ScBaseCell rSrcCell, 
ScDocument rDestDoc, cons
 
 } // namespace
 
-ScBaseCell* ScBaseCell::Clone( ScDocument rDestDoc, int nCloneFlags ) const
+ScBaseCell* ScBaseCell::Clone( ScDocument rDestDoc, int ) const
 {
 // notes will not be cloned - cell address only needed for formula cells
 ScAddress aDestPos;
-return lclCloneCell( *this, rDestDoc, aDestPos, nCloneFlags );
+return lclCloneCell( *this, rDestDoc, aDestPos );
 }
 
-ScBaseCell* ScBaseCell::Clone( ScDocument rDestDoc, const ScAddress 
rDestPos, int nCloneFlags ) const
+ScBaseCell* ScBaseCell::Clone( ScDocument rDestDoc, const ScAddress 
rDestPos, int ) const
 {
-return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags );
+return lclCloneCell( *this, rDestDoc, rDestPos );
 }
 
 bool ScBaseCell::HasEmptyData() const
@@ -147,7 +146,6 @@ ScValueCell::ScValueCell( double fValue ) :
 #if OSL_DEBUG_LEVEL  0
 ScValueCell::~ScValueCell()
 {
-eCellType = CELLTYPE_DESTROYED;
 }
 #endif
 
@@ -162,7 +160,6 @@ ScStringCell::ScStringCell( const OUString rString ) :
 #if OSL_DEBUG_LEVEL  0
 ScStringCell::~ScStringCell()
 {
-eCellType = CELLTYPE_DESTROYED;
 }
 #endif
 
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index ddbe216..845fa33 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -599,9 +599,6 @@ ScFormulaCell::~ScFormulaCell()
 pDocument-GetExternalRefManager()-removeRefCell(this);
 
 delete pCode;
-#if OSL_DEBUG_LEVEL  0
-eCellType = CELLTYPE_DESTROYED;
-#endif
 }
 
 ScFormulaCell* ScFormulaCell::Clone() const
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index adbf268..2811c46 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -500,12 +500,6 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress 
rPos, ScRefCellValue
 case CELLTYPE_NONE:
 fValue = 0.0;   // empty or broadcaster cell
 break;
-#if OSL_DEBUG_LEVEL  0
-case CELLTYPE_DESTROYED:
-SetError(errCellNoValue);
-fValue = 0.0;
-break;
-#endif
 }
 
 return fValue;
diff --git a/sc/source/ui/unoobj/chart2uno.cxx 
b/sc/source/ui/unoobj/chart2uno.cxx
index 778d562..600efb2 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2619,9 +2619,6 @@ void ScChart2DataSequence::BuildDataCache()
 }
 }
 break;
-#if OSL_DEBUG_LEVEL  0
-case CELLTYPE_DESTROYED:
-#endif
 case CELLTYPE_EDIT:
 case CELLTYPE_NONE:
 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-06-18 Thread Kohei Yoshida
 sc/inc/cell.hxx   |  204 --
 sc/source/core/data/cell.cxx  |  166 --
 sc/source/core/data/cell2.cxx |  156 
 3 files changed, 526 deletions(-)

New commits:
commit 2f0e2ff8aa2028a9edaaffc90b1a05092176c68d
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jun 18 15:39:14 2013 -0400

Put ScBaseCell, ScValueCell, ScStringCell, ScEditCell to eternal rest.

You had your day. Now it's time for us to part ways.

Change-Id: I4bd5797adf2091387cacaf6474069c3f9f20c134

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
deleted file mode 100644
index aef29df..000
--- a/sc/inc/cell.hxx
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the License); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef SC_CELL_HXX
-#define SC_CELL_HXX
-
-#include scdllapi.h
-#include global.hxx
-
-#include tools/mempool.hxx
-
-#include boost/shared_ptr.hpp
-
-#define USE_MEMPOOL
-
-class ScDocument;
-class EditTextObject;
-class ScMatrix;
-class SvtBroadcaster;
-class ScProgress;
-class ScPatternAttr;
-
-class ScBaseCell
-{
-protected:
-~ScBaseCell();  // not virtual - not to be called directly.
-
-public:
-explicitScBaseCell( CellType eNewType );
-
-/** Base copy constructor. Does NOT clone cell note or broadcaster! */
-ScBaseCell( const ScBaseCell rCell );
-
-/** Returns a clone of this cell at the same position,
-broadcaster will not be cloned. */
-ScBaseCell* Clone( ScDocument rDestDoc, int nCloneFlags = 
SC_CLONECELL_DEFAULT ) const;
-
-/** Returns a clone of this cell for the passed document position,
-broadcaster will not be cloned. */
-ScBaseCell* Clone( ScDocument rDestDoc, const ScAddress rDestPos, 
int nCloneFlags = SC_CLONECELL_DEFAULT ) const;
-
-inline CellType GetCellType() const { return (CellType)eCellType; }
-
-/** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may 
have been
-created due to reference to empty cell). */
-boolHasEmptyData() const;
-boolHasValueData() const;
-boolHasStringData() const;
-OUString   GetStringData() const;  // only real strings
-
-private:
-ScBaseCell operator=( const ScBaseCell );
-
-protected:
-sal_uInt8eCellType;  // enum CellType - sal_uInt8 spart 
Speicher
-};
-
-class ScValueCell : public ScBaseCell
-{
-public:
-#ifdef USE_MEMPOOL
-DECL_FIXEDMEMPOOL_NEWDEL( ScValueCell )
-#endif
-
-explicitScValueCell( double fValue );
-
-#if OSL_DEBUG_LEVEL  0
-~ScValueCell();
-#endif
-
-inline void SetValue( double fValue ) { mfValue = fValue; }
-inline double   GetValue() const { return mfValue; }
-double* GetValuePtr() { return mfValue; }
-
-private:
-double  mfValue;
-};
-
-class ScStringCell : public ScBaseCell
-{
-public:
-#ifdef USE_MEMPOOL
-DECL_FIXEDMEMPOOL_NEWDEL( ScStringCell )
-#endif
-
-explicitScStringCell(const OUString rString);
-
-#if OSL_DEBUG_LEVEL  0
-~ScStringCell();
-#endif
-
-inline void SetString( const OUString rString ) { maString = rString; 
}
-inline constOUString GetString() const { return maString; }
-const OUString* GetStringPtr() const { return maString; }
-
-private:
-OUString   maString;
-};
-
-class ScEditCell : public ScBaseCell
-{
-EditTextObject* mpData;
-mutable OUString* mpString;// for faster access to formulas
-ScDocument* mpDoc;   // for EditEngine access with Pool
-
-voidSetTextObject( const EditTextObject* pObject,
-const SfxItemPool* pFromPool );
-
-// not implemented
-ScEditCell( const ScEditCell );
-
-public:
-
-#ifdef USE_MEMPOOL
-DECL_FIXEDMEMPOOL_NEWDEL( ScEditCell )
-#endif
-
-~ScEditCell();  // always because of pData!
-
-/**
- * Constructor that takes ownership of the passed 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-22 Thread Kohei Yoshida
 sc/inc/columniterator.hxx  |4 +--
 sc/inc/mtvelements.hxx |   41 +++--
 sc/source/core/data/column2.cxx|   20 
 sc/source/core/data/columniterator.cxx |6 ++--
 4 files changed, 49 insertions(+), 22 deletions(-)

New commits:
commit 2e77d3e3e38b5ba667329493382b793477abb5d6
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed May 22 20:27:24 2013 -0400

Define block types for string, edit text and formula cell elements.

Also, remove the custom_ prefix from block names.

Change-Id: If3dfdbdacc2d0113fa8d631bec7a914b51668115

diff --git a/sc/inc/columniterator.hxx b/sc/inc/columniterator.hxx
index 69929aa..f15d6d5 100644
--- a/sc/inc/columniterator.hxx
+++ b/sc/inc/columniterator.hxx
@@ -21,8 +21,8 @@ class ScColumnTextWidthIterator : boost::noncopyable
 size_t mnCurPos;
 sc::CellTextAttrStoreType::iterator miBlockCur;
 sc::CellTextAttrStoreType::iterator miBlockEnd;
-sc::custom_celltextattr_block::iterator miDataCur;
-sc::custom_celltextattr_block::iterator miDataEnd;
+sc::celltextattr_block::iterator miDataCur;
+sc::celltextattr_block::iterator miDataEnd;
 
 public:
 ScColumnTextWidthIterator(ScColumn rCol, SCROW nStartRow, SCROW nEndRow);
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 1628381..941c1a24a 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -11,7 +11,9 @@
 #define SC_MTVELEMENTS_HXX
 
 #include address.hxx
+#include formulacell.hxx
 #include svl/broadcast.hxx
+#include editeng/editobj.hxx
 
 #define DEBUG_COLUMN_STORAGE 0
 
@@ -25,6 +27,7 @@
 #include mdds/multi_type_vector_macro.hpp
 #include mdds/multi_type_vector.hpp
 #include mdds/multi_type_vector_custom_func1.hpp
+#include mdds/multi_type_vector_custom_func3.hpp
 
 #include boost/unordered_map.hpp
 
@@ -47,29 +50,53 @@ struct CellTextAttr
 const mdds::mtv::element_t element_type_broadcaster = 
mdds::mtv::element_type_user_start;
 const mdds::mtv::element_t element_type_celltextattr = 
mdds::mtv::element_type_user_start + 1;
 
+const mdds::mtv::element_t element_type_string = 
mdds::mtv::element_type_user_start + 2;
+const mdds::mtv::element_t element_type_edittext = 
mdds::mtv::element_type_user_start + 3;
+const mdds::mtv::element_t element_type_formula = 
mdds::mtv::element_type_user_start + 4;
+
+const mdds::mtv::element_t element_type_numeric = 
mdds::mtv::element_type_numeric;
+
 // Custom element blocks.
 
-typedef mdds::mtv::noncopyable_managed_element_blockelement_type_broadcaster, 
SvtBroadcaster custom_broadcaster_block;
-typedef mdds::mtv::default_element_blockelement_type_celltextattr, 
CellTextAttr custom_celltextattr_block;
+typedef mdds::mtv::noncopyable_managed_element_blockelement_type_broadcaster, 
SvtBroadcaster broadcaster_block;
+typedef mdds::mtv::default_element_blockelement_type_celltextattr, 
CellTextAttr celltextattr_block;
+typedef mdds::mtv::default_element_blockelement_type_string, rtl::OUString 
string_block;
+typedef mdds::mtv::noncopyable_managed_element_blockelement_type_edittext, 
EditTextObject edittext_block;
+typedef mdds::mtv::noncopyable_managed_element_blockelement_type_formula, 
ScFormulaCell formula_block;
 
 // This needs to be in the same namespace as CellTextAttr.
-MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, 
CellTextAttr(), custom_celltextattr_block)
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, 
CellTextAttr(), celltextattr_block)
 
 }
 
-// This needs to be in global namespace just like SvtBroacaster is.
-MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, 
sc::element_type_broadcaster, NULL, sc::custom_broadcaster_block)
+// These need to be in global namespace just like their respective types are.
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, 
sc::element_type_broadcaster, NULL, sc::broadcaster_block)
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, 
NULL, sc::formula_block)
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, 
sc::element_type_edittext, NULL, sc::edittext_block)
+
+namespace rtl {
+
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(OUString, sc::element_type_string, 
OUString(), sc::string_block)
+
+}
 
 namespace sc {
 
 // Broadcaster storage container
-typedef mdds::mtv::custom_block_func1sc::element_type_broadcaster, 
sc::custom_broadcaster_block BCBlkFunc;
+typedef mdds::mtv::custom_block_func1sc::element_type_broadcaster, 
sc::broadcaster_block BCBlkFunc;
 typedef mdds::multi_type_vectorBCBlkFunc BroadcasterStoreType;
 
 // Cell text attribute container.
-typedef mdds::mtv::custom_block_func1sc::element_type_celltextattr, 
sc::custom_celltextattr_block CTAttrFunc;
+typedef mdds::mtv::custom_block_func1sc::element_type_celltextattr, 
sc::celltextattr_block CTAttrFunc;
 typedef mdds::multi_type_vectorCTAttrFunc CellTextAttrStoreType;
 
+// Cell container
+typedef mdds::mtv::custom_block_func3
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-22 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |   10 +++---
 sc/inc/listenercontext.hxx  |9 ++---
 sc/source/core/data/clipcontext.cxx |5 +++--
 sc/source/core/data/listenercontext.cxx |   11 +++
 4 files changed, 23 insertions(+), 12 deletions(-)

New commits:
commit 4add59245371c68b67bc0270bb1fef5000d0e97e
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed May 22 20:46:42 2013 -0400

Reduce dependency on mtvelements.hxx header.

Because that header includes lots of template definitions which would
undoubtedly slow down compilation speed.

Change-Id: Ifdd686a250d341a7a6877cca41f042f8dfdbbaf9

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 84b1fcc..8a847bd 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -11,18 +11,22 @@
 #define SC_CLIPCONTEXT_HXX
 
 #include address.hxx
-#include mtvelements.hxx
 
 #include vector
 #include boost/unordered_map.hpp
+#include boost/noncopyable.hpp
+#include boost/scoped_ptr.hpp
 
 class ScDocument;
 
 namespace sc {
 
-class ClipContextBase
+struct ColumnBlockPosition;
+class ColumnBlockPositionSet;
+
+class ClipContextBase : boost::noncopyable
 {
-sc::ColumnBlockPositionSet maSet;
+boost::scoped_ptrColumnBlockPositionSet mpSet;
 
 ClipContextBase(); // disabled
 
diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx
index f4fbb0f..1e7d067 100644
--- a/sc/inc/listenercontext.hxx
+++ b/sc/inc/listenercontext.hxx
@@ -12,18 +12,21 @@
 
 #include address.hxx
 #include columnspanset.hxx
-#include mtvelements.hxx
 
 #include boost/noncopyable.hpp
+#include boost/scoped_ptr.hpp
 
 class ScDocument;
 
 namespace sc {
 
+struct ColumnBlockPosition;
+class ColumnBlockPositionSet;
+
 class StartListeningContext : boost::noncopyable
 {
 ScDocument mrDoc;
-ColumnBlockPositionSet maSet;
+boost::scoped_ptrColumnBlockPositionSet mpSet;
 public:
 StartListeningContext(ScDocument rDoc);
 ScDocument getDoc();
@@ -35,7 +38,7 @@ class EndListeningContext : boost::noncopyable
 {
 ScDocument mrDoc;
 ColumnSpanSet maSet;
-ColumnBlockPositionSet maPosSet;
+boost::scoped_ptrColumnBlockPositionSet mpPosSet;
 public:
 EndListeningContext(ScDocument rDoc);
 ScDocument getDoc();
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index 2b51076..782c0f9 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -9,17 +9,18 @@
 
 #include clipcontext.hxx
 #include document.hxx
+#include mtvelements.hxx
 
 namespace sc {
 
 ClipContextBase::ClipContextBase(ScDocument rDoc) :
-maSet(rDoc) {}
+mpSet(new ColumnBlockPositionSet(rDoc)) {}
 
 ClipContextBase::~ClipContextBase() {}
 
 ColumnBlockPosition* ClipContextBase::getBlockPosition(SCTAB nTab, SCCOL nCol)
 {
-return maSet.getBlockPosition(nTab, nCol);
+return mpSet-getBlockPosition(nTab, nCol);
 }
 
 CopyFromClipContext::CopyFromClipContext(ScDocument rDoc,
diff --git a/sc/source/core/data/listenercontext.cxx 
b/sc/source/core/data/listenercontext.cxx
index 1f4c995..6f67920 100644
--- a/sc/source/core/data/listenercontext.cxx
+++ b/sc/source/core/data/listenercontext.cxx
@@ -9,6 +9,7 @@
 
 #include listenercontext.hxx
 #include document.hxx
+#include mtvelements.hxx
 
 namespace sc {
 
@@ -38,7 +39,8 @@ public:
 
 }
 
-StartListeningContext::StartListeningContext(ScDocument rDoc) : mrDoc(rDoc), 
maSet(rDoc) {}
+StartListeningContext::StartListeningContext(ScDocument rDoc) :
+mrDoc(rDoc), mpSet(new ColumnBlockPositionSet(rDoc)) {}
 
 ScDocument StartListeningContext::getDoc()
 {
@@ -47,10 +49,11 @@ ScDocument StartListeningContext::getDoc()
 
 ColumnBlockPosition* StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL 
nCol)
 {
-return maSet.getBlockPosition(nTab, nCol);
+return mpSet-getBlockPosition(nTab, nCol);
 }
 
-EndListeningContext::EndListeningContext(ScDocument rDoc) : mrDoc(rDoc), 
maPosSet(rDoc) {}
+EndListeningContext::EndListeningContext(ScDocument rDoc) :
+mrDoc(rDoc), mpPosSet(new ColumnBlockPositionSet(rDoc)) {}
 
 ScDocument EndListeningContext::getDoc()
 {
@@ -59,7 +62,7 @@ ScDocument EndListeningContext::getDoc()
 
 ColumnBlockPosition* EndListeningContext::getBlockPosition(SCTAB nTab, SCCOL 
nCol)
 {
-return maPosSet.getBlockPosition(nTab, nCol);
+return mpPosSet-getBlockPosition(nTab, nCol);
 }
 
 void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, 
SCROW nRow)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-20 Thread Kohei Yoshida
 sc/inc/column.hxx   |4 +
 sc/inc/document.hxx |2 
 sc/inc/formulacell.hxx  |2 
 sc/inc/listenercontext.hxx  |   12 
 sc/inc/table.hxx|7 +-
 sc/source/core/data/column2.cxx |   38 ++---
 sc/source/core/data/column3.cxx |4 -
 sc/source/core/data/documen7.cxx|   15 -
 sc/source/core/data/document.cxx|4 +
 sc/source/core/data/formulacell.cxx |   92 
 sc/source/core/data/listenercontext.cxx |   12 
 sc/source/core/data/table2.cxx  |6 +-
 sc/source/core/data/table5.cxx  |8 ++
 13 files changed, 165 insertions(+), 41 deletions(-)

New commits:
commit 72507ec4ca301abbb2ed96ae1b2ac5c47839dbfc
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon May 20 11:12:49 2013 -0400

Keep track of column block positions when mass-pasting formula cells.

This speeds up the following scenario:

1) type =B1 in A1. Leave A2 empty.
2) Select A1:A2 and Ctrl-C to copy.
3) Select A3:A5 (or longer if you so wish), and ctrl-V to paste.

This causes the broadcaster storage array in column B to be heavily
partitioned due to the empty cells interspersed between formula cells
in column A.  Without tracking the column position this would cause a
O(n^2) complexity algorithm.

Change-Id: Ic2f23c2c2bea3353c517faa73fe5412c7528bd95

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 46ffbd9..6db56d4 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -37,6 +37,7 @@ namespace editeng { class SvxBorderLine; }
 
 namespace sc {
 struct FormulaGroupContext;
+class StartListeningContext;
 class EndListeningContext;
 class CopyFromClipContext;
 class CopyToClipContext;
@@ -226,7 +227,7 @@ public:
 void CopyFromClip(
 sc::CopyFromClipContext rCxt, SCROW nRow1, SCROW nRow2, long nDy, 
ScColumn rColumn );
 
-voidStartListeningInArea( SCROW nRow1, SCROW nRow2 );
+void StartListeningInArea( sc::StartListeningContext rCxt, SCROW nRow1, 
SCROW nRow2 );
 voidBroadcastInArea( SCROW nRow1, SCROW nRow2 );
 
 voidRemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
@@ -433,6 +434,7 @@ public:
 
 voidStartListening( SvtListener rLst, SCROW nRow );
 voidEndListening( SvtListener rLst, SCROW nRow );
+void StartListening( sc::StartListeningContext rCxt, SCROW nRow, 
SvtListener rListener );
 void EndListening( sc::EndListeningContext rCxt, SCROW nRow, SvtListener 
rListener );
 voidMoveListeners( SvtBroadcaster rSource, SCROW nDestRow );
 voidStartAllListeners();
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f01e811..544c9b5 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -49,6 +49,7 @@
 namespace editeng { class SvxBorderLine; }
 namespace sc {
 struct FormulaGroupContext;
+class StartListeningContext;
 class EndListeningContext;
 class CopyFromClipContext;
 struct ColumnBlockPosition;
@@ -1765,6 +1766,7 @@ public:
 voidEndListeningCell( const ScAddress rAddress,
 SvtListener* pListener );
 
+void StartListeningCell( sc::StartListeningContext rCxt, const ScAddress 
rPos, SvtListener rListener );
 void EndListeningCell( sc::EndListeningContext rCxt, const ScAddress 
rPos, SvtListener rListener );
 
 void EndListeningFormulaCells( std::vectorScFormulaCell* rCells );
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index e081353..4760062 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -30,6 +30,7 @@
 
 namespace sc {
 
+class StartListeningContext;
 class EndListeningContext;
 
 }
@@ -313,6 +314,7 @@ public:
 
 // nOnlyNames may be one or more of SC_LISTENING_NAMES_*
 void StartListeningTo( ScDocument* pDoc );
+void StartListeningTo( sc::StartListeningContext rCxt );
 void EndListeningTo(
 ScDocument* pDoc, ScTokenArray* pArr = NULL, ScAddress aPos = 
ScAddress() );
 void EndListeningTo( sc::EndListeningContext rCxt );
diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx
index 36f26d8..2503e72 100644
--- a/sc/inc/listenercontext.hxx
+++ b/sc/inc/listenercontext.hxx
@@ -12,6 +12,7 @@
 
 #include address.hxx
 #include columnspanset.hxx
+#include mtvelements.hxx
 
 #include boost/noncopyable.hpp
 
@@ -19,6 +20,17 @@ class ScDocument;
 
 namespace sc {
 
+class StartListeningContext : boost::noncopyable
+{
+ScDocument mrDoc;
+ColumnBlockPositionSet maSet;
+public:
+StartListeningContext(ScDocument rDoc);
+ScDocument getDoc();
+
+ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+};
+
 class EndListeningContext : boost::noncopyable
 {
 ScDocument mrDoc;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-20 Thread Kohei Yoshida
 sc/inc/listenercontext.hxx  |3 +++
 sc/source/core/data/column2.cxx |   13 +++--
 sc/source/core/data/listenercontext.cxx |7 ++-
 3 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 822f0ad64aaff65737bf10189642538f2dd81225
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon May 20 12:25:19 2013 -0400

Do the same trick when getting broadcasters during mass formula cell 
deletion.

Change-Id: Iee1b3ff637d10c6bd2d2342db518a2fc986327b7

diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx
index 2503e72..f4fbb0f 100644
--- a/sc/inc/listenercontext.hxx
+++ b/sc/inc/listenercontext.hxx
@@ -35,10 +35,13 @@ class EndListeningContext : boost::noncopyable
 {
 ScDocument mrDoc;
 ColumnSpanSet maSet;
+ColumnBlockPositionSet maPosSet;
 public:
 EndListeningContext(ScDocument rDoc);
 ScDocument getDoc();
 
+ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+
 void addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow);
 void purgeEmptyBroadcasters();
 };
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index eeb5519..324519a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2107,10 +2107,19 @@ void ScColumn::StartListening( 
sc::StartListeningContext rCxt, SCROW nRow, SvtL
 
 void ScColumn::EndListening( sc::EndListeningContext rCxt, SCROW nRow, 
SvtListener rListener )
 {
-SvtBroadcaster* pBC = GetBroadcaster(nRow);
-if (!pBC)
+sc::ColumnBlockPosition* p = rCxt.getBlockPosition(nTab, nCol);
+if (!p)
+return;
+
+sc::BroadcasterStoreType::iterator it = p-miBroadcasterPos;
+std::pairsc::BroadcasterStoreType::iterator,size_t aPos = 
maBroadcasters.position(it, nRow);
+it = aPos.first; // store the block position for next iteration.
+if (it-type != sc::element_type_broadcaster)
 return;
 
+SvtBroadcaster* pBC = sc::custom_broadcaster_block::at(*it-data, 
aPos.second);
+OSL_ASSERT(pBC);
+
 rListener.EndListening(*pBC);
 if (!pBC-HasListeners())
 // There is no more listeners for this cell. Add it to the purge list 
for later purging.
diff --git a/sc/source/core/data/listenercontext.cxx 
b/sc/source/core/data/listenercontext.cxx
index 7ab3799..f53f1bc 100644
--- a/sc/source/core/data/listenercontext.cxx
+++ b/sc/source/core/data/listenercontext.cxx
@@ -40,13 +40,18 @@ ColumnBlockPosition* 
StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL n
 return maSet.getBlockPosition(nTab, nCol);
 }
 
-EndListeningContext::EndListeningContext(ScDocument rDoc) : mrDoc(rDoc) {}
+EndListeningContext::EndListeningContext(ScDocument rDoc) : mrDoc(rDoc), 
maPosSet(rDoc) {}
 
 ScDocument EndListeningContext::getDoc()
 {
 return mrDoc;
 }
 
+ColumnBlockPosition* EndListeningContext::getBlockPosition(SCTAB nTab, SCCOL 
nCol)
+{
+return maPosSet.getBlockPosition(nTab, nCol);
+}
+
 void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, 
SCROW nRow)
 {
 maSet.set(nTab, nCol, nRow, true);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-20 Thread Kohei Yoshida
 sc/inc/column.hxx   |2 -
 sc/inc/columnspanset.hxx|1 
 sc/inc/document.hxx |2 -
 sc/inc/table.hxx|2 -
 sc/source/core/data/column2.cxx |5 ++--
 sc/source/core/data/columnspanset.cxx   |   33 +---
 sc/source/core/data/document.cxx|6 ++---
 sc/source/core/data/listenercontext.cxx |   14 +++--
 sc/source/core/data/table1.cxx  |5 ++--
 9 files changed, 26 insertions(+), 44 deletions(-)

New commits:
commit 7deddb5045887ec5b905bf8c2827657ad4ff9757
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon May 20 13:17:28 2013 -0400

Ditto when purging broadcasters.

Change-Id: I632d617cad76485f7e1f57daa7db4d4cfa775e8b

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6db56d4..d1492eb 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -471,7 +471,7 @@ public:
 
 SvtBroadcaster* GetBroadcaster( SCROW nRow );
 const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
-void DeleteBroadcasters( SCROW nRow1, SCROW nRow2 );
+void DeleteBroadcasters( sc::ColumnBlockPosition rBlockPos, SCROW nRow1, 
SCROW nRow2 );
 
 private:
 void UpdateScriptType( sc::CellTextAttr rAttr, SCROW nRow );
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 35d94bf..ab24828 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -47,7 +47,6 @@ public:
 void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
 
 void executeFromTop(Action ac) const;
-void executeFromBottom(Action ac) const;
 };
 
 }
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 544c9b5..ff525a6 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1970,7 +1970,7 @@ public:
 
 SvtBroadcaster* GetBroadcaster( const ScAddress rPos );
 const SvtBroadcaster* GetBroadcaster( const ScAddress rPos ) const;
-void DeleteBroadcasters( const ScAddress rTopPos, SCROW nLength );
+void DeleteBroadcasters( sc::ColumnBlockPosition rBlockPos, const 
ScAddress rTopPos, SCROW nLength );
 
 private: // CLOOK-Impl-methods
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 48fca53..6038311 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -850,7 +850,7 @@ public:
 
 SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
 const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
-void DeleteBroadcasters( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
+void DeleteBroadcasters( sc::ColumnBlockPosition rBlockPos, SCCOL nCol, 
SCROW nRow1, SCROW nRow2 );
 
 /** Replace behaves differently to the Search; adjust the rCol and rRow 
accordingly.
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 324519a..43a0ee5 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1605,9 +1605,10 @@ const SvtBroadcaster* ScColumn::GetBroadcaster(SCROW 
nRow) const
 return maBroadcasters.getSvtBroadcaster*(nRow);
 }
 
-void ScColumn::DeleteBroadcasters( SCROW nRow1, SCROW nRow2 )
+void ScColumn::DeleteBroadcasters( sc::ColumnBlockPosition rBlockPos, SCROW 
nRow1, SCROW nRow2 )
 {
-maBroadcasters.set_empty(nRow1, nRow2);
+rBlockPos.miBroadcasterPos =
+maBroadcasters.set_empty(rBlockPos.miBroadcasterPos, nRow1, nRow2);
 }
 
 sal_uInt16 ScColumn::GetTextWidth(SCROW nRow) const
diff --git a/sc/source/core/data/columnspanset.cxx 
b/sc/source/core/data/columnspanset.cxx
index ea4f706..9b63dc7 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -85,43 +85,14 @@ void ColumnSpanSet::executeFromTop(Action ac) const
 ColumnSpansType::const_iterator it = rCol.begin(), itEnd = 
rCol.end();
 SCROW nRow1, nRow2;
 nRow1 = it-first;
+bool bVal = it-second;
 for (++it; it != itEnd; ++it)
 {
 nRow2 = it-first-1;
-bool bVal = it-second;
 ac.execute(ScAddress(nCol, nRow1, nTab), nRow2-nRow1+1, bVal);
 
 nRow1 = nRow2+1; // for the next iteration.
-}
-}
-}
-}
-
-void ColumnSpanSet::executeFromBottom(Action ac) const
-{
-for (size_t nTab = 0; nTab  maDoc.size(); ++nTab)
-{
-if (!maDoc[nTab])
-continue;
-
-const TableType rTab = *maDoc[nTab];
-for (size_t nCol = 0; nCol  rTab.size(); ++nCol)
-{
-if (!rTab[nCol])
-continue;
-
-ac.startColumn(nTab, nCol);
-ColumnSpansType rCol = *rTab[nCol];
-ColumnSpansType::const_reverse_iterator it = rCol.rbegin(), itEnd 
= rCol.rend();
-SCROW nRow1, nRow2;
-nRow2 = it-first-1;
-for (++it; it != itEnd; ++it)
-{
-nRow1 = it-first;
-bool bVal = it-second;
-

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-17 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |   13 +++--
 sc/inc/column.hxx   |3 ++-
 sc/inc/table.hxx|6 ++
 sc/source/core/data/clipcontext.cxx |   15 ++-
 sc/source/core/data/column.cxx  |4 ++--
 sc/source/core/data/document.cxx|8 
 sc/source/core/data/table2.cxx  |   14 +++---
 7 files changed, 42 insertions(+), 21 deletions(-)

New commits:
commit 0382595ab85cede79419770010840a5c6278c616
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 17 10:02:05 2013 -0400

Move the boolean flags to the context bucket.

To reduce the number of function parameters lower.

Change-Id: I816bd7c27070597f5fcdf69bdc7d981279390ca6

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index e28d265..0df627c 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -30,6 +30,8 @@ class ClipContextBase
 SCTAB mnTabStart;
 SCTAB mnTabEnd;
 
+ClipContextBase(); // disabled
+
 public:
 ClipContextBase(ScDocument rDoc);
 virtual ~ClipContextBase();
@@ -44,7 +46,6 @@ public:
 
 class CopyFromClipContext : public ClipContextBase
 {
-
 ScDocument* mpRefUndoDoc;
 ScDocument* mpClipDoc;
 sal_uInt16  mnInsertFlag;
@@ -69,9 +70,17 @@ public:
 
 class CopyToClipContext : public ClipContextBase
 {
+bool mbKeepScenarioFlags:1;
+bool mbCloneNotes:1;
+
+CopyToClipContext(); // disabled
+
 public:
-CopyToClipContext(ScDocument rDoc);
+CopyToClipContext(ScDocument rDoc, bool bKeepScenarioFlags, bool 
bCloneNotes);
 virtual ~CopyToClipContext();
+
+bool isKeepScenarioFlags() const;
+bool isCloneNotes() const;
 };
 
 }
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 0eab575..4e5688c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -216,7 +216,8 @@ public:
 voidInsertRow( SCROW nStartRow, SCSIZE nSize );
 voidDeleteRow( SCROW nStartRow, SCSIZE nSize );
 voidDeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag 
);
-void CopyToClip( sc::CopyToClipContext rCxt, SCROW nRow1, SCROW nRow2, 
ScColumn rColumn, bool bKeepScenarioFlags ) const;
+void CopyToClip(
+sc::CopyToClipContext rCxt, SCROW nRow1, SCROW nRow2, ScColumn 
rColumn ) const;
 void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn rDestCol);
 void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn rDestCol 
);
 bool InitBlockPosition( sc::ColumnBlockPosition rBlockPos );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 2538a0b..9b0d4d2 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -380,10 +380,8 @@ public:
 bool* pUndoOutline = NULL );
 
 voidDeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 
sal_uInt16 nDelFlag);
-void CopyToClip( sc::CopyToClipContext rCxt, SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2, ScTable* pTable,
- bool bKeepScenarioFlags, bool bCloneNoteCaptions );
-void CopyToClip( sc::CopyToClipContext rCxt, const ScRangeList rRanges, 
ScTable* pTable,
- bool bKeepScenarioFlags, bool bCloneNoteCaptions );
+void CopyToClip( sc::CopyToClipContext rCxt, SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2, ScTable* pTable );
+void CopyToClip( sc::CopyToClipContext rCxt, const ScRangeList rRanges, 
ScTable* pTable );
 void CopyStaticToDocument(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2, ScTable* pDestTab);
 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, 
SCROW nDestRow, ScTable rDestTab );
 
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index e3db67d..8a02cea 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -101,9 +101,22 @@ bool CopyFromClipContext::isSkipAttrForEmptyCells() const
 return mbSkipAttrForEmptyCells;
 }
 
-CopyToClipContext::CopyToClipContext(ScDocument rDoc) : ClipContextBase(rDoc) 
{}
+CopyToClipContext::CopyToClipContext(
+ScDocument rDoc, bool bKeepScenarioFlags, bool bCloneNotes) :
+ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), 
mbCloneNotes(bCloneNotes) {}
+
 CopyToClipContext::~CopyToClipContext() {}
 
+bool CopyToClipContext::isKeepScenarioFlags() const
+{
+return mbKeepScenarioFlags;
+}
+
+bool CopyToClipContext::isCloneNotes() const
+{
+return mbCloneNotes;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 655918b..9fb6406 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1185,10 +1185,10 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize 
)
 
 
 void ScColumn::CopyToClip(
-sc::CopyToClipContext rCxt, SCROW nRow1, SCROW nRow2, ScColumn rColumn, 
bool bKeepScenarioFlags) const
+sc::CopyToClipContext rCxt, SCROW 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-17 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |7 ++
 sc/inc/column.hxx   |3 +-
 sc/inc/table.hxx|   10 +
 sc/source/core/data/clipcontext.cxx |3 ++
 sc/source/core/data/column.cxx  |   36 --
 sc/source/core/data/documen2.cxx|9 ++--
 sc/source/core/data/document.cxx|   38 ++--
 sc/source/core/data/table2.cxx  |   18 ++---
 8 files changed, 90 insertions(+), 34 deletions(-)

New commits:
commit 0b6304c54973df70f4c18117ed83c6f8da02d6c9
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 17 12:40:17 2013 -0400

Do the same thing for CopyToDocument.

This removes O(n^2) slowness from undo and redo of a large array of
cells with empty cells in between.

Change-Id: Id87c8ac8986c97ddf305f849a4752f0f92cc5899

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 0df627c..4d9224f 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -83,6 +83,13 @@ public:
 bool isCloneNotes() const;
 };
 
+class CopyToDocContext : public ClipContextBase
+{
+public:
+CopyToDocContext(ScDocument rDoc);
+virtual ~CopyToDocContext();
+};
+
 }
 
 #endif
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4e5688c..1165ee3 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -40,6 +40,7 @@ namespace sc {
 class EndListeningContext;
 class CopyFromClipContext;
 class CopyToClipContext;
+class CopyToDocContext;
 struct ColumnBlockPosition;
 }
 
@@ -252,7 +253,7 @@ public:
 ScFunctionData rData, ScFlatBoolRowSegments rHiddenRows, SCROW 
nStartRow, SCROW nEndRow) const;
 
 void CopyToColumn(
-SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
+sc::CopyToDocContext rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 
nFlags, bool bMarked,
 ScColumn rColumn, const ScMarkData* pMarkData = NULL, bool bAsLink = 
false) const;
 
 void UndoToColumn(
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 9b0d4d2..c40e5ec 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -52,6 +52,7 @@ namespace sc {
 class EndListeningContext;
 class CopyFromClipContext;
 class CopyToClipContext;
+class CopyToDocContext;
 struct ColumnBlockPosition;
 }
 
@@ -396,10 +397,11 @@ public:
 voidBroadcastInArea( SCCOL nCol1, SCROW nRow1,
 SCCOL nCol2, SCROW nRow2 );
 
-voidCopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
-const ScMarkData* pMarkData = NULL,
-bool bAsLink = false, bool bColRowFlags = true);
+void CopyToTable(
+sc::CopyToDocContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
+sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
+const ScMarkData* pMarkData = NULL, bool bAsLink = false, bool 
bColRowFlags = true );
+
 voidUndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
 sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
 const ScMarkData* pMarkData = NULL);
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index 8a02cea..8777aa3 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -117,6 +117,9 @@ bool CopyToClipContext::isCloneNotes() const
 return mbCloneNotes;
 }
 
+CopyToDocContext::CopyToDocContext(ScDocument rDoc) : ClipContextBase(rDoc) {}
+CopyToDocContext::~CopyToDocContext() {}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 9fb6406..d196223 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1368,6 +1368,7 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW 
nDestRow, ScColumn rDes
 }
 
 void ScColumn::CopyToColumn(
+sc::CopyToDocContext rCxt,
 SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked, ScColumn 
rColumn,
 const ScMarkData* pMarkData, bool bAsLink) const
 {
@@ -1381,7 +1382,7 @@ void ScColumn::CopyToColumn(
 while ( aIter.Next( nStart, nEnd )  nStart = nRow2 )
 {
 if ( nEnd = nRow1 )
-CopyToColumn( std::max(nRow1,nStart), std::min(nRow2,nEnd),
+CopyToColumn(rCxt, std::max(nRow1,nStart), 
std::min(nRow2,nEnd),
 nFlags, false, rColumn, pMarkData, bAsLink 
);
 }
 }
@@ -1443,6 +1444,7 @@ void ScColumn::CopyToColumn(
 // Special case to allow removing of cell instances.  A
 // string cell with empty content is used to indicate an
 // empty cell.
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-17 Thread Kohei Yoshida
 sc/inc/column.hxx|2 +-
 sc/inc/table.hxx |6 +++---
 sc/source/core/data/column.cxx   |   12 +---
 sc/source/core/data/document.cxx |8 ++--
 sc/source/core/data/table2.cxx   |   13 +
 5 files changed, 20 insertions(+), 21 deletions(-)

New commits:
commit 823516dfb1e910c5789fb162aeb67d7b40ab457c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 17 13:29:04 2013 -0400

Reuse CopyToDocContext for UndoTo*.

UndoToDocument and its nested methods are tightly coupled with the CopyTo
counterparts, and they both are used in the same undo / redo code

Perhaps we can clean this up to reduce redundancy in the future.

Change-Id: Id3aec60914ac3a87acbb53f889896a5850047c59

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1165ee3..0e7ed53 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -257,7 +257,7 @@ public:
 ScColumn rColumn, const ScMarkData* pMarkData = NULL, bool bAsLink = 
false) const;
 
 void UndoToColumn(
-SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
+sc::CopyToDocContext rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 
nFlags, bool bMarked,
 ScColumn rColumn, const ScMarkData* pMarkData = NULL) const;
 
 voidCopyScenarioFrom( const ScColumn rSrcCol );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index c40e5ec..7d0836f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -402,9 +402,9 @@ public:
 sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
 const ScMarkData* pMarkData = NULL, bool bAsLink = false, bool 
bColRowFlags = true );
 
-voidUndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
-const ScMarkData* pMarkData = NULL);
+void UndoToTable(
+sc::CopyToDocContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
+sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* 
pMarkData = NULL );
 
 voidCopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
 SCsCOL nDx, SCsROW nDy, ScTable* pTable);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d196223..94cd257 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1475,18 +1475,16 @@ void ScColumn::CopyToColumn(
 
 
 void ScColumn::UndoToColumn(
-SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked, ScColumn 
rColumn,
-const ScMarkData* pMarkData) const
+sc::CopyToDocContext rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, 
bool bMarked,
+ScColumn rColumn, const ScMarkData* pMarkData ) const
 {
-sc::CopyToDocContext aCxt(*rColumn.pDocument);
-aCxt.setTabRange(rColumn.nTab, rColumn.nTab);
 if (nRow1  0)
-CopyToColumn(aCxt, 0, nRow1-1, IDF_FORMULA, false, rColumn);
+CopyToColumn(rCxt, 0, nRow1-1, IDF_FORMULA, false, rColumn);
 
-CopyToColumn(aCxt, nRow1, nRow2, nFlags, bMarked, rColumn, pMarkData); 
 //! bMarked 
+CopyToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rColumn, pMarkData); 
 //! bMarked 
 
 if (nRow2  MAXROW)
-CopyToColumn(aCxt, nRow2+1, MAXROW, IDF_FORMULA, false, rColumn);
+CopyToColumn(rCxt, nRow2+1, MAXROW, IDF_FORMULA, false, rColumn);
 }
 
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 44668ac..4e54630 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1872,11 +1872,13 @@ void ScDocument::UndoToDocument(SCCOL nCol1, SCROW 
nRow1, SCTAB nTab1,
 if (nTab1  0)
 CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTab1-1, IDF_FORMULA, false, 
pDestDoc, pMarks );
 
+sc::CopyToDocContext aCxt(*pDestDoc);
+aCxt.setTabRange(nTab1, nTab2);
 OSL_ASSERT( nTab2  static_castSCTAB(maTabs.size())  nTab2  
static_castSCTAB(pDestDoc-maTabs.size()));
 for (SCTAB i = nTab1; i = nTab2; i++)
 {
 if (maTabs[i]  pDestDoc-maTabs[i])
-maTabs[i]-UndoToTable(nCol1, nRow1, nCol2, nRow2, nFlags,
+maTabs[i]-UndoToTable(aCxt, nCol1, nRow1, nCol2, nRow2, 
nFlags,
 bOnlyMarked, pDestDoc-maTabs[i], pMarks);
 }
 
@@ -1926,13 +1928,15 @@ void ScDocument::UndoToDocument(const ScRange rRange,
 
 bool bOldAutoCalc = pDestDoc-GetAutoCalc();
 pDestDoc-SetAutoCalc( false ); // avoid multiple calculations
+sc::CopyToDocContext aCxt(*pDestDoc);
+aCxt.setTabRange(nTab1, nTab2);
 if (nTab1  0)
 CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTab1-1, IDF_FORMULA, false, 
pDestDoc, pMarks );
 
 for (SCTAB i = nTab1; i = nTab2  i  static_castSCTAB(maTabs.size()); 
i++)
 {
 if (maTabs[i]  i  static_castSCTAB(pDestDoc-maTabs.size())  

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-17 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |7 +
 sc/inc/column.hxx   |   11 +
 sc/inc/document.hxx |2 +
 sc/inc/table.hxx|   12 ++
 sc/source/core/data/clipcontext.cxx |3 ++
 sc/source/core/data/column3.cxx |   21 +++--
 sc/source/core/data/document.cxx|   43 ++--
 sc/source/core/data/table2.cxx  |   14 ++-
 8 files changed, 86 insertions(+), 27 deletions(-)

New commits:
commit 7ed2000a046a5c2b8491439fe2c9ddba1a9dadb7
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 17 15:08:23 2013 -0400

Same with MixDocument(). But this one has additional bottleneck...

With the removal of existing cells. So, this change is not enough to
make this operation fly.

Change-Id: Ic468375f6d0c28e2cc7d5391fb0565d53ee7fb4e

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 4d9224f..599da6e 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -90,6 +90,13 @@ public:
 virtual ~CopyToDocContext();
 };
 
+class MixDocContext : public ClipContextBase
+{
+public:
+MixDocContext(ScDocument rDoc);
+virtual ~MixDocContext();
+};
+
 }
 
 #endif
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 0e7ed53..c71ffea 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -41,6 +41,7 @@ namespace sc {
 class CopyFromClipContext;
 class CopyToClipContext;
 class CopyToDocContext;
+class MixDocContext;
 struct ColumnBlockPosition;
 }
 
@@ -231,10 +232,12 @@ public:
 voidRemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
 
 //  Selection (?) of this document
-voidMixMarked( const ScMarkData rMark, sal_uInt16 nFunction,
-bool bSkipEmpty, ScColumn rSrcCol );
-voidMixData( SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool 
bSkipEmpty,
-ScColumn rSrcCol );
+void MixMarked(
+sc::MixDocContext rCxt, const ScMarkData rMark, sal_uInt16 nFunction,
+bool bSkipEmpty, const ScColumn rSrcCol );
+void MixData(
+sc::MixDocContext rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 
nFunction, bool bSkipEmpty,
+const ScColumn rSrcCol );
 
 ScFormulaCell*  CreateRefCell( ScDocument* pDestDoc, const ScAddress 
rDestPos,
 SCSIZE nIndex, sal_uInt16 nFlags ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5f63d85..f01e811 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1988,6 +1988,8 @@ private: // CLOOK-Impl-methods
 };
 
 bool TableExists( SCTAB nTab ) const;
+ScTable* FetchTable( SCTAB nTab );
+const ScTable* FetchTable( SCTAB nTab ) const;
 
 voidMergeNumberFormatter(ScDocument* pSrcDoc);
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7d0836f..f04a9bb 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -53,6 +53,7 @@ namespace sc {
 class CopyFromClipContext;
 class CopyToClipContext;
 class CopyToDocContext;
+class MixDocContext;
 struct ColumnBlockPosition;
 }
 
@@ -412,10 +413,13 @@ public:
 ScTable* pTransClip, sal_uInt16 nFlags, bool 
bAsLink );
 
 // mark of this document
-voidMixMarked( const ScMarkData rMark, sal_uInt16 nFunction,
-bool bSkipEmpty, ScTable* pSrcTab );
-voidMixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-sal_uInt16 nFunction, bool bSkipEmpty, ScTable* 
pSrcTab );
+void MixMarked(
+sc::MixDocContext rCxt, const ScMarkData rMark, sal_uInt16 nFunction,
+bool bSkipEmpty, const ScTable* pSrcTab );
+
+void MixData(
+sc::MixDocContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2,
+sal_uInt16 nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
 
 voidCopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, 
SCROW nEndRow,
 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index 8777aa3..2c7abdf 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -120,6 +120,9 @@ bool CopyToClipContext::isCloneNotes() const
 CopyToDocContext::CopyToDocContext(ScDocument rDoc) : ClipContextBase(rDoc) {}
 CopyToDocContext::~CopyToDocContext() {}
 
+MixDocContext::MixDocContext(ScDocument rDoc) : ClipContextBase(rDoc) {}
+MixDocContext::~MixDocContext() {}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index a29f791..b530184 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -828,8 +828,9 @@ ScBaseCell* ScColumn::CloneCell(
 }
 
 
-void ScColumn::MixMarked( 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-17 Thread Kohei Yoshida
 sc/inc/documentimport.hxx  |9 +++--
 sc/inc/mtvelements.hxx |   19 +++
 sc/source/core/data/documentimport.cxx |   55 +
 sc/source/core/data/mtvelements.cxx|   40 
 4 files changed, 101 insertions(+), 22 deletions(-)

New commits:
commit f0ab6e703da23633b9a7fc3c7d7e6c1979b54043
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 17 16:39:15 2013 -0400

Keep track of column block positions in ScDocumentImport too.

This currently only affects document import via orcus, but it'll be
good to put this in place.

Change-Id: I8cc6d54aba6fab1f2774127f92c2a764f7b690fb

diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index eeafbba..afd954b 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -15,10 +15,13 @@
 
 #include rtl/ustring.hxx
 
+#include boost/noncopyable.hpp
+
 class ScDocument;
 class ScAddress;
 class ScTokenArray;
 class ScBaseCell;
+struct ScDocumentImportImpl;
 
 /**
  * Accessor class to ScDocument.  Its purpose is to allow import filter to
@@ -27,15 +30,15 @@ class ScBaseCell;
  * position calculation, or anything else that requires expensive
  * computation which are unnecessary and undesirable during import.
  */
-class SC_DLLPUBLIC ScDocumentImport
+class SC_DLLPUBLIC ScDocumentImport : boost::noncopyable
 {
-ScDocument mrDoc;
+ScDocumentImportImpl* mpImpl;
 
 ScDocumentImport(); // disabled
 
 public:
 ScDocumentImport(ScDocument rDoc);
-ScDocumentImport(const ScDocumentImport r);
+~ScDocumentImport();
 
 ScDocument getDoc();
 const ScDocument getDoc() const;
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index b21f7c7..1628381 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -10,6 +10,7 @@
 #ifndef SC_MTVELEMENTS_HXX
 #define SC_MTVELEMENTS_HXX
 
+#include address.hxx
 #include svl/broadcast.hxx
 
 #define DEBUG_COLUMN_STORAGE 0
@@ -25,6 +26,10 @@
 #include mdds/multi_type_vector.hpp
 #include mdds/multi_type_vector_custom_func1.hpp
 
+#include boost/unordered_map.hpp
+
+class ScDocument;
+
 namespace sc {
 
 struct CellTextAttr
@@ -74,6 +79,20 @@ struct ColumnBlockPosition
 CellTextAttrStoreType::iterator miCellTextAttrPos;
 };
 
+class ColumnBlockPositionSet
+{
+typedef boost::unordered_mapSCCOL, ColumnBlockPosition ColumnsType;
+typedef boost::unordered_mapSCTAB, ColumnsType TablesType;
+
+ScDocument mrDoc;
+TablesType maTables;
+
+public:
+ColumnBlockPositionSet(ScDocument rDoc);
+
+ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+};
+
 }
 
 #endif
diff --git a/sc/source/core/data/documentimport.cxx 
b/sc/source/core/data/documentimport.cxx
index c92688f..ced0936 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -15,24 +15,36 @@
 #include formulacell.hxx
 #include docoptio.hxx
 #include globalnames.hxx
+#include mtvelements.hxx
 
-ScDocumentImport::ScDocumentImport(ScDocument rDoc) : mrDoc(rDoc) {}
-ScDocumentImport::ScDocumentImport(const ScDocumentImport r) : mrDoc(r.mrDoc) 
{}
+struct ScDocumentImportImpl
+{
+ScDocument mrDoc;
+sc::ColumnBlockPositionSet maBlockPosSet;
+
+ScDocumentImportImpl(ScDocument rDoc) : mrDoc(rDoc), maBlockPosSet(rDoc) 
{}
+};
+
+ScDocumentImport::ScDocumentImport(ScDocument rDoc) : mpImpl(new 
ScDocumentImportImpl(rDoc)) {}
+ScDocumentImport::~ScDocumentImport()
+{
+delete mpImpl;
+}
 
 ScDocument ScDocumentImport::getDoc()
 {
-return mrDoc;
+return mpImpl-mrDoc;
 }
 
 const ScDocument ScDocumentImport::getDoc() const
 {
-return mrDoc;
+return mpImpl-mrDoc;
 }
 
 SCTAB ScDocumentImport::getSheetIndex(const OUString rName) const
 {
 SCTAB nTab = -1;
-if (!mrDoc.GetTable(rName, nTab))
+if (!mpImpl-mrDoc.GetTable(rName, nTab))
 return -1;
 
 return nTab;
@@ -40,33 +52,34 @@ SCTAB ScDocumentImport::getSheetIndex(const OUString 
rName) const
 
 SCTAB ScDocumentImport::getSheetCount() const
 {
-return mrDoc.maTabs.size();
+return mpImpl-mrDoc.maTabs.size();
 }
 
 bool ScDocumentImport::appendSheet(const OUString rName)
 {
-SCTAB nTabCount = mrDoc.maTabs.size();
+SCTAB nTabCount = mpImpl-mrDoc.maTabs.size();
 if (!ValidTab(nTabCount))
 return false;
 
-mrDoc.maTabs.push_back(new ScTable(mrDoc, nTabCount, rName));
+mpImpl-mrDoc.maTabs.push_back(new ScTable(mpImpl-mrDoc, nTabCount, 
rName));
 return true;
 }
 
 void ScDocumentImport::setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, 
sal_uInt16 nDay)
 {
-if (!mrDoc.pDocOptions)
-mrDoc.pDocOptions = new ScDocOptions;
+if (!mpImpl-mrDoc.pDocOptions)
+mpImpl-mrDoc.pDocOptions = new ScDocOptions;
 
-mrDoc.pDocOptions-SetDate(nDay, nMonth, nYear);
+mpImpl-mrDoc.pDocOptions-SetDate(nDay, nMonth, nYear);
 }
 
 void ScDocumentImport::setAutoInput(const ScAddress rPos, 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-17 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |   20 ---
 sc/source/core/data/clipcontext.cxx |   64 ++--
 sc/source/core/data/column.cxx  |2 -
 sc/source/core/data/documen2.cxx|2 -
 sc/source/core/data/document.cxx|   13 ---
 sc/source/core/data/table2.cxx  |1 
 6 files changed, 27 insertions(+), 75 deletions(-)

New commits:
commit 8d71db3c08c1295c2df98fccba8529a5e55d1af1
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 17 16:48:25 2013 -0400

A bit of a cleanup.

Change-Id: Iaa7003cabee4630e4fbb8fb1cd114d04b4e9e33c

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 599da6e..84b1fcc 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -22,13 +22,7 @@ namespace sc {
 
 class ClipContextBase
 {
-typedef boost::unordered_mapSCCOL, ColumnBlockPosition ColumnsType;
-typedef std::vectorColumnsType TablesType;
-
-ScDocument mrDoc;
-TablesType maTables;
-SCTAB mnTabStart;
-SCTAB mnTabEnd;
+sc::ColumnBlockPositionSet maSet;
 
 ClipContextBase(); // disabled
 
@@ -36,16 +30,13 @@ public:
 ClipContextBase(ScDocument rDoc);
 virtual ~ClipContextBase();
 
-void setTabRange(SCTAB nStart, SCTAB nEnd);
-
-SCTAB getTabStart() const;
-SCTAB getTabEnd() const;
-
 ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
 };
 
 class CopyFromClipContext : public ClipContextBase
 {
+SCTAB mnTabStart;
+SCTAB mnTabEnd;
 ScDocument* mpRefUndoDoc;
 ScDocument* mpClipDoc;
 sal_uInt16  mnInsertFlag;
@@ -61,6 +52,11 @@ public:
 
 virtual ~CopyFromClipContext();
 
+void setTabRange(SCTAB nStart, SCTAB nEnd);
+
+SCTAB getTabStart() const;
+SCTAB getTabEnd() const;
+
 ScDocument* getUndoDoc();
 ScDocument* getClipDoc();
 sal_uInt16 getInsertFlag() const;
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index 2c7abdf..2b51076 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -13,62 +13,20 @@
 namespace sc {
 
 ClipContextBase::ClipContextBase(ScDocument rDoc) :
-mrDoc(rDoc), mnTabStart(-1), mnTabEnd(-1) {}
+maSet(rDoc) {}
 
 ClipContextBase::~ClipContextBase() {}
 
-void ClipContextBase::setTabRange(SCTAB nStart, SCTAB nEnd)
-{
-mnTabStart = nStart;
-mnTabEnd = nEnd;
-}
-
-SCTAB ClipContextBase::getTabStart() const
-{
-return mnTabStart;
-}
-
-SCTAB ClipContextBase::getTabEnd() const
-{
-return mnTabEnd;
-}
-
 ColumnBlockPosition* ClipContextBase::getBlockPosition(SCTAB nTab, SCCOL nCol)
 {
-if (mnTabStart  0 || mnTabEnd  0 || mnTabStart  mnTabEnd)
-return NULL;
-
-size_t nTabIndex = nTab - mnTabStart;
-if (nTabIndex = maTables.size())
-maTables.resize(nTabIndex+1);
-
-ColumnsType rCols = maTables[nTabIndex];
-
-ColumnsType::iterator it = rCols.find(nCol);
-if (it != rCols.end())
-// Block position for this column has already been fetched.
-return it-second;
-
-std::pairColumnsType::iterator,bool r =
-rCols.insert(
-ColumnsType::value_type(nCol, ColumnBlockPosition()));
-
-if (!r.second)
-// insertion failed.
-return NULL;
-
-it = r.first;
-
-if (!mrDoc.InitColumnBlockPosition(it-second, nTab, nCol))
-return NULL;
-
-return it-second;
+return maSet.getBlockPosition(nTab, nCol);
 }
 
 CopyFromClipContext::CopyFromClipContext(ScDocument rDoc,
 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
 bool bAsLink, bool bSkipAttrForEmptyCells) :
 ClipContextBase(rDoc),
+mnTabStart(-1), mnTabEnd(-1),
 mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc), mnInsertFlag(nInsertFlag),
 mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells) {}
 
@@ -76,6 +34,22 @@ CopyFromClipContext::~CopyFromClipContext()
 {
 }
 
+void CopyFromClipContext::setTabRange(SCTAB nStart, SCTAB nEnd)
+{
+mnTabStart = nStart;
+mnTabEnd = nEnd;
+}
+
+SCTAB CopyFromClipContext::getTabStart() const
+{
+return mnTabStart;
+}
+
+SCTAB CopyFromClipContext::getTabEnd() const
+{
+return mnTabEnd;
+}
+
 ScDocument* CopyFromClipContext::getUndoDoc()
 {
 return mpRefUndoDoc;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 94cd257..10d36b6 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1514,7 +1514,6 @@ void ScColumn::CopyScenarioFrom( const ScColumn rSrcCol )
 {
 //  This is the scenario table, the data is copied into it
 sc::CopyToDocContext aCxt(*pDocument);
-aCxt.setTabRange(nTab, nTab);
 ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW );
 SCROW nStart = -1, nEnd = -1;
 const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd );
@@ -1546,7 +1545,6 @@ void ScColumn::CopyScenarioTo( ScColumn rDestCol ) const
 {
 //  This is the scenario table, the data is 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-16 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |   10 +++--
 sc/source/core/data/clipcontext.cxx |   65 +---
 sc/source/core/data/document.cxx|   19 +-
 3 files changed, 32 insertions(+), 62 deletions(-)

New commits:
commit a38e13f50998d9cc50f737f0352e2676af96f44a
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu May 16 13:52:33 2013 -0400

Cleaned up a bit to remove the need to initialize the block positions.

Change-Id: Iad2e69e4eb61167ad85581a83b19e3798c5edfd0

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 8b1f261..53f2110 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -27,6 +27,8 @@ class CopyFromClipContext
 
 TablesType maTables;
 
+ScDocument mrDoc;
+
 ScDocument* mpRefUndoDoc;
 ScDocument* mpClipDoc;
 sal_uInt16  mnInsertFlag;
@@ -36,16 +38,16 @@ class CopyFromClipContext
 boolmbSkipAttrForEmptyCells:1;
 
 CopyFromClipContext(); // disabled
+
 public:
-CopyFromClipContext(
+CopyFromClipContext(ScDocument rDoc,
 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
 bool bAsLink, bool bSkipAttrForEmptyCells);
 
-bool initBlockPositions(ScDocument rDoc, SCCOL nCol1, SCCOL nCol2);
-void setTabRange(SCTAB nStart, SCTAB nEnd);
-
 ~CopyFromClipContext();
 
+void setTabRange(SCTAB nStart, SCTAB nEnd);
+
 ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
 
 ScDocument* getUndoDoc();
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index e3e66a2..1d19dd1 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -12,9 +12,10 @@
 
 namespace sc {
 
-CopyFromClipContext::CopyFromClipContext(
+CopyFromClipContext::CopyFromClipContext(ScDocument rDoc,
 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
 bool bAsLink, bool bSkipAttrForEmptyCells) :
+mrDoc(rDoc),
 mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc), mnInsertFlag(nInsertFlag),
 mnTabStart(-1), mnTabEnd(-1),
 mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells) {}
@@ -23,44 +24,6 @@ CopyFromClipContext::~CopyFromClipContext()
 {
 }
 
-bool CopyFromClipContext::initBlockPositions(ScDocument rDoc, SCCOL nCol1, 
SCCOL nCol2)
-{
-if (mnTabStart  0 || mnTabEnd  0 || mnTabStart  mnTabEnd)
-return false;
-
-size_t nSize = mnTabEnd - mnTabStart + 1;
-if (maTables.size()  nSize)
-maTables.resize(nSize);
-
-for (size_t i = 0; i  nSize; ++i)
-{
-SCTAB nTab = i + mnTabStart;
-ColumnsType rCols = maTables[i];
-for (SCCOL nCol = nCol1; nCol = nCol2; ++nCol)
-{
-ColumnsType::iterator it = rCols.find(nCol);
-if (it != rCols.end())
-// This column has already been initialized. Skip it.
-continue;
-
-std::pairColumnsType::iterator,bool r =
-rCols.insert(
-ColumnsType::value_type(nCol, ColumnBlockPosition()));
-
-if (!r.second)
-// insertion failed.
-return false;
-
-it = r.first;
-
-if (!rDoc.InitColumnBlockPosition(it-second, nTab, nCol))
-return false;
-}
-}
-
-return true;
-}
-
 void CopyFromClipContext::setTabRange(SCTAB nStart, SCTAB nEnd)
 {
 mnTabStart = nStart;
@@ -69,14 +32,34 @@ void CopyFromClipContext::setTabRange(SCTAB nStart, SCTAB 
nEnd)
 
 ColumnBlockPosition* CopyFromClipContext::getBlockPosition(SCTAB nTab, SCCOL 
nCol)
 {
+if (mnTabStart  0 || mnTabEnd  0 || mnTabStart  mnTabEnd)
+return NULL;
+
 size_t nTabIndex = nTab - mnTabStart;
 if (nTabIndex = maTables.size())
-return NULL;
+maTables.resize(nTabIndex+1);
 
 ColumnsType rCols = maTables[nTabIndex];
+
 ColumnsType::iterator it = rCols.find(nCol);
+if (it != rCols.end())
+// Block position for this column has already been fetched.
+return it-second;
+
+std::pairColumnsType::iterator,bool r =
+rCols.insert(
+ColumnsType::value_type(nCol, ColumnBlockPosition()));
+
+if (!r.second)
+// insertion failed.
+return NULL;
+
+it = r.first;
+
+if (!mrDoc.InitColumnBlockPosition(it-second, nTab, nCol))
+return NULL;
 
-return it == rCols.end() ? NULL : it-second;
+return it-second;
 }
 
 ScDocument* CopyFromClipContext::getUndoDoc()
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 213b4f5..b8d4497 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2515,7 +2515,7 @@ void ScDocument::CopyFromClip( const ScRange rDestRange, 
const ScMarkData rMar
 if ( ( nInsFlag  IDF_ATTRIB )  !bSkipAttrForEmpty )
 nDelFlag |= IDF_ATTRIB;
 
-sc::CopyFromClipContext aCxt(pRefUndoDoc, pClipDoc, 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-16 Thread Kohei Yoshida
 sc/inc/column.hxx   |4 +
 sc/inc/columnspanset.hxx|6 ++
 sc/inc/document.hxx |3 +
 sc/inc/listenercontext.hxx  |2 
 sc/inc/table.hxx|2 
 sc/source/core/data/column.cxx  |   49 ---
 sc/source/core/data/column2.cxx |   66 +++-
 sc/source/core/data/column3.cxx |   37 +
 sc/source/core/data/columnspanset.cxx   |   27 ++---
 sc/source/core/data/documen6.cxx|   58 
 sc/source/core/data/listenercontext.cxx |4 -
 sc/source/core/data/table1.cxx  |9 
 sc/source/ui/view/viewfunc.cxx  |   12 -
 13 files changed, 210 insertions(+), 69 deletions(-)

New commits:
commit 53d2aae88262df683fc94c0d99d060d48116050c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu May 16 18:37:12 2013 -0400

Optimize ScViewFunc::GetSelectionScriptType().

This change reduces the duration of this method from somewhere in the
ballpark of 10 seconds down to a tiny fraction of a second.

Change-Id: I0278dc06a4f134b43cd08bd94693b6dec4893f1f

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index a697bed..f1584b1 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -446,6 +446,8 @@ public:
 void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
 
 sal_uInt8 GetScriptType( SCROW nRow ) const;
+sal_uInt8 GetRangeScriptType( sc::CellTextAttrStoreType::iterator itPos, 
SCROW nRow1, SCROW nRow2 );
+
 void SetScriptType( SCROW nRow, sal_uInt8 nType );
 
 size_t GetFormulaHash( SCROW nRow ) const;
@@ -464,6 +466,8 @@ public:
 void DeleteBroadcasters( SCROW nRow1, SCROW nRow2 );
 
 private:
+void UpdateScriptType( sc::CellTextAttr rAttr, SCROW nRow );
+
 void DeleteRange(
 SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDelFlag, 
std::vectorSCROW rDeletedRows );
 
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index afd1797..35d94bf 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -30,17 +30,21 @@ class ColumnSpanSet : boost::noncopyable
 
 DocType maDoc;
 
+ColumnSpansType getColumnSpans(SCTAB nTab, SCCOL nCol);
+
 public:
 class Action
 {
 public:
 virtual ~Action() = 0;
+virtual void startColumn(SCTAB nTab, SCCOL nCol);
 virtual void execute(const ScAddress rPos, SCROW nLength, bool bVal) 
= 0;
 };
 
 ~ColumnSpanSet();
 
-void set(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bVal);
+void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
+void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
 
 void executeFromTop(Action ac) const;
 void executeFromBottom(Action ac) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e2ea7e3..5f63d85 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1277,6 +1277,9 @@ public:
 SC_DLLPUBLIC sal_uInt8  GetStringScriptType( const OUString 
rString );
 SC_DLLPUBLIC sal_uInt8 GetCellScriptType( const ScAddress rPos, sal_uLong 
nNumberFormat );
 SC_DLLPUBLIC sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab );
+sal_uInt8 GetRangeScriptType(
+sc::ColumnBlockPosition rBlockPos, const ScAddress rPos, SCROW 
nLength );
+sal_uInt8 GetRangeScriptType( const ScRangeList rRanges );
 
 boolHasDetectiveOperations() const;
 voidAddDetectiveOperation( const ScDetOpData rData );
diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx
index 2fc55a7..36f26d8 100644
--- a/sc/inc/listenercontext.hxx
+++ b/sc/inc/listenercontext.hxx
@@ -27,7 +27,7 @@ public:
 EndListeningContext(ScDocument rDoc);
 ScDocument getDoc();
 
-void addEmptyBroadcasterPosition(SCCOL nCol, SCROW nRow, SCTAB nTab);
+void addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow);
 void purgeEmptyBroadcasters();
 };
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 00255fe..333eb9a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -829,6 +829,8 @@ public:
 sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow ) const;
 void SetScriptType( SCCOL nCol, SCROW nRow, sal_uInt8 nType );
 
+sal_uInt8 GetRangeScriptType( sc::ColumnBlockPosition rBlockPos, SCCOL 
nCol, SCROW nRow1, SCROW nRow2 );
+
 size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
 
 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 704bdff..77bf89a 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2296,9 +2296,6 @@ bool ScColumn::HasEditCells(SCROW nStartRow, SCROW 
nEndRow, SCROW rFirst)
 if (itCell == itCellEnd)
 return false;
 
-SvNumberFormatter* pFormatter = pDocument-GetFormatTable();
-

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-16 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |   37 ++
 sc/inc/column.hxx   |3 +-
 sc/inc/table.hxx|9 +++---
 sc/source/core/data/clipcontext.cxx |   51 
 sc/source/core/data/column.cxx  |   10 +--
 sc/source/core/data/document.cxx|8 -
 sc/source/core/data/table2.cxx  |   14 +
 7 files changed, 84 insertions(+), 48 deletions(-)

New commits:
commit 32e561591fb13825c11160a8cb4291f2cebd5741
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu May 16 23:59:42 2013 -0400

Do the same optimization for CopyToClip.

The basic idea is the same as the one I did for CopyFromClip.  This prevents
the O(n^2) algorithm from being invoked during undo object creation.

Change-Id: Iac46663b0c25db2f00ffa3ab95a4dcf2857252ce

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 53f2110..e28d265 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -20,20 +20,34 @@ class ScDocument;
 
 namespace sc {
 
-class CopyFromClipContext
+class ClipContextBase
 {
 typedef boost::unordered_mapSCCOL, ColumnBlockPosition ColumnsType;
 typedef std::vectorColumnsType TablesType;
 
+ScDocument mrDoc;
 TablesType maTables;
+SCTAB mnTabStart;
+SCTAB mnTabEnd;
 
-ScDocument mrDoc;
+public:
+ClipContextBase(ScDocument rDoc);
+virtual ~ClipContextBase();
+
+void setTabRange(SCTAB nStart, SCTAB nEnd);
+
+SCTAB getTabStart() const;
+SCTAB getTabEnd() const;
+
+ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+};
+
+class CopyFromClipContext : public ClipContextBase
+{
 
 ScDocument* mpRefUndoDoc;
 ScDocument* mpClipDoc;
 sal_uInt16  mnInsertFlag;
-SCTAB   mnTabStart;
-SCTAB   mnTabEnd;
 boolmbAsLink:1;
 boolmbSkipAttrForEmptyCells:1;
 
@@ -44,21 +58,22 @@ public:
 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
 bool bAsLink, bool bSkipAttrForEmptyCells);
 
-~CopyFromClipContext();
-
-void setTabRange(SCTAB nStart, SCTAB nEnd);
-
-ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+virtual ~CopyFromClipContext();
 
 ScDocument* getUndoDoc();
 ScDocument* getClipDoc();
 sal_uInt16 getInsertFlag() const;
-SCTAB getTabStart() const;
-SCTAB getTabEnd() const;
 bool isAsLink() const;
 bool isSkipAttrForEmptyCells() const;
 };
 
+class CopyToClipContext : public ClipContextBase
+{
+public:
+CopyToClipContext(ScDocument rDoc);
+virtual ~CopyToClipContext();
+};
+
 }
 
 #endif
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index f1584b1..0eab575 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -39,6 +39,7 @@ namespace sc {
 struct FormulaGroupContext;
 class EndListeningContext;
 class CopyFromClipContext;
+class CopyToClipContext;
 struct ColumnBlockPosition;
 }
 
@@ -215,7 +216,7 @@ public:
 voidInsertRow( SCROW nStartRow, SCSIZE nSize );
 voidDeleteRow( SCROW nStartRow, SCSIZE nSize );
 voidDeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag 
);
-void CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn rColumn, bool 
bKeepScenarioFlags) const;
+void CopyToClip( sc::CopyToClipContext rCxt, SCROW nRow1, SCROW nRow2, 
ScColumn rColumn, bool bKeepScenarioFlags ) const;
 void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn rDestCol);
 void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn rDestCol 
);
 bool InitBlockPosition( sc::ColumnBlockPosition rBlockPos );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 333eb9a..2538a0b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -51,6 +51,7 @@ namespace sc {
 struct FormulaGroupContext;
 class EndListeningContext;
 class CopyFromClipContext;
+class CopyToClipContext;
 struct ColumnBlockPosition;
 }
 
@@ -379,10 +380,10 @@ public:
 bool* pUndoOutline = NULL );
 
 voidDeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 
sal_uInt16 nDelFlag);
-voidCopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 
ScTable* pTable,
-bool bKeepScenarioFlags, bool bCloneNoteCaptions);
-voidCopyToClip(const ScRangeList rRanges, ScTable* pTable,
-   bool bKeepScenarioFlags, bool bCloneNoteCaptions);
+void CopyToClip( sc::CopyToClipContext rCxt, SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2, ScTable* pTable,
+ bool bKeepScenarioFlags, bool bCloneNoteCaptions );
+void CopyToClip( sc::CopyToClipContext rCxt, const ScRangeList rRanges, 
ScTable* pTable,
+ bool bKeepScenarioFlags, bool bCloneNoteCaptions );
 void CopyStaticToDocument(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2, ScTable* pDestTab);
 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-15 Thread Kohei Yoshida
 sc/inc/clipcontext.hxx  |   28 ++-
 sc/inc/column.hxx   |3 
 sc/inc/document.hxx |6 -
 sc/inc/table.hxx|2 
 sc/source/core/data/clipcontext.cxx |   49 
 sc/source/core/data/column3.cxx |   20 ++---
 sc/source/core/data/document.cxx|  141 +---
 sc/source/core/data/table2.cxx  |   17 ++--
 8 files changed, 152 insertions(+), 114 deletions(-)

New commits:
commit 4aa1318c8a48645ea7ff32818f616de144b31fa1
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed May 15 12:04:56 2013 -0400

Move all clip params into the new context class. We don't need two buckets.

Change-Id: Ida0542583242ebcdd7f1448931e31656aa542457

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 00049f1..ca6760f 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -10,13 +10,39 @@
 #ifndef SC_CLIPCONTEXT_HXX
 #define SC_CLIPCONTEXT_HXX
 
+#include address.hxx
+
+class ScDocument;
+
 namespace sc {
 
 class CopyFromClipContext
 {
+ScDocument* mpRefUndoDoc;
+ScDocument* mpClipDoc;
+sal_uInt16  mnInsertFlag;
+SCTAB   mnTabStart;
+SCTAB   mnTabEnd;
+boolmbAsLink:1;
+boolmbSkipAttrForEmptyCells:1;
+
+CopyFromClipContext(); // disabled
 public:
-CopyFromClipContext();
+CopyFromClipContext(
+ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
+bool bAsLink, bool bSkipAttrForEmptyCells);
+
+void setTabRange(SCTAB nStart, SCTAB nEnd);
+
 ~CopyFromClipContext();
+
+ScDocument* getUndoDoc();
+ScDocument* getClipDoc();
+sal_uInt16 getInsertFlag() const;
+SCTAB getTabStart() const;
+SCTAB getTabEnd() const;
+bool isAsLink() const;
+bool isSkipAttrForEmptyCells() const;
 };
 
 }
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9d810e1..cf171ae 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -236,8 +236,7 @@ public:
 void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn rDestCol);
 void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn rDestCol 
);
 void CopyFromClip(
-sc::CopyFromClipContext rCxt, SCROW nRow1, SCROW nRow2, long nDy,
-sal_uInt16 nInsFlag, bool bAsLink, bool bSkipAttrForEmpty, ScColumn 
rColumn );
+sc::CopyFromClipContext rCxt, SCROW nRow1, SCROW nRow2, long nDy, 
ScColumn rColumn );
 
 voidStartListeningInArea( SCROW nRow1, SCROW nRow2 );
 voidBroadcastInArea( SCROW nRow1, SCROW nRow2 );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7b7ea40..00cd7ab 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -144,7 +144,6 @@ class ScRowBreakIterator;
 struct ScSetStringParam;
 class ScDocRowHeightUpdater;
 struct ScColWidthParam;
-struct ScCopyBlockFromClipParams;
 class ScSheetEvents;
 class ScProgress;
 class SvtListener;
@@ -1143,11 +1142,10 @@ public:
 SCTAB nTab, ScDocument* pClipDoc = NULL);
 void CopyBlockFromClip(
 sc::CopyFromClipContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
-const ScMarkData rMark, SCsCOL nDx, SCsROW nDy, const 
ScCopyBlockFromClipParams* pCBFCP );
+const ScMarkData rMark, SCsCOL nDx, SCsROW nDy );
 void CopyNonFilteredFromClip(
 sc::CopyFromClipContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
-const ScMarkData rMark, SCsCOL nDx, SCsROW nDy, const 
ScCopyBlockFromClipParams* pCBFCP,
-SCROW  rClipStartRow );
+const ScMarkData rMark, SCsCOL nDx, SCsROW nDy, SCROW  rClipStartRow 
);
 
 voidStartListeningFromClip( SCCOL nCol1, SCROW nRow1,
 SCCOL nCol2, SCROW nRow2,
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index ac2b2bf..70fc1cf 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -386,7 +386,7 @@ public:
 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, 
SCROW nDestRow, ScTable rDestTab );
 void CopyFromClip(
 sc::CopyFromClipContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
-SCsCOL nDx, SCsROW nDy, sal_uInt16 nInsFlag, bool bAsLink, bool 
bSkipAttrForEmpty, ScTable* pTable );
+SCsCOL nDx, SCsROW nDy, ScTable* pTable );
 
 voidStartListeningInArea( SCCOL nCol1, SCROW nRow1,
 SCCOL nCol2, SCROW nRow2 );
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index adfbfbb..5dcbddd 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -11,9 +11,56 @@
 
 namespace sc {
 
-CopyFromClipContext::CopyFromClipContext() {}
+CopyFromClipContext::CopyFromClipContext(
+ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
+bool bAsLink, bool bSkipAttrForEmptyCells) :
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-15 Thread Kohei Yoshida
 sc/inc/document.hxx  |2 +-
 sc/source/core/data/document.cxx |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit bd7ea19d0eeb0aae3102fca569e7f914180380c6
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed May 15 12:32:05 2013 -0400

Remove unused function argument.

Change-Id: I0b4deec7f4b10c7b14e482f61c667972caa30bc8

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 00cd7ab..4d71471 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1145,7 +1145,7 @@ public:
 const ScMarkData rMark, SCsCOL nDx, SCsROW nDy );
 void CopyNonFilteredFromClip(
 sc::CopyFromClipContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
-const ScMarkData rMark, SCsCOL nDx, SCsROW nDy, SCROW  rClipStartRow 
);
+const ScMarkData rMark, SCsCOL nDx, SCROW  rClipStartRow );
 
 voidStartListeningFromClip( SCCOL nCol1, SCROW nRow1,
 SCCOL nCol2, SCROW nRow2,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index d0bc5a6..342499e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2390,7 +2390,7 @@ void ScDocument::CopyBlockFromClip(
 
 void ScDocument::CopyNonFilteredFromClip(
 sc::CopyFromClipContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
-const ScMarkData rMark, SCsCOL nDx, SCsROW /*nDy*/, SCROW  rClipStartRow 
)
+const ScMarkData rMark, SCsCOL nDx, SCROW  rClipStartRow )
 {
 //  call CopyBlockFromClip for ranges of consecutive non-filtered rows
 //  nCol1/nRow1 etc. is in target doc
@@ -2564,7 +2564,7 @@ void ScDocument::CopyFromClip( const ScRange rDestRange, 
const ScMarkData rMar
 else
 {
 CopyNonFilteredFromClip(
-aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nDy, 
nClipStartRow);
+aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nClipStartRow);
 }
 nC1 = nC2 + 1;
 nC2 = std::min((SCCOL)(nC1 + nXw), nCol2);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-15 Thread Kohei Yoshida
 sc/inc/column.hxx|4 -
 sc/inc/conditio.hxx  |1 
 sc/inc/document.hxx  |3 +
 sc/source/core/data/column.cxx   |   85 ++-
 sc/source/core/data/column2.cxx  |2 
 sc/source/core/data/conditio.cxx |   12 +
 sc/source/core/data/documen4.cxx |   40 --
 7 files changed, 121 insertions(+), 26 deletions(-)

New commits:
commit 66cec852203818e4f45d3be0eab7a018d1a385cf
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed May 15 22:14:40 2013 -0400

Speed up ScColumn::HasEditCells() by keeping track of block position.

Use block position hint to avoid re-starting search in the cell text
attribute array.  This change alone cuts additional 10 seconds off of
the previously mentioned use case, by reducing the duration of
HasEditCells() call from the previous ~10 seconds to a tiny fraction
of a second.

Change-Id: Id9f951cd235a88928c900619b6b66d7b8a057e0c

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index edf362f..a697bed 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -268,7 +268,7 @@ public:
 voidMoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn rCol);
 
 
-bool   HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW 
rFirst) const;
+bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW rFirst);
 
 bool SetString(
 SCROW nRow, SCTAB nTab, const String rString, 
formula::FormulaGrammar::AddressConvention eConv,
@@ -411,7 +411,7 @@ public:
 void GetOptimalHeight(
 SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, OutputDevice* 
pDev,
 double nPPTX, double nPPTY, const Fraction rZoomX, const Fraction 
rZoomY,
-bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart) const;
+bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart);
 
 /// Including current, may return -1
 SCsROW  GetNextUnprotected( SCROW nRow, bool bUp ) const;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 9e7e14d..87cfcc3 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -455,6 +455,7 @@ public:
 boolCheckAllEntries();
 
 ScConditionalFormat* GetFormat( sal_uInt32 nKey );
+const ScConditionalFormat* GetFormat( sal_uInt32 nKey ) const;
 
 voidCompileAll();
 voidCompileXML();
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index c511cf0..e2ea7e3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1267,6 +1267,9 @@ public:
 
 SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, 
SCTAB nTab ) const;
 SC_DLLPUBLIC const SfxItemSet*  GetCondResult( SCCOL nCol, SCROW nRow, 
SCTAB nTab ) const;
+const SfxItemSet* GetCondResult(
+ScRefCellValue rCell, const ScAddress rPos, const 
ScConditionalFormatList rList,
+const std::vectorsal_uInt32 rIndex ) const;
 const SfxPoolItem*  GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, 
sal_uInt16 nWhich ) const;
 
 SC_DLLPUBLIC const ::com::sun::star::uno::Reference 
::com::sun::star::i18n::XBreakIterator  GetBreakIterator();
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 0e42ff1..704bdff 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -33,6 +33,7 @@
 #include globalnames.hxx
 #include cellvalue.hxx
 #include tokenarray.hxx
+#include cellform.hxx
 
 #include svl/poolcach.hxx
 #include svl/zforlist.hxx
@@ -2286,25 +2287,89 @@ void ScColumn::ResetChanged( SCROW nStartRow, SCROW 
nEndRow )
 }
 
 
-bool ScColumn::HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW rFirst) 
const
+bool ScColumn::HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW rFirst)
 {
 //  used in GetOptimalHeight - ambiguous script type counts as edit cell
 
-SCROW nRow = 0;
-SCSIZE nIndex;
-Search(nStartRow,nIndex);
-while ( (nIndex  maItems.size()) ? ((nRow=maItems[nIndex].nRow) = 
nEndRow) : false )
+std::vectorColEntry::const_iterator itCell = Search(nStartRow);
+std::vectorColEntry::const_iterator itCellEnd = maItems.end();
+if (itCell == itCellEnd)
+return false;
+
+SvNumberFormatter* pFormatter = pDocument-GetFormatTable();
+ScConditionalFormatList* pCFList = pDocument-GetCondFormList(nTab);
+
+sc::CellTextAttrStoreType::iterator itAttrPos = maCellTextAttrs.begin();
+for (; itCell != itCellEnd  itCell-nRow = nEndRow; ++itCell)
 {
-ScBaseCell* pCell = maItems[nIndex].pCell;
+ScBaseCell* pCell = itCell-pCell;
+SCROW nRow = itCell-nRow;
 CellType eCellType = pCell-GetCellType();
-if ( eCellType == CELLTYPE_EDIT ||
- IsAmbiguousScriptNonZero( pDocument-GetScriptType(nCol, nRow, 
nTab) ) ||
- ((eCellType == CELLTYPE_FORMULA)  
((ScFormulaCell*)pCell)-IsMultilineResult()) )
+
+// See if this is a real edit cell.
+if (eCellType == CELLTYPE_EDIT)
+{
+  

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-14 Thread Kohei Yoshida
 sc/inc/textuno.hxx  |4 +++-
 sc/source/ui/unoobj/textuno.cxx |1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 4038dd021673730a28b0e560c6ba613da1ff
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue May 14 16:25:41 2013 -0400

Fix memory leak.

Change-Id: I90e419d19f4565f7f20603358308fd7aeba83190

diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx
index 19f9eff..e531c8e 100644
--- a/sc/inc/textuno.hxx
+++ b/sc/inc/textuno.hxx
@@ -35,6 +35,8 @@
 #include rtl/ref.hxx
 #include scdllapi.h
 
+#include boost/noncopyable.hpp
+
 class EditEngine;
 class EditTextObject;
 class SvxEditEngineForwarder;
@@ -110,7 +112,7 @@ public:
 
 //  ScHeaderFooterTextData: shared data between sub objects of a 
ScHeaderFooterTextObj
 
-class ScHeaderFooterTextData
+class ScHeaderFooterTextData : boost::noncopyable
 {
 private:
 EditTextObject* mpTextObj;
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 77ba10f..3976e21 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -200,6 +200,7 @@ ScHeaderFooterTextData::~ScHeaderFooterTextData()
 
 delete pForwarder;
 delete pEditEngine;
+delete mpTextObj;
 }
 
 SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-09 Thread Kohei Yoshida
 sc/inc/brdcst.hxx |6 +-
 sc/source/core/data/column.cxx|   10 --
 sc/source/core/data/column3.cxx   |   19 +--
 sc/source/core/data/documen7.cxx  |4 ++--
 sc/source/core/data/table5.cxx|4 ++--
 sc/source/core/tool/addinlis.cxx  |2 +-
 sc/source/core/tool/adiasync.cxx  |2 +-
 sc/source/core/tool/brdcst.cxx|   14 ++
 sc/source/core/tool/ddelink.cxx   |2 +-
 sc/source/ui/docshell/docsh.cxx   |6 +++---
 sc/source/ui/unoobj/chart2uno.cxx |2 +-
 11 files changed, 27 insertions(+), 44 deletions(-)

New commits:
commit a417e759f737ecea4f4a28df70abc7c3b5572a8d
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu May 9 10:20:39 2013 -0400

ScHint doesn't need to store broadcaster pointer. Let's not.

Change-Id: I86f9b44c87f3a730902d12505252e4b7e0a24fe4

diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx
index 069f032..beef774 100644
--- a/sc/inc/brdcst.hxx
+++ b/sc/inc/brdcst.hxx
@@ -33,15 +33,11 @@ class SvtBroadcaster;
 
 class ScHint : public SfxSimpleHint
 {
-private:
 ScAddress   aAddress;
-SvtBroadcaster* mpBroadcaster;
 
 public:
 TYPEINFO();
-ScHint( sal_uLong n, const ScAddress a, SvtBroadcaster* p );
-SvtBroadcaster* GetBroadcaster() const;
-void SetBroadcaster( SvtBroadcaster* p );
+ScHint( sal_uLong n, const ScAddress a );
 const ScAddressGetAddress() const { return aAddress; }
   ScAddressGetAddress()   { return aAddress; }
 voidSetAddress( const ScAddress rAdr ) { aAddress = rAdr; 
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index af373d6..a4371f2 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1138,7 +1138,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
 SCSIZE nNewCount = maItems.size();
 bool bCountChanged = false;
 ScAddress aAdr( nCol, 0, nTab );
-ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL );// only areas 
(ScBaseCell* == NULL)
+ScHint aHint(SC_HINT_DATACHANGED, aAdr);// only areas (ScBaseCell* == 
NULL)
 ScAddress rAddress = aHint.GetAddress();
 // for sparse occupation use single broadcasts, not ranges
 bool bSingleBroadcasts = (((maItems.back().nRow - maItems[i].nRow) /
@@ -1725,7 +1725,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, 
ScColumn rCol)
 }
 // Broadcast changes
 ScAddress aAdr( nCol, 0, nTab );
-ScHint aHint(SC_HINT_DATACHANGED, aAdr, NULL);  // areas only
+ScHint aHint(SC_HINT_DATACHANGED, aAdr);  // areas only
 ScAddress rAddress = aHint.GetAddress();
 
 // must iterate backwards, because indexes of following cells become 
invalid
@@ -2104,7 +2104,7 @@ void ScColumn::SetDirty( const ScRange rRange )
 pDocument-SetAutoCalc( false );// no multiple recalculation
 SCROW nRow2 = rRange.aEnd.Row();
 ScAddress aPos( nCol, 0, nTab );
-ScHint aHint( SC_HINT_DATACHANGED, aPos, NULL );
+ScHint aHint(SC_HINT_DATACHANGED, aPos);
 SCROW nRow;
 SCSIZE nIndex;
 Search( rRange.aStart.Row(), nIndex );
@@ -2116,7 +2116,6 @@ void ScColumn::SetDirty( const ScRange rRange )
 else
 {
 aHint.GetAddress().SetRow( nRow );
-aHint.SetBroadcaster(GetBroadcaster(nRow));
 pDocument-Broadcast( aHint );
 }
 nIndex++;
@@ -2133,7 +2132,7 @@ void ScColumn::SetTableOpDirty( const ScRange rRange )
 pDocument-SetAutoCalc( false );// no multiple recalculation
 SCROW nRow2 = rRange.aEnd.Row();
 ScAddress aPos( nCol, 0, nTab );
-ScHint aHint( SC_HINT_TABLEOPDIRTY, aPos, NULL );
+ScHint aHint(SC_HINT_TABLEOPDIRTY, aPos);
 SCROW nRow;
 SCSIZE nIndex;
 Search( rRange.aStart.Row(), nIndex );
@@ -2145,7 +2144,6 @@ void ScColumn::SetTableOpDirty( const ScRange rRange )
 else
 {
 aHint.GetAddress().SetRow( nRow );
-aHint.SetBroadcaster(GetBroadcaster(nRow));
 pDocument-Broadcast( aHint );
 }
 nIndex++;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e36312b..8e8ad31 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -82,7 +82,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
 ((ScFormulaCell*)pNewCell)-SetDirty();
 else
 pDocument-Broadcast(
-ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), 
GetBroadcaster(nRow)));
+ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab)));
 }
 }
 }
@@ -123,7 +123,7 @@ void ScColumn::Delete( SCROW nRow )
 pCell-Delete();
 
 pDocument-Broadcast(
-ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), 
GetBroadcaster(nRow)));
+ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab)));
 
 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-03 Thread Kohei Yoshida
 sc/inc/brdcst.hxx   |1 -
 sc/source/core/data/column.cxx  |2 +-
 sc/source/core/data/column3.cxx |   13 ++---
 sc/source/core/data/formulacell.cxx |2 +-
 sc/source/core/tool/chartlis.cxx|2 +-
 sc/source/core/tool/lookupcache.cxx |2 +-
 sc/source/ui/docshell/servobj.cxx   |2 +-
 sc/source/ui/unoobj/cellsuno.cxx|2 +-
 sc/source/ui/unoobj/chart2uno.cxx   |2 +-
 9 files changed, 13 insertions(+), 15 deletions(-)

New commits:
commit 2ec086a11c2f61fd9bd703591e411793df11a700
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 3 16:39:10 2013 -0400

Remove SC_HINT_DYING. We don't do anything specific for this hint.

Use SC_HINT_DATACHANGED instead, and do broadcast *after* the cell is
removed from the cell array, to avoid the dying cell from being used
during recalculation after the broadcast.

Change-Id: I8eb31eafa50c737ab683ca697657e64e52ae52e7

diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx
index 737e7e8..069f032 100644
--- a/sc/inc/brdcst.hxx
+++ b/sc/inc/brdcst.hxx
@@ -27,7 +27,6 @@
 
 class SvtBroadcaster;
 
-#define SC_HINT_DYING   SFX_HINT_DYING
 #define SC_HINT_DATACHANGED SFX_HINT_DATACHANGED
 #define SC_HINT_TABLEOPDIRTYSFX_HINT_USER00
 #define SC_HINT_CALCALL SFX_HINT_USER01
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 4e061ab..e20521a 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1731,7 +1731,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, 
ScColumn rCol)
 }
 // Broadcast changes
 ScAddress aAdr( nCol, 0, nTab );
-ScHint aHint( SC_HINT_DYING, aAdr, NULL );  // areas only
+ScHint aHint(SC_HINT_DATACHANGED, aAdr, NULL);  // areas only
 ScAddress rAddress = aHint.GetAddress();
 
 // must iterate backwards, because indexes of following cells become 
invalid
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index dd22051..8983fa1 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -105,9 +105,6 @@ void ScColumn::Delete( SCROW nRow )
 return;
 
 ScBaseCell* pCell = maItems[nIndex].pCell;
-pDocument-Broadcast(
-ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), 
GetBroadcaster(nRow)));
-
 maItems.erase(maItems.begin() + nIndex);
 maTextWidths.set_empty(nRow, nRow);
 maScriptTypes.set_empty(nRow, nRow);
@@ -116,6 +113,9 @@ void ScColumn::Delete( SCROW nRow )
 static_castScFormulaCell*(pCell)-EndListeningTo(pDocument);
 pCell-Delete();
 
+pDocument-Broadcast(
+ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), 
GetBroadcaster(nRow)));
+
 CellStorageModified();
 }
 
@@ -124,13 +124,14 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
 {
 ScBaseCell* pCell = maItems[nIndex].pCell;
 SCROW nRow = maItems[nIndex].nRow;
-pDocument-Broadcast(
-ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), 
GetBroadcaster(nRow)));
 maItems.erase(maItems.begin() + nIndex);
 if (pCell-GetCellType() == CELLTYPE_FORMULA)
 static_castScFormulaCell*(pCell)-EndListeningTo(pDocument);
 pCell-Delete();
 
+pDocument-Broadcast(
+ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), 
GetBroadcaster(nRow)));
+
 maTextWidths.set_empty(nRow, nRow);
 maScriptTypes.set_empty(nRow, nRow);
 CellStorageModified();
@@ -304,8 +305,6 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE 
nEndIndex, sal_uInt16 nDe
 paste cells operation, which removes the caption objects later in
 drawing undo. */
 
-ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 );
-
 // cache all formula cells, they will be deleted at end of this function
 typedef ::std::vector ScFormulaCell*  FormulaCellVector;
 FormulaCellVector aDelCells;
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index aa36598..cb13563 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1512,7 +1512,7 @@ void ScFormulaCell::Notify( SvtBroadcaster, const 
SfxHint rHint)
 {
 const ScHint* p = PTR_CAST( ScHint, rHint );
 sal_uLong nHint = (p ? p-GetId() : 0);
-if (nHint  (SC_HINT_DATACHANGED | SC_HINT_DYING | 
SC_HINT_TABLEOPDIRTY))
+if (nHint  (SC_HINT_DATACHANGED | SC_HINT_TABLEOPDIRTY))
 {
 bool bForceTrack = false;
 if ( nHint  SC_HINT_TABLEOPDIRTY )
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 0b0f7a1..ed07960 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -213,7 +213,7 @@ uno::Reference chart::XChartData  
ScChartListener::GetUnoSource() const
 void ScChartListener::Notify( SvtBroadcaster, const SfxHint rHint )
 {
 const ScHint* p = dynamic_castconst 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-03 Thread Kohei Yoshida
 sc/inc/cell.hxx |4 --
 sc/source/core/data/cell.cxx|5 --
 sc/source/core/data/column.cxx  |3 -
 sc/source/core/data/column2.cxx |   75 +++-
 4 files changed, 22 insertions(+), 65 deletions(-)

New commits:
commit 530016c7cc7b557f4be481ea09360abd10a531e3
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri May 3 22:24:31 2013 -0400

With the removal of CELLTYPE_NOTE, IsBlank() is now always false.

Let's remove this.

Change-Id: Ica92ea41e104a3f0e97b717ff2e4e115682ce33f

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index ef7c2f7..909c89d 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -65,10 +65,6 @@ public:
 
 inline CellType GetCellType() const { return (CellType)eCellType; }
 
-/** Returns true, if the cell is empty (neither value nor formula nor cell 
note).
-Returns false for formula cells returning nothing, use HasEmptyData() 
for that. */
-boolIsBlank() const;
-
 /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may 
have been
 created due to reference to empty cell). */
 boolHasEmptyData() const;
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index b5c8d33..6ccc80a 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -106,11 +106,6 @@ void ScBaseCell::Delete()
 }
 }
 
-bool ScBaseCell::IsBlank() const
-{
-return false;
-}
-
 bool ScBaseCell::HasEmptyData() const
 {
 switch ( eCellType )
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index e20521a..6f4aff8 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1089,8 +1089,7 @@ bool ScColumn::TestInsertCol( SCROW nStartRow, SCROW 
nEndRow) const
 bool bTest = true;
 if ( !maItems.empty() )
 for (SCSIZE i=0; (imaItems.size())  bTest; i++)
-bTest = (maItems[i].nRow  nStartRow) || (maItems[i].nRow  
nEndRow)
-|| maItems[i].pCell-IsBlank();
+bTest = (maItems[i].nRow  nStartRow) || (maItems[i].nRow  
nEndRow);
 
 //  AttrArray only looks for merged cells
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index db9a3e8..40fcf2c 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1113,19 +1113,7 @@ bool ScColumn::IsEmptyData() const
 
 bool ScColumn::IsEmptyVisData() const
 {
-if ( maItems.empty() )
-return true;
-else
-{
-bool bVisData = false;
-SCSIZE i;
-for (i=0; imaItems.size()  !bVisData; i++)
-{
-if(!maItems[i].pCell-IsBlank())
-bVisData = true;
-}
-return !bVisData;
-}
+return maItems.empty();
 }
 
 SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const
@@ -1148,22 +1136,10 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW 
nEndRow ) const
 
 SCROW ScColumn::GetLastVisDataPos() const
 {
-SCROW nRet = 0;
-if ( !maItems.empty() )
-{
-SCSIZE i;
-bool bFound = false;
-for (i=maItems.size(); i0  !bFound; )
-{
---i;
-if(!maItems[i].pCell-IsBlank())
-{
-bFound = true;
-nRet = maItems[i].nRow;
-}
-}
-}
-return nRet;
+if (maItems.empty())
+return 0;
+
+return maItems.back().nRow;
 }
 
 SCROW ScColumn::GetFirstVisDataPos() const
@@ -1184,12 +1160,11 @@ SCROW ScColumn::GetFirstVisDataPos() const
 
 bool ScColumn::HasVisibleDataAt(SCROW nRow) const
 {
-SCSIZE nIndex;
-if (Search(nRow, nIndex))
-if (!maItems[nIndex].pCell-IsBlank())
-return true;
+std::vectorColEntry::const_iterator it = Search(nRow);
+if (it == maItems.end())
+return false;
 
-return false;
+return it-nRow == nRow;
 }
 
 bool ScColumn::IsEmptyAttr() const
@@ -1210,15 +1185,12 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW 
nEndRow) const
 if ( maItems.empty() )
 return true;
 
-SCSIZE nIndex;
-Search( nStartRow, nIndex );
-while ( nIndex  maItems.size()  maItems[nIndex].nRow = nEndRow )
-{
-if ( !maItems[nIndex].pCell-IsBlank() )   // found a cell
-return false;   // not empty
-++nIndex;
-}
-return true;// no cell found
+std::vectorColEntry::const_iterator it = Search(nStartRow);
+if (it == maItems.end())
+// All non-empty cells are before nStartRow.
+return true;
+
+return (it-nRow  nEndRow);
 }
 
 SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, 
ScDirection eDir ) const
@@ -1236,7 +1208,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, 
SCROW nEndRow, ScDirecti
 i--;
 if ( maItems[i].nRow  

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-05-02 Thread Kohei Yoshida
 sc/inc/column.hxx  |9 -
 sc/inc/mtvblockfunc.hxx|   35 +++
 sc/source/core/data/column.cxx |1 +
 3 files changed, 44 insertions(+), 1 deletion(-)

New commits:
commit 58ae6486359672d14d577426babb98f5fa04090d
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu May 2 23:16:01 2013 -0400

Add new broadcaster storage in ScColumn. Not used yet.

Change-Id: I8e68de0e50fffc1df0545af16456cd4cdd3596d8

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 290f45b..ed1392a 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -25,6 +25,7 @@
 #include address.hxx
 #include rangenam.hxx
 #include types.hxx
+#include mtvblockfunc.hxx
 #include formula/types.hxx
 
 #include set
@@ -41,7 +42,7 @@
 #endif
 
 #include mdds/multi_type_vector.hpp
-#include mdds/multi_type_vector_trait.hpp
+#include mdds/multi_type_vector_custom_func1.hpp
 
 namespace editeng { class SvxBorderLine; }
 
@@ -117,6 +118,10 @@ struct ColDoubleEntry
 
 class ScColumn
 {
+// Broadcaster storage container
+typedef mdds::mtv::custom_block_func1sc::element_type_broadcaster, 
sc::custom_broadcaster_block BroadcasterBlkFunc;
+typedef mdds::multi_type_vectorBroadcasterBlkFunc BroadcasterStoreType;
+
 typedef mdds::multi_type_vectormdds::mtv::element_block_func 
TextWidthType;
 typedef mdds::multi_type_vectormdds::mtv::element_block_func ScriptType;
 
@@ -128,6 +133,8 @@ class ScColumn
 // Script types are stored as unsigned char.
 ScriptType maScriptTypes;
 
+BroadcasterStoreType maBroadcasters;
+
 SCCOL   nCol;
 SCTAB   nTab;
 
diff --git a/sc/inc/mtvblockfunc.hxx b/sc/inc/mtvblockfunc.hxx
new file mode 100644
index 000..41c5175
--- /dev/null
+++ b/sc/inc/mtvblockfunc.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_MTVBLOCKFUNC_HXX
+#define SC_MTVBLOCKFUNC_HXX
+
+#include svl/broadcast.hxx
+
+#include mdds/multi_type_vector_macro.hpp
+#include mdds/multi_type_vector_types.hpp
+
+namespace sc {
+
+// Custom element type IDs for multi_type_vector.
+
+const mdds::mtv::element_t element_type_broadcaster = 
mdds::mtv::element_type_user_start;
+
+// Custom element blocks.
+
+typedef mdds::mtv::noncopyable_managed_element_blockelement_type_broadcaster, 
SvtBroadcaster custom_broadcaster_block;
+
+}
+
+// This needs to be in global namespace just like SvtBroacaster is.
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, 
sc::element_type_broadcaster, NULL, sc::custom_broadcaster_block)
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index be9e5d6..c98cc39 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -113,6 +113,7 @@ std::vectorColEntry::const_iterator ScColumn::Search( 
SCROW nRow ) const
 ScColumn::ScColumn() :
 maTextWidths(MAXROWCOUNT),
 maScriptTypes(MAXROWCOUNT),
+maBroadcasters(MAXROWCOUNT),
 nCol( 0 ),
 pAttrArray( NULL ),
 pDocument( NULL ),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-04-30 Thread Kohei Yoshida
 sc/inc/formulacell.hxx |2 +-
 sc/source/core/data/column.cxx |2 +-
 sc/source/core/data/formulacell.cxx|7 +++
 sc/source/core/tool/formulagroup.cxx   |3 +++
 sc/source/filter/oox/formulabuffer.cxx |2 +-
 sc/source/ui/unoobj/cellsuno.cxx   |2 +-
 6 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 8de5aadd3c24d6d678a0103c48f53ecb212f4ebb
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Apr 30 11:24:29 2013 -0400

Ensure that modified formula cells are redrawn.

ScFormulaCell::bChanged is responsible for this, though, we should only
set it to true for visible cells only. That's a TODO for later.

Change-Id: Ic237c45fb271f901320f4843c89710aedd16c906

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 2a8546f..2d0d04c 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -192,7 +192,7 @@ public:
 voidFindRangeNamesInUse(std::setsal_uInt16 rIndexes) const;
 boolIsSubTotal() const  { return 
bSubTotal; }
 boolIsChanged() const;
-voidResetChanged();
+void SetChanged(bool b);
 boolIsEmpty();  // formula::svEmptyCell result
 // display as empty string if formula::svEmptyCell result
 boolIsEmptyDisplayedAsString();
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index da9aa3c..2933e9f 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2382,7 +2382,7 @@ void ScColumn::ResetChanged( SCROW nStartRow, SCROW 
nEndRow )
 {
 ScBaseCell* pCell = maItems[nIndex].pCell;
 if (pCell-GetCellType() == CELLTYPE_FORMULA)
-((ScFormulaCell*)pCell)-ResetChanged();
+((ScFormulaCell*)pCell)-SetChanged(false);
 ++nIndex;
 }
 }
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index d271edc..80305c2 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2730,9 +2730,9 @@ bool ScFormulaCell::IsChanged() const
 return bChanged;
 }
 
-void ScFormulaCell::ResetChanged()
+void ScFormulaCell::SetChanged(bool b)
 {
-bChanged = false;
+bChanged = b;
 }
 
 void ScFormulaCell::CompileDBFormula()
@@ -3153,8 +3153,7 @@ bool ScFormulaCell::InterpretInvariantFormulaGroup()
 // Ensure the cell truly has a result:
 pCell-aResult = aResult;
 pCell-ResetDirty();
-
-// FIXME: there is a view / refresh missing here it appears.
+pCell-SetChanged(true);
 }
 
 return true;
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 9f76fe2..c554e9c 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -88,7 +88,10 @@ bool FormulaGroupInterpreter::interpret()
 
 pDest-SetResultToken(aInterpreter.GetResultToken().get());
 pDest-ResetDirty();
+pDest-SetChanged(true);
 }
+
+return true;
 }
 
 }
diff --git a/sc/source/filter/oox/formulabuffer.cxx 
b/sc/source/filter/oox/formulabuffer.cxx
index 0fa6dcb..32ec1d6 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -151,7 +151,7 @@ void FormulaBuffer::applyCellFormulaValues( const 
std::vector ValueAddressPair
 {
 pCell-SetHybridDouble( it-second );
 pCell-ResetDirty();
-pCell-ResetChanged();
+pCell-SetChanged(false);
 }
 }
 }
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 6006181..dc40193 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6609,7 +6609,7 @@ void SAL_CALL ScCellObj::setFormulaResult( double nValue 
) throw(uno::RuntimeExc
 ScFormulaCell* pCell = pDocSh-GetDocument()-GetFormulaCell(aCellPos);
 pCell-SetHybridDouble( nValue );
 pCell-ResetDirty();
-pCell-ResetChanged();
+pCell-SetChanged(false);
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-04-29 Thread Kohei Yoshida
 sc/inc/column.hxx   |2 +-
 sc/source/core/data/column.cxx  |   13 ++---
 sc/source/core/data/column2.cxx |1 +
 sc/source/core/data/column3.cxx |   15 ++-
 4 files changed, 6 insertions(+), 25 deletions(-)

New commits:
commit 5f461f32fea980df4d89fbbbc815800d8d5deb40
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Apr 29 15:17:47 2013 -0400

CellStorageModified() is the right (and only) place to mark group dirty.

CellStorageModified is supposed to be called whenever the cell array
content changes. We should take advantage of it.

Change-Id: Ib1cd0e91f3d5a3d03d2172ed6cc916520d1baa49

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6b3202a..9b6e614 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -139,7 +139,7 @@ class ScColumn
 
 ScAttrArray*  pAttrArray;
 ScDocument*   pDocument;
-bool  bDirtyGroups; /// formula groups are dirty.
+bool mbDirtyGroups; /// formula groups are dirty.
 
 friend class ScDocument;// for FillInfo
 friend class ScDocumentIterator;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 17bbe68..da9aa3c 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -116,7 +116,7 @@ ScColumn::ScColumn() :
 nCol( 0 ),
 pAttrArray( NULL ),
 pDocument( NULL ),
-bDirtyGroups( true )
+mbDirtyGroups(true)
 {
 }
 
@@ -134,7 +134,6 @@ void ScColumn::Init(SCCOL nNewCol, SCTAB nNewTab, 
ScDocument* pDoc)
 nTab = nNewTab;
 pDocument = pDoc;
 pAttrArray = new ScAttrArray( nCol, nTab, pDocument );
-bDirtyGroups = true;
 }
 
 
@@ -893,8 +892,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 ::std::swap( pCell1, pCell2 );
 }
 
-bDirtyGroups = true;
-
 // from here: first cell (pCell1, nIndex1) exists always
 
 ScAddress aPos1( nCol, nRow1, nTab );
@@ -1054,8 +1051,6 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn rCol)
 return;
 }
 
-bDirtyGroups = true;
-
 // from here: own cell (pCell1, nIndex1) exists always
 
 ScFormulaCell* pFmlaCell1 = (pCell1-GetCellType() == CELLTYPE_FORMULA) ? 
static_cast ScFormulaCell* ( pCell1 ) : 0;
@@ -1175,8 +1170,6 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
 if ( i = maItems.size() )
 return ;
 
-bDirtyGroups = true;
-
 bool bOldAutoCalc = pDocument-GetAutoCalc();
 pDocument-SetAutoCalc( false );// avoid recalculations
 
@@ -1711,9 +1704,7 @@ void ScColumn::SwapCol(ScColumn rCol)
 pAttrArray-SetCol(nCol);
 rCol.pAttrArray-SetCol(rCol.nCol);
 
-bool bDirty = bDirtyGroups;
-bDirtyGroups = rCol.bDirtyGroups;
-rCol.bDirtyGroups = bDirty;
+std::swap(mbDirtyGroups, rCol.mbDirtyGroups);
 
 SCSIZE i;
 for (i = 0; i  maItems.size(); i++)
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 25725ae..434edad 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1398,6 +1398,7 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, 
bool bForward) const
 
 void ScColumn::CellStorageModified()
 {
+mbDirtyGroups = true;
 #if DEBUG_COLUMN_STORAGE
 if (maItems.empty())
 {
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 615fbaf..63b3a5f 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -87,7 +87,6 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
 ScAddress( nCol, nRow, nTab ), pNewCell-GetBroadcaster()) 
);
 }
 }
-bDirtyGroups = true;
 }
 
 
@@ -95,7 +94,6 @@ void ScColumn::Insert( SCROW nRow, sal_uInt32 nNumberFormat, 
ScBaseCell* pCell )
 {
 Insert(nRow, pCell);
 SetNumberFormat(nRow, nNumberFormat);
-bDirtyGroups = true;
 }
 
 
@@ -105,7 +103,6 @@ void ScColumn::Append( SCROW nRow, ScBaseCell* pCell )
 maItems.back().pCell = pCell;
 maItems.back().nRow  = nRow;
 
-bDirtyGroups = true;
 maTextWidths.setunsigned short(nRow, TEXTWIDTH_DIRTY);
 maScriptTypes.setunsigned short(nRow, SC_SCRIPTTYPE_UNKNOWN);
 CellStorageModified();
@@ -138,7 +135,6 @@ void ScColumn::Delete( SCROW nRow )
 if (pCell-GetCellType() == CELLTYPE_FORMULA)
 static_castScFormulaCell*(pCell)-EndListeningTo(pDocument);
 pCell-Delete();
-bDirtyGroups = true;
 
 CellStorageModified();
 }
@@ -159,7 +155,6 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
 static_castScFormulaCell*(pCell)-EndListeningTo(pDocument);
 pCell-Delete();
 
-bDirtyGroups = true;
 maTextWidths.set_empty(nRow, nRow);
 maScriptTypes.set_empty(nRow, nRow);
 CellStorageModified();
@@ -196,8 +191,6 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 sal_Bool bOldAutoCalc = pDocument-GetAutoCalc();
 pDocument-SetAutoCalc( false ); // Avoid 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-04-29 Thread Kohei Yoshida
 sc/inc/column.hxx   |6 +-
 sc/inc/document.hxx |6 +-
 sc/inc/formulagroup.hxx |   30 ++
 sc/inc/table.hxx|7 ++-
 sc/source/core/data/column2.cxx |5 -
 sc/source/core/data/document.cxx|5 +++--
 sc/source/core/data/formulacell.cxx |5 -
 sc/source/core/data/table1.cxx  |5 +++--
 8 files changed, 60 insertions(+), 9 deletions(-)

New commits:
commit 7baf318bf56c8093fdbdeb4d54f56cbe9cadc81c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Apr 29 17:15:32 2013 -0400

Pass formula group context to FetchDoubleArray. Not yet used.

In the future I'll use it to store temporary double array buffer here,
in case the requested row span is over multiple arrays.

Change-Id: Id4260ec4ced4c8c1ee718106f37a7374c62b204c

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9b6e614..e70f108 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -45,6 +45,10 @@
 
 namespace editeng { class SvxBorderLine; }
 
+namespace sc {
+struct FormulaGroupContext;
+}
+
 class Fraction;
 class OutputDevice;
 class SfxItemPoolCache;
@@ -460,7 +464,7 @@ public:
 ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
 bool ResolveStaticReference( ScMatrix rMat, SCCOL nMatCol, SCROW nRow1, 
SCROW nRow2 );
-const double* FetchDoubleArray( SCROW nRow1, SCROW nRow2 ) const;
+const double* FetchDoubleArray( sc::FormulaGroupContext rCxt, SCROW 
nRow1, SCROW nRow2 ) const;
 
 ScRefCellValue GetRefCellValue( SCROW );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 876c9d7..0920dd5e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -47,6 +47,9 @@
 #include boost/scoped_ptr.hpp
 
 namespace editeng { class SvxBorderLine; }
+namespace sc {
+struct FormulaGroupContext;
+}
 class SvxFontItem;
 
 class KeyEvent;
@@ -1944,7 +1947,8 @@ public:
 formula::FormulaTokenRef ResolveStaticReference( const ScAddress rPos );
 formula::FormulaTokenRef ResolveStaticReference( const ScRange rRange );
 
-const double* FetchDoubleArray( const ScAddress rPos, SCROW nLength ) 
const;
+const double* FetchDoubleArray(
+sc::FormulaGroupContext rCxt, const ScAddress rPos, SCROW nLength ) 
const;
 
 private: // CLOOK-Impl-methods
 
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
new file mode 100644
index 000..0a8e3f7
--- /dev/null
+++ b/sc/inc/formulagroup.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_FORMULAGROUP_HXX
+#define SC_FORMULAGROUP_HXX
+
+#include boost/noncopyable.hpp
+#include boost/ptr_container/ptr_vector.hpp
+
+namespace sc {
+
+struct FormulaGroupContext : boost::noncopyable
+{
+typedef std::vectordouble DoubleArrayType;
+typedef boost::ptr_vectorDoubleArrayType ArrayStoreType;
+
+ArrayStoreType maArrays;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7c45a57..c090f8b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -47,6 +47,10 @@ namespace com { namespace sun { namespace star {
 }
 } } }
 
+namespace sc {
+struct FormulaGroupContext;
+}
+
 class SfxItemSet;
 class SfxStyleSheetBase;
 class SvxBoxInfoItem;
@@ -822,7 +826,8 @@ public:
 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 );
-const double* FetchDoubleArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) 
const;
+const double* FetchDoubleArray(
+sc::FormulaGroupContext rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) 
const;
 
 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 434edad..2e20d0f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -57,6 +57,7 @@
 #include cellvalue.hxx
 #include tokenarray.hxx
 #include globalnames.hxx
+#include formulagroup.hxx
 
 #include math.h
 
@@ -1661,8 +1662,10 @@ bool ScColumn::ResolveStaticReference( ScMatrix rMat, 
SCCOL nMatCol, SCROW nRow
 return true;
 }
 
-const double* ScColumn::FetchDoubleArray( SCROW nRow1, SCROW nRow2 ) const
+const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext /*rCxt*/, 
SCROW nRow1, SCROW nRow2 ) const
 {
+// TODO: I'll use the context object later.
+
 if 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-04-26 Thread Kohei Yoshida
 sc/inc/formulacell.hxx  |3 
 sc/source/core/data/formulacell.cxx |  156 ++--
 2 files changed, 82 insertions(+), 77 deletions(-)

New commits:
commit b77a730516be574e0db5b80e90c7dd87a5b897c0
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Apr 26 23:16:43 2013 -0400

Move the invariant group handler into its own method.

Change-Id: I3ed8da3c9673b990d5ae17d235bcf4fc1a4541f1

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 397fd9c..e4f1cfa 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -302,7 +302,8 @@ public:
 
 CompareState CompareByTokenArray( ScFormulaCell *pOther ) const;
 
-bool   InterpretFormulaGroup();
+bool InterpretFormulaGroup();
+bool InterpretInvariantFormulaGroup();
 
 // nOnlyNames may be one or more of SC_LISTENING_NAMES_*
 void StartListeningTo( ScDocument* pDoc );
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 43d80cf..3bfd458 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2965,82 +2965,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
 }
 
 if (xGroup-mbInvariant)
-{
-if (pCode-GetVectorState() == FormulaVectorCheckReference)
-{
-// An invariant group should only have absolute references, and no
-// external references are allowed.
-
-ScTokenArray aCode;
-pCode-Reset();
-for (const formula::FormulaToken* p = pCode-First(); p; p = 
pCode-Next())
-{
-const ScToken* pToken = static_castconst ScToken*(p);
-switch (pToken-GetType())
-{
-case svSingleRef:
-{
-const ScSingleRefData rRef = pToken-GetSingleRef();
-ScAddress aRefPos(rRef.nCol, rRef.nRow, rRef.nTab);
-formula::FormulaTokenRef pNewToken = 
pDocument-ResolveStaticReference(aRefPos);
-if (!pNewToken)
-return false;
-
-aCode.AddToken(*pNewToken);
-}
-break;
-case svDoubleRef:
-{
-const ScComplexRefData rRef = pToken-GetDoubleRef();
-ScRange aRefRange(
-rRef.Ref1.nCol, rRef.Ref1.nRow, rRef.Ref1.nTab,
-rRef.Ref2.nCol, rRef.Ref2.nRow, rRef.Ref2.nTab);
-
-formula::FormulaTokenRef pNewToken = 
pDocument-ResolveStaticReference(aRefRange);
-if (!pNewToken)
-return false;
-
-aCode.AddToken(*pNewToken);
-}
-break;
-default:
-aCode.AddToken(*pToken);
-}
-}
-
-ScCompiler aComp(pDocument, aPos, aCode);
-aComp.SetGrammar(pDocument-GetGrammar());
-aComp.CompileTokenArray(); // Create RPN token array.
-ScInterpreter aInterpreter(this, pDocument, aPos, aCode);
-aInterpreter.Interpret();
-aResult.SetToken(aInterpreter.GetResultToken().get());
-}
-else
-{
-// Formula contains no references.
-ScInterpreter aInterpreter(this, pDocument, aPos, *pCode);
-aInterpreter.Interpret();
-aResult.SetToken(aInterpreter.GetResultToken().get());
-}
-
-for ( sal_Int32 i = 0; i  xGroup-mnLength; i++ )
-{
-ScAddress aTmpPos = aPos;
-aTmpPos.SetRow(xGroup-mnStart + i);
-ScFormulaCell* pCell = pDocument-GetFormulaCell(aTmpPos);
-assert( pCell != NULL );
-
-// FIXME: this set of horrors is unclear to me ... certainly
-// the above GetCell is profoundly nasty  slow ...
-
-// Ensure the cell truly has a result:
-pCell-aResult = aResult;
-pCell-ResetDirty();
-
-// FIXME: there is a view / refresh missing here it appears.
-}
-return true;
-}
+return InterpretInvariantFormulaGroup();
 
 // scan the formula ...
 // have a document method: Get2DRangeAsDoublesArray that does the
@@ -3072,6 +2997,85 @@ bool ScFormulaCell::InterpretFormulaGroup()
 return false;
 }
 
+bool ScFormulaCell::InterpretInvariantFormulaGroup()
+{
+if (pCode-GetVectorState() == FormulaVectorCheckReference)
+{
+// An invariant group should only have absolute references, and no
+// external references are allowed.
+
+ScTokenArray aCode;
+pCode-Reset();
+for (const formula::FormulaToken* p = pCode-First(); p; p = 
pCode-Next())
+{
+const ScToken* pToken = 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-04-25 Thread Kohei Yoshida
 sc/inc/column.hxx|6 ++
 sc/inc/document.hxx  |9 +
 sc/inc/formulacell.hxx   |6 +++---
 sc/inc/table.hxx |1 +
 sc/source/core/data/column.cxx   |5 +
 sc/source/core/data/column2.cxx  |   27 +++
 sc/source/core/data/document.cxx |9 +
 sc/source/core/data/table1.cxx   |   11 +++
 8 files changed, 71 insertions(+), 3 deletions(-)

New commits:
commit fe7eede8274500d8c45aa886fc5bbe38e518a0c4
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Apr 25 15:43:32 2013 -0400

Not yet used, but a hook to retrieve a vector reference value.

Will be used in the next iteration.

Change-Id: Iff875e7e8a48df849d6df4dfb1418a024c9f7c06

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 8e076ee..866fce3 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -93,6 +93,11 @@ struct ColEntry
 {
 SCROW   nRow;
 ScBaseCell* pCell;
+
+struct Less : std::binary_functionColEntry, ColEntry, bool
+{
+bool operator() (const ColEntry r1, const ColEntry r2) const;
+};
 };
 
 struct ColDoubleEntry
@@ -443,6 +448,7 @@ public:
 size_t GetFormulaHash( SCROW nRow ) const;
 
 ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
+bool ResolveVectorReference( SCROW nRow1, SCROW nRow2 );
 
 ScRefCellValue GetRefCellValue( SCROW );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index afdd493..71d76ad 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1940,6 +1940,15 @@ public:
 
 ScFormulaVectorState GetFormulaVectorState( const ScAddress rPos ) const;
 
+/**
+ * Check if the range contains any dirty formula cells.  In the future
+ * we'll use this function to interpret those dirty formula cells on
+ * demand.
+ *
+ * @return true if the range is totally clean, false otherwise.
+ */
+bool ResolveVectorReference( const ScAddress rPos, SCROW nEndRow );
+
 private: // CLOOK-Impl-methods
 
 /**
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 3e68144..e6239e3 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -33,9 +33,9 @@ struct ScSimilarFormulaDelta;
 
 struct SC_DLLPUBLIC ScFormulaCellGroup
 {
-sal_Int32  mnRefCount;
-sal_Int32  mnStart;  // Start offset of that cell
-sal_Int32  mnLength; // How many of these do we have ?
+sal_Int32 mnRefCount;
+SCROW mnStart;  // Start offset of that cell
+SCROW mnLength; // How many of these do we have ?
 bool mbInvariant;
 
 ScFormulaCellGroup();
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index d46a447..eb5f756 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -819,6 +819,7 @@ public:
 size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
 
 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
+bool ResolveVectorReference( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
 
 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 8ecb82e..0c3e630 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -45,6 +45,11 @@
 using ::editeng::SvxBorderLine;
 using namespace formula;
 
+bool ColEntry::Less::operator() (const ColEntry r1, const ColEntry r2) const
+{
+return r1.nRow  r2.nRow;
+}
+
 namespace {
 
 inline bool IsAmbiguousScriptNonZero( sal_uInt8 nScript )
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 82f03cc..00f900b 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1589,6 +1589,33 @@ ScFormulaVectorState ScColumn::GetFormulaVectorState( 
SCROW nRow ) const
 return pCell ? pCell-GetVectorState() : FormulaVectorUnknown;
 }
 
+bool ScColumn::ResolveVectorReference( SCROW nRow1, SCROW nRow2 )
+{
+std::vectorColEntry::iterator itEnd = maItems.end();
+// Find first cell whose position is equal or greater than nRow1.
+ColEntry aBound;
+aBound.nRow = nRow1;
+std::vectorColEntry::iterator it =
+std::lower_bound(maItems.begin(), itEnd, aBound, ColEntry::Less());
+
+if (it == itEnd)
+return false;
+
+for (; it != itEnd  it-nRow = nRow2; ++it)
+{
+if (it-pCell-GetCellType() != CELLTYPE_FORMULA)
+// Non-formula cells are fine.
+continue;
+
+ScFormulaCell* pFC = static_castScFormulaCell*(it-pCell);
+if (pFC-GetDirty())
+// Dirty formula cells are not supported yet.
+return false;
+}
+
+return true;
+}
+
 ScRefCellValue ScColumn::GetRefCellValue( SCROW nRow )
 {
 ScRefCellValue aCell; // start empty
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9d86d45..6a00d36 100644
--- a/sc/source/core/data/document.cxx
+++ 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-04-24 Thread Kohei Yoshida
 sc/inc/formulacell.hxx  |   11 +-
 sc/source/core/data/column3.cxx |   31 +--
 sc/source/core/data/formulacell.cxx |  150 +---
 3 files changed, 71 insertions(+), 121 deletions(-)

New commits:
commit eee877bcef42435ee99b2614ba9a0ab151703aa9
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Apr 24 21:43:06 2013 -0400

We really don't need to use similar data unless I missed something.

Change-Id: Iaab6033120c3d50a54fb151916dc2a7b7ba5a98c

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 469495a..3e68144 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -34,14 +34,12 @@ struct ScSimilarFormulaDelta;
 struct SC_DLLPUBLIC ScFormulaCellGroup
 {
 sal_Int32  mnRefCount;
-ScSimilarFormulaDelta *mpDelta;  // difference between items in column
 sal_Int32  mnStart;  // Start offset of that cell
 sal_Int32  mnLength; // How many of these do we have ?
+bool mbInvariant;
 
 ScFormulaCellGroup();
 ~ScFormulaCellGroup();
-
-bool IsCompatible( ScSimilarFormulaDelta *pDelta );
 };
 inline void intrusive_ptr_add_ref(ScFormulaCellGroup *p)
 {
@@ -100,6 +98,8 @@ private:
 
 public:
 
+enum CompareState { NotEqual = 0, EqualInvariant, EqualRelativeRef };
+
 #ifdef USE_MEMPOOL
 DECL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell )
 #endif
@@ -297,8 +297,9 @@ public:
 { return xGroup; }
 void   SetCellGroup( const ScFormulaCellGroupRef xRef )
 { xGroup = xRef; }
-ScSimilarFormulaDelta *BuildDeltaTo( ScFormulaCell *pOther );
-void   ReleaseDelta( ScSimilarFormulaDelta *pDelta );
+
+CompareState CompareByTokenArray( ScFormulaCell *pOther ) const;
+
 bool   InterpretFormulaGroup();
 
 // nOnlyNames may be one or more of SC_LISTENING_NAMES_*
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3eb4b17..615fbaf 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2118,15 +2118,14 @@ void ScColumn::RebuildFormulaGroups()
 if ( rCur.pCell-GetCellType() != CELLTYPE_FORMULA )
 continue;
 
-// see if these formulae are similar
+// see if these formula tokens are identical.
 ScFormulaCell *pCur = static_cast ScFormulaCell *( rCur.pCell );
 ScFormulaCell *pPrev = static_cast ScFormulaCell *( rPrev.pCell );
 
-ScSimilarFormulaDelta *pDelta = pPrev-BuildDeltaTo( pCur );
-
-if ( !pDelta )
+ScFormulaCell::CompareState eCompState = 
pPrev-CompareByTokenArray(pCur);
+if (eCompState == ScFormulaCell::NotEqual)
 {
-// not similar
+// different formula tokens.
 pCur-SetCellGroup( xNone );
 continue;
 }
@@ -2136,8 +2135,8 @@ void ScColumn::RebuildFormulaGroups()
 {
 // create a new group ...
 xGroup.reset(new ScFormulaCellGroup);
-xGroup-mpDelta = pDelta;
 xGroup-mnStart = rPrev.nRow;
+xGroup-mbInvariant = eCompState == ScFormulaCell::EqualInvariant;
 xGroup-mnLength = 2;
 
 maFnGroups.push_back( xGroup );
@@ -2145,27 +2144,11 @@ void ScColumn::RebuildFormulaGroups()
 pCur-SetCellGroup( xGroup );
 pPrev-SetCellGroup( xGroup );
 }
-else if ( xGroup-IsCompatible( pDelta ) )
+else
 {
-// we are a compatible extension - extend the group
+// existing group. extend its length.
 pCur-SetCellGroup( xGroup );
 xGroup-mnLength++;
-pCur-ReleaseDelta( pDelta );
-}
-else
-{
-#if OSL_DEBUG_LEVEL  1
-OUString aFormula;
-pCur-GetFormula( aFormula );
-ScAddress aAddr( nCol, rCur.nRow, nTab );
-OUString aCellAddr;
-aAddr.Format( aCellAddr, 0, pDocument );
-
-fprintf( stderr, unusual incompatible extension in cell '%s' of 
formulae '%s'\n ,
- OUStringToOString( aCellAddr, RTL_TEXTENCODING_UTF8 
).getStr(),
- OUStringToOString( aFormula, RTL_TEXTENCODING_UTF8 
).getStr() );
-#endif
-pCur-ReleaseDelta( pDelta );
 }
 }
 
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index ab70344..fe956f5 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -376,7 +376,7 @@ void adjustDBRange(ScToken* pToken, ScDocument rNewDoc, 
const ScDocument* pOldD
 }
 
 ScFormulaCellGroup::ScFormulaCellGroup() :
-mnRefCount(0), mpDelta(NULL), mnStart(0), mnLength(0)
+mnRefCount(0), mnStart(0), mnLength(0), mbInvariant(false)
 {
 }
 
@@ -2857,123 +2857,89 @@ void ScFormulaCell::CompileColRowNameFormula()
 }
 }
 
-// we really want to be a lot more descriptive than this
-struct 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-28 Thread Kohei Yoshida
 sc/inc/cell.hxx  |2 
 sc/source/core/data/cell.cxx |   80 ---
 sc/source/core/data/documen4.cxx |   24 +--
 3 files changed, 12 insertions(+), 94 deletions(-)

New commits:
commit 620fdad868ab90cb6733bf83ab0ac5450d1ce3e8
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Mar 28 10:59:07 2013 -0400

ScBaseCell::CellEqual is no more.

Change-Id: I9a2923ec85ce116662d66a38b61a5258ff113168

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index b0919a6..166649d 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -100,8 +100,6 @@ public:
 boolHasStringData() const;
 rtl::OUString   GetStringData() const;  // only real strings
 
-static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* 
pCell2 );
-
 private:
 ScBaseCell operator=( const ScBaseCell );
 
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index cee5df3..66032a8 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -345,86 +345,6 @@ rtl::OUString ScBaseCell::GetStringData() const
 return aStr;
 }
 
-bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 
)
-{
-CellType eType1 = CELLTYPE_NONE;
-CellType eType2 = CELLTYPE_NONE;
-if ( pCell1 )
-{
-eType1 = pCell1-GetCellType();
-if (eType1 == CELLTYPE_EDIT)
-eType1 = CELLTYPE_STRING;
-else if (eType1 == CELLTYPE_NOTE)
-eType1 = CELLTYPE_NONE;
-}
-if ( pCell2 )
-{
-eType2 = pCell2-GetCellType();
-if (eType2 == CELLTYPE_EDIT)
-eType2 = CELLTYPE_STRING;
-else if (eType2 == CELLTYPE_NOTE)
-eType2 = CELLTYPE_NONE;
-}
-if ( eType1 != eType2 )
-return false;
-
-switch ( eType1 )   // Both Types are the same
-{
-case CELLTYPE_NONE: // Both Empty
-return true;
-case CELLTYPE_VALUE:// Really Value-Cells
-return ( ((const ScValueCell*)pCell1)-GetValue() ==
- ((const ScValueCell*)pCell2)-GetValue() );
-case CELLTYPE_STRING:   // String or Edit
-{
-rtl::OUString aText1;
-if ( pCell1-GetCellType() == CELLTYPE_STRING )
-aText1 = ((const ScStringCell*)pCell1)-GetString();
-else
-aText1 = ((const ScEditCell*)pCell1)-GetString();
-rtl::OUString aText2;
-if ( pCell2-GetCellType() == CELLTYPE_STRING )
-aText2 = ((const ScStringCell*)pCell2)-GetString();
-else
-aText2 = ((const ScEditCell*)pCell2)-GetString();
-return ( aText1 == aText2 );
-}
-case CELLTYPE_FORMULA:
-{
-//! pasted Lines / allow Slots!
-//! Comparsion Function of the Formula Cell???
-//! To request with ScColumn::SwapRow to catch together!
-
-ScTokenArray* pCode1 = ((ScFormulaCell*)pCell1)-GetCode();
-ScTokenArray* pCode2 = ((ScFormulaCell*)pCell2)-GetCode();
-
-if (pCode1-GetLen() == pCode2-GetLen())   // nicht-UPN
-{
-bool bEqual = true;
-sal_uInt16 nLen = pCode1-GetLen();
-FormulaToken** ppToken1 = pCode1-GetArray();
-FormulaToken** ppToken2 = pCode2-GetArray();
-for (sal_uInt16 i=0; inLen; i++)
-if ( !ppToken1[i]-TextEqual(*(ppToken2[i])) )
-{
-bEqual = false;
-break;
-}
-
-if (bEqual)
-return true;
-}
-
-return false;   // varying long or varying Tokens
-}
-default:
-OSL_FAIL(oops, something for the Cells???);
-}
-return false;
-}
-
-// 
-
 ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) :
 ScBaseCell( CELLTYPE_NOTE )
 {
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 3df2fbc..27fd9fa 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -790,18 +790,18 @@ sal_uInt16 ScDocument::RowDifferences( SCROW nThisRow, 
SCTAB nThisTab,
 
 if (ValidCol(nOtherCol))// nur Spalten vergleichen, die in beiden 
Dateien sind
 {
-const ScBaseCell* pThisCell = GetCell( ScAddress( nThisCol, 
nThisRow, nThisTab ) );
-const ScBaseCell* pOtherCell = rOtherDoc.GetCell( ScAddress( 
nOtherCol, nOtherRow, nOtherTab ) );
-if (!ScBaseCell::CellEqual( pThisCell, pOtherCell ))
+ScRefCellValue aThisCell, aOtherCell;
+ 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-28 Thread Kohei Yoshida
 sc/inc/cell.hxx  |1 
 sc/inc/column.hxx|1 
 sc/inc/document.hxx  |   25 +-
 sc/inc/table.hxx |1 
 sc/source/core/data/column3.cxx  |   13 +++
 sc/source/core/data/dociter.cxx  |4 -
 sc/source/core/data/document.cxx |   15 +++-
 sc/source/core/data/table2.cxx   |8 ++
 sc/source/core/inc/interpre.hxx  |2 
 sc/source/core/tool/interpr1.cxx |   13 +--
 sc/source/core/tool/interpr2.cxx |   25 +++---
 sc/source/core/tool/interpr4.cxx |  141 ---
 sc/source/core/tool/interpr5.cxx |  104 ++--
 13 files changed, 160 insertions(+), 193 deletions(-)

New commits:
commit 15596e85a98805c32db4c9e5bbc9eb509c773733
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Mar 28 12:37:56 2013 -0400

More on removing use of ScBaseCell in ScInterpreter.

Change-Id: I4468e04e009da3f2ca5a975f2b1a4aed207922b3

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 166649d..7395713 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -145,6 +145,7 @@ public:
 
 inline void SetValue( double fValue ) { mfValue = fValue; }
 inline double   GetValue() const { return mfValue; }
+double* GetValuePtr() { return mfValue; }
 
 private:
 double  mfValue;
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ba18278..b5d95a4 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -276,6 +276,7 @@ public:
 
 voidGetString( SCROW nRow, rtl::OUString rString ) const;
 const OUString* GetStringCell( SCROW nRow ) const;
+double* GetValueCell( SCROW nRow );
 voidGetInputString( SCROW nRow, rtl::OUString rString ) const;
 double  GetValue( SCROW nRow ) const;
 const EditTextObject* GetEditText( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 88fcd11..840c7d1 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -813,6 +813,17 @@ public:
  * it returns NULL even for a edit cell.
  */
 const OUString* GetStringCell( const ScAddress rPos ) const;
+
+/**
+ * Return a pointer to the double value stored in value cell.
+ *
+ * @param rPos cell position
+ *
+ * @return pointer to the double value stored in a numeric cell, or NULL
+ * if the cell at specified position is not a numeric cell.
+ */
+double* GetValueCell( const ScAddress rPos );
+
 SC_DLLPUBLIC void   GetInputString( SCCOL nCol, SCROW nRow, SCTAB 
nTab, String rString );
 SC_DLLPUBLIC void   GetInputString( SCCOL nCol, SCROW nRow, SCTAB 
nTab, rtl::OUString rString );
 sal_uInt16  GetStringForFormula( const ScAddress rPos, 
rtl::OUString rString );
@@ -827,12 +838,14 @@ public:
 sal_uInt32  GetNumberFormat( const ScRange rRange ) const;
 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScAddress ) const;
 void SetNumberFormat( const ScAddress rPos, sal_uInt32 nNumberFormat );
-/** If no number format attribute is set and the cell
-pointer passed is of type formula cell, the calculated
-number format of the formula cell is returned. pCell
-may be NULL. */
-SC_DLLPUBLIC void   GetNumberFormatInfo( short nType, sal_uLong 
nIndex,
-const ScAddress rPos, const ScBaseCell* pCell ) const;
+
+/**
+ * If no number format attribute is set and a formula cell pointer is
+ * passed, the calculated number format of the formula cell is returned.
+ * pCell may be NULL.
+ */
+SC_DLLPUBLIC void GetNumberFormatInfo( short nType, sal_uLong nIndex,
+const ScAddress rPos, const ScFormulaCell* pCell ) 
const;
 voidGetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String 
rFormula ) const;
 const ScTokenArray* GetFormulaTokens( const ScAddress rPos ) const;
 SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress rPos ) 
const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3ddcbfc..b5d692c 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -319,6 +319,7 @@ public:
 
 voidGetString( SCCOL nCol, SCROW nRow, rtl::OUString rString ) 
const;
 const OUString* GetStringCell( SCCOL nCol, SCROW nRow ) const;
+double* GetValueCell( SCCOL nCol, SCROW nRow );
 voidGetInputString( SCCOL nCol, SCROW nRow, rtl::OUString rString 
) const;
 double  GetValue( const ScAddress rPos ) const
 {
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 5316ee0..9bd0ee9 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1784,6 +1784,19 @@ const OUString* ScColumn::GetStringCell( SCROW nRow ) 
const
 return static_castconst ScStringCell*(pCell)-GetStringPtr();
 }
 
+double* ScColumn::GetValueCell( 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-28 Thread Kohei Yoshida
 sc/inc/document.hxx  |   10 +-
 sc/source/core/data/documen8.cxx |   30 +++---
 sc/source/core/data/document.cxx |  173 +--
 3 files changed, 99 insertions(+), 114 deletions(-)

New commits:
commit 6cdd0206413476fa6d278297d296786f934c1da2
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Mar 28 14:22:46 2013 -0400

Remove GetCell() from ScDocument, and make PutCell() private.

At this point, only ScTable and ScFormulaCell call PutCell().  Make them
friends of ScDocument (for now).

Change-Id: I7b8795580eafe7ea0ba5a4325f531efe53a2ea5b

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 840c7d1..d83f044 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -215,6 +215,8 @@ friend class ScAttrRectIterator;
 friend class ScDocShell;
 friend class ScDocRowHeightUpdater;
 friend class ScColumnTextWidthIterator;
+friend class ScFormulaCell;
+friend class ScTable;
 
 typedef ::std::vectorScTable* TableContainer;
 private:
@@ -743,9 +745,6 @@ public:
 
 SC_DLLPUBLIC void EnsureTable( SCTAB nTab );
 
-SC_DLLPUBLIC void   PutCell( const ScAddress, ScBaseCell* pCell, 
bool bForceTab = false );
-SC_DLLPUBLIC void   PutCell(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScBaseCell* pCell,
-sal_uLong nFormatIndex, bool bForceTab = false);
 //  return TRUE = number format is set
 SC_DLLPUBLIC bool   SetString(
 SCCOL nCol, SCROW nRow, SCTAB nTab, const rtl::OUString rString,
@@ -853,8 +852,6 @@ public:
 SC_DLLPUBLIC void   GetFormula( SCCOL nCol, SCROW nRow, SCTAB 
nTab, rtl::OUString rFormula ) const;
 SC_DLLPUBLIC void   GetCellType( SCCOL nCol, SCROW nRow, SCTAB 
nTab, CellType rCellType ) const;
 SC_DLLPUBLIC CellType   GetCellType( const ScAddress rPos ) const;
-SC_DLLPUBLIC void   GetCell( SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScBaseCell* rpCell ) const;
-SC_DLLPUBLIC ScBaseCell*GetCell( const ScAddress rPos ) const;
 
 SC_DLLPUBLIC bool   HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
 SC_DLLPUBLIC bool   HasStringData( SCCOL nCol, SCROW nRow, SCTAB 
nTab ) const;
@@ -1976,6 +1973,9 @@ private: // CLOOK-Impl-methods
 
 boolHasPartOfMerged( const ScRange rRange );
 
+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 );
+
 std::map SCTAB, ScSortParam  mSheetSortParams;
 
 };
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 3dda38c1..5fe23dc 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -96,6 +96,7 @@
 #define VSPL_START  0
 #define VSPL_DONE   1
 
+using namespace com::sun::star;
 
 // STATIC DATA ---
 
@@ -1613,14 +1614,15 @@ void ScDocument::TransliterateText( const ScMarkData 
rMultiMark, sal_Int32 nTyp
 
 while (bFound)
 {
-const ScBaseCell* pCell = GetCell( ScAddress( nCol, nRow, nTab 
) );
-CellType eType = pCell ? pCell-GetCellType() : CELLTYPE_NONE;
+ScRefCellValue aCell;
+aCell.assign(*this, ScAddress(nCol, nRow, nTab));
+
 // fdo#32786 TITLE_CASE/SENTENCE_CASE need the extra handling 
in EditEngine (loop over words/sentences).
 // Still use TransliterationWrapper directly for text cells 
with other transliteration types,
 // for performance reasons.
-if ( eType == CELLTYPE_EDIT ||
- ( eType == CELLTYPE_STRING  ( nType == 
com::sun::star::i18n::TransliterationModulesExtra::SENTENCE_CASE ||
- nType == 
com::sun::star::i18n::TransliterationModulesExtra::TITLE_CASE ) ) )
+if (aCell.meType == CELLTYPE_EDIT ||
+(aCell.meType == CELLTYPE_STRING 
+ ( nType == 
i18n::TransliterationModulesExtra::SENTENCE_CASE || nType == 
i18n::TransliterationModulesExtra::TITLE_CASE)))
 {
 if (!pEngine)
 pEngine = new ScFieldEditEngine(this, GetEnginePool(), 
GetEditPool());
@@ -1631,13 +1633,11 @@ void ScDocument::TransliterateText( const ScMarkData 
rMultiMark, sal_Int32 nTyp
 pPattern-FillEditItemSet( pDefaults );
 pEngine-SetDefaults( pDefaults, true );
 
-if ( eType == CELLTYPE_STRING )
-pEngine-SetText( static_castconst 
ScStringCell*(pCell)-GetString() );
-else
-{
-const EditTextObject* pData = static_castconst 
ScEditCell*(pCell)-GetData();
-pEngine-SetText( 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-28 Thread Kohei Yoshida
 sc/inc/cell.hxx|   19 ---
 sc/inc/formulacell.hxx |   11 +--
 sc/source/core/data/cellvalue.cxx  |1 +
 sc/source/core/data/column.cxx |1 +
 sc/source/core/data/column2.cxx|1 +
 sc/source/core/data/column3.cxx|1 +
 sc/source/core/data/conditio.cxx   |1 +
 sc/source/core/data/documen4.cxx   |1 +
 sc/source/core/data/documen7.cxx   |2 ++
 sc/source/core/data/formulacell.cxx|6 ++
 sc/source/core/data/formulaiter.cxx|1 +
 sc/source/core/data/table2.cxx |   19 ++-
 sc/source/core/data/table3.cxx |1 +
 sc/source/core/data/validat.cxx|1 +
 sc/source/core/tool/chgtrack.cxx   |1 +
 sc/source/core/tool/compiler.cxx   |1 +
 sc/source/core/tool/consoli.cxx|1 +
 sc/source/core/tool/interpr1.cxx   |   24 +---
 sc/source/core/tool/interpr2.cxx   |4 +++-
 sc/source/core/tool/interpr4.cxx   |4 +++-
 sc/source/filter/excel/xelink.cxx  |1 +
 sc/source/filter/excel/xestream.cxx|1 +
 sc/source/filter/excel/xetable.cxx |1 +
 sc/source/filter/oox/formulabuffer.cxx |1 +
 sc/source/filter/xml/xmlcelli.cxx  |1 +
 sc/source/ui/app/inputhdl.cxx  |5 ++---
 sc/source/ui/docshell/docfunc.cxx  |1 +
 sc/source/ui/docshell/impex.cxx|1 +
 sc/source/ui/docshell/tablink.cxx  |3 +--
 sc/source/ui/inc/inputhdl.hxx  |4 ++--
 sc/source/ui/miscdlgs/anyrefdg.cxx |2 +-
 sc/source/ui/unoobj/cellsuno.cxx   |1 +
 sc/source/ui/unoobj/chart2uno.cxx  |1 +
 sc/source/ui/unoobj/funcuno.cxx|1 +
 sc/source/ui/view/tabvwsha.cxx |1 +
 sc/source/ui/view/viewfun2.cxx |1 +
 sc/source/ui/view/viewfunc.cxx |2 ++
 37 files changed, 82 insertions(+), 47 deletions(-)

New commits:
commit 2cfc8edab4291a389121582281999076c56d1462
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Mar 28 15:52:57 2013 -0400

Remove some headers in cell.hxx.

Change-Id: Ic99967a3ef6a35ca4fc465054e0d4de512cafb43

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 217cfab..60a70f5 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -20,23 +20,12 @@
 #ifndef SC_CELL_HXX
 #define SC_CELL_HXX
 
-#include stddef.h
+#include scdllapi.h
+#include global.hxx
 
-#include set
-#include vector
-#include boost/shared_ptr.hpp
-#include boost/intrusive_ptr.hpp
+#include tools/mempool.hxx
 
-#include tools/mempool.hxx
-#include svl/listener.hxx
-#include global.hxx
-#include rangenam.hxx
-#include formula/grammar.hxx
-#include tokenarray.hxx
-#include formularesult.hxx
-#include rtl/ustrbuf.hxx
-#include unotools/fontcvt.hxx
-#include scdllapi.h
+#include boost/shared_ptr.hpp
 
 #define USE_MEMPOOL
 
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 8bdcbc0..45a708d 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -21,7 +21,14 @@
 #define SC_FORMULACELL_HXX
 
 #include cell.hxx
+#include formularesult.hxx
 
+#include formula/tokenarray.hxx
+#include svl/listener.hxx
+
+#include set
+
+class ScTokenArray;
 struct ScSimilarFormulaDelta;
 
 struct SC_DLLPUBLIC ScFormulaCellGroup
@@ -276,9 +283,9 @@ public:
 voidSetResultDouble( double n ) { aResult.SetDouble( n); }
 
 voidSetErrCode( sal_uInt16 n );
-inline bool IsHyperLinkCell() const { return pCode  
pCode-IsHyperLink(); }
+bool IsHyperLinkCell() const;
 EditTextObject* CreateURLObject();
-voidGetURLResult( rtl::OUString rURL, rtl::OUString 
rCellText );
+void GetURLResult( OUString rURL, OUString rCellText );
 
 /** Determines whether or not the result string contains more than one 
paragraph */
 boolIsMultilineResult();
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index c287f10..c3a333c 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -15,6 +15,7 @@
 #include editeng/editstat.hxx
 #include stringutil.hxx
 #include editutil.hxx
+#include tokenarray.hxx
 #include formula/token.hxx
 
 namespace {
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index c046192..5b18f3c 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -32,6 +32,7 @@
 #include postit.hxx
 #include globalnames.hxx
 #include cellvalue.hxx
+#include tokenarray.hxx
 
 #include svl/poolcach.hxx
 #include svl/zforlist.hxx
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 2e878e2..afd0cff 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -55,6 +55,7 @@
 #include segmenttree.hxx
 #include docparam.hxx
 #include cellvalue.hxx
+#include tokenarray.hxx
 
 #include math.h
 
diff --git a/sc/source/core/data/column3.cxx 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-28 Thread Kohei Yoshida
 sc/inc/cell.hxx  |2 --
 sc/source/core/data/cell.cxx |   12 
 sc/source/core/data/column.cxx   |2 +-
 sc/source/core/data/table3.cxx   |9 +
 sc/source/core/tool/interpr4.cxx |2 +-
 5 files changed, 7 insertions(+), 20 deletions(-)

New commits:
commit f4bb958afc095a2618da6a1653c82d465cb98896
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Mar 28 16:09:02 2013 -0400

Remove GetErrorCode() from ScBaseCell; only relevant for ScFormulaCell.

Change-Id: I5c41fc88bf138411ded334f823ab6187401c96df

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 60a70f5..a42b0722 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -80,8 +80,6 @@ public:
 /** Deletes the own cell broadcaster. */
 voidDeleteBroadcaster();
 
-/** Error code if ScFormulaCell, else 0. */
-sal_uInt16  GetErrorCode() const;
 /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may 
have been
 created due to reference to empty cell). */
 boolHasEmptyData() const;
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index aa6e2a2..3862e88 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -141,18 +141,6 @@ void ScBaseCell::DeleteBroadcaster()
 DELETEZ( mpBroadcaster );
 }
 
-sal_uInt16 ScBaseCell::GetErrorCode() const
-{
-switch ( eCellType )
-{
-case CELLTYPE_FORMULA :
-return ((ScFormulaCell*)this)-GetErrCode();
-default:
-return 0;
-}
-}
-
-
 bool ScBaseCell::HasEmptyData() const
 {
 switch ( eCellType )
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5b18f3c..0aa3b17 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1391,7 +1391,7 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW 
nRow2, ScColumn rDestCol
 if (rCell.GetDirty()  pDocument-GetAutoCalc())
 rCell.Interpret();
 
-if (rCell.GetErrorCode())
+if (rCell.GetErrCode())
 // Skip cells with error.
 break;
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 13bbec7..0a1e4b0 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1229,14 +1229,15 @@ public:
 }
 
 bool isQueryByValue(
-const ScQueryEntry::Item rItem, SCCOL nCol, SCROW nRow, const 
ScBaseCell* pCell)
+const ScQueryEntry::Item rItem, SCCOL nCol, SCROW nRow, ScBaseCell* 
pCell)
 {
 if (rItem.meType == ScQueryEntry::ByString)
 return false;
 
 if (pCell)
 {
-if (pCell-GetErrorCode())
+if (pCell-GetCellType() == CELLTYPE_FORMULA 
+static_castScFormulaCell*(pCell)-GetErrCode())
 // Error values are compared as string.
 return false;
 
@@ -1361,10 +1362,10 @@ public:
 
 if ( pCell )
 {
-if (pCell-GetCellType() == CELLTYPE_FORMULA  
pCell-GetErrorCode())
+if (pCell-GetCellType() == CELLTYPE_FORMULA  
static_castScFormulaCell*(pCell)-GetErrCode())
 {
 // Error cell is evaluated as string (for now).
-aCellStr = ScGlobal::GetErrorString(pCell-GetErrorCode());
+aCellStr = 
ScGlobal::GetErrorString(static_castScFormulaCell*(pCell)-GetErrCode());
 }
 else if (pCell-GetCellType() != CELLTYPE_NOTE)
 {
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 6247e51..e24fc66 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -192,7 +192,7 @@ double ScInterpreter::GetValueCellValue( const ScAddress 
rPos, double fOrig )
 
 sal_uInt16 ScInterpreter::GetCellErrCode( const ScRefCellValue rCell )
 {
-return rCell.meType == CELLTYPE_FORMULA ? rCell.mpFormula-GetErrorCode() 
: 0;
+return rCell.meType == CELLTYPE_FORMULA ? rCell.mpFormula-GetErrCode() : 
0;
 }
 
 /** Convert string content to numeric value.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-27 Thread Kohei Yoshida
 sc/inc/column.hxx|1 +
 sc/inc/document.hxx  |1 +
 sc/inc/table.hxx |1 +
 sc/source/core/data/column3.cxx  |   14 ++
 sc/source/core/data/document.cxx |   12 ++--
 sc/source/core/data/table2.cxx   |8 
 sc/source/ui/view/viewfunc.cxx   |   14 ++
 7 files changed, 41 insertions(+), 10 deletions(-)

New commits:
commit 0133017bb6f8b04cda9b79b9d89007319c1e9c20
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Mar 27 12:44:33 2013 -0400

Make viewfunc.cxx free of ScBaseCell.

Change-Id: I15a2682d2739a1c7be0d52b98c45b8d5a82c1686

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index dc81438..ba18278 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -279,6 +279,7 @@ public:
 voidGetInputString( SCROW nRow, rtl::OUString rString ) const;
 double  GetValue( SCROW nRow ) const;
 const EditTextObject* GetEditText( SCROW nRow ) const;
+void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr rAttr );
 voidGetFormula( SCROW nRow, rtl::OUString rFormula ) const;
 const ScTokenArray* GetFormulaTokens( SCROW nRow ) const;
 const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9953006..a245da8 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -820,6 +820,7 @@ public:
 SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const { 
ScAddress aAdr(nCol, nRow, nTab); return GetValue(aAdr);}
 SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double 
rValue ) const;
 SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress rPos ) 
const;
+void RemoveEditTextCharAttribs( const ScAddress rPos, const 
ScPatternAttr rAttr );
 SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat ) 
const;
 SC_DLLPUBLIC void   GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
  sal_uInt32 rFormat ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 0a12ead..3ddcbfc 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -328,6 +328,7 @@ public:
 }
 double  GetValue( SCCOL nCol, SCROW nRow ) const;
 const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
+void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const 
ScPatternAttr rAttr );
 void GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString rFormula ) const;
 const ScTokenArray* GetFormulaTokens( SCCOL nCol, SCROW nRow ) const;
 const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index aa04f39..fb5e261 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1835,6 +1835,20 @@ const EditTextObject* ScColumn::GetEditText( SCROW nRow 
) const
 return pEditCell-GetData();
 }
 
+void ScColumn::RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr 
rAttr )
+{
+SCSIZE nIndex;
+if (!Search(nRow, nIndex))
+return;
+
+ScBaseCell* pCell = maItems[nIndex].pCell;
+if (pCell-GetCellType() != CELLTYPE_EDIT)
+return;
+
+ScEditCell* pEditCell = static_castScEditCell*(pCell);
+pEditCell-RemoveCharAttribs(rAttr);
+}
+
 void ScColumn::GetFormula( SCROW nRow, rtl::OUString rFormula ) const
 {
 SCSIZE  nIndex;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1603d23..93ddc9f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3132,7 +3132,7 @@ sal_uInt16 ScDocument::GetStringForFormula( const 
ScAddress rPos, OUString rSt
 
 void ScDocument::GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double rValue 
) const
 {
-if ( ValidTab(nTab)  nTab  static_castSCTAB(maTabs.size())  
maTabs[nTab] )
+if (TableExists(nTab))
 rValue = maTabs[nTab]-GetValue( nCol, nRow );
 else
 rValue = 0.0;
@@ -3141,12 +3141,20 @@ void ScDocument::GetValue( SCCOL nCol, SCROW nRow, 
SCTAB nTab, double rValue )
 const EditTextObject* ScDocument::GetEditText( const ScAddress rPos ) const
 {
 SCTAB nTab = rPos.Tab();
-if (!ValidTab(nTab) || nTab = static_castSCTAB(maTabs.size()) || 
!maTabs[nTab])
+if (!TableExists(nTab))
 return NULL;
 
 return maTabs[nTab]-GetEditText(rPos.Col(), rPos.Row());
 }
 
+void ScDocument::RemoveEditTextCharAttribs( const ScAddress rPos, const 
ScPatternAttr rAttr )
+{
+if (!TableExists(rPos.Tab()))
+return;
+
+return maTabs[rPos.Tab()]-RemoveEditTextCharAttribs(rPos.Col(), 
rPos.Row(), rAttr);
+}
+
 double ScDocument::GetValue( const ScAddress rPos ) const
 {
 SCTAB nTab = rPos.Tab();
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 319226f..253032b 100644
--- a/sc/source/core/data/table2.cxx
+++ 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-27 Thread Kohei Yoshida
 sc/inc/cell.hxx  |2 -
 sc/inc/dociter.hxx   |2 -
 sc/inc/document.hxx  |1 
 sc/inc/editutil.hxx  |3 ++
 sc/source/core/data/cell.cxx |   12 -
 sc/source/core/data/document.cxx |9 ++-
 sc/source/core/tool/editutil.cxx |   10 +++
 sc/source/ui/docshell/docsh8.cxx |   50 +--
 sc/source/ui/view/gridwin.cxx|   47 +---
 9 files changed, 75 insertions(+), 61 deletions(-)

New commits:
commit c2a63024f4c5d105e9678163cbb2ad6c7806afb0
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Mar 27 15:53:09 2013 -0400

More on killing direct use of ScEditCell.

Change-Id: If6e3529666ff064107d3c5687b6993822572c0d9

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 0b78f98..c3443d2 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -105,8 +105,6 @@ public:
 boolHasValueData() const;
 boolHasStringData() const;
 rtl::OUString   GetStringData() const;  // only real strings
-// default implementation, creates url object from passed url
-static EditTextObject* CreateURLObjectFromURL( ScDocument rDoc, const 
OUString rURL, const OUString rText );
 
 static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* 
pCell2 );
 
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 4477ba3..5e9b16d 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -425,7 +425,7 @@ private:
 SCTAB   nTab;
 SCCOL   nStartCol;
 SCCOL   nEndCol;
-   SCROW   nStartRow;
+SCROW   nStartRow;
 SCROW   nEndRow;
 SCROW*  pNextRows;
 SCSIZE* pNextIndices;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a245da8..ec944f6 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1227,6 +1227,7 @@ public:
 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, 
SCTAB nTab, sal_uInt16 nWhich ) const;
 SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress rPos, sal_uInt16 
nWhich ) const;
 SC_DLLPUBLIC const ScPatternAttr*   GetPattern( SCCOL nCol, SCROW nRow, 
SCTAB nTab ) const;
+SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress rPos ) 
const;
 SC_DLLPUBLIC const ScPatternAttr*GetMostUsedPattern( SCCOL nCol, SCROW 
nStartRow, SCROW nEndRow, SCTAB nTab ) const;
 const ScPatternAttr*GetSelectionPattern( const ScMarkData rMark, bool 
bDeep = true );
 ScPatternAttr*  CreateSelectionPattern( const ScMarkData rMark, 
bool bDeep = true );
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index ac8fc23..5f979cb 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -61,6 +61,9 @@ public:
 
 SC_DLLPUBLIC static OUString GetString( const EditTextObject rEditText );
 
+static EditTextObject* CreateURLObjectFromURL(
+ScDocument rDoc, const OUString rURL, const OUString rText );
+
 public:
 ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB 
nZ,
 const Point rScrPosPixel,
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index c34e55c..03fbe68 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -600,16 +600,6 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, 
const ScBaseCell* pCell2 )
 return false;
 }
 
-EditTextObject* ScBaseCell::CreateURLObjectFromURL( ScDocument rDoc, const 
OUString rURL, const OUString rText )
-{
-SvxURLField aUrlField( rURL, rText, SVXURLFORMAT_APPDEFAULT);
-EditEngine rEE = rDoc.GetEditEngine();
-rEE.SetText( EMPTY_STRING );
-rEE.QuickInsertField( SvxFieldItem( aUrlField, EE_FEATURE_FIELD ), 
ESelection( 0x, 0x ) );
-
-return rEE.CreateTextObject();
-}
-
 // 
 
 ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) :
@@ -1978,7 +1968,7 @@ EditTextObject* ScFormulaCell::CreateURLObject()
 rtl::OUString aURL;
 GetURLResult( aURL, aCellText );
 
-return CreateURLObjectFromURL( *pDocument, aURL, aCellText );
+return ScEditUtil::CreateURLObjectFromURL( *pDocument, aURL, aCellText );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 93ddc9f..97e66a7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4309,11 +4309,18 @@ const SfxPoolItem* ScDocument::GetAttr( const 
ScAddress rPos, sal_uInt16 nWhich
 
 const ScPatternAttr* ScDocument::GetPattern( SCCOL nCol, SCROW nRow, SCTAB 
nTab ) const
 {
-if ( ValidTab(nTab)  nTab  static_castSCTAB(maTabs.size())  
maTabs[nTab] )
+if (TableExists(nTab))
 return maTabs[nTab]-GetPattern( nCol, nRow );
 return NULL;
 }
 
+const ScPatternAttr* ScDocument::GetPattern( const 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-27 Thread Kohei Yoshida
 sc/inc/dociter.hxx   |5 +++--
 sc/source/core/data/dociter.cxx  |   23 ---
 sc/source/core/data/documen8.cxx |   19 ---
 sc/source/ui/docshell/docsh.cxx  |   24 ++--
 sc/source/ui/docshell/docsh8.cxx |   12 
 5 files changed, 37 insertions(+), 46 deletions(-)

New commits:
commit 99b00e76eef76246e6c3474b98b5b87eb8df
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Mar 27 16:43:51 2013 -0400

More on killing direct use of ScEditCell (and some of ScBaseCell).

Change-Id: I65d530333213f8b3db38a269e74a0beabcd1ff89

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 5e9b16d..c38f200 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -431,6 +431,7 @@ private:
 SCSIZE* pNextIndices;
 SCCOL   nCol;
 SCROW   nRow;
+ScRefCellValue  maCurCell;
 boolbMore;
 
 public:
@@ -438,7 +439,7 @@ public:
 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2);
 ~ScHorizontalCellIterator();
 
-ScBaseCell* GetNext( SCCOL rCol, SCROW rRow );
+ScRefCellValue* GetNext( SCCOL rCol, SCROW rRow );
 boolReturnNext( SCCOL rCol, SCROW rRow );
 /// Set a(nother) sheet and (re)init.
 voidSetTab( SCTAB nTab );
@@ -524,7 +525,7 @@ private:
 
 SCCOL   nCellCol;
 SCROW   nCellRow;
-ScBaseCell* pCell;
+ScRefCellValue* pCell;
 SCCOL   nAttrCol1;
 SCCOL   nAttrCol2;
 SCROW   nAttrRow;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index f64837e..c318e04 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1797,7 +1797,7 @@ void ScHorizontalCellIterator::SetTab( SCTAB nTabP )
 Advance();
 }
 
-ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL rCol, SCROW rRow )
+ScRefCellValue* ScHorizontalCellIterator::GetNext( SCCOL rCol, SCROW rRow )
 {
 if ( bMore )
 {
@@ -1820,7 +1820,8 @@ ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL 
rCol, SCROW rRow )
 }
 
 Advance();
-return pCell;
+maCurCell.assign(*pCell);
+return maCurCell;
 }
 else
 return NULL;
@@ -1917,7 +1918,7 @@ bool ScHorizontalValueIterator::GetNext( double rValue, 
sal_uInt16 rErr )
 bool bFound = false;
 while ( !bFound )
 {
-ScBaseCell* pCell = pCellIter-GetNext( nCurCol, nCurRow );
+ScRefCellValue* pCell = pCellIter-GetNext( nCurCol, nCurRow );
 while ( !pCell )
 {
 if ( nCurTab  nEndTab )
@@ -1930,12 +1931,12 @@ bool ScHorizontalValueIterator::GetNext( double 
rValue, sal_uInt16 rErr )
 }
 if ( !bSubTotal || !pDoc-maTabs[nCurTab]-RowFiltered( nCurRow ) )
 {
-switch (pCell-GetCellType())
+switch (pCell-meType)
 {
 case CELLTYPE_VALUE:
 {
 bNumValid = false;
-rValue = ((ScValueCell*)pCell)-GetValue();
+rValue = pCell-mfValue;
 rErr = 0;
 if ( bCalcAsShown )
 {
@@ -1949,12 +1950,12 @@ bool ScHorizontalValueIterator::GetNext( double 
rValue, sal_uInt16 rErr )
 break;
 case CELLTYPE_FORMULA:
 {
-if (!bSubTotal || 
!((ScFormulaCell*)pCell)-IsSubTotal())
+if (!bSubTotal || !pCell-mpFormula-IsSubTotal())
 {
-rErr = ((ScFormulaCell*)pCell)-GetErrCode();
-if ( rErr || ((ScFormulaCell*)pCell)-IsValue() )
+rErr = pCell-mpFormula-GetErrCode();
+if (rErr || pCell-mpFormula-IsValue())
 {
-rValue = ((ScFormulaCell*)pCell)-GetValue();
+rValue = pCell-mpFormula-GetValue();
 bNumValid = false;
 bFound = true;
 }
@@ -2161,7 +2162,7 @@ bool ScUsedAreaIterator::GetNext()
 if ( pCell  IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) )
 pCell = aCellIter.GetNext( nCellCol, nCellRow );
 
-while ( pCell  pCell-IsBlank() )
+while (pCell  pCell-isEmpty())
 pCell = aCellIter.GetNext( nCellCol, nCellRow );
 
 if ( pPattern  IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) )
@@ -2215,7 +2216,7 @@ bool ScUsedAreaIterator::GetNext()
 if ( bUseCell ) // Cell position
 {
 if (pCell)
-maFoundCell.assign(*pCell);
+maFoundCell = *pCell;
 else
 maFoundCell.clear();
 
diff 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-27 Thread Kohei Yoshida
 sc/inc/cellsuno.hxx  |6 -
 sc/source/ui/unoobj/cellsuno.cxx |  212 ---
 2 files changed, 114 insertions(+), 104 deletions(-)

New commits:
commit 5fdb21a65dede00fc56e4bfd2e75a9f2c427ca2c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Mar 27 18:07:33 2013 -0400

More of the same.

Change-Id: Id9a5968376f955b325d18067688f59116663740f

diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index 3585c89..687105c 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -828,8 +828,8 @@ private:
 sal_Int16   nActionLockCount;
 
 private:
-String  GetInputString_Impl(sal_Bool bEnglish) const;
-String  GetOutputString_Impl() const;
+OUStringGetInputString_Impl(bool bEnglish) const;
+OUStringGetOutputString_Impl() const;
 voidSetString_Impl(const String rString, sal_Bool bInterpret, 
sal_Bool bEnglish);
 double  GetValue_Impl() const;
 voidSetValue_Impl(double fValue);
@@ -980,7 +980,7 @@ public:
 throw(::com::sun::star::uno::RuntimeException);
 virtual sal_Int16 SAL_CALL resetActionLocks() 
throw(::com::sun::star::uno::RuntimeException);
 
-static String   GetOutputString_Impl(ScDocument* pDoc, const 
ScAddress aPos);
+static OUString GetOutputString_Impl(ScDocument* pDoc, const ScAddress 
aPos);
 };
 
 
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index e74f249..1b9a2e5 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2348,43 +2348,45 @@ void ScCellRangesBase::SetOnePropertyValue( const 
SfxItemPropertySimpleEntry* pE
 switch ( pEntry-nWID )
 {
 case EE_CHAR_ESCAPEMENT:// Specifically for xlsx import
+{
+sal_Int32 nValue = 0;
+aValue = nValue;
+if (nValue)
 {
-sal_Int32 nValue(0);
-aValue = nValue;
-if( nValue )
+for (size_t i = 0, n = aRanges.size(); i  n; ++i)
 {
-size_t n = aRanges.size();
-for( size_t i = 0; i  n; i++ )
-{
-ScRange aRange( *aRanges[ i ] );
-/* TODO: Iterate through the range */
-ScAddress  aAddr = aRange.aStart;
-ScDocument *pDoc = pDocShell-GetDocument();
-ScBaseCell *pCell = pDoc-GetCell( aAddr );
-String aStr( pCell-GetStringData() );
-EditEngine aEngine( pDoc-GetEnginePool() );
-
aEngine.SetEditTextObjectPool(pDoc-GetEditPool());
-
-/* EE_CHAR_ESCAPEMENT seems to be set on the 
cell _only_ when
- * there are no other attribs for the cell.
- * So, it is safe to overwrite the complete 
attribute set.
- * If there is a need - getting CellType and 
processing
- * the attributes could be considered.
- */
-SfxItemSet aAttr = aEngine.GetEmptyItemSet();
-aEngine.SetText( aStr );
-if( nValue  0 )// Subscript
-aAttr.Put( SvxEscapementItem( 
SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
-else// Superscript
-aAttr.Put( SvxEscapementItem( 
SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
-aEngine.QuickSetAttribs( aAttr, ESelection( 0, 
0, 0, aStr.Len()));
-
-// The cell will own the text object instance.
-pDoc-SetEditText(aRanges[0]-aStart, 
aEngine.CreateTextObject());
-}
+ScRange aRange = *aRanges[i];
+
+/* TODO: Iterate through the range */
+ScAddress aAddr = aRange.aStart;
+ScDocument *pDoc = pDocShell-GetDocument();
+ScRefCellValue aCell;
+aCell.assign(*pDoc, aAddr);
+
+OUString aStr = aCell.getString();
+EditEngine aEngine( pDoc-GetEnginePool() );
+aEngine.SetEditTextObjectPool(pDoc-GetEditPool());
+
+/* EE_CHAR_ESCAPEMENT seems to be set on the cell 
_only_ when
+ * there are no other 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-27 Thread Kohei Yoshida
 sc/inc/editutil.hxx  |2 ++
 sc/source/core/data/attarray.cxx |   34 --
 sc/source/core/data/cell2.cxx|   19 +--
 sc/source/core/tool/editutil.cxx |   22 ++
 4 files changed, 45 insertions(+), 32 deletions(-)

New commits:
commit 9eac784a55158f6e51818d93fe94ae2bd4fef24e
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Mar 27 20:35:34 2013 -0400

attrarray.cxx is now free of ScBaseCell.

Change-Id: I9a323062fc341ef5fc20f2922503a88f3a45ce0d

diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 5f979cb..f18c094 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -64,6 +64,8 @@ public:
 static EditTextObject* CreateURLObjectFromURL(
 ScDocument rDoc, const OUString rURL, const OUString rText );
 
+static void RemoveCharAttribs( EditTextObject rEditText, const 
ScPatternAttr rAttr );
+
 public:
 ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB 
nZ,
 const Point rScrPosPixel,
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 9d1996a..29522130 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include attarray.hxx
 #include scitems.hxx
 #include svx/algitem.hxx
 #include editeng/boxitem.hxx
@@ -29,7 +30,6 @@
 #include editeng/fontitem.hxx
 #include unotools/fontcvt.hxx
 
-#include attarray.hxx
 #include global.hxx
 #include document.hxx
 #include docpool.hxx
@@ -41,6 +41,8 @@
 #include globstr.hrc
 #include segmenttree.hxx
 #include cell.hxx
+#include cellvalue.hxx
+#include editutil.hxx
 #include rtl/strbuf.hxx
 
 // STATIC DATA ---
@@ -352,20 +354,24 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, 
SCROW nEndRow,
 {
 for (SCROW nRow = nStartRow; nRow = nEndRow; ++nRow)
 {
-ScBaseCell* pCell;
-pDocument-GetCell(nCol, nRow, nTab, pCell);
-if (pCell  pCell-GetCellType() == CELLTYPE_EDIT)
+ScAddress aPos(nCol, nRow, nTab);
+ScRefCellValue aCell;
+aCell.assign(*pDocument, aPos);
+if (aCell.meType != CELLTYPE_EDIT || !aCell.mpEditText)
+continue;
+
+EditTextObject* pOldData = NULL;
+if (pDataArray)
+pOldData = aCell.mpEditText-Clone();
+
+// Direct modification of cell content - something to watch out for if
+// we decide to share edit text instances in the future.
+
ScEditUtil::RemoveCharAttribs(const_castEditTextObject(*aCell.mpEditText), 
*pPattern);
+
+if (pDataArray)
 {
-EditTextObject* pOldData = NULL;
-ScEditCell* pEditCell = static_castScEditCell*(pCell);
-if (pDataArray)
-pOldData = pEditCell-GetData()-Clone();
-pEditCell-RemoveCharAttribs(*pPattern);
-if (pDataArray)
-{
-EditTextObject* pNewData = pEditCell-GetData()-Clone();
-pDataArray-AddItem(nTab, nCol, nRow, pOldData, pNewData);
-}
+EditTextObject* pNewData = aCell.mpEditText-Clone();
+pDataArray-AddItem(nTab, nCol, nRow, pOldData, pNewData);
 }
 }
 }
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index cacd5e1..297f8d0 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -146,24 +146,7 @@ const EditTextObject* ScEditCell::GetData() const
 
 void ScEditCell::RemoveCharAttribs( const ScPatternAttr rAttr )
 {
-const struct {
-sal_uInt16 nAttrType;
-sal_uInt16 nCharType;
-} AttrTypeMap[] = {
-{ ATTR_FONT,EE_CHAR_FONTINFO },
-{ ATTR_FONT_HEIGHT, EE_CHAR_FONTHEIGHT },
-{ ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT },
-{ ATTR_FONT_COLOR,  EE_CHAR_COLOR }
-};
-sal_uInt16 nMapCount = sizeof (AttrTypeMap) / sizeof (AttrTypeMap[0]);
-
-const SfxItemSet rSet = rAttr.GetItemSet();
-const SfxPoolItem* pItem;
-for (sal_uInt16 i = 0; i  nMapCount; ++i)
-{
-if ( rSet.GetItemState(AttrTypeMap[i].nAttrType, false, pItem) == 
SFX_ITEM_SET )
-mpData-RemoveCharAttribs(AttrTypeMap[i].nCharType);
-}
+ScEditUtil::RemoveCharAttribs(*mpData, rAttr);
 }
 
 void ScEditCell::UpdateFields(SCTAB nTab)
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 53f36ad..4e1955c 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -114,6 +114,28 @@ EditTextObject* ScEditUtil::CreateURLObjectFromURL( 
ScDocument rDoc, const OUSt
 return rEE.CreateTextObject();
 }
 
+void ScEditUtil::RemoveCharAttribs( EditTextObject rEditText, const 
ScPatternAttr rAttr )
+{
+const struct {
+sal_uInt16 nAttrType;
+sal_uInt16 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/dociter.hxx  |1 -
 sc/source/core/data/dociter.cxx |7 ---
 2 files changed, 8 deletions(-)

New commits:
commit e90d9b09e31565ec6b1488009b7075945b78ab22
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 10:42:06 2013 -0400

This method no longer used. Good. Remove it.

Change-Id: I397dedd6c7388b350af0f93151fdf0160698acc7

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index d24c6ab..eb34633 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -76,7 +76,6 @@ public:
 boolGetFirst();
 boolGetNext();
 
-ScBaseCell* GetCell();
 ScCellValue GetCellValue() const;
 const ScPatternAttr*GetPattern();
 voidGetPos( SCCOL rCol, SCROW rRow, SCTAB rTab );
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 24fd2b3..9f7dd02 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -197,13 +197,6 @@ bool ScDocumentIterator::GetNext()
 return GetThis();
 }
 
-//
-
-ScBaseCell* ScDocumentIterator::GetCell()
-{
-return pCell;
-}
-
 ScCellValue ScDocumentIterator::GetCellValue() const
 {
 ScCellValue aRet;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/cell.hxx   |1 
 sc/inc/cellvalue.hxx  |   56 ++
 sc/inc/column.hxx |1 
 sc/inc/document.hxx   |   11 +
 sc/inc/table.hxx  |1 
 sc/source/core/data/cellvalue.cxx |  309 --
 sc/source/core/data/column3.cxx   |   12 +
 sc/source/core/data/document.cxx  |8 
 sc/source/core/data/table2.cxx|7 
 9 files changed, 326 insertions(+), 80 deletions(-)

New commits:
commit 0aa3d9c489effcc9ab01946ab9cea846bbab1c39
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 12:00:43 2013 -0400

Add ScRefCellValue, which is ScCellValue without copied value.

It directly points to the original cell value instance.

Change-Id: I638ec8b931873d237871b6d8fa9f0e1277520d0f

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 236ad43..0b78f98 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -175,6 +175,7 @@ public:
 
 inline void SetString( const rtl::OUString rString ) { maString = 
rString; }
 inline constrtl::OUString GetString() const { return maString; }
+const OUString* GetStringPtr() const { return maString; }
 
 private:
 rtl::OUString   maString;
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 9dd3a9a..7998898 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -19,7 +19,8 @@ class ScBaseCell;
 
 /**
  * Store arbitrary cell value of any kind.  It only stores cell value and
- * nothing else.
+ * nothing else.  It creates a copy of the original cell value, and manages
+ * the life cycle of the copied value.
  */
 struct SC_DLLPUBLIC ScCellValue
 {
@@ -78,6 +79,59 @@ struct SC_DLLPUBLIC ScCellValue
 void swap( ScCellValue r );
 };
 
+/**
+ * This is very similar to ScCellValue, except that it points to the
+ * original value instead of copying it.  As such, don't hold an instance of
+ * this class any longer than necessary.
+ */
+struct SC_DLLPUBLIC ScRefCellValue
+{
+CellType meType;
+union {
+double mfValue;
+const OUString* mpString;
+const EditTextObject* mpEditText;
+ScFormulaCell* mpFormula;
+};
+
+ScRefCellValue();
+ScRefCellValue( double fValue );
+ScRefCellValue( const OUString* pString );
+ScRefCellValue( const EditTextObject* pEditText );
+ScRefCellValue( ScFormulaCell* pFormula );
+ScRefCellValue( const ScRefCellValue r );
+~ScRefCellValue();
+
+void clear();
+
+/**
+ * Take cell value from specified position in specified document.
+ */
+void assign( ScDocument rDoc, const ScAddress rPos );
+
+/**
+ * TODO: Remove this later.
+ */
+void assign( ScBaseCell rCell );
+
+/**
+ * Set cell value at specified position in specified document.
+ */
+void commit( ScDocument rDoc, const ScAddress rPos ) const;
+
+bool hasString() const;
+
+bool hasNumeric() const;
+
+bool isEmpty() const;
+
+bool equalsWithoutFormat( const ScRefCellValue r ) const;
+
+ScRefCellValue operator= ( const ScRefCellValue r );
+
+void swap( ScRefCellValue r );
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index f25dc78..ac329b2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -272,6 +272,7 @@ public:
 voidSetError( SCROW nRow, const sal_uInt16 nError);
 
 voidGetString( SCROW nRow, rtl::OUString rString ) const;
+const OUString* GetStringCell( SCROW nRow ) const;
 voidGetInputString( SCROW nRow, rtl::OUString rString ) const;
 double  GetValue( SCROW nRow ) const;
 const EditTextObject* GetEditText( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 70c5620..892d18f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -802,6 +802,17 @@ public:
 
 SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab ) 
const;
 OUString GetString( const ScAddress rPos ) const;
+
+/**
+ * Return a pointer to the string object stored in string cell.
+ *
+ * @param rPos cell position.
+ *
+ * @return pointer to the string object stored in string cell, or NULL if
+ * the cell at specified position is not a string cell. Note that
+ * it returns NULL even for a edit cell.
+ */
+const OUString* GetStringCell( const ScAddress rPos ) const;
 SC_DLLPUBLIC void   GetInputString( SCCOL nCol, SCROW nRow, SCTAB 
nTab, String rString );
 SC_DLLPUBLIC void   GetInputString( SCCOL nCol, SCROW nRow, SCTAB 
nTab, rtl::OUString rString );
 sal_uInt16  GetStringForFormula( const ScAddress rPos, 
rtl::OUString rString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 461da522..0a12ead 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -318,6 +318,7 @@ public:
 voidSetError( SCCOL nCol, SCROW nRow, 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/chgtrack.hxx  |3 
 sc/inc/dociter.hxx   |   12 --
 sc/source/core/data/dociter.cxx  |  187 +--
 sc/source/core/tool/chgtrack.cxx |8 -
 sc/source/core/tool/interpr1.cxx |4 
 sc/source/core/tool/interpr5.cxx |2 
 6 files changed, 59 insertions(+), 157 deletions(-)

New commits:
commit 6a6f74a9d5fa61ccdd97bffd46c13fd799a8d52e
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 12:35:36 2013 -0400

By using ScRefCellValue we can remove some duplicated code.

Change-Id: I75652172033e4ce00ac239e85d835c7cc9256fe2

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index b30cf1b..6b06c22 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -37,7 +37,6 @@
 
 class ScDocument;
 class ScFormulaCell;
-class ScCellIterator;
 
 enum ScChangeActionType
 {
@@ -800,7 +799,7 @@ public:
 rtl::OUString rStr, ScDocument* pDoc, bool bFlag3D = false ) const;
 
 static ScChangeActionContentCellType GetContentCellType( const 
ScCellValue rCell );
-static ScChangeActionContentCellType GetContentCellType( const 
ScCellIterator rIter );
+static ScChangeActionContentCellType GetContentCellType( const 
ScRefCellValue rIter );
 
 // NewCell
 bool IsMatrixOrigin() const;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index eb34633..4f3ab26 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -24,6 +24,7 @@
 #include tools/solar.h
 #include global.hxx
 #include scdllapi.h
+#include cellvalue.hxx
 
 #include memory
 
@@ -45,7 +46,6 @@ struct ScQueryParam;
 struct ScDBQueryParamInternal;
 struct ScDBQueryParamMatrix;
 class ScFormulaCell;
-class ScCellValue;
 
 class ScDocumentIterator// walk through all non-empty cells
 {
@@ -222,13 +222,7 @@ private:
 SCSIZE mnIndex;
 bool mbSubTotal;
 
-CellType meCurType;
-OUString maCurString;
-union {
-double mfCurValue;
-const EditTextObject* mpCurEditText; // points to the original.
-ScFormulaCell* mpCurFormula; // points to the original.
-};
+ScRefCellValue maCurCell;
 
 void init();
 bool getCurrent();
@@ -245,9 +239,11 @@ public:
 const ScFormulaCell* getFormulaCell() const;
 double getValue() const;
 ScCellValue getCellValue() const;
+ScRefCellValue getRefCellValue() const;
 
 bool hasString() const;
 bool hasNumeric() const;
+bool hasEmptyData() const;
 bool isEmpty() const;
 bool equalsWithoutFormat( const ScAddress rPos ) const;
 
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 9f7dd02..adb7787 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -943,9 +943,7 @@ ScCellIterator::ScCellIterator( ScDocument* pDoc, const 
ScRange rRange, bool bS
 maStartPos(rRange.aStart),
 maEndPos(rRange.aEnd),
 mnIndex(0),
-mbSubTotal(bSTotal),
-meCurType(CELLTYPE_NONE),
-mfCurValue(0.0)
+mbSubTotal(bSTotal)
 {
 init();
 }
@@ -996,7 +994,7 @@ bool ScCellIterator::getCurrent()
 maCurPos.IncTab();
 if (maCurPos.Tab()  maEndPos.Tab())
 {
-meCurType = CELLTYPE_NONE;
+maCurCell.clear();
 return false; // Over and out
 }
 }
@@ -1021,26 +1019,26 @@ bool ScCellIterator::getCurrent()
 else
 {
 // Found it!
-meCurType = pCell-GetCellType();
-switch (meCurType)
+maCurCell.meType = pCell-GetCellType();
+switch (maCurCell.meType)
 {
 case CELLTYPE_VALUE:
-mfCurValue = static_castconst 
ScValueCell*(pCell)-GetValue();
+maCurCell.mfValue = static_castconst 
ScValueCell*(pCell)-GetValue();
 break;
 case CELLTYPE_STRING:
-maCurString = static_castconst 
ScStringCell*(pCell)-GetString();
+maCurCell.mpString = static_castconst 
ScStringCell*(pCell)-GetStringPtr();
 break;
 case CELLTYPE_EDIT:
-mpCurEditText = static_castconst 
ScEditCell*(pCell)-GetData();
+maCurCell.mpEditText = static_castconst 
ScEditCell*(pCell)-GetData();
 break;
 case CELLTYPE_FORMULA:
-mpCurFormula = static_castScFormulaCell*(pCell);
+maCurCell.mpFormula = 
static_castScFormulaCell*(pCell);
 break;
 default:
-meCurType = CELLTYPE_NONE;
+maCurCell.meType = CELLTYPE_NONE;
  

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/cellvalue.hxx |5 -
 sc/inc/conditio.hxx  |9 -
 sc/inc/validat.hxx   |   15 +--
 sc/source/core/data/cell.cxx |3 
 sc/source/core/data/conditio.cxx |  112 
 sc/source/core/data/documen4.cxx |   12 +-
 sc/source/core/data/fillinfo.cxx |8 +
 sc/source/core/data/validat.cxx  |  177 ++-
 sc/source/core/tool/detfunc.cxx  |3 
 9 files changed, 134 insertions(+), 210 deletions(-)

New commits:
commit 1fda609106ffdabf4c200c1fa8138134504895fd
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 15:04:25 2013 -0400

Make the conditional formatting code free of ScBaseCell.

Change-Id: I93f83a840874c973cdc0821ddeb1913be7f09767

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 7998898..84127cd 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -80,9 +80,10 @@ struct SC_DLLPUBLIC ScCellValue
 };
 
 /**
- * This is very similar to ScCellValue, except that it points to the
+ * This is very similar to ScCellValue, except that it references the
  * original value instead of copying it.  As such, don't hold an instance of
- * this class any longer than necessary.
+ * this class any longer than necessary, and absolutely not after the
+ * original cell has been destroyed.
  */
 struct SC_DLLPUBLIC ScRefCellValue
 {
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index d5a55e3..8592bcb 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -35,10 +35,9 @@
 #include boost/ptr_container/ptr_vector.hpp
 #include boost/scoped_ptr.hpp
 
-class ScBaseCell;
 class ScFormulaCell;
 class ScTokenArray;
-
+class ScRefCellValue;
 
 //  nOptions Flags
 #define SC_COND_NOBLANKS1
@@ -196,7 +195,7 @@ public:
 
 virtual void SetParent( ScConditionalFormat* pNew )  { pCondFormat = pNew; 
}
 
-boolIsCellValid( ScBaseCell* pCell, const ScAddress rPos ) 
const;
+bool IsCellValid( ScRefCellValue rCell, const ScAddress rPos ) const;
 
 ScConditionMode GetOperation() const{ return eOp; }
 boolIsIgnoreBlank() const   { return ( nOptions  
SC_COND_NOBLANKS ) == 0; }
@@ -406,9 +405,9 @@ public:
 
 const ScFormatEntry* GetEntry( sal_uInt16 nPos ) const;
 
-const rtl::OUString   GetCellStyle( ScBaseCell* pCell, const ScAddress 
rPos ) const;
+const OUString GetCellStyle( ScRefCellValue rCell, const ScAddress rPos 
) const;
 
-ScCondFormatData GetData( ScBaseCell* pCell, const ScAddress rPos ) const;
+ScCondFormatData GetData( ScRefCellValue rCell, const ScAddress rPos ) 
const;
 
 boolEqualEntries( const ScConditionalFormat r ) const;
 
diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx
index 8c73b7d..85737a3 100644
--- a/sc/inc/validat.hxx
+++ b/sc/inc/validat.hxx
@@ -125,12 +125,11 @@ public:
 @return  true = rStrings has been filled with at least one entry. */
 bool FillSelectionList(std::vectorScTypedStrData rStrings, const 
ScAddress rPos) const;
 
-//  with string: during input, with cell: for detective / 
RC_FORCED
-sal_BoolIsDataValid( const String rTest, const ScPatternAttr 
rPattern,
-const ScAddress rPos ) const;
-sal_BoolIsDataValid( ScBaseCell* pCell, const ScAddress rPos 
) const;
+//  with string: during input, with cell: for detective / RC_FORCED
+bool IsDataValid(
+const OUString rTest, const ScPatternAttr rPattern, const ScAddress 
rPos ) const;
 
-bool IsDataValid( ScCellIterator rIter ) const;
+bool IsDataValid( ScRefCellValue rCell, const ScAddress rPos ) const;
 
 // TRUE - break
 sal_BoolDoError( Window* pParent, const String rInput, const 
ScAddress rPos ) const;
@@ -160,14 +159,14 @@ private:
 @param rMatch(out-param) the index of the first item that matched, 
-1 if nothing matched.
 @return  true = Cell range found, rRange is valid, or an error entry 
stuffed into the list if pCell==NULL. */
 bool GetSelectionFromFormula(
-std::vectorScTypedStrData* pStrings, ScBaseCell* pCell, const 
ScAddress rPos,
+std::vectorScTypedStrData* pStrings, ScRefCellValue rCell, const 
ScAddress rPos,
 const ScTokenArray rTokArr, int rMatch) const;
 
 /** Tests, if pCell is equal to what the passed token array represents. */
-boolIsEqualToTokenArray( ScBaseCell* pCell, const ScAddress 
rPos, const ScTokenArray rTokArr ) const;
+bool IsEqualToTokenArray( ScRefCellValue rCell, const ScAddress rPos, 
const ScTokenArray rTokArr ) const;
 
 /** Tests, if contents of pCell occur in cell range referenced by own 
formula, or in a string list. */
-boolIsListValid( ScBaseCell* pCell, const ScAddress rPos ) 
const;
+bool IsListValid( ScRefCellValue rCell, const ScAddress rPos ) const;
 };
 
 //
diff --git 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/dociter.hxx  |2 +-
 sc/source/core/data/dociter.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 9749a706fdea2ee0519870ef5d58a78f4fbf33bd
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 16:44:45 2013 -0400

This can return const reference.

Change-Id: I1cf3e58167b883fee1b8cb32783a7892f6e0faa5

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 4f3ab26..acb31e2 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -239,7 +239,7 @@ public:
 const ScFormulaCell* getFormulaCell() const;
 double getValue() const;
 ScCellValue getCellValue() const;
-ScRefCellValue getRefCellValue() const;
+const ScRefCellValue getRefCellValue() const;
 
 bool hasString() const;
 bool hasNumeric() const;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index adb7787..87b832d 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1131,7 +1131,7 @@ ScCellValue ScCellIterator::getCellValue() const
 return aRet;
 }
 
-ScRefCellValue ScCellIterator::getRefCellValue() const
+const ScRefCellValue ScCellIterator::getRefCellValue() const
 {
 return maCurCell;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/dociter.hxx |7 ---
 sc/source/core/data/dociter.cxx|   15 ---
 sc/source/filter/excel/xetable.cxx |   29 -
 sc/source/filter/inc/xetable.hxx   |7 +++
 4 files changed, 31 insertions(+), 27 deletions(-)

New commits:
commit f40fc0bf4e8d2050c030fcf41cf6db2947798c81
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 18:20:20 2013 -0400

Take care of xetable.?xx.

Change-Id: I00e57ca172ba41733d39aa5025c3f0a6f1de755d

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index acb31e2..b50c68a 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -527,7 +527,7 @@ private:
 
 SCCOL   nCellCol;
 SCROW   nCellRow;
-const ScBaseCell*   pCell;
+ScBaseCell* pCell;
 SCCOL   nAttrCol1;
 SCCOL   nAttrCol2;
 SCROW   nAttrRow;
@@ -537,7 +537,8 @@ private:
 SCCOL   nFoundEndCol;
 SCROW   nFoundRow;
 const ScPatternAttr*pFoundPattern;
-const ScBaseCell*   pFoundCell;
+
+ScRefCellValue maFoundCell;
 
 public:
 ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTable,
@@ -550,7 +551,7 @@ public:
 SCCOL   GetEndCol() const   { return nFoundEndCol; }
 SCROW   GetRow() const  { return nFoundRow; }
 const ScPatternAttr*GetPattern() const  { return pFoundPattern; }
-const ScBaseCell*   GetCell() const { return pFoundCell; }
+const ScRefCellValue   GetCell() const;
 };
 
 class ScRowBreakIterator
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 87b832d..8cfa1eb 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2206,7 +2206,7 @@ bool ScUsedAreaIterator::GetNext()
 {
 if ( IsGreater( nCellCol, nCellRow, nAttrCol1, nAttrRow ) ) // Only 
attributes at the beginning?
 {
-pFoundCell = NULL;
+maFoundCell.clear();
 pFoundPattern = pPattern;
 nFoundRow = nAttrRow;
 nFoundStartCol = nAttrCol1;
@@ -2231,7 +2231,7 @@ bool ScUsedAreaIterator::GetNext()
 }
 else if ( pPattern ) // Just attributes - take over right away
 {
-pFoundCell = NULL;
+maFoundCell.clear();
 pFoundPattern = pPattern;
 nFoundRow = nAttrRow;
 nFoundStartCol = nAttrCol1;
@@ -2242,7 +2242,11 @@ bool ScUsedAreaIterator::GetNext()
 
 if ( bUseCell ) // Cell position
 {
-pFoundCell = pCell;
+if (pCell)
+maFoundCell.assign(*pCell);
+else
+maFoundCell.clear();
+
 nFoundRow = nCellRow;
 nFoundStartCol = nFoundEndCol = nCellCol;
 }
@@ -2256,6 +2260,11 @@ bool ScUsedAreaIterator::GetNext()
 return bFound;
 }
 
+const ScRefCellValue ScUsedAreaIterator::GetCell() const
+{
+return maFoundCell;
+}
+
 
//---
 
 ScDocAttrIterator::ScDocAttrIterator(ScDocument* pDocument, SCTAB nTable,
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index e71cfcd..06e70bb 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -643,25 +643,24 @@ IMPL_FIXEDMEMPOOL_NEWDEL( XclExpLabelCell )
 
 XclExpLabelCell::XclExpLabelCell(
 const XclExpRoot rRoot, const XclAddress rXclPos,
-const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId, const 
ScStringCell rCell ) :
+const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId, const OUString 
rStr ) :
 XclExpSingleCellBase( EXC_ID3_LABEL, 0, rXclPos, nForcedXFId )
 {
 sal_uInt16 nMaxLen = (rRoot.GetBiff() == EXC_BIFF8) ? EXC_STR_MAXLEN : 
EXC_LABEL_MAXLEN;
 XclExpStringRef xText = XclExpStringHelper::CreateCellString(
-rRoot, rCell.GetString(), pPattern, EXC_STR_DEFAULT, nMaxLen );
+rRoot, rStr, pPattern, EXC_STR_DEFAULT, nMaxLen);
 Init( rRoot, pPattern, xText );
 }
 
 XclExpLabelCell::XclExpLabelCell(
 const XclExpRoot rRoot, const XclAddress rXclPos,
 const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
-const ScEditCell rCell, XclExpHyperlinkHelper rLinkHelper ) :
+const EditTextObject* pEditText, XclExpHyperlinkHelper rLinkHelper ) :
 XclExpSingleCellBase( EXC_ID3_LABEL, 0, rXclPos, nForcedXFId )
 {
 sal_uInt16 nMaxLen = (rRoot.GetBiff() == EXC_BIFF8) ? EXC_STR_MAXLEN : 
EXC_LABEL_MAXLEN;
 
 XclExpStringRef xText;
-const EditTextObject* pEditText = rCell.GetData();
 if (pEditText)
 xText = XclExpStringHelper::CreateCellString(
 rRoot, *pEditText, pPattern, rLinkHelper, EXC_STR_DEFAULT, 
nMaxLen);
@@ -2301,7 +2300,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot rRoot 
) :
 XclAddress aXclPos( static_cast 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/cellvalue.hxx  |4 +
 sc/inc/dociter.hxx|2 
 sc/source/core/data/cellvalue.cxx |   32 +++
 sc/source/core/data/dociter.cxx   |   28 +
 sc/source/core/tool/rangeseq.cxx  |   44 +++--
 sc/source/ui/view/tabvwsh5.cxx|   77 +++---
 6 files changed, 86 insertions(+), 101 deletions(-)

New commits:
commit 7fbb6dc56fde660076eb46f3e6d519bc472f3eda
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 18:42:19 2013 -0400

More on killing direct use of cell classes.

Change-Id: Ie2b6819652f330a493b7f9fe557736b27e402803

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 84127cd..d4ef307 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -124,6 +124,10 @@ struct SC_DLLPUBLIC ScRefCellValue
 
 bool hasNumeric() const;
 
+double getValue();
+
+OUString getString();
+
 bool isEmpty() const;
 
 bool equalsWithoutFormat( const ScRefCellValue r ) const;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index b50c68a..7161ac2 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -237,7 +237,7 @@ public:
 const EditTextObject* getEditText() const;
 ScFormulaCell* getFormulaCell();
 const ScFormulaCell* getFormulaCell() const;
-double getValue() const;
+double getValue();
 ScCellValue getCellValue() const;
 const ScRefCellValue getRefCellValue() const;
 
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index 5b853a3..e4f0c2e 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -477,6 +477,38 @@ bool ScRefCellValue::hasNumeric() const
 return hasNumericImpl(meType, mpFormula);
 }
 
+double ScRefCellValue::getValue()
+{
+switch (meType)
+{
+case CELLTYPE_VALUE:
+return mfValue;
+case CELLTYPE_FORMULA:
+return mpFormula-GetValue();
+default:
+;
+}
+return 0.0;
+}
+
+OUString ScRefCellValue::getString()
+{
+switch (meType)
+{
+case CELLTYPE_STRING:
+return *mpString;
+case CELLTYPE_EDIT:
+if (mpEditText)
+return ScEditUtil::GetString(*mpEditText);
+break;
+case CELLTYPE_FORMULA:
+return mpFormula-GetString();
+default:
+;
+}
+return EMPTY_OUSTRING;
+}
+
 bool ScRefCellValue::isEmpty() const
 {
 return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 8cfa1eb..6d8f758 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1060,20 +1060,7 @@ CellType ScCellIterator::getType() const
 
 OUString ScCellIterator::getString()
 {
-switch (maCurCell.meType)
-{
-case CELLTYPE_STRING:
-return *maCurCell.mpString;
-case CELLTYPE_EDIT:
-if (maCurCell.mpEditText)
-return ScEditUtil::GetString(*maCurCell.mpEditText);
-break;
-case CELLTYPE_FORMULA:
-return maCurCell.mpFormula-GetString();
-default:
-;
-}
-return EMPTY_OUSTRING;
+return maCurCell.getString();
 }
 
 const EditTextObject* ScCellIterator::getEditText() const
@@ -1091,18 +1078,9 @@ const ScFormulaCell* ScCellIterator::getFormulaCell() 
const
 return maCurCell.mpFormula;
 }
 
-double ScCellIterator::getValue() const
+double ScCellIterator::getValue()
 {
-switch (maCurCell.meType)
-{
-case CELLTYPE_VALUE:
-return maCurCell.mfValue;
-case CELLTYPE_FORMULA:
-return maCurCell.mpFormula-GetValue();
-default:
-;
-}
-return 0.0;
+return maCurCell.getValue();
 }
 
 ScCellValue ScCellIterator::getCellValue() const
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 114354c..9e08c89 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -243,22 +243,6 @@ sal_Bool ScRangeToSequence::FillStringArray( uno::Any 
rAny, const ScMatrix* pMa
 return sal_True;
 }
 
-//
-
-static double lcl_GetValueFromCell( ScBaseCell rCell )
-{
-//! ScBaseCell member function?
-
-CellType eType = rCell.GetCellType();
-if ( eType == CELLTYPE_VALUE )
-return ((ScValueCell)rCell).GetValue();
-else if ( eType == CELLTYPE_FORMULA )
-return ((ScFormulaCell)rCell).GetValue();  // called only if 
result is value
-
-OSL_FAIL( GetValueFromCell: wrong type );
-return 0;
-}
-
 sal_Bool ScRangeToSequence::FillMixedArray( uno::Any rAny, ScDocument* pDoc, 
const ScRange rRange,
 sal_Bool bAllowNV )
 {
@@ -281,22 +265,24 @@ sal_Bool ScRangeToSequence::FillMixedArray( uno::Any 
rAny, ScDocument* 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

2013-03-26 Thread Kohei Yoshida
 sc/inc/cellform.hxx   |7 ++
 sc/source/core/tool/cellform.cxx  |  103 ++
 sc/source/filter/dif/difexp.cxx   |   94 +++---
 sc/source/filter/html/htmlexp.cxx |   92 +++--
 sc/source/filter/inc/htmlexp.hxx  |4 -
 5 files changed, 196 insertions(+), 104 deletions(-)

New commits:
commit 7e297f5b952ac3c2691811cf9697e43b756dd8c5
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Mar 26 19:13:21 2013 -0400

More of the same...

Change-Id: I829d221d6bf164cd6087d41c65e26240108aa021

diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index e6314fc..e2935a0 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -28,6 +28,7 @@ class SvNumberFormatter;
 class Color;
 class ScDocument;
 class ScAddress;
+class ScRefCellValue;
 
 enum ScForceTextFmt {
 ftDontForce,// numbers as numbers
@@ -47,6 +48,12 @@ public:
ScForceTextFmt eForceTextFmt = ftDontForce,
bool bUseStarFormat = false );
 
+static void GetString(
+ScRefCellValue rCell, sal_uLong nFormat, rtl::OUString rString,
+Color** ppColor, SvNumberFormatter rFormatter, bool bNullVals = true,
+bool bFormula  = false, ScForceTextFmt eForceTextFmt = ftDontForce,
+bool bUseStarFormat = false );
+
 static OUString GetString(
 const ScDocument rDoc, const ScAddress rPos, sal_uLong nFormat,
 Color** ppColor, SvNumberFormatter rFormatter, bool bNullVals = true,
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 254bb43..8254a96 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -24,6 +24,7 @@
 #include cellform.hxx
 #include cell.hxx
 #include document.hxx
+#include cellvalue.hxx
 #include formula/errorcodes.hxx
 #include sc.hrc
 
@@ -143,6 +144,108 @@ void ScCellFormat::GetString( ScBaseCell* pCell, 
sal_uLong nFormat, OUString rS
 }
 }
 
+void ScCellFormat::GetString( ScRefCellValue rCell, sal_uLong nFormat, 
OUString rString,
+  Color** ppColor, SvNumberFormatter rFormatter,
+  bool bNullVals, bool bFormula, ScForceTextFmt 
eForceTextFmt,
+  bool bUseStarFormat )
+{
+*ppColor = NULL;
+if (rFormatter==NULL)
+{
+rString = OUString();
+return;
+}
+
+switch (rCell.meType)
+{
+case CELLTYPE_STRING:
+rFormatter.GetOutputString(*rCell.mpString, nFormat, rString, 
ppColor, bUseStarFormat);
+break;
+case CELLTYPE_EDIT:
+rFormatter.GetOutputString(rCell.getString(), nFormat, rString, 
ppColor );
+break;
+case CELLTYPE_VALUE:
+{
+double nValue = rCell.mfValue;
+if (!bNullVals  nValue == 0.0)
+rString = OUString();
+else
+{
+if( eForceTextFmt == ftCheck )
+{
+if( nFormat  rFormatter.IsTextFormat( nFormat ) )
+eForceTextFmt = ftForce;
+}
+if( eForceTextFmt == ftForce )
+{
+OUString aTemp;
+rFormatter.GetOutputString( nValue, 0, aTemp, ppColor );
+rFormatter.GetOutputString( aTemp, nFormat, rString, 
ppColor );
+}
+else
+rFormatter.GetOutputString( nValue, nFormat, rString, 
ppColor, bUseStarFormat );
+}
+}
+break;
+case CELLTYPE_FORMULA:
+{
+ScFormulaCell*  pFCell = rCell.mpFormula;
+if ( bFormula )
+{
+pFCell-GetFormula( rString );
+}
+else
+{
+// A macro started from the interpreter, which has
+// access to Formular Cells, becomes a CellText, even if
+// that triggers further interpretation, except if those
+// cells are already being interpreted.
+// IdleCalc generally doesn't trigger futher interpretation,
+// as not to get Err522 (circular).
+if ( pFCell-GetDocument()-IsInInterpreter() 
+(!pFCell-GetDocument()-GetMacroInterpretLevel()
+|| pFCell-IsRunning()) )
+{
+rString = OUString(...);
+}
+else
+{
+sal_uInt16 nErrCode = pFCell-GetErrCode();
+
+// get the number format only after interpretation 
(GetErrCode):
+if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+nFormat = pFCell-GetStandardFormat( rFormatter,
+nFormat );
+
+if (nErrCode != 0)
+ 

  1   2   >