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

Kohei Yoshida kohei.yoshida at gmail.com
Wed Mar 27 18:19:09 PDT 2013


 sc/inc/cell.hxx                 |   19 ++--
 sc/source/core/data/cell.cxx    |  173 ----------------------------------------
 sc/source/core/data/cell2.cxx   |  168 ++++++++++++++++++++++++++++++++++++++
 sc/source/core/data/column3.cxx |   16 ++-
 4 files changed, 187 insertions(+), 189 deletions(-)

New commits:
commit 56588de4e931176a6c7854e88b31019bee132fb3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 27 21:18:29 2013 -0400

    Some followup cleanup now that these methods are in the formula cell only.
    
    Change-Id: I796bf379f004a1371c86362e57eaac4a511f34cd

diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 6369e18d..7603b05 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1820,82 +1820,83 @@ bool ScFormulaCell::InterpretFormulaGroup()
 
 void ScFormulaCell::StartListeningTo( ScDocument* pDoc )
 {
-    if (!pDoc->IsClipOrUndo() && !pDoc->GetNoListening() && !IsInChangeTrack())
+    if (pDoc->IsClipOrUndo() || pDoc->GetNoListening() || IsInChangeTrack())
+        return;
+
+    pDoc->SetDetectiveDirty(true);  // It has changed something
+
+    ScTokenArray* pArr = GetCode();
+    if( pArr->IsRecalcModeAlways() )
     {
-        pDoc->SetDetectiveDirty(true);  // It has changed something
+        pDoc->StartListeningArea(BCA_LISTEN_ALWAYS, this);
+        SetNeedsListening( false);
+        return;
+    }
 
-        ScFormulaCell* pFormCell = (ScFormulaCell*)this;
-        ScTokenArray* pArr = pFormCell->GetCode();
-        if( pArr->IsRecalcModeAlways() )
-            pDoc->StartListeningArea( BCA_LISTEN_ALWAYS, pFormCell );
-        else
+    pArr->Reset();
+    ScToken* t;
+    while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
+    {
+        StackVar eType = t->GetType();
+        ScSingleRefData& rRef1 = t->GetSingleRef();
+        ScSingleRefData& rRef2 = (eType == svDoubleRef ?
+            t->GetDoubleRef().Ref2 : rRef1);
+        switch( eType )
         {
-            pArr->Reset();
-            ScToken* t;
-            while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
-            {
-                StackVar eType = t->GetType();
-                ScSingleRefData& rRef1 = t->GetSingleRef();
-                ScSingleRefData& rRef2 = (eType == svDoubleRef ?
-                    t->GetDoubleRef().Ref2 : rRef1);
-                switch( eType )
+            case svSingleRef:
+                rRef1.CalcAbsIfRel(aPos);
+                if ( rRef1.Valid() )
                 {
-                    case svSingleRef:
-                        rRef1.CalcAbsIfRel( pFormCell->aPos );
-                        if ( rRef1.Valid() )
-                        {
-                            pDoc->StartListeningCell(
-                                ScAddress( rRef1.nCol,
-                                           rRef1.nRow,
-                                           rRef1.nTab ), pFormCell );
+                    pDoc->StartListeningCell(
+                        ScAddress( rRef1.nCol,
+                                   rRef1.nRow,
+                                   rRef1.nTab ), this );
+                }
+            break;
+            case svDoubleRef:
+                t->CalcAbsIfRel(aPos);
+                if ( rRef1.Valid() && rRef2.Valid() )
+                {
+                    if ( t->GetOpCode() == ocColRowNameAuto )
+                    {   // automagically
+                        if ( rRef1.IsColRel() )
+                        {   // ColName
+                            pDoc->StartListeningArea( ScRange (
+                                rRef1.nCol,
+                                rRef1.nRow,
+                                rRef1.nTab,
+                                rRef2.nCol,
+                                MAXROW,
+                                rRef2.nTab ), this );
                         }
-                    break;
-                    case svDoubleRef:
-                        t->CalcAbsIfRel( pFormCell->aPos );
-                        if ( rRef1.Valid() && rRef2.Valid() )
-                        {
-                            if ( t->GetOpCode() == ocColRowNameAuto )
-                            {   // automagically
-                                if ( rRef1.IsColRel() )
-                                {   // ColName
-                                    pDoc->StartListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        rRef2.nCol,
-                                        MAXROW,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                                else
-                                {   // RowName
-                                    pDoc->StartListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        MAXCOL,
-                                        rRef2.nRow,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                            }
-                            else
-                            {
-                                pDoc->StartListeningArea( ScRange (
-                                    rRef1.nCol,
-                                    rRef1.nRow,
-                                    rRef1.nTab,
-                                    rRef2.nCol,
-                                    rRef2.nRow,
-                                    rRef2.nTab ), pFormCell );
-                            }
+                        else
+                        {   // RowName
+                            pDoc->StartListeningArea( ScRange (
+                                rRef1.nCol,
+                                rRef1.nRow,
+                                rRef1.nTab,
+                                MAXCOL,
+                                rRef2.nRow,
+                                rRef2.nTab ), this );
                         }
-                    break;
-                    default:
-                        ;   // nothing
+                    }
+                    else
+                    {
+                        pDoc->StartListeningArea( ScRange (
+                            rRef1.nCol,
+                            rRef1.nRow,
+                            rRef1.nTab,
+                            rRef2.nCol,
+                            rRef2.nRow,
+                            rRef2.nTab ), this );
+                    }
                 }
-            }
+            break;
+            default:
+                ;   // nothing
         }
-        pFormCell->SetNeedsListening( false);
     }
+    SetNeedsListening( false);
 }
 
 //  pArr gesetzt -> Referenzen von anderer Zelle nehmen
@@ -1904,83 +1905,83 @@ void ScFormulaCell::StartListeningTo( ScDocument* pDoc )
 void ScFormulaCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr,
         ScAddress aCellPos )
 {
-    if (!pDoc->IsClipOrUndo() && !IsInChangeTrack())
+    if (pDoc->IsClipOrUndo() || IsInChangeTrack())
+        return;
+
+    pDoc->SetDetectiveDirty(true);  // It has changed something
+
+    if ( GetCode()->IsRecalcModeAlways() )
     {
-        pDoc->SetDetectiveDirty(true);  // It has changed something
+        pDoc->EndListeningArea( BCA_LISTEN_ALWAYS, this );
+        return;
+    }
 
-        ScFormulaCell* pFormCell = (ScFormulaCell*)this;
-        if( pFormCell->GetCode()->IsRecalcModeAlways() )
-            pDoc->EndListeningArea( BCA_LISTEN_ALWAYS, pFormCell );
-        else
+    if (!pArr)
+    {
+        pArr = GetCode();
+        aCellPos = aPos;
+    }
+    pArr->Reset();
+    ScToken* t;
+    while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
+    {
+        StackVar eType = t->GetType();
+        ScSingleRefData& rRef1 = t->GetSingleRef();
+        ScSingleRefData& rRef2 = (eType == svDoubleRef ?
+            t->GetDoubleRef().Ref2 : rRef1);
+        switch( eType )
         {
-            if (!pArr)
-            {
-                pArr = pFormCell->GetCode();
-                aCellPos = pFormCell->aPos;
-            }
-            pArr->Reset();
-            ScToken* t;
-            while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
-            {
-                StackVar eType = t->GetType();
-                ScSingleRefData& rRef1 = t->GetSingleRef();
-                ScSingleRefData& rRef2 = (eType == svDoubleRef ?
-                    t->GetDoubleRef().Ref2 : rRef1);
-                switch( eType )
+            case svSingleRef:
+                rRef1.CalcAbsIfRel( aCellPos );
+                if ( rRef1.Valid() )
                 {
-                    case svSingleRef:
-                        rRef1.CalcAbsIfRel( aCellPos );
-                        if ( rRef1.Valid() )
-                        {
-                            pDoc->EndListeningCell(
-                                ScAddress( rRef1.nCol,
-                                           rRef1.nRow,
-                                           rRef1.nTab ), pFormCell );
+                    pDoc->EndListeningCell(
+                        ScAddress( rRef1.nCol,
+                                   rRef1.nRow,
+                                   rRef1.nTab ), this );
+                }
+            break;
+            case svDoubleRef:
+                t->CalcAbsIfRel( aCellPos );
+                if ( rRef1.Valid() && rRef2.Valid() )
+                {
+                    if ( t->GetOpCode() == ocColRowNameAuto )
+                    {   // automagically
+                        if ( rRef1.IsColRel() )
+                        {   // ColName
+                            pDoc->EndListeningArea( ScRange (
+                                rRef1.nCol,
+                                rRef1.nRow,
+                                rRef1.nTab,
+                                rRef2.nCol,
+                                MAXROW,
+                                rRef2.nTab ), this );
                         }
-                    break;
-                    case svDoubleRef:
-                        t->CalcAbsIfRel( aCellPos );
-                        if ( rRef1.Valid() && rRef2.Valid() )
-                        {
-                            if ( t->GetOpCode() == ocColRowNameAuto )
-                            {   // automagically
-                                if ( rRef1.IsColRel() )
-                                {   // ColName
-                                    pDoc->EndListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        rRef2.nCol,
-                                        MAXROW,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                                else
-                                {   // RowName
-                                    pDoc->EndListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        MAXCOL,
-                                        rRef2.nRow,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                            }
-                            else
-                            {
-                                pDoc->EndListeningArea( ScRange (
-                                    rRef1.nCol,
-                                    rRef1.nRow,
-                                    rRef1.nTab,
-                                    rRef2.nCol,
-                                    rRef2.nRow,
-                                    rRef2.nTab ), pFormCell );
-                            }
+                        else
+                        {   // RowName
+                            pDoc->EndListeningArea( ScRange (
+                                rRef1.nCol,
+                                rRef1.nRow,
+                                rRef1.nTab,
+                                MAXCOL,
+                                rRef2.nRow,
+                                rRef2.nTab ), this );
                         }
-                    break;
-                    default:
-                        ;   // nothing
+                    }
+                    else
+                    {
+                        pDoc->EndListeningArea( ScRange (
+                            rRef1.nCol,
+                            rRef1.nRow,
+                            rRef1.nTab,
+                            rRef2.nCol,
+                            rRef2.nRow,
+                            rRef2.nTab ), this );
+                    }
                 }
-            }
+            break;
+            default:
+                ;   // nothing
         }
     }
 }
commit 1106e3a52918fc5f06f7f1cecea51e9b031cec5d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 27 21:09:37 2013 -0400

    Now we don't need to check for the cell type; it's always of formula type.
    
    Change-Id: I4066975340f7e8a89e9e4d07cc7bed3851da52b6

diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index a68203f..6369e18d 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1820,10 +1820,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
 
 void ScFormulaCell::StartListeningTo( ScDocument* pDoc )
 {
-    if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo()
-            && !pDoc->GetNoListening()
-            && !((ScFormulaCell*)this)->IsInChangeTrack()
-        )
+    if (!pDoc->IsClipOrUndo() && !pDoc->GetNoListening() && !IsInChangeTrack())
     {
         pDoc->SetDetectiveDirty(true);  // It has changed something
 
@@ -1907,9 +1904,7 @@ void ScFormulaCell::StartListeningTo( ScDocument* pDoc )
 void ScFormulaCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr,
         ScAddress aCellPos )
 {
-    if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo()
-            && !((ScFormulaCell*)this)->IsInChangeTrack()
-        )
+    if (!pDoc->IsClipOrUndo() && !IsInChangeTrack())
     {
         pDoc->SetDetectiveDirty(true);  // It has changed something
 
commit a25d96116d70549efc748b6773bcb8d78934ada1
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 27 21:07:40 2013 -0400

    Stop exporting symbols of these cell classes except for ScFormulaCell.
    
    And move StartListeningTo() and EndListeningTo() methods from ScBaseCell
    to ScFormulaCell.  They really do belong only to the formula cells.
    
    Change-Id: I468cd899beec0d8281ebb0d57fe6205a0fc4f534

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index c3443d2..b0919a6 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -51,7 +51,7 @@ class SvtBroadcaster;
 class ScProgress;
 class ScPatternAttr;
 
-class SC_DLLPUBLIC ScBaseCell
+class ScBaseCell
 {
 protected:
                     ~ScBaseCell();  // not virtual - not to be called directly.
@@ -91,12 +91,6 @@ public:
     /** Deletes the own cell broadcaster. */
     void            DeleteBroadcaster();
 
-    // nOnlyNames may be one or more of SC_LISTENING_NAMES_*
-    void            StartListeningTo( ScDocument* pDoc );
-    void            EndListeningTo( ScDocument* pDoc,
-                                    ScTokenArray* pArr = NULL,
-                                    ScAddress aPos = ScAddress() );
-
     /** Error code if ScFormulaCell, else 0. */
     sal_uInt16          GetErrorCode() const;
     /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been
@@ -120,7 +114,7 @@ protected:
 
 // ============================================================================
 
-class SC_DLLPUBLIC ScNoteCell : public ScBaseCell
+class ScNoteCell : public ScBaseCell
 {
 public:
 #ifdef USE_MEMPOOL
@@ -158,7 +152,7 @@ private:
     double          mfValue;
 };
 
-class SC_DLLPUBLIC ScStringCell : public ScBaseCell
+class ScStringCell : public ScBaseCell
 {
 public:
 #ifdef USE_MEMPOOL
@@ -179,7 +173,7 @@ private:
     rtl::OUString   maString;
 };
 
-class SC_DLLPUBLIC ScEditCell : public ScBaseCell
+class ScEditCell : public ScBaseCell
 {
     EditTextObject* mpData;
     mutable OUString* mpString;        // for faster access to formulas
@@ -578,6 +572,11 @@ public:
     ScSimilarFormulaDelta *BuildDeltaTo( ScFormulaCell *pOther );
     void                   ReleaseDelta( ScSimilarFormulaDelta *pDelta );
     bool                   InterpretFormulaGroup();
+
+    // nOnlyNames may be one or more of SC_LISTENING_NAMES_*
+    void StartListeningTo( ScDocument* pDoc );
+    void EndListeningTo(
+        ScDocument* pDoc, ScTokenArray* pArr = NULL, ScAddress aPos = ScAddress() );
 };
 
 #endif
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 03fbe68..f732019 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -277,179 +277,6 @@ void ScBaseCell::DeleteBroadcaster()
     DELETEZ( mpBroadcaster );
 }
 
-void ScBaseCell::StartListeningTo( ScDocument* pDoc )
-{
-    if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo()
-            && !pDoc->GetNoListening()
-            && !((ScFormulaCell*)this)->IsInChangeTrack()
-        )
-    {
-        pDoc->SetDetectiveDirty(true);  // It has changed something
-
-        ScFormulaCell* pFormCell = (ScFormulaCell*)this;
-        ScTokenArray* pArr = pFormCell->GetCode();
-        if( pArr->IsRecalcModeAlways() )
-            pDoc->StartListeningArea( BCA_LISTEN_ALWAYS, pFormCell );
-        else
-        {
-            pArr->Reset();
-            ScToken* t;
-            while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
-            {
-                StackVar eType = t->GetType();
-                ScSingleRefData& rRef1 = t->GetSingleRef();
-                ScSingleRefData& rRef2 = (eType == svDoubleRef ?
-                    t->GetDoubleRef().Ref2 : rRef1);
-                switch( eType )
-                {
-                    case svSingleRef:
-                        rRef1.CalcAbsIfRel( pFormCell->aPos );
-                        if ( rRef1.Valid() )
-                        {
-                            pDoc->StartListeningCell(
-                                ScAddress( rRef1.nCol,
-                                           rRef1.nRow,
-                                           rRef1.nTab ), pFormCell );
-                        }
-                    break;
-                    case svDoubleRef:
-                        t->CalcAbsIfRel( pFormCell->aPos );
-                        if ( rRef1.Valid() && rRef2.Valid() )
-                        {
-                            if ( t->GetOpCode() == ocColRowNameAuto )
-                            {   // automagically
-                                if ( rRef1.IsColRel() )
-                                {   // ColName
-                                    pDoc->StartListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        rRef2.nCol,
-                                        MAXROW,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                                else
-                                {   // RowName
-                                    pDoc->StartListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        MAXCOL,
-                                        rRef2.nRow,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                            }
-                            else
-                            {
-                                pDoc->StartListeningArea( ScRange (
-                                    rRef1.nCol,
-                                    rRef1.nRow,
-                                    rRef1.nTab,
-                                    rRef2.nCol,
-                                    rRef2.nRow,
-                                    rRef2.nTab ), pFormCell );
-                            }
-                        }
-                    break;
-                    default:
-                        ;   // nothing
-                }
-            }
-        }
-        pFormCell->SetNeedsListening( false);
-    }
-}
-
-//  pArr gesetzt -> Referenzen von anderer Zelle nehmen
-// Then aPos must also be commited
-
-void ScBaseCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr,
-        ScAddress aPos )
-{
-    if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo()
-            && !((ScFormulaCell*)this)->IsInChangeTrack()
-        )
-    {
-        pDoc->SetDetectiveDirty(true);  // It has changed something
-
-        ScFormulaCell* pFormCell = (ScFormulaCell*)this;
-        if( pFormCell->GetCode()->IsRecalcModeAlways() )
-            pDoc->EndListeningArea( BCA_LISTEN_ALWAYS, pFormCell );
-        else
-        {
-            if (!pArr)
-            {
-                pArr = pFormCell->GetCode();
-                aPos = pFormCell->aPos;
-            }
-            pArr->Reset();
-            ScToken* t;
-            while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
-            {
-                StackVar eType = t->GetType();
-                ScSingleRefData& rRef1 = t->GetSingleRef();
-                ScSingleRefData& rRef2 = (eType == svDoubleRef ?
-                    t->GetDoubleRef().Ref2 : rRef1);
-                switch( eType )
-                {
-                    case svSingleRef:
-                        rRef1.CalcAbsIfRel( aPos );
-                        if ( rRef1.Valid() )
-                        {
-                            pDoc->EndListeningCell(
-                                ScAddress( rRef1.nCol,
-                                           rRef1.nRow,
-                                           rRef1.nTab ), pFormCell );
-                        }
-                    break;
-                    case svDoubleRef:
-                        t->CalcAbsIfRel( aPos );
-                        if ( rRef1.Valid() && rRef2.Valid() )
-                        {
-                            if ( t->GetOpCode() == ocColRowNameAuto )
-                            {   // automagically
-                                if ( rRef1.IsColRel() )
-                                {   // ColName
-                                    pDoc->EndListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        rRef2.nCol,
-                                        MAXROW,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                                else
-                                {   // RowName
-                                    pDoc->EndListeningArea( ScRange (
-                                        rRef1.nCol,
-                                        rRef1.nRow,
-                                        rRef1.nTab,
-                                        MAXCOL,
-                                        rRef2.nRow,
-                                        rRef2.nTab ), pFormCell );
-                                }
-                            }
-                            else
-                            {
-                                pDoc->EndListeningArea( ScRange (
-                                    rRef1.nCol,
-                                    rRef1.nRow,
-                                    rRef1.nTab,
-                                    rRef2.nCol,
-                                    rRef2.nRow,
-                                    rRef2.nTab ), pFormCell );
-                            }
-                        }
-                    break;
-                    default:
-                        ;   // nothing
-                }
-            }
-        }
-    }
-}
-
-
 sal_uInt16 ScBaseCell::GetErrorCode() const
 {
     switch ( eCellType )
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 297f8d0..a68203f 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1818,6 +1818,178 @@ bool ScFormulaCell::InterpretFormulaGroup()
     }
 }
 
+void ScFormulaCell::StartListeningTo( ScDocument* pDoc )
+{
+    if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo()
+            && !pDoc->GetNoListening()
+            && !((ScFormulaCell*)this)->IsInChangeTrack()
+        )
+    {
+        pDoc->SetDetectiveDirty(true);  // It has changed something
+
+        ScFormulaCell* pFormCell = (ScFormulaCell*)this;
+        ScTokenArray* pArr = pFormCell->GetCode();
+        if( pArr->IsRecalcModeAlways() )
+            pDoc->StartListeningArea( BCA_LISTEN_ALWAYS, pFormCell );
+        else
+        {
+            pArr->Reset();
+            ScToken* t;
+            while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
+            {
+                StackVar eType = t->GetType();
+                ScSingleRefData& rRef1 = t->GetSingleRef();
+                ScSingleRefData& rRef2 = (eType == svDoubleRef ?
+                    t->GetDoubleRef().Ref2 : rRef1);
+                switch( eType )
+                {
+                    case svSingleRef:
+                        rRef1.CalcAbsIfRel( pFormCell->aPos );
+                        if ( rRef1.Valid() )
+                        {
+                            pDoc->StartListeningCell(
+                                ScAddress( rRef1.nCol,
+                                           rRef1.nRow,
+                                           rRef1.nTab ), pFormCell );
+                        }
+                    break;
+                    case svDoubleRef:
+                        t->CalcAbsIfRel( pFormCell->aPos );
+                        if ( rRef1.Valid() && rRef2.Valid() )
+                        {
+                            if ( t->GetOpCode() == ocColRowNameAuto )
+                            {   // automagically
+                                if ( rRef1.IsColRel() )
+                                {   // ColName
+                                    pDoc->StartListeningArea( ScRange (
+                                        rRef1.nCol,
+                                        rRef1.nRow,
+                                        rRef1.nTab,
+                                        rRef2.nCol,
+                                        MAXROW,
+                                        rRef2.nTab ), pFormCell );
+                                }
+                                else
+                                {   // RowName
+                                    pDoc->StartListeningArea( ScRange (
+                                        rRef1.nCol,
+                                        rRef1.nRow,
+                                        rRef1.nTab,
+                                        MAXCOL,
+                                        rRef2.nRow,
+                                        rRef2.nTab ), pFormCell );
+                                }
+                            }
+                            else
+                            {
+                                pDoc->StartListeningArea( ScRange (
+                                    rRef1.nCol,
+                                    rRef1.nRow,
+                                    rRef1.nTab,
+                                    rRef2.nCol,
+                                    rRef2.nRow,
+                                    rRef2.nTab ), pFormCell );
+                            }
+                        }
+                    break;
+                    default:
+                        ;   // nothing
+                }
+            }
+        }
+        pFormCell->SetNeedsListening( false);
+    }
+}
+
+//  pArr gesetzt -> Referenzen von anderer Zelle nehmen
+// Then aPos must also be commited
+
+void ScFormulaCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr,
+        ScAddress aCellPos )
+{
+    if ( eCellType == CELLTYPE_FORMULA && !pDoc->IsClipOrUndo()
+            && !((ScFormulaCell*)this)->IsInChangeTrack()
+        )
+    {
+        pDoc->SetDetectiveDirty(true);  // It has changed something
+
+        ScFormulaCell* pFormCell = (ScFormulaCell*)this;
+        if( pFormCell->GetCode()->IsRecalcModeAlways() )
+            pDoc->EndListeningArea( BCA_LISTEN_ALWAYS, pFormCell );
+        else
+        {
+            if (!pArr)
+            {
+                pArr = pFormCell->GetCode();
+                aCellPos = pFormCell->aPos;
+            }
+            pArr->Reset();
+            ScToken* t;
+            while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
+            {
+                StackVar eType = t->GetType();
+                ScSingleRefData& rRef1 = t->GetSingleRef();
+                ScSingleRefData& rRef2 = (eType == svDoubleRef ?
+                    t->GetDoubleRef().Ref2 : rRef1);
+                switch( eType )
+                {
+                    case svSingleRef:
+                        rRef1.CalcAbsIfRel( aCellPos );
+                        if ( rRef1.Valid() )
+                        {
+                            pDoc->EndListeningCell(
+                                ScAddress( rRef1.nCol,
+                                           rRef1.nRow,
+                                           rRef1.nTab ), pFormCell );
+                        }
+                    break;
+                    case svDoubleRef:
+                        t->CalcAbsIfRel( aCellPos );
+                        if ( rRef1.Valid() && rRef2.Valid() )
+                        {
+                            if ( t->GetOpCode() == ocColRowNameAuto )
+                            {   // automagically
+                                if ( rRef1.IsColRel() )
+                                {   // ColName
+                                    pDoc->EndListeningArea( ScRange (
+                                        rRef1.nCol,
+                                        rRef1.nRow,
+                                        rRef1.nTab,
+                                        rRef2.nCol,
+                                        MAXROW,
+                                        rRef2.nTab ), pFormCell );
+                                }
+                                else
+                                {   // RowName
+                                    pDoc->EndListeningArea( ScRange (
+                                        rRef1.nCol,
+                                        rRef1.nRow,
+                                        rRef1.nTab,
+                                        MAXCOL,
+                                        rRef2.nRow,
+                                        rRef2.nTab ), pFormCell );
+                                }
+                            }
+                            else
+                            {
+                                pDoc->EndListeningArea( ScRange (
+                                    rRef1.nCol,
+                                    rRef1.nRow,
+                                    rRef1.nTab,
+                                    rRef2.nCol,
+                                    rRef2.nRow,
+                                    rRef2.nTab ), pFormCell );
+                            }
+                        }
+                    break;
+                    default:
+                        ;   // nothing
+                }
+            }
+        }
+    }
+}
+
 // ============================================================================
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index fb5e261..8e6fb19 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -84,7 +84,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
 
             if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() )
             {
-                pOldCell->EndListeningTo( pDocument );
+                static_cast<ScFormulaCell*>(pOldCell)->EndListeningTo( pDocument );
                 // If in EndListening NoteCell is destroyed in same Col
                 if ( nIndex >= maItems.size() || maItems[nIndex].nRow != nRow )
                     Search(nRow, nIndex);
@@ -110,8 +110,10 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
     // After Import we call CalcAfterLoad and in there Listening.
     if ( !(pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc()) )
     {
-        pNewCell->StartListeningTo( pDocument );
         CellType eCellType = pNewCell->GetCellType();
+        if (eCellType == CELLTYPE_FORMULA)
+            static_cast<ScFormulaCell*>(pNewCell)->StartListeningTo(pDocument);
+
         // A note cell is only created by StartListeningCell when loading,
         // triggering Formula cells must be dirty anyway.
         if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_NOTE) )
@@ -171,7 +173,8 @@ void ScColumn::Delete( SCROW nRow )
             maScriptTypes.set_empty(nRow, nRow);
             // Should we free memory here (delta)? It'll be slower!
         }
-        pCell->EndListeningTo( pDocument );
+        if (pCell->GetCellType() == CELLTYPE_FORMULA)
+            static_cast<ScFormulaCell*>(pCell)->EndListeningTo(pDocument);
         pCell->Delete();
         bDirtyGroups = true;
 
@@ -190,7 +193,8 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
         ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), pCell));
     pNoteCell->Delete();
     maItems.erase(maItems.begin() + nIndex);
-    pCell->EndListeningTo( pDocument );
+    if (pCell->GetCellType() == CELLTYPE_FORMULA)
+        static_cast<ScFormulaCell*>(pCell)->EndListeningTo(pDocument);
     pCell->Delete();
 
     bDirtyGroups = true;
@@ -1446,7 +1450,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
 
                 if ( pOldCell->GetCellType() == CELLTYPE_FORMULA )
                 {
-                    pOldCell->EndListeningTo( pDocument );
+                    static_cast<ScFormulaCell*>(pOldCell)->EndListeningTo(pDocument);
                     // If in EndListening NoteCell destroyed in same in gleicher Col
                     if ( i >= maItems.size() || maItems[i].nRow != nRow )
                         Search(nRow, i);
@@ -1460,7 +1464,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
 
                 if ( pNewCell->GetCellType() == CELLTYPE_FORMULA )
                 {
-                    pNewCell->StartListeningTo( pDocument );
+                    static_cast<ScFormulaCell*>(pNewCell)->StartListeningTo(pDocument);
                     ((ScFormulaCell*)pNewCell)->SetDirty();
                 }
                 else


More information about the Libreoffice-commits mailing list