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 "support/docstring.h"
19 #include "frontends/Clipboard.h"
23 using lyx::frontend::Clipboard;
35 /// Get all elements of the cut buffer in plain text format.
36 std::vector<docstring> availableSelections(Buffer const *);
37 /// Get the number of available elements in the cut buffer.
38 size_type numberOfSelections();
39 /// Get the sel_index-th element of the cut buffer in plain text format.
40 docstring selection(size_t sel_index);
43 * Replace using the font of the first selected character and select
44 * the new string. Does handle undo.
46 void replaceSelectionWithString(Cursor & cur, docstring const & str);
47 /// If a selection exists, delete it without pushing it to the cut buffer.
49 void replaceSelection(Cursor & cur);
52 * Cut the current selection and possibly push it to the cut buffer and
54 * Does handle undo. Calls saveSelection.
55 * \param doclear If this is true: Delete leading spaces in paragraphs before
57 * \param realcut If this is true: Push the selection to the cut buffer and
58 * system clipboard. Set this to false to only delete the
61 void cutSelection(Cursor & cur, bool doclear = true, bool realcut = true);
62 /// Push the current selection to the cut buffer and the system clipboard.
63 void copySelection(Cursor const & cur);
65 void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext);
67 * Push the current selection to the cut buffer and the system clipboard.
68 * \param plaintext plain text version of the selection for the system
71 void copySelection(Cursor const & cur, docstring const & plaintext);
72 /// Push the selection buffer to the cut buffer.
73 void copySelectionToStack();
74 /// Store the current selection in the internal selection buffer
75 void saveSelection(Cursor const & cur);
76 /// Is a selection available in our selection buffer?
78 /// Clear our selection buffer
79 void clearSelection();
80 /// Clear our cut stack.
82 /// Paste the current selection at \p cur
83 /// Does handle undo. Does only work in text, not mathed.
84 void pasteSelection(Cursor & cur, ErrorList &);
85 /// Replace the current selection with the clipboard contents as text
86 /// (internal or external: which is newer).
87 /// Does handle undo. Does only work in text, not mathed.
88 void pasteClipboardText(Cursor & cur, ErrorList & errorList,
89 bool asParagraphs = true);
90 /// Replace the current selection with the clipboard contents as graphic.
91 /// Does handle undo. Does only work in text, not mathed.
92 void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
93 Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
94 /// Replace the current selection with cut buffer \c sel_index
95 /// Does handle undo. Does only work in text, not mathed.
96 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
97 /// Paste the clipboard as simple text, removing any formatting
98 void pasteSimpleText(Cursor & cur, bool asParagraphs);
100 /// Paste the paragraph list \p parlist at the position given by \p cur.
101 /// Does not handle undo. Does only work in text, not mathed.
102 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
103 DocumentClass const * const textclass, ErrorList & errorList);
106 /** Needed to switch between different classes. This works
107 * for a list of paragraphs beginning with the specified par.
108 * It changes layouts and character styles.
110 void switchBetweenClasses(DocumentClass const * const c1,
111 DocumentClass const * const c2, InsetText & in, ErrorList &);
113 /// Get the current selection as a string. Does not change the selection.
114 /// Does only work if the whole selection is in mathed.
115 docstring grabSelection(Cursor const & cur);
116 /// Erase the current selection.
117 /// Does not handle undo. Does only work if the whole selection is in mathed.
118 /// Calls saveSelection.
119 void eraseSelection(Cursor & cur);
120 /// Reduce the selected text in mathed to only one cell. If it spans multiple
121 /// cells, the cursor is moved the end of the current cell and the anchor to the
122 /// start. If the selection is inside only one cell, nothing is done. Return
123 /// true if the selection now does not span multiple cells anymore.
124 bool reduceSelectionToOneCell(Cursor & cur);
125 /// Returns true if multiple cells are selected in mathed.
126 bool multipleCellsSelected(Cursor const & cur);
127 /// Erase the selection and return it as a string.
128 /// Does not handle undo. Does only work if the whole selection is in mathed.
129 docstring grabAndEraseSelection(Cursor & cur);
130 // other selection methods
131 /// Erase the selection if one exists.
132 /// Does not handle undo. Does only work if the whole selection is in mathed.
133 void selDel(Cursor & cur);
134 /// Clear or delete the selection if one exists, depending on lyxrc setting.
135 /// Does not handle undo. Does only work if the whole selection is in mathed.
136 void selClearOrDel(Cursor & cur);
137 /// Calculate rectangular region of cell between \c i1 and \c i2.
138 void region(CursorSlice const & i1, CursorSlice const & i2,
139 Inset::row_type & r1, Inset::row_type & r2,
140 Inset::col_type & c1, Inset::col_type & c2);
141 /** Tabular has its own paste stack for multiple cells
142 * but it needs to know whether there is a more recent
143 * ordinary paste. Therefore which one is newer.
145 //FIXME: this is a workaround for bug 1919. Replace this by
146 //an all-for-one-paste mechanism in 1.7
147 /// store whether tabular or ordinary paste stack is newer
148 void dirtyTabularStack(bool b);
149 /// is the tabular paste stack newer than the ordinary one?
150 bool tabularStackDirty();