From 42bb6baae411dcef47fbe8555412960be2c0dfad Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 20 Nov 2011 08:22:02 +0100 Subject: ManageNames: make Multiselection work in the table --- sc/source/ui/namedlg/namemgrtable.cxx | 55 +++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'sc/source/ui/namedlg/namemgrtable.cxx') diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx index 40309d8f4ed7..5528efb2b168 100644 --- a/sc/source/ui/namedlg/namemgrtable.cxx +++ b/sc/source/ui/namedlg/namemgrtable.cxx @@ -35,6 +35,7 @@ #include "namedlg.hrc" #include "namedlg.hxx" #include "viewdata.hxx" +#include "globalnames.hxx" #include "sfx2/app.hxx" @@ -83,6 +84,7 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, ScRangeName* pGlobalR Show(); maHeaderBar.Show(); + SetSelectionMode(MULTIPLE_SELECTION); } void ScRangeManagerTable::addEntry(const ScRangeNameLine& rLine) @@ -94,32 +96,28 @@ void ScRangeManagerTable::addEntry(const ScRangeNameLine& rLine) void ScRangeManagerTable::GetCurrentLine(ScRangeNameLine& rLine) { SvLBoxEntry* pCurrentEntry = GetCurEntry(); - rLine.aName = GetEntryText( pCurrentEntry, 0); - rLine.aExpression = GetEntryText(pCurrentEntry, 1); - rLine.aScope = GetEntryText(pCurrentEntry, 2); + GetLine(rLine, pCurrentEntry); +} + +void ScRangeManagerTable::GetLine(ScRangeNameLine& rLine, SvLBoxEntry* pEntry) +{ + rLine.aName = GetEntryText( pEntry, 0); + rLine.aExpression = GetEntryText(pEntry, 1); + rLine.aScope = GetEntryText(pEntry, 2); } void ScRangeManagerTable::UpdateEntries() { Clear(); - for (ScRangeName::iterator itr = mpGlobalRangeName->begin(); - itr != mpGlobalRangeName->end(); ++itr) - { - if (!itr->HasType(RT_DATABASE) && !itr->HasType(RT_SHARED)) - { - ScRangeNameLine aLine; - aLine.aName = itr->GetName(); - aLine.aScope = maGlobalString; - itr->GetSymbol(aLine.aExpression); - addEntry(aLine); - } - } for (std::map::iterator itr = maTabRangeNames.begin(); itr != maTabRangeNames.end(); ++itr) { ScRangeName* pLocalRangeName = itr->second; ScRangeNameLine aLine; - aLine.aScope = itr->first; + if (itr->first == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME))) + aLine.aScope = maGlobalString; + else + aLine.aScope = itr->first; for (ScRangeName::iterator it = pLocalRangeName->begin(); it != pLocalRangeName->end(); ++it) { @@ -133,6 +131,31 @@ void ScRangeManagerTable::UpdateEntries() } } +void ScRangeManagerTable::DeleteSelectedEntries() +{ + RemoveSelection(); +} + +bool ScRangeManagerTable::IsMultiSelection() +{ + return GetSelectionCount() > 1; +} + +std::vector ScRangeManagerTable::GetSelectedEntries() +{ + std::vector aSelectedEntries; + for (SvLBoxEntry* pEntry = FirstSelected(); pEntry != LastSelected(); pEntry = NextSelected(pEntry)) + { + ScRangeNameLine aLine; + GetLine( aLine, pEntry ); + aSelectedEntries.push_back(aLine); + } + SvLBoxEntry* pEntry = LastSelected(); + ScRangeNameLine aLine; + GetLine( aLine, pEntry ); + aSelectedEntries.push_back(aLine); + return aSelectedEntries; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3