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 @@
     * @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 @@

    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 @@
}

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 @@
    // 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 @@
    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 @@

    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 @@
        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 )