diff options
54 files changed, 480 insertions, 633 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index c1d5cf2a2873..7551ba693b15 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -65,7 +65,7 @@ class ScPatternAttr; // ============================================================================ /** Default cell clone flags: do not start listening, do not adjust 3D refs to - old position. Note: Notes must be cloned separately, through ScDocument.*/ + old position, clone note captions of cell notes. */ const int SC_CLONECELL_DEFAULT = 0x0000; /** If set, cloned formula cells will start to listen to the document. */ @@ -92,29 +92,27 @@ public: /** Base copy constructor. Does NOT clone cell note or broadcaster! */ ScBaseCell( const ScBaseCell& rCell ); - /** Returns a clone of this cell at the same position; cell broadcaster - will not be cloned. */ - ScBaseCell* Clone( ScDocument& rDestDoc, - int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + /** Returns a clone of this cell at the same position, cell note and + broadcaster will not be cloned. */ + ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; /** Returns a clone of this cell for the passed document position, cell - broadcaster will not be cloned. */ - ScBaseCell* Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, - int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + note and broadcaster will not be cloned. */ + ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + + /** Returns a clone of this cell, clones cell note and caption object too + (unless SC_CLONECELL_NOCAPTION flag is set). Broadcaster will not be cloned. */ + ScBaseCell* CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; /** Due to the fact that ScBaseCell does not have a vtable, this function - deletes the cell by calling the appropriate d'tor of the derived class. - */ + deletes the cell by calling the appropriate d'tor of the derived class. */ void Delete(); inline CellType GetCellType() const { return (CellType)eCellType; } - /** Returns true, if the cell is empty (neither value nor formula). - Returns false for formula cells returning nothing; use HasEmptyData() - for that. - Does *not* check for notes; use ScDocument.GetNote() for that. - */ - bool IsBlank( ) const; + /** Returns true, if the cell is empty (neither value nor formula nor cell note). + Returns false for formula cells returning nothing, use HasEmptyData() for that. */ + bool IsBlank( bool bIgnoreNotes = false ) const; // for idle-calculations inline sal_uInt16 GetTextWidth() const { return nTextWidth; } @@ -123,6 +121,18 @@ public: inline sal_uInt8 GetScriptType() const { return nScriptType; } inline void SetScriptType( sal_uInt8 nNew ) { nScriptType = nNew; } + /** Returns true, if the cell contains a note. */ + inline bool HasNote() const { return mpNote != 0; } + /** Returns the pointer to a cell note object (read-only). */ + inline const ScPostIt* GetNote() const { return mpNote; } + /** Returns the pointer to a cell note object. */ + inline ScPostIt* GetNote() { return mpNote; } + /** Takes ownership of the passed cell note object. */ + void TakeNote( ScPostIt* pNote ); + /** Returns and forgets the own cell note object. Caller takes ownership! */ + ScPostIt* ReleaseNote(); + /** Deletes the own cell note object. */ + void DeleteNote(); /** Returns true, if the cell contains a broadcaster. */ inline bool HasBroadcaster() const { return mpBroadcaster != 0; } @@ -146,20 +156,20 @@ public: /** Error code if ScFormulaCell, else 0. */ sal_uInt16 GetErrorCode() const; - - /** ScFormulaCell with formula::svEmptyCell result, or ScEmptyCell */ + /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been + created due to reference to empty cell). */ bool HasEmptyData() const; bool HasValueData() const; bool HasStringData() const; String GetStringData() const; // only real strings - static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ); private: ScBaseCell& operator=( const ScBaseCell& ); private: + ScPostIt* mpNote; /// The cell note. Cell takes ownership! SvtBroadcaster* mpBroadcaster; /// Broadcaster for changed values. Cell takes ownership! protected: @@ -170,23 +180,25 @@ protected: // ============================================================================ - -// Empty cell to take broadcaster -class SC_DLLPUBLIC ScEmptyCell : public ScBaseCell +class SC_DLLPUBLIC ScNoteCell : public ScBaseCell { public: #ifdef USE_MEMPOOL - DECL_FIXEDMEMPOOL_NEWDEL( ScEmptyCell ) + DECL_FIXEDMEMPOOL_NEWDEL( ScNoteCell ) #endif /** Cell takes ownership of the passed broadcaster. */ - explicit ScEmptyCell( SvtBroadcaster* pBC = 0 ); + explicit ScNoteCell( SvtBroadcaster* pBC = 0 ); + /** Cell takes ownership of the passed note and broadcaster. */ + explicit ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC = 0 ); #if OSL_DEBUG_LEVEL > 0 - ~ScEmptyCell(); + ~ScNoteCell(); #endif -}; +private: + ScNoteCell( const ScNoteCell& ); +}; class SC_DLLPUBLIC ScValueCell : public ScBaseCell { diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index b665e399aaee..7e21ba884740 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -265,6 +265,15 @@ public: bool HasValueData( SCROW nRow ) const; bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const; + /** Returns the pointer to a cell note object at the passed row. */ + ScPostIt* GetNote( SCROW nRow ); + /** Sets the passed cell note object at the passed row. Takes ownership! */ + void TakeNote( SCROW nRow, ScPostIt* pNote ); + /** Returns and forgets a cell note object at the passed row. */ + ScPostIt* ReleaseNote( SCROW nRow ); + /** Deletes the note at the passed row. */ + void DeleteNote( SCROW nRow ); + void SetDirty(); void SetDirty( const ScRange& ); void SetDirtyVar(); diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index 43e13bf3788f..c06b9935e1b1 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -479,8 +479,6 @@ private: ScHorizontalCellIterator aCellIter; ScHorizontalAttrIterator aAttrIter; - ScDocument * pDoc; - const SCTAB nTable; SCCOL nNextCol; SCROW nNextRow; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cbcc3b1021ec..a7ae1c3bb576 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -273,7 +273,6 @@ private: ::std::auto_ptr<ScExternalRefManager> pExternalRefMgr; ::std::auto_ptr<ScMacroManager> mpMacroMgr; - std::map< const ScAddress, ScPostIt* > pNotes; // mutable for lazy construction mutable ::std::auto_ptr< ScFormulaParserPool > @@ -803,16 +802,16 @@ public: /** Returns true, if there is any data to create a selection list for rPos. */ sal_Bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; - /* Note management API - */ - SC_DLLPUBLIC ScPostIt* GetNote( ScAddress const & ); + /** Returns the pointer to a cell note object at the passed cell address. */ + SC_DLLPUBLIC ScPostIt* GetNote( const ScAddress& rPos ); + /** Sets the passed note at the cell with the passed cell address. */ + void TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ); + /** Returns and forgets the cell note object at the passed cell address. */ + ScPostIt* ReleaseNote( const ScAddress& rPos ); + /** Returns the pointer to an existing or created cell note object at the passed cell address. */ SC_DLLPUBLIC ScPostIt* GetOrCreateNote( const ScAddress& rPos ); - bool SetNote( ScAddress const &, ScPostIt* ); - bool MoveNote( ScAddress const & from, ScAddress const & to ); - bool SwapNotes( ScAddress const &, ScAddress const & ); - ScPostIt* ReleaseNote( ScAddress const & ); - void DeleteNote( ScAddress const & ); - + /** Deletes the note at the passed cell address. */ + void DeleteNote( const ScAddress& rPos ); /** Creates the captions of all uninitialized cell notes in the specified sheet. @param bForced True = always create all captions, false = skip when Undo is disabled. */ void InitializeNoteCaptions( SCTAB nTab, bool bForced = false ); diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 7d72340ff943..e8f7da17e4f5 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -273,7 +273,7 @@ enum CellType CELLTYPE_VALUE, CELLTYPE_STRING, CELLTYPE_FORMULA, - CELLTYPE_EMPTY, + CELLTYPE_NOTE, CELLTYPE_EDIT, CELLTYPE_SYMBOLS // for load/save #if OSL_DEBUG_LEVEL > 0 diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 2859dd008778..9cd3c573a072 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -340,6 +340,14 @@ public: void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const; void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const; + /** Returns the pointer to a cell note object at the passed cell address. */ + ScPostIt* GetNote( SCCOL nCol, SCROW nRow ); + /** Sets the passed cell note object at the passed cell address. Takes ownership! */ + void TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote ); + /** Returns and forgets the cell note object at the passed cell address. */ + ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow ); + /** Deletes the note at the passed cell address. */ + void DeleteNote( SCCOL nCol, SCROW nRow ); /** Creates the captions of all uninitialized cell notes. @param bForced True = always create all captions, false = skip when Undo is disabled. */ void InitializeNoteCaptions( bool bForced = false ); diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx index df8462c590a6..44f5cd58019e 100644 --- a/sc/source/core/data/autonamecache.cxx +++ b/sc/source/core/data/autonamecache.cxx @@ -90,7 +90,7 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index c56cb239681c..49c94a50ea56 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -72,20 +72,20 @@ const sal_uInt16 MAXRECURSION = 400; #ifdef USE_MEMPOOL // MemPools auf 4k Boundaries - 64 Bytes ausrichten -const sal_uInt16 nMemPoolEmptyCell = (0x8000 - 64) / sizeof(ScEmptyCell); -const sal_uInt16 nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); +const sal_uInt16 nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); const sal_uInt16 nMemPoolFormulaCell = (0x8000 - 64) / sizeof(ScFormulaCell); -const sal_uInt16 nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); - -IMPL_FIXEDMEMPOOL_NEWDEL( ScEmptyCell, nMemPoolEmptyCell, nMemPoolEmptyCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) +const sal_uInt16 nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); +const sal_uInt16 nMemPoolNoteCell = (0x1000 - 64) / sizeof(ScNoteCell); +IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) IMPL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell, nMemPoolFormulaCell, nMemPoolFormulaCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) +IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) +IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell, nMemPoolNoteCell, nMemPoolNoteCell ) #endif // ============================================================================ ScBaseCell::ScBaseCell( CellType eNewType ) : + mpNote( 0 ), mpBroadcaster( 0 ), nTextWidth( TEXTWIDTH_DIRTY ), eCellType( sal::static_int_cast<sal_uInt8>(eNewType) ), @@ -94,6 +94,7 @@ ScBaseCell::ScBaseCell( CellType eNewType ) : } ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : + mpNote( 0 ), mpBroadcaster( 0 ), nTextWidth( rCell.nTextWidth ), eCellType( rCell.eCellType ), @@ -103,6 +104,7 @@ ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : ScBaseCell::~ScBaseCell() { + delete mpNote; delete mpBroadcaster; OSL_ENSURE( eCellType == CELLTYPE_DESTROYED, "BaseCell Destructor" ); } @@ -121,9 +123,9 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons return new ScEditCell( static_cast< const ScEditCell& >( rSrcCell ), rDestDoc ); case CELLTYPE_FORMULA: return new ScFormulaCell( static_cast< const ScFormulaCell& >( rSrcCell ), rDestDoc, rDestPos, nCloneFlags ); - case CELLTYPE_EMPTY: - return new ScEmptyCell; - default:; + case CELLTYPE_NOTE: + return new ScNoteCell; + default:; } OSL_FAIL( "lclCloneCell - unknown cell type" ); return 0; @@ -225,7 +227,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD } // namespace -ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, int nCloneFlags ) const +ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags ) const { // notes will not be cloned -> cell address only needed for formula cells ScAddress aDestPos; @@ -234,14 +236,27 @@ ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, int nCloneFlags ) const return lclCloneCell( *this, rDestDoc, aDestPos, nCloneFlags ); } -ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const +ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const { return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); } +ScBaseCell* ScBaseCell::CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const +{ + ScBaseCell* pNewCell = lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); + if( mpNote ) + { + if( !pNewCell ) + pNewCell = new ScNoteCell; + bool bCloneCaption = (nCloneFlags & SC_CLONECELL_NOCAPTION) == 0; + pNewCell->TakeNote( mpNote->Clone( rOwnPos, rDestDoc, rDestPos, bCloneCaption ) ); + } + return pNewCell; +} void ScBaseCell::Delete() { + DeleteNote(); switch (eCellType) { case CELLTYPE_VALUE: @@ -256,8 +271,8 @@ void ScBaseCell::Delete() case CELLTYPE_FORMULA: delete (ScFormulaCell*) this; break; - case CELLTYPE_EMPTY: - delete (ScEmptyCell*) this; + case CELLTYPE_NOTE: + delete (ScNoteCell*) this; break; default: OSL_FAIL("Attempt to Delete() an unknown CELLTYPE"); @@ -265,12 +280,28 @@ void ScBaseCell::Delete() } } +bool ScBaseCell::IsBlank( bool bIgnoreNotes ) const +{ + return (eCellType == CELLTYPE_NOTE) && (bIgnoreNotes || !mpNote); +} + +void ScBaseCell::TakeNote( ScPostIt* pNote ) +{ + delete mpNote; + mpNote = pNote; +} -bool ScBaseCell::IsBlank( ) const +ScPostIt* ScBaseCell::ReleaseNote() { - return (CELLTYPE_EMPTY == eCellType); + ScPostIt* pNote = mpNote; + mpNote = 0; + return pNote; } +void ScBaseCell::DeleteNote() +{ + DELETEZ( mpNote ); +} void ScBaseCell::TakeBroadcaster( SvtBroadcaster* pBroadcaster ) { @@ -487,7 +518,7 @@ bool ScBaseCell::HasEmptyData() const { switch ( eCellType ) { - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : return true; case CELLTYPE_FORMULA : return ((ScFormulaCell*)this)->IsEmpty(); @@ -550,17 +581,17 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) if ( pCell1 ) { eType1 = pCell1->GetCellType(); - if (CELLTYPE_EDIT == eType1) + if (eType1 == CELLTYPE_EDIT) eType1 = CELLTYPE_STRING; - else if (CELLTYPE_EMPTY == eType1) + else if (eType1 == CELLTYPE_NOTE) eType1 = CELLTYPE_NONE; } if ( pCell2 ) { eType2 = pCell2->GetCellType(); - if (CELLTYPE_EDIT == eType2) + if (eType2 == CELLTYPE_EDIT) eType2 = CELLTYPE_STRING; - else if (CELLTYPE_EMPTY == eType2) + else if (eType2 == CELLTYPE_NOTE) eType2 = CELLTYPE_NONE; } if ( eType1 != eType2 ) @@ -623,21 +654,26 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) // ============================================================================ -ScEmptyCell::ScEmptyCell( SvtBroadcaster* pBC ) : - ScBaseCell( CELLTYPE_EMPTY ) +ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) : + ScBaseCell( CELLTYPE_NOTE ) { TakeBroadcaster( pBC ); } +ScNoteCell::ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC ) : + ScBaseCell( CELLTYPE_NOTE ) +{ + TakeNote( pNote ); + TakeBroadcaster( pBC ); +} #if OSL_DEBUG_LEVEL > 0 -ScEmptyCell::~ScEmptyCell() +ScNoteCell::~ScNoteCell() { eCellType = CELLTYPE_DESTROYED; } #endif - // ============================================================================ ScValueCell::ScValueCell() : diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 2c8d341c8141..28fb6348ebc8 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -61,7 +61,7 @@ using namespace formula; // STATIC DATA ----------------------------------------------------------- #ifdef USE_MEMPOOL -const sal_uInt16 nMemPoolEditCell = (0x1000 - 64) / sizeof(ScEmptyCell); +const sal_uInt16 nMemPoolEditCell = (0x1000 - 64) / sizeof(ScNoteCell); IMPL_FIXEDMEMPOOL_NEWDEL( ScEditCell, nMemPoolEditCell, nMemPoolEditCell ) #endif diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 89e635427a10..fc1178f4a622 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -840,7 +840,7 @@ void lclTakeBroadcaster( ScBaseCell*& rpCell, SvtBroadcaster* pBC ) if( rpCell ) rpCell->TakeBroadcaster( pBC ); else - rpCell = new ScEmptyCell( pBC ); + rpCell = new ScNoteCell( pBC ); } } @@ -908,10 +908,11 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) } else { - if ( pBC1 ) + ScNoteCell* pDummyCell = pBC1 ? new ScNoteCell( pBC1 ) : 0; + if ( pDummyCell ) { // insert dummy note cell (without note) containing old broadcaster - pItems[nIndex1].pCell = new ScEmptyCell( pBC1 ); + pItems[nIndex1].pCell = pDummyCell; } else { @@ -961,8 +962,9 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) // do not swap formula cells with equal formulas, but swap notes if (bEqual) { - pDocument->SwapNotes( aPos1, aPos2 ); - + ScPostIt* pNote1 = pCell1->ReleaseNote(); + pCell1->TakeNote( pCell2->ReleaseNote() ); + pCell2->TakeNote( pNote1 ); return; } } @@ -971,14 +973,17 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) /* Create clone of pCell1 at position of pCell2 (pCell1 exists always, see variable swapping above). Do not clone the note, but move pointer of old note to new cell. */ - ScBaseCell* pNew2 = pCell1->Clone( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL ); + ScBaseCell* pNew2 = pCell1->CloneWithoutNote( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL ); + pNew2->TakeNote( pCell1->ReleaseNote() ); + /* Create clone of pCell2 at position of pCell1. Do not clone the note, + but move pointer of old note to new cell. */ ScBaseCell* pNew1 = 0; if ( pCell2 ) { - pNew1 = pCell2->Clone( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); + pNew1 = pCell2->CloneWithoutNote( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); + pNew1->TakeNote( pCell2->ReleaseNote() ); } - pDocument->SwapNotes( aPos1, aPos2 ); // move old broadcasters new cells at the same old position SvtBroadcaster* pBC1 = pCell1->ReleaseBroadcaster(); @@ -1074,17 +1079,10 @@ bool ScColumn::TestInsertCol( SCROW nStartRow, SCROW nEndRow) const if (!IsEmpty()) { bool bTest = true; - if (pItems) { - ScAddress pos( nCol, 0, nTab ); - for (SCSIZE i=0; (i<nCount) && bTest; i++) { - pos.SetRow( pItems[i].nRow ); - bTest = ( - ((nStartRow < pItems[i].nRow) && (pItems[i].nRow < nEndRow)) - || (pItems[i].pCell->IsBlank()) - || (0 == pDocument->GetNote( pos )) - ); - } - } + if (pItems) + for (SCSIZE i=0; (i<nCount) && bTest; i++) + bTest = (pItems[i].nRow < nStartRow) || (pItems[i].nRow > nEndRow) + || pItems[i].pCell->IsBlank(); // AttrArray testet nur zusammengefasste @@ -1201,9 +1199,6 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) for (i = 0; i < nDelCount; i++) { ScBaseCell* pCell = ppDelCells[i]; - // Oct, 2011: Perhaps need to update IsBlank call in ENSURE to check - // for notes (via ScDocument.GetNote), but I'm not sure the current - // code (above and below this comment) is even correct. OSL_ENSURE( pCell->IsBlank(), "sichtbare Zelle weggeschoben" ); SvtBroadcaster* pBC = pCell->GetBroadcaster(); if (pBC) @@ -1252,8 +1247,6 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee if (nBlockCount) { int nCloneFlags = bCloneNoteCaptions ? SC_CLONECELL_DEFAULT : SC_CLONECELL_NOCAPTION; - ScDocument * rDestDoc = rColumn.pDocument; - rColumn.Resize( rColumn.GetCellCount() + nBlockCount ); ScAddress aOwnPos( nCol, 0, nTab ); ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab ); @@ -1261,15 +1254,7 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee { aOwnPos.SetRow( pItems[i].nRow ); aDestPos.SetRow( pItems[i].nRow ); - ScBaseCell* pNewCell = pItems[i].pCell->Clone( - *rDestDoc, aDestPos, nCloneFlags - ); - ScPostIt* pNewNote = pDocument->GetNote( aOwnPos ); - if (pNewNote) - pNewNote = new ScPostIt( *rDestDoc, aDestPos, *pNewNote ); - if ( ! rDestDoc->SetNote( aDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; don't leak - + ScBaseCell* pNewCell = pItems[i].pCell->CloneWithNote( aOwnPos, *rColumn.pDocument, aDestPos, nCloneFlags ); rColumn.Append( aDestPos.Row(), pNewCell ); } } @@ -1398,12 +1383,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const SCSIZE nThisIndex; if ( Search( aDestPos.Row(), nThisIndex ) ) { - ScBaseCell* pNew = pItems[nThisIndex].pCell->Clone( rDestDoc, aDestPos ); - ScPostIt* pNewNote = pDocument->GetNote( aOwnPos ); - pNewNote = new ScPostIt( rDestDoc, aDestPos, pNewNote ); - if ( ! rDestDoc.SetNote( aDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; don't leak - + ScBaseCell* pNew = pItems[nThisIndex].pCell->CloneWithNote( aOwnPos, rDestDoc, aDestPos ); rDestCol.Insert( aDestPos.Row(), pNew ); } } @@ -1611,7 +1591,7 @@ 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(); - ScEmptyCell* pEmptyCell = new ScEmptyCell; // Dummy like in DeleteRange + ScNoteCell* pNoteCell = new ScNoteCell; // Dummy like in DeleteRange // must iterate backwards, because indexes of following cells become invalid for (EntryPosPairs::reverse_iterator it( aEntries.rbegin()); @@ -1620,7 +1600,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) nStartPos = (*it).first; nStopPos = (*it).second; for (i=nStartPos; i<nStopPos; ++i) - pItems[i].pCell = pEmptyCell; + pItems[i].pCell = pNoteCell; for (i=nStartPos; i<nStopPos; ++i) { rAddress.SetRow( pItems[i].nRow ); @@ -1630,7 +1610,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) memmove( &pItems[nStartPos], &pItems[nStopPos], (nCount - nStartPos) * sizeof(ColEntry) ); } - pEmptyCell->Delete(); + pNoteCell->Delete(); pItems[nCount].nRow = 0; pItems[nCount].pCell = NULL; } @@ -1806,7 +1786,7 @@ void ScColumn::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScColumn* pRefUndo, /* Do not copy cell note to the undo document. Undo will copy back the formula cell while keeping the original note. */ - ScBaseCell* pSave = pRefUndo ? pOld->Clone( *pDocument ) : 0; + ScBaseCell* pSave = pRefUndo ? pOld->CloneWithoutNote( *pDocument ) : 0; bool bChanged = pOld->UpdateDeleteTab(nTable, bIsMove, nSheets); if ( nRow != pItems[i].nRow ) diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 547e83307669..83ecd3cc1036 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -946,7 +946,7 @@ void ScColumn::RemoveAutoSpellObj() String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - + pNewCell->TakeNote( pOldCell->ReleaseNote() ); pItems[i].pCell = pNewCell; delete pOldCell; } @@ -1018,7 +1018,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - + pNewCell->TakeNote( pOldCell->ReleaseNote() ); pItems[i].pCell = pNewCell; delete pOldCell; } @@ -1150,11 +1150,7 @@ bool ScColumn::IsEmptyVisData(bool bNotes) const for (i=0; i<nCount && !bVisData; i++) { ScBaseCell* pCell = pItems[i].pCell; - ScPostIt *note = pDocument->GetNote( - ScAddress( nCol, pItems[i].nRow, nTab ) - ); - - if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) + if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) bVisData = true; } return !bVisData; @@ -1171,7 +1167,7 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) { if ( pItems[nIndex].nRow >= nStartRow && - pItems[nIndex].pCell->GetCellType() != CELLTYPE_EMPTY ) + pItems[nIndex].pCell->GetCellType() != CELLTYPE_NOTE ) { ++nVisCount; } @@ -1191,9 +1187,7 @@ SCROW ScColumn::GetLastVisDataPos(bool bNotes) const { --i; ScBaseCell* pCell = pItems[i].pCell; - ScPostIt *note = pDocument->GetNote( ScAddress(nCol, pItems[i].nRow, nTab) ); - - if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) + if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) { bFound = true; nRet = pItems[i].nRow; @@ -1213,9 +1207,7 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const for (i=0; i<nCount && !bFound; i++) { ScBaseCell* pCell = pItems[i].pCell; - ScPostIt *note = pDocument->GetNote( ScAddress(nCol, pItems[i].nRow, nTab) ); - - if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) + if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) { bFound = true; nRet = pItems[i].nRow; @@ -1228,11 +1220,9 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const bool ScColumn::HasVisibleDataAt(SCROW nRow) const { SCSIZE nIndex; - if (Search(nRow, nIndex)) { - ScAddress aPos( nCol, nRow, nTab ); - if (!pItems[nIndex].pCell->IsBlank() || pDocument->GetNote(aPos)) + if (Search(nRow, nIndex)) + if (!pItems[nIndex].pCell->IsBlank()) return true; - } return false; } @@ -1259,10 +1249,8 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow, bool bIgnoreNotes) c Search( nStartRow, nIndex ); while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) { - if ( ( ! pItems[nIndex].pCell->IsBlank() ) - || ( ! bIgnoreNotes && pDocument->GetNote( ScAddress( nCol, pItems[nIndex].nRow, nTab ))) - ) - return false; // not empty if even one cell is not blank or has a note + if ( !pItems[nIndex].pCell->IsBlank( bIgnoreNotes ) ) // found a cell + return false; // not empty ++nIndex; } return true; // no cell found @@ -1275,7 +1263,6 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti SCSIZE i; if (pItems && (nCount > 0)) { - ScAddress aPos( nCol, 0, nTab ); if (eDir == DIR_BOTTOM) { i = nCount; @@ -1284,9 +1271,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti i--; if ( pItems[i].nRow < nStartRow ) break; - aPos.SetRow( pItems[i].nRow ); - ScPostIt* aNote = pDocument->GetNote( aPos ); - bFound = pItems[i].nRow <= nEndRow && (!pItems[i].pCell->IsBlank() || aNote ); + bFound = pItems[i].nRow <= nEndRow && !pItems[i].pCell->IsBlank(); } if (bFound) nLines = static_cast<SCSIZE>(nEndRow - pItems[i].nRow); @@ -1300,9 +1285,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti { if ( pItems[i].nRow > nEndRow ) break; - aPos.SetRow( pItems[i].nRow ); - ScPostIt* aNote = pDocument->GetNote( aPos ); - bFound = pItems[i].nRow >= nStartRow && (!pItems[i].pCell->IsBlank() || aNote ); + bFound = pItems[i].nRow >= nStartRow && !pItems[i].pCell->IsBlank(); i++; } if (bFound) @@ -1365,14 +1348,8 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const SCSIZE nIndex; bool bThere = Search(rRow, nIndex); - ScAddress aPos( nCol, 0, nTab ); - if (bThere) { - aPos.SetRow(pItems[nIndex].nRow); - if ( pItems[nIndex].pCell->IsBlank() - && (0 == pDocument->GetNote( aPos ) ) - ) - bThere = false; - } + if (bThere && pItems[nIndex].pCell->IsBlank()) + bThere = false; if (bThere) { @@ -1383,22 +1360,14 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndex<nCount-1) { ++nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - while ( nIndex < nCount -1 - && pItems[nIndex].nRow == nLast +1 - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + while (nIndex<nCount-1 && pItems[nIndex].nRow==nLast+1 + && !pItems[nIndex].pCell->IsBlank()) { ++nIndex; ++nLast; - aPos.SetRow( pItems[nIndex].nRow ); } - if ( nIndex == nCount -1 ) - if ( pItems[nIndex].nRow == nLast +1 - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + if (nIndex==nCount-1) + if (pItems[nIndex].nRow==nLast+1 && !pItems[nIndex].pCell->IsBlank()) ++nLast; } } @@ -1407,22 +1376,14 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndex>0) { --nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - while ( nIndex > 0 - && pItems[nIndex].nRow +1 == nLast - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + while (nIndex>0 && pItems[nIndex].nRow+1==nLast + && !pItems[nIndex].pCell->IsBlank()) { --nIndex; --nLast; - aPos.SetRow( pItems[nIndex].nRow ); } - if ( 0 == nIndex ) - if ( pItems[nIndex].nRow +1 == nLast - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + if (nIndex==0) + if (pItems[nIndex].nRow+1==nLast && !pItems[nIndex].pCell->IsBlank()) --nLast; } } @@ -1437,17 +1398,10 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (!bThere) { - aPos.SetRow( pItems[nIndex].nRow ); if (bForward) { - while ( nIndex < nCount - && ( pItems[nIndex].pCell->IsBlank() - && (0 == pDocument->GetNote( aPos )) ) - ) - { + while (nIndex<nCount && pItems[nIndex].pCell->IsBlank()) ++nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - } if (nIndex<nCount) rRow = pItems[nIndex].nRow; else @@ -1455,14 +1409,8 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const } else { - while ( nIndex > 0 - && ( pItems[nIndex-1].pCell->IsBlank() - && (0 == pDocument->GetNote( aPos )) ) - ) - { + while (nIndex>0 && pItems[nIndex-1].pCell->IsBlank()) --nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - } if (nIndex>0) rRow = pItems[nIndex-1].nRow; else @@ -1478,9 +1426,7 @@ bool ScColumn::HasDataAt(SCROW nRow) const SCSIZE nIndex; if (Search(nRow, nIndex)) - if ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( ScAddress( nCol, nRow, nTab )) - ) + if (!pItems[nIndex].pCell->IsBlank()) return true; return false; @@ -1557,7 +1503,7 @@ void ScColumn::StartListening( SvtListener& rLst, SCROW nRow ) } else { - pCell = new ScEmptyCell; + pCell = new ScNoteCell; Insert(nRow, pCell); } @@ -1582,7 +1528,7 @@ void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow ) } else { - pCell = new ScEmptyCell; + pCell = new ScNoteCell; Insert(nDestRow, pCell); } @@ -1616,7 +1562,7 @@ void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) if (!pBC->HasListeners()) { - if (pCell->IsBlank() && (0 == pDocument->GetNote(ScAddress(nCol, nRow, nTab))) ) + if (pCell->IsBlank()) DeleteAtIndex(nIndex); else pCell->DeleteBroadcaster(); @@ -1699,7 +1645,7 @@ void lcl_UpdateSubTotal( ScFunctionData& rData, ScBaseCell* pCell ) } } break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: bCell = false; break; // bei Strings nichts diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index e39cbe1cfea1..baa05185ce8e 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -88,17 +88,12 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) if (Search(nRow, nIndex)) { ScBaseCell* pOldCell = pItems[nIndex].pCell; - ScAddress oldAddy( nCol, pItems[nIndex].nRow, nTab ); - ScAddress newAddy( nCol, nRow, nTab ); - ScPostIt* oldNote = pDocument->GetNote( oldAddy ); - ScPostIt* newNote = pDocument->GetNote( newAddy ); // move broadcaster and note to new cell, if not existing in new cell if (pOldCell->HasBroadcaster() && !pNewCell->HasBroadcaster()) pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - - if ( oldNote && !newNote ) - pDocument->MoveNote( oldAddy, newAddy ); + if (pOldCell->HasNote() && !pNewCell->HasNote()) + pNewCell->TakeNote( pOldCell->ReleaseNote() ); if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() ) { @@ -153,7 +148,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) CellType eCellType = pNewCell->GetCellType(); // Notizzelle entsteht beim Laden nur durch StartListeningCell, // ausloesende Formelzelle muss sowieso dirty sein. - if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_EMPTY) ) + if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_NOTE) ) { if ( eCellType == CELLTYPE_FORMULA ) ((ScFormulaCell*)pNewCell)->SetDirty(); @@ -217,17 +212,17 @@ void ScColumn::Delete( SCROW nRow ) if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - ScEmptyCell* pEmptyCell = new ScEmptyCell; - pItems[nIndex].pCell = pEmptyCell; // Dummy, for Interpret + ScNoteCell* pNoteCell = new ScNoteCell; + pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, nRow, nTab ), pCell ) ); if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() ) { - pEmptyCell->TakeBroadcaster( pBC ); + pNoteCell->TakeBroadcaster( pBC ); } else { - pEmptyCell->Delete(); + pNoteCell->Delete(); --nCount; memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); pItems[nCount].nRow = 0; @@ -243,11 +238,11 @@ void ScColumn::Delete( SCROW nRow ) void ScColumn::DeleteAtIndex( SCSIZE nIndex ) { ScBaseCell* pCell = pItems[nIndex].pCell; - ScEmptyCell* pEmptyCell = new ScEmptyCell; - pItems[nIndex].pCell = pEmptyCell; // Dummy, for Interpret + ScNoteCell* pNoteCell = new ScNoteCell; + pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, pItems[nIndex].nRow, nTab ), pCell ) ); - pEmptyCell->Delete(); + pNoteCell->Delete(); --nCount; memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); pItems[nCount].nRow = 0; @@ -379,20 +374,13 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe drawing undo. */ bool bDeleteNote = (nDelFlag & IDF_NOTE) != 0; bool bNoCaptions = (nDelFlag & IDF_NOCAPTIONS) != 0; - - if (bDeleteNote && bNoCaptions) { - for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { - ScPostIt* pNote = pDocument->GetNote( - ScAddress( nCol, pItems[ nIdx ].nRow, nTab ) - ); - if ( pNote ) + if (bDeleteNote && bNoCaptions) + for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) + if ( ScPostIt* pNote = pItems[ nIdx ].pCell->GetNote() ) pNote->ForgetCaption(); - } - } ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 ); - // cache all formula cells, they will be deleted at end of this function typedef ::std::vector< ScFormulaCell* > FormulaCellVector; FormulaCellVector aDelCells; @@ -403,7 +391,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe SCSIZE nFirst(nStartIndex); // dummy replacement for old cells, to prevent that interpreter uses old cell - boost::scoped_ptr<ScEmptyCell> pDummyCell(new ScEmptyCell); + boost::scoped_ptr<ScNoteCell> pDummyCell(new ScNoteCell); for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { @@ -436,7 +424,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bDelete = true; else { - // decide whether to delete the cell object according to passed + // decide whether to delete the cell object according to passed // flags switch ( eCellType ) { @@ -467,7 +455,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bDelete = (nDelFlag & IDF_FORMULA) != 0; break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: // do note delete note cell with broadcaster bDelete = bDeleteNote && !pOldCell->GetBroadcaster(); break; @@ -479,28 +467,23 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe if (bDelete) { // try to create a replacement note cell, if note or broadcaster exists - ScEmptyCell* pEmptyCell = 0; - if (eCellType != CELLTYPE_EMPTY) + ScNoteCell* pNoteCell = 0; + if (eCellType != CELLTYPE_NOTE) { - // do not rescue note if it has to be deleted according to - // passed flags - // #i99844# do not release broadcaster from old cell, it - // still has to notify deleted content + // do not rescue note if it has to be deleted according to passed flags + ScPostIt* pNote = bDeleteNote ? 0 : pOldCell->ReleaseNote(); + // #i99844# do not release broadcaster from old cell, it still has to notify deleted content SvtBroadcaster* pBC = pOldCell->GetBroadcaster(); - if ( ! bDeleteNote || pBC ) - pEmptyCell = new ScEmptyCell( pBC ); - else - pDocument->DeleteNote( - ScAddress(nCol, pItems[nIdx].nRow, nTab) - ); + if( pNote || pBC ) + pNoteCell = new ScNoteCell( pNote, pBC ); } // remove cell entry in cell item list SCROW nOldRow = pItems[nIdx].nRow; - if (pEmptyCell) + if (pNoteCell) { // replace old cell with the replacement note cell - pItems[nIdx].pCell = pEmptyCell; + pItems[nIdx].pCell = pNoteCell; // ... so it's not really deleted bDelete = false; } @@ -517,15 +500,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe aHint.GetAddress().SetRow( nOldRow ); aHint.SetCell( pOldCell ); pDocument->Broadcast( aHint ); - // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pEmptyCell) + // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pNoteCell) pOldCell->ReleaseBroadcaster(); pOldCell->Delete(); } } else { + // delete cell note if (bDeleteNote) - pDocument->DeleteNote( ScAddress(nCol, pItems[nIdx].nRow, nTab) ); + pItems[nIdx].pCell->DeleteNote(); } if (!bDelete) @@ -559,7 +543,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe { // this segment removed if (!bRemoved) nStartSegment = aIt->first; - // The first of removes in a row sets start (they should be + // The first of removes in a row sets start (they should be // alternating removed/notremoved anyway). bRemoved = true; } @@ -578,7 +562,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe } ++aIt; } - // The last removed segment up to nCount is discarded, there's nothing + // The last removed segment up to nCount is discarded, there's nothing // following to be moved. if (bRemoved) nShift += nCount - nStartSegment; @@ -746,7 +730,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nStartIndex < rColumn.nCount && rColumn.pItems[nStartIndex].nRow <= nRow2-nDy ) { SCSIZE nEndIndex = nStartIndex; - if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_NOTE ) { SCROW nStartRow = rColumn.pItems[nStartIndex].nRow; SCROW nEndRow = nStartRow; @@ -756,7 +740,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nEndRow < nRow2-nDy && nEndIndex+1 < rColumn.nCount && rColumn.pItems[nEndIndex+1].nRow == nEndRow+1 && - rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_EMPTY ) + rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_NOTE ) { ++nEndIndex; ++nEndRow; @@ -841,29 +825,25 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, passed together with IDF_NOTE in nInsFlag. Of course, there is still the need to create a new cell, if there is no cell at the destination position at all. */ - ScBaseCell* pNewCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0; - if (pNewCell) + ScBaseCell* pAddNoteCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0; + if (pAddNoteCell) { // do nothing if source cell does not contain a note - ScPostIt* pSourceNote = 0; - ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); - if ( rColumn.pItems[i].pCell ) - pSourceNote = pDocument->GetNote( aSourcePos ); - - if ( pSourceNote ) + const ScBaseCell* pSourceCell = rColumn.pItems[i].pCell; + const ScPostIt* pSourceNote = pSourceCell ? pSourceCell->GetNote() : 0; + if (pSourceNote) { + OSL_ENSURE( !pAddNoteCell->HasNote(), "ScColumn::CopyFromClip - unexpected note at destination cell" ); bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0; // #i52342# if caption is cloned, the note must be constructed with the destination document + ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); ScPostIt* pNewNote = pSourceNote->Clone( aSourcePos, *pDocument, aDestPos, bCloneCaption ); - ScAddress newAddy( nCol, aDestPos.Row(), nTab ); - - if ( ! pDocument->SetNote( newAddy, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; no leak + pAddNoteCell->TakeNote( pNewNote ); } } else { - pNewCell = bAsLink ? + ScBaseCell* pNewCell = bAsLink ? rColumn.CreateRefCell( pDocument, aDestPos, i, nInsFlag ) : rColumn.CloneCell( i, nInsFlag, *pDocument, aDestPos ); if (pNewCell) @@ -907,7 +887,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD ScBaseCell& rSource = *pItems[nIndex].pCell; switch (rSource.GetCellType()) { - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: // note will be cloned below break; @@ -915,13 +895,13 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD case CELLTYPE_EDIT: // note will be cloned below if (bCloneString) - pNew = rSource.Clone( rDestDoc, rDestPos ); + pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); break; case CELLTYPE_VALUE: // note will be cloned below if (lclCanCloneValue( *pDocument, *this, pItems[nIndex].nRow, bCloneValue, bCloneDateTime )) - pNew = rSource.Clone( rDestDoc, rDestPos ); + pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); break; case CELLTYPE_FORMULA: @@ -939,7 +919,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD if (bForceFormula || bCloneFormula) { // note will be cloned below - pNew = rSource.Clone( rDestDoc, rDestPos ); + pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); } else if ( (bCloneValue || bCloneDateTime || bCloneString) && !rDestDoc.IsUndo() ) { @@ -991,20 +971,16 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD // clone the cell note if (bCloneNote) { - ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); - ScPostIt* pNote = pDocument->GetNote( aOwnPos ); - - if ( pNote ) + if (ScPostIt* pNote = rSource.GetNote()) { bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; - // #i52342# if caption is cloned, the note must be constructed - // with the destination document + // #i52342# if caption is cloned, the note must be constructed with the destination document + ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); ScPostIt* pNewNote = pNote->Clone( aOwnPos, rDestDoc, rDestPos, bCloneCaption ); - if ( ! rDestDoc.SetNote( rDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; don't leak - if (!pNew) - pNew = new ScEmptyCell(); + pNew = new ScNoteCell( pNewNote ); + else + pNew->TakeNote( pNewNote ); } } @@ -1110,14 +1086,14 @@ 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_EMPTY ); - sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_EMPTY ); + sal_Bool bSrcEmpty = ( eSrcType == CELLTYPE_NONE || eSrcType == CELLTYPE_NOTE ); + sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_NOTE ); if ( bSkipEmpty && bDestEmpty ) // Originalzelle wiederherstellen { if ( pSrc ) // war da eine Zelle? { - pNew = pSrc->Clone( *pDocument ); + pNew = pSrc->CloneWithoutNote( *pDocument ); } } else if ( nFunction ) // wirklich Rechenfunktion angegeben @@ -1173,7 +1149,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, // mit Texten wird nicht gerechnet - immer "alte" Zelle, also pSrc if (pSrc) - pNew = pSrc->Clone( *pDocument ); + pNew = pSrc->CloneWithoutNote( *pDocument ); else if (pDest) bDelete = sal_True; } @@ -1216,7 +1192,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, if (pDest && !pNew) // alte Zelle da ? { if ( pDest->GetBroadcaster() ) - pNew = new ScEmptyCell; // Broadcaster uebernehmen + pNew = new ScNoteCell; // Broadcaster uebernehmen else Delete(nRow); // -> loeschen } @@ -1419,7 +1395,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if ( rString == aStr ) bIsText = true; break; - case CELLTYPE_EMPTY : // durch =Formel referenziert + case CELLTYPE_NOTE : // durch =Formel referenziert break; default: if ( i == nCount - 1 ) @@ -1539,17 +1515,14 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if (Search(nRow, i)) { ScBaseCell* pOldCell = pItems[i].pCell; + ScPostIt* pNote = pOldCell->ReleaseNote(); SvtBroadcaster* pBC = pOldCell->ReleaseBroadcaster(); - - ScPostIt* pNote = pDocument->GetNote( - ScAddress( nCol, pItems[i].nRow, nTab ) - ); - if (pNewCell || pNote || pBC) { - if ( ! pNewCell ) - pNewCell = new ScEmptyCell(); - + if (pNewCell) + pNewCell->TakeNote( pNote ); + else + pNewCell = new ScNoteCell( pNote ); if (pBC) { pNewCell->TakeBroadcaster(pBC); @@ -1813,7 +1786,7 @@ void ScColumn::GetString( SCROW nRow, String& rString ) const if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_EMPTY) + if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); ScCellFormat::GetString( pCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()) ); @@ -1832,7 +1805,7 @@ void ScColumn::GetInputString( SCROW nRow, String& rString ) const if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_EMPTY) + if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) ); @@ -1948,6 +1921,44 @@ bool ScColumn::HasStringCells( SCROW nStartRow, SCROW nEndRow ) const } +ScPostIt* ScColumn::GetNote( SCROW nRow ) +{ + SCSIZE nIndex; + return Search( nRow, nIndex ) ? pItems[ nIndex ].pCell->GetNote() : 0; +} + + +void ScColumn::TakeNote( SCROW nRow, ScPostIt* pNote ) +{ + SCSIZE nIndex; + if( Search( nRow, nIndex ) ) + pItems[ nIndex ].pCell->TakeNote( pNote ); + else + Insert( nRow, new ScNoteCell( pNote ) ); +} + + +ScPostIt* ScColumn::ReleaseNote( SCROW nRow ) +{ + ScPostIt* pNote = 0; + SCSIZE nIndex; + if( Search( nRow, nIndex ) ) + { + ScBaseCell* pCell = pItems[ nIndex ].pCell; + pNote = pCell->ReleaseNote(); + if( (pCell->GetCellType() == CELLTYPE_NOTE) && !pCell->GetBroadcaster() ) + DeleteAtIndex( nIndex ); + } + return pNote; +} + + +void ScColumn::DeleteNote( SCROW nRow ) +{ + delete ReleaseNote( nRow ); +} + + sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const { sal_Int32 nStringLen = 0; @@ -1963,7 +1974,7 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRowEnd ) { ScBaseCell* pCell = pItems[nIndex].pCell; - if ( pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell->GetCellType() != CELLTYPE_NOTE ) { Color* pColor; sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr( diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index b4e0681e73f4..bc9689bddb0c 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1160,7 +1160,7 @@ ScBaseCell* ScQueryCellIterator::GetThis() (nRow = pCol->pItems[nColRow].nRow) <= aParam.nRow2 ) { ScBaseCell* pCell = pCol->pItems[nColRow].pCell; - if ( pCell->GetCellType() == CELLTYPE_EMPTY ) + if ( pCell->GetCellType() == CELLTYPE_NOTE ) ++nRow; else if (bAllStringIgnore && pCell->HasStringData()) ++nRow; @@ -1472,7 +1472,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { SCSIZE nMid = (nLo+nHi)/2; SCSIZE i = nMid; - while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_EMPTY) + while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_NOTE) ++i; if (i > nHi) { @@ -1920,12 +1920,10 @@ inline sal_Bool IsGreater( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) return ( nRow1 > nRow2 ) || ( nRow1 == nRow2 && nCol1 > nCol2 ); } -ScUsedAreaIterator::ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTab, +ScUsedAreaIterator::ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) : - aCellIter( pDocument, nTab, nCol1, nRow1, nCol2, nRow2 ), - aAttrIter( pDocument, nTab, nCol1, nRow1, nCol2, nRow2 ), - pDoc( pDocument ), - nTable( nTab ), + aCellIter( pDocument, nTable, nCol1, nRow1, nCol2, nRow2 ), + aAttrIter( pDocument, nTable, nCol1, nRow1, nCol2, nRow2 ), nNextCol( nCol1 ), nNextRow( nRow1 ) { @@ -1944,11 +1942,7 @@ sal_Bool ScUsedAreaIterator::GetNext() if ( pCell && IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) ) pCell = aCellIter.GetNext( nCellCol, nCellRow ); - while ( pCell - && ( pCell->IsBlank() - && (0 == pDoc->GetNote( ScAddress(nCellCol, nCellRow, nTable))) - ) - ) + while ( pCell && pCell->IsBlank() ) pCell = aCellIter.GetNext( nCellCol, nCellRow ); if ( pPattern && IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) ) diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index e6b4c51cb1c4..97d834455659 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -124,6 +124,7 @@ private: }; // STATIC DATA ----------------------------------------------------------- + ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : xServiceManager( ::comphelper::getProcessServiceFactory() ), diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index bb3230d55b61..f821ccfb2cbc 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -76,12 +76,12 @@ sal_Bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, CellType eFType, eVType; GetCellType(nFCol, nFRow, nFTab, eFType); GetCellType(nVCol, nVRow, nVTab, eVType); - // CELLTYPE_EMPTY: no value, but referenced by formula + // CELLTYPE_NOTE: no value, but referenced by formula // #i108005# convert target value to number using default format, // as previously done in ScInterpreter::GetDouble double nTargetVal = 0.0; sal_uInt32 nFIndex = 0; - if (CELLTYPE_FORMULA == eFType && (CELLTYPE_VALUE == eVType || CELLTYPE_EMPTY == eVType) && + if (eFType == CELLTYPE_FORMULA && (eVType == CELLTYPE_VALUE || eVType == CELLTYPE_NOTE) && GetFormatTable()->IsNumberFormat(sValStr, nFIndex, nTargetVal)) { ScSingleRefData aRefData; @@ -172,7 +172,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, if (*itr == nTab1) maTabs[*itr]->PutCell(nCol1, nRow1, pCell); else - maTabs[*itr]->PutCell(nCol1, nRow1, pCell->Clone(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING)); + maTabs[*itr]->PutCell(nCol1, nRow1, pCell->CloneWithoutNote(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING)); } } @@ -308,7 +308,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera itr = rMark.begin(); for (; itr != itrEnd && *itr < nMax; ++itr) if( maTabs[*itr] ) - maTabs[*itr]->PutCell( j, k, aRefCell.Clone( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) ); + maTabs[*itr]->PutCell( j, k, aRefCell.CloneWithoutNote( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) ); } } @@ -836,8 +836,8 @@ sal_uInt16 ScDocument::RowDifferences( SCROW nThisRow, SCTAB nThisTab, nDif += 4; // Inhalt <-> leer zaehlt mehr } - if ( (pThisCell && pThisCell->GetCellType() != CELLTYPE_EMPTY) || - (pOtherCell && pOtherCell->GetCellType() != CELLTYPE_EMPTY) ) + if ( ( pThisCell && pThisCell->GetCellType()!=CELLTYPE_NOTE ) || + ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) ) ++nUsed; } } @@ -877,8 +877,8 @@ sal_uInt16 ScDocument::ColDifferences( SCCOL nThisCol, SCTAB nThisTab, nDif += 4; // Inhalt <-> leer zaehlt mehr } - if ( (pThisCell && pThisCell->GetCellType() != CELLTYPE_EMPTY) || - (pOtherCell && pOtherCell->GetCellType() != CELLTYPE_EMPTY) ) + if ( ( pThisCell && pThisCell->GetCellType()!=CELLTYPE_NOTE ) || + ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) ) ++nUsed; } } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 2cf366f9dcb0..b9526d31f272 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1895,9 +1895,8 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam, i = nTab; nEndTab = nTab; } - else { + else pClipDoc->ResetClip(this, pMarks); - } if ( bUseRangeForVBA ) CopyRangeNamesToClip(pClipDoc, aClipRange, nTab ); @@ -3262,195 +3261,48 @@ sal_Bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) cons } -/** ScPostIt* ScDocument::GetNote( ScAddress const & aPos ) - -Returns the ScPostIt object pointer associated with the document address aPos. -If the specific cell does not have a note, returns the NULL pointer. - -Notes: - -- If an ScPostIt* exists for the specified address, but the cell is no - longer addressable (e.g. if the sheet was deleted, but the note was not - properly removed), this function will remove the note before returning NULL. -*/ -ScPostIt* ScDocument::GetNote( ScAddress const & aPos ) +ScPostIt* ScDocument::GetNote( const ScAddress& rPos ) { - std::map< const ScAddress, ScPostIt* >::iterator it; - it = pNotes.find( aPos ); - - if ( pNotes.end() == it ) - return( 0 ); - - if (! ( ValidTab( aPos.Tab() ) - && aPos.Tab() < static_cast<SCTAB>(maTabs.size()) ) - ) - { - DELETEZ( it->second ); - pNotes.erase(it); - return( 0 ); - } - - return( it->second ); + ScTable* pTable = ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast<SCTAB>(maTabs.size()) ? maTabs[ rPos.Tab() ] : 0; + return pTable ? pTable->GetNote( rPos.Col(), rPos.Row() ) : 0; } -/** bool ScDocument::SetNote( ScAddress const & aPos, ScPostIt* pNote ) - -Set the ScPostIt for the cell at aPos to pNote. - -Returns true on success, or false if unable to set pNote for aPos. - -Notes: -- If a note already exists at 'aPos', it will first be deleted, before putting - pNote as the new ScPostIt for 'aPos'. -*/ -bool ScDocument::SetNote( ScAddress const & aPos, ScPostIt* pNote ) +void ScDocument::TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ) { - std::map< const ScAddress, ScPostIt* >::iterator it; - it = pNotes.find( aPos ); - - if ( pNotes.end() != it ) { - // if the note is the same as what's already there, do nothing ... - if ( it->second == pNote ) - return true; - - // ... otherwise, remove old note, before ... - DELETEZ( it->second ); - pNotes.erase( it ); - } - - if ( ! ( ValidTab( aPos.Tab() ) - && aPos.Tab() < static_cast<SCTAB>(maTabs.size()) ) - ) - return false; - - if ( pNote ) // no sense adding an empty pointer - pNotes[ aPos ] = pNote; - - return true; -} - - -/** ScPostIt* ScDocument::ReleaseNote( ScAddress const & aPos ) - -Returns a pointer to the ScPostIt assigned to the document position aPos, -removing it from cell address aPos. - -Notes: -- When this function completes, the document will have no ScPostIt* - assigned to aPos. Thus, the caller must dispose of, or otherwise deal with, - the returned *ScPostIt object. -*/ -ScPostIt* ScDocument::ReleaseNote( ScAddress const & aPos ) -{ - ScPostIt* pNote = 0; - std::map< const ScAddress, ScPostIt* >::iterator it; - - it = pNotes.find( aPos ); - - if ( pNotes.end() != it ) - { - pNote = it->second; - pNotes.erase( it ); - } - - return( pNote ); -} - - -/** void ScDocument::DeleteNote( ScAddress const & aPos ) - -Removes the ScPostIt object, if any, assigned to the document address aPos. -*/ -void ScDocument::DeleteNote( ScAddress const & aPos ) -{ - ScPostIt* pNote = ReleaseNote( aPos ); - DELETEZ( pNote ); -} - - -/** bool ScDocument::MoveNote( ScAddress const & aFrom, ScAddress const & aTo ) - -Moves the ScPostIt object associated with aFrom to aTo. - -Returns true on success, false on failure. - -Notes: -- Any ScPostIt object that exists at aTo is properly removed before insertion. -- Not transactional. If the function fails, there is no guarantee that any - ScPostIt at aTo or aFrom will still exist, although they will be properly - cleaned up if they don't. -*/ -bool ScDocument::MoveNote( ScAddress const & aFrom, ScAddress const & aTo ) -{ - ScPostIt* pFromNote = ReleaseNote( aFrom ); - if ( SetNote( aTo, pFromNote ) ) - return true; - - // Doh! An error occurred. Attempt to not lose note, or at least - // don't leak the memory - if ( ! SetNote( aFrom, pFromNote ) ) - DELETEZ( pFromNote ); - - return false; + if( ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast<SCTAB>(maTabs.size()) && maTabs[ rPos.Tab() ] ) + maTabs[ rPos.Tab() ]->TakeNote( rPos.Col(), rPos.Row(), rpNote ); + else + DELETEZ( rpNote ); } -/** bool ScDocument::SwapNotes( ScAddress const & aOne, ScAddress const & aTwo ) - -Swap the notes assigned to positions aOne and aTwo. - -Returns true on success, false on failure. - -Notes: -- Not transactional. If a failure occurs, the ScPostIt objects at aOne or aTwo - may (not) be set. Any ScPostIt that is not set, however, will be properly - cleaned up. -*/ -bool ScDocument::SwapNotes( ScAddress const & aOne, ScAddress const & aTwo ) +ScPostIt* ScDocument::ReleaseNote( const ScAddress& rPos ) { - ScPostIt* pNoteA = ReleaseNote( aOne ); - ScPostIt* pNoteB = ReleaseNote( aTwo ); - - if ( ! SetNote( aTwo, pNoteA ) ) { - DELETEZ( pNoteA ); - if ( ! SetNote( aOne, pNoteB ) ) - DELETEZ( pNoteB ); - return false; - } - else - { - if ( ! SetNote( aOne, pNoteB ) ) { - DELETEZ( pNoteB ); - return false; - } - } - - return true; + ScTable* pTable = ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast<SCTAB>(maTabs.size())? maTabs[ rPos.Tab() ] : 0; + return pTable ? pTable->ReleaseNote( rPos.Col(), rPos.Row() ) : 0; } -/** ScPostIt* ScDocument::GetOrCreateNote( const ScAddress& rPos ) - -Returns the pointer to the ScPostIt at rPos. - -If no ScPostIt exists at rPos, create a new one for rPos and return pointer - to newly created ScPostIt. -*/ ScPostIt* ScDocument::GetOrCreateNote( const ScAddress& rPos ) { ScPostIt* pNote = GetNote( rPos ); if( !pNote ) { pNote = new ScPostIt( *this, rPos, false ); - if ( ! SetNote( rPos, pNote ) ) - DELETEZ( pNote ); //apparently unsuccessful; don't leak memory + TakeNote( rPos, pNote ); } - return pNote; } +void ScDocument::DeleteNote( const ScAddress& rPos ) +{ + if( ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast<SCTAB>(maTabs.size()) && maTabs[ rPos.Tab() ] ) + maTabs[ rPos.Tab() ]->DeleteNote( rPos.Col(), rPos.Row() ); +} + + void ScDocument::InitializeNoteCaptions( SCTAB nTab, bool bForced ) { if( ValidTab( nTab ) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[ nTab ] ) diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index df0ec520b073..0d70c48bf568 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -406,7 +406,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX RowInfo* pThisRowInfo = &pRowInfo[nArrY]; CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX]; pInfo->pCell = pThisCol->pItems[nUIndex].pCell; - if (pInfo->pCell->GetCellType() != CELLTYPE_EMPTY) + if (pInfo->pCell->GetCellType() != CELLTYPE_NOTE) { pThisRowInfo->bEmptyText = false; // Zeile nicht leer pInfo->bEmptyCellText = false; // Zelle nicht leer diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index ad6ee1a0c11c..ddf0941d1b44 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -855,14 +855,13 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption( aNoteData.mpCaption = &rCaption; ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, false ); pNote->AutoStamp(); - - if ( rDoc.SetNote( rPos, pNote ) ) - // ScNoteCaptionCreator c'tor updates the caption object to be part - // of a note + rDoc.TakeNote( rPos, pNote ); + // if pNote still points to the note after TakeNote(), insertion was successful + if( pNote ) + { + // ScNoteCaptionCreator c'tor updates the caption object to be part of a note ScNoteCaptionCreator aCreator( rDoc, rPos, rCaption, bShown ); - else - DELETEZ( pNote ); // SetNote was apparently not successful. - + } return pNote; } @@ -893,9 +892,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData( visible, the caption object will be created automatically. */ ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption ); pNote->AutoStamp(); - if ( ! rDoc.SetNote( rPos, pNote ) ) - DELETEZ( pNote ); // SetNote was apparently not successful - + rDoc.TakeNote( rPos, pNote ); + // if pNote still points to the note after TakeNote(), insertion was successful return pNote; } @@ -916,8 +914,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromString( visible, the caption object will be created automatically. */ pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption ); pNote->AutoStamp(); - if ( ! rDoc.SetNote( rPos, pNote ) ) - DELETEZ( pNote ); // SetNote was apparently not successful + rDoc.TakeNote( rPos, pNote ); + // if pNote still points to the note after TakeNote(), insertion was successful } return pNote; } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 7c2edc2b01b3..941ca3668926 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1239,7 +1239,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa ScBaseCell* pCell = NULL; while ( aColIter.Next( nCellRow, pCell ) ) { - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { rRow = nCellRow; return true; // Zelle gefunden @@ -1655,7 +1655,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_EMPTY) + if (pNextCell && pNextCell->GetCellType() != CELLTYPE_NOTE) // Cell content in a next column ends display of this string. nMissing = 0; else diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 84fb8f1bbf4e..6b1835970f14 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -630,15 +630,9 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, else // kopieren { ScAddress aOwnPos( nCol, nRow, nTab ); - ScPostIt* pNewNote = pDocument->GetNote(aOwnPos); - if ( pNewNote ) - pNewNote = new ScPostIt( *pDestDoc, aDestPos, *pNewNote); - if ( ! pDestDoc->SetNote( aDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // if unsuccessful, don't leak mem - if (pCell->GetCellType() == CELLTYPE_FORMULA) { - pNew = pCell->Clone( *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); + pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); // Referenzen drehen // bei Cut werden Referenzen spaeter per UpdateTranspose angepasst @@ -648,7 +642,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } else { - pNew = pCell->Clone( *pDestDoc, aDestPos ); + pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos ); } } pTransClip->PutCell( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pNew ); @@ -1098,15 +1092,50 @@ void ScTable::GetFormula( SCCOL nCol, SCROW nRow, String& rFormula ) } +ScPostIt* ScTable::GetNote( SCCOL nCol, SCROW nRow ) +{ + return ValidColRow( nCol, nRow ) ? aCol[ nCol ].GetNote( nRow ) : 0; +} + + +void ScTable::TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote ) +{ + if( ValidColRow( nCol, nRow ) ) + { + aCol[ nCol ].TakeNote( nRow, rpNote ); + if( rpNote && rpNote->GetNoteData().mxInitData.get() ) + { + if( !mxUninitNotes.get() ) + mxUninitNotes.reset( new ScAddress2DVec ); + mxUninitNotes->push_back( ScAddress2D( nCol, nRow ) ); + } + InvalidateTableArea(); + } + else + DELETEZ( rpNote ); +} + + +ScPostIt* ScTable::ReleaseNote( SCCOL nCol, SCROW nRow ) +{ + return ValidColRow( nCol, nRow ) ? aCol[ nCol ].ReleaseNote( nRow ) : 0; +} + + +void ScTable::DeleteNote( SCCOL nCol, SCROW nRow ) +{ + if( ValidColRow( nCol, nRow ) ) + aCol[ nCol ].DeleteNote( nRow ); +} + + void ScTable::InitializeNoteCaptions( bool bForced ) { if( mxUninitNotes.get() && (bForced || pDocument->IsUndoEnabled()) ) { - for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt ) { - ScAddress aPos( aIt->first, aIt->second, nTab ); - if( ScPostIt* pNote = pDocument->GetNote( aPos ) ) - pNote->GetOrCreateCaption( aPos ); - } + for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt ) + if( ScPostIt* pNote = GetNote( aIt->first, aIt->second ) ) + pNote->GetOrCreateCaption( ScAddress( aIt->first, aIt->second, nTab ) ); mxUninitNotes.reset(); } } @@ -2941,7 +2970,7 @@ void ScTable::CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW n ScBaseCell* pCell = GetCell( nCol, nRow ); if (pCell) { - pCell = pCell->Clone( *pDocument ); + pCell = pCell->CloneWithoutNote( *pDocument ); if (pCell->GetCellType() == CELLTYPE_FORMULA) { ((ScFormulaCell*)pCell)->UpdateReference( URM_COPY, aRange, diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 2f9f8f086c3b..047a7f60bcdd 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -387,13 +387,13 @@ short ScTable::CompareCell( sal_uInt16 nSort, if (pCell1) { eType1 = pCell1->GetCellType(); - if ( CELLTYPE_EMPTY == eType1) + if (eType1 == CELLTYPE_NOTE) pCell1 = NULL; } if (pCell2) { eType2 = pCell2->GetCellType(); - if ( CELLTYPE_EMPTY == eType2 ) + if (eType2 == CELLTYPE_NOTE) pCell2 = NULL; } @@ -1202,7 +1202,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam, bMatchWholeCell = false; if ( pCell ) { - if (pCell->GetCellType() != CELLTYPE_EMPTY) + if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow ); ScCellFormat::GetInputString( pCell, nFormat, aCellStr, *(pDocument->GetFormatTable()) ); @@ -1451,9 +1451,8 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) ScSortInfo** ppInfo = pArray->GetFirstArray(); SCSIZE nValidCount = nCount; // keine Note-/Leerzellen zaehlen, sind ans Ende sortiert - while ( nValidCount > 0 - && ( NULL == ppInfo[nValidCount-1]->pCell - || CELLTYPE_EMPTY == ppInfo[nValidCount-1]->pCell->GetCellType() ) ) + while ( nValidCount > 0 && ( ppInfo[nValidCount-1]->pCell == NULL || + ppInfo[nValidCount-1]->pCell->GetCellType() == CELLTYPE_NOTE ) ) 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 556dd416903b..4854f493581e 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -808,7 +808,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { case CELLTYPE_STRING: case CELLTYPE_EDIT: - aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) ); + aCol[nCol].Insert( aDestPos.Row(), pSrcCell->CloneWithoutNote( *pDocument ) ); break; default: { @@ -1357,14 +1357,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, rProgress.SetStateOnPercent( ++nProgress ); } } - else if (eCellType != CELLTYPE_EMPTY) + else if (eCellType != CELLTYPE_NOTE) { for (rInner = nIMin; rInner <= nIMax; rInner++) { if (pDocument->RowFiltered( rInner, nTab)) continue; ScAddress aDestPos( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), nTab ); - aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) ); + aCol[nCol].Insert( aDestPos.Row(), pSrcCell->CloneWithoutNote( *pDocument ) ); } nProgress += nIMax - nIMin + 1; rProgress.SetStateOnPercent( nProgress ); diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 291f6a6ddba4..4edb697ad976 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -78,7 +78,6 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( bDoSearch && ((pCell = aCol[nCol].GetCell( nRow )) != NULL) ) { bool bMultiLine = false; - ScAddress cellPos( nCol, nRow, nTab ); CellType eCellType = pCell->GetCellType(); switch (rSearchItem.GetCellType()) { @@ -103,7 +102,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo break; case SVX_SEARCHIN_NOTE: { - if (const ScPostIt* pNote = pDocument->GetNote( cellPos )) + if(const ScPostIt* pNote = pCell->GetNote()) { aString = pNote->GetText(); bMultiLine = pNote->HasMultiLineText(); @@ -157,8 +156,9 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo rUndoStr = aString; else if (pUndoDoc) { - ScBaseCell* pUndoCell = pCell->Clone( *pUndoDoc ); - pUndoDoc->PutCell( cellPos, pUndoCell); + ScAddress aAdr( nCol, nRow, nTab ); + ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *pUndoDoc ); + pUndoDoc->PutCell( aAdr, pUndoCell); } bool bRepeat = !rSearchItem.GetWordOnly(); do @@ -219,8 +219,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo { // NB: rich text format is lost. // This is also true of Cells. - if ( ScPostIt* pNote = pDocument->GetNote( cellPos ) ) - pNote->SetText( cellPos, aString ); + if( ScPostIt* pNote = pCell->GetNote() ) + pNote->SetText( ScAddress( nCol, nRow, nTab ), aString ); } else if ( cMatrixFlag != MM_NONE ) { // Matrix nicht zerreissen @@ -231,7 +231,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( aString.GetChar(0) == '{' ) aString.Erase( 0, 1 ); } - ScFormulaCell* pFCell = new ScFormulaCell( pDocument, cellPos, + ScAddress aAdr( nCol, nRow, nTab ); + ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr, aString,formula::FormulaGrammar::GRAM_NATIVE_UI, cMatrixFlag ); SCCOL nMatCols; SCROW nMatRows; @@ -829,7 +830,7 @@ bool lcl_maybeReplaceCellString( ScColumn& rColObj, SCCOL& rCol, SCROW& rRow, rtl::OUString& rUndoStr, SCCOL nCol, SCROW nRow, const SvxSearchItem& rSearchItem) { ScBaseCell* pCell = rColObj.GetCell(nRow); - if (!pCell || CELLTYPE_EMPTY == pCell->GetCellType() ) + if (!pCell || pCell->GetCellType() == CELLTYPE_NOTE) { // empty cell found. rCol = nCol; @@ -1024,7 +1025,7 @@ bool ScTable::SearchRangeForAllEmptyCells( pUndoDoc->PutCell(nCol, nRow, nTab, new ScStringCell(String())); } } - else if ( CELLTYPE_EMPTY == pCell->GetCellType() ) + else if (pCell->GetCellType() == CELLTYPE_NOTE) { rMatchedRanges.Join(ScRange(nCol, nRow, nTab)); bFound = true; @@ -1033,15 +1034,8 @@ bool ScTable::SearchRangeForAllEmptyCells( { if (pUndoDoc) { - ScAddress aPos(nCol, nRow, nTab); - ScBaseCell* pNewCell = pCell->Clone(*pUndoDoc, aPos); - - ScPostIt* pNewNote = pDocument->GetNote( aPos ); - pNewNote = new ScPostIt( *pUndoDoc, aPos, *pNewNote ); - - pUndoDoc->PutCell(nCol, nRow, nTab, pNewCell); - if ( ! pUndoDoc->SetNote(aPos, pNewNote) ) - DELETEZ( pNewNote ); // don't leak mem on failure + ScAddress aCellPos(nCol, nRow, nTab); + pUndoDoc->PutCell(nCol, nRow, nTab, pCell->CloneWithNote(aCellPos, *pUndoDoc, aCellPos)); } aCol[nCol].SetString(nRow, nTab, rSearchItem.GetReplaceString()); } diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index f4093df94b75..6f9129de95f5 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -483,7 +483,7 @@ ScChartListenerCollection::~ScChartListenerCollection() { // remove ChartListener objects before aTimer dtor is called, because // ScChartListener::EndListeningTo may cause ScChartListenerCollection::StartTimer - // to be called if an empty ScEmptyCell is deleted + // to be called if an empty ScNoteCell is deleted if (GetCount()) FreeAll(); diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index a3c61333d96d..8a341a6c4a7d 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1686,7 +1686,7 @@ void ScChangeActionContent::SetValue( String& rStr, ScBaseCell*& pCell, pCell->Delete(); if ( ScChangeActionContent::GetContentCellType( pOrgCell ) ) { - pCell = pOrgCell->Clone( *pToDoc ); + pCell = pOrgCell->CloneWithoutNote( *pToDoc ); switch ( pOrgCell->GetCellType() ) { case CELLTYPE_VALUE : @@ -1846,7 +1846,7 @@ void ScChangeActionContent::PutValueToDoc( ScBaseCell* pCell, // nothing break; default: - pDoc->PutCell( aPos, pCell->Clone( *pDoc ) ); + pDoc->PutCell( aPos, pCell->CloneWithoutNote( *pDoc ) ); } } } @@ -4399,7 +4399,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScBaseCell* pNewCell = pContent->GetNewCell(); if ( pNewCell ) { - ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument ); + ScBaseCell* pClonedNewCell = pNewCell->CloneWithoutNote( *pDocument ); String aNewValue; pContent->GetNewString( aNewValue ); pClonedTrack->nGeneratedMin = pGenerated->GetActionNumber() + 1; @@ -4483,7 +4483,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScChangeActionContent* pContent = dynamic_cast< const ScChangeActionContent* >( pAction ); OSL_ENSURE( pContent, "ScChangeTrack::Clone: pContent is null!" ); const ScBaseCell* pOldCell = pContent->GetOldCell(); - ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->Clone( *pDocument ) : 0; + ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->CloneWithoutNote( *pDocument ) : 0; String aOldValue; pContent->GetOldString( aOldValue ); @@ -4502,7 +4502,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScBaseCell* pNewCell = pContent->GetNewCell(); if ( pNewCell ) { - ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument ); + ScBaseCell* pClonedNewCell = pNewCell->CloneWithoutNote( *pDocument ); pClonedContent->SetNewValue( pClonedNewCell, pDocument ); } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index c43f6f9f5763..1a484ef65bf4 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3091,7 +3091,7 @@ bool ScCompiler::IsColRowName( const String& rName ) break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: @@ -3220,7 +3220,7 @@ bool ScCompiler::IsColRowName( const String& rName ) break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index c4ec87742381..3fc28bbcea1f 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1762,7 +1762,7 @@ void ScInterpreter::ScIsEmpty() // ScCountEmptyCells(). // if (HasCellEmptyData( GetCell( aAdr))) CellType eCellType = GetCellType( GetCell( aAdr ) ); - if ( (CELLTYPE_NONE == eCellType) || (CELLTYPE_EMPTY == eCellType) ) + if((eCellType == CELLTYPE_NONE) || (eCellType == CELLTYPE_NOTE)) nRes = 1; } break; @@ -1926,7 +1926,7 @@ void ScInterpreter::ScType() switch ( GetCellType( pCell ) ) { // NOTE: this is Xcl nonsense! - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : nType = 1; // empty cell is value (0) break; case CELLTYPE_STRING : @@ -3492,7 +3492,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) if( eFunc == ifCOUNT2 ) { CellType eCellType = pCell->GetCellType(); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_EMPTY) + if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount++; if ( nGlobalError ) nGlobalError = 0; @@ -3555,7 +3555,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) do { CellType eType = pCell->GetCellType(); - if( eType != CELLTYPE_NONE && eType != CELLTYPE_EMPTY ) + if( eType != CELLTYPE_NONE && eType != CELLTYPE_NOTE ) nCount++; } while ( (pCell = aIter.GetNext()) != NULL ); @@ -4704,7 +4704,7 @@ void ScInterpreter::ScCountEmptyCells() ScAddress aAdr; PopSingleRef( aAdr ); eCellType = GetCellType( GetCell( aAdr ) ); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_EMPTY) + if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount = 1; } break; @@ -4728,7 +4728,7 @@ void ScInterpreter::ScCountEmptyCells() do { if ((eCellType = pCell->GetCellType()) != CELLTYPE_NONE - && eCellType != CELLTYPE_EMPTY) + && eCellType != CELLTYPE_NOTE) nCount++; } while ( (pCell = aDocIter.GetNext()) != NULL ); } @@ -6170,7 +6170,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) } else { - if ( CELLTYPE_EMPTY == GetCellType( pCell ) ) + if ( GetCellType( pCell ) == CELLTYPE_NOTE ) { rEntry.bQueryByString = false; rEntry.nVal = 0.0; diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 008a8835847a..bbde6aaad2c0 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1607,8 +1607,8 @@ void ScInterpreter::ScBackSolver() if (nGlobalError == 0) { ScBaseCell* pVCell = GetCell( aValueAdr ); - // CELLTYPE_EMPTY: kein Value aber von Formel referiert - bool bTempCell = (!pVCell || CELLTYPE_EMPTY == pVCell->GetCellType() ); + // CELLTYPE_NOTE: kein Value aber von Formel referiert + bool bTempCell = (!pVCell || pVCell->GetCellType() == CELLTYPE_NOTE); ScBaseCell* pFCell = GetCell( aFormulaAdr ); if ( ((pVCell && pVCell->GetCellType() == CELLTYPE_VALUE) || bTempCell) @@ -1620,7 +1620,7 @@ void ScInterpreter::ScBackSolver() if ( bTempCell ) { - pNote = pDok->GetNote( aValueAdr ); + pNote = pVCell ? pVCell->ReleaseNote() : 0; fSaveVal = 0.0; pVCell = new ScValueCell( fSaveVal ); pDok->PutCell( aValueAdr, pVCell ); @@ -1769,12 +1769,7 @@ void ScInterpreter::ScBackSolver() } if ( bTempCell ) { - pVCell = 0; - if ( pNote ) { - pVCell = new ScEmptyCell(); - if ( ! pDok->SetNote( aValueAdr, pNote ) ) - DELETEZ( pNote ); - } + pVCell = pNote ? new ScNoteCell( pNote ) : 0; pDok->PutCell( aValueAdr, pVCell ); } else diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index ade3e2361d8a..261403e6ed90 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -493,7 +493,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel } break; case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: fValue = 0.0; // empty or broadcaster cell break; case CELLTYPE_SYMBOLS: @@ -2677,7 +2677,7 @@ void ScInterpreter::ScExternal() } else if ( ( aUnoName = ScGlobal::GetAddInCollection()->FindFunction(aFuncName, false) ).Len() ) { - // bLocalFirst=false in FindFunction, cFunc should be the stored + // bLocalFirst=false in FindFunction, cFunc should be the stored // internal name ScUnoAddInCall aCall( *ScGlobal::GetAddInCollection(), aUnoName, nParamCount ); diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx index 30ec33e580f0..980ca093f1fa 100644 --- a/sc/source/filter/dif/difexp.cxx +++ b/sc/source/filter/dif/difexp.cxx @@ -175,7 +175,7 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc switch( pAkt->GetCellType() ) { case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: aOS.AssignAscii( pEmptyData ); break; case CELLTYPE_VALUE: diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index a36b08190ce0..e6621f000b40 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2329,7 +2329,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : OSL_FAIL( "XclExpCellTable::XclExpCellTable - unknown cell type" ); // run-through! case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: { xCell.reset( new XclExpBlankCell( GetRoot(), aXclPos, nLastXclCol, pPattern, nMergeBaseXFId ) ); @@ -2342,7 +2342,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : maRowBfr.AppendCell( xCell, bIsMergedBase ); // notes - const ScPostIt* pScNote = rDoc.GetNote(aScPos); + const ScPostIt* pScNote = pScCell ? pScCell->GetNote() : 0; if( pScNote || (aAddNoteText.Len() > 0) ) mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, aAddNoteText ) ); diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index c7ceea9bd37e..84c734e7fd13 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -1181,7 +1181,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) Color* pColor; switch ( pCell->GetCellType() ) { - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : // nothing break; case CELLTYPE_EDIT : diff --git a/sc/source/filter/lotus/expop.cxx b/sc/source/filter/lotus/expop.cxx index f1b5a8dcbe8f..c1b0ae23a4e2 100644 --- a/sc/source/filter/lotus/expop.cxx +++ b/sc/source/filter/lotus/expop.cxx @@ -393,7 +393,7 @@ FltError ExportWK1::Write() WKString( nCol, nRow, ( ScFormulaCell * ) pCell, *pPatAttr ); } break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_NONE: break; default: diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx index a1d78f26ba0e..ffef3ce6a782 100644 --- a/sc/source/filter/rtf/rtfexp.cxx +++ b/sc/source/filter/rtf/rtfexp.cxx @@ -195,7 +195,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) { switch ( pCell->GetCellType() ) { - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : bValueData = false; break; // nix case CELLTYPE_EDIT : diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index 5808ac9b2122..d5259697fbb9 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -101,7 +101,7 @@ ScBaseCell* ScMyCellInfo::CreateCell(ScDocument* pDoc) } } - return pCell ? pCell->Clone( *pDoc ) : 0; + return pCell ? pCell->CloneWithoutNote( *pDoc ) : 0; } ScMyDeleted::ScMyDeleted() @@ -682,7 +682,7 @@ void ScXMLChangeTrackingImportHelper::SetContentDependencies(ScMyContentAction* const ScBaseCell* pOldCell = pActContent->GetOldCell(); if (pOldCell) { - ScBaseCell* pNewCell = pOldCell->Clone( *pDoc ); + ScBaseCell* pNewCell = pOldCell->CloneWithoutNote( *pDoc ); if (pNewCell) { pPrevActContent->SetNewCell(pNewCell, pDoc, EMPTY_STRING); @@ -774,7 +774,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) { ScBaseCell* pNewCell = NULL; if (pCell->GetCellType() != CELLTYPE_FORMULA) - pNewCell = pCell->Clone( *pDoc ); + pNewCell = pCell->CloneWithoutNote( *pDoc ); else { sal_uInt8 nMatrixFlag = static_cast<ScFormulaCell*>(pCell)->GetMatrixFlag(); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 2a13153b35af..06d80ced67cf 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -761,7 +761,7 @@ bool lcl_IsEmptyOrNote( ScDocument* pDoc, const table::CellAddress& rCurrentPos ScAddress aScAddress; ScUnoConversion::FillScAddress( aScAddress, rCurrentPos ); ScBaseCell* pCell = pDoc->GetCell( aScAddress ); - return ( !pCell || CELLTYPE_EMPTY == pCell->GetCellType() ); + return ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE ); } void ScXMLTableRowCellContext::EndElement() diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index d316aedea925..6bf85b573937 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -1178,10 +1178,9 @@ sal_Bool lcl_EmptyExcept( ScDocument* pDoc, const ScRange& rRange, const ScRange ScBaseCell* pCell = aIter.GetFirst(); while (pCell) { - ScAddress aPos( aIter.GetPos() ); - if ( !pCell->IsBlank() || pDoc->GetNote( aPos ) ) // real content? + if ( !pCell->IsBlank() ) // real content? { - if ( !rExcept.In( aPos ) ) + if ( !rExcept.In( ScAddress( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ) ) ) return false; // cell found } pCell = aIter.GetNext(); diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index f260d798aba8..f218b8b0ac21 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -791,7 +791,7 @@ sal_Bool ScDocFunc::SetNormalString( const ScAddress& rPos, const String& rText, pTabs = new SCTAB[1]; pTabs[0] = rPos.Tab(); ppOldCells = new ScBaseCell*[1]; - ppOldCells[0] = pDocCell ? pDocCell->Clone( *pDoc ) : 0; + ppOldCells[0] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; pHasFormat = new sal_Bool[1]; pOldFormats = new sal_uLong[1]; @@ -855,8 +855,8 @@ sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bo sal_Bool bHeight = ( bEditDeleted || bEditCell || pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) ); - ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->Clone( *pDoc, rPos ) : 0; - ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->Clone( *pDoc, rPos ) : 0; + ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->CloneWithoutNote( *pDoc, rPos ) : 0; + ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->CloneWithoutNote( *pDoc, rPos ) : 0; pDoc->PutCell( rPos, pNewCell ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 047cbf54235b..d09eb8f33647 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -270,7 +270,7 @@ sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates ) { ScCellIterator aCellIter( &aDocument, 0,0, nTable, MAXCOL,MAXROW, nTable ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bFound; pCell = aCellIter.GetNext() ) - if (aDocument.GetNote( aCellIter.GetPos() )) + if (pCell->HasNote()) bFound = sal_True; nTable++; } @@ -1798,7 +1798,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt sal_Bool bString; switch ( eType ) { - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_NONE: aString.Erase(); bString = false; diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index ec4c0a4678ca..c33b76a923c6 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -973,7 +973,7 @@ sal_uLong ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet { ScBaseCell* pCell; aDocument.GetCell( nDocCol, nDocRow, nTab, pCell ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) { // Paragraphs erhalten @@ -1090,7 +1090,7 @@ sal_uLong ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet { case sdbc::DataType::LONGVARCHAR: { - if ( pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell->GetCellType() != CELLTYPE_NOTE ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) lcl_getLongVarCharEditString( aString, diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index a77065d613c3..830d832399c0 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1362,7 +1362,7 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p const sal_Unicode cBlank = ' '; if (!ScGlobal::UnicodeStrChr( pSeps, cBlank)) { - // Cope with broken generators that put leading blanks before a quoted + // Cope with broken generators that put leading blanks before a quoted // field, like "field1", "field2", "..." // NOTE: this is not in conformance with http://tools.ietf.org/html/rfc4180 const sal_Unicode* pb = p; @@ -1495,7 +1495,7 @@ sal_Bool ScImportExport::Doc2Text( SvStream& rStrm ) lcl_WriteSimpleString( rStrm, aCell ); } break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_NONE: break; default: diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 85dd15da18fb..25330e7ca78c 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -878,7 +878,7 @@ void ScContentTree::GetNoteStrings() { ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab ); for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() ) - if ( const ScPostIt* pNote = pDoc->GetNote( aIter.GetPos() ) ) + if( const ScPostIt* pNote = pCell->GetNote() ) InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) ); } } @@ -897,10 +897,10 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex ) ScBaseCell* pCell = aIter.GetFirst(); while (pCell) { - if( pDoc->GetNote( aIter.GetPos() ) ) + if( pCell->HasNote() ) { if (nFound == nIndex) - return aIter.GetPos(); + return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden ++nFound; } pCell = aIter.GetNext(); @@ -931,7 +931,7 @@ sal_Bool ScContentTree::NoteStringsChanged() ScBaseCell* pCell = aIter.GetFirst(); while (pCell && bEqual) { - if ( const ScPostIt* pNote = pDoc->GetNote( aIter.GetPos() ) ) + if( const ScPostIt* pNote = pCell->GetNote() ) { if ( !pEntry ) bEqual = false; diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 1fb2d3ac6304..a4c6c6dc529f 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -278,7 +278,7 @@ void ScUndoEnterData::Undo() ScDocument* pDoc = pDocShell->GetDocument(); for (sal_uInt16 i=0; i<nCount; i++) { - ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell ); if (pHasFormat && pOldFormats) @@ -411,7 +411,7 @@ void ScUndoEnterValue::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos, pNewCell ); @@ -497,7 +497,7 @@ void ScUndoPutCell::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); @@ -515,7 +515,7 @@ void ScUndoPutCell::Redo() BeginRedo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); @@ -901,8 +901,7 @@ void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData ) ScDocument& rDoc = *pDocShell->GetDocument(); OSL_ENSURE( !rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" ); ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false ); - if ( ! rDoc.SetNote( maPos, pNote ) ) - DELETEZ( pNote ); // Apparently unsuccesful, so don't leak memory. + rDoc.TakeNote( maPos, pNote ); } } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 7b6cd4c6338b..748b3c0b3cc1 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1276,7 +1276,7 @@ String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, sal_Boo if ( pDoc ) { ScBaseCell* pCell = pDoc->GetCell( rPosition ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { CellType eType = pCell->GetCellType(); if ( eType == CELLTYPE_FORMULA ) @@ -3446,9 +3446,10 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCel while (pCell) { // Notizen zaehlen als nicht-leer - ScAddress aPos( aIter.GetPos() ); - if ( !pCell->IsBlank() || pDoc->GetNote( aPos ) ) - aMarkData.SetMultiMarkArea( ScRange( aPos ), false ); + if ( !pCell->IsBlank() ) + aMarkData.SetMultiMarkArea( + ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ), + false ); pCell = aIter.GetNext(); } @@ -3486,8 +3487,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC while (pCell) { sal_Bool bAdd = false; - if ( pDoc->GetNote( aIter.GetPos() ) - && ( nContentFlags & sheet::CellFlags::ANNOTATION ) ) + if ( pCell->HasNote() && ( nContentFlags & sheet::CellFlags::ANNOTATION ) ) bAdd = sal_True; else switch ( pCell->GetCellType() ) @@ -3639,7 +3639,7 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl( ScBaseCell* pCmpCell = aCmpIter.GetFirst(); while (pCmpCell) { - if (pCmpCell->GetCellType() != CELLTYPE_EMPTY) + if (pCmpCell->GetCellType() != CELLTYPE_NOTE) { SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetCol()) : static_cast<SCCOLROW>(aCmpIter.GetRow()); if (bColumnDiff) @@ -6174,7 +6174,7 @@ String ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellP if ( pDoc ) { ScBaseCell* pCell = pDoc->GetCell( aCellPos ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) { @@ -9201,7 +9201,7 @@ void ScCellsEnumeration::CheckPos_Impl() sal_Bool bFound = false; ScDocument* pDoc = pDocShell->GetDocument(); ScBaseCell* pCell = pDoc->GetCell(aPos); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { if (!pMark) { diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index f3b91a589e1e..757edb66d1ed 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2451,7 +2451,7 @@ void ScChart2DataSequence::BuildDataCache() #endif case CELLTYPE_EDIT: case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_STRING: case CELLTYPE_SYMBOLS: default: diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 73fa37ce8323..4d4d5880a2a2 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -3397,11 +3397,11 @@ bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) { - if ( pDoc->GetNote( aCellIter.GetPos() ) ) + if (pCell->HasNote()) { if (nFound == nIndex) { - rPos = aCellIter.GetPos(); + rPos = ScAddress( aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab() ); return true; } ++nFound; @@ -3476,10 +3476,9 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException) sal_uLong nCount = 0; if (pDocShell) { - ScDocument* pDoc = pDocShell->GetDocument(); - ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); + ScCellIterator aCellIter( pDocShell->GetDocument(), 0,0, nTab, MAXCOL,MAXROW, nTab ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) - if ( pDoc->GetNote( aCellIter.GetPos() ) ) + if (pCell->HasNote()) ++nCount; } return nCount; diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index bc78043cb7b0..f49a2402ed85 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -193,7 +193,7 @@ sal_Bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange, { if (pCell->GetCellType() == CELLTYPE_FORMULA) { - ScAddress aCellPos( aIter.GetPos() ); + ScAddress aCellPos = aIter.GetPos(); sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos); if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) { diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index d27bba70128b..531ac702250d 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -936,7 +936,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) { ScCellIterator aCellIter(pDoc, *aRanges[nPos]); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() ) - if ( pDoc->GetNote( aCellIter.GetPos() ) ) + if ( pCell->HasNote() ) bEnable = sal_True; // note found } } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 14609a7d15e0..69c7a52d7c58 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -387,7 +387,7 @@ sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTA do { pDoc->GetCell( rPosX, rPosY, nTab, rpCell ); - if ( !rpCell || CELLTYPE_EMPTY == rpCell->GetCellType() ) + if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE ) { if ( rPosX <= 0 ) return false; // alles leer bis links diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 14515f68ce1f..35fbedc52469 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2096,7 +2096,6 @@ void ScOutputData::DrawNoteMarks() { CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; ScBaseCell* pCell = pInfo->pCell; - ScAddress aPos( nX, pThisRowInfo->nRowNo, nTab ); sal_Bool bIsMerged = false; if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) @@ -2107,17 +2106,12 @@ void ScOutputData::DrawNoteMarks() SCCOL nMergeX = nX; SCROW nMergeY = nY; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - aPos.SetCol( nMergeX ); - aPos.SetRow( nMergeY ); - pCell = pDoc->GetCell( aPos ); + pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); // use origin's pCell for NotePtr test below } - if ( pCell - && pDoc->GetNote( aPos ) - && ( bIsMerged - || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) - ) + if ( pCell && pCell->HasNote() && ( bIsMerged || + ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { if (bFirst) { @@ -2184,24 +2178,18 @@ void ScOutputData::AddPDFNotes() SCROW nY = pRowInfo[nArrY].nRowNo; SCCOL nMergeX = nX; SCROW nMergeY = nY; - ScAddress aPos( nX, nY, nTab ); if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) { // find start of merged cell bIsMerged = sal_True; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - aPos.SetCol( nMergeX ); - aPos.SetRow( nMergeY ); - pCell = pDoc->GetCell( aPos ); + pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); // use origin's pCell for NotePtr test below } - const ScPostIt* pNote = pDoc->GetNote( aPos ); - if ( pCell && pNote - && ( bIsMerged - || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) - ) + if ( pCell && pCell->HasNote() && ( bIsMerged || + ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { long nNoteWidth = (long)( SC_CLIPMARK_SIZE * nPPTX ); long nNoteHeight = (long)( SC_CLIPMARK_SIZE * nPPTY ); @@ -2220,10 +2208,11 @@ void ScOutputData::AddPDFNotes() if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) ) { Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight ); + const ScPostIt* pNote = pCell->GetNote(); // Note title is the cell address (as on printed note pages) String aTitle; - ScAddress aAddress( aPos ); + ScAddress aAddress( nMergeX, nMergeY, nTab ); aAddress.Format( aTitle, SCA_VALID, pDoc, pDoc->GetAddressConvention() ); // Content has to be a simple string without line breaks diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 0082cdf92052..b0dba17f4507 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1088,7 +1088,7 @@ sal_Bool ScOutputData::IsAvailable( SCCOL nX, SCROW nY ) // where a note is empty as well as a cell that's hidden by protection settings const ScBaseCell* pCell = pDoc->GetCell( ScAddress( nX, nY, nTab ) ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY && !IsEmptyCellText( NULL, nX, nY ) ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE && !IsEmptyCellText( NULL, nX, nY ) ) { return false; } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 4dee3fb68ce4..7c07e11c714f 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1924,7 +1924,8 @@ long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocation { ScAddress &rPos = aNotePosList[ nNoteStart + nCount ]; - if( const ScPostIt* pNote = pDoc->GetNote( rPos ) ) + ScBaseCell* pCell = pDoc->GetCell( rPos); + if( const ScPostIt* pNote = pCell->GetNote() ) { if(const EditTextObject *pEditText = pNote->GetEditTextObject()) pEditEngine->SetText(*pEditText); @@ -2564,10 +2565,9 @@ long ScPrintFunc::CountNotePages() ScBaseCell* pCell = aIter.GetNext( nCol, nRow ); while (pCell) { - ScAddress aPos( nCol, nRow, nPrintTab ); - if ( pDoc->GetNote( aPos ) ) + if (pCell->HasNote()) { - aNotePosList.push_back( aPos ); + aNotePosList.push_back( ScAddress( nCol,nRow,nPrintTab ) ); ++nCount; } diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index 1b047acc8e87..10d517b31a5e 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -136,7 +136,7 @@ bool ScConversionEngineBase::FindNextConversionCell() if( mpUndoDoc && pCell ) { - ScBaseCell* pUndoCell = pCell->Clone( *mpUndoDoc ); + ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *mpUndoDoc ); mpUndoDoc->PutCell( aPos, pUndoCell ); } @@ -157,7 +157,7 @@ bool ScConversionEngineBase::FindNextConversionCell() if( mpRedoDoc && pCell ) { - ScBaseCell* pRedoCell = pCell->Clone( *mpRedoDoc ); + ScBaseCell* pRedoCell = pCell->CloneWithoutNote( *mpRedoDoc ); mpRedoDoc->PutCell( aPos, pRedoCell ); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index dcea6d5ee24c..dacdb113f932 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -397,7 +397,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS pDoc->GetCell( nCol, nRow, i, pDocCell ); if ( pDocCell ) { - ppOldCells[nUndoPos] = pDocCell->Clone( *pDoc ); + ppOldCells[nUndoPos] = pDocCell->CloneWithoutNote( *pDoc ); if ( pDocCell->GetCellType() == CELLTYPE_EDIT ) bEditDeleted = sal_True; @@ -709,7 +709,7 @@ void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& r nCol,nRow,nTab, nCol,nRow,nTab, HASATTR_NEEDHEIGHT ); // Undo - ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->Clone( *pDoc ) : 0; + ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->CloneWithoutNote( *pDoc ) : 0; pDoc->SetValue( nCol, nRow, nTab, rValue ); @@ -804,7 +804,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb pTabs[nPos] = *itr; ScBaseCell* pDocCell; pDoc->GetCell( nCol, nRow, *itr, pDocCell ); - ppOldCells[nPos] = pDocCell ? pDocCell->Clone( *pDoc ) : 0; + ppOldCells[nPos] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; ++nPos; } |