2000-04-10 14:29:05 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
/**
|
|
|
|
* \file CutAndPaste.h
|
2003-05-06 09:34:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
|
|
|
* \author Lars Gullik Bjønnes
|
2003-06-28 01:23:11 +00:00
|
|
|
* \author Alfredo Braunstein
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-05-06 09:34:56 +00:00
|
|
|
*/
|
2000-04-10 14:29:05 +00:00
|
|
|
|
|
|
|
#ifndef CUTANDPASTE_H
|
|
|
|
#define CUTANDPASTE_H
|
|
|
|
|
2012-03-13 16:13:31 +00:00
|
|
|
#include "DocumentClassPtr.h"
|
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2008-02-03 10:43:03 +00:00
|
|
|
#include "frontends/Clipboard.h"
|
|
|
|
|
2003-06-17 15:33:49 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2008-02-03 10:43:03 +00:00
|
|
|
using lyx::frontend::Clipboard;
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2008-02-28 01:42:02 +00:00
|
|
|
class DocumentClass;
|
2003-05-20 16:51:31 +00:00
|
|
|
class ErrorList;
|
2006-05-21 17:33:03 +00:00
|
|
|
class InsetText;
|
2008-02-24 14:59:23 +00:00
|
|
|
class Cursor;
|
2007-04-26 08:30:11 +00:00
|
|
|
class ParagraphList;
|
2000-04-10 14:29:05 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
namespace cap {
|
2003-06-17 15:33:49 +00:00
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Get all elements of the cut buffer in plain text format.
|
2008-07-30 09:09:23 +00:00
|
|
|
std::vector<docstring> availableSelections(Buffer const *);
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Get the number of available elements in the cut buffer.
|
2006-10-21 00:16:43 +00:00
|
|
|
size_type numberOfSelections();
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Get the sel_index-th element of the cut buffer in plain text format.
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring selection(size_t sel_index);
|
2003-06-17 15:33:49 +00:00
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
/**
|
|
|
|
* Replace using the font of the first selected character and select
|
2012-04-18 10:44:31 +00:00
|
|
|
* the new string. Does handle undo.
|
2004-03-25 09:16:36 +00:00
|
|
|
*/
|
2012-04-18 10:44:31 +00:00
|
|
|
void replaceSelectionWithString(Cursor & cur, docstring const & str);
|
2007-02-08 10:40:46 +00:00
|
|
|
/// If a selection exists, delete it without pushing it to the cut buffer.
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Does handle undo.
|
2007-04-26 14:56:30 +00:00
|
|
|
void replaceSelection(Cursor & cur);
|
2003-05-06 09:34:56 +00:00
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
/**
|
|
|
|
* Cut the current selection and possibly push it to the cut buffer and
|
|
|
|
* system clipboard.
|
2007-07-10 12:48:04 +00:00
|
|
|
* Does handle undo. Calls saveSelection.
|
2007-01-04 16:50:03 +00:00
|
|
|
* \param doclear If this is true: Delete leading spaces in paragraphs before
|
|
|
|
* they get merged.
|
|
|
|
* \param realcut If this is true: Push the selection to the cut buffer and
|
2007-02-08 10:40:46 +00:00
|
|
|
* system clipboard. Set this to false to only delete the
|
2007-05-28 22:27:45 +00:00
|
|
|
* selection.
|
2007-01-04 16:50:03 +00:00
|
|
|
*/
|
2007-04-26 14:56:30 +00:00
|
|
|
void cutSelection(Cursor & cur, bool doclear = true, bool realcut = true);
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Push the current selection to the cut buffer and the system clipboard.
|
2008-08-13 13:46:19 +00:00
|
|
|
void copySelection(Cursor const & cur);
|
2008-11-16 19:19:07 +00:00
|
|
|
///
|
|
|
|
void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext);
|
2007-01-13 18:29:50 +00:00
|
|
|
/**
|
|
|
|
* Push the current selection to the cut buffer and the system clipboard.
|
|
|
|
* \param plaintext plain text version of the selection for the system
|
|
|
|
* clipboard
|
|
|
|
*/
|
2008-08-13 13:46:19 +00:00
|
|
|
void copySelection(Cursor const & cur, docstring const & plaintext);
|
2007-02-02 03:10:15 +00:00
|
|
|
/// Push the selection buffer to the cut buffer.
|
|
|
|
void copySelectionToStack();
|
|
|
|
/// Store the current selection in the internal selection buffer
|
2008-08-13 13:46:19 +00:00
|
|
|
void saveSelection(Cursor const & cur);
|
2007-02-02 03:10:15 +00:00
|
|
|
/// Is a selection available in our selection buffer?
|
|
|
|
bool selection();
|
|
|
|
/// Clear our selection buffer
|
|
|
|
void clearSelection();
|
2007-09-15 17:24:08 +00:00
|
|
|
/// Clear our cut stack.
|
|
|
|
void clearCutStack();
|
2007-02-02 03:10:15 +00:00
|
|
|
/// Paste the current selection at \p cur
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
void pasteSelection(Cursor & cur, ErrorList &);
|
2008-02-03 10:43:03 +00:00
|
|
|
/// Replace the current selection with the clipboard contents as text
|
|
|
|
/// (internal or external: which is newer).
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2013-04-14 17:45:36 +00:00
|
|
|
/// \p asParagraphs is only considered if plain text is pasted.
|
2013-07-13 08:29:54 +00:00
|
|
|
bool pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
|
2013-04-14 17:45:36 +00:00
|
|
|
Clipboard::TextType preferedType = Clipboard::LyXOrPlainTextType);
|
2008-02-03 10:43:03 +00:00
|
|
|
/// Replace the current selection with the clipboard contents as graphic.
|
2007-01-13 18:29:50 +00:00
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2008-02-03 10:43:03 +00:00
|
|
|
void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
|
|
|
|
Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
|
2007-01-13 18:29:50 +00:00
|
|
|
/// Replace the current selection with cut buffer \c sel_index
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2013-07-13 08:29:54 +00:00
|
|
|
bool pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
|
2011-10-29 15:42:01 +00:00
|
|
|
/// Paste the clipboard as simple text, removing any formatting
|
|
|
|
void pasteSimpleText(Cursor & cur, bool asParagraphs);
|
2003-03-06 15:39:37 +00:00
|
|
|
|
2006-11-17 19:52:45 +00:00
|
|
|
/// Paste the paragraph list \p parlist at the position given by \p cur.
|
|
|
|
/// Does not handle undo. Does only work in text, not mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
2012-03-13 16:13:31 +00:00
|
|
|
DocumentClassConstPtr textclass, ErrorList & errorList);
|
2005-11-29 15:08:35 +00:00
|
|
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
/** Needed to switch between different classes. This works
|
2005-05-04 11:21:14 +00:00
|
|
|
* for a list of paragraphs beginning with the specified par.
|
|
|
|
* It changes layouts and character styles.
|
2004-10-05 10:11:42 +00:00
|
|
|
*/
|
2012-03-13 16:13:31 +00:00
|
|
|
void switchBetweenClasses(DocumentClassConstPtr c1,
|
|
|
|
DocumentClassConstPtr c2, InsetText & in, ErrorList &);
|
2003-03-06 15:39:37 +00:00
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Get the current selection as a string. Does not change the selection.
|
|
|
|
/// Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
docstring grabSelection(Cursor const & cur);
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Erase the current selection.
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-07-10 12:48:04 +00:00
|
|
|
/// Calls saveSelection.
|
2007-04-26 14:56:30 +00:00
|
|
|
void eraseSelection(Cursor & cur);
|
2008-03-12 00:18:39 +00:00
|
|
|
/// Reduce the selected text in mathed to only one cell. If it spans multiple
|
|
|
|
/// cells, the cursor is moved the end of the current cell and the anchor to the
|
|
|
|
/// start. If the selection is inside only one cell, nothing is done. Return
|
|
|
|
/// true if the selection now does not span multiple cells anymore.
|
|
|
|
bool reduceSelectionToOneCell(Cursor & cur);
|
2008-03-12 00:59:29 +00:00
|
|
|
/// Returns true if multiple cells are selected in mathed.
|
|
|
|
bool multipleCellsSelected(Cursor const & cur);
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Erase the selection and return it as a string.
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
docstring grabAndEraseSelection(Cursor & cur);
|
2004-04-18 07:32:34 +00:00
|
|
|
// other selection methods
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Erase the selection if one exists.
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
void selDel(Cursor & cur);
|
2007-01-04 16:50:03 +00:00
|
|
|
/// Clear or delete the selection if one exists, depending on lyxrc setting.
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
void selClearOrDel(Cursor & cur);
|
2008-03-12 00:19:31 +00:00
|
|
|
/// Calculate rectangular region of cell between \c i1 and \c i2.
|
|
|
|
void region(CursorSlice const & i1, CursorSlice const & i2,
|
|
|
|
Inset::row_type & r1, Inset::row_type & r2,
|
|
|
|
Inset::col_type & c1, Inset::col_type & c2);
|
2005-09-06 17:39:39 +00:00
|
|
|
/** Tabular has its own paste stack for multiple cells
|
2006-04-05 23:56:29 +00:00
|
|
|
* but it needs to know whether there is a more recent
|
2005-09-06 17:39:39 +00:00
|
|
|
* ordinary paste. Therefore which one is newer.
|
|
|
|
*/
|
|
|
|
//FIXME: this is a workaround for bug 1919. Replace this by
|
2008-03-12 00:19:18 +00:00
|
|
|
//an all-for-one-paste mechanism in 1.7
|
2005-09-06 17:39:39 +00:00
|
|
|
/// store whether tabular or ordinary paste stack is newer
|
|
|
|
void dirtyTabularStack(bool b);
|
|
|
|
/// is the tabular paste stack newer than the ordinary one?
|
|
|
|
bool tabularStackDirty();
|
2004-03-25 09:16:36 +00:00
|
|
|
} // namespace cap
|
|
|
|
} // namespce lyx
|
2000-04-10 14:29:05 +00:00
|
|
|
|
|
|
|
#endif
|