Factorise external pasting code.

* LyXText::pasteString(): new private method.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16475 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-01-03 07:30:50 +00:00
parent 04afd7af17
commit 61f7ebd4a9
2 changed files with 23 additions and 22 deletions

View File

@ -386,6 +386,12 @@ private:
void charInserted();
/// set 'number' font property
void number(LCursor & cur);
/// paste string at current cursor.
/// \param str string to paste
/// \param argument method for parsing ("paragraph" is special)
void pasteString(LCursor & cur, docstring const & str,
docstring const & argument);
};
} // namespace lyx

View File

@ -860,31 +860,13 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
break;
}
case LFUN_CLIPBOARD_PASTE: {
cur.clearSelection();
docstring const clip = theClipboard().get();
if (!clip.empty()) {
recordUndo(cur);
if (cmd.argument() == "paragraph")
insertStringAsParagraphs(cur, clip);
else
insertStringAsLines(cur, clip);
}
case LFUN_CLIPBOARD_PASTE:
pasteString(cur, theClipboard().get(), cmd.argument());
break;
}
case LFUN_PRIMARY_SELECTION_PASTE: {
cur.clearSelection();
docstring const clip = theSelection().get();
if (!clip.empty()) {
recordUndo(cur);
if (cmd.argument() == "paragraph")
insertStringAsParagraphs(cur, clip);
else
insertStringAsLines(cur, clip);
}
case LFUN_PRIMARY_SELECTION_PASTE:
pasteString(cur, theSelection().get(), cmd.argument());
break;
}
case LFUN_UNICODE_INSERT: {
if (cmd.argument().empty())
@ -1879,4 +1861,17 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
}
void LyXText::pasteString(LCursor & cur, docstring const & clip,
docstring const & argument)
{
cur.clearSelection();
if (!clip.empty()) {
recordUndo(cur);
if (argument == "paragraph")
insertStringAsParagraphs(cur, clip);
else
insertStringAsLines(cur, clip);
}
}
} // namespace lyx