diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2013-09-09 10:19:54 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-09-20 14:20:50 +0000 |
commit | 09a546ed1f4ca691ab9a81e0a0a08ec53f99a558 (patch) | |
tree | 2981fce61a3fe945c68198f92fe3fbe990068d2d /sc/source/ui/dialogs | |
parent | 38dd74047968fd734b598d3ee7293cd5263c1012 (diff) |
fdo#39881 change Find All behaviour in Calc
Allow to search in all sheets.
Find all now creates new dialog describing all matching cells.
Change-Id: I36a9bee314b620384937fff074680022397c8c5f
Reviewed-on: https://gerrit.libreoffice.org/5886
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source/ui/dialogs')
-rw-r--r-- | sc/source/ui/dialogs/searchresults.cxx | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx new file mode 100644 index 000000000000..fa89eb7f5c41 --- /dev/null +++ b/sc/source/ui/dialogs/searchresults.cxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "searchresults.hxx" + +#include <svtools/simptabl.hxx> +#include <svtools/treelistentry.hxx> +#include "dociter.hxx" +#include "document.hxx" +#include "rangeutl.hxx" +#include "tabvwsh.hxx" + +SearchResults::SearchResults(ScDocument *pDoc) : + ModelessDialog(NULL, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui") + , mpDoc(pDoc) +{ + SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results"); + Size aControlSize(150, 120); + aControlSize = pContainer->LogicToPixel(aControlSize, MAP_APPFONT); + pContainer->set_width_request(aControlSize.Width()); + pContainer->set_height_request(aControlSize.Height()); + + mpList = new SvSimpleTable(*pContainer); + long nTabs[] = {3, 0, 40, 60}; + mpList->SetTabs(&nTabs[0]); + mpList->InsertHeaderEntry("Sheet\tCell\tContent"); + mpList->SetSelectHdl( LINK(this, SearchResults, ListSelectHdl) ); +} + +SearchResults::~SearchResults() +{ + delete mpList; +} + +void SearchResults::Show(const ScRangeList &rMatchedRanges) +{ + mpList->Clear(); + for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i) + { + ScCellIterator aIter(mpDoc, *rMatchedRanges[i]); + for (bool bHas = aIter.first(); bHas; bHas = aIter.next()) + { + ScAddress aAddress = aIter.GetPos(); + OUString sAddress; + ScRangeStringConverter::GetStringFromAddress(sAddress, aAddress, + mpDoc, formula::FormulaGrammar::CONV_OOO); + mpList->InsertEntry(sAddress.replace('.', '\t') + "\t" + mpDoc->GetString(aAddress)); + } + } + ModelessDialog::Show(); +} + +IMPL_LINK_NOARG( SearchResults, ListSelectHdl ) +{ + SvTreeListEntry *pEntry = mpList->FirstSelected(); + ScAddress aAddress; + sal_Int32 nOffset = 0; + OUString sAddress = mpList->GetEntryText(pEntry).replaceFirst("\t", "."); + ScRangeStringConverter::GetAddressFromString(aAddress, sAddress, + mpDoc, formula::FormulaGrammar::CONV_OOO, nOffset, '\t'); + ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); + pScViewShell->SetTabNo(aAddress.Tab()); + pScViewShell->SetCursor(aAddress.Col(), aAddress.Row()); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |