summaryrefslogtreecommitdiff
path: root/sc/source/ui/namedlg/namemgrtable.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-10 15:50:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-04-11 09:58:26 +0200
commit565a254a814a06086ac067d5c64b4557e73c9666 (patch)
treecc148ac4a4e15fa78f9861d762909895d86d7ec6 /sc/source/ui/namedlg/namemgrtable.cxx
parent92b25179973fce7cafa3364dc19693a5a22f4952 (diff)
weld ScNameDlg
Change-Id: I7a00dd386a1cb52e046d0f57c77fe3fdf8252bb7 Reviewed-on: https://gerrit.libreoffice.org/70548 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/namedlg/namemgrtable.cxx')
-rw-r--r--sc/source/ui/namedlg/namemgrtable.cxx38
1 files changed, 36 insertions, 2 deletions
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 5be7b4eea7e2..22bde43d02fc 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -134,6 +134,13 @@ void ScRangeManagerTable::GetCurrentLine(ScRangeNameLine& rLine)
GetLine(rLine, pCurrentEntry);
}
+void RangeManagerTable::GetCurrentLine(ScRangeNameLine& rLine)
+{
+ std::unique_ptr<weld::TreeIter> xCurrentEntry(m_xTreeView->make_iterator());
+ if (m_xTreeView->get_cursor(xCurrentEntry.get()))
+ GetLine(rLine, *xCurrentEntry);
+}
+
void ScRangeManagerTable::GetLine(ScRangeNameLine& rLine, SvTreeListEntry* pEntry)
{
rLine.aName = GetEntryText( pEntry, 0);
@@ -200,11 +207,24 @@ void ScRangeManagerTable::DeleteSelectedEntries()
RemoveSelection();
}
+void RangeManagerTable::DeleteSelectedEntries()
+{
+ std::vector<int> aRows = m_xTreeView->get_selected_rows();
+ std::sort(aRows.begin(), aRows.end());
+ for (auto it = aRows.rbegin(); it != aRows.rend(); ++it)
+ m_xTreeView->remove(*it);
+}
+
bool ScRangeManagerTable::IsMultiSelection()
{
return GetSelectionCount() > 1;
}
+bool RangeManagerTable::IsMultiSelection()
+{
+ return m_xTreeView->count_selected_rows() > 1;
+}
+
std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries()
{
std::vector<ScRangeNameLine> aSelectedEntries;
@@ -236,6 +256,18 @@ void ScRangeManagerTable::SetEntry(const ScRangeNameLine& rLine)
}
}
+void RangeManagerTable::SetEntry(const ScRangeNameLine& rLine)
+{
+ for (int i = 0, nEntryCount = m_xTreeView->n_children(); i < nEntryCount; ++i)
+ {
+ if (rLine.aName == m_xTreeView->get_text(i, 0) &&
+ rLine.aScope == m_xTreeView->get_text(i, 2))
+ {
+ m_xTreeView->set_cursor(i);
+ }
+ }
+}
+
namespace {
//ensure that the minimum column size is respected
@@ -367,7 +399,7 @@ IMPL_LINK_NOARG(RangeManagerTable, SizeAllocHdl, const Size&, void)
CheckForFormulaString();
}
-void RangeManagerTable::addEntry(const ScRangeNameLine& rLine)
+void RangeManagerTable::addEntry(const ScRangeNameLine& rLine, bool bSetCurEntry)
{
int nRow = m_xTreeView->n_children();
m_xTreeView->append();
@@ -376,6 +408,8 @@ void RangeManagerTable::addEntry(const ScRangeNameLine& rLine)
m_xTreeView->set_text(nRow, rLine.aScope, 2);
// just unique to track which one has been cached by maCalculatedFormulaEntries
m_xTreeView->set_id(nRow, OUString::number(m_nId++));
+ if (bSetCurEntry)
+ m_xTreeView->set_cursor(nRow);
}
void RangeManagerTable::GetLine(ScRangeNameLine& rLine, weld::TreeIter& rEntry)
@@ -402,7 +436,7 @@ void RangeManagerTable::Init()
if (!rEntry.second->HasType(ScRangeData::Type::Database))
{
aLine.aName = rEntry.second->GetName();
- addEntry(aLine);
+ addEntry(aLine, false);
}
}
}