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