]> git.lyx.org Git - lyx.git/commitdiff
Factorise external pasting code.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 3 Jan 2007 07:30:50 +0000 (07:30 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 3 Jan 2007 07:30:50 +0000 (07:30 +0000)
* 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
src/text3.C

index feb0b273ff1ceb2e10074984e29461e772862bf6..34de73838076aec414968608bdf4e9f946e54c24 100644 (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
index 4450e3048f00a3679a9c9dc25a4aa17e8de10838..f8d42d02d14578db9bf4ef4042f670664e83bf86 100644 (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