diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-27 21:07:40 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-28 01:12:50 -0400 |
commit | 96228fa3ec1ac4aaf648f791d9249418b1213f1a (patch) | |
tree | 3840ecd44f501c71d69548e21af86d8b6be13f36 | |
parent | 49f9492358944b45cb9878aea0d6158df8301869 (diff) |
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
-rw-r--r-- | sc/inc/cell.hxx | 19 | ||||
-rw-r--r-- | sc/source/core/data/cell.cxx | 173 | ||||
-rw-r--r-- | sc/source/core/data/cell2.cxx | 172 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 16 |
4 files changed, 191 insertions, 189 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index c3443d269f02..b0919a66213a 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 03fbe680c352..f732019c5e83 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 297f8d020f80..a68203fca223 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 fb5e26119681..8e6fb19467b9 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 |