]> git.lyx.org Git - lyx.git/blob - src/frontends/Clipboard.h
New LFUN tabular-feature (#9794)
[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/strfwd.h"
20
21 using lyx::support::FileName;
22
23 namespace lyx {
24 namespace frontend {
25
26 /**
27  * A Clipboard class manages the clipboard.
28  */
29 class Clipboard
30 {
31 public:
32         virtual ~Clipboard() {}
33
34         enum GraphicsType {
35                 PdfGraphicsType,
36                 PngGraphicsType,
37                 JpegGraphicsType,
38                 LinkBackGraphicsType,
39                 EmfGraphicsType,
40                 WmfGraphicsType,
41                 AnyGraphicsType
42         };
43
44         enum TextType {
45                 AnyTextType,
46                 LyXOrPlainTextType,
47                 PlainTextType,
48                 HtmlTextType,
49                 LaTeXTextType,
50                 LyXTextType,
51         };
52
53         /**
54          * Get the system clipboard contents. The format is as written in
55          * .lyx files (may even be an older version than ours if it comes
56          * from an older LyX).
57          * Does not convert plain text to LyX if only plain text is available.
58          * This should be called when the user requests to paste from the
59          * clipboard.
60          */
61         virtual std::string const getAsLyX() const = 0;
62         /// Get the contents of the window system clipboard in any text format except LyxTextType.
63         virtual docstring const getAsText(TextType type) const = 0;
64         /// Get the contents of the window system clipboard as graphics file.
65         virtual FileName getAsGraphics(Cursor const & cur, GraphicsType type) const = 0;
66
67         /**
68          * Fill the system clipboard. The format of \p lyx is as written in
69          * .lyx files, the format of \p text is plain text.
70          * We put the clipboard contents in LyX format and plain text into
71          * the system clipboard if supported, so that it is useful for other
72          * applications as well as other instances of LyX.
73          * This should be called when the user requests to cut or copy to
74          * the clipboard.
75          */
76         virtual void put(std::string const & lyx, docstring const & html, docstring const & text) = 0;
77
78         /// Put a general string on the system clipboard (not LyX text)
79         virtual void put(std::string const & text) const = 0;
80
81         /// Does the clipboard contain text contents?
82         virtual bool hasTextContents(TextType type = AnyTextType) const = 0;
83         /// Does the clipboard contain graphics contents of a certain type?
84         virtual bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const = 0;
85         /// state of clipboard.
86         /// \returns true if the system clipboard has been set within LyX
87         /// (document contents, dialogs count as external here).
88         virtual bool isInternal() const = 0;
89         /// \returns true if the OS has the concept of clipboard ownership,
90         /// which is crucial for our concept of internal clipboard.
91         virtual bool hasInternal() const = 0;
92         /// Is the clipboard empty?
93         /// \returns true if both the LyX and the plaintext versions of the
94         /// clipboard are empty, and no supported graphics format is available.
95         virtual bool empty() const = 0;
96 };
97
98 } // namespace frontend
99
100 /// Implementation is in Application.cpp
101 extern frontend::Clipboard & theClipboard();
102
103 } // namespace lyx
104
105
106 #endif // BASE_CLIPBOARD_H