From 7f77edbeacbfdbb33fa175ebb20d5dd9773671f2 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 5 Jan 2009 14:29:40 +0000 Subject: [PATCH] branch: Fix bug http://bugzilla.lyx.org/show_bug.cgi?id=5560. Allow users to paste text from e.g. MS Word. This text can be paste from clipboard both as text and as graphics. LyX should prefer to paste it as text. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@27996 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text3.cpp | 3 ++- src/frontends/Clipboard.h | 2 ++ src/frontends/qt4/GuiClipboard.cpp | 8 ++++++++ src/frontends/qt4/GuiClipboard.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index 44d394cd5b..335977403e 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -998,7 +998,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (arg.empty()) { if (theClipboard().isInternal()) pasteFromStack(cur, bv->buffer().errorList("Paste"), 0); - else if (theClipboard().hasGraphicsContents()) + else if (theClipboard().hasGraphicsContents() + && !theClipboard().hasTextContents()) pasteClipboardGraphics(cur, bv->buffer().errorList("Paste")); else pasteClipboardText(cur, bv->buffer().errorList("Paste")); diff --git a/src/frontends/Clipboard.h b/src/frontends/Clipboard.h index cdbe98b9a6..7235b01013 100644 --- a/src/frontends/Clipboard.h +++ b/src/frontends/Clipboard.h @@ -69,6 +69,8 @@ public: /// Does the clipboard contain LyX contents? virtual bool hasLyXContents() const = 0; + /// Does the clipboard contain text contents? + virtual bool hasTextContents() const = 0; /// Does the clipboard contain graphics contents of a certain type? virtual bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const = 0; /// state of clipboard. diff --git a/src/frontends/qt4/GuiClipboard.cpp b/src/frontends/qt4/GuiClipboard.cpp index dcef9a4b26..03fb6312aa 100644 --- a/src/frontends/qt4/GuiClipboard.cpp +++ b/src/frontends/qt4/GuiClipboard.cpp @@ -342,6 +342,14 @@ bool GuiClipboard::hasLyXContents() const } +bool GuiClipboard::hasTextContents() const +{ + QMimeData const * const source = + qApp->clipboard()->mimeData(QClipboard::Clipboard); + return source && source->hasText(); +} + + bool GuiClipboard::hasGraphicsContents(Clipboard::GraphicsType type) const { if (type == AnyGraphicsType) { diff --git a/src/frontends/qt4/GuiClipboard.h b/src/frontends/qt4/GuiClipboard.h index 40fa01e386..d0552a8281 100644 --- a/src/frontends/qt4/GuiClipboard.h +++ b/src/frontends/qt4/GuiClipboard.h @@ -41,6 +41,7 @@ public: void put(std::string const & lyx, docstring const & text); bool hasLyXContents() const; bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const; + bool hasTextContents() const; bool isInternal() const; bool hasInternal() const; bool empty() const;