diff options
-rw-r--r-- | sc/inc/cell.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/cell.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 51 | ||||
-rw-r--r-- | sc/source/core/data/table6.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 9 |
6 files changed, 55 insertions, 15 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index 09c9f3896edf..da093573a49e 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -102,7 +102,7 @@ public: /** 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; + ScBaseCell* CloneWithNote( 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. */ diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 11ac123cdf41..37285e78d65a 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -240,7 +240,7 @@ ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); } -ScBaseCell* ScBaseCell::CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const +ScBaseCell* ScBaseCell::CloneWithNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const { ScBaseCell* pNewCell = lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); return pNewCell; diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 4df060c4aed5..abee27efb792 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1219,7 +1219,7 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee { aOwnPos.SetRow( maItems[i].nRow ); aDestPos.SetRow( maItems[i].nRow ); - ScBaseCell* pNewCell = maItems[i].pCell->CloneWithNote( aOwnPos, *rColumn.pDocument, aDestPos, nCloneFlags ); + ScBaseCell* pNewCell = maItems[i].pCell->CloneWithNote( *rColumn.pDocument, aDestPos, nCloneFlags ); rColumn.Append( aDestPos.Row(), pNewCell ); } } @@ -1347,7 +1347,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const SCSIZE nThisIndex; if ( Search( aDestPos.Row(), nThisIndex ) ) { - ScBaseCell* pNew = maItems[nThisIndex].pCell->CloneWithNote( aOwnPos, rDestDoc, aDestPos ); + ScBaseCell* pNew = maItems[nThisIndex].pCell->CloneWithNote( rDestDoc, aDestPos ); rDestCol.Insert( aDestPos.Row(), pNew ); } } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 50608c8ad24b..371f123fbe70 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -488,6 +488,9 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal } } + if (nDelFlag & IDF_CONTENTS) + maNotes.erase( nCol1, nRow1, nCol2, nRow2); + if (IsStreamValid()) // TODO: In the future we may want to check if the table has been // really modified before setting the stream invalid. @@ -503,6 +506,16 @@ void ScTable::DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark ) aCol[i].DeleteSelection( nDelFlag, rMark ); } + ScRangeList aRangeList; + rMark.FillRangeListWithMarks(&aRangeList, false); + + for (size_t i = 0; i < aRangeList.size(); ++i) + { + ScRange* pRange = aRangeList[i]; + if (nDelFlag & IDF_CONTENTS && pRange) + maNotes.erase(pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row()); + } + // // Zellschutz auf geschuetzter Tabelle nicht setzen // @@ -714,7 +727,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScAddress aOwnPos( nCol, nRow, nTab ); if (pCell->GetCellType() == CELLTYPE_FORMULA) { - pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); + pNew = pCell->CloneWithNote( *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); // Referenzen drehen // bei Cut werden Referenzen spaeter per UpdateTranspose angepasst @@ -724,7 +737,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } else { - pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos ); + pNew = pCell->CloneWithNote( *pDestDoc, aDestPos ); } } pTransClip->PutCell( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pNew ); @@ -853,6 +866,17 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (!bColRowFlags) // Spaltenbreiten/Zeilenhoehen/Flags return; + //remove old notes + if (nFlags & IDF_CONTENTS) + pDestTab->maNotes.erase(nCol1, nRow1, nCol2, nRow2); + + bool bAddNotes = nFlags & (IDF_NOTE | IDF_ADDNOTES); + if (bAddNotes) + { + bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; + pDestTab->maNotes.CopyFromClip(maNotes, pDocument, nCol1, nRow1, nCol2, nRow2, 0, 0, pDestTab->nTab, bCloneCaption); + } + if (pDBDataNoName) { ScDBData* pNewDBData = new ScDBData(*pDBDataNoName); @@ -970,6 +994,17 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, aCol[i].CopyToColumn(0, MAXROW, IDF_FORMULA, false, pDestTab->aCol[i]); } + //remove old notes + if (nFlags & IDF_CONTENTS) + pDestTab->maNotes.erase(nCol1, nRow1, nCol2, nRow2); + + bool bAddNotes = nFlags & (IDF_NOTE | IDF_ADDNOTES); + if (bAddNotes) + { + bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; + pDestTab->maNotes.CopyFromClip(maNotes, pDocument, nCol1, nRow1, nCol2, nRow2, 0, 0, pDestTab->nTab, bCloneCaption); + } + if (bWidth||bHeight) { if (bWidth) @@ -1473,8 +1508,18 @@ bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bEmpty = true; for (SCCOL i=nCol1; i<=nCol2 && bEmpty; i++) { - //TODO:moggi bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2 ); + if (!bIgnoreNotes) + { + for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end() && bEmpty; ++itr) + { + SCCOL nCol = itr->first.first; + SCROW nRow = itr->first.second; + + if (nCol >= nCol1 && nCol <= nCol2 && nRow >= nRow1 && nRow <= nRow2) + bEmpty = false; + } + } } return bEmpty; } diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 0635eeebb923..ca47dcbf75af 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -1026,7 +1026,7 @@ bool ScTable::SearchRangeForAllEmptyCells( if (pUndoDoc) { ScAddress aCellPos(nCol, nRow, nTab); - pUndoDoc->PutCell(nCol, nRow, nTab, pCell->CloneWithNote(aCellPos, *pUndoDoc, aCellPos)); + pUndoDoc->PutCell(nCol, nRow, nTab, pCell->CloneWithNote(*pUndoDoc, aCellPos)); } aCol[nCol].SetString(nRow, nTab, rSearchItem.GetReplaceString(), pDocument->GetAddressConvention()); } diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index b080ac045989..c9233c59e8a7 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2178,7 +2178,6 @@ void ScOutputData::AddPDFNotes() for (SCCOL nX=nX1; nX<=nX2; nX++) { CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; - ScBaseCell* pCell = pInfo->pCell; sal_Bool bIsMerged = false; SCROW nY = pRowInfo[nArrY].nRowNo; SCCOL nMergeX = nX; @@ -2189,13 +2188,10 @@ void ScOutputData::AddPDFNotes() // find start of merged cell bIsMerged = sal_True; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); // use origin's pCell for NotePtr test below } - //TODO: moggi search for a better way with new note handling - /* - if ( pCell && pCell->HasNote() && ( bIsMerged || + if ( pDoc->GetNotes(nTab)->findByAddress(nMergeX, nMergeY) && ( bIsMerged || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { long nNoteWidth = (long)( SC_CLIPMARK_SIZE * nPPTX ); @@ -2215,7 +2211,7 @@ void ScOutputData::AddPDFNotes() if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) ) { Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight ); - const ScPostIt* pNote = pCell->GetNote(); + const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nMergeX, nMergeY); // Note title is the cell address (as on printed note pages) String aTitle; @@ -2234,7 +2230,6 @@ void ScOutputData::AddPDFNotes() pPDFData->CreateNote( aNoteRect, aNote ); } } - */ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign; } |