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>
This commit is contained in:
Matúš Kukan 2013-09-09 10:19:54 +02:00 committed by Markus Mohrhard
parent 38dd740479
commit 09a546ed1f
7 changed files with 175 additions and 8 deletions

View File

@ -378,6 +378,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
$(if $(filter TRUE,$(MPL_SUBSET)),, \
sc/source/ui/dbgui/pvlaydlg) \
sc/source/ui/dbgui/sfiltdlg \
sc/source/ui/dialogs/searchresults \
sc/source/ui/docshell/arealink \
sc/source/ui/docshell/autostyl \
sc/source/ui/docshell/dbdocfun \

View File

@ -107,6 +107,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/samplingdialog \
sc/uiconfig/scalc/ui/standardfilterdialog \
sc/uiconfig/scalc/ui/scgeneralpage \
sc/uiconfig/scalc/ui/searchresults \
sc/uiconfig/scalc/ui/selectrange \
sc/uiconfig/scalc/ui/selectsource \
sc/uiconfig/scalc/ui/sheetprintpage \

View File

@ -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: */

View File

@ -0,0 +1,31 @@
/* -*- 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/.
*/
#ifndef SC_UI_SEARCHRESULTS_HXX
#define SC_UI_SEARCHRESULTS_HXX
#include <vcl/dialog.hxx>
class ScDocument;
class ScRangeList;
class SvSimpleTable;
class SearchResults : public ModelessDialog
{
ScDocument *mpDoc;
SvSimpleTable *mpList;
DECL_LINK( ListSelectHdl, void * );
public:
SearchResults(ScDocument *);
virtual ~SearchResults();
void Show(const ScRangeList &);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -79,6 +79,7 @@
#include "tabbgcolor.hxx"
#include "clipparam.hxx"
#include "prnsave.hxx"
#include "searchresults.hxx"
#include "tokenarray.hxx"
#include <boost/scoped_ptr.hpp>
@ -1657,6 +1658,9 @@ void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
if (nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL)
{
static SearchResults *aSearchResults = new SearchResults(pDoc);
aSearchResults->Show(aMatchedRanges);
rMark.ResetMark();
for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)
{

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires LibreOffice 1.0 -->
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="SearchResultsDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Search Results</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="close">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="svtlo-SvSimpleTableContainer" id="results">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">close</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1189,13 +1189,8 @@ IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, Control *, pCtrl )
if (m_pAllSheetsCB == pCtrl)
{
if ( m_pAllSheetsCB->IsChecked() )
m_pSearchAllBtn->Disable();
else
{
bSet = sal_True;
ModifyHdl_Impl(m_pSearchLB);
}
bSet = sal_True;
ModifyHdl_Impl(m_pSearchLB);
}
if (m_pJapOptionsCB == pCtrl)
@ -1725,7 +1720,7 @@ void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
if ( m_pSearchAllBtn == pCtrl &&
( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
{
m_pSearchAllBtn->Enable( ( bWriter || !m_pAllSheetsCB->IsChecked() ) );
m_pSearchAllBtn->Enable( true );
return;
}
if ( m_pReplaceBtn == pCtrl && ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )