sc/inc/strings.hrc | 2 + sc/source/ui/dialogs/searchresults.cxx | 45 +++++++++++++-------------------- sc/source/ui/inc/searchresults.hxx | 4 ++ sc/uiconfig/scalc/ui/searchresults.ui | 25 +++++++++++++----- 4 files changed, 42 insertions(+), 34 deletions(-)
New commits: commit 470682b3abf0622f5e9663d62d8641f63ceb6f30 Author: heiko tietze <tietze.he...@gmail.com> Date: Sat Nov 25 12:35:59 2017 +0100 tdf#113831 Show number of search results Skipped label used to show the number via resource strings Change-Id: I6f57799565126c202041d0bf6a9f361d4e64cdfd Reviewed-on: https://gerrit.libreoffice.org/45269 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index e82b9d1f5362..a29c93b54a7c 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -47,6 +47,8 @@ #define SCSTR_NO_TAB_BG_COLOR NC_("SCSTR_NO_TAB_BG_COLOR", "Default") #define SCSTR_RENAMEOBJECT NC_("SCSTR_RENAMEOBJECT", "Name Object") #define STR_INSERTGRAPHIC NC_("STR_INSERTGRAPHIC", "Insert Image") +#define SCSTR_TOTAL NC_("SCSTR_TOTAL", "%1 results found") +#define SCSTR_SKIPPED NC_("SCSTR_SKIPPED", "(only %1 are listed)") // Attribute #define SCSTR_PROTECTDOC NC_("SCSTR_PROTECTDOC", "Protect Document") #define SCSTR_UNPROTECTDOC NC_("SCSTR_UNPROTECTDOC", "Unprotect document") diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx index d9cf33f1a4be..f72bb7423388 100644 --- a/sc/source/ui/dialogs/searchresults.cxx +++ b/sc/source/ui/dialogs/searchresults.cxx @@ -25,9 +25,11 @@ namespace sc { SearchResultsDlg::SearchResultsDlg( SfxBindings* _pBindings, vcl::Window* pParent ) : ModelessDialog(pParent, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui"), + aSkipped( ScResId( SCSTR_SKIPPED ) ), + aTotal( ScResId( SCSTR_TOTAL ) ), mpBindings(_pBindings), mpDoc(nullptr) { - get(mpLabel, "skipped"); + get(mpSearchResults, "lbSearchResults"); SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results"); Size aControlSize(150, 120); @@ -50,23 +52,19 @@ SearchResultsDlg::~SearchResultsDlg() void SearchResultsDlg::dispose() { mpList.disposeAndClear(); - mpLabel.disposeAndClear(); + mpSearchResults.disposeAndClear(); ModelessDialog::dispose(); } namespace { class ListWrapper { - size_t mnCount; - static const size_t mnMaximum = 1000; OUStringBuffer maName; - VclPtr<FixedText> mpLabel; VclPtr<SvSimpleTable> mpList; public: - ListWrapper(const VclPtr<SvSimpleTable> &pList, - const VclPtr<FixedText> &pLabel) : - mnCount(0), - mpLabel(pLabel), + size_t mnCount = 0; + static const size_t mnMaximum = 1000; + ListWrapper(const VclPtr<SvSimpleTable> &pList) : mpList(pList) { mpList->Clear(); @@ -88,33 +86,19 @@ namespace mpList->InsertEntry(maName.makeStringAndClear()); } } - void Update() - { - if (mnCount > mnMaximum) - { - if (mpLabel) - { - size_t nSkipped = mnCount - mnMaximum; - OUString aSkipped(mpLabel->GetText()); - mpList->InsertEntry( - aSkipped.replaceFirst("$1", OUString::number(nSkipped))); - } - } - mpList->SetUpdateMode(true); - } }; } void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges, bool bCellNotes ) { - ListWrapper aList(mpList, mpLabel); + ListWrapper aList(mpList); std::vector<OUString> aTabNames = pDoc->GetAllTableNames(); SCTAB nTabCount = aTabNames.size(); // tdf#92160 - too many results blow the widget's mind size_t nMatchMax = rMatchedRanges.size(); - if (nMatchMax > 1000) - nMatchMax = 1000; + if (nMatchMax > ListWrapper::mnMaximum) + nMatchMax = ListWrapper::mnMaximum; if (bCellNotes) { @@ -163,7 +147,14 @@ void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatche } } } - aList.Update(); + + OUString aSearchResults = ScGlobal::ReplaceOrAppend( aTotal, "%1", OUString::number( aList.mnCount ) ); + if (aList.mnCount > ListWrapper::mnMaximum) + aSearchResults += " " + ScGlobal::ReplaceOrAppend( aSkipped, "%1", OUString::number( ListWrapper::mnMaximum ) ); + mpSearchResults->SetText(aSearchResults); + + mpList->SetUpdateMode(true); + mpDoc = pDoc; } diff --git a/sc/source/ui/inc/searchresults.hxx b/sc/source/ui/inc/searchresults.hxx index ae9707ef2ac4..f07cc19ce5df 100644 --- a/sc/source/ui/inc/searchresults.hxx +++ b/sc/source/ui/inc/searchresults.hxx @@ -23,7 +23,9 @@ namespace sc { class SearchResultsDlg : public ModelessDialog { VclPtr<SvSimpleTable> mpList; - VclPtr<FixedText> mpLabel; + VclPtr<FixedText> mpSearchResults; + OUString aSkipped; + OUString aTotal; SfxBindings* mpBindings; ScDocument* mpDoc; diff --git a/sc/uiconfig/scalc/ui/searchresults.ui b/sc/uiconfig/scalc/ui/searchresults.ui index 7146a03a2117..62b8ffa19303 100644 --- a/sc/uiconfig/scalc/ui/searchresults.ui +++ b/sc/uiconfig/scalc/ui/searchresults.ui @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.1 --> <interface domain="sc"> - <!-- interface-requires LibreOffice 1.0 --> - <!-- interface-requires gtk+ 3.0 --> + <requires lib="gtk+" version="3.0"/> + <requires lib="LibreOffice" version="1.0"/> <object class="GtkDialog" id="SearchResultsDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -37,7 +38,7 @@ <property name="expand">False</property> <property name="fill">True</property> <property name="pack_type">end</property> - <property name="position">0</property> + <property name="position">2</property> </packing> </child> <child> @@ -46,6 +47,9 @@ <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> </object> <packing> <property name="expand">False</property> @@ -54,16 +58,25 @@ </packing> </child> <child> - <object class="GtkLabel" id="skipped"> - <property name="visible">False</property> + <object class="GtkLabel" id="lbSearchResults"> + <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes" context="searchresults|skipped">skipped $1 ...</property> + <property name="halign">start</property> + <property name="label"></property> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> </child> </object> </child> <action-widgets> <action-widget response="0">close</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits