2000-04-19 14:42:19 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insettabular.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2000-04-19 14:42:19 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-04-19 14:42:19 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2004-10-23 09:46:33 +00:00
|
|
|
|
// This is Juergen's rewrite of the tabular (table) support.
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
2004-02-16 11:58:51 +00:00
|
|
|
|
// Things to think of when designing the new tabular support:
|
2000-04-19 14:42:19 +00:00
|
|
|
|
// - color support (colortbl, color)
|
|
|
|
|
// - decimal alignment (dcloumn)
|
|
|
|
|
// - custom lines (hhline)
|
|
|
|
|
// - rotation
|
|
|
|
|
// - multicolumn
|
|
|
|
|
// - multirow
|
|
|
|
|
// - column styles
|
|
|
|
|
|
|
|
|
|
// This is what I have written about tabular support in the LyX3-Tasks file:
|
|
|
|
|
//
|
|
|
|
|
// o rewrite of table code. Should probably be written as some
|
2004-10-23 09:46:33 +00:00
|
|
|
|
// kind of an inset. [Done]
|
2000-04-19 14:42:19 +00:00
|
|
|
|
// o enhance longtable support
|
|
|
|
|
|
|
|
|
|
// Lgb
|
|
|
|
|
|
|
|
|
|
#ifndef INSETTABULAR_H
|
|
|
|
|
#define INSETTABULAR_H
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "inset.h"
|
2000-04-21 15:16:22 +00:00
|
|
|
|
#include "tabular.h"
|
2004-01-08 18:30:14 +00:00
|
|
|
|
|
2003-09-04 01:18:42 +00:00
|
|
|
|
class FuncStatus;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
class LyXLex;
|
|
|
|
|
class BufferView;
|
|
|
|
|
class Buffer;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
class BufferParams;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
class Paragraph;
|
2004-01-08 18:30:14 +00:00
|
|
|
|
class CursorSlice;
|
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
class Painter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
2005-07-15 22:10:25 +00:00
|
|
|
|
class InsetTabular : public InsetOld {
|
2000-04-19 14:42:19 +00:00
|
|
|
|
public:
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
InsetTabular(Buffer const &, row_type rows = 1,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
col_type columns = 1);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
~InsetTabular();
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const &, LyXLex &);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-11-30 01:59:49 +00:00
|
|
|
|
void drawSelection(PainterInfo & pi, int x, int y) const;
|
|
|
|
|
///
|
2006-09-09 18:52:00 +00:00
|
|
|
|
virtual lyx::docstring const editMessage() const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2005-07-15 22:10:25 +00:00
|
|
|
|
EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
|
|
|
|
///
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool insetAllowed(InsetBase::Code) const { return true; }
|
2001-07-09 14:19:41 +00:00
|
|
|
|
///
|
2006-07-07 10:18:33 +00:00
|
|
|
|
bool allowSpellCheck() const { return true; }
|
|
|
|
|
///
|
2006-03-17 19:45:28 +00:00
|
|
|
|
bool canTrackChanges() const { return true; }
|
2002-07-23 21:03:38 +00:00
|
|
|
|
/** returns true if, when outputing LaTeX, font changes should
|
2002-12-01 22:59:25 +00:00
|
|
|
|
be closed before generating this inset. This is needed for
|
|
|
|
|
insets that may contain several paragraphs */
|
2002-07-23 21:03:38 +00:00
|
|
|
|
bool noFontChange() const { return true; }
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-06-13 07:37:48 +00:00
|
|
|
|
bool display() const { return tabular.isLongTabular(); }
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int latex(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2006-10-11 19:40:50 +00:00
|
|
|
|
int plaintext(Buffer const &, lyx::odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-11-23 23:04:52 +00:00
|
|
|
|
Code lyxCode() const { return InsetBase::TABULAR_CODE; }
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/// get offset of this cursor slice relative to our upper left corner
|
2005-07-15 15:49:40 +00:00
|
|
|
|
void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-01-20 14:25:24 +00:00
|
|
|
|
bool tabularFeatures(LCursor & cur, std::string const & what);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-01-20 14:25:24 +00:00
|
|
|
|
void tabularFeatures(LCursor & cur, LyXTabular::Feature feature,
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const & val = std::string());
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void openLayoutDialog(BufferView *) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool showInsetDialog(BufferView *) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
|
/// number of cells
|
2005-07-18 12:57:08 +00:00
|
|
|
|
size_t nargs() const { return tabular.getNumberOfCells(); }
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
boost::shared_ptr<InsetText const> cell(idx_type) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
boost::shared_ptr<InsetText> cell(idx_type);
|
2003-11-01 09:56:18 +00:00
|
|
|
|
///
|
2003-10-14 13:01:49 +00:00
|
|
|
|
LyXText * getText(int) const;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2003-11-04 11:36:28 +00:00
|
|
|
|
///
|
2005-09-07 10:37:05 +00:00
|
|
|
|
void markErased(bool);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2005-11-17 08:41:56 +00:00
|
|
|
|
// this should return true if we have a "normal" cell, otherwise false.
|
2002-01-08 14:24:49 +00:00
|
|
|
|
// "normal" means without width set!
|
2005-11-17 08:41:56 +00:00
|
|
|
|
/// should all paragraphs be output with "Standard" layout?
|
|
|
|
|
bool forceDefaultParagraphs(idx_type cell = 0) const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2002-08-02 16:39:43 +00:00
|
|
|
|
///
|
2003-07-04 08:23:23 +00:00
|
|
|
|
void addPreview(lyx::graphics::PreviewLoader &) const;
|
2002-08-02 16:39:43 +00:00
|
|
|
|
|
2003-07-10 12:26:40 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
Buffer const & buffer() const;
|
2003-06-03 15:10:14 +00:00
|
|
|
|
|
|
|
|
|
/// set the owning buffer
|
2004-05-17 11:28:31 +00:00
|
|
|
|
void buffer(Buffer const * buf);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
/// lock cell with given index
|
2004-02-13 13:51:12 +00:00
|
|
|
|
void edit(LCursor & cur, bool left);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
2005-07-15 00:39:44 +00:00
|
|
|
|
InsetBase * editXY(LCursor & cur, int x, int y);
|
2003-11-17 12:53:44 +00:00
|
|
|
|
/// can we go further down on mouse click?
|
|
|
|
|
bool descendable() const { return true; }
|
2003-12-10 09:45:32 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Public structures and variables
|
|
|
|
|
///
|
|
|
|
|
mutable LyXTabular tabular;
|
|
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
|
protected:
|
2005-07-15 22:10:25 +00:00
|
|
|
|
///
|
2004-11-23 23:04:52 +00:00
|
|
|
|
InsetTabular(InsetTabular const &);
|
2005-07-15 22:10:25 +00:00
|
|
|
|
///
|
2004-11-24 21:58:42 +00:00
|
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
///
|
|
|
|
|
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
2005-07-17 01:13:36 +00:00
|
|
|
|
///
|
|
|
|
|
int scroll() const { return scx_; }
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
|
private:
|
2004-11-23 23:04:52 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
|
|
|
|
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2006-06-20 08:39:16 +00:00
|
|
|
|
void drawCellLines(lyx::frontend::Painter &, int x, int y, row_type row,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
idx_type cell, bool erased) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2005-03-21 18:21:13 +00:00
|
|
|
|
void setCursorFromCoordinates(LCursor & cur, int x, int y) const;
|
2003-12-15 15:33:15 +00:00
|
|
|
|
|
|
|
|
|
///
|
2004-02-16 11:58:51 +00:00
|
|
|
|
void moveNextCell(LCursor & cur);
|
2003-12-15 15:33:15 +00:00
|
|
|
|
///
|
2004-02-16 11:58:51 +00:00
|
|
|
|
void movePrevCell(LCursor & cur);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int getCellXPos(idx_type cell) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-01-20 14:25:24 +00:00
|
|
|
|
void resetPos(LCursor & cur) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void removeTabularRow();
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
bool hasPasteBuffer() const;
|
|
|
|
|
///
|
2004-02-13 16:22:53 +00:00
|
|
|
|
bool copySelection(LCursor & cur);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-02-13 16:22:53 +00:00
|
|
|
|
bool pasteSelection(LCursor & cur);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-02-13 16:22:53 +00:00
|
|
|
|
void cutSelection(LCursor & cur);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-08-16 00:32:04 +00:00
|
|
|
|
bool isRightToLeft(LCursor & cur) const;
|
2001-05-28 15:11:24 +00:00
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void getSelection(LCursor & cur, row_type & rs, row_type & re,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
col_type & cs, col_type & ce) const;
|
2001-07-17 15:39:12 +00:00
|
|
|
|
///
|
2006-09-03 07:02:38 +00:00
|
|
|
|
bool insertAsciiString(BufferView &, lyx::docstring const & buf, bool usePaste);
|
2004-02-13 16:22:53 +00:00
|
|
|
|
/// are we operating on several cells?
|
|
|
|
|
bool tablemode(LCursor & cur) const;
|
|
|
|
|
|
2005-06-27 12:53:35 +00:00
|
|
|
|
/// return the "Manhattan distance" to nearest corner
|
2006-10-13 16:44:44 +00:00
|
|
|
|
int dist(BufferView &, idx_type cell, int x, int y) const;
|
2005-03-21 18:21:13 +00:00
|
|
|
|
/// return the cell nearest to x, y
|
2006-10-13 16:44:44 +00:00
|
|
|
|
idx_type getNearestCell(BufferView &, int x, int y) const;
|
2005-04-26 11:12:20 +00:00
|
|
|
|
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-06-03 15:10:14 +00:00
|
|
|
|
Buffer const * buffer_;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
mutable idx_type first_visible_cell;
|
2005-07-15 22:10:25 +00:00
|
|
|
|
///
|
|
|
|
|
mutable int scx_;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
};
|
2003-03-09 18:11:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsetTabularMailer : public MailInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2003-07-18 16:13:33 +00:00
|
|
|
|
InsetTabularMailer(InsetTabular const & inset);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2004-11-18 12:58:19 +00:00
|
|
|
|
///
|
|
|
|
|
static void string2params(std::string const &, InsetTabular &);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const params2string(InsetTabular const &);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const name_;
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
|
|
|
|
InsetTabular & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const featureAsString(LyXTabular::Feature feature);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
|
#endif
|