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

Kohei Yoshida kohei.yoshida at collabora.com
Wed Nov 19 19:06:55 PST 2014


 sc/inc/column.hxx               |    8 +++++---
 sc/source/core/data/column3.cxx |   22 ++++++++++++++++------
 sc/source/core/data/table2.cxx  |    2 +-
 3 files changed, 22 insertions(+), 10 deletions(-)

New commits:
commit 797db638870f5c6192e72c0b4669b471788e16ea
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Nov 19 22:05:32 2014 -0500

    Use group area listener when entering a new single formula cell.
    
    Change-Id: I01dc4537919b69a312e92ede2ae00fbe7d781bd7

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 72a55e9..19bb2aa 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -307,7 +307,7 @@ public:
      * @return pCell if it was successfully inserted, NULL otherwise. pCell
      *         is deleted automatically on failure to insert.
      */
-    ScFormulaCell* SetFormulaCell( SCROW nRow, ScFormulaCell* pCell );
+    ScFormulaCell* SetFormulaCell( SCROW nRow, ScFormulaCell* pCell, bool bSingle = false );
     ScFormulaCell* SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell );
 
     bool SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells );
@@ -630,8 +630,10 @@ private:
 
     sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
     sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow );
-    void AttachNewFormulaCell( const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, bool bJoin = true );
-    void AttachNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, bool bJoin = true );
+    void AttachNewFormulaCell(
+        const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, bool bJoin = true, bool bSingle = false );
+    void AttachNewFormulaCell(
+        const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, bool bJoin = true, bool bSingle = false );
     void AttachNewFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength );
     void BroadcastNewCell( SCROW nRow );
     bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, const sc::CellStoreType::iterator& itr );
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 150d609..8b6fa92 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -375,13 +375,13 @@ sc::CellStoreType::iterator ScColumn::GetPositionToInsert( const sc::CellStoreTy
 }
 
 void ScColumn::AttachNewFormulaCell(
-    const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, bool bJoin )
+    const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, bool bJoin, bool bSingle )
 {
-    AttachNewFormulaCell(maCells.position(itPos, nRow), rCell, bJoin);
+    AttachNewFormulaCell(maCells.position(itPos, nRow), rCell, bJoin, bSingle);
 }
 
 void ScColumn::AttachNewFormulaCell(
-    const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, bool bJoin )
+    const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, bool bJoin, bool bSingle )
 {
     if (bJoin)
         // See if this new formula cell can join an existing shared formula group.
@@ -394,7 +394,17 @@ void ScColumn::AttachNewFormulaCell(
     // After Import we call CalcAfterLoad and in there Listening.
     if (!pDocument->IsClipOrUndo() && !pDocument->IsInsertingFromOtherDoc())
     {
-        rCell.StartListeningTo(pDocument);
+        if (bSingle)
+        {
+            boost::shared_ptr<sc::ColumnBlockPositionSet> pPosSet(new sc::ColumnBlockPositionSet(*pDocument));
+            sc::StartListeningContext aStartCxt(*pDocument, pPosSet);
+            sc::EndListeningContext aEndCxt(*pDocument, pPosSet);
+            SCROW nRow = aPos.first->position + aPos.second;
+            StartListeningFormulaCells(aStartCxt, aEndCxt, nRow, nRow);
+        }
+        else
+            rCell.StartListeningTo(pDocument);
+
         if (!pDocument->IsCalcingAfterLoad())
             rCell.SetDirty();
     }
@@ -1822,7 +1832,7 @@ void ScColumn::SetFormula( SCROW nRow, const OUString& rFormula, formula::Formul
     AttachNewFormulaCell(it, nRow, *pCell);
 }
 
-ScFormulaCell* ScColumn::SetFormulaCell( SCROW nRow, ScFormulaCell* pCell )
+ScFormulaCell* ScColumn::SetFormulaCell( SCROW nRow, ScFormulaCell* pCell, bool bSingle )
 {
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     sal_uInt32 nCellFormat = GetNumberFormat(nRow);
@@ -1833,7 +1843,7 @@ ScFormulaCell* ScColumn::SetFormulaCell( SCROW nRow, ScFormulaCell* pCell )
 
     CellStorageModified();
 
-    AttachNewFormulaCell(it, nRow, *pCell);
+    AttachNewFormulaCell(it, nRow, *pCell, true, bSingle);
     return pCell;
 }
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 0856454..ef81e6d 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1409,7 +1409,7 @@ ScFormulaCell* ScTable::SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* p
         return NULL;
     }
 
-    return aCol[nCol].SetFormulaCell(nRow, pCell);
+    return aCol[nCol].SetFormulaCell(nRow, pCell, true);
 }
 
 bool ScTable::SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells )


More information about the Libreoffice-commits mailing list