diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-03 15:05:51 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-09 13:34:31 -0400 |
commit | 59f38babd074cc0b835a5d2a1c81af013dba0deb (patch) | |
tree | 6a9fd62c6b8eabe939845e85f3dd5942963cc51b /sc | |
parent | ff4731fb89f3b9d394c3826ab8dbe9d77df90a5a (diff) |
Remove broadcaster from ScBaseCell, remove ScNoteCell and CELLTYPE_NOTE...
and Calc is now officially broken. Let's start fixing this bit by bit...
Change-Id: I383c88245fe1e573666da636c6a8ca8815352ce7
Diffstat (limited to 'sc')
35 files changed, 204 insertions, 565 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index 7b7019cc1ada..ef7c2f731b21 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -69,17 +69,6 @@ public: Returns false for formula cells returning nothing, use HasEmptyData() for that. */ bool IsBlank() const; - /** Returns true, if the cell contains a broadcaster. */ - inline bool HasBroadcaster() const { return mpBroadcaster != 0; } - /** Returns the pointer to the cell broadcaster. */ - inline SvtBroadcaster* GetBroadcaster() const { return mpBroadcaster; } - /** Takes ownership of the passed cell broadcaster. */ - void TakeBroadcaster( SvtBroadcaster* pBroadcaster ); - /** Returns and forgets the own cell broadcaster. Caller takes ownership! */ - SvtBroadcaster* ReleaseBroadcaster(); - /** Deletes the own cell broadcaster. */ - void DeleteBroadcaster(); - /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been created due to reference to empty cell). */ bool HasEmptyData() const; @@ -90,33 +79,10 @@ public: private: ScBaseCell& operator=( const ScBaseCell& ); -private: - SvtBroadcaster* mpBroadcaster; /// Broadcaster for changed values. Cell takes ownership! - protected: sal_uInt8 eCellType; // enum CellType - sal_uInt8 spart Speicher }; -// ============================================================================ - -class ScNoteCell : public ScBaseCell -{ -public: -#ifdef USE_MEMPOOL - DECL_FIXEDMEMPOOL_NEWDEL( ScNoteCell ) -#endif - - /** Cell takes ownership of the passed broadcaster. */ - explicit ScNoteCell( SvtBroadcaster* pBC = 0 ); - -#if OSL_DEBUG_LEVEL > 0 - ~ScNoteCell(); -#endif - -private: - ScNoteCell( const ScNoteCell& ); -}; - class ScValueCell : public ScBaseCell { public: diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index ed1392a6936f..907074db06f7 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -119,8 +119,8 @@ struct ColDoubleEntry class ScColumn { // Broadcaster storage container - typedef mdds::mtv::custom_block_func1<sc::element_type_broadcaster, sc::custom_broadcaster_block> BroadcasterBlkFunc; - typedef mdds::multi_type_vector<BroadcasterBlkFunc> BroadcasterStoreType; + typedef mdds::mtv::custom_block_func1<sc::element_type_broadcaster, sc::custom_broadcaster_block> BCBlkFunc; + typedef mdds::multi_type_vector<BCBlkFunc> BCStoreType; typedef mdds::multi_type_vector<mdds::mtv::element_block_func> TextWidthType; typedef mdds::multi_type_vector<mdds::mtv::element_block_func> ScriptType; @@ -133,7 +133,7 @@ class ScColumn // Script types are stored as unsigned char. ScriptType maScriptTypes; - BroadcasterStoreType maBroadcasters; + BCStoreType maBroadcasters; SCCOL nCol; SCTAB nTab; @@ -473,6 +473,8 @@ public: void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat ); + SvtBroadcaster* GetBroadcaster( SCROW nRow ); + private: const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 0920dd5e71ba..79a062681f77 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1967,6 +1967,8 @@ private: // CLOOK-Impl-methods ScDocument* mpDoc; }; + SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ); + bool TableExists( SCTAB nTab ) const; void MergeNumberFormatter(ScDocument* pSrcDoc); diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 0ef1bd8fdc3c..f823232a488a 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -286,7 +286,6 @@ enum CellType CELLTYPE_VALUE, CELLTYPE_STRING, CELLTYPE_FORMULA, - CELLTYPE_NOTE, CELLTYPE_EDIT, #if OSL_DEBUG_LEVEL > 0 CELLTYPE_DESTROYED diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index c090f8bb313f..c7b3498d726c 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -831,6 +831,8 @@ public: ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow ); + SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ); + /** 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/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx index 1dca11e62afe..ab03a959707b 100644 --- a/sc/source/core/data/autonamecache.cxx +++ b/sc/source/core/data/autonamecache.cxx @@ -81,7 +81,6 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_NOTE: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: #endif diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 0bde4bf2080b..b5c8d33cff8e 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -29,26 +29,22 @@ #ifdef USE_MEMPOOL IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell ) IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell ) #endif // ============================================================================ ScBaseCell::ScBaseCell( CellType eNewType ) : - mpBroadcaster( 0 ), eCellType( sal::static_int_cast<sal_uInt8>(eNewType) ) { } ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : - mpBroadcaster( 0 ), eCellType( rCell.eCellType ) { } ScBaseCell::~ScBaseCell() { - delete mpBroadcaster; OSL_ENSURE( eCellType == CELLTYPE_DESTROYED, "BaseCell Destructor" ); } @@ -66,8 +62,6 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons return new ScEditCell(static_cast<const ScEditCell&>(rSrcCell), rDestDoc, rDestPos); case CELLTYPE_FORMULA: return new ScFormulaCell( static_cast< const ScFormulaCell& >( rSrcCell ), rDestDoc, rDestPos, nCloneFlags ); - case CELLTYPE_NOTE: - return new ScNoteCell; default:; } OSL_FAIL( "lclCloneCell - unknown cell type" ); @@ -106,9 +100,6 @@ void ScBaseCell::Delete() case CELLTYPE_FORMULA: delete (ScFormulaCell*) this; break; - case CELLTYPE_NOTE: - delete (ScNoteCell*) this; - break; default: OSL_FAIL("Attempt to Delete() an unknown CELLTYPE"); break; @@ -117,36 +108,13 @@ void ScBaseCell::Delete() bool ScBaseCell::IsBlank() const { - if(eCellType == CELLTYPE_NOTE) - return true; - return false; } -void ScBaseCell::TakeBroadcaster( SvtBroadcaster* pBroadcaster ) -{ - delete mpBroadcaster; - mpBroadcaster = pBroadcaster; -} - -SvtBroadcaster* ScBaseCell::ReleaseBroadcaster() -{ - SvtBroadcaster* pBroadcaster = mpBroadcaster; - mpBroadcaster = 0; - return pBroadcaster; -} - -void ScBaseCell::DeleteBroadcaster() -{ - DELETEZ( mpBroadcaster ); -} - bool ScBaseCell::HasEmptyData() const { switch ( eCellType ) { - case CELLTYPE_NOTE : - return true; case CELLTYPE_FORMULA : return ((ScFormulaCell*)this)->IsEmpty(); default: @@ -201,21 +169,6 @@ OUString ScBaseCell::GetStringData() const return aStr; } -ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) : - ScBaseCell( CELLTYPE_NOTE ) -{ - TakeBroadcaster( pBC ); -} - -#if OSL_DEBUG_LEVEL > 0 -ScNoteCell::~ScNoteCell() -{ - eCellType = CELLTYPE_DESTROYED; -} -#endif - -// ============================================================================ - ScValueCell::ScValueCell( double fValue ) : ScBaseCell( CELLTYPE_VALUE ), mfValue( fValue ) diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index 588ccfbc17e9..17a426278679 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -24,8 +24,6 @@ CellType adjustCellType( CellType eOrig ) { switch (eOrig) { - case CELLTYPE_NOTE: - return CELLTYPE_NONE; case CELLTYPE_EDIT: return CELLTYPE_STRING; default: @@ -354,7 +352,7 @@ bool ScCellValue::hasNumeric() const bool ScCellValue::isEmpty() const { - return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE; + return meType == CELLTYPE_NONE; } bool ScCellValue::equalsWithoutFormat( const ScCellValue& r ) const @@ -498,7 +496,7 @@ OUString ScRefCellValue::getString() bool ScRefCellValue::isEmpty() const { - return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE; + return meType == CELLTYPE_NONE; } bool ScRefCellValue::hasEmptyValue() diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index c98cc396288c..188932be6078 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -843,23 +843,6 @@ void ScColumn::ReserveSize( SCSIZE nSize ) maItems.reserve(nSize); } - -namespace { - -/** Moves broadcaster from old cell to new cell if exists, otherwise creates a new note cell. */ -void lclTakeBroadcaster( ScBaseCell*& rpCell, SvtBroadcaster* pBC ) -{ - if( pBC ) - { - if( rpCell ) - rpCell->TakeBroadcaster( pBC ); - else - rpCell = new ScNoteCell( pBC ); - } -} - -} // namespace - // SwapRow for sorting void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) { @@ -907,9 +890,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) // simple swap if no formula cells present if ( !pFmlaCell1 && !pFmlaCell2 ) { - // remember cell broadcasters, must remain at old position - SvtBroadcaster* pBC1 = pCell1->ReleaseBroadcaster(); - if ( pCell2 ) { /* Both cells exist, no formula cells involved, a simple swap can @@ -917,10 +897,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) maItems[nIndex1].pCell = pCell2; maItems[nIndex2].pCell = pCell1; - SvtBroadcaster* pBC2 = pCell2->ReleaseBroadcaster(); - pCell1->TakeBroadcaster( pBC2 ); - pCell2->TakeBroadcaster( pBC1 ); - // Swap text width values. unsigned short nVal1 = maTextWidths.get<unsigned short>(nRow1); unsigned short nVal2 = maTextWidths.get<unsigned short>(nRow2); @@ -937,19 +913,10 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) // Only cell 1 exists; cell 2 is empty. Move cell 1 from to row // 2. - ScNoteCell* pDummyCell = pBC1 ? new ScNoteCell( pBC1 ) : 0; - if ( pDummyCell ) - { - // insert dummy note cell (without note) containing old broadcaster - maItems[nIndex1].pCell = pDummyCell; - } - else - { - // remove ColEntry at old position - maItems.erase( maItems.begin() + nIndex1 ); - maTextWidths.set_empty(nRow1, nRow1); - maScriptTypes.set_empty(nRow1, nRow1); - } + // remove ColEntry at old position + maItems.erase( maItems.begin() + nIndex1 ); + maTextWidths.set_empty(nRow1, nRow1); + maScriptTypes.set_empty(nRow1, nRow1); // Empty text width at the cell 1 position. For now, we don't // transfer the old value to the cell 2 position since Insert() is @@ -1012,12 +979,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) pNew1 = pCell2->Clone( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); } - // move old broadcasters new cells at the same old position - SvtBroadcaster* pBC1 = pCell1->ReleaseBroadcaster(); - lclTakeBroadcaster( pNew1, pBC1 ); - SvtBroadcaster* pBC2 = pCell2 ? pCell2->ReleaseBroadcaster() : 0; - lclTakeBroadcaster( pNew2, pBC2 ); - /* Insert the new cells. Old cell has to be deleted, if there is no new cell (call to Insert deletes old cell by itself). */ if ( !pNew1 ) @@ -1245,14 +1206,13 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) for (i = 0; i < nDelCount; i++) { - ScBaseCell* pCell = ppDelCells[i]; - OSL_ENSURE( pCell->IsBlank(), "visible cell moved away" ); - SvtBroadcaster* pBC = pCell->GetBroadcaster(); + SCROW nDelRow = pDelRows[i]; + SvtBroadcaster* pBC = GetBroadcaster(nDelRow); if (pBC) { MoveListeners( *pBC, pDelRows[i] - nSize ); - pCell->DeleteBroadcaster(); - pCell->Delete(); + maBroadcasters.set_empty(nDelRow, nDelRow); + ppDelCells[i]->Delete(); } } @@ -1773,7 +1733,6 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) ScAddress aAdr( nCol, 0, nTab ); ScHint aHint( SC_HINT_DYING, aAdr, NULL ); // areas only ScAddress& rAddress = aHint.GetAddress(); - ScNoteCell* pNoteCell = new ScNoteCell; // Dummy like in DeleteRange // must iterate backwards, because indexes of following cells become invalid bool bErased = false; @@ -1783,8 +1742,6 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) nStartPos = (*it).first; nStopPos = (*it).second; for (i=nStartPos; i<nStopPos; ++i) - maItems[i].pCell = pNoteCell; // Assign the dumpy cell instance to all slots. - for (i=nStartPos; i<nStopPos; ++i) { rAddress.SetRow( maItems[i].nRow ); pDocument->AreaBroadcast( aHint ); @@ -1793,7 +1750,6 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) maItems.erase(maItems.begin() + nStartPos, maItems.begin() + nStopPos); bErased = true; } - pNoteCell->Delete(); // Delete the dummy cell instance. if (bErased) { @@ -2175,7 +2131,7 @@ void ScColumn::SetDirty( const ScRange& rRange ) else { aHint.GetAddress().SetRow( nRow ); - aHint.SetBroadcaster(pCell->GetBroadcaster()); + aHint.SetBroadcaster(maBroadcasters.get<SvtBroadcaster*>(nRow)); pDocument->Broadcast( aHint ); } nIndex++; @@ -2204,7 +2160,7 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange ) else { aHint.GetAddress().SetRow( nRow ); - aHint.SetBroadcaster(pCell->GetBroadcaster()); + aHint.SetBroadcaster(maBroadcasters.get<SvtBroadcaster*>(nRow)); pDocument->Broadcast( aHint ); } nIndex++; diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index bad84e9e5469..817fca09b7c9 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -61,6 +61,8 @@ #include <math.h> +#include <boost/scoped_ptr.hpp> + #if DEBUG_COLUMN_STORAGE #include "columniterator.hxx" #include <iostream> @@ -902,7 +904,7 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r void ScColumn::RemoveAutoSpellObj() { - ScTabEditEngine* pEngine = NULL; + boost::scoped_ptr<ScTabEditEngine> pEngine; for (SCSIZE i=0; i<maItems.size(); i++) if ( maItems[i].pCell->GetCellType() == CELLTYPE_EDIT ) @@ -918,29 +920,26 @@ void ScColumn::RemoveAutoSpellObj() // test for attributes if ( !pEngine ) - pEngine = new ScTabEditEngine(pDocument); + pEngine.reset(new ScTabEditEngine(pDocument)); pEngine->SetText( *pData ); - ScEditAttrTester aTester( pEngine ); + ScEditAttrTester aTester(pEngine.get()); if ( aTester.NeedsObject() ) // only remove spelling errors { pOldCell->SetData(pEngine->CreateTextObject()); } else // create a string { - String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); + OUString aText = ScEditUtil::GetSpaceDelimitedString(*pEngine); ScBaseCell* pNewCell = new ScStringCell( aText ); - pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); maItems[i].pCell = pNewCell; delete pOldCell; } } - - delete pEngine; } void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) { - ScFieldEditEngine* pEngine = NULL; + boost::scoped_ptr<ScFieldEditEngine> pEngine; SCSIZE i; Search( nStartRow, i ); @@ -958,7 +957,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) // test for attributes if ( !pEngine ) { - pEngine = new ScFieldEditEngine(pDocument, pDocument->GetEditPool()); + pEngine.reset(new ScFieldEditEngine(pDocument, pDocument->GetEditPool())); // EE_CNTRL_ONLINESPELLING if there are errors already pEngine->SetControlWord( pEngine->GetControlWord() | EE_CNTRL_ONLINESPELLING ); pDocument->ApplyAsianEditSettings( *pEngine ); @@ -994,13 +993,10 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) { String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); - pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); maItems[i].pCell = pNewCell; delete pOldCell; } } - - delete pEngine; } // ========================================================================================= @@ -1522,18 +1518,8 @@ void ScColumn::SetCell(SCROW nRow, ScBaseCell* pNewCell) if (Search(nRow, nIndex)) { ScBaseCell* pOldCell = maItems[nIndex].pCell; - - // move broadcaster and note to new cell, if not existing in new cell - if (pOldCell->HasBroadcaster() && !pNewCell->HasBroadcaster()) - pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() ) - { 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); - } pOldCell->Delete(); maItems[nIndex].pCell = pNewCell; } @@ -1550,6 +1536,11 @@ void ScColumn::SetCell(SCROW nRow, ScBaseCell* pNewCell) } } +SvtBroadcaster* ScColumn::GetBroadcaster(SCROW nRow) +{ + return maBroadcasters.get<SvtBroadcaster*>(nRow); +} + unsigned short ScColumn::GetTextWidth(SCROW nRow) const { return maTextWidths.get<unsigned short>(nRow); @@ -1883,83 +1874,46 @@ void ScColumn::FindUsed( SCROW nStartRow, SCROW nEndRow, bool* pUsed ) const void ScColumn::StartListening( SvtListener& rLst, SCROW nRow ) { - SvtBroadcaster* pBC = NULL; - ScBaseCell* pCell; - - SCSIZE nIndex; - if (Search(nRow,nIndex)) - { - pCell = maItems[nIndex].pCell; - pBC = pCell->GetBroadcaster(); - } - else - { - pCell = new ScNoteCell; - Insert(nRow, pCell); - } - - if (!pBC) - { - pBC = new SvtBroadcaster; - pCell->TakeBroadcaster(pBC); - } + SvtBroadcaster* pBC = new SvtBroadcaster; + maBroadcasters.set(nRow, pBC); rLst.StartListening(*pBC); } void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow ) { - SvtBroadcaster* pBC = NULL; - ScBaseCell* pCell; - - SCSIZE nIndex; - if (Search(nDestRow,nIndex)) - { - pCell = maItems[nIndex].pCell; - pBC = pCell->GetBroadcaster(); - } - else - { - pCell = new ScNoteCell; - Insert(nDestRow, pCell); - } + // Move listeners from the source position to the destination position. + if (!rSource.HasListeners()) + // No listeners to relocate. Bail out. + return; - if (!pBC) + // See if the destination position already has a broadcaster, if not, create one. + SvtBroadcaster* pBC = NULL; + if (maBroadcasters.is_empty(nDestRow)) { pBC = new SvtBroadcaster; - pCell->TakeBroadcaster(pBC); + maBroadcasters.set(nDestRow, pBC); } + else + pBC = maBroadcasters.get<SvtBroadcaster*>(nDestRow); - if (rSource.HasListeners()) + SvtListenerIter aIter(rSource); + for (SvtListener* pLst = aIter.GoStart(); pLst; pLst = aIter.GoNext()) { - SvtListenerIter aIter( rSource); - for (SvtListener* pLst = aIter.GoStart(); pLst; pLst = aIter.GoNext()) - { - pLst->StartListening( *pBC); - pLst->EndListening( rSource); - } + pLst->StartListening(*pBC); + pLst->EndListening(rSource); } } void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) { - SCSIZE nIndex; - if (Search(nRow,nIndex)) - { - ScBaseCell* pCell = maItems[nIndex].pCell; - SvtBroadcaster* pBC = pCell->GetBroadcaster(); - if (pBC) - { - rLst.EndListening(*pBC); + SvtBroadcaster* pBC = maBroadcasters.get<SvtBroadcaster*>(nRow); + if (!pBC) + return; - if (!pBC->HasListeners()) - { - if (pCell->IsBlank()) - DeleteAtIndex(nIndex); - else - pCell->DeleteBroadcaster(); - } - } - } + rLst.EndListening(*pBC); + if (!pBC->HasListeners()) + // There is no more listeners for this cell. Remove the broadcaster. + maBroadcasters.set_empty(nRow, nRow); } void ScColumn::CompileDBFormula() @@ -2036,10 +1990,6 @@ static void lcl_UpdateSubTotal( ScFunctionData& rData, const ScBaseCell* pCell ) } } break; - case CELLTYPE_NOTE: - bCell = false; - break; - // nothing for strings default: { // added to avoid warnings diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 233433032c4f..8cd890ec60e4 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -75,17 +75,6 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) 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) ) - { - if ( eCellType == CELLTYPE_FORMULA ) - ((ScFormulaCell*)pNewCell)->SetDirty(); - else - pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, - ScAddress( nCol, nRow, nTab ), pNewCell->GetBroadcaster()) ); - } } } @@ -112,32 +101,22 @@ void ScColumn::Append( SCROW nRow, ScBaseCell* pCell ) void ScColumn::Delete( SCROW nRow ) { SCSIZE nIndex; + if (!Search(nRow, nIndex)) + return; - if (Search(nRow, nIndex)) - { - ScBaseCell* pCell = maItems[nIndex].pCell; - ScNoteCell* pNoteCell = new ScNoteCell; - maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret - pDocument->Broadcast( ScHint( SC_HINT_DYING, - ScAddress( nCol, nRow, nTab ), pCell->GetBroadcaster())); - if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() ) - { - pNoteCell->TakeBroadcaster( pBC ); - } - else - { - pNoteCell->Delete(); - maItems.erase( maItems.begin() + nIndex); - maTextWidths.set_empty(nRow, nRow); - maScriptTypes.set_empty(nRow, nRow); - // Should we free memory here (delta)? It'll be slower! - } - if (pCell->GetCellType() == CELLTYPE_FORMULA) - static_cast<ScFormulaCell*>(pCell)->EndListeningTo(pDocument); - pCell->Delete(); + ScBaseCell* pCell = maItems[nIndex].pCell; + pDocument->Broadcast( + ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), GetBroadcaster(nRow))); - CellStorageModified(); - } + maItems.erase(maItems.begin() + nIndex); + maTextWidths.set_empty(nRow, nRow); + maScriptTypes.set_empty(nRow, nRow); + // Should we free memory here (delta)? It'll be slower! + if (pCell->GetCellType() == CELLTYPE_FORMULA) + static_cast<ScFormulaCell*>(pCell)->EndListeningTo(pDocument); + pCell->Delete(); + + CellStorageModified(); } @@ -145,11 +124,8 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex ) { ScBaseCell* pCell = maItems[nIndex].pCell; SCROW nRow = maItems[nIndex].nRow; - ScNoteCell* pNoteCell = new ScNoteCell; - maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret pDocument->Broadcast( - ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster())); - pNoteCell->Delete(); + ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), maBroadcasters.get<SvtBroadcaster*>(nRow))); maItems.erase(maItems.begin() + nIndex); if (pCell->GetCellType() == CELLTYPE_FORMULA) static_cast<ScFormulaCell*>(pCell)->EndListeningTo(pDocument); @@ -191,30 +167,24 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) sal_Bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // Avoid calculating it multiple times - sal_Bool bFound=false; + bool bFound = false; SCROW nEndRow = nStartRow + nSize - 1; SCSIZE nStartIndex = 0; SCSIZE nEndIndex = 0; SCSIZE i; + maBroadcasters.set_empty(nStartRow, nEndRow); + for ( i = nFirstIndex; i < maItems.size() && maItems[i].nRow <= nEndRow; i++ ) { if (!bFound) { nStartIndex = i; - bFound = sal_True; + bFound = true; } nEndIndex = i; - - ScBaseCell* pCell = maItems[i].pCell; - SvtBroadcaster* pBC = pCell->GetBroadcaster(); - if (pBC) - { - // Now returns invalid reference; direct References are not moved - pCell->DeleteBroadcaster(); - // We delete empty Broadcaster in DeleteRange - } } + if (bFound) { DeleteRange( nStartIndex, nEndIndex, IDF_CONTENTS ); @@ -319,10 +289,6 @@ bool checkDeleteCellByFlag( case CELLTYPE_FORMULA: bDelete = (nDelFlag & IDF_FORMULA) != 0; break; - case CELLTYPE_NOTE: - // do note delete note cell with broadcaster - bDelete = !rEntry.pCell->GetBroadcaster(); - break; default:; // added to avoid warnings } @@ -349,12 +315,10 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe RemovedSegments_t aRemovedSegments(nStartIndex, maItems.size(), false); SCSIZE nFirst = nStartIndex; - // dummy replacement for old cells, to prevent that interpreter uses old cell - boost::scoped_ptr<ScNoteCell> pDummyCell(new ScNoteCell); - for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { - if (((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) && !maItems[ nIdx ].pCell->GetBroadcaster()) + SCROW nRow = maItems[nIdx].nRow; + if (((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) && maBroadcasters.is_empty(nRow)) { // all content is deleted and cell does not contain broadcaster @@ -365,14 +329,8 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe aDelCells.push_back( static_cast< ScFormulaCell* >( pOldCell ) ); } else - { - // interpret in broadcast must not use the old cell - maItems[ nIdx ].pCell = pDummyCell.get(); - aHint.GetAddress().SetRow( maItems[ nIdx ].nRow ); - aHint.SetBroadcaster(pOldCell->GetBroadcaster()); - pDocument->Broadcast( aHint ); pOldCell->Delete(); - } + continue; } @@ -392,51 +350,14 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe if (bDelete) { - // Try to create a replacement "note" cell if broadcaster exists. - ScNoteCell* pNoteCell = NULL; - SvtBroadcaster* pBC = pOldCell->GetBroadcaster(); - if (pBC && pBC->HasListeners()) - { - // NOTE: the broadcaster here is transferred and released only - // if it has listeners! If it does not, it will simply be - // deleted when the cell is deleted and no replacement cell is - // created. - pNoteCell = new ScNoteCell(pBC); - pOldCell->ReleaseBroadcaster(); - } - // remove cell entry in cell item list - SCROW nOldRow = maItems[nIdx].nRow; - if (pNoteCell) - { - // replace old cell with the replacement note cell - maItems[nIdx].pCell = pNoteCell; - // ... so it's not really deleted - bDelete = false; - } - else - maItems[nIdx].pCell = pDummyCell.get(); - if (eCellType == CELLTYPE_FORMULA) { // Cache formula cells (will be deleted later), delete cell of other type. aDelCells.push_back(static_cast<ScFormulaCell*>(pOldCell)); } else - { - aHint.GetAddress().SetRow(nOldRow); - SvtBroadcaster* pHintBC = NULL; - if (pNoteCell) - pHintBC = pNoteCell->GetBroadcaster(); - else if (pOldCell) - pHintBC = pOldCell->GetBroadcaster(); - aHint.SetBroadcaster(pHintBC); - pDocument->Broadcast(aHint); - if (pNoteCell != pOldCell) - { - pOldCell->Delete(); - } - } + pOldCell->Delete(); } if (!bDelete) @@ -498,27 +419,14 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe // NOTE: this actually may remove ScNoteCell entries from maItems if // the last listener is removed from a broadcaster. for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt ) - (*aIt)->EndListeningTo( pDocument ); - - // NOTE: the vector does not contain cells with broadcasters that have - // listeners. If it would, broadcasters that were deleted during - // EndListeningTo() would have to be released from these cells. - - // broadcast SC_HINT_DYING for all cells and delete them - for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt ) { - // A formula cell's broadcaster now is at the replacement cell, use - // that. If there is no cell anymore it means all listeners are - // gone for this formula cell and the replacement cell was removed - // from maItems. - SCSIZE nIndex; - ScBaseCell* pCell = (Search( (*aIt)->aPos.Row(), nIndex) ? maItems[nIndex].pCell : NULL); - aHint.SetBroadcaster(pCell ? pCell->GetBroadcaster() : NULL); - aHint.SetAddress( (*aIt)->aPos ); - pDocument->Broadcast( aHint ); + (*aIt)->EndListeningTo( pDocument ); (*aIt)->Delete(); } } + + // TODO: Broadcasting is temporarily removed from this method. Add it back + // once the broadcaster refactoring is finished. } @@ -652,23 +560,19 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nStartIndex < rColumn.maItems.size() && rColumn.maItems[nStartIndex].nRow <= nRow2-nDy ) { SCSIZE nEndIndex = nStartIndex; - if ( rColumn.maItems[nStartIndex].pCell->GetCellType() != CELLTYPE_NOTE ) - { - SCROW nStartRow = rColumn.maItems[nStartIndex].nRow; - SCROW nEndRow = nStartRow; - - // find consecutive non-empty cells - while ( nEndRow < nRow2-nDy && - nEndIndex+1 < rColumn.maItems.size() && - rColumn.maItems[nEndIndex+1].nRow == nEndRow+1 && - rColumn.maItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_NOTE ) - { - ++nEndIndex; - ++nEndRow; - } + SCROW nStartRow = rColumn.maItems[nStartIndex].nRow; + SCROW nEndRow = nStartRow; - rColumn.pAttrArray->CopyAreaSafe( nStartRow+nDy, nEndRow+nDy, nDy, *pAttrArray ); + // find consecutive non-empty cells + while ( nEndRow < nRow2-nDy && + nEndIndex+1 < rColumn.maItems.size() && + rColumn.maItems[nEndIndex+1].nRow == nEndRow+1 ) + { + ++nEndIndex; + ++nEndRow; } + + rColumn.pAttrArray->CopyAreaSafe( nStartRow+nDy, nEndRow+nDy, nDy, *pAttrArray ); nStartIndex = nEndIndex + 1; } } @@ -780,10 +684,6 @@ ScBaseCell* ScColumn::CloneCell( ScBaseCell& rSource = *maItems[nIndex].pCell; switch (rSource.GetCellType()) { - case CELLTYPE_NOTE: - // note will be cloned below - break; - case CELLTYPE_STRING: case CELLTYPE_EDIT: // note will be cloned below @@ -960,8 +860,8 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, CellType eSrcType = pSrc ? pSrc->GetCellType() : CELLTYPE_NONE; CellType eDestType = pDest ? pDest->GetCellType() : CELLTYPE_NONE; - sal_Bool bSrcEmpty = ( eSrcType == CELLTYPE_NONE || eSrcType == CELLTYPE_NOTE ); - sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_NOTE ); + bool bSrcEmpty = (eSrcType == CELLTYPE_NONE); + bool bDestEmpty = (eDestType == CELLTYPE_NONE); if ( bSkipEmpty && bDestEmpty ) // Restore original row { @@ -1060,10 +960,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, { if (pDest && !pNew) // Old cell present? { - if ( pDest->GetBroadcaster() ) - pNew = new ScNoteCell; // Take over Broadcaster - else - Delete(nRow); // -> Delete + Delete(nRow); // -> Delete } if (pNew) Insert(nRow, pNew); // Insert new one @@ -1139,21 +1036,23 @@ void ScColumn::StartNeededListeners() void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 ) { - if ( !maItems.empty() ) + if (maItems.empty()) + return; + + SCROW nRow; + SCSIZE nIndex; + if (!Search(nRow1, nIndex)) + return; + + while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRow2 ) { - SCROW nRow; - SCSIZE nIndex; - Search( nRow1, nIndex ); - while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRow2 ) - { - ScBaseCell* pCell = maItems[nIndex].pCell; - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) - ((ScFormulaCell*)pCell)->SetDirty(); - else - pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, - ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster())); - nIndex++; - } + ScBaseCell* pCell = maItems[nIndex].pCell; + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + ((ScFormulaCell*)pCell)->SetDirty(); + else + pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, + ScAddress(nCol, nRow, nTab), GetBroadcaster(nRow))); + nIndex++; } } @@ -1272,8 +1171,6 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if ( rString == aStr ) bIsText = true; break; - case CELLTYPE_NOTE : // Referenced via = Formula - break; default: if ( i == maItems.size() - 1 ) i = 0; @@ -1392,25 +1289,10 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if (Search(nRow, i)) { ScBaseCell* pOldCell = maItems[i].pCell; - SvtBroadcaster* pBC = pOldCell->ReleaseBroadcaster(); - if (pNewCell || pBC) + if (pNewCell) { - if(!pNewCell) - pNewCell = new ScNoteCell(); - - if (pBC) - { - pNewCell->TakeBroadcaster(pBC); - pLastFormulaTreeTop = 0; // Err527 Workaround - } - if ( pOldCell->GetCellType() == CELLTYPE_FORMULA ) - { 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); - } pOldCell->Delete(); maItems[i].pCell = pNewCell; // Replace @@ -1425,7 +1307,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, } else pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, - ScAddress(nCol, nRow, nTabP), pNewCell->GetBroadcaster())); + ScAddress(nCol, nRow, nTabP), GetBroadcaster(nRow))); } else { @@ -1525,11 +1407,6 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, std::vector<ScTy nValue = pFC->GetValue(); } break; - - // skip broadcaster cells - case CELLTYPE_NOTE: - continue; - default: ; } @@ -1710,13 +1587,8 @@ void ScColumn::GetString( SCROW nRow, OUString& rString ) const { ScRefCellValue aCell; aCell.assign(*maItems[nIndex].pCell); - if (aCell.meType != CELLTYPE_NOTE) - { - sal_uLong nFormat = GetNumberFormat( nRow ); - ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable())); - } - else - rString = EMPTY_OUSTRING; + sal_uLong nFormat = GetNumberFormat( nRow ); + ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable())); } else rString = EMPTY_OUSTRING; @@ -1755,13 +1627,8 @@ void ScColumn::GetInputString( SCROW nRow, OUString& rString ) const { ScRefCellValue aCell; aCell.assign(*maItems[nIndex].pCell); - if (aCell.meType != CELLTYPE_NOTE) - { - sal_uLong nFormat = GetNumberFormat( nRow ); - ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable())); - } - else - rString = OUString(); + sal_uLong nFormat = GetNumberFormat( nRow ); + ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable())); } else rString = OUString(); @@ -1936,31 +1803,28 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh { ScRefCellValue aCell; aCell.assign(*maItems[nIndex].pCell); - if (aCell.meType != CELLTYPE_NOTE) + Color* pColor; + sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr( + nRow, ATTR_VALUE_FORMAT ))->GetValue(); + ScCellFormat::GetString(aCell, nFormat, aString, &pColor, *pNumFmt); + sal_Int32 nLen; + if (bIsOctetTextEncoding) { - Color* pColor; - sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr( - nRow, ATTR_VALUE_FORMAT ))->GetValue(); - ScCellFormat::GetString(aCell, nFormat, aString, &pColor, *pNumFmt); - sal_Int32 nLen; - if (bIsOctetTextEncoding) + if (!aString.convertToString( &aOString, eCharSet, + RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)) { - if (!aString.convertToString( &aOString, eCharSet, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | - RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)) - { - // TODO: anything? this is used by the dBase export filter - // that throws an error anyway, but in case of another - // context we might want to indicate a conversion error - // early. - } - nLen = aOString.getLength(); + // TODO: anything? this is used by the dBase export filter + // that throws an error anyway, but in case of another + // context we might want to indicate a conversion error + // early. } - else - nLen = aString.getLength() * sizeof(sal_Unicode); - if ( nStringLen < nLen) - nStringLen = nLen; + nLen = aOString.getLength(); } + else + nLen = aString.getLength() * sizeof(sal_Unicode); + if ( nStringLen < nLen) + nStringLen = nLen; nIndex++; } } diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index c091cd592643..e889a9372b45 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1650,7 +1650,7 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const { CellType eCellType = mpDoc->GetCellType(rPos); - if (eCellType == CELLTYPE_NONE || eCellType == CELLTYPE_NOTE) + if (eCellType == CELLTYPE_NONE) // empty cell. return false; diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 173905ae51ea..b834a0c33b66 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1245,9 +1245,7 @@ ScBaseCell* ScQueryCellIterator::GetThis() (nRow = pCol->maItems[nColRow].nRow) <= mpParam->nRow2 ) { ScBaseCell* pCell = pCol->maItems[nColRow].pCell; - if ( pCell->GetCellType() == CELLTYPE_NOTE ) - ++nRow; - else if (bAllStringIgnore && pCell->HasStringData()) + if (bAllStringIgnore && pCell->HasStringData()) ++nRow; else { @@ -1559,8 +1557,6 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { SCSIZE nMid = (nLo+nHi)/2; SCSIZE i = nMid; - while (i <= nHi && pCol->maItems[i].pCell->GetCellType() == CELLTYPE_NOTE) - ++i; if (i > nHi) { if (nMid > 0) diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 37e4be0db04e..fa5f79edee73 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -69,7 +69,7 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, // as previously done in ScInterpreter::GetDouble double nTargetVal = 0.0; sal_uInt32 nFIndex = 0; - if (eFType == CELLTYPE_FORMULA && (eVType == CELLTYPE_VALUE || eVType == CELLTYPE_NOTE) && + if (eFType == CELLTYPE_FORMULA && (eVType == CELLTYPE_VALUE) && GetFormatTable()->IsNumberFormat(sValStr, nFIndex, nTargetVal)) { ScSingleRefData aRefData; diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 191ca7d8d4af..1af78e04e2c3 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -444,8 +444,9 @@ void ScDocument::TrackFormulas( sal_uLong nHintId ) pTrack = pFormulaTrack; do { - ScHint aHint( nHintId, pTrack->aPos, pTrack->GetBroadcaster() ); - if ( ( pBC = pTrack->GetBroadcaster() ) != NULL ) + pBC = GetBroadcaster(pTrack->aPos); + ScHint aHint(nHintId, pTrack->aPos, pBC); + if (pBC) pBC->Broadcast( aHint ); pBASM->AreaBroadcast( aHint ); // Repaint fuer bedingte Formate mit relativen Referenzen: diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 3a07d3fc05c9..7a2671901b60 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2202,6 +2202,14 @@ ScDocument::NumFmtMergeHandler::~NumFmtMergeHandler() mpDoc->pFormatExchangeList = NULL; } +SvtBroadcaster* ScDocument::GetBroadcaster( const ScAddress& rPos ) +{ + if (!TableExists(rPos.Tab())) + return NULL; + + return maTabs[rPos.Tab()]->GetBroadcaster(rPos.Col(), rPos.Row()); +} + bool ScDocument::TableExists( SCTAB nTab ) const { return ValidTab(nTab) && static_cast<size_t>(nTab) < maTabs.size() && maTabs[nTab]; diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 1e37c6deaa9e..8eb78e649127 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -381,11 +381,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX RowInfo* pThisRowInfo = &pRowInfo[nArrY]; CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX]; pInfo->maCell.assign(*pThisCol->maItems[nUIndex].pCell); - if (pInfo->maCell.meType != CELLTYPE_NOTE) - { - pThisRowInfo->bEmptyText = false; // Zeile nicht leer - pInfo->bEmptyCellText = false; // Zelle nicht leer - } + pThisRowInfo->bEmptyText = false; // Zeile nicht leer + pInfo->bEmptyCellText = false; // Zelle nicht leer ++nArrY; } ++nUIndex; diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 7abc2793faf0..37278d649ad8 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1390,7 +1390,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa ScBaseCell* pCell = NULL; while ( aColIter.Next( nCellRow, pCell ) ) { - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) + if (pCell) { rRow = nCellRow; return true; // Zelle gefunden @@ -1800,7 +1800,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d while (nMissing > 0 && nNewCol < MAXCOL) { ScBaseCell* pNextCell = aCol[nNewCol+1].GetCell(nRow); - if (pNextCell && pNextCell->GetCellType() != CELLTYPE_NOTE) + if (pNextCell) // Cell content in a next column ends display of this string. nMissing = 0; else @@ -2160,6 +2160,14 @@ ScRefCellValue ScTable::GetRefCellValue( SCCOL nCol, SCROW nRow ) return aCol[nCol].GetRefCellValue(nRow); } +SvtBroadcaster* ScTable::GetBroadcaster( SCCOL nCol, SCROW nRow ) +{ + if (!ValidColRow(nCol, nRow)) + return NULL; + + return aCol[nCol].GetBroadcaster(nRow); +} + void ScTable::DeleteConditionalFormat( sal_uLong nIndex ) { mpCondFormatList->erase(nIndex); diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index ec4e67bb4912..a668a2c9a166 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -377,18 +377,6 @@ short ScTable::CompareCell( sal_uInt16 nSort, short nRes = 0; CellType eType1 = CELLTYPE_NONE, eType2 = CELLTYPE_NONE; - if (pCell1) - { - eType1 = pCell1->GetCellType(); - if (eType1 == CELLTYPE_NOTE) - pCell1 = NULL; - } - if (pCell2) - { - eType2 = pCell2->GetCellType(); - if (eType2 == CELLTYPE_NOTE) - pCell2 = NULL; - } if (pCell1) { @@ -1367,7 +1355,7 @@ public: // Error cell is evaluated as string (for now). aCellStr = ScGlobal::GetErrorString(static_cast<ScFormulaCell*>(pCell)->GetErrCode()); } - else if (pCell->GetCellType() != CELLTYPE_NOTE) + else { sal_uLong nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow ); ScRefCellValue aCell; @@ -1660,8 +1648,7 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) ScSortInfo** ppInfo = pArray->GetFirstArray(); SCSIZE nValidCount = nCount; // keine Note-/Leerzellen zaehlen, sind ans Ende sortiert - while ( nValidCount > 0 && ( ppInfo[nValidCount-1]->pCell == NULL || - ppInfo[nValidCount-1]->pCell->GetCellType() == CELLTYPE_NOTE ) ) + while ( nValidCount > 0 && (ppInfo[nValidCount-1]->pCell == NULL) ) nValidCount--; // keine Strings zaehlen, sind zwischen Value und Leer while ( nValidCount > 0 diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 8b8b67ba5020..d63971e779df 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -1477,7 +1477,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, pProgress->SetStateOnPercent( ++nProgress ); } } - else if (eCellType != CELLTYPE_NOTE) + else { for (rInner = nIMin; rInner <= nIMax; rInner++) { diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index cbffff1560b4..852c2c04db57 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -1166,7 +1166,7 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p switch ( pCell->GetCellType() ) { case CELLTYPE_VALUE : - pDocument->Broadcast(ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster())); + pDocument->Broadcast(ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), GetBroadcaster(nCol, nRow))); break; case CELLTYPE_FORMULA : ((ScFormulaCell*)pCell)->SetDirty(); @@ -1209,7 +1209,7 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p { case CELLTYPE_VALUE : pDocument->Broadcast( - ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster())); + ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), GetBroadcaster(nCol, nRow))); break; case CELLTYPE_FORMULA : ((ScFormulaCell*)pCell)->SetDirty(); diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 729f91254663..17f62da32837 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -817,7 +817,7 @@ bool lcl_maybeReplaceCellString( ScColumn& rColObj, SCCOL& rCol, SCROW& rRow, OUString& rUndoStr, SCCOL nCol, SCROW nRow, const SvxSearchItem& rSearchItem) { ScBaseCell* pCell = rColObj.GetCell(nRow); - if (!pCell || pCell->GetCellType() == CELLTYPE_NOTE) + if (!pCell) { // empty cell found. rCol = nCol; @@ -1020,27 +1020,6 @@ bool ScTable::SearchRangeForAllEmptyCells( } } } - else if (pCell->GetCellType() == CELLTYPE_NOTE) - { - rMatchedRanges.Join(ScRange(nCol, nRow, nTab)); - bFound = true; - - if (bReplace) - { - if (pUndoDoc) - { - ScAddress aCellPos(nCol, nRow, nTab); - pUndoDoc->PutCell(aCellPos, pCell->Clone(*pUndoDoc, aCellPos)); - ScNotes* pNotes = pUndoDoc->GetNotes(nTab); - ScPostIt* pPostIt = maNotes.findByAddress(nCol, nRow); - if (pPostIt) - { - pNotes->insert(nCol, nRow, pPostIt->Clone(ScAddress(nCol, nRow, nTab), *pUndoDoc, ScAddress(nCol, nRow, nTab), true)); - } - } - aCol[nCol].SetString(nRow, nTab, rSearchItem.GetReplaceString(), pDocument->GetAddressConvention()); - } - } } } return bFound; diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 0c16240afa24..ff9f7cb7e7da 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2130,7 +2130,7 @@ void ScInterpreter::ScIsEmpty() // ScCountEmptyCells(). ScRefCellValue aCell; aCell.assign(*pDok, aAdr); - if ((aCell.meType == CELLTYPE_NONE) || (aCell.meType == CELLTYPE_NOTE)) + if (aCell.meType == CELLTYPE_NONE) nRes = 1; } break; @@ -2298,9 +2298,6 @@ void ScInterpreter::ScType() switch (aCell.meType) { // NOTE: this is Xcl nonsense! - case CELLTYPE_NOTE : - nType = 1; // empty cell is value (0) - break; case CELLTYPE_STRING : case CELLTYPE_EDIT : nType = 2; @@ -4129,7 +4126,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) if( eFunc == ifCOUNT2 ) { CellType eCellType = aCell.meType; - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) + if (eCellType != CELLTYPE_NONE) nCount++; if ( nGlobalError ) nGlobalError = 0; @@ -5399,7 +5396,7 @@ void ScInterpreter::ScCountEmptyCells() ScAddress aAdr; PopSingleRef( aAdr ); eCellType = pDok->GetCellType(aAdr); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) + if (eCellType != CELLTYPE_NONE) nCount = 1; } break; @@ -7314,18 +7311,10 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) } else { - if (aCell.meType == CELLTYPE_NOTE) - { - rItem.meType = ScQueryEntry::ByValue; - rItem.mfVal = 0.0; - } - else - { - OUString aStr; - GetCellString(aStr, aCell); - rItem.meType = ScQueryEntry::ByString; - rItem.maString = aStr; - } + OUString aStr; + GetCellString(aStr, aCell); + rItem.meType = ScQueryEntry::ByString; + rItem.maString = aStr; } } break; diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 40d5d83444ae..adbf2685cb9e 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -498,7 +498,6 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& } break; case CELLTYPE_NONE: - case CELLTYPE_NOTE: fValue = 0.0; // empty or broadcaster cell break; #if OSL_DEBUG_LEVEL > 0 diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx index 704edb1a8770..e4b5a77dc123 100644 --- a/sc/source/filter/dif/difexp.cxx +++ b/sc/source/filter/dif/difexp.cxx @@ -163,7 +163,6 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc switch (aCell.meType) { case CELLTYPE_NONE: - case CELLTYPE_NOTE: aOS.appendAscii(pEmptyData); break; case CELLTYPE_VALUE: diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 4851f2069810..9c293807f7f7 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2383,7 +2383,6 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : OSL_FAIL( "XclExpCellTable::XclExpCellTable - unknown cell type" ); // run-through! case CELLTYPE_NONE: - case CELLTYPE_NOTE: { xCell.reset( new XclExpBlankCell( GetRoot(), aXclPos, nLastXclCol, pPattern, nMergeBaseXFId ) ); diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 9cf0b3e73e8f..424f1d9a43a4 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -1138,9 +1138,6 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) Color* pColor; switch (aCell.meType) { - case CELLTYPE_NOTE : - // nothing - break; case CELLTYPE_EDIT : bFieldText = WriteFieldText(aCell.mpEditText); if ( bFieldText ) diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx index 7dd2475503cf..0ab1395c3af1 100644 --- a/sc/source/filter/rtf/rtfexp.cxx +++ b/sc/source/filter/rtf/rtfexp.cxx @@ -177,7 +177,6 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) ScAddress aPos(nCol, nRow, nTab); switch (pDoc->GetCellType(aPos)) { - case CELLTYPE_NOTE: case CELLTYPE_NONE: bValueData = false; break; diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 556f27bf29eb..b1f83dc9c920 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1137,7 +1137,7 @@ namespace { bool isEmptyOrNote( ScDocument* pDoc, const ScAddress& rCurrentPos ) { CellType eType = pDoc->GetCellType(rCurrentPos); - return (eType == CELLTYPE_NONE) || (eType == CELLTYPE_NOTE); + return (eType == CELLTYPE_NONE); } } @@ -1255,7 +1255,6 @@ OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos ) switch (eType) { case CELLTYPE_NONE: - case CELLTYPE_NOTE: return EMPTY_OUSTRING; case CELLTYPE_EDIT: { diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 0fd8177d1703..bc71e3b9cd9d 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1916,7 +1916,6 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt bool bString; switch ( eType ) { - case CELLTYPE_NOTE: case CELLTYPE_NONE: aString = OUString(); bString = false; diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index d86db2505896..120b3863dfed 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -1081,14 +1081,11 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, CharSet eCharS { case sdbc::DataType::LONGVARCHAR: { - if (pCell->meType != CELLTYPE_NOTE) - { - if (pCell->meType == CELLTYPE_EDIT) - lcl_getLongVarCharEditString(aString, *pCell, aEditEngine); - else - lcl_getLongVarCharString( - aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt); - } + if (pCell->meType == CELLTYPE_EDIT) + lcl_getLongVarCharEditString(aString, *pCell, aEditEngine); + else + lcl_getLongVarCharString( + aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt); } break; diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index d50856f9de74..9b466bfd1864 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1650,7 +1650,6 @@ bool ScImportExport::Doc2Text( SvStream& rStrm ) lcl_WriteSimpleString( rStrm, aCell ); } break; - case CELLTYPE_NOTE: case CELLTYPE_NONE: break; default: diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 346eff279112..d0155229f68b 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -3737,32 +3737,29 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl( ScCellIterator aCmpIter( pDoc, aCmpRange ); for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next()) { - if (aCmpIter.getType() != CELLTYPE_NOTE) - { - SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row()); - if (bColumnDiff) - aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab, - static_cast<SCCOL>(nCellPos),MAXROW,nTab ); - else - aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab ); + SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row()); + if (bColumnDiff) + aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab, + static_cast<SCCOL>(nCellPos),MAXROW,nTab ); + else + aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab ); - for (i=0; i<nRangeCount; i++) + for (i=0; i<nRangeCount; i++) + { + ScRange aRange( *aRanges[ i ] ); + if ( aRange.Intersects( aCellRange ) ) { - ScRange aRange( *aRanges[ i ] ); - if ( aRange.Intersects( aCellRange ) ) + if (bColumnDiff) { - if (bColumnDiff) - { - aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos)); - aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos)); - } - else - { - aRange.aStart.SetRow(nCellPos); - aRange.aEnd.SetRow(nCellPos); - } - aMarkData.SetMultiMarkArea( aRange ); + aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos)); + aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos)); + } + else + { + aRange.aStart.SetRow(nCellPos); + aRange.aEnd.SetRow(nCellPos); } + aMarkData.SetMultiMarkArea( aRange ); } } } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 38036b7982b1..6ce49d24408a 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2624,7 +2624,6 @@ void ScChart2DataSequence::BuildDataCache() #endif case CELLTYPE_EDIT: case CELLTYPE_NONE: - case CELLTYPE_NOTE: case CELLTYPE_STRING: default: ; // do nothing diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index d66fc09ca8ac..b900c01308c6 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -107,7 +107,7 @@ bool ScConversionEngineBase::FindNextConversionCell() { ScAddress aPos( mnCurrCol, mnCurrRow, nTab ); CellType eCellType = mrDoc.GetCellType( aPos ); - bool bEmptyCell = eCellType == CELLTYPE_NONE || eCellType == CELLTYPE_NOTE; + bool bEmptyCell = eCellType == CELLTYPE_NONE; if (mpUndoDoc && !bEmptyCell) mrDoc.CopyCellToDocument(aPos, aPos, *mpUndoDoc); |