diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2013-09-11 09:06:24 +0200 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-23 10:44:20 -0400 |
commit | 759bdbbc348d320994813a9de1a7927b795580a3 (patch) | |
tree | 897cb53c217866ce6b365f76943390e3e6368529 /sc/source/ui/view | |
parent | ae88290f87acf693fed02140ca384ec15589616b (diff) |
Re-implement cell note storage using mdds::multi_type_vector.
Change-Id: I34ea91e360e2a6b85d65f970c6e43db687d213ca
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r-- | sc/source/ui/view/cellsh.cxx | 64 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/view/drawview.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin5.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/printfun.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun6.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 1 |
9 files changed, 43 insertions, 97 deletions
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 6fe7c0e2ffff..e1ed032bcadd 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -602,7 +602,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) { // always take cursor position, do not use top-left cell of selection OUString aNoteText; - if ( const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY) ) + if ( const ScPostIt* pNote = pDoc->GetNote(nPosX, nPosY, nTab) ) aNoteText = pNote->GetText(); rSet.Put( SfxStringItem( nWhich, aNoteText ) ); } @@ -906,7 +906,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) case FID_NOTE_VISIBLE: { - const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY); + const ScPostIt* pNote = pDoc->GetNote(nPosX, nPosY, nTab); if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) ) rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) ); else @@ -922,7 +922,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) if (!rMark.IsMarked() && !rMark.IsMultiMarked()) { // Check current cell - const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY); + const ScPostIt* pNote = pDoc->GetNote(nPosX, nPosY, nTab); if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) ) if ( pNote->IsCaptionShown() != bSearchForHidden) bEnable = true; @@ -943,41 +943,18 @@ void ScCellShell::GetState(SfxItemSet &rSet) const SCCOL nCol0 = pRange->aStart.Col(); const SCCOL nCol1 = pRange->aEnd.Col(); const SCTAB nRangeTab = pRange->aStart.Tab(); - const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 ); - const ScNotes *pNotes = pDoc->GetNotes(nRangeTab); - - if ( nCellNumber < pNotes->size() ) - { - // Check by each cell - for ( SCROW nRow = nRow0; nRow <= nRow1 && !bEnable; ++nRow ) - { - for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol ) - { - const ScPostIt* pNote = pNotes->findByAddress(nCol, nRow); - if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) ) - { - if ( pNote->IsCaptionShown() != bSearchForHidden) - { - bEnable = true; - break; - } - } - } - } - } - else + // Check by each cell + // nCellNumber < pDoc->CountNotes() with const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 ); + for ( SCROW nRow = nRow0; nRow <= nRow1 && !bEnable; ++nRow ) { - // Check by each document note - for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr) + for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol ) { - SCCOL nCol = itr->first.first; - SCROW nRow = itr->first.second; - - if ( nCol <= nCol1 && nRow <= nRow1 && nCol >= nCol0 && nRow >= nRow0 ) + const ScPostIt* pNote = pDoc->GetNote(nCol, nRow, nRangeTab); + if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) ) { - if ( itr->second->IsCaptionShown() != bSearchForHidden) + if ( pNote->IsCaptionShown() != bSearchForHidden) { - bEnable = true; //note found + bEnable = true; break; } } @@ -1003,17 +980,16 @@ void ScCellShell::GetState(SfxItemSet &rSet) size_t nCount = aRanges.size(); for (size_t nPos = 0; nPos < nCount && !bEnable; ++nPos) { - ScNotes* pNotes = pDoc->GetNotes( aRanges[nPos]->aStart.Tab() ); - for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr) + SCTAB aTab = aRanges[nPos]->aStart.Tab(); + for (SCCOL aCol=aRanges[nPos]->aStart.Col(); aCol <= aRanges[nPos]->aEnd.Col() && !bEnable; aCol++) { - 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() ) + for (SCROW aRow=aRanges[nPos]->aStart.Row(); aRow <= aRanges[nPos]->aEnd.Row(); aRow++) { - bEnable = true; //note found - break; + if (pDoc->HasNote(aCol, aRow, aTab)) + { + bEnable = true; + break; + } } } } @@ -1022,7 +998,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) else { bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) && - pDoc->GetNotes(nTab)->findByAddress( nPosX, nPosY ); + pDoc->GetNote(nPosX, nPosY, nTab); } if ( !bEnable ) rSet.DisableItem( nWhich ); diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 75d4a8dfa88b..83901a69e971 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2113,7 +2113,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) { ScDocument* pDoc = GetViewData()->GetDocument(); ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); - if( ScPostIt* pNote = pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) ) + if( ScPostIt* pNote = pDoc->GetNote(aPos) ) { bool bShow; const SfxPoolItem* pItem; @@ -2148,7 +2148,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) { // Check current cell ScAddress aPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() ); - if( pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) ) + if( pDoc->GetNote(aPos) ) { pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote ); bDone = true; @@ -2173,35 +2173,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) const SCCOL nCol0 = pRange->aStart.Col(); const SCCOL nCol1 = pRange->aEnd.Col(); const SCTAB nRangeTab = pRange->aStart.Tab(); - const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 ); - ScNotes *pNotes = pDoc->GetNotes(nRangeTab); - - if ( nCellNumber < pNotes->size() ) + // Check by each cell + for ( SCROW nRow = nRow0; nRow <= nRow1; ++nRow ) { - // Check by each cell - for ( SCROW nRow = nRow0; nRow <= nRow1; ++nRow ) + for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol ) { - for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol ) - { - ScPostIt* pNote = pNotes->findByAddress(nCol, nRow); - if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) ) - { - ScAddress aPos( nCol, nRow, nRangeTab ); - pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote ); - bDone = true; - } - } - } - } - else - { - // Check by each document note - for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr) - { - SCCOL nCol = itr->first.first; - SCROW nRow = itr->first.second; - - if ( nCol <= nCol1 && nRow <= nRow1 && nCol >= nCol0 && nRow >= nRow0 ) + if ( pDoc->HasNote(nCol, nRow, nRangeTab) && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) ) { ScAddress aPos( nCol, nRow, nRangeTab ); pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote ); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 5300a096121a..18cd6fec9e38 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -749,7 +749,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->GetNotes(pCaptData->maStart.Tab())->ReleaseNote( pCaptData->maStart ); + ScPostIt* pNote = pDoc->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 f70b838b22ff..beef8046b8dd 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -384,7 +384,7 @@ static void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pD ScDocument& rDoc = *pViewData->GetDocument(); ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ); - ScPostIt* pNote = rDoc.GetNotes( aCellPos.Tab() )->findByAddress( aCellPos ); + ScPostIt* pNote = rDoc.GetNote( 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 fc08d7e4ef13..41328c1007bb 100644 --- a/sc/source/ui/view/gridwin5.cxx +++ b/sc/source/ui/view/gridwin5.cxx @@ -163,7 +163,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->GetNotes( aCellPos.Tab() )->findByAddress( aCellPos ); + const ScPostIt* pNote = pDoc->GetNote( aCellPos ); if ( (!aTrackText.isEmpty()) || (pNote && !pNote->IsCaptionShown()) ) { bool bNew = true; diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 58673afd7eb7..089d4d8c07fb 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2356,7 +2356,7 @@ void ScOutputData::DrawNoteMarks() // use origin's pCell for NotePtr test below } - if ( mpDoc->GetNotes(nTab)->findByAddress(nX, pRowInfo[nArrY].nRowNo) && ( bIsMerged || + if ( mpDoc->GetNote(nX, pRowInfo[nArrY].nRowNo, nTab) && ( bIsMerged || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { if (bFirst) @@ -2432,7 +2432,7 @@ void ScOutputData::AddPDFNotes() // use origin's pCell for NotePtr test below } - if ( mpDoc->GetNotes(nTab)->findByAddress(nMergeX, nMergeY) && ( bIsMerged || + if ( mpDoc->GetNote(nMergeX, nMergeY, nTab) && ( bIsMerged || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { long nNoteWidth = (long)( SC_CLIPMARK_SIZE * mnPPTX ); @@ -2452,7 +2452,7 @@ void ScOutputData::AddPDFNotes() if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) ) { Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight ); - const ScPostIt* pNote = mpDoc->GetNotes(nTab)->findByAddress(nMergeX, nMergeY); + const ScPostIt* pNote = mpDoc->GetNote(nMergeX, nMergeY, nTab); // Note title is the cell address (as on printed note pages) ScAddress aAddress( nMergeX, nMergeY, nTab ); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 814a6ceb6cbe..6584bb83dbc3 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1863,7 +1863,7 @@ long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocation { ScAddress &rPos = aNotePosList[ nNoteStart + nCount ]; - if( const ScPostIt* pNote = pDoc->GetNotes(rPos.Tab())->findByAddress( rPos ) ) + if( const ScPostIt* pNote = pDoc->GetNote( rPos ) ) { if(const EditTextObject *pEditText = pNote->GetEditTextObject()) pEditEngine->SetText(*pEditText); @@ -2465,8 +2465,6 @@ long ScPrintFunc::CountNotePages() if ( !aTableParam.bNotes || !bPrintCurrentTable ) return 0; - long nCount=0; - sal_Bool bError = false; if (!aAreaParam.bPrintArea) bError = !AdjustPrintArea(sal_True); // completely search in Doc @@ -2495,20 +2493,16 @@ long ScPrintFunc::CountNotePages() if (bDoThis) { - ScNotes::const_iterator itr = pDoc->GetNotes(nPrintTab)->begin(); - ScNotes::const_iterator itrEnd = pDoc->GetNotes(nPrintTab)->end(); - for (; itr != itrEnd; ++itr) + for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) { - SCCOL nCol = itr->first.first; - SCROW nRow = itr->first.second; - if (nCol > nEndCol || nRow > nEndRow) - continue; - - if (nCol < nStartCol || nRow < nStartRow) - continue; - - aNotePosList.push_back( ScAddress( nCol, nRow, nPrintTab ) ); - ++nCount; + if (pDoc->HasColNotes(nCol, nPrintTab)) + { + for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow ) + { + if ( pDoc->HasNote(nCol, nRow, nPrintTab) ) + aNotePosList.push_back( ScAddress( nCol, nRow, nPrintTab ) ); + } + } } } } diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx index 16fa92c04645..9c25516c94eb 100644 --- a/sc/source/ui/view/viewfun6.cxx +++ b/sc/source/ui/view/viewfun6.cxx @@ -292,7 +292,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->GetNotes(aPos.Tab())->GetOrCreateNote( aPos ) ) + if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) ) { // hide temporary note caption HideNoteMarker(); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index fcf4fec85c6a..ec2abd28caf7 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2043,7 +2043,6 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR nTab = *itr; const SCCOLROW* pTabRanges = pRanges; - pDoc->InitializeNoteCaptions( nTab ); for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) { SCCOLROW nStartNo = *(pTabRanges++); |