2006-06-20 08:39:16 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-08-31 22:16:11 +00:00
|
|
|
* \file GuiClipboard.h
|
2006-06-20 08:39:16 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author unknown
|
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#ifndef GUICLIPBOARD_H
|
|
|
|
#define GUICLIPBOARD_H
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
|
|
#include "frontends/Clipboard.h"
|
|
|
|
|
2010-10-23 00:21:58 +00:00
|
|
|
#include <QMimeData>
|
2007-09-30 20:28:15 +00:00
|
|
|
#include <QObject>
|
2010-10-23 00:21:58 +00:00
|
|
|
#include <QStringList>
|
2007-09-30 20:28:15 +00:00
|
|
|
|
2010-12-11 23:04:24 +00:00
|
|
|
#include <boost/cstdint.hpp>
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2008-05-23 07:52:39 +00:00
|
|
|
class QMacPasteboardMimeGraphics;
|
|
|
|
|
2010-10-23 00:21:58 +00:00
|
|
|
/**
|
|
|
|
* \class CacheMimeData
|
|
|
|
*
|
|
|
|
* This class is used in order to query the clipboard only once on
|
|
|
|
* startup and once each time the contents of the clipboard changes.
|
|
|
|
*/
|
|
|
|
class CacheMimeData : public QMimeData
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
// LyX calls "on_dataChanged" on startup, so it is not necessary to
|
|
|
|
// query the clipboard here.
|
|
|
|
CacheMimeData()
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// reads the clipboard and updates the cached_formats_
|
|
|
|
void update();
|
|
|
|
/// returns the cached list of formats supported by the object
|
|
|
|
virtual QStringList formats() const { return cached_formats_; }
|
|
|
|
/// reads the clipboard and returns the data
|
|
|
|
QByteArray data(QString const & mimeType) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// the cached list of formats supported by the object
|
|
|
|
QStringList cached_formats_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
/**
|
|
|
|
* The Qt4 version of the Clipboard.
|
|
|
|
*/
|
2007-09-30 20:28:15 +00:00
|
|
|
class GuiClipboard: public QObject, public Clipboard
|
2006-06-20 08:39:16 +00:00
|
|
|
{
|
2007-09-30 20:28:15 +00:00
|
|
|
Q_OBJECT
|
2006-06-20 08:39:16 +00:00
|
|
|
public:
|
2007-09-30 20:28:15 +00:00
|
|
|
GuiClipboard();
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2006-07-08 13:27:43 +00:00
|
|
|
/** Clipboard overloaded methods
|
2006-06-20 08:39:16 +00:00
|
|
|
*/
|
|
|
|
//@{
|
2007-01-13 18:29:50 +00:00
|
|
|
std::string const getAsLyX() const;
|
2008-02-03 10:43:03 +00:00
|
|
|
FileName getAsGraphics(Cursor const & cur, GraphicsType type) const;
|
2007-01-13 18:29:50 +00:00
|
|
|
docstring const getAsText() const;
|
2013-04-12 20:12:47 +00:00
|
|
|
void put(std::string const & lyx, docstring const & html, docstring const & text);
|
2007-01-13 18:29:50 +00:00
|
|
|
bool hasLyXContents() const;
|
2008-02-03 10:43:03 +00:00
|
|
|
bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const;
|
2009-01-04 23:31:32 +00:00
|
|
|
bool hasTextContents() const;
|
2007-01-03 08:53:54 +00:00
|
|
|
bool isInternal() const;
|
2007-12-28 15:56:05 +00:00
|
|
|
bool hasInternal() const;
|
2007-01-07 16:43:38 +00:00
|
|
|
bool empty() const;
|
2006-06-20 08:39:16 +00:00
|
|
|
//@}
|
2007-09-30 20:28:15 +00:00
|
|
|
|
2008-02-03 10:43:03 +00:00
|
|
|
FileName getPastedGraphicsFileName(Cursor const & cur,
|
|
|
|
Clipboard::GraphicsType & type) const;
|
|
|
|
|
2007-09-30 20:28:15 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void on_dataChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool text_clipboard_empty_;
|
|
|
|
bool has_lyx_contents_;
|
2008-02-03 10:43:03 +00:00
|
|
|
bool has_graphics_contents_;
|
2010-10-23 00:21:58 +00:00
|
|
|
/// the cached mime data used to describe the information
|
|
|
|
/// that can be stored in the clipboard
|
|
|
|
CacheMimeData cache_;
|
2010-12-11 23:04:24 +00:00
|
|
|
/// checksum for internal clipboard data (used on Mac)
|
|
|
|
boost::uint32_t checksum;
|
2006-06-20 08:39:16 +00:00
|
|
|
};
|
|
|
|
|
2008-05-25 07:49:16 +00:00
|
|
|
QString const lyxMimeType();
|
|
|
|
QString const pdfMimeType();
|
|
|
|
QString const emfMimeType();
|
|
|
|
QString const wmfMimeType();
|
2008-05-25 07:22:45 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#endif // GUICLIPBOARD_H
|