From 61f7ebd4a9a211a301364addfc69f09db347eb12 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 3 Jan 2007 07:30:50 +0000 Subject: [PATCH] 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 --- src/lyxtext.h | 6 ++++++ src/text3.C | 39 +++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/lyxtext.h b/src/lyxtext.h index feb0b273ff..34de738380 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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 diff --git a/src/text3.C b/src/text3.C index 4450e3048f..f8d42d02d1 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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