diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-23 06:20:06 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-23 06:25:36 +0100 |
commit | ab63c12395ed3771b1df6822eaa8572c06db0765 (patch) | |
tree | 5b9448bdb43d84f859d4a90224dabd51779bcf68 /sc | |
parent | e58dfb62106fc047d73ad0d62595ebc805ece5e1 (diff) |
ManageNames: make pasting of multiple names working and fix crash
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/namedlg/namemgrtable.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/editsh.cxx | 15 |
3 files changed, 32 insertions, 10 deletions
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx index a72e765e536b..dc894a093c4b 100644 --- a/sc/source/ui/namedlg/namemgrtable.cxx +++ b/sc/source/ui/namedlg/namemgrtable.cxx @@ -140,7 +140,8 @@ void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>& void ScRangeManagerTable::DeleteSelectedEntries() { - RemoveSelection(); + if (GetSelectionCount()) + RemoveSelection(); } bool ScRangeManagerTable::IsMultiSelection() @@ -151,16 +152,19 @@ bool ScRangeManagerTable::IsMultiSelection() std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries() { std::vector<ScRangeNameLine> aSelectedEntries; - for (SvLBoxEntry* pEntry = FirstSelected(); pEntry != LastSelected(); pEntry = NextSelected(pEntry)) + if (GetSelectionCount()) { + 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); } - SvLBoxEntry* pEntry = LastSelected(); - ScRangeNameLine aLine; - GetLine( aLine, pEntry ); - aSelectedEntries.push_back(aLine); return aSelectedEntries; } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index a8f5cba3dcc4..0aab1e5b9908 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1838,7 +1838,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) ); std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames(); - pHdl->InsertFunction( aNames.at(0), false ); // without "()" + if (aNames.size()) + { + rtl::OUStringBuffer aBuffer; + for (std::vector<rtl::OUString>::const_iterator itr = aNames.begin(); + itr != aNames.end(); ++itr) + { + aBuffer.append(*itr).append(' '); + } + pHdl->InsertFunction( aBuffer.makeStringAndClear(), false ); // without "()" + } } } break; diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 15bc31eb8bac..9a1eff383f8b 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -440,9 +440,18 @@ void ScEditShell::Execute( SfxRequest& rReq ) if ( nRet == BTN_PASTE_NAME ) { std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames(); - pTableView->InsertText(aNames.at(0)); - if (pTopView) - pTopView->InsertText(aNames.at(0)); + if (aNames.size()) + { + rtl::OUStringBuffer aBuffer; + for (std::vector<rtl::OUString>::const_iterator itr = aNames.begin(); + itr != aNames.end(); ++itr) + { + aBuffer.append(*itr).append(' '); + } + pTableView->InsertText(aBuffer.toString()); + if (pTopView) + pTopView->InsertText(aBuffer.makeStringAndClear()); + } } delete pDlg; |