4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Lars Gullik Bjønnes
9 * \author Alfredo Braunstein
11 * Full author contact details are available in file CREDITS.
17 #include "DocumentClassPtr.h"
19 #include "support/docstring.h"
21 #include "frontends/Clipboard.h"
25 using lyx::frontend::Clipboard;
37 /// Get all elements of the cut buffer in plain text format.
38 std::vector<docstring> availableSelections(Buffer const *);
39 /// Get the number of available elements in the cut buffer.
40 size_type numberOfSelections();
41 /// Get the sel_index-th element of the cut buffer in plain text format.
42 docstring selection(size_t sel_index);
45 * Replace using the font of the first selected character and select
46 * the new string. Does handle undo.
48 void replaceSelectionWithString(Cursor & cur, docstring const & str);
49 /// If a selection exists, delete it without pushing it to the cut buffer.
51 void replaceSelection(Cursor & cur);
54 * Cut the current selection and possibly push it to the cut buffer and
56 * Does handle undo. Calls saveSelection.
57 * \param doclear If this is true: Delete leading spaces in paragraphs before
59 * \param realcut If this is true: Push the selection to the cut buffer and
60 * system clipboard. Set this to false to only delete the
63 void cutSelection(Cursor & cur, bool doclear = true, bool realcut = true);
64 /// Push the current selection to the cut buffer and the system clipboard.
65 void copySelection(Cursor const & cur);
67 void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext);
69 * Push the current selection to the cut buffer and the system clipboard.
70 * \param plaintext plain text version of the selection for the system
73 void copySelection(Cursor const & cur, docstring const & plaintext);
74 /// Push the selection buffer to the cut buffer.
75 void copySelectionToStack();
76 /// Store the current selection in the internal selection buffer
77 void saveSelection(Cursor const & cur);
78 /// Is a selection available in our selection buffer?
80 /// Clear our selection buffer
81 void clearSelection();
82 /// Clear our cut stack.
84 /// Paste the current selection at \p cur
85 /// Does handle undo. Does only work in text, not mathed.
86 void pasteSelection(Cursor & cur, ErrorList &);
87 /// Replace the current selection with the clipboard contents as text
88 /// (internal or external: which is newer).
89 /// Does handle undo. Does only work in text, not mathed.
90 /// \p asParagraphs is only considered if plain text is pasted.
91 void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
92 Clipboard::TextType preferedType = Clipboard::LyXOrPlainTextType);
93 /// Replace the current selection with the clipboard contents as graphic.
94 /// Does handle undo. Does only work in text, not mathed.
95 void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
96 Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
97 /// Replace the current selection with cut buffer \c sel_index
98 /// Does handle undo. Does only work in text, not mathed.
99 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
100 /// Paste the clipboard as simple text, removing any formatting
101 void pasteSimpleText(Cursor & cur, bool asParagraphs);
103 /// Paste the paragraph list \p parlist at the position given by \p cur.
104 /// Does not handle undo. Does only work in text, not mathed.
105 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
106 DocumentClassConstPtr textclass, ErrorList & errorList);
109 /** Needed to switch between different classes. This works
110 * for a list of paragraphs beginning with the specified par.
111 * It changes layouts and character styles.
113 void switchBetweenClasses(DocumentClassConstPtr c1,
114 DocumentClassConstPtr c2, InsetText & in, ErrorList &);
116 /// Get the current selection as a string. Does not change the selection.
117 /// Does only work if the whole selection is in mathed.
118 docstring grabSelection(Cursor const & cur);
119 /// Erase the current selection.
120 /// Does not handle undo. Does only work if the whole selection is in mathed.
121 /// Calls saveSelection.
122 void eraseSelection(Cursor & cur);
123 /// Reduce the selected text in mathed to only one cell. If it spans multiple
124 /// cells, the cursor is moved the end of the current cell and the anchor to the
125 /// start. If the selection is inside only one cell, nothing is done. Return
126 /// true if the selection now does not span multiple cells anymore.
127 bool reduceSelectionToOneCell(Cursor & cur);
128 /// Returns true if multiple cells are selected in mathed.
129 bool multipleCellsSelected(Cursor const & cur);
130 /// Erase the selection and return it as a string.
131 /// Does not handle undo. Does only work if the whole selection is in mathed.
132 docstring grabAndEraseSelection(Cursor & cur);
133 // other selection methods
134 /// Erase the selection if one exists.
135 /// Does not handle undo. Does only work if the whole selection is in mathed.
136 void selDel(Cursor & cur);
137 /// Clear or delete the selection if one exists, depending on lyxrc setting.
138 /// Does not handle undo. Does only work if the whole selection is in mathed.
139 void selClearOrDel(Cursor & cur);
140 /// Calculate rectangular region of cell between \c i1 and \c i2.
141 void region(CursorSlice const & i1, CursorSlice const & i2,
142 Inset::row_type & r1, Inset::row_type & r2,
143 Inset::col_type & c1, Inset::col_type & c2);
144 /** Tabular has its own paste stack for multiple cells
145 * but it needs to know whether there is a more recent
146 * ordinary paste. Therefore which one is newer.
148 //FIXME: this is a workaround for bug 1919. Replace this by
149 //an all-for-one-paste mechanism in 1.7
150 /// store whether tabular or ordinary paste stack is newer
151 void dirtyTabularStack(bool b);
152 /// is the tabular paste stack newer than the ordinary one?
153 bool tabularStackDirty();