2000-04-19 14:42:19 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetTabular.h
|
2002-09-25 14:26:13 +00:00
|
|
|
* 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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2007-04-26 12:54:21 +00:00
|
|
|
* \author Matthias Ettrich
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
|
|
|
* \author Jü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
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
#ifndef INSET_TABULAR_H
|
|
|
|
#define INSET_TABULAR_H
|
2000-04-19 14:42:19 +00:00
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
#include "Inset.h"
|
2007-04-26 12:54:21 +00:00
|
|
|
#include "InsetText.h"
|
2007-09-20 20:44:08 +00:00
|
|
|
#include "Layout.h"
|
|
|
|
#include "Length.h"
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <vector>
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
2004-01-08 18:30:14 +00:00
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
class Buffer;
|
2008-03-21 17:45:14 +00:00
|
|
|
class BufferView;
|
2008-03-15 12:22:28 +00:00
|
|
|
class CompletionList;
|
2004-01-08 18:30:14 +00:00
|
|
|
class CursorSlice;
|
2008-03-21 17:45:14 +00:00
|
|
|
class InsetTableCell;
|
|
|
|
class FuncStatus;
|
|
|
|
class Lexer;
|
|
|
|
class Paragraph;
|
2004-01-08 18:30:14 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace frontend { class Painter; }
|
2000-04-19 14:42:19 +00:00
|
|
|
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
class InsetTabular;
|
2007-04-26 14:56:30 +00:00
|
|
|
class Cursor;
|
2007-04-26 12:54:21 +00:00
|
|
|
class OutputParams;
|
|
|
|
|
|
|
|
//
|
|
|
|
// A helper struct for tables
|
2007-05-28 22:27:45 +00:00
|
|
|
//
|
2007-10-06 09:19:53 +00:00
|
|
|
class Tabular {
|
2007-04-26 12:54:21 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
enum Feature {
|
|
|
|
///
|
|
|
|
APPEND_ROW = 0,
|
|
|
|
///
|
|
|
|
APPEND_COLUMN,
|
|
|
|
///
|
|
|
|
DELETE_ROW,
|
|
|
|
///
|
|
|
|
DELETE_COLUMN,
|
|
|
|
///
|
|
|
|
COPY_ROW,
|
|
|
|
///
|
|
|
|
COPY_COLUMN,
|
|
|
|
///
|
|
|
|
TOGGLE_LINE_TOP,
|
|
|
|
///
|
|
|
|
TOGGLE_LINE_BOTTOM,
|
|
|
|
///
|
|
|
|
TOGGLE_LINE_LEFT,
|
|
|
|
///
|
|
|
|
TOGGLE_LINE_RIGHT,
|
|
|
|
///
|
|
|
|
ALIGN_LEFT,
|
|
|
|
///
|
|
|
|
ALIGN_RIGHT,
|
|
|
|
///
|
|
|
|
ALIGN_CENTER,
|
|
|
|
///
|
|
|
|
ALIGN_BLOCK,
|
|
|
|
///
|
|
|
|
VALIGN_TOP,
|
|
|
|
///
|
|
|
|
VALIGN_BOTTOM,
|
|
|
|
///
|
|
|
|
VALIGN_MIDDLE,
|
|
|
|
///
|
|
|
|
M_ALIGN_LEFT,
|
|
|
|
///
|
|
|
|
M_ALIGN_RIGHT,
|
|
|
|
///
|
|
|
|
M_ALIGN_CENTER,
|
|
|
|
///
|
|
|
|
M_VALIGN_TOP,
|
|
|
|
///
|
|
|
|
M_VALIGN_BOTTOM,
|
|
|
|
///
|
|
|
|
M_VALIGN_MIDDLE,
|
|
|
|
///
|
|
|
|
MULTICOLUMN,
|
|
|
|
///
|
|
|
|
SET_ALL_LINES,
|
|
|
|
///
|
|
|
|
UNSET_ALL_LINES,
|
|
|
|
///
|
|
|
|
SET_LONGTABULAR,
|
|
|
|
///
|
|
|
|
UNSET_LONGTABULAR,
|
|
|
|
///
|
|
|
|
SET_PWIDTH,
|
|
|
|
///
|
|
|
|
SET_MPWIDTH,
|
|
|
|
///
|
|
|
|
SET_ROTATE_TABULAR,
|
|
|
|
///
|
|
|
|
UNSET_ROTATE_TABULAR,
|
|
|
|
///
|
2007-05-12 20:59:21 +00:00
|
|
|
TOGGLE_ROTATE_TABULAR,
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
SET_ROTATE_CELL,
|
|
|
|
///
|
|
|
|
UNSET_ROTATE_CELL,
|
|
|
|
///
|
2007-05-12 20:59:21 +00:00
|
|
|
TOGGLE_ROTATE_CELL,
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
SET_USEBOX,
|
|
|
|
///
|
|
|
|
SET_LTHEAD,
|
|
|
|
UNSET_LTHEAD,
|
|
|
|
///
|
|
|
|
SET_LTFIRSTHEAD,
|
|
|
|
UNSET_LTFIRSTHEAD,
|
|
|
|
///
|
|
|
|
SET_LTFOOT,
|
|
|
|
UNSET_LTFOOT,
|
|
|
|
///
|
|
|
|
SET_LTLASTFOOT,
|
|
|
|
UNSET_LTLASTFOOT,
|
|
|
|
///
|
|
|
|
SET_LTNEWPAGE,
|
|
|
|
///
|
2008-05-04 07:51:50 +00:00
|
|
|
TOGGLE_LTCAPTION,
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
SET_SPECIAL_COLUMN,
|
|
|
|
///
|
|
|
|
SET_SPECIAL_MULTI,
|
|
|
|
///
|
|
|
|
SET_BOOKTABS,
|
|
|
|
///
|
|
|
|
UNSET_BOOKTABS,
|
|
|
|
///
|
|
|
|
SET_TOP_SPACE,
|
|
|
|
///
|
|
|
|
SET_BOTTOM_SPACE,
|
|
|
|
///
|
|
|
|
SET_INTERLINE_SPACE,
|
|
|
|
///
|
2008-03-20 08:45:40 +00:00
|
|
|
SET_BORDER_LINES,
|
|
|
|
///
|
2009-01-03 18:33:09 +00:00
|
|
|
TABULAR_VALIGN_TOP,
|
|
|
|
///
|
|
|
|
TABULAR_VALIGN_MIDDLE,
|
|
|
|
///
|
|
|
|
TABULAR_VALIGN_BOTTOM,
|
|
|
|
///
|
2009-07-11 13:09:45 +00:00
|
|
|
LONGTABULAR_ALIGN_LEFT,
|
|
|
|
///
|
|
|
|
LONGTABULAR_ALIGN_CENTER,
|
|
|
|
///
|
|
|
|
LONGTABULAR_ALIGN_RIGHT,
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
LAST_ACTION
|
|
|
|
};
|
|
|
|
///
|
|
|
|
enum {
|
|
|
|
///
|
|
|
|
CELL_NORMAL = 0,
|
|
|
|
///
|
|
|
|
CELL_BEGIN_OF_MULTICOLUMN,
|
|
|
|
///
|
|
|
|
CELL_PART_OF_MULTICOLUMN
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
enum VAlignment {
|
|
|
|
///
|
|
|
|
LYX_VALIGN_TOP = 0,
|
|
|
|
///
|
2009-07-11 14:33:05 +00:00
|
|
|
LYX_VALIGN_MIDDLE = 1,
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2009-07-11 14:33:05 +00:00
|
|
|
LYX_VALIGN_BOTTOM = 2
|
|
|
|
|
2007-04-26 12:54:21 +00:00
|
|
|
};
|
2009-07-11 13:09:45 +00:00
|
|
|
///
|
|
|
|
enum HAlignment {
|
|
|
|
///
|
|
|
|
LYX_LONGTABULAR_ALIGN_LEFT = 0,
|
|
|
|
///
|
|
|
|
LYX_LONGTABULAR_ALIGN_CENTER = 1,
|
|
|
|
///
|
|
|
|
LYX_LONGTABULAR_ALIGN_RIGHT = 2
|
|
|
|
};
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
enum BoxType {
|
|
|
|
///
|
|
|
|
BOX_NONE = 0,
|
|
|
|
///
|
|
|
|
BOX_PARBOX = 1,
|
|
|
|
///
|
|
|
|
BOX_MINIPAGE = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
class ltType {
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
ltType();
|
|
|
|
// we have this header type (is set in the getLT... functions)
|
|
|
|
bool set;
|
|
|
|
// double borders on top
|
|
|
|
bool topDL;
|
|
|
|
// double borders on bottom
|
|
|
|
bool bottomDL;
|
|
|
|
// used for FirstHeader & LastFooter and if this is true
|
|
|
|
// all the rows marked as FirstHeader or LastFooter are
|
|
|
|
// ignored in the output and it is set to be empty!
|
|
|
|
bool empty;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// type for row numbers
|
|
|
|
typedef size_t row_type;
|
|
|
|
/// type for column numbers
|
|
|
|
typedef size_t col_type;
|
|
|
|
/// type for cell indices
|
|
|
|
typedef size_t idx_type;
|
|
|
|
/// index indicating an invalid position
|
|
|
|
static const idx_type npos = static_cast<idx_type>(-1);
|
|
|
|
|
|
|
|
/// constructor
|
2008-07-23 12:13:41 +00:00
|
|
|
Tabular(Buffer &, col_type columns_arg, row_type rows_arg);
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
/// Returns true if there is a topline, returns false if not
|
2008-03-18 18:08:32 +00:00
|
|
|
bool topLine(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Returns true if there is a topline, returns false if not
|
2008-03-18 18:08:32 +00:00
|
|
|
bool bottomLine(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Returns true if there is a topline, returns false if not
|
2008-03-18 18:08:32 +00:00
|
|
|
bool leftLine(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Returns true if there is a topline, returns false if not
|
2008-03-18 18:08:32 +00:00
|
|
|
bool rightLine(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
bool topAlreadyDrawn(idx_type cell) const;
|
|
|
|
///
|
|
|
|
bool leftAlreadyDrawn(idx_type cell) const;
|
|
|
|
///
|
|
|
|
bool isLastRow(idx_type cell) const;
|
|
|
|
|
|
|
|
/// return space occupied by the second horizontal line and
|
|
|
|
/// interline space above row \p row in pixels
|
|
|
|
int getAdditionalHeight(row_type row) const;
|
|
|
|
///
|
|
|
|
int getAdditionalWidth(idx_type cell) const;
|
|
|
|
|
|
|
|
/* returns the maximum over all rows */
|
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int columnWidth(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int width() const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int height() const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int rowAscent(row_type row) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int rowDescent(row_type row) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
void setRowAscent(row_type row, int height);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
void setRowDescent(row_type row, int height);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
void setCellWidth(idx_type cell, int new_width);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
void setAllLines(idx_type cell, bool line);
|
|
|
|
///
|
2008-03-18 18:08:32 +00:00
|
|
|
void setTopLine(idx_type cell, bool line);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-18 18:08:32 +00:00
|
|
|
void setBottomLine(idx_type cell, bool line);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-18 18:08:32 +00:00
|
|
|
void setLeftLine(idx_type cell, bool line);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-18 18:08:32 +00:00
|
|
|
void setRightLine(idx_type cell, bool line);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-18 18:08:32 +00:00
|
|
|
bool rowTopLine(row_type row) const;
|
|
|
|
///
|
|
|
|
bool rowBottomLine(row_type row) const;
|
|
|
|
///
|
|
|
|
bool columnLeftLine(col_type column) const;
|
|
|
|
///
|
|
|
|
bool columnRightLine(col_type column) const;
|
|
|
|
|
2007-04-26 12:54:21 +00:00
|
|
|
void setAlignment(idx_type cell, LyXAlignment align,
|
|
|
|
bool onlycolumn = false);
|
|
|
|
///
|
|
|
|
void setVAlignment(idx_type cell, VAlignment align,
|
|
|
|
bool onlycolumn = false);
|
|
|
|
///
|
2007-04-28 12:58:49 +00:00
|
|
|
void setColumnPWidth(Cursor &, idx_type, Length const &);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-04-28 12:58:49 +00:00
|
|
|
bool setMColumnPWidth(Cursor &, idx_type, Length const &);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
void setAlignSpecial(idx_type cell, docstring const & special,
|
|
|
|
Feature what);
|
|
|
|
///
|
|
|
|
LyXAlignment getAlignment(idx_type cell,
|
|
|
|
bool onlycolumn = false) const;
|
|
|
|
///
|
|
|
|
VAlignment getVAlignment(idx_type cell,
|
|
|
|
bool onlycolumn = false) const;
|
|
|
|
///
|
2007-04-28 12:58:49 +00:00
|
|
|
Length const getPWidth(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int cellWidth(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
int getBeginningOfTextInCell(idx_type cell) const;
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void appendRow(idx_type cell);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
void deleteRow(row_type row);
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void copyRow(row_type);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void appendColumn(idx_type cell);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
void deleteColumn(col_type column);
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void copyColumn(col_type);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
bool isFirstCellInRow(idx_type cell) const;
|
|
|
|
///
|
|
|
|
idx_type getFirstCellInRow(row_type row) const;
|
|
|
|
///
|
|
|
|
bool isLastCellInRow(idx_type cell) const;
|
|
|
|
///
|
|
|
|
idx_type getLastCellInRow(row_type row) const;
|
|
|
|
///
|
|
|
|
idx_type numberOfCellsInRow(idx_type cell) const;
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream &) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void read(Lexer &);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int latex(odocstream &, OutputParams const &) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
//
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream & os, OutputParams const &) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void plaintext(odocstream &,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const & runparams, int const depth,
|
2007-11-01 16:59:40 +00:00
|
|
|
bool onlydata, char_type delim) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
bool isMultiColumn(idx_type cell) const;
|
|
|
|
///
|
|
|
|
bool isMultiColumnReal(idx_type cell) const;
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void setMultiColumn(idx_type cell, idx_type number);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
|
|
|
|
///
|
|
|
|
bool isPartOfMultiColumn(row_type row, col_type column) const;
|
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
row_type cellRow(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
col_type cellColumn(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
col_type cellRightColumn(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
void setRotateCell(idx_type cell, bool);
|
|
|
|
///
|
|
|
|
bool getRotateCell(idx_type cell) const;
|
|
|
|
///
|
|
|
|
bool needRotating() const;
|
|
|
|
///
|
|
|
|
bool isLastCell(idx_type cell) const;
|
|
|
|
///
|
2008-03-25 13:32:38 +00:00
|
|
|
idx_type cellAbove(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-25 13:32:38 +00:00
|
|
|
idx_type cellBelow(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
idx_type cellIndex(row_type row, col_type column) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
void setUsebox(idx_type cell, BoxType);
|
|
|
|
///
|
|
|
|
BoxType getUsebox(idx_type cell) const;
|
|
|
|
//
|
|
|
|
// Long Tabular Options support functions
|
|
|
|
///
|
|
|
|
bool checkLTType(row_type row, ltType const &) const;
|
|
|
|
///
|
|
|
|
void setLTHead(row_type row, bool flag, ltType const &, bool first);
|
|
|
|
///
|
|
|
|
bool getRowOfLTHead(row_type row, ltType &) const;
|
|
|
|
///
|
|
|
|
bool getRowOfLTFirstHead(row_type row, ltType &) const;
|
|
|
|
///
|
|
|
|
void setLTFoot(row_type row, bool flag, ltType const &, bool last);
|
|
|
|
///
|
|
|
|
bool getRowOfLTFoot(row_type row, ltType &) const;
|
|
|
|
///
|
|
|
|
bool getRowOfLTLastFoot(row_type row, ltType &) const;
|
|
|
|
///
|
|
|
|
void setLTNewPage(row_type row, bool what);
|
|
|
|
///
|
|
|
|
bool getLTNewPage(row_type row) const;
|
|
|
|
///
|
2008-05-04 07:51:50 +00:00
|
|
|
idx_type setLTCaption(row_type row, bool what);
|
|
|
|
///
|
|
|
|
bool ltCaption(row_type row) const;
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
bool haveLTHead() const;
|
|
|
|
///
|
|
|
|
bool haveLTFirstHead() const;
|
|
|
|
///
|
|
|
|
bool haveLTFoot() const;
|
|
|
|
///
|
|
|
|
bool haveLTLastFoot() const;
|
|
|
|
///
|
2009-02-10 18:08:09 +00:00
|
|
|
bool haveLTCaption() const;
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
// end longtable support
|
|
|
|
///
|
2008-03-25 13:32:38 +00:00
|
|
|
boost::shared_ptr<InsetTableCell> cellInset(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-25 13:32:38 +00:00
|
|
|
boost::shared_ptr<InsetTableCell> cellInset(row_type row,
|
2007-04-26 12:54:21 +00:00
|
|
|
col_type column) const;
|
|
|
|
///
|
|
|
|
void setCellInset(row_type row, col_type column,
|
2008-03-21 06:16:05 +00:00
|
|
|
boost::shared_ptr<InsetTableCell>) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Search for \param inset in the tabular, with the
|
|
|
|
///
|
|
|
|
void validate(LaTeXFeatures &) const;
|
|
|
|
//private:
|
2008-07-16 14:28:26 +00:00
|
|
|
// FIXME Now that cells have an InsetTableCell as their insets, rather
|
|
|
|
// than an InsetText, it'd be possible to reverse the relationship here,
|
|
|
|
// so that cell_vector was a vector<InsetTableCell> rather than a
|
|
|
|
// vector<CellData>, and an InsetTableCell had a CellData as a member,
|
|
|
|
// or perhaps just had its members as members.
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
class CellData {
|
2007-04-26 12:54:21 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-07-23 12:13:41 +00:00
|
|
|
CellData(Buffer &);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
CellData(CellData const &);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
CellData & operator=(CellData);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
void swap(CellData & rhs);
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
idx_type cellno;
|
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int width;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
int multicolumn;
|
|
|
|
///
|
|
|
|
LyXAlignment alignment;
|
|
|
|
///
|
|
|
|
VAlignment valignment;
|
|
|
|
///
|
|
|
|
bool top_line;
|
|
|
|
///
|
|
|
|
bool bottom_line;
|
|
|
|
///
|
|
|
|
bool left_line;
|
|
|
|
///
|
|
|
|
bool right_line;
|
|
|
|
///
|
|
|
|
BoxType usebox;
|
|
|
|
///
|
|
|
|
bool rotate;
|
|
|
|
///
|
|
|
|
docstring align_special;
|
|
|
|
///
|
2007-04-28 12:58:49 +00:00
|
|
|
Length p_width; // this is only set for multicolumn!!!
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-21 06:16:05 +00:00
|
|
|
boost::shared_ptr<InsetTableCell> inset;
|
2007-04-26 12:54:21 +00:00
|
|
|
};
|
2008-03-25 13:32:38 +00:00
|
|
|
CellData & cellInfo(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
typedef std::vector<CellData> cell_vector;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
typedef std::vector<cell_vector> cell_vvector;
|
|
|
|
|
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
class RowData {
|
2007-04-26 12:54:21 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
RowData();
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int ascent;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int descent;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Extra space between the top line and this row
|
2007-04-28 12:58:49 +00:00
|
|
|
Length top_space;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Ignore top_space if true and use the default top space
|
|
|
|
bool top_space_default;
|
|
|
|
/// Extra space between this row and the bottom line
|
2007-04-28 12:58:49 +00:00
|
|
|
Length bottom_space;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Ignore bottom_space if true and use the default bottom space
|
|
|
|
bool bottom_space_default;
|
|
|
|
/// Extra space between the bottom line and the next top line
|
2007-04-28 12:58:49 +00:00
|
|
|
Length interline_space;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// Ignore interline_space if true and use the default interline space
|
|
|
|
bool interline_space_default;
|
|
|
|
/// This are for longtabulars only
|
|
|
|
/// a row of endhead
|
|
|
|
bool endhead;
|
|
|
|
/// a row of endfirsthead
|
|
|
|
bool endfirsthead;
|
|
|
|
/// a row of endfoot
|
|
|
|
bool endfoot;
|
|
|
|
/// row of endlastfoot
|
|
|
|
bool endlastfoot;
|
2007-11-23 02:10:00 +00:00
|
|
|
/// row for a newpage
|
2007-04-26 12:54:21 +00:00
|
|
|
bool newpage;
|
2008-05-04 07:51:50 +00:00
|
|
|
/// caption
|
|
|
|
bool caption;
|
2007-04-26 12:54:21 +00:00
|
|
|
};
|
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
typedef std::vector<RowData> row_vector;
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
class ColumnData {
|
2007-04-26 12:54:21 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
ColumnData();
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
LyXAlignment alignment;
|
|
|
|
///
|
|
|
|
VAlignment valignment;
|
|
|
|
///
|
2007-09-04 10:52:08 +00:00
|
|
|
int width;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2007-04-28 12:58:49 +00:00
|
|
|
Length p_width;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
docstring align_special;
|
|
|
|
};
|
|
|
|
///
|
2008-02-27 20:59:44 +00:00
|
|
|
typedef std::vector<ColumnData> column_vector;
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
idx_type numberofcells;
|
|
|
|
///
|
|
|
|
std::vector<row_type> rowofcell;
|
|
|
|
///
|
|
|
|
std::vector<col_type> columnofcell;
|
|
|
|
///
|
|
|
|
row_vector row_info;
|
|
|
|
///
|
|
|
|
column_vector column_info;
|
|
|
|
///
|
|
|
|
mutable cell_vvector cell_info;
|
|
|
|
///
|
|
|
|
bool use_booktabs;
|
|
|
|
///
|
|
|
|
bool rotate;
|
2009-01-03 18:33:09 +00:00
|
|
|
///
|
|
|
|
VAlignment tabular_valignment;
|
2007-04-26 12:54:21 +00:00
|
|
|
//
|
|
|
|
// for long tabulars
|
2009-07-11 13:09:45 +00:00
|
|
|
///
|
|
|
|
HAlignment longtabular_alignment;
|
2007-04-26 12:54:21 +00:00
|
|
|
//
|
|
|
|
bool is_long_tabular;
|
|
|
|
/// endhead data
|
|
|
|
ltType endhead;
|
|
|
|
/// endfirsthead data
|
|
|
|
ltType endfirsthead;
|
|
|
|
/// endfoot data
|
|
|
|
ltType endfoot;
|
|
|
|
/// endlastfoot data
|
|
|
|
ltType endlastfoot;
|
|
|
|
|
|
|
|
///
|
2008-07-23 12:13:41 +00:00
|
|
|
void init(Buffer &, row_type rows_arg,
|
2007-04-26 12:54:21 +00:00
|
|
|
col_type columns_arg);
|
|
|
|
///
|
2007-09-04 18:13:19 +00:00
|
|
|
void updateIndexes();
|
2008-07-21 02:07:54 +00:00
|
|
|
///
|
|
|
|
bool setFixedWidth(row_type r, col_type c);
|
2008-09-15 08:09:52 +00:00
|
|
|
///
|
|
|
|
void updateContentAlignment(row_type r, col_type c);
|
2008-03-24 14:03:00 +00:00
|
|
|
/// return true of update is needed
|
|
|
|
bool updateColumnWidths();
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-18 18:08:32 +00:00
|
|
|
idx_type columnSpan(idx_type cell) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
BoxType useParbox(idx_type cell) const;
|
|
|
|
///
|
|
|
|
// helper function for Latex returns number of newlines
|
|
|
|
///
|
2008-09-26 21:24:59 +00:00
|
|
|
int TeXTopHLine(odocstream &, row_type row, std::string const lang) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-09-26 21:24:59 +00:00
|
|
|
int TeXBottomHLine(odocstream &, row_type row, std::string const lang) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-25 20:48:48 +00:00
|
|
|
int TeXCellPreamble(odocstream &, idx_type cell, bool & ismulticol) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-03-25 20:48:48 +00:00
|
|
|
int TeXCellPostamble(odocstream &, idx_type cell, bool ismulticol) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int TeXLongtableHeaderFooter(odocstream &, OutputParams const &) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
bool isValidRow(row_type const row) const;
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int TeXRow(odocstream &, row_type const row,
|
2007-04-26 12:54:21 +00:00
|
|
|
OutputParams const &) const;
|
|
|
|
///
|
|
|
|
// helper functions for plain text
|
|
|
|
///
|
|
|
|
bool plaintextTopHLine(odocstream &, row_type row,
|
2007-05-28 22:27:45 +00:00
|
|
|
std::vector<unsigned int> const &) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
|
|
|
bool plaintextBottomHLine(odocstream &, row_type row,
|
2007-05-28 22:27:45 +00:00
|
|
|
std::vector<unsigned int> const &) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void plaintextPrintCell(odocstream &,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const &,
|
|
|
|
idx_type cell, row_type row, col_type column,
|
|
|
|
std::vector<unsigned int> const &,
|
|
|
|
bool onlydata) const;
|
2007-04-26 12:54:21 +00:00
|
|
|
/// auxiliary function for docbook
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbookRow(odocstream & os, row_type, OutputParams const &) const;
|
|
|
|
|
|
|
|
/// change associated Buffer
|
2008-07-23 12:13:41 +00:00
|
|
|
void setBuffer(Buffer & buffer);
|
2008-02-27 20:43:16 +00:00
|
|
|
/// retrieve associated Buffer
|
2008-07-23 12:13:41 +00:00
|
|
|
Buffer & buffer() const { return *buffer_; }
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
private:
|
2008-07-23 12:13:41 +00:00
|
|
|
Buffer * buffer_;
|
2008-02-27 20:43:16 +00:00
|
|
|
|
2008-03-21 17:45:14 +00:00
|
|
|
}; // Tabular
|
|
|
|
|
2007-04-26 12:54:21 +00:00
|
|
|
|
2008-03-21 17:45:14 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
class InsetTableCell : public InsetText
|
|
|
|
{
|
2008-03-21 17:45:14 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-07-23 12:13:41 +00:00
|
|
|
InsetTableCell(Buffer & buf);
|
2008-03-21 17:45:14 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCode lyxCode() const { return CELL_CODE; }
|
2008-03-21 17:45:14 +00:00
|
|
|
///
|
|
|
|
Inset * clone() { return new InsetTableCell(*this); }
|
|
|
|
///
|
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd,
|
|
|
|
FuncStatus & status) const;
|
|
|
|
///
|
2008-07-16 14:23:32 +00:00
|
|
|
void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
|
2008-09-13 10:10:01 +00:00
|
|
|
///
|
|
|
|
void setContentAlignment(LyXAlignment al) {contentAlign = al; }
|
2008-08-08 21:26:18 +00:00
|
|
|
/// writes the contents of the cell as a string, optionally
|
|
|
|
/// descending into insets
|
|
|
|
docstring asString(bool intoInsets = true);
|
2008-03-21 17:45:14 +00:00
|
|
|
private:
|
|
|
|
/// unimplemented
|
|
|
|
InsetTableCell();
|
|
|
|
/// unimplemented
|
|
|
|
void operator=(InsetTableCell const &);
|
2008-07-21 02:07:54 +00:00
|
|
|
// FIXME
|
|
|
|
// This boolean is supposed to track whether the cell has had its
|
|
|
|
// width explicitly set. We need to know this to determine whether
|
|
|
|
// layout changes and paragraph customization are allowed---that is,
|
|
|
|
// we need it in forcePlainLayout() and allowParagraphCustomization().
|
|
|
|
// Unfortunately, that information is not readily available in
|
|
|
|
// InsetTableCell. In the case of multicolumn cells, it is present
|
|
|
|
// in CellData, and so would be available here if CellData were to
|
|
|
|
// become a member of InsetTableCell. But in the other case, it isn't
|
|
|
|
// even available there, but is held in Tabular::ColumnData.
|
|
|
|
// So, the present solution uses this boolean to track the information
|
|
|
|
// we need to track, and tries to keep it updated. This is not ideal,
|
|
|
|
// but the other solutions are no better. These are:
|
|
|
|
// (i) Keep a pointer in InsetTableCell to the table;
|
|
|
|
// (ii) Find the table by iterating over the Buffer's insets.
|
|
|
|
// Solution (i) raises the problem of updating the pointer when an
|
|
|
|
// InsetTableCell is copied, and we'd therefore need a copy constructor
|
|
|
|
// in InsetTabular and then in Tabular, which seems messy, given how
|
|
|
|
// complicated those classes are. Solution (ii) involves a lot of
|
|
|
|
// iterating, since this information is needed quite often, and so may
|
|
|
|
// be quite slow.
|
|
|
|
// So, well, if someone can do better, please do!
|
|
|
|
// --rgh
|
2008-07-16 14:23:32 +00:00
|
|
|
///
|
|
|
|
bool isFixedWidth;
|
2008-09-13 10:10:01 +00:00
|
|
|
// FIXME: Here the thoughts from the comment above also apply.
|
|
|
|
///
|
|
|
|
LyXAlignment contentAlign;
|
2008-07-22 14:31:16 +00:00
|
|
|
/// should paragraph indendation be omitted in any case?
|
|
|
|
bool neverIndent() const { return true; }
|
|
|
|
///
|
2008-09-13 10:10:01 +00:00
|
|
|
LyXAlignment contentAlignment() const { return contentAlign; }
|
|
|
|
///
|
2008-07-22 14:31:16 +00:00
|
|
|
virtual bool usePlainLayout() const { return true; }
|
|
|
|
///
|
|
|
|
virtual bool forcePlainLayout(idx_type = 0) const;
|
|
|
|
///
|
|
|
|
virtual bool allowParagraphCustomization(idx_type = 0) const;
|
2008-07-22 16:13:59 +00:00
|
|
|
/// Is the width forced to some value?
|
|
|
|
bool hasFixedWidth() const { return isFixedWidth; }
|
2008-03-21 17:45:14 +00:00
|
|
|
};
|
2007-04-26 12:54:21 +00:00
|
|
|
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
class InsetTabular : public Inset
|
|
|
|
{
|
2000-04-19 14:42:19 +00:00
|
|
|
public:
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2008-07-23 12:13:41 +00:00
|
|
|
InsetTabular(Buffer &, 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();
|
2008-07-23 13:25:03 +00:00
|
|
|
///
|
|
|
|
void setBuffer(Buffer & buffer);
|
|
|
|
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
static void string2params(std::string const &, InsetTabular &);
|
|
|
|
///
|
|
|
|
static std::string params2string(InsetTabular const &);
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void read(Lexer &);
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-09-21 20:39:47 +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;
|
|
|
|
///
|
2009-04-22 20:55:13 +00:00
|
|
|
bool editable() const { return true; }
|
|
|
|
///
|
|
|
|
bool hasSettings() const { return true; }
|
2005-07-15 22:10:25 +00:00
|
|
|
///
|
2007-12-21 20:42:46 +00:00
|
|
|
bool insetAllowed(InsetCode code) const;
|
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
|
|
|
///
|
2009-07-11 13:09:45 +00:00
|
|
|
DisplayType display() const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int latex(odocstream &, OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int plaintext(odocstream &, OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream &, 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
|
|
|
///
|
2007-10-13 09:04:52 +00:00
|
|
|
InsetCode lyxCode() const { return TABULAR_CODE; }
|
2008-03-28 18:50:33 +00:00
|
|
|
///
|
|
|
|
docstring contextMenu(BufferView const & bv, int x, int y) const;
|
2004-11-30 01:59:49 +00:00
|
|
|
/// get offset of this cursor slice relative to our upper left corner
|
2006-10-17 16:23:27 +00:00
|
|
|
void cursorPos(BufferView const & bv, CursorSlice const & sl,
|
|
|
|
bool boundary, int & x, int & y) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool tabularFeatures(Cursor & cur, std::string const & what);
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void tabularFeatures(Cursor & cur, Tabular::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
|
2008-04-21 13:33:39 +00:00
|
|
|
size_t nargs() const { return tabular.numberofcells; }
|
2001-04-27 14:03:25 +00:00
|
|
|
///
|
2008-03-21 06:16:05 +00:00
|
|
|
boost::shared_ptr<InsetTableCell const> cell(idx_type) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
///
|
2008-03-21 06:16:05 +00:00
|
|
|
boost::shared_ptr<InsetTableCell> cell(idx_type);
|
2003-11-01 09:56:18 +00:00
|
|
|
///
|
2007-04-29 23:33:02 +00:00
|
|
|
Text * getText(int) const;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
2006-10-20 09:29:19 +00:00
|
|
|
/// set the change for the entire inset
|
|
|
|
void setChange(Change const & change);
|
2006-10-24 06:11:45 +00:00
|
|
|
/// accept the changes within the inset
|
2009-07-16 08:37:32 +00:00
|
|
|
void acceptChanges();
|
2006-10-24 21:38:47 +00:00
|
|
|
/// reject the changes within the inset
|
2009-07-16 08:37:32 +00:00
|
|
|
void rejectChanges();
|
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?
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
virtual bool allowParagraphCustomization(idx_type cell = 0) const;
|
|
|
|
///
|
2008-07-10 17:41:52 +00:00
|
|
|
virtual bool forcePlainLayout(idx_type cell = 0) const;
|
2008-03-19 16:21:33 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void addPreview(graphics::PreviewLoader &) const;
|
2002-08-02 16:39:43 +00:00
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
/// lock cell with given index
|
2008-02-11 08:20:13 +00:00
|
|
|
void edit(Cursor & cur, bool front, EntryDirection entry_from);
|
2008-03-18 18:08:32 +00:00
|
|
|
/// get table row from x coordinate
|
|
|
|
int rowFromY(Cursor & cur, int y) const;
|
|
|
|
/// get table column from y coordinate
|
|
|
|
int columnFromX(Cursor & cur, int x) const;
|
2003-11-04 12:36:59 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset * editXY(Cursor & cur, int x, int y);
|
2003-11-17 12:53:44 +00:00
|
|
|
/// can we go further down on mouse click?
|
2009-10-26 22:21:07 +00:00
|
|
|
bool descendable(BufferView const &) const { return true; }
|
2007-08-12 21:43:58 +00:00
|
|
|
// Update the counters of this inset and of its contents
|
2008-02-27 20:43:16 +00:00
|
|
|
void updateLabels(ParIterator const &);
|
2003-12-10 09:45:32 +00:00
|
|
|
|
2008-03-15 12:22:28 +00:00
|
|
|
///
|
|
|
|
bool completionSupported(Cursor const &) const;
|
|
|
|
///
|
|
|
|
bool inlineCompletionSupported(Cursor const & cur) const;
|
|
|
|
///
|
|
|
|
bool automaticInlineCompletion() const;
|
|
|
|
///
|
|
|
|
bool automaticPopupCompletion() const;
|
|
|
|
///
|
2008-03-16 17:07:10 +00:00
|
|
|
bool showCompletionCursor() const;
|
|
|
|
///
|
2008-03-15 12:22:28 +00:00
|
|
|
CompletionList const * createCompletionList(Cursor const & cur) const;
|
|
|
|
///
|
|
|
|
docstring completionPrefix(Cursor const & cur) const;
|
|
|
|
///
|
|
|
|
bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
|
|
|
|
///
|
|
|
|
void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
|
2008-08-08 16:19:28 +00:00
|
|
|
///
|
|
|
|
virtual bool usePlainLayout() const { return true; }
|
2008-03-15 12:22:28 +00:00
|
|
|
|
2008-04-11 12:02:10 +00:00
|
|
|
///
|
|
|
|
virtual InsetTabular * asInsetTabular() { return this; }
|
|
|
|
///
|
|
|
|
virtual InsetTabular const * asInsetTabular() const { return this; }
|
|
|
|
///
|
|
|
|
bool isRightToLeft(Cursor & cur) const;
|
2008-08-08 21:26:18 +00:00
|
|
|
/// writes the cells between stidx and enidx as a string, optionally
|
|
|
|
/// descending into the insets
|
|
|
|
docstring asString(idx_type stidx, idx_type enidx, bool intoInsets = true);
|
2008-04-11 12:02:10 +00:00
|
|
|
|
2008-10-25 10:47:38 +00:00
|
|
|
/// Returns whether the cell in the specified row and column is selected.
|
|
|
|
bool isCellSelected(Cursor & cur, row_type row, col_type col) const;
|
2003-12-10 09:45:32 +00:00
|
|
|
//
|
|
|
|
// Public structures and variables
|
|
|
|
///
|
2007-04-26 12:54:21 +00:00
|
|
|
mutable Tabular tabular;
|
2003-12-10 09:45:32 +00:00
|
|
|
|
2008-03-05 00:21:05 +00:00
|
|
|
private:
|
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
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2004-03-18 13:57:20 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
2005-07-17 01:13:36 +00:00
|
|
|
///
|
|
|
|
int scroll() const { return scx_; }
|
2008-03-05 00:21:05 +00:00
|
|
|
///
|
|
|
|
Inset * clone() const { return new InsetTabular(*this); }
|
2004-11-23 23:04:52 +00:00
|
|
|
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void drawCellLines(frontend::Painter &, int x, int y, row_type row,
|
2009-02-09 21:14:23 +00:00
|
|
|
idx_type cell, Change const & change) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
|
2003-12-15 15:33:15 +00:00
|
|
|
|
|
|
|
///
|
2008-04-11 12:02:10 +00:00
|
|
|
void moveNextCell(Cursor & cur,
|
|
|
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
|
2003-12-15 15:33:15 +00:00
|
|
|
///
|
2008-04-11 12:02:10 +00:00
|
|
|
void movePrevCell(Cursor & cur,
|
|
|
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
|
2001-07-24 22:08:49 +00:00
|
|
|
///
|
2008-03-25 13:32:38 +00:00
|
|
|
int cellXPos(idx_type cell) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void resetPos(Cursor & 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
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool copySelection(Cursor & cur);
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool pasteClipboard(Cursor & cur);
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void cutSelection(Cursor & cur);
|
2001-04-04 09:42:56 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void getSelection(Cursor & 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
|
|
|
///
|
2007-01-15 22:49:14 +00:00
|
|
|
bool insertPlaintextString(BufferView &, docstring const & buf, bool usePaste);
|
2004-02-13 16:22:53 +00:00
|
|
|
|
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
|
|
|
|
2007-05-12 20:59:21 +00:00
|
|
|
/// test the rotation state of the give cell range.
|
|
|
|
bool oneCellHasRotationState(bool rotated,
|
2007-05-28 22:27:45 +00:00
|
|
|
row_type row_start, row_type row_end,
|
2007-05-12 20:59:21 +00:00
|
|
|
col_type col_start, col_type col_end) const;
|
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_;
|
2008-03-25 21:26:03 +00:00
|
|
|
/// true when selecting rows with the mouse
|
|
|
|
bool rowselect_;
|
|
|
|
/// true when selecting columns with the mouse
|
|
|
|
bool colselect_;
|
2000-04-19 14:42:19 +00:00
|
|
|
};
|
2003-03-09 18:11:57 +00:00
|
|
|
|
2007-04-26 12:54:21 +00:00
|
|
|
std::string const featureAsString(Tabular::Feature feature);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
#endif // INSET_TABULAR_H
|