summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-02-23 23:36:49 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-02-29 23:37:51 +0100
commitc06dbbe7594c2a0b5a5b19f8e183d9c421e6e094 (patch)
tree276dbc9a2c9589953c79bc45c70a965b99482ec0 /sc/source
parenta6d65732f14e49be8ec61aac53a2a8b909d810f7 (diff)
remove mpNote from ScBaseCell
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/cell.cxx40
-rw-r--r--sc/source/core/data/column.cxx7
-rw-r--r--sc/source/core/data/column2.cxx37
-rw-r--r--sc/source/core/data/column3.cxx138
-rw-r--r--sc/source/core/data/document.cxx50
-rw-r--r--sc/source/core/data/drwlayer.cxx2
-rw-r--r--sc/source/core/data/postit.cxx192
-rw-r--r--sc/source/core/data/table1.cxx69
-rw-r--r--sc/source/core/data/table2.cxx121
-rw-r--r--sc/source/core/data/table3.cxx17
-rw-r--r--sc/source/core/data/table6.cxx19
-rw-r--r--sc/source/core/tool/detfunc.cxx2
-rw-r--r--sc/source/core/tool/interpr2.cxx22
-rw-r--r--sc/source/filter/excel/excdoc.cxx17
-rw-r--r--sc/source/filter/excel/xetable.cxx6
-rw-r--r--sc/source/filter/inc/excdoc.hxx5
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx18
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx4
-rw-r--r--sc/source/ui/docshell/docfunc.cxx8
-rw-r--r--sc/source/ui/docshell/docsh.cxx12
-rw-r--r--sc/source/ui/drawfunc/futext3.cxx6
-rw-r--r--sc/source/ui/navipi/content.cxx37
-rw-r--r--sc/source/ui/undo/undoblk3.cxx2
-rw-r--r--sc/source/ui/undo/undocell.cxx12
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx76
-rw-r--r--sc/source/ui/unoobj/docuno.cxx21
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx4
-rw-r--r--sc/source/ui/unoobj/notesuno.cxx4
-rw-r--r--sc/source/ui/view/cellsh.cxx25
-rw-r--r--sc/source/ui/view/cellsh1.cxx2
-rw-r--r--sc/source/ui/view/drawview.cxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx2
-rw-r--r--sc/source/ui/view/gridwin5.cxx2
-rw-r--r--sc/source/ui/view/output.cxx8
-rw-r--r--sc/source/ui/view/printfun.cxx26
-rw-r--r--sc/source/ui/view/viewfun6.cxx2
36 files changed, 544 insertions, 473 deletions
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index c8ac64f3e5a3..11ac123cdf41 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -80,7 +80,6 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell )
// ============================================================================
ScBaseCell::ScBaseCell( CellType eNewType ) :
- mpNote( 0 ),
mpBroadcaster( 0 ),
nTextWidth( TEXTWIDTH_DIRTY ),
eCellType( sal::static_int_cast<sal_uInt8>(eNewType) ),
@@ -89,7 +88,6 @@ ScBaseCell::ScBaseCell( CellType eNewType ) :
}
ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) :
- mpNote( 0 ),
mpBroadcaster( 0 ),
nTextWidth( rCell.nTextWidth ),
eCellType( rCell.eCellType ),
@@ -99,7 +97,6 @@ ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) :
ScBaseCell::~ScBaseCell()
{
- delete mpNote;
delete mpBroadcaster;
OSL_ENSURE( eCellType == CELLTYPE_DESTROYED, "BaseCell Destructor" );
}
@@ -246,19 +243,11 @@ ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, const ScAddress&
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:
@@ -282,27 +271,9 @@ void ScBaseCell::Delete()
}
}
-bool ScBaseCell::IsBlank( bool bIgnoreNotes ) const
-{
- return (eCellType == CELLTYPE_NOTE) && (bIgnoreNotes || !mpNote);
-}
-
-void ScBaseCell::TakeNote( ScPostIt* pNote )
+bool ScBaseCell::IsBlank() const
{
- delete mpNote;
- mpNote = pNote;
-}
-
-ScPostIt* ScBaseCell::ReleaseNote()
-{
- ScPostIt* pNote = mpNote;
- mpNote = 0;
- return pNote;
-}
-
-void ScBaseCell::DeleteNote()
-{
- DELETEZ( mpNote );
+ return false;
}
void ScBaseCell::TakeBroadcaster( SvtBroadcaster* pBroadcaster )
@@ -662,13 +633,6 @@ ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) :
TakeBroadcaster( pBC );
}
-ScNoteCell::ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC ) :
- ScBaseCell( CELLTYPE_NOTE )
-{
- TakeNote( pNote );
- TakeBroadcaster( pBC );
-}
-
#if OSL_DEBUG_LEVEL > 0
ScNoteCell::~ScNoteCell()
{
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 444cc67df767..4df060c4aed5 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -932,12 +932,9 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
}
}
- // do not swap formula cells with equal formulas, but swap notes
+ // do not swap formula cells with equal formulas
if (bEqual)
{
- ScPostIt* pNote1 = pCell1->ReleaseNote();
- pCell1->TakeNote( pCell2->ReleaseNote() );
- pCell2->TakeNote( pNote1 );
return;
}
}
@@ -947,7 +944,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
variable swapping above). Do not clone the note, but move pointer of
old note to new cell. */
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. */
@@ -955,7 +951,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
if ( pCell2 )
{
pNew1 = pCell2->CloneWithoutNote( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL );
- pNew1->TakeNote( pCell2->ReleaseNote() );
}
// move old broadcasters new cells at the same old position
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 865820a1e0f6..1ca582dec35d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -933,7 +933,6 @@ void ScColumn::RemoveAutoSpellObj()
String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine );
ScBaseCell* pNewCell = new ScStringCell( aText );
pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() );
- pNewCell->TakeNote( pOldCell->ReleaseNote() );
maItems[i].pCell = pNewCell;
delete pOldCell;
}
@@ -1003,7 +1002,6 @@ 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() );
maItems[i].pCell = pNewCell;
delete pOldCell;
}
@@ -1124,7 +1122,7 @@ bool ScColumn::IsEmptyData() const
return (maItems.empty());
}
-bool ScColumn::IsEmptyVisData(bool bNotes) const
+bool ScColumn::IsEmptyVisData() const
{
if ( maItems.empty() )
return true;
@@ -1134,9 +1132,7 @@ bool ScColumn::IsEmptyVisData(bool bNotes) const
SCSIZE i;
for (i=0; i<maItems.size() && !bVisData; i++)
{
- ScBaseCell* pCell = maItems[i].pCell;
- if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) )
- bVisData = true;
+ bVisData = true;
}
return !bVisData;
}
@@ -1151,8 +1147,7 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const
Search( nStartRow, nIndex );
while ( nIndex < maItems.size() && maItems[nIndex].nRow <= nEndRow )
{
- if ( maItems[nIndex].nRow >= nStartRow &&
- maItems[nIndex].pCell->GetCellType() != CELLTYPE_NOTE )
+ if ( maItems[nIndex].nRow >= nStartRow )
{
++nVisCount;
}
@@ -1161,7 +1156,7 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const
return nVisCount;
}
-SCROW ScColumn::GetLastVisDataPos(bool bNotes) const
+SCROW ScColumn::GetLastVisDataPos() const
{
SCROW nRet = 0;
if ( !maItems.empty() )
@@ -1171,18 +1166,14 @@ SCROW ScColumn::GetLastVisDataPos(bool bNotes) const
for (i=maItems.size(); i>0 && !bFound; )
{
--i;
- ScBaseCell* pCell = maItems[i].pCell;
- if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) )
- {
- bFound = true;
- nRet = maItems[i].nRow;
- }
+ bFound = true;
+ nRet = maItems[i].nRow;
}
}
return nRet;
}
-SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const
+SCROW ScColumn::GetFirstVisDataPos() const
{
SCROW nRet = 0;
if ( !maItems.empty() )
@@ -1191,12 +1182,8 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const
bool bFound = false;
for (i=0; i<maItems.size() && !bFound; i++)
{
- ScBaseCell* pCell = maItems[i].pCell;
- if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) )
- {
- bFound = true;
- nRet = maItems[i].nRow;
- }
+ bFound = true;
+ nRet = maItems[i].nRow;
}
}
return nRet;
@@ -1225,7 +1212,7 @@ bool ScColumn::IsEmpty() const
return (IsEmptyData() && IsEmptyAttr());
}
-bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow, bool bIgnoreNotes) const
+bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
{
if ( maItems.empty() )
return true;
@@ -1234,7 +1221,7 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow, bool bIgnoreNotes) c
Search( nStartRow, nIndex );
while ( nIndex < maItems.size() && maItems[nIndex].nRow <= nEndRow )
{
- if ( !maItems[nIndex].pCell->IsBlank( bIgnoreNotes ) ) // found a cell
+ if ( !maItems[nIndex].pCell->IsBlank() ) // found a cell
return false; // not empty
++nIndex;
}
@@ -1447,7 +1434,7 @@ bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow ) const
if (pAttrArray)
{
// row of last cell is needed
- SCROW nLastData = GetLastVisDataPos( true ); // always including notes, 0 if none
+ SCROW nLastData = GetLastVisDataPos(); // always including notes, 0 if none
return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData );
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ab9f666034e6..66db4efce517 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -91,8 +91,6 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
// move broadcaster and note to new cell, if not existing in new cell
if (pOldCell->HasBroadcaster() && !pNewCell->HasBroadcaster())
pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() );
- if (pOldCell->HasNote() && !pNewCell->HasNote())
- pNewCell->TakeNote( pOldCell->ReleaseNote() );
if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() )
{
@@ -310,12 +308,6 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
have to forget the pointers to them. This is used e.g. while undoing a
"paste cells" operation, which removes the caption objects later in
drawing undo. */
- bool bDeleteNote = (nDelFlag & IDF_NOTE) != 0;
- bool bNoCaptions = (nDelFlag & IDF_NOCAPTIONS) != 0;
- if (bDeleteNote && bNoCaptions)
- for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx )
- if ( ScPostIt* pNote = maItems[ nIdx ].pCell->GetNote() )
- pNote->ForgetCaption();
ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 );
@@ -395,7 +387,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
case CELLTYPE_NOTE:
// do note delete note cell with broadcaster
- bDelete = bDeleteNote && !pOldCell->GetBroadcaster();
+ bDelete = !pOldCell->GetBroadcaster();
break;
default:; // added to avoid warnings
@@ -408,24 +400,9 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
ScNoteCell* pNoteCell = NULL;
SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
bool bKeepBC = pBC && pBC->HasListeners();
- if (eCellType == CELLTYPE_NOTE)
- {
- if (bKeepBC)
- {
- // We need to keep this "note" cell to keep the broadcaster.
- pNoteCell = static_cast<ScNoteCell*>(pOldCell);
- if (bDeleteNote)
- pOldCell->DeleteNote();
- }
- }
- else
- {
- // 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
- if (pNote || bKeepBC)
- pNoteCell = new ScNoteCell( pNote, pBC );
- }
+ // #i99844# do not release broadcaster from old cell, it still has to notify deleted content
+ if ( bKeepBC)
+ pNoteCell = new ScNoteCell( pBC );
// remove cell entry in cell item list
SCROW nOldRow = maItems[nIdx].nRow;
@@ -457,12 +434,6 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
}
}
}
- else
- {
- // delete cell note
- if (bDeleteNote)
- maItems[nIdx].pCell->DeleteNote();
- }
if (!bDelete)
{
@@ -753,9 +724,6 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy,
Resize( nNew );
}
- // IDF_ADDNOTES must be passed without other content flags than IDF_NOTE
- bool bAddNotes = (nInsFlag & (IDF_CONTENTS | IDF_ADDNOTES)) == (IDF_NOTE | IDF_ADDNOTES);
-
sal_Bool bAtEnd = false;
for (SCSIZE i = 0; i < nColCount && !bAtEnd; i++)
{
@@ -769,37 +737,11 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy,
ScAddress aDestPos( nCol, (SCROW)nDestRow, nTab );
- /* #i102056# Paste from clipboard needs to paste the cell notes in
- a second pass. This must not overwrite the existing cells
- already copied to the destination position in the first pass.
- To indicate this special case, the modifier IDF_ADDNOTES is
- 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* pAddNoteCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0;
- if (pAddNoteCell)
- {
- // do nothing if source cell does not contain a note
- const ScBaseCell* pSourceCell = rColumn.maItems[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.maItems[i].nRow, rColumn.nTab );
- ScPostIt* pNewNote = pSourceNote->Clone( aSourcePos, *pDocument, aDestPos, bCloneCaption );
- pAddNoteCell->TakeNote( pNewNote );
- }
- }
- else
- {
- ScBaseCell* pNewCell = bAsLink ?
- rColumn.CreateRefCell( pDocument, aDestPos, i, nInsFlag ) :
- rColumn.CloneCell( i, nInsFlag, *pDocument, aDestPos );
- if (pNewCell)
- Insert( aDestPos.Row(), pNewCell );
- }
+ ScBaseCell* pNewCell = bAsLink ?
+ rColumn.CreateRefCell( pDocument, aDestPos, i, nInsFlag ) :
+ rColumn.CloneCell( i, nInsFlag, *pDocument, aDestPos );
+ if (pNewCell)
+ Insert( aDestPos.Row(), pNewCell );
}
}
}
@@ -831,7 +773,6 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD
bool bCloneString = (nFlags & IDF_STRING) != 0;
bool bCloneSpecialBoolean = (nFlags & IDF_SPECIAL_BOOLEAN) != 0;
bool bCloneFormula = (nFlags & IDF_FORMULA) != 0;
- bool bCloneNote = (nFlags & IDF_NOTE) != 0;
bool bForceFormula = false;
ScBaseCell* pNew = 0;
@@ -918,22 +859,6 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD
default: OSL_FAIL( "ScColumn::CloneCell - unknown cell type" );
}
- // clone the cell note
- if (bCloneNote)
- {
- 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
- ScAddress aOwnPos( nCol, maItems[nIndex].nRow, nTab );
- ScPostIt* pNewNote = pNote->Clone( aOwnPos, rDestDoc, rDestPos, bCloneCaption );
- if (!pNew)
- pNew = new ScNoteCell( pNewNote );
- else
- pNew->TakeNote( pNewNote );
- }
- }
-
return pNew;
}
@@ -1465,14 +1390,9 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
if (Search(nRow, i))
{
ScBaseCell* pOldCell = maItems[i].pCell;
- ScPostIt* pNote = pOldCell->ReleaseNote();
SvtBroadcaster* pBC = pOldCell->ReleaseBroadcaster();
- if (pNewCell || pNote || pBC)
+ if (pNewCell || pBC)
{
- if (pNewCell)
- pNewCell->TakeNote( pNote );
- else
- pNewCell = new ScNoteCell( pNote );
if (pBC)
{
pNewCell->TakeBroadcaster(pBC);
@@ -1883,44 +1803,6 @@ bool ScColumn::HasStringCells( SCROW nStartRow, SCROW nEndRow ) const
}
-ScPostIt* ScColumn::GetNote( SCROW nRow )
-{
- SCSIZE nIndex;
- return Search( nRow, nIndex ) ? maItems[ nIndex ].pCell->GetNote() : 0;
-}
-
-
-void ScColumn::TakeNote( SCROW nRow, ScPostIt* pNote )
-{
- SCSIZE nIndex;
- if( Search( nRow, nIndex ) )
- maItems[ 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 = maItems[ 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;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 22e7ac4a1850..2a5c751fbe4f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3259,48 +3259,6 @@ bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
}
-ScPostIt* ScDocument::GetNote( const ScAddress& rPos )
-{
- 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;
-}
-
-
-void ScDocument::TakeNote( const ScAddress& rPos, ScPostIt*& rpNote )
-{
- 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 );
-}
-
-
-ScPostIt* ScDocument::ReleaseNote( const ScAddress& rPos )
-{
- 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 )
-{
- ScPostIt* pNote = GetNote( rPos );
- if( !pNote )
- {
- pNote = new ScPostIt( *this, rPos, false );
- 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 ] )
@@ -5777,4 +5735,12 @@ bool ScDocument::IsInVBAMode() const
return false;
}
+ScNotes* ScDocument::GetNotes(SCTAB nTab)
+{
+ if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
+ return maTabs[nTab]->GetNotes();
+
+ return NULL;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index e781e605183d..5d84a271a873 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -638,7 +638,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
where cell note is already deleted (thus document cannot find
the note object anymore). The caption will be deleted later
with drawing undo. */
- if( ScPostIt* pNote = pDoc->GetNote( rData.maStart ) )
+ if( ScPostIt* pNote = pDoc->GetNotes( rData.maStart.Tab() )->findByAddress( rData.maStart ) )
pNote->UpdateCaptionPos( rData.maStart );
return;
}
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 5c6eed7ffe79..a76f9f5de65d 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -54,6 +54,8 @@
#include "userdat.hxx"
#include "detfunc.hxx"
+#include <utility>
+
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
@@ -780,7 +782,7 @@ void ScNoteUtil::UpdateCaptionPositions( ScDocument& rDoc, const ScRange& rRange
for( ScAddress aPos( rRange.aStart ); aPos.Tab() <= rRange.aEnd.Tab(); aPos.IncTab() )
for( aPos.SetCol( rRange.aStart.Col() ); aPos.Col() <= rRange.aEnd.Col(); aPos.IncCol() )
for( aPos.SetRow( rRange.aStart.Row() ); aPos.Row() <= rRange.aEnd.Row(); aPos.IncRow() )
- if( ScPostIt* pNote = rDoc.GetNote( aPos ) )
+ if( ScPostIt* pNote = rDoc.GetNotes(aPos.Tab())->findByAddress( aPos ) )
pNote->UpdateCaptionPos( aPos );
}
@@ -791,7 +793,7 @@ SdrCaptionObj* ScNoteUtil::CreateTempCaption(
OUStringBuffer aBuffer( rUserText );
// add plain text of invisible (!) cell note (no formatting etc.)
SdrCaptionObj* pNoteCaption = 0;
- const ScPostIt* pNote = rDoc.GetNote( rPos );
+ const ScPostIt* pNote = rDoc.GetNotes(rPos.Tab())->findByAddress( rPos );
if( pNote && !pNote->IsCaptionShown() )
{
if( aBuffer.getLength() > 0 )
@@ -853,9 +855,9 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption(
aNoteData.mpCaption = &rCaption;
ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, false );
pNote->AutoStamp();
- rDoc.TakeNote( rPos, pNote );
+
// if pNote still points to the note after TakeNote(), insertion was successful
- if( pNote )
+ if( rDoc.GetNotes(rPos.Tab())->insert( rPos, pNote ) )
{
// ScNoteCaptionCreator c'tor updates the caption object to be part of a note
ScNoteCaptionCreator aCreator( rDoc, rPos, rCaption, bShown );
@@ -890,9 +892,10 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
visible, the caption object will be created automatically. */
ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption );
pNote->AutoStamp();
- rDoc.TakeNote( rPos, pNote );
- // if pNote still points to the note after TakeNote(), insertion was successful
- return pNote;
+ if(rDoc.GetNotes(rPos.Tab())->insert( rPos, pNote ))
+ return pNote;
+ else
+ return NULL;
}
ScPostIt* ScNoteUtil::CreateNoteFromString(
@@ -912,12 +915,183 @@ ScPostIt* ScNoteUtil::CreateNoteFromString(
visible, the caption object will be created automatically. */
pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption );
pNote->AutoStamp();
- rDoc.TakeNote( rPos, pNote );
- // if pNote still points to the note after TakeNote(), insertion was successful
+ //insert takes ownership
+ if(!rDoc.GetNotes(rPos.Tab())->insert( rPos, pNote ))
+ pNote = NULL;
}
return pNote;
}
// ============================================================================
+// ScNotes
+// ============================================================================
+
+ScNotes::ScNotes(ScDocument* pDoc):
+ mpDoc(pDoc)
+{
+
+}
+
+ScNotes::~ScNotes()
+{
+ clear();
+}
+
+ScNotes::iterator ScNotes::begin()
+{
+ return maNoteMap.begin();
+}
+
+ScNotes::iterator ScNotes::end()
+{
+ return maNoteMap.end();
+}
+
+ScNotes::const_iterator ScNotes::begin() const
+{
+ return maNoteMap.begin();
+}
+
+ScNotes::const_iterator ScNotes::end() const
+{
+ return maNoteMap.end();
+}
+
+size_t ScNotes::size() const
+{
+ return maNoteMap.size();
+}
+
+bool ScNotes::empty() const
+{
+ return maNoteMap.empty();
+}
+
+ScPostIt* ScNotes::findByAddress(SCCOL nCol, SCROW nRow)
+{
+ ScNoteMap::iterator itr = maNoteMap.find(std::pair<SCCOL, SCROW>(nCol, nRow));
+ if (itr != maNoteMap.end())
+ return itr->second;
+
+ return NULL;
+}
+
+const ScPostIt* ScNotes::findByAddress(SCCOL nCol, SCROW nRow) const
+{
+ ScNoteMap::const_iterator itr = maNoteMap.find(std::pair<SCCOL, SCROW>(nCol, nRow));
+ if (itr != maNoteMap.end())
+ return itr->second;
+
+ return NULL;
+}
+
+ScPostIt* ScNotes::findByAddress(const ScAddress& rPos)
+{
+ return findByAddress(rPos.Col(), rPos.Row());
+}
+
+const ScPostIt* ScNotes::findByAddress(const ScAddress& rPos) const
+{
+ return findByAddress(rPos.Col(), rPos.Row());
+}
+
+bool ScNotes::insert(SCCOL nCol, SCROW nRow, ScPostIt* pPostIt)
+{
+ std::pair<iterator, bool> aResult = maNoteMap.insert(std::pair<ScAddress2D, ScPostIt*>(std::pair<SCCOL, SCROW>(nCol, nRow), pPostIt));
+ if (!aResult.second)
+ delete pPostIt;
+
+ return aResult.second;
+}
+
+bool ScNotes::insert(const ScAddress& rPos, ScPostIt* pPostIt)
+{
+ return insert(rPos.Col(), rPos.Row(), pPostIt);
+}
+
+void ScNotes::erase(SCCOL nCol, SCROW nRow)
+{
+ iterator itr = maNoteMap.find(std::pair<SCCOL, SCROW>(nCol, nRow));
+ if (itr != maNoteMap.end())
+ {
+ delete itr->second;
+ maNoteMap.erase(itr);
+ }
+}
+
+void ScNotes::erase(const ScAddress& rPos)
+{
+ erase(rPos.Col(), rPos.Row());
+}
+
+ScPostIt* ScNotes::ReleaseNote(SCCOL nCol, SCROW nRow)
+{
+ ScPostIt* pPostIt = NULL;
+ iterator itr = maNoteMap.find(std::pair<SCCOL, SCROW>(nCol, nRow));
+ if (itr!= maNoteMap.end())
+ {
+ pPostIt = itr->second;
+ maNoteMap.erase(itr);
+ }
+ return pPostIt;
+}
+
+ScPostIt* ScNotes::ReleaseNote(const ScAddress& rPos)
+{
+ return ReleaseNote(rPos.Col(), rPos.Row());
+}
+
+ScPostIt* ScNotes::GetOrCreateNote(const ScAddress& rPos)
+{
+ iterator itr = maNoteMap.find(std::pair<SCCOL, SCROW>(rPos.Col(), rPos.Row()));
+ if (itr != maNoteMap.end())
+ return itr->second;
+ else
+ {
+ ScPostIt* pPostIt = new ScPostIt(*mpDoc, rPos, false);
+ insert(rPos, pPostIt);
+ return pPostIt;
+ }
+}
+
+void ScNotes::clear()
+{
+ for (iterator itr = maNoteMap.begin(); itr != maNoteMap.end(); ++itr)
+ {
+ delete itr->second;
+ }
+ maNoteMap.clear();
+}
+
+ScNotes* ScNotes::clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bCloneNoteCaption, SCTAB nTab)
+{
+ ScNotes* pNotes = new ScNotes(pDoc);
+ for (ScNotes::iterator itr = maNoteMap.begin(); itr != maNoteMap.end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if (nCol >= nCol1 && nCol <= nCol2 && nRow >= nRow1 && nRow <= nRow2)
+ {
+ pNotes->insert(nCol, nRow, itr->second->Clone( ScAddress(nCol, nRow, nTab),*pDoc, ScAddress(nCol, nRow, nTab), bCloneNoteCaption));
+ }
+ }
+ return pNotes;
+}
+
+void ScNotes::CopyFromClip(const ScNotes& rNotes, ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy, SCTAB nTab, bool bCloneCaption)
+{
+ for (ScNotes::const_iterator itr = rNotes.begin(); itr != rNotes.end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+ if (nCol >= nCol1 && nCol <= nCol2 && nRow >= nRow1 && nRow <= nRow2)
+ {
+ erase(nCol+nDx, nRow+nDy);
+ insert(nCol+nDx, nRow+nDy, itr->second->Clone( ScAddress(nCol, nRow, nTab), *pDoc, ScAddress(nCol, nRow, nTab), bCloneCaption ));
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 4493a718578f..ccae115633c2 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -267,6 +267,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const rtl::OUString& rNewName
nScenarioFlags( 0 ),
pDBDataNoName(NULL),
mpRangeName(NULL),
+ maNotes(pDoc),
bScenario(false),
bLayoutRTL(false),
bLoadingRTL(false),
@@ -527,15 +528,26 @@ bool ScTable::GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const
SCCOL nMaxX = 0;
SCROW nMaxY = 0;
for (SCCOL i=0; i<=MAXCOL; i++)
- if (!aCol[i].IsEmptyVisData(true)) // true = Notizen zaehlen auch
+ if (!aCol[i].IsEmptyVisData())
{
bFound = true;
nMaxX = i;
- SCROW nColY = aCol[i].GetLastVisDataPos(true);
+ SCROW nColY = aCol[i].GetLastVisDataPos();
if (nColY > nMaxY)
nMaxY = nColY;
}
+ for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if (nMaxX < nCol)
+ nMaxX = nCol;
+ if (nMaxY < nRow)
+ nMaxY = nRow;
+ }
+
rEndCol = nMaxX;
rEndRow = nMaxY;
return bFound;
@@ -564,16 +576,30 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const
SCCOL i;
for (i=0; i<=MAXCOL; i++) // Daten testen
- if (!aCol[i].IsEmptyVisData(bNotes))
+ if (!aCol[i].IsEmptyVisData())
{
bFound = true;
if (i>nMaxX)
nMaxX = i;
- SCROW nColY = aCol[i].GetLastVisDataPos(bNotes);
+ SCROW nColY = aCol[i].GetLastVisDataPos();
if (nColY > nMaxY)
nMaxY = nColY;
}
+ if (bNotes)
+ {
+ for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if (nMaxX < nCol)
+ nMaxX = nCol;
+ if (nMaxY < nRow)
+ nMaxY = nRow;
+ }
+ }
+
SCCOL nMaxDataX = nMaxX;
for (i=0; i<=MAXCOL; i++) // Attribute testen
@@ -683,14 +709,29 @@ bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
}
for (i=nStartCol; i<=nEndCol; i++) // Daten testen
- if (!aCol[i].IsEmptyVisData(bNotes))
+ if (!aCol[i].IsEmptyVisData())
{
bFound = true;
- SCROW nColY = aCol[i].GetLastVisDataPos(bNotes);
+ SCROW nColY = aCol[i].GetLastVisDataPos();
if (nColY > nMaxY)
nMaxY = nColY;
}
+ if (bNotes)
+ {
+ for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if (nStartCol > nCol || nEndCol < nCol)
+ continue;
+
+ if (nMaxY < nRow)
+ nMaxY = nRow;
+ }
+ }
+
rEndRow = nMaxY;
return bFound;
}
@@ -727,16 +768,28 @@ bool ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
bool bDatFound = false;
for (i=0; i<=MAXCOL; i++) // Daten testen
- if (!aCol[i].IsEmptyVisData(true))
+ if (!aCol[i].IsEmptyVisData())
{
if (!bDatFound && i<nMinX)
nMinX = i;
bFound = bDatFound = true;
- SCROW nColY = aCol[i].GetFirstVisDataPos(true);
+ SCROW nColY = aCol[i].GetFirstVisDataPos();
if (nColY < nMinY)
nMinY = nColY;
}
+ for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ bFound = bDatFound = true;
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if (nMinX > nCol)
+ nMinX = nCol;
+ if (nMinY > nRow)
+ nMinY = nRow;
+ }
+
rStartCol = nMinX;
rStartRow = nMinY;
return bFound;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2c40a5ca3033..aef1446ada0f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -173,6 +173,22 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
for (SCCOL j=nStartCol; j<=nEndCol; j++)
aCol[j].InsertRow( nStartRow, nSize );
+
+ ScNotes aNotes(pDocument);
+ for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ if (itr->first.second >= nStartRow)
+ {
+ aNotes.insert(itr->first.first, itr->first.second + nSize, itr->second);
+ maNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+ }
+ for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
+ {
+ maNotes.insert( itr->first.first, itr->first.second, itr->second);
+ aNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+
DecRecalcLevel( false );
InvalidatePageBreaks();
@@ -225,6 +241,21 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
}
}
+ ScNotes aNotes(pDocument);
+ for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ if (itr->first.second >= nStartRow)
+ {
+ aNotes.insert(itr->first.first, itr->first.second - nSize, itr->second);
+ maNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+ }
+ for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
+ {
+ maNotes.insert( itr->first.first, itr->first.second, itr->second);
+ aNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+
{ // scope for bulk broadcast
ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
for (SCCOL j=nStartCol; j<=nEndCol; j++)
@@ -307,6 +338,23 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
aCol[MAXCOL - nSize - i].MoveTo(nStartRow, nEndRow, aCol[MAXCOL - i]);
}
+ ScNotes aNotes(pDocument);
+ for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ if (itr->first.first > nStartCol)
+ {
+ aNotes.insert(itr->first.first + nSize, itr->first.second, itr->second);
+ maNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+ else
+ aNotes.insert( itr->first.first, itr->first.second, itr->second);
+ }
+ for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
+ {
+ maNotes.insert( itr->first.first, itr->first.second, itr->second);
+ aNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+
if (nStartCol>0) // copy old attributes
{
sal_uInt16 nWhichArray[2];
@@ -387,6 +435,24 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
for (SCSIZE i=0; static_cast<SCCOL>(i+nSize)+nStartCol <= MAXCOL; i++)
aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]);
}
+
+ ScNotes aNotes(pDocument);
+ for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ if (itr->first.first > nStartCol)
+ {
+ aNotes.insert(itr->first.first - nSize, itr->first.second, itr->second);
+ maNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+ else
+ aNotes.insert( itr->first.first, itr->first.second, itr->second);
+ }
+ for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
+ {
+ maNotes.insert( itr->first.first, itr->first.second, itr->second);
+ aNotes.ReleaseNote(itr->first.first, itr->first.second);
+ }
+
DecRecalcLevel();
InvalidatePageBreaks();
@@ -467,6 +533,10 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
//local range names need to be copied first for formula cells
if (!pTable->mpRangeName && mpRangeName)
pTable->mpRangeName = new ScRangeName(*mpRangeName);
+
+ // notes
+ pTable->maNotes = *maNotes.clone(pTable->pDocument, nCol1, nRow1, nCol2, nRow2, bCloneNoteCaptions, nTab);
+
SCCOL i;
for ( i = nCol1; i <= nCol2; i++)
@@ -528,6 +598,14 @@ void ScTable::CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
for ( i = nCol1; i <= nCol2; i++)
aCol[i].CopyFromClip(nRow1, nRow2, nDy, nInsFlag, bAsLink, bSkipAttrForEmpty, pTable->aCol[i - nDx]);
+ bool bAddNotes = (nInsFlag & (IDF_CONTENTS | IDF_ADDNOTES)) == (IDF_NOTE | IDF_ADDNOTES);
+ if (bAddNotes)
+ {
+ bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0;
+ maNotes.CopyFromClip(pTable->maNotes, pDocument, nCol1, nRow1, nCol2, nRow2, nDx, nDy, nTab, bCloneCaption);
+ }
+
+
if ((nInsFlag & IDF_ATTRIB) != 0)
{
if (nRow1==0 && nRow2==MAXROW && pColWidth && pTable->pColWidth)
@@ -1091,41 +1169,9 @@ void ScTable::GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula )
rFormula = rtl::OUString();
}
-
-ScPostIt* ScTable::GetNote( SCCOL nCol, SCROW nRow )
+ScNotes* ScTable::GetNotes()
{
- 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 );
+ return &maNotes;
}
@@ -1134,7 +1180,7 @@ void ScTable::InitializeNoteCaptions( bool bForced )
if( mxUninitNotes.get() && (bForced || pDocument->IsUndoEnabled()) )
{
for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt )
- if( ScPostIt* pNote = GetNote( aIt->first, aIt->second ) )
+ if( ScPostIt* pNote = maNotes.findByAddress( aIt->first, aIt->second ) )
pNote->GetOrCreateCaption( ScAddress( aIt->first, aIt->second, nTab ) );
mxUninitNotes.reset();
}
@@ -1422,7 +1468,10 @@ bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
}
bool bEmpty = true;
for (SCCOL i=nCol1; i<=nCol2 && bEmpty; i++)
- bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2, bIgnoreNotes );
+ {
+ //TODO:moggi
+ bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2 );
+ }
return bEmpty;
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b15703ef2bf9..db0c249cc9a1 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -580,6 +580,14 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
}
}
}
+ for (ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ if (itr->first.first == nCol1 || itr->first.first == nCol2)
+ {
+ //only then we need to swap
+ //TODO: implement it
+ }
+ }
}
void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
@@ -610,6 +618,15 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
SetRowFiltered(nRow1, nRow1, bRow2Filtered);
SetRowFiltered(nRow2, nRow2, bRow1Filtered);
}
+
+ for (ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
+ {
+ if (itr->first.second == nRow1 || itr->first.second == nRow2)
+ {
+ //only then we need to swap
+ //TODO:implement it
+ }
+ }
}
short ScTable::Compare(SCCOLROW nIndex1, SCCOLROW nIndex2)
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 381ee2d64cab..0635eeebb923 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -105,14 +105,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo
}
break;
case SVX_SEARCHIN_NOTE:
- {
- if(const ScPostIt* pNote = pCell->GetNote())
- {
- aString = pNote->GetText();
- bMultiLine = pNote->HasMultiLineText();
- }
- }
- break;
+ break; // don't search this case here
default:
break;
}
@@ -219,14 +212,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo
}
}
while (bRepeat);
- if (rSearchItem.GetCellType() == SVX_SEARCHIN_NOTE)
- {
- // NB: rich text format is lost.
- // This is also true of Cells.
- if( ScPostIt* pNote = pCell->GetNote() )
- pNote->SetText( ScAddress( nCol, nRow, nTab ), aString );
- }
- else if ( cMatrixFlag != MM_NONE )
+
+ if ( cMatrixFlag != MM_NONE )
{ // Matrix nicht zerreissen
if ( aString.Len() > 2 )
{ // {} raus, erst hier damit auch "{=" durch "{=..." ersetzt werden kann
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 9c6d65f4b611..4c9c87fe20b1 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1483,7 +1483,7 @@ void ScDetectiveFunc::UpdateAllComments( ScDocument& rDoc )
{
if ( ScDrawObjData* pData = ScDrawLayer::GetNoteCaptionData( pObject, nObjTab ) )
{
- ScPostIt* pNote = rDoc.GetNote( pData->maStart );
+ ScPostIt* pNote = rDoc.GetNotes( pData->maStart.Tab() )->findByAddress( pData->maStart );
// caption should exist, we iterate over drawing objects...
OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "ScDetectiveFunc::UpdateAllComments - invalid cell note" );
if( pNote )
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 31e5e8451ed2..f022e9c10a7e 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1613,25 +1613,15 @@ void ScInterpreter::ScBackSolver()
{
ScBaseCell* pVCell = GetCell( aValueAdr );
// 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)
+ if ( ((pVCell && pVCell->GetCellType() == CELLTYPE_VALUE))
&& pFCell && pFCell->GetCellType() == CELLTYPE_FORMULA )
{
ScRange aVRange( aValueAdr, aValueAdr ); // fuer SetDirty
double fSaveVal; // Original value to be restored later if necessary
- ScPostIt* pNote = 0;
- if ( bTempCell )
- {
- pNote = pVCell ? pVCell->ReleaseNote() : 0;
- fSaveVal = 0.0;
- pVCell = new ScValueCell( fSaveVal );
- pDok->PutCell( aValueAdr, pVCell );
- }
- else
- fSaveVal = GetCellValue( aValueAdr, pVCell );
+ fSaveVal = GetCellValue( aValueAdr, pVCell );
const sal_uInt16 nMaxIter = 100;
const double fEps = 1E-10;
@@ -1772,13 +1762,7 @@ void ScInterpreter::ScBackSolver()
{
nX = fBestX;
}
- if ( bTempCell )
- {
- pVCell = pNote ? new ScNoteCell( pNote ) : 0;
- pDok->PutCell( aValueAdr, pVCell );
- }
- else
- pValue->SetValue( fSaveVal );
+ pValue->SetValue( fSaveVal );
pDok->SetDirty( aVRange );
pFormula->Interpret();
if ( !bDoneIteration )
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index d427350b40e9..f77f4e7e3c9a 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -149,7 +149,8 @@ ExcTable::ExcTable( const XclExpRoot& rRoot ) :
XclExpRoot( rRoot ),
mnScTab( SCTAB_GLOBAL ),
nExcTab( EXC_NOTAB ),
- pTabNames( new NameBuffer( 0, 16 ) )
+ pTabNames( new NameBuffer( 0, 16 ) ),
+ mxNoteList( new XclExpNoteList )
{
}
@@ -158,7 +159,8 @@ ExcTable::ExcTable( const XclExpRoot& rRoot, SCTAB nScTab ) :
XclExpRoot( rRoot ),
mnScTab( nScTab ),
nExcTab( rRoot.GetTabInfo().GetXclTab( nScTab ) ),
- pTabNames( new NameBuffer( 0, 16 ) )
+ pTabNames( new NameBuffer( 0, 16 ) ),
+ mxNoteList( new XclExpNoteList )
{
}
@@ -428,6 +430,17 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
// cell table: DEFROWHEIGHT, DEFCOLWIDTH, COLINFO, DIMENSIONS, ROW, cell records
mxCellTable.reset( new XclExpCellTable( GetRoot() ) );
+ //export cell notes
+ ScNotes::iterator itr = rDoc.GetNotes(mnScTab)->begin();
+ ScNotes::iterator itrEnd = rDoc.GetNotes(mnScTab)->end();
+ for (; itr != itrEnd; ++itr)
+ {
+ // notes
+ const ScPostIt* pScNote = itr->second;
+ ScAddress aScPos( itr->first.first, itr->first.second, mnScTab );
+ mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, rtl::OUString() ) );
+ }
+
if( GetOutput() != EXC_OUTPUT_BINARY )
{
FillAsXmlTable( nCodeNameIdx );
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 88b3f83814bb..955425e870c1 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2337,10 +2337,8 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) :
if( xCell )
maRowBfr.AppendCell( xCell, bIsMergedBase );
- // notes
- const ScPostIt* pScNote = pScCell ? pScCell->GetNote() : 0;
- if( pScNote || (aAddNoteText.Len() > 0) )
- mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, aAddNoteText ) );
+ if ( aAddNoteText.Len() )
+ mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, NULL, aAddNoteText ) );
// other sheet contents
if( pPattern )
diff --git a/sc/source/filter/inc/excdoc.hxx b/sc/source/filter/inc/excdoc.hxx
index 75c0f2433569..500ab1238e0c 100644
--- a/sc/source/filter/inc/excdoc.hxx
+++ b/sc/source/filter/inc/excdoc.hxx
@@ -33,6 +33,7 @@
#include "excrecds.hxx"
#include "xeroot.hxx"
#include "root.hxx"
+#include "xeescher.hxx"
#include <boost/shared_ptr.hpp>
//------------------------------------------------------------------ Forwards -
@@ -57,6 +58,8 @@ class ExcTable : public XclExpRecordBase, public XclExpRoot
private:
typedef XclExpRecordList< ExcBundlesheetBase > ExcBoundsheetList;
typedef boost::shared_ptr< XclExpCellTable > XclExpCellTableRef;
+ typedef XclExpRecordList< XclExpNote > XclExpNoteList;
+ typedef boost::shared_ptr< XclExpNoteList > XclExpNoteListRef;
XclExpRecordList<> aRecList;
XclExpCellTableRef mxCellTable;
@@ -68,6 +71,8 @@ private:
NameBuffer* pTabNames;
+ XclExpNoteListRef mxNoteList;
+
// pRec mit new anlegen und vergessen, delete macht ExcTable selber!
void Add( XclExpRecordBase* pRec );
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 4770839d547f..b246f737dfb0 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2195,13 +2195,13 @@ void ScXMLExport::_ExportAutoStyles()
while (aNoteIter != aNoteEnd)
{
ScAddress aPos = aNoteIter->maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ SCTAB nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( nTable );
if (bCopySheet)
{
//! separate method AddStyleFromNote needed?
- ScPostIt* pNote = pDoc->GetNote( aPos );
+ ScPostIt* pNote = pDoc->GetNotes( nTable )->findByAddress(aPos);
OSL_ENSURE( pNote, "note not found" );
if (pNote)
{
@@ -2243,11 +2243,11 @@ void ScXMLExport::_ExportAutoStyles()
while (aNoteParaIter != aNoteParaEnd)
{
ScAddress aPos = aNoteParaIter->maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ SCTAB nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( nTable );
if (bCopySheet)
{
- ScPostIt* pNote = pDoc->GetNote( aPos );
+ ScPostIt* pNote = pDoc->GetNotes(nTable)->findByAddress( aPos );
OSL_ENSURE( pNote, "note not found" );
if (pNote)
{
@@ -2278,11 +2278,11 @@ void ScXMLExport::_ExportAutoStyles()
while (aNoteTextIter != aNoteTextEnd)
{
ScAddress aPos = aNoteTextIter->maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ SCTAB nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( nTable );
if (bCopySheet)
{
- ScPostIt* pNote = pDoc->GetNote( aPos );
+ ScPostIt* pNote = pDoc->GetNotes(nTable)->findByAddress( aPos );
OSL_ENSURE( pNote, "note not found" );
if (pNote)
{
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index fc08ca836ec2..f3ccf181cf1f 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -191,7 +191,7 @@ sal_Int32 ScNotesChildren::AddNotes(const ScPreviewLocationData& rData, const Re
}
else
{
- if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
+ if( ScPostIt* pNote = pDoc->GetNotes( aNote.maNoteCell.Tab() )->findByAddress( aNote.maNoteCell ) )
aNote.maNoteText = pNote->GetText();
aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
if (aNote.mpTextHelper)
@@ -368,7 +368,7 @@ sal_Int32 ScNotesChildren::CheckChanges(const ScPreviewLocationData& rData,
}
else
{
- if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
+ if( ScPostIt* pNote = pDoc->GetNotes( aNote.maNoteCell.Tab() )->findByAddress( aNote.maNoteCell ) )
aNote.maNoteText = pNote->GetText();
}
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 58041904a991..b8c995b0431c 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1108,7 +1108,7 @@ sal_Bool ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText,
bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
{
ScDocument& rDoc = *rDocShell.GetDocument();
- ScPostIt* pNote = rDoc.GetNote( rPos );
+ ScPostIt* pNote = rDoc.GetNotes( rPos.Tab() )->findByAddress( rPos );
if( !pNote || (bShow == pNote->IsCaptionShown()) ) return false;
// move the caption to internal or hidden layer and create undo action
@@ -1141,7 +1141,7 @@ bool ScDocFunc::SetNoteText( const ScAddress& rPos, const String& rText, sal_Boo
String aNewText = convertLineEnd(rText, GetSystemLineEnd()); //! ist das noetig ???
- if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetOrCreateNote( rPos ) : pDoc->GetNote( rPos ) )
+ if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetNotes(rPos.Tab())->GetOrCreateNote( rPos ) : pDoc->GetNotes( rPos.Tab() )->findByAddress(rPos) )
pNote->SetText( rPos, aNewText );
//! Undo !!!
@@ -1170,7 +1170,7 @@ bool ScDocFunc::ReplaceNote( const ScAddress& rPos, const String& rNoteText, con
::svl::IUndoManager* pUndoMgr = (pDrawLayer && rDoc.IsUndoEnabled()) ? rDocShell.GetUndoManager() : 0;
ScNoteData aOldData;
- ScPostIt* pOldNote = rDoc.ReleaseNote( rPos );
+ ScPostIt* pOldNote = rDoc.GetNotes(rPos.Tab())->ReleaseNote( rPos );
if( pOldNote )
{
// ensure existing caption object before draw undo tracking starts
@@ -4406,7 +4406,7 @@ sal_Bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, sal_Bool bCont
bool bHasNotes = false;
for( ScAddress aPos( nStartCol, nStartRow, nTab ); !bHasNotes && (aPos.Col() <= nEndCol); aPos.IncCol() )
for( aPos.SetRow( nStartRow ); !bHasNotes && (aPos.Row() <= nEndRow); aPos.IncRow() )
- bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (pDoc->GetNote( aPos ) != 0);
+ bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) != 0);
if (!pUndoDoc)
{
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 7a8c06ce426c..62c8633f7832 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -263,15 +263,11 @@ sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates )
if ( nStates & HIDDENINFORMATION_NOTES )
{
SCTAB nTableCount = aDocument.GetTableCount();
- SCTAB nTable = 0;
- sal_Bool bFound(false);
- while ( nTable < nTableCount && !bFound )
+ bool bFound = false;
+ for (SCTAB nTab = 0; nTab < nTableCount && !bFound; ++nTab)
{
- ScCellIterator aCellIter( &aDocument, 0,0, nTable, MAXCOL,MAXROW, nTable );
- for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bFound; pCell = aCellIter.GetNext() )
- if (pCell->HasNote())
- bFound = sal_True;
- nTable++;
+ if (!aDocument.GetNotes(nTab)->empty())
+ bFound = true;
}
if (bFound)
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
index 3bc52a502b83..6a3387b2d060 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -79,7 +79,7 @@ void FuText::StopEditMode(sal_Bool /*bTextDirection*/)
if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, rViewData.GetTabNo() ) )
{
aNotePos = pCaptData->maStart;
- pNote = rDoc.GetNote( aNotePos );
+ pNote = rDoc.GetNotes( aNotePos.Tab() )->findByAddress( aNotePos );
OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
}
@@ -147,13 +147,13 @@ void FuText::StopEditMode(sal_Bool /*bTextDirection*/)
// rescue note data before deletion
ScNoteData aNoteData( pNote->GetNoteData() );
// delete note from document (removes caption, but does not delete it)
- rDoc.DeleteNote( aNotePos );
+ rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
// create undo action for removed note
pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
}
else
{
- rDoc.DeleteNote( aNotePos );
+ rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
}
// ScDocument::DeleteNote has deleted the note that pNote points to
pNote = 0;
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index c80ca02a7e45..6b9b620af35c 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -850,7 +850,7 @@ const ScAreaLink* ScContentTree::GetLink( sal_uLong nIndex )
}
}
- OSL_FAIL("Link nicht gefunden");
+ OSL_FAIL("link not found");
return NULL;
}
@@ -875,10 +875,12 @@ void ScContentTree::GetNoteStrings()
SCTAB nTabCount = pDoc->GetTableCount();
for (SCTAB nTab=0; nTab<nTabCount; nTab++)
{
- ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
- for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
- if( const ScPostIt* pNote = pCell->GetNote() )
- InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) );
+ ScNotes::iterator itr = pDoc->GetNotes(nTab)->begin();
+ ScNotes::iterator itrEnd = pDoc->GetNotes(nTab)->end();
+ for (; itr != itrEnd; ++itr)
+ {
+//TODO: moggi
+ }
}
}
@@ -892,21 +894,22 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
SCTAB nTabCount = pDoc->GetTableCount();
for (SCTAB nTab=0; nTab<nTabCount; nTab++)
{
- ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ ScNotes* pNotes = pDoc->GetNotes(nTab);
+ if (nFound + pNotes->size() >= nIndex)
{
- if( pCell->HasNote() )
+ for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
{
if (nFound == nIndex)
- return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden
+ return ScAddress( itr->first.first, itr->first.second, nTab ); // gefunden
+
++nFound;
}
- pCell = aIter.GetNext();
}
+ else
+ nFound += pNotes->size();
}
- OSL_FAIL("Notiz nicht gefunden");
+ OSL_FAIL("note not found");
return ScAddress();
}
@@ -922,15 +925,14 @@ sal_Bool ScContentTree::NoteStringsChanged()
SvLBoxEntry* pEntry = FirstChild( pParent );
- sal_Bool bEqual = sal_True;
+ bool bEqual = true;
SCTAB nTabCount = pDoc->GetTableCount();
for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
{
- ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell && bEqual)
+ ScNotes* pNotes = pDoc->GetNotes(nTab);
+ for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
{
- if( const ScPostIt* pNote = pCell->GetNote() )
+ if( const ScPostIt* pNote = itr->second )
{
if ( !pEntry )
bEqual = false;
@@ -942,7 +944,6 @@ sal_Bool ScContentTree::NoteStringsChanged()
pEntry = NextSibling( pEntry );
}
}
- pCell = aIter.GetNext();
}
}
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 00f3b6e850fe..3286614bb530 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -1210,7 +1210,7 @@ void ScUndoReplace::Undo()
}
else if (pSearchItem->GetCellType() == SVX_SEARCHIN_NOTE)
{
- ScPostIt* pNote = pDoc->GetNote( aCursorPos );
+ ScPostIt* pNote = pDoc->GetNotes( aCursorPos.Tab() )->findByAddress( aCursorPos );
OSL_ENSURE( pNote, "ScUndoReplace::Undo - cell does not contain a note" );
if (pNote)
pNote->SetText( aCursorPos, aUndoStr );
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 114964220a19..a0198bb52c17 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -897,9 +897,9 @@ void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData )
if( rNoteData.mpCaption )
{
ScDocument& rDoc = *pDocShell->GetDocument();
- OSL_ENSURE( !rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
+ OSL_ENSURE( !rDoc.GetNotes( maPos.Tab() )->findByAddress(maPos), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false );
- rDoc.TakeNote( maPos, pNote );
+ rDoc.GetNotes(maPos.Tab())->insert( maPos, pNote );
}
}
@@ -908,8 +908,8 @@ void ScUndoReplaceNote::DoRemoveNote( const ScNoteData& rNoteData )
if( rNoteData.mpCaption )
{
ScDocument& rDoc = *pDocShell->GetDocument();
- OSL_ENSURE( rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
- if( ScPostIt* pNote = rDoc.ReleaseNote( maPos ) )
+ OSL_ENSURE( rDoc.GetNotes( maPos.Tab() )->findByAddress(maPos), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
+ if( ScPostIt* pNote = rDoc.GetNotes(maPos.Tab())->ReleaseNote( maPos ) )
{
/* Forget pointer to caption object to suppress removing the
caption object from the drawing layer while deleting pNote
@@ -936,7 +936,7 @@ ScUndoShowHideNote::~ScUndoShowHideNote()
void ScUndoShowHideNote::Undo()
{
BeginUndo();
- if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( maPos ) )
+ if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( maPos.Tab() )->findByAddress(maPos) )
pNote->ShowCaption( maPos, !mbShown );
EndUndo();
}
@@ -944,7 +944,7 @@ void ScUndoShowHideNote::Undo()
void ScUndoShowHideNote::Redo()
{
BeginRedo();
- if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( maPos ) )
+ if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( maPos.Tab() )->findByAddress(maPos) )
pNote->ShowCaption( maPos, mbShown );
EndRedo();
}
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 10a4ac7f6683..3ab1978bd452 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3581,53 +3581,50 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
while (pCell)
{
sal_Bool bAdd = false;
- if ( pCell->HasNote() && ( nContentFlags & sheet::CellFlags::ANNOTATION ) )
- bAdd = sal_True;
- else
- switch ( pCell->GetCellType() )
- {
- case CELLTYPE_STRING:
- if ( nContentFlags & sheet::CellFlags::STRING )
- bAdd = sal_True;
- break;
- case CELLTYPE_EDIT:
- if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
- bAdd = sal_True;
- break;
- case CELLTYPE_FORMULA:
- if ( nContentFlags & sheet::CellFlags::FORMULA )
- bAdd = sal_True;
- break;
- case CELLTYPE_VALUE:
- if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
- == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
- bAdd = sal_True;
- else
- {
- // Date/Time Erkennung
+ switch ( pCell->GetCellType() )
+ {
+ case CELLTYPE_STRING:
+ if ( nContentFlags & sheet::CellFlags::STRING )
+ bAdd = sal_True;
+ break;
+ case CELLTYPE_EDIT:
+ if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
+ bAdd = sal_True;
+ break;
+ case CELLTYPE_FORMULA:
+ if ( nContentFlags & sheet::CellFlags::FORMULA )
+ bAdd = sal_True;
+ break;
+ case CELLTYPE_VALUE:
+ if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
+ == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
+ bAdd = sal_True;
+ else
+ {
+ // Date/Time Erkennung
- sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)pDoc->GetAttr(
+ sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)pDoc->GetAttr(
aIter.GetCol(), aIter.GetRow(), aIter.GetTab(),
ATTR_VALUE_FORMAT ))->GetValue();
- short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
- if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
+ short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
+ if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
(nTyp == NUMBERFORMAT_DATETIME))
- {
- if ( nContentFlags & sheet::CellFlags::DATETIME )
- bAdd = sal_True;
- }
- else
- {
- if ( nContentFlags & sheet::CellFlags::VALUE )
- bAdd = sal_True;
- }
+ {
+ if ( nContentFlags & sheet::CellFlags::DATETIME )
+ bAdd = sal_True;
}
- break;
- default:
+ else
+ {
+ if ( nContentFlags & sheet::CellFlags::VALUE )
+ bAdd = sal_True;
+ }
+ }
+ break;
+ default:
{
// added to avoid warnings
}
- }
+ }
if (bAdd)
aMarkData.SetMultiMarkArea(
@@ -3636,6 +3633,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
pCell = aIter.GetNext();
}
+
}
ScRangeList aNewRanges;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 0b3b2311a736..147c10d49de1 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3493,18 +3493,15 @@ bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos
{
sal_Int32 nFound = 0;
ScDocument* pDoc = pDocShell->GetDocument();
- ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab );
- for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() )
+ const ScNotes* pNotes = pDoc->GetNotes(nTab);
+ for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
{
- if (pCell->HasNote())
+ if (nFound == nIndex)
{
- if (nFound == nIndex)
- {
- rPos = ScAddress( aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab() );
- return true;
- }
- ++nFound;
+ rPos = ScAddress( itr->first.first, itr->first.second, nTab );
+ return true;
}
+ ++nFound;
}
}
return false;
@@ -3575,10 +3572,8 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException)
sal_uLong nCount = 0;
if (pDocShell)
{
- ScCellIterator aCellIter( pDocShell->GetDocument(), 0,0, nTab, MAXCOL,MAXROW, nTab );
- for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() )
- if (pCell->HasNote())
- ++nCount;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ nCount = pDoc->GetNotes(nTab)->size();
}
return nCount;
}
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index 03d0b1c604f1..e21282cf527b 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -219,7 +219,7 @@ SvxEditSource* ScAnnotationEditSource::Clone() const
SdrObject* ScAnnotationEditSource::GetCaptionObj()
{
- ScPostIt* pNote = pDocShell->GetDocument()->GetNote( aCellPos );
+ ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos);
return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
}
@@ -245,7 +245,7 @@ SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
return pForwarder;
if ( pDocShell )
- if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( aCellPos ) )
+ if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos) )
if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
pEditEngine->SetText( *pEditObj ); // incl. Umbrueche
diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx
index 7eec85ffbe69..8fcfc1d1bffa 100644
--- a/sc/source/ui/unoobj/notesuno.cxx
+++ b/sc/source/ui/unoobj/notesuno.cxx
@@ -268,7 +268,7 @@ SvxUnoText& ScAnnotationObj::GetUnoText()
const ScPostIt* ScAnnotationObj::ImplGetNote() const
{
- return pDocShell ? pDocShell->GetDocument()->GetNote( aCellPos ) : 0;
+ return pDocShell ? pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos) : 0;
}
//------------------------------------------------------------------------
@@ -298,7 +298,7 @@ SvxUnoText& ScAnnotationShapeObj::GetUnoText()
uno::Reference < drawing::XShape > ScAnnotationShapeObj::GetXShape()
{
if (!xShape.is())
- if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( aCellPos ) )
+ if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos) )
if( SdrObject* pCaption = pNote->GetOrCreateCaption( aCellPos ) )
xShape.set( pCaption->getUnoShape(), uno::UNO_QUERY );
return xShape;
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 66a8839b7c29..c1e56709fef4 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -577,8 +577,6 @@ void ScCellShell::GetState(SfxItemSet &rSet)
SCTAB nTabCount = pDoc->GetTableCount();
SCTAB nTabSelCount = rMark.GetSelectCount();
-
-
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while ( nWhich )
@@ -606,9 +604,8 @@ void ScCellShell::GetState(SfxItemSet &rSet)
case SID_RANGE_NOTETEXT:
{
// always take cursor position, do not use top-left cell of selection
- ScAddress aPos( nPosX, nPosY, nTab );
String aNoteText;
- if ( const ScPostIt* pNote = pDoc->GetNote( aPos ) )
+ if ( const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY) )
aNoteText = pNote->GetText();
rSet.Put( SfxStringItem( nWhich, aNoteText ) );
}
@@ -921,7 +918,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
case FID_NOTE_VISIBLE:
{
- const ScPostIt* pNote = pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) );
+ const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY);
if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
else
@@ -931,7 +928,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
case SID_DELETE_NOTE:
{
- sal_Bool bEnable = false;
+ bool bEnable = false;
if ( rMark.IsMarked() || rMark.IsMultiMarked() )
{
if ( pDoc->IsSelectionEditable( rMark ) )
@@ -942,17 +939,23 @@ void ScCellShell::GetState(SfxItemSet &rSet)
size_t nCount = aRanges.size();
for (size_t nPos = 0; nPos < nCount && !bEnable; ++nPos)
{
- ScCellIterator aCellIter(pDoc, *aRanges[nPos]);
- for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() )
- if ( pCell->HasNote() )
- bEnable = sal_True; // note found
+ ScNotes* pNotes = pDoc->GetNotes( aRanges[nPos]->aStart.Tab() );
+ for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if ( nCol <= aRanges[nPos]->aEnd.Col() && nRow <= aRanges[nPos]->aEnd.Row()
+ && nCol >= aRanges[nPos]->aStart.Col() && nRow >= aRanges[nPos]->aStart.Row() )
+ bEnable = true; //note found
+ }
}
}
}
else
{
bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
- pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) );
+ pDoc->GetNotes(nTab)->findByAddress( nPosX, nPosY );
}
if ( !bEnable )
rSet.DisableItem( nWhich );
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index a1683b4ea6f0..1e1f98308247 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1885,7 +1885,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
{
ScDocument* pDoc = GetViewData()->GetDocument();
ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
- if( ScPostIt* pNote = pDoc->GetNote( aPos ) )
+ if( ScPostIt* pNote = pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) )
{
bool bShow;
const SfxPoolItem* pItem;
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 2243e7507146..27beef2b1eb5 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -693,7 +693,7 @@ void ScDrawView::DeleteMarked()
bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
// remove the cell note from document, we are its owner now
- ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
+ ScPostIt* pNote = pDoc->GetNotes(pCaptData->maStart.Tab())->ReleaseNote( pCaptData->maStart );
OSL_ENSURE( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
if( pNote )
{
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1fbc0678533d..02200bbbc2bc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -370,7 +370,7 @@ void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pDrDoc, c
ScDocument& rDoc = *pViewData->GetDocument();
ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
- ScPostIt* pNote = rDoc.GetNote( aCellPos );
+ ScPostIt* pNote = rDoc.GetNotes( aCellPos.Tab() )->findByAddress( aCellPos );
SdrObject* pObj = pNote ? pNote->GetCaption() : 0;
if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) )
{
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index ed6ebae8fc47..62af15157675 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -199,7 +199,7 @@ bool ScGridWindow::ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard )
}
// Notiz nur, wenn sie nicht schon auf dem Drawing-Layer angezeigt wird:
- const ScPostIt* pNote = pDoc->GetNote( aCellPos );
+ const ScPostIt* pNote = pDoc->GetNotes( aCellPos.Tab() )->findByAddress( aCellPos );
if ( (aTrackText.Len() > 0) || (pNote && !pNote->IsCaptionShown()) )
{
bool bNew = true;
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index b80bfdc7f2f4..346a60083e88 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -2081,8 +2081,10 @@ void ScOutputData::DrawChangeTrack()
}
}
+//TODO: moggi Need to check if this can't be written simpler
void ScOutputData::DrawNoteMarks()
{
+
sal_Bool bFirst = sal_True;
long nInitPosX = nScrX;
@@ -2100,7 +2102,6 @@ void ScOutputData::DrawNoteMarks()
for (SCCOL nX=nX1; nX<=nX2; nX++)
{
CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
- ScBaseCell* pCell = pInfo->pCell;
sal_Bool bIsMerged = false;
if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped )
@@ -2115,7 +2116,7 @@ void ScOutputData::DrawNoteMarks()
// use origin's pCell for NotePtr test below
}
- if ( pCell && pCell->HasNote() && ( bIsMerged ||
+ if ( pDoc->GetNotes(nTab)->findByAddress(nX, pRowInfo[nArrY].nRowNo) && ( bIsMerged ||
( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) )
{
if (bFirst)
@@ -2193,6 +2194,8 @@ void ScOutputData::AddPDFNotes()
// use origin's pCell for NotePtr test below
}
+ //TODO: moggi search for a better way with new note handling
+ /*
if ( pCell && pCell->HasNote() && ( bIsMerged ||
( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) )
{
@@ -2232,6 +2235,7 @@ void ScOutputData::AddPDFNotes()
pPDFData->CreateNote( aNoteRect, aNote );
}
}
+ */
nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
}
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 1a0218962b0c..01f1b5bedd25 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -1868,8 +1868,7 @@ long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocation
{
ScAddress &rPos = aNotePosList[ nNoteStart + nCount ];
- ScBaseCell* pCell = pDoc->GetCell( rPos);
- if( const ScPostIt* pNote = pCell->GetNote() )
+ if( const ScPostIt* pNote = pDoc->GetNotes(rPos.Tab())->findByAddress( rPos ) )
{
if(const EditTextObject *pEditText = pNote->GetEditTextObject())
pEditEngine->SetText(*pEditText);
@@ -2473,8 +2472,6 @@ long ScPrintFunc::CountNotePages()
return 0;
long nCount=0;
- SCCOL nCol;
- SCROW nRow;
sal_Bool bError = false;
if (!aAreaParam.bPrintArea)
@@ -2504,17 +2501,20 @@ long ScPrintFunc::CountNotePages()
if (bDoThis)
{
- ScHorizontalCellIterator aIter( pDoc, nPrintTab, nStartCol,nStartRow, nEndCol,nEndRow );
- ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
- while (pCell)
+ ScNotes::const_iterator itr = pDoc->GetNotes(nPrintTab)->begin();
+ ScNotes::const_iterator itrEnd = pDoc->GetNotes(nPrintTab)->end();
+ for (; itr != itrEnd; ++itr)
{
- if (pCell->HasNote())
- {
- aNotePosList.push_back( ScAddress( nCol,nRow,nPrintTab ) );
- ++nCount;
- }
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+ if (nCol > nEndCol || nRow > nEndRow)
+ continue;
+
+ if (nCol < nStartCol || nRow < nStartRow)
+ continue;
- pCell = aIter.GetNext( nCol, nRow );
+ aNotePosList.push_back( ScAddress( nCol, nRow, nPrintTab ) );
+ ++nCount;
}
}
}
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index 0f4736e2df8c..87f5ec1fcb6a 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -342,7 +342,7 @@ void ScViewFunc::EditNote()
// generated undo action is processed in FuText::StopEditMode
// get existing note or create a new note (including caption drawing object)
- if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) )
+ if( ScPostIt* pNote = pDoc->GetNotes(aPos.Tab())->GetOrCreateNote( aPos ) )
{
// hide temporary note caption
HideNoteMarker();