Kaydet (Commit) ab63c123 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

ManageNames: make pasting of multiple names working and fix crash

üst e58dfb62
...@@ -140,7 +140,8 @@ void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>& ...@@ -140,7 +140,8 @@ void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>&
void ScRangeManagerTable::DeleteSelectedEntries() void ScRangeManagerTable::DeleteSelectedEntries()
{ {
RemoveSelection(); if (GetSelectionCount())
RemoveSelection();
} }
bool ScRangeManagerTable::IsMultiSelection() bool ScRangeManagerTable::IsMultiSelection()
...@@ -151,16 +152,19 @@ bool ScRangeManagerTable::IsMultiSelection() ...@@ -151,16 +152,19 @@ bool ScRangeManagerTable::IsMultiSelection()
std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries() std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries()
{ {
std::vector<ScRangeNameLine> aSelectedEntries; 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; ScRangeNameLine aLine;
GetLine( aLine, pEntry ); GetLine( aLine, pEntry );
aSelectedEntries.push_back(aLine); aSelectedEntries.push_back(aLine);
} }
SvLBoxEntry* pEntry = LastSelected();
ScRangeNameLine aLine;
GetLine( aLine, pEntry );
aSelectedEntries.push_back(aLine);
return aSelectedEntries; return aSelectedEntries;
} }
......
...@@ -1838,7 +1838,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) ...@@ -1838,7 +1838,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) ); pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames(); 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; break;
......
...@@ -440,9 +440,18 @@ void ScEditShell::Execute( SfxRequest& rReq ) ...@@ -440,9 +440,18 @@ void ScEditShell::Execute( SfxRequest& rReq )
if ( nRet == BTN_PASTE_NAME ) if ( nRet == BTN_PASTE_NAME )
{ {
std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames(); std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames();
pTableView->InsertText(aNames.at(0)); if (aNames.size())
if (pTopView) {
pTopView->InsertText(aNames.at(0)); 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; delete pDlg;
......
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