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
This commit is contained in:
Vincent van Ravesteijn 2009-01-04 23:31:32 +00:00
parent a05cc2c93e
commit 89034a543b
4 changed files with 13 additions and 1 deletions

View 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"));

View 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.

View 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) {

View 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;