#include "BufferView.h"
#include "Changes.h"
#include "Cursor.h"
+#include "Encoding.h"
#include "ErrorList.h"
#include "FuncCode.h"
#include "FuncRequest.h"
buffer->paragraphs() = paragraphs;
buffer->inset().setBuffer(*buffer);
buffer->params().setDocumentClass(docclass);
- ostringstream lyx;
- if (buffer->write(lyx))
- theClipboard().put(lyx.str(), plaintext);
- else
- theClipboard().put(string(), plaintext);
+ string lyx;
+ ostringstream oslyx;
+ if (buffer->write(oslyx))
+ lyx = oslyx.str();
+ odocstringstream oshtml;
+ OutputParams runparams(encodings.fromLyXName("utf8"));
+ buffer->writeLyXHTMLSource(oshtml, runparams, Buffer::FullSource);
+ theClipboard().put(lyx, oshtml.str(), plaintext);
// Save that memory
buffer->paragraphs().clear();
}
virtual docstring const getAsText() const = 0;
/// Get the contents of the window system clipboard as graphics file.
virtual FileName getAsGraphics(Cursor const & cur, GraphicsType type) const = 0;
-
+
/**
* Fill the system clipboard. The format of \p lyx is as written in
* .lyx files, the format of \p text is plain text.
* This should be called when the user requests to cut or copy to
* the clipboard.
*/
- virtual void put(std::string const & lyx, docstring const & text) = 0;
+ virtual void put(std::string const & lyx, docstring const & html, docstring const & text) = 0;
/// Does the clipboard contain LyX contents?
virtual bool hasLyXContents() const = 0;
return FileName();
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(mime);
- LYXERR(Debug::ACTION, "Getting from clipboard: mime = " << mime.data()
+ LYXERR(Debug::ACTION, "Getting from clipboard: mime = " << mime.constData()
<< "length = " << ar.count());
-
+
QFile f(toqstr(filename.absFileName()));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
LYXERR(Debug::ACTION, "Error opening file "
}
-void GuiClipboard::put(string const & lyx, docstring const & text)
+void GuiClipboard::put(string const & lyx, docstring const & html, docstring const & text)
{
LYXERR(Debug::ACTION, "GuiClipboard::put(`" << lyx << "' `"
- << to_utf8(text) << "')");
+ << to_utf8(html) << "' `" << to_utf8(text) << "')");
// We don't convert the encoding of lyx since the encoding of the
// clipboard contents is specified in the data itself
QMimeData * data = new QMimeData;
// clipboard.
QString const qtext = toqstr(text);
data->setText(qtext);
+ QString const qhtml = toqstr(html);
+ data->setHtml(qhtml);
qApp->clipboard()->setMimeData(data, QClipboard::Clipboard);
}
LYXERR(Debug::ACTION, "Qt Clipboard changed. We found the following mime types:");
for (int i = 0; i < l.count(); i++)
LYXERR(Debug::ACTION, l.value(i));
-
+
text_clipboard_empty_ = qApp->clipboard()->
text(QClipboard::Clipboard).isEmpty();
std::string const getAsLyX() const;
FileName getAsGraphics(Cursor const & cur, GraphicsType type) const;
docstring const getAsText() const;
- void put(std::string const & lyx, docstring const & text);
+ void put(std::string const & lyx, docstring const & html, docstring const & text);
bool hasLyXContents() const;
bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const;
bool hasTextContents() const;