summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2013-09-09 10:19:54 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-20 14:20:50 +0000
commit09a546ed1f4ca691ab9a81e0a0a08ec53f99a558 (patch)
tree2981fce61a3fe945c68198f92fe3fbe990068d2d
parent38dd74047968fd734b598d3ee7293cd5263c1012 (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>
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/UIConfig_scalc.mk1
-rw-r--r--sc/source/ui/dialogs/searchresults.cxx73
-rw-r--r--sc/source/ui/inc/searchresults.hxx31
-rw-r--r--sc/source/ui/view/viewfun2.cxx4
-rw-r--r--sc/uiconfig/scalc/ui/searchresults.ui62
-rw-r--r--svx/source/dialog/srchdlg.cxx11
7 files changed, 175 insertions, 8 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index b0ab893c8698..47a67f0a6926 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -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 \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 9274dd6de91e..2945a5cae6ad 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -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 \
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: */
diff --git a/sc/source/ui/inc/searchresults.hxx b/sc/source/ui/inc/searchresults.hxx
new file mode 100644
index 000000000000..a5f01a0c5bab
--- /dev/null
+++ b/sc/source/ui/inc/searchresults.hxx
@@ -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: */
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index c8ba3a77327a..267969276b9d 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -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)
{
diff --git a/sc/uiconfig/scalc/ui/searchresults.ui b/sc/uiconfig/scalc/ui/searchresults.ui
new file mode 100644
index 000000000000..c39408aa2a31
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/searchresults.ui
@@ -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>
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index d9535b14d2d3..d07b77373ced 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -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 )