diff options
author | Eike Rathke <erack@redhat.com> | 2016-07-28 00:43:03 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-07-28 00:50:15 +0200 |
commit | 4f719263ae8dc44eabfba4654f9dbed92a9c5360 (patch) | |
tree | 58082e261d0b9175ac42c873e5379c7bebc4ee86 /sc/source/ui/dialogs/searchresults.cxx | |
parent | d4cb9c3a8851cb874fd8b6c77d4d7521da7579b7 (diff) |
display the SearchAll() and ReplaceAll() results for notes, tdf#65334 related
Change-Id: Ib9ff40b26526efdf242db2ef1804e54611f16b0e
Diffstat (limited to 'sc/source/ui/dialogs/searchresults.cxx')
-rw-r--r-- | sc/source/ui/dialogs/searchresults.cxx | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx index 225fb2f0318b..c6e747084a6f 100644 --- a/sc/source/ui/dialogs/searchresults.cxx +++ b/sc/source/ui/dialogs/searchresults.cxx @@ -50,24 +50,57 @@ void SearchResultsDlg::dispose() ModelessDialog::dispose(); } -void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges ) +void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges, bool bCellNotes ) { mpList->Clear(); mpList->SetUpdateMode(false); std::vector<OUString> aTabNames = pDoc->GetAllTableNames(); SCTAB nTabCount = aTabNames.size(); - for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i) + if (bCellNotes) { - ScCellIterator aIter(pDoc, *rMatchedRanges[i]); - for (bool bHas = aIter.first(); bHas; bHas = aIter.next()) + for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i) { - ScAddress aPos = aIter.GetPos(); - if (aPos.Tab() >= nTabCount) - // Out-of-bound sheet index. - continue; - - OUString aPosStr = aPos.Format(ScRefFlags::ADDR_ABS, nullptr, pDoc->GetAddressConvention()); - mpList->InsertEntry(aTabNames[aPos.Tab()] + "\t" + aPosStr + "\t" + pDoc->GetString(aPos)); + /* TODO: a CellNotes iterator would come handy and migt speed + * things up a little, though we only loop through the + * search/replace result positions here. */ + ScRange aRange( *rMatchedRanges[i] ); + // Bear in mind that mostly the range is one address position + // or a column or a row joined. + ScAddress aPos( aRange.aStart ); + for ( ; aPos.Tab() <= aRange.aEnd.Tab(); aPos.IncTab()) + { + if (aPos.Tab() >= nTabCount) + break; // can this even happen? we just searched on existing sheets ... + for (aPos.SetCol( aRange.aStart.Col()); aPos.Col() <= aRange.aEnd.Col(); aPos.IncCol()) + { + for (aPos.SetRow( aRange.aStart.Row()); aPos.Row() <= aRange.aEnd.Row(); aPos.IncRow()) + { + const ScPostIt* pNote = pDoc->GetNote( aPos); + if (pNote) + { + OUString aPosStr = aPos.Format(ScRefFlags::ADDR_ABS, nullptr, pDoc->GetAddressConvention()); + mpList->InsertEntry(aTabNames[aPos.Tab()] + "\t" + aPosStr + "\t" + pNote->GetText()); + } + } + } + } + } + } + else + { + for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i) + { + ScCellIterator aIter(pDoc, *rMatchedRanges[i]); + for (bool bHas = aIter.first(); bHas; bHas = aIter.next()) + { + ScAddress aPos = aIter.GetPos(); + if (aPos.Tab() >= nTabCount) + // Out-of-bound sheet index. + continue; + + OUString aPosStr = aPos.Format(ScRefFlags::ADDR_ABS, nullptr, pDoc->GetAddressConvention()); + mpList->InsertEntry(aTabNames[aPos.Tab()] + "\t" + aPosStr + "\t" + pDoc->GetString(aPos)); + } } } mpList->SetUpdateMode(true); |