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