Kaydet (Commit) cd19a766 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SearchResultsDlg

Change-Id: Ib2a031843a92626941ebe9c94a77a44c4c970585
Reviewed-on: https://gerrit.libreoffice.org/69757
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst cddb51d7
......@@ -141,9 +141,6 @@
#define STR_MID NC_("STR_MID", "Mid" )
#define STR_SOUTH NC_("STR_SOUTH", "South" )
#define STR_SUM NC_("STR_SUM", "Total" )
#define STR_SHEET NC_("STR_SHEET", "Sheet" )
#define STR_CELL NC_("STR_CELL", "Cell" )
#define STR_CONTENT NC_("STR_CONTENT", "Content" )
#define SCSTR_UNDO_PAGE_ANCHOR NC_("SCSTR_UNDO_PAGE_ANCHOR", "Page Anchor" )
#define SCSTR_UNDO_CELL_ANCHOR NC_("SCSTR_UNDO_CELL_ANCHOR", "Cell Anchor" )
#define SCSTR_CONDITION NC_("SCSTR_CONDITION", "Condition ")
......
......@@ -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() {}
......
......@@ -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 );
......
......@@ -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);
......
......@@ -2,10 +2,23 @@
<!-- Generated with glade 3.20.1 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkTreeStore" id="liststore3">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name text2 -->
<column type="gchararray"/>
<!-- column-name text3 -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="SearchResultsDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="title" translatable="yes" context="searchresults|SearchResultsDialog">Search Results</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
......@@ -42,13 +55,67 @@
</packing>
</child>
<child>
<object class="svtlo-SvSimpleTableContainer" id="results">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="results">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore3</property>
<property name="rules_hint">True</property>
<property name="headers_visible">True</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="versions-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="searchresults|sheet">Sheet</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="searchresults|cell">Cell</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer2"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="searchresults|content">Content</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer3"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment