]> git.lyx.org Git - features.git/commitdiff
Fix bug http://bugzilla.lyx.org/show_bug.cgi?id=5560.
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 4 Jan 2009 23:31:32 +0000 (23:31 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 4 Jan 2009 23:31:32 +0000 (23:31 +0000)
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/trunk@27988 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text3.cpp
src/frontends/Clipboard.h
src/frontends/qt4/GuiClipboard.cpp
src/frontends/qt4/GuiClipboard.h

index 1cba2af9de3330707ddeec30fa0da9758d2ddcb2..24e6b5e19b4c51c0cce5316a6ee3a0134806f149 100644 (file)
@@ -1021,7 +1021,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"));
index cdbe98b9a6d0f92ef0434939847a10e43e081720..7235b01013cb738c2b460c4867ae1da67655773c 100644 (file)
@@ -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.
index 0979d1f7ad3a6aeb3c15fa3d968ccdc1346a9057..ed1f492858d67d9536354e0af127665e672d8797 100644 (file)
@@ -342,6 +342,14 @@ bool GuiClipboard::hasLyXContents() const
 }
 
 
+bool GuiClipboard::hasTextContents() const
+{
+       QMimeData const * const source =
+               qApp->clipboard()->mimeData(QClipboard::Clipboard);
+       return source->hasText();       
+}
+
+
 bool GuiClipboard::hasGraphicsContents(Clipboard::GraphicsType type) const
 {
        if (type == AnyGraphicsType) {
index 40fa01e3868bf87e43ef96c93c00725c46223d04..d0552a828136292e6e9aafd2ced55dc513d43f72 100644 (file)
@@ -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;