#include "Paragraph.h"
#include "ParagraphParameters.h"
#include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TextMetrics.h"
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
-
-#include <boost/scoped_ptr.hpp>
+#include "support/unique_ptr.h"
#include <cstring>
#include <iostream>
///
-boost::scoped_ptr<Tabular> paste_tabular;
+unique_ptr<Tabular> paste_tabular;
struct TabularFeature {
{
// the SET/UNSET actions are used by the table dialog,
// the TOGGLE actions by the table toolbar buttons
+ // FIXME: these values have been hardcoded in InsetMathGrid and other
+ // math insets.
{ Tabular::APPEND_ROW, "append-row", false },
{ Tabular::APPEND_COLUMN, "append-column", false },
{ Tabular::DELETE_ROW, "delete-row", false },
{ Tabular::SET_MROFFSET, "set-mroffset", true },
{ Tabular::SET_ALL_LINES, "set-all-lines", false },
{ Tabular::UNSET_ALL_LINES, "unset-all-lines", false },
+ { Tabular::TOGGLE_LONGTABULAR, "toggle-longtabular", false },
{ Tabular::SET_LONGTABULAR, "set-longtabular", false },
{ Tabular::UNSET_LONGTABULAR, "unset-longtabular", false },
{ Tabular::SET_PWIDTH, "set-pwidth", true },
{ Tabular::UNSET_LTCAPTION, "unset-ltcaption", false },
{ Tabular::SET_SPECIAL_COLUMN, "set-special-column", true },
{ Tabular::SET_SPECIAL_MULTICOLUMN, "set-special-multicolumn", true },
+ { Tabular::TOGGLE_BOOKTABS, "toggle-booktabs", false },
{ Tabular::SET_BOOKTABS, "set-booktabs", false },
{ Tabular::UNSET_BOOKTABS, "unset-booktabs", false },
{ Tabular::SET_TOP_SPACE, "set-top-space", true },
}
-DocIterator separatorPos(InsetTableCell * cell, docstring const & align_d)
+DocIterator separatorPos(InsetTableCell const * cell, docstring const & align_d)
{
DocIterator dit = doc_iterator_begin(&(cell->buffer()), cell);
for (; dit; dit.forwardChar())
{
InsetTableCell tail = InsetTableCell(head);
DocIterator const dit = separatorPos(&head, align_d);
- hassep = dit;
+ hassep = (bool)dit;
if (hassep) {
pit_type const psize = head.paragraphs().front().size();
head.paragraphs().front().eraseChars(dit.pos(), psize, false);
idx_type const i = cellIndex(r, c);
if (columnSpan(i) == 1) {
if (getAlignment(i) == LYX_ALIGN_DECIMAL
- && cell_info[r][c].decimal_width!=0)
+ && cell_info[r][c].decimal_width != 0)
new_width = max(new_width, cellInfo(i).width
+ max_dwidth[c] - cellInfo(i).decimal_width);
else
dpoint = from_utf8(lyxrc.default_decimal_point);
} else {
cellInfo(cell).alignment = align;
- cellInset(cell).get()->setContentAlignment(align);
+ cellInset(cell)->setContentAlignment(align);
}
}
}
+int Tabular::offsetVAlignment() const
+{
+ // for top-alignment the first horizontal table line must be exactly at
+ // the position of the base line of the surrounding text line
+ // for bottom alignment, the same is for the last table line
+ int offset_valign = 0;
+ switch (tabular_valignment) {
+ case Tabular::LYX_VALIGN_BOTTOM:
+ offset_valign = rowAscent(0) - height();
+ break;
+ case Tabular::LYX_VALIGN_MIDDLE:
+ offset_valign = (- height()) / 2 + rowAscent(0);
+ break;
+ case Tabular::LYX_VALIGN_TOP:
+ offset_valign = rowAscent(0);
+ break;
+ }
+ return offset_valign;
+}
+
+
Length const Tabular::getPWidth(idx_type cell) const
{
if (isMultiColumn(cell))
}
-Tabular::CellData & Tabular::cellInfo(idx_type cell) const
+Tabular::CellData const & Tabular::cellInfo(idx_type cell) const
+{
+ return cell_info[cellRow(cell)][cellColumn(cell)];
+}
+
+
+Tabular::CellData & Tabular::cellInfo(idx_type cell)
{
return cell_info[cellRow(cell)][cellColumn(cell)];
}
// we center in multicol when no decimal point
if (column_info[c].alignment == LYX_ALIGN_DECIMAL) {
docstring const align_d = column_info[c].decimal_point;
- DocIterator const dit = separatorPos(cellInset(cell).get(), align_d);
+ DocIterator const dit = separatorPos(cellInset(cell), align_d);
ismulticol |= !dit;
}
OutputParams const & runparams) const
{
idx_type cell = cellIndex(row, 0);
- shared_ptr<InsetTableCell> inset = cellInset(cell);
+ InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front();
string const lang = par.getParLanguage(buffer().params())->lang();
}
TeXCellPreamble(os, cell, ismulticol, ismultirow);
- shared_ptr<InsetTableCell> inset = cellInset(cell);
+ InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front();
if (getAlignment(cell) == LYX_ALIGN_DECIMAL) {
// copy cell and split in 2
- InsetTableCell head = InsetTableCell(*cellInset(cell).get());
- head.setBuffer(buffer());
+ InsetTableCell head = InsetTableCell(*cellInset(cell));
+ head.setBuffer(const_cast<Buffer &>(buffer()));
DocIterator dit = cellInset(cell)->getText(0)->macrocontextPosition();
dit.pop_back();
dit.push_back(CursorSlice(head));
void Tabular::latex(otexstream & os, OutputParams const & runparams) const
{
bool const is_tabular_star = !tabular_width.zero();
- TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid,
- runparams.lastpos);
+ TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid, runparams.lastpos);
//+---------------------------------------------------------------------
//+ first the opening preamble +
os << column_info[c].align_special;
} else {
if (!column_info[c].p_width.zero()) {
+ bool decimal = false;
switch (column_info[c].alignment) {
case LYX_ALIGN_LEFT:
os << ">{\\raggedright}";
case LYX_ALIGN_BLOCK:
case LYX_ALIGN_LAYOUT:
case LYX_ALIGN_SPECIAL:
+ break;
case LYX_ALIGN_DECIMAL:
+ os << ">{\\raggedleft}";
+ decimal = true;
break;
}
+ char valign = 'p';
switch (column_info[c].valignment) {
case LYX_VALIGN_TOP:
- os << 'p';
+ // this is the default
break;
case LYX_VALIGN_MIDDLE:
- os << 'm';
+ valign = 'm';
break;
case LYX_VALIGN_BOTTOM:
- os << 'b';
+ valign = 'b';
break;
- }
- os << '{'
- << from_ascii(column_info[c].p_width.asLatexString())
- << '}';
+ }
+ os << valign;
+
+ // Fixed-width cells with alignment at decimal separator
+ // are output as two cells of half the width with the decimal
+ // separator as column sep. This effectively puts the content
+ // centered, which differs from the normal decimal sep alignment
+ // and is not ideal, but we cannot do better ATM (see #9568).
+ // FIXME: Implement proper decimal sep alignment, e.g. via siunitx.
+ if (decimal) {
+ docstring const halffixedwith =
+ from_ascii(Length(column_info[c].p_width.value() / 2,
+ column_info[c].p_width.unit()).asLatexString());
+ os << '{'
+ << halffixedwith
+ << '}'
+ << "@{\\extracolsep{0pt}" << column_info[c].decimal_point << "}"
+ << valign
+ << '{'
+ << halffixedwith
+ << '}';
+ } else
+ os << '{'
+ << from_ascii(column_info[c].p_width.asLatexString())
+ << '}';
} else {
switch (column_info[c].alignment) {
case LYX_ALIGN_LEFT:
continue;
stringstream attr;
+
+ Length const cwidth = column_info[c].p_width;
+ if (!cwidth.zero()) {
+ string const hwidth = cwidth.asHTMLString();
+ attr << "style =\"width: " << hwidth << ";\" ";
+ }
+
attr << "align='";
switch (getAlignment(cell)) {
case LYX_ALIGN_LEFT:
else if (isMultiRow(cell))
attr << " rowspan='" << rowSpan(cell) << "'";
- xs << html::StartTag(celltag, attr.str()) << html::CR();
+ xs << html::StartTag(celltag, attr.str(), true) << html::CR();
ret += cellInset(cell)->xhtml(xs, runparams);
xs << html::EndTag(celltag) << html::CR();
++cell;
}
-shared_ptr<InsetTableCell> Tabular::cellInset(idx_type cell) const
+shared_ptr<InsetTableCell> Tabular::cellInset(idx_type cell)
{
return cell_info[cellRow(cell)][cellColumn(cell)].inset;
}
-shared_ptr<InsetTableCell> Tabular::cellInset(row_type row,
- col_type column) const
+shared_ptr<InsetTableCell> Tabular::cellInset(row_type row, col_type column)
{
return cell_info[row][column].inset;
}
+InsetTableCell const * Tabular::cellInset(idx_type cell) const
+{
+ return cell_info[cellRow(cell)][cellColumn(cell)].inset.get();
+}
+
+
void Tabular::setCellInset(row_type row, col_type column,
- shared_ptr<InsetTableCell> ins) const
+ shared_ptr<InsetTableCell> ins)
{
CellData & cd = cell_info[row][column];
cd.inset = ins;
{
bool enabled = true;
switch (cmd.action()) {
- case LFUN_LAYOUT:
- enabled = !forcePlainLayout();
- break;
- case LFUN_LAYOUT_PARAGRAPH:
- enabled = allowParagraphCustomization();
- break;
-
case LFUN_MATH_DISPLAY:
if (!hasFixedWidth()) {
enabled = false;
InsetTabular::InsetTabular(Buffer * buf, row_type rows,
col_type columns)
: Inset(buf), tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))),
- first_visible_cell_(0), offset_valign_(0), rowselect_(false), colselect_(false)
+ rowselect_(false), colselect_(false)
{
}
InsetTabular::InsetTabular(InsetTabular const & tab)
- : Inset(tab), tabular(tab.tabular)
+ : Inset(tab), tabular(tab.tabular),
+ rowselect_(false), colselect_(false)
{
}
bool InsetTabular::allowsCaptionVariation(std::string const & newtype) const
{
return tabular.is_long_tabular &&
- (newtype == "Standard" || newtype == "LongTableNoNumber");
+ (newtype == "Standard" || newtype == "Unnumbered");
}
int InsetTabular::rowFromY(Cursor & cur, int y) const
{
// top y coordinate of tabular
- int h = yo(cur.bv()) - tabular.rowAscent(0) + offset_valign_;
+ int h = yo(cur.bv()) - tabular.rowAscent(0) + tabular.offsetVAlignment();
row_type r = 0;
for (; r < tabular.nrows() && y > h; ++r)
h += tabular.rowAscent(r) + tabular.rowDescent(r)
// determine horizontal offset because of decimal align (if necessary)
int decimal_width = 0;
if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) {
- InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell).get());
+ InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell));
tail.setBuffer(tabular.buffer());
// we need to set macrocontext position everywhere
// otherwise we crash with nested insets (e.g. footnotes)
tabular.setRowDescent(r, maxdes + ADD_TO_HEIGHT + bottom_space);
}
- // for top-alignment the first horizontal table line must be exactly at
- // the position of the base line of the surrounding text line
- // for bottom alignment, the same is for the last table line
- switch (tabular.tabular_valignment) {
- case Tabular::LYX_VALIGN_BOTTOM:
- offset_valign_ = tabular.rowAscent(0) - tabular.height();
- break;
- case Tabular::LYX_VALIGN_MIDDLE:
- offset_valign_ = (- tabular.height()) / 2 + tabular.rowAscent(0);
- break;
- case Tabular::LYX_VALIGN_TOP:
- offset_valign_ = tabular.rowAscent(0);
- break;
- }
-
tabular.updateColumnWidths();
- dim.asc = tabular.rowAscent(0) - offset_valign_;
+ dim.asc = tabular.rowAscent(0) - tabular.offsetVAlignment();
dim.des = tabular.height() - dim.asc;
dim.wid = tabular.width() + 2 * ADD_TO_TABULAR_WIDTH;
}
bool const original_selection_state = pi.selected;
idx_type idx = 0;
- first_visible_cell_ = Tabular::npos;
- int yy = y + offset_valign_;
+ int yy = y + tabular.offsetVAlignment();
for (row_type r = 0; r < tabular.nrows(); ++r) {
int nx = x;
for (col_type c = 0; c < tabular.ncols(); ++c) {
continue;
}
- if (first_visible_cell_ == Tabular::npos)
- first_visible_cell_ = idx;
-
pi.selected |= isCellSelected(cur, r, c);
int const cx = nx + tabular.textHOffset(idx);
int const cy = yy + tabular.textVOffset(idx);
void InsetTabular::drawBackground(PainterInfo & pi, int x, int y) const
{
x += ADD_TO_TABULAR_WIDTH;
- y += offset_valign_ - tabular.rowAscent(0);
+ y += tabular.offsetVAlignment() - tabular.rowAscent(0);
pi.pain.fillRectangle(x, y, tabular.width(), tabular.height(),
pi.backgroundColor(this));
}
}
int const w = tabular.cellWidth(cell);
int const h = tabular.cellHeight(cell);
- int const yy = y - tabular.rowAscent(r) + offset_valign_;
+ int const yy = y - tabular.rowAscent(r) + tabular.offsetVAlignment();
if (isCellSelected(cur, r, c))
pi.pain.fillRectangle(xx, yy, w, h, Color_selection);
xx += w;
}
+bool InsetTabular::hitSelectRow(BufferView const & bv, int x) const
+{
+ int const x0 = xo(bv) + ADD_TO_TABULAR_WIDTH;
+ return x < x0 || x > x0 + tabular.width();
+}
+
+
+bool InsetTabular::hitSelectColumn(BufferView const & bv, int y) const
+{
+ int const y0 = yo(bv) - tabular.rowAscent(0) + tabular.offsetVAlignment();
+ // FIXME: using ADD_TO_TABULAR_WIDTH is not really correct since
+ // there is no margin added vertically to tabular insets.
+ // However, it works for now.
+ return y < y0 + ADD_TO_TABULAR_WIDTH || y > y0 + tabular.height() - ADD_TO_TABULAR_WIDTH;
+}
+
+
+bool InsetTabular::clickable(BufferView const & bv, int x, int y) const
+{
+ return hitSelectRow(bv, x) || hitSelectColumn(bv, y);
+}
+
+
void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
{
LYXERR(Debug::DEBUG, "# InsetTabular::doDispatch: cmd: " << cmd
case LFUN_MOUSE_PRESS: {
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
// select row
- if (cmd.x() < xo(cur.bv()) + ADD_TO_TABULAR_WIDTH
- || cmd.x() > xo(cur.bv()) + tabular.width()) {
+ if (hitSelectRow(cur.bv(), cmd.x())) {
row_type r = rowFromY(cur, cmd.y());
cur.idx() = tabular.getFirstCellInRow(r);
+ cur.pit() = 0;
cur.pos() = 0;
cur.resetAnchor();
cur.idx() = tabular.getLastCellInRow(r);
+ cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
- cur.setSelection(true);
+ cur.selection(true);
bvcur = cur;
rowselect_ = true;
break;
}
// select column
- int const y0 = yo(cur.bv()) - tabular.rowAscent(0) + offset_valign_;
- if (cmd.y() < y0 + ADD_TO_TABULAR_WIDTH
- || cmd.y() > y0 + tabular.height()) {
+ if (hitSelectColumn(cur.bv(), cmd.y())) {
col_type c = columnFromX(cur, cmd.x());
cur.idx() = tabular.cellIndex(0, c);
+ cur.pit() = 0;
cur.pos() = 0;
cur.resetAnchor();
cur.idx() = tabular.cellIndex(tabular.nrows() - 1, c);
+ cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
- cur.setSelection(true);
+ cur.selection(true);
bvcur = cur;
colselect_ = true;
break;
cur.pit() = 0;
cur.pos() = 0;
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
break;
}
// select (additional) column
cur.pit() = 0;
cur.pos() = 0;
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
break;
}
// only update if selection changes
cur.noScreenUpdate();
setCursorFromCoordinates(cur, cmd.x(), cmd.y());
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
// if this is a multicell selection, we just set the cursor to
// the beginning of the cell's text.
if (bvcur.selIsMultiCell()) {
case LFUN_CELL_BACKWARD:
movePrevCell(cur);
- cur.setSelection(false);
+ cur.selection(false);
break;
case LFUN_CELL_FORWARD:
moveNextCell(cur);
- cur.setSelection(false);
+ cur.selection(false);
break;
case LFUN_CHAR_FORWARD_SELECT:
cur.screenUpdateFlags(Update::Force | Update::FitCursor);
break;
-// case LFUN_SCREEN_DOWN: {
-// //if (hasSelection())
-// // cur.selection() = false;
-// col_type const col = tabular.cellColumn(cur.idx());
-// int const t = cur.bv().top_y() + cur.bv().height();
-// if (t < yo() + tabular.getHeightOfTabular()) {
-// cur.bv().scrollDocView(t, true);
-// cur.idx() = tabular.cellBelow(first_visible_cell_) + col;
-// } else {
-// cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + col;
-// }
-// cur.par() = 0;
-// cur.pos() = 0;
-// break;
-// }
-//
-// case LFUN_SCREEN_UP: {
-// //if (hasSelection())
-// // cur.selection() = false;
-// col_type const col = tabular.cellColumn(cur.idx());
-// int const t = cur.bv().top_y() + cur.bv().height();
-// if (yo() < 0) {
-// cur.bv().scrollDocView(t, true);
-// if (yo() > 0)
-// cur.idx() = col;
-// else
-// cur.idx() = tabular.cellBelow(first_visible_cell_) + col;
-// } else {
-// cur.idx() = col;
-// }
-// cur.par() = cur.lastpar();
-// cur.pos() = cur.lastpos();
-// break;
-// }
-
case LFUN_LAYOUT_TABULAR:
cur.bv().showDialog("tabular");
break;
- case LFUN_INSET_MODIFY: {
- string arg;
- if (cmd.getArg(1) == "from-dialog")
- arg = cmd.getArg(0) + to_utf8(cmd.argument().substr(19));
+ case LFUN_INSET_MODIFY:
+ // we come from the dialog
+ if (cmd.getArg(0) == "tabular")
+ tabularFeatures(cur, cmd.getLongArg(1));
else
- arg = to_utf8(cmd.argument());
- if (!tabularFeatures(cur, arg))
cur.undispatched();
break;
- }
+
+ case LFUN_TABULAR_FEATURE:
+ tabularFeatures(cur, to_utf8(cmd.argument()));
+ break;
// insert file functions
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
}
-// function sets an object as defined in func_status.h:
-// states OK, Unknown, Disabled, On, Off.
-bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
- FuncStatus & status) const
+bool InsetTabular::getFeatureStatus(Cursor & cur, string const & s,
+ string const & argument, FuncStatus & status) const
{
- switch (cmd.action()) {
- case LFUN_INSET_MODIFY: {
- if (&cur.inset() != this || cmd.getArg(0) != "tabular")
- break;
-
- // FIXME: We only check for the very first argument...
- string const s = cmd.getArg(1);
- // We always enable the lfun if it is coming from the dialog
- // because the dialog makes sure all the settings are valid,
- // even though the first argument might not be valid now.
- if (s == "from-dialog") {
- status.setEnabled(true);
- return true;
- }
int action = Tabular::LAST_ACTION;
int i = 0;
return true;
}
- string const argument = cmd.getLongArg(2);
-
row_type sel_row_start = 0;
row_type sel_row_end = 0;
col_type sel_col_start = 0;
case Tabular::SET_LINE_TOP:
case Tabular::SET_LINE_BOTTOM:
+ status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ break;
+
case Tabular::SET_LINE_LEFT:
case Tabular::SET_LINE_RIGHT:
- status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ status.setEnabled(!tabular.use_booktabs
+ && !tabular.ltCaption(tabular.cellRow(cur.idx())));
break;
case Tabular::TOGGLE_LINE_TOP:
break;
case Tabular::TOGGLE_LINE_LEFT:
- status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ status.setEnabled(!tabular.use_booktabs
+ && !tabular.ltCaption(tabular.cellRow(cur.idx())));
status.setOnOff(tabular.leftLine(cur.idx()));
break;
case Tabular::TOGGLE_LINE_RIGHT:
- status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ status.setEnabled(!tabular.use_booktabs
+ && !tabular.ltCaption(tabular.cellRow(cur.idx())));
status.setOnOff(tabular.rightLine(cur.idx()));
break;
break;
case Tabular::SET_LONGTABULAR:
+ case Tabular::TOGGLE_LONGTABULAR:
// setting as longtable is not allowed when table is inside a float
if (cur.innerInsetOfType(FLOAT_CODE) != 0
|| cur.innerInsetOfType(WRAP_CODE) != 0)
status.setOnOff(tabular.ltCaption(sel_row_start));
break;
+ case Tabular::TOGGLE_BOOKTABS:
case Tabular::SET_BOOKTABS:
status.setOnOff(tabular.use_booktabs);
break;
break;
}
return true;
+}
+
+
+// function sets an object as defined in FuncStatus.h:
+// states OK, Unknown, Disabled, On, Off.
+bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const
+{
+ switch (cmd.action()) {
+ case LFUN_INSET_MODIFY:
+ if (cmd.getArg(0) != "tabular")
+ break;
+ if (cmd.getArg(1) == "for-dialog") {
+ // The dialog is asking the status of a command
+ if (&cur.inset() != this)
+ break;
+ string action = cmd.getArg(2);
+ string arg = cmd.getLongArg(3);
+ return getFeatureStatus(cur, action, arg, status);
+ } else {
+ // We always enable the lfun if it is coming from the dialog
+ // because the dialog makes sure all the settings are valid,
+ // even though the first argument might not be valid now.
+ status.setEnabled(true);
+ return true;
+ }
+
+ case LFUN_TABULAR_FEATURE: {
+ if (&cur.inset() != this)
+ break;
+ string action = cmd.getArg(0);
+ string arg = cmd.getLongArg(1);
+ return getFeatureStatus(cur, action, arg, status);
}
case LFUN_CAPTION_INSERT: {
}
// check if there is already a caption
bool have_caption = false;
- InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()).get());
+ InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()));
ParagraphList::const_iterator pit = itc.paragraphs().begin();
ParagraphList::const_iterator pend = itc.paragraphs().end();
for (; pit != pend; ++pit) {
void InsetTabular::validate(LaTeXFeatures & features) const
{
tabular.validate(features);
- // FIXME XHTML
- // It'd be better to be able to get this from an InsetLayout, but at present
- // InsetLayouts do not seem really to work for things that aren't InsetTexts.
- if (features.runparams().flavor == OutputParams::HTML)
- features.addCSSSnippet(
- "table { border: 1px solid black; display: inline-block; }\n"
- "td { border: 1px solid black; padding: 0.5ex; }");
+ features.useInsetLayout(getLayout());
}
// y offset correction
y += cellYPos(sl.idx());
y += tabular.textVOffset(sl.idx());
- y += offset_valign_;
+ y += tabular.offsetVAlignment();
// x offset correction
x += cellXPos(sl.idx());
Inset * InsetTabular::editXY(Cursor & cur, int x, int y)
{
//lyxerr << "InsetTabular::editXY: " << this << endl;
- cur.setSelection(false);
+ cur.selection(false);
cur.push(*this);
cur.idx() = getNearestCell(cur.bv(), x, y);
return cur.bv().textMetrics(&cell(cur.idx())->text()).editXY(cur, x, y);
}
-bool InsetTabular::tabularFeatures(Cursor & cur, string const & argument)
+void InsetTabular::tabularFeatures(Cursor & cur, string const & argument)
{
+ cur.recordUndoInset(this);
+
istringstream is(argument);
string s;
- is >> s;
- if (insetCode(s) != TABULAR_CODE)
- return false;
-
// Safe guard.
size_t safe_guard = 0;
for (;;) {
if (is.eof())
- break;
+ return;
safe_guard++;
if (safe_guard > 1000) {
LYXERR0("parameter max count reached!");
- break;
+ return;
}
is >> s;
Tabular::Feature action = Tabular::LAST_ACTION;
LYXERR(Debug::DEBUG, "Feature: " << s << "\t\tvalue: " << val);
tabularFeatures(cur, action, val);
}
- return true;
}
break;
}
- cur.recordUndoInset(this);
-
getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end);
row_type const row = tabular.cellRow(cur.idx());
col_type const column = tabular.cellColumn(cur.idx());
cur.idx() = tabular.cellIndex(sel_row_start, column);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
case Tabular::DELETE_COLUMN:
cur.idx() = tabular.cellIndex(row, sel_col_start);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
case Tabular::COPY_ROW:
tabular.rightLine(cur.selEnd().idx()));
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
}
tabular.getAlignment(cur.selEnd().idx()));
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
}
}
break;
+ case Tabular::TOGGLE_LONGTABULAR:
+ if (tabular.is_long_tabular)
+ tabularFeatures(cur, Tabular::UNSET_LONGTABULAR);
+ else
+ tabular.is_long_tabular = true;
+ break;
+
case Tabular::SET_LONGTABULAR:
tabular.is_long_tabular = true;
break;
cur.idx() = tabular.setLTCaption(row, true);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
// If a row is set as caption, then also insert
// a caption. Otherwise the LaTeX output is broken.
// Select cell if it is non-empty
cur.idx() = tabular.setLTCaption(row, false);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
FuncRequest fr(LFUN_INSET_DISSOLVE, "caption");
if (lyx::getStatus(fr).enabled())
lyx::dispatch(fr);
break;
}
+ case Tabular::TOGGLE_BOOKTABS:
+ tabular.use_booktabs = !tabular.use_booktabs;
+ break;
+
case Tabular::SET_BOOKTABS:
tabular.use_booktabs = true;
break;