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-02-16 11:58:51 +00:00
|
|
|
|
// This is the rewrite of the tabular (table) support.
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
|
|
// Ideally the tabular support should do as the mathed and use
|
|
|
|
|
// LaTeX in the .lyx file too.
|
|
|
|
|
|
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
|
|
|
|
|
// kind of an inset. At least get the code out of the kernel.
|
|
|
|
|
// - colortbl -multirow
|
|
|
|
|
// - hhline -multicolumn
|
|
|
|
|
// - dcolumn
|
|
|
|
|
// 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 Painter;
|
|
|
|
|
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;
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
|
|
class InsetTabular : public UpdatableInset {
|
|
|
|
|
public:
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
InsetTabular(Buffer const &, int rows = 1, int columns = 1);
|
|
|
|
|
///
|
2003-06-03 15:10:14 +00:00
|
|
|
|
InsetTabular(InsetTabular const &);
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2001-04-04 09:42:56 +00:00
|
|
|
|
~InsetTabular();
|
|
|
|
|
///
|
2003-07-25 17:11:25 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> clone() const;
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
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
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const editMessage() const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-01-14 17:21:39 +00:00
|
|
|
|
bool insetAllowed(InsetOld::Code) const { return true; }
|
2001-07-09 14:19:41 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool isTextInset() 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
|
|
|
|
///
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int plaintext(Buffer const &, std::ostream &,
|
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &,
|
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
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code lyxCode() const { return InsetOld::TABULAR_CODE; }
|
2003-11-10 09:06:48 +00:00
|
|
|
|
/// get the absolute screen x,y of the cursor
|
2004-01-30 11:41:12 +00:00
|
|
|
|
void getCursorPos(CursorSlice const & cur, 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;
|
2003-09-18 20:18:39 +00:00
|
|
|
|
/// Appends \c list with all labels found within this inset.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void getLabelList(Buffer const &, std::vector<std::string> & list) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
|
/// number of cells
|
|
|
|
|
size_t nargs() const;
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
2004-02-16 11:58:51 +00:00
|
|
|
|
InsetText const & cell(int) const;
|
|
|
|
|
///
|
|
|
|
|
InsetText & cell(int);
|
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
|
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void markErased();
|
|
|
|
|
|
2002-01-08 14:24:49 +00:00
|
|
|
|
// this should return true if we have a "normal" cell, otherwise true.
|
|
|
|
|
// "normal" means without width set!
|
2004-01-26 10:13:15 +00:00
|
|
|
|
bool forceDefaultParagraphs(InsetBase const * in) 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
|
2003-10-15 08:49:44 +00:00
|
|
|
|
void buffer(Buffer * 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
|
|
|
|
///
|
2004-02-13 13:51:12 +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:
|
|
|
|
|
///
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void priv_dispatch(LCursor & cur, FuncRequest & cmd);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
///
|
|
|
|
|
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
private:
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void drawCellLines(Painter &, int x, int baseline,
|
2004-02-16 11:58:51 +00:00
|
|
|
|
int row, int cell) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-02-13 16:22:53 +00:00
|
|
|
|
void drawCellSelection(PainterInfo &, int x, int baseline,
|
2004-02-16 11:58:51 +00:00
|
|
|
|
int row, int column, int cell) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2004-02-13 16:22:53 +00:00
|
|
|
|
InsetBase * setPos(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
|
|
|
|
///
|
2001-04-04 09:42:56 +00:00
|
|
|
|
int getCellXPos(int cell) const;
|
|
|
|
|
///
|
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-01-20 14:25:24 +00:00
|
|
|
|
bool isRightToLeft(LCursor & cur);
|
2001-05-28 15:11:24 +00:00
|
|
|
|
///
|
2004-02-13 16:22:53 +00:00
|
|
|
|
void getSelection(LCursor & cur,
|
|
|
|
|
int & rs, int & re, int & cs, int & ce) const;
|
2001-07-17 15:39:12 +00:00
|
|
|
|
///
|
2004-01-15 17:34:44 +00:00
|
|
|
|
bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
|
2004-02-13 16:22:53 +00:00
|
|
|
|
/// are we operating on several cells?
|
|
|
|
|
bool tablemode(LCursor & cur) const;
|
|
|
|
|
|
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
|
|
|
|
///
|
2003-07-18 16:23:17 +00:00
|
|
|
|
mutable int cursorx_;
|
|
|
|
|
///
|
2001-04-04 09:42:56 +00:00
|
|
|
|
mutable int first_visible_cell;
|
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;
|
2003-03-09 18:11:57 +00:00
|
|
|
|
/// Returns the active cell if successful, else -1.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static int 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
|