]> git.lyx.org Git - lyx.git/blob - src/frontends/Clipboard.h
* only for Mac
[lyx.git] / src / frontends / Clipboard.h
1 // -*- C++ -*-
2 /**
3  * \file Clipboard.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef BASE_CLIPBOARD_H
15 #define BASE_CLIPBOARD_H
16
17 #include "Cursor.h"
18
19 #include "support/FileName.h"
20 #include "support/strfwd.h"
21
22 using lyx::support::FileName;
23
24 namespace lyx {
25 namespace frontend {
26
27 /**
28  * A Clipboard class manages the clipboard.
29  */
30 class Clipboard
31 {
32 public:
33         virtual ~Clipboard() {}
34
35         enum GraphicsType {
36                 PdfGraphicsType,
37                 PngGraphicsType,
38                 JpegGraphicsType,
39                 LinkBackGraphicsType,
40                 AnyGraphicsType,
41         };
42
43         /**
44          * Get the system clipboard contents. The format is as written in
45          * .lyx files (may even be an older version than ours if it comes
46          * from an older LyX).
47          * Does not convert plain text to LyX if only plain text is available.
48          * This should be called when the user requests to paste from the
49          * clipboard.
50          */
51         virtual std::string const getAsLyX() const = 0;
52         /// Get the contents of the window system clipboard in plain text format.
53         virtual docstring const getAsText() const = 0;
54         /// Get the contents of the window system clipboard as graphics file.
55         virtual FileName getAsGraphics(Cursor const & cur, GraphicsType type) const = 0;
56         
57         /**
58          * Fill the system clipboard. The format of \p lyx is as written in
59          * .lyx files, the format of \p text is plain text.
60          * We put the clipboard contents in LyX format and plain text into
61          * the system clipboard if supported, so that it is useful for other
62          * applications as well as other instances of LyX.
63          * This should be called when the user requests to cut or copy to
64          * the clipboard.
65          */
66         virtual void put(std::string const & lyx, docstring const & text) = 0;
67
68         /// Does the clipboard contain LyX contents?
69         virtual bool hasLyXContents() const = 0;
70         /// Does the clipboard contain graphics contents of a certain type?
71         virtual bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const = 0;
72         /// state of clipboard.
73         /// \returns true if the system clipboard has been set within LyX
74         /// (document contents, dialogs count as external here).
75         virtual bool isInternal() const = 0;
76         /// \returns true if the OS has the concept of clipboard ownership,
77         /// which is crucial for our concept of internal clipboard.
78         virtual bool hasInternal() const = 0;
79         /// Is the clipboard empty?
80         /// \returns true if both the LyX and the plaintext versions of the
81         /// clipboard are empty, and no supported graphics format is available.
82         virtual bool empty() const = 0;
83 };
84
85 } // namespace frontend
86
87 /// Implementation is in Application.cpp
88 extern frontend::Clipboard & theClipboard();
89
90 } // namespace lyx
91
92
93 #endif // BASE_CLIPBOARD_H