diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-03-26 14:12:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-03-26 18:23:23 +0100 |
commit | cd19a7664a25eda786bb76feefb40ebcbf79a54d (patch) | |
tree | 0b3c1986126778e93732013c8d6438842c0f0e66 /sc/source | |
parent | cddb51d709f58f54fbf303fdb567ea0484852657 (diff) |
weld SearchResultsDlg
Change-Id: Ib2a031843a92626941ebe9c94a77a44c4c970585
Reviewed-on: https://gerrit.libreoffice.org/69757
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/dialogs/searchresults.cxx | 97 | ||||
-rw-r--r-- | sc/source/ui/inc/searchresults.hxx | 20 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 2 |
3 files changed, 54 insertions, 65 deletions
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx index 34ac4dd989ee..6a4d899d892f 100644 --- a/sc/source/ui/dialogs/searchresults.cxx +++ b/sc/source/ui/dialogs/searchresults.cxx @@ -22,66 +22,56 @@ namespace sc { -SearchResultsDlg::SearchResultsDlg( SfxBindings* _pBindings, vcl::Window* pParent ) : - ModelessDialog(pParent, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui"), - aSkipped( ScResId( SCSTR_SKIPPED ) ), - mpBindings(_pBindings), mpDoc(nullptr) +SearchResultsDlg::SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParent) + : SfxDialogController(pParent, "modules/scalc/ui/searchresults.ui", "SearchResultsDialog") + , aSkipped(ScResId(SCSTR_SKIPPED)) + , mpBindings(_pBindings) + , mpDoc(nullptr) + , mxList(m_xBuilder->weld_tree_view("results")) + , mxSearchResults(m_xBuilder->weld_label("lbSearchResults")) { - get(mpSearchResults, "lbSearchResults"); - - SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results"); - Size aControlSize(150, 120); - aControlSize = pContainer->LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont)); - pContainer->set_width_request(aControlSize.Width()); - pContainer->set_height_request(aControlSize.Height()); - - mpList = VclPtr<SvSimpleTable>::Create(*pContainer); - long nTabs[] = {0, 40, 60}; - mpList->SetTabs(SAL_N_ELEMENTS(nTabs), nTabs); - mpList->InsertHeaderEntry(ScResId(STR_SHEET) + "\t" + ScResId(STR_CELL) + "\t" + ScResId(STR_CONTENT)); - mpList->SetSelectHdl( LINK(this, SearchResultsDlg, ListSelectHdl) ); -} + mxList->set_size_request(mxList->get_approximate_digit_width() * 50, mxList->get_height_rows(15)); -SearchResultsDlg::~SearchResultsDlg() -{ - disposeOnce(); + std::vector<int> aWidths; + aWidths.push_back(mxList->get_approximate_digit_width() * 10); + aWidths.push_back(mxList->get_approximate_digit_width() * 10); + mxList->set_column_fixed_widths(aWidths); + mxList->connect_changed(LINK(this, SearchResultsDlg, ListSelectHdl)); } -void SearchResultsDlg::dispose() +SearchResultsDlg::~SearchResultsDlg() { - mpList.disposeAndClear(); - mpSearchResults.disposeAndClear(); - ModelessDialog::dispose(); } namespace { class ListWrapper { - OUStringBuffer maName; - VclPtr<SvSimpleTable> mpList; + weld::TreeView& mrList; public: size_t mnCount = 0; static const size_t mnMaximum = 1000; - ListWrapper(const VclPtr<SvSimpleTable> &pList) : - mpList(pList) + ListWrapper(weld::TreeView& rList) + : mrList(rList) { - mpList->Clear(); - mpList->SetUpdateMode(false); + mrList.clear(); + mrList.freeze(); } - void Insert(const OUString &aTabName, + ~ListWrapper() + { + mrList.thaw(); + } + void Insert(const OUString &rTabName, const ScAddress &rPos, formula::FormulaGrammar::AddressConvention eConvention, - const OUString &aText) + const OUString &rText) { if (mnCount++ < mnMaximum) { - maName.append(aTabName); - maName.append("\t"); - maName.append(rPos.Format(ScRefFlags::ADDR_ABS, - nullptr, eConvention)); - maName.append("\t"); - maName.append(aText); - mpList->InsertEntry(maName.makeStringAndClear()); + mrList.append_text(rTabName); + int nPos = mrList.n_children() - 1; + mrList.set_text(nPos, rPos.Format(ScRefFlags::ADDR_ABS, + nullptr, eConvention), 1); + mrList.set_text(nPos, rText, 2); } } }; @@ -89,7 +79,7 @@ namespace void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges, bool bCellNotes ) { - ListWrapper aList(mpList); + ListWrapper aList(*mxList); std::vector<OUString> aTabNames = pDoc->GetAllTableNames(); SCTAB nTabCount = aTabNames.size(); @@ -150,14 +140,12 @@ void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatche OUString aSearchResults = aTotal.replaceFirst("%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); + mxSearchResults->set_label(aSearchResults); mpDoc = pDoc; } -bool SearchResultsDlg::Close() +void SearchResultsDlg::Close() { if (mpBindings) { @@ -168,21 +156,21 @@ bool SearchResultsDlg::Close() if (pDispacher) { pDispacher->ExecuteList(SID_SEARCH_RESULTS_DIALOG, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem }); + SfxCallMode::SYNCHRON | SfxCallMode::RECORD, { &aItem }); } } - return ModelessDialog::Close(); + SfxDialogController::Close(); } -IMPL_LINK_NOARG( SearchResultsDlg, ListSelectHdl, SvTreeListBox*, void ) +IMPL_LINK_NOARG( SearchResultsDlg, ListSelectHdl, weld::TreeView&, void ) { if (!mpDoc) return; - SvTreeListEntry *pEntry = mpList->FirstSelected(); - OUString aTabStr = SvTabListBox::GetEntryText(pEntry, 0); - OUString aPosStr = SvTabListBox::GetEntryText(pEntry, 1); + int nEntry = mxList->get_selected_index(); + OUString aTabStr = mxList->get_text(nEntry, 0); + OUString aPosStr = mxList->get_text(nEntry, 1); SCTAB nTab = -1; if (!mpDoc->GetTable(aTabStr, nTab)) @@ -203,10 +191,11 @@ IMPL_LINK_NOARG( SearchResultsDlg, ListSelectHdl, SvTreeListBox*, void ) } SearchResultsDlgWrapper::SearchResultsDlgWrapper( - vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* /*pInfo*/ ) : - SfxChildWindow(_pParent, nId) + vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* /*pInfo*/) + : SfxChildWindow(_pParent, nId) + , m_xDialog(new SearchResultsDlg(pBindings, _pParent->GetFrameWeld())) { - SetWindow( VclPtr<SearchResultsDlg>::Create(pBindings, _pParent) ); + SetController(m_xDialog); } SearchResultsDlgWrapper::~SearchResultsDlgWrapper() {} diff --git a/sc/source/ui/inc/searchresults.hxx b/sc/source/ui/inc/searchresults.hxx index 74acb8413bff..ff092f897b48 100644 --- a/sc/source/ui/inc/searchresults.hxx +++ b/sc/source/ui/inc/searchresults.hxx @@ -10,9 +10,9 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_SEARCHRESULTS_HXX #define INCLUDED_SC_SOURCE_UI_INC_SEARCHRESULTS_HXX -#include <vcl/dialog.hxx> +#include <vcl/weld.hxx> +#include <sfx2/basedlgs.hxx> #include <sfx2/childwin.hxx> -#include <svtools/simptabl.hxx> class ScDocument; class ScRangeList; @@ -20,27 +20,27 @@ class SvTreeListBox; namespace sc { -class SearchResultsDlg : public ModelessDialog +class SearchResultsDlg : public SfxDialogController { - VclPtr<SvSimpleTable> mpList; - VclPtr<FixedText> mpSearchResults; OUString const aSkipped; SfxBindings* const mpBindings; ScDocument* mpDoc; + std::unique_ptr<weld::TreeView> mxList; + std::unique_ptr<weld::Label> mxSearchResults; - DECL_LINK( ListSelectHdl, SvTreeListBox*, void ); + DECL_LINK(ListSelectHdl, weld::TreeView&, void); public: - SearchResultsDlg( SfxBindings* _pBindings, vcl::Window* pParent ); + SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParent); virtual ~SearchResultsDlg() override; - virtual void dispose() override; - void FillResults( ScDocument* pDoc, const ScRangeList& rMatchedRanges, bool bCellNotes ); + virtual void Close() override; - virtual bool Close() override; + void FillResults( ScDocument* pDoc, const ScRangeList& rMatchedRanges, bool bCellNotes ); }; class SearchResultsDlgWrapper : public SfxChildWindow { + std::shared_ptr<SearchResultsDlg> m_xDialog; public: SearchResultsDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index eb0297c732aa..5bf77e821bfc 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1840,7 +1840,7 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, SfxChildWindow* pWnd = pViewFrm->GetChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId()); if (pWnd) { - sc::SearchResultsDlg* pDlg = static_cast<sc::SearchResultsDlg*>(pWnd->GetWindow()); + sc::SearchResultsDlg* pDlg = static_cast<sc::SearchResultsDlg*>(pWnd->GetController().get()); if (pDlg) pDlg->FillResults(&rDoc, aMatchedRanges, pSearchItem->GetCellType() == SvxSearchCellType::NOTE); |