}
-void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index)
+bool pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index)
{
// this does not make sense, if there is nothing to paste
if (!checkPastePossible(sel_index))
- return;
+ return false;
cur.recordUndo();
pasteParagraphList(cur, theCuts[sel_index].first,
theCuts[sel_index].second, errorList);
+ return true;
}
-void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
+bool pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
Clipboard::TextType type)
{
// Use internal clipboard if it is the most recent one
// This overrides asParagraphs and type on purpose!
- if (theClipboard().isInternal()) {
- pasteFromStack(cur, errorList, 0);
- return;
- }
+ if (theClipboard().isInternal())
+ return pasteFromStack(cur, errorList, 0);
// First try LyX format
if ((type == Clipboard::LyXTextType ||
cur.recordUndo();
pasteParagraphList(cur, buffer.paragraphs(),
buffer.params().documentClassPtr(), errorList);
- return;
+ return true;
}
}
}
// Buffer buffer(string(), false);
Buffer buffer("", false);
buffer.setUnnamed(true);
- if (buffer.importString(names[i], text, errorList)) {
+ available = buffer.importString(names[i], text, errorList);
+ if (available)
+ available = !buffer.paragraphs().empty();
+ if (available && !buffer.paragraphs()[0].empty()) {
cur.recordUndo();
pasteParagraphList(cur, buffer.paragraphs(),
buffer.params().documentClassPtr(), errorList);
- return;
+ return true;
}
}
}
// Then try plain text
docstring const text = theClipboard().getAsText(Clipboard::PlainTextType);
if (text.empty())
- return;
+ return false;
cur.recordUndo();
if (asParagraphs)
cur.text()->insertStringAsParagraphs(cur, text, cur.current_font);
else
cur.text()->insertStringAsLines(cur, text, cur.current_font);
+ return true;
}
/// (internal or external: which is newer).
/// Does handle undo. Does only work in text, not mathed.
/// \p asParagraphs is only considered if plain text is pasted.
-void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
+bool pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
Clipboard::TextType preferedType = Clipboard::LyXOrPlainTextType);
/// Replace the current selection with the clipboard contents as graphic.
/// Does handle undo. Does only work in text, not mathed.
Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
/// Replace the current selection with cut buffer \c sel_index
/// Does handle undo. Does only work in text, not mathed.
-void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
+bool pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
/// Paste the clipboard as simple text, removing any formatting
void pasteSimpleText(Cursor & cur, bool asParagraphs);
// without argument?
string const arg = to_utf8(cmd.argument());
if (arg.empty()) {
+ bool tryGraphics = true;
if (theClipboard().isInternal())
pasteFromStack(cur, bv->buffer().errorList("Paste"), 0);
- else if (theClipboard().hasGraphicsContents()
- && !theClipboard().hasTextContents())
+ else if (theClipboard().hasTextContents()) {
+ if (pasteClipboardText(cur, bv->buffer().errorList("Paste"),
+ true, Clipboard::AnyTextType))
+ tryGraphics = false;
+ }
+ if (tryGraphics && theClipboard().hasGraphicsContents())
pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"));
- else
- pasteClipboardText(cur, bv->buffer().errorList("Paste"), true);
} else if (isStrUnsignedInt(arg)) {
// we have a numerical argument
pasteFromStack(cur, bv->buffer().errorList("Paste"),