From ad4abd949de51cd66288bdb4f884cc5ab2b6a59a Mon Sep 17 00:00:00 2001 From: heiko tietze Date: Sat, 25 Nov 2017 12:35:59 +0100 Subject: 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 Reviewed-by: Michael Meeks (cherry picked from commit 470682b3abf0622f5e9663d62d8641f63ceb6f30) Reviewed-on: https://gerrit.libreoffice.org/45320 Reviewed-by: Heiko Tietze Tested-by: Heiko Tietze --- 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(-) 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("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 mpLabel; VclPtr mpList; public: - ListWrapper(const VclPtr &pList, - const VclPtr &pLabel) : - mnCount(0), - mpLabel(pLabel), + size_t mnCount = 0; + static const size_t mnMaximum = 1000; + ListWrapper(const VclPtr &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 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 mpList; - VclPtr mpLabel; + VclPtr 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 @@ + - - + + False 6 @@ -37,7 +38,7 @@ False True end - 0 + 2 @@ -46,6 +47,9 @@ False True True + + + False @@ -54,16 +58,25 @@ - - False + + True False - skipped $1 ... + start + + + False + True + 3 + close + + + -- cgit v1.2.3