if (old_format)
return;
- lex.nextToken();
+ lex.next();
string token = lex.getString();
while (lex.isOK() && (token != "\\end_inset")) {
- lex.nextToken();
+ lex.next();
token = lex.getString();
}
if (token != "\\end_inset") {
++cell;
Dimension dim;
MetricsInfo m = mi;
- m.base.textwidth =
- tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
+ LyXLength p_width = tabular.column_info[j].p_width;
+ if (!p_width.zero()) {
+ m.base.textwidth = p_width.inPixels(mi.base.textwidth);
+ }
tabular.getCellInset(cell).metrics(m, dim);
maxAsc = max(maxAsc, dim.asc);
maxDesc = max(maxDesc, dim.des);
for (int i = 0; i < tabular.rows(); ++i) {
int nx = x;
idx = tabular.getCellNumber(i, 0);
- if (y + tabular.getDescentOfRow(i) <= 0 &&
- y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
- {
- y += tabular.getDescentOfRow(i) +
- tabular.getAscentOfRow(i + 1) +
- tabular.getAdditionalHeight(i + 1);
+ if (y + tabular.getDescentOfRow(i) <= 0
+ && y - tabular.getAscentOfRow(i) < pi.pain.paperHeight()) {
+ y += tabular.getDescentOfRow(i)
+ + tabular.getAscentOfRow(i + 1)
+ + tabular.getAdditionalHeight(i + 1);
continue;
}
for (int j = 0; j < tabular.columns(); ++j) {
lyxerr << "InsetTabular::edit: " << this << endl;
finishUndo();
int cell;
+ cur.push(*this);
if (left) {
if (isRightToLeft(cur))
cell = tabular.getLastCellInRow(0);
cell = tabular.getNumberOfCells() - 1;
}
cur.selection() = false;
- resetPos(cur);
- cur.bv().fitCursor();
- cur.push(*this);
+ // this accesses the position cache before it is initialized
+ //resetPos(cur);
+ //cur.bv().fitCursor();
cur.idx() = cell;
}
cur.selection() = false;
cur.push(const_cast<InsetTabular&>(*this));
return setPos(cur, x, y);
- //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
+ //int xx = cursorx_ - xo() + tabular.getBeginningOfTextInCell(actcell);
}
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
- // we'll pop up the table dialog on release
- if (cmd.button() == mouse_button::button3)
+ lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
+
+ if (cmd.button() == mouse_button::button1) {
+ cur.selection() = false;
+ setPos(cur, cmd.x, cmd.y);
+ cur.resetAnchor();
+ bvcur = cur;
break;
- cur.selection() = false;
- setPos(cur, cmd.x, cmd.y);
- cur.resetAnchor();
- bvcur = cur;
+ }
+
//if (cmd.button() == mouse_button::button2)
// dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
- //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
+
+ // we'll pop up the table dialog on release
+ if (cmd.button() == mouse_button::button3)
+ break;
break;
case LFUN_MOUSE_MOTION:
- if (cmd.button() != mouse_button::button1)
- break;
- // ignore motions deeper nested than the real anchor
- if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
- break;
- setPos(cur, cmd.x, cmd.y);
- bvcur.setCursor(cur, true);
- //lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
+ lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
+ if (cmd.button() == mouse_button::button1) {
+ // only accept motions to places not deeper nested than the real anchor
+ if (bvcur.anchor_.hasPart(cur)) {
+ setPos(cur, cmd.x, cmd.y);
+ bvcur.setCursor(cur);
+ bvcur.selection() = true;
+ }
+ }
break;
case LFUN_MOUSE_RELEASE:
- //lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
+ lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
if (cmd.button() == mouse_button::button3)
InsetTabularMailer(*this).showDialog(&cur.bv());
break;
int actcol = tabular.column_of_cell(actcell);
int column = actcol;
if (cur.bv().top_y() + cur.bv().painter().paperHeight()
- < yo_ + tabular.getHeightOfTabular())
+ < yo() + tabular.getHeightOfTabular())
{
cur.bv().scrollDocView(
cur.bv().top_y() + cur.bv().painter().paperHeight());
//if (hasSelection())
// cur.selection() = false;
int column = tabular.column_of_cell(cur.idx());
- if (yo_ < 0) {
+ if (yo() < 0) {
cur.bv().scrollDocView(
cur.bv().top_y() - cur.bv().painter().paperHeight());
- if (yo_ > 0)
+ if (yo() > 0)
cur.idx() = column;
else
cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
int InsetTabular::plaintext(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
- int dp = runparams.linelen ? ownerPar(buf, this).params().depth() : 0;
+ int dp = runparams.linelen ? runparams.depth : 0;
return tabular.plaintext(buf, os, runparams, dp, false, 0);
}
InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
{
+ lyxerr << "# InsetTabular::setPos() x=" << x << " y=" << y << endl;
int idx_min = 0;
int dist_min = 1000000;
for (idx_type i = 0; i < nargs(); ++i) {
for (; c < cell; ++c)
lx += tabular.getWidthOfColumn(c);
- return lx - tabular.getWidthOfColumn(cell) + xo_;
+ return lx - tabular.getWidthOfColumn(cell) + xo();
}
scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
} else if (cursorx_ - offset < 20) {
scroll(bv, 20 - cursorx_ + offset);
- } else if (scroll() && xo_ > 20 &&
- xo_ + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
+ } else if (scroll() && xo() > 20 &&
+ xo() + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
scroll(bv, old_x - cursorx_);
}
}
-bool InsetTabular::isRightToLeft(LCursor & cur)
+bool InsetTabular::isRightToLeft(LCursor & cur) const
{
- return cur.bv().getParentLanguage(this)->RightToLeft();
+ BOOST_ASSERT(cur.size() > 1);
+ Paragraph const & parentpar = cur[cur.size() - 2].paragraph();
+ LCursor::pos_type const parentpos = cur[cur.size() - 2].pos();
+ return parentpar.getFontSettings(cur.bv().buffer()->params(),
+ parentpos).language()->RightToLeft();
}
// we can only set this if we are not too far right
if (cols < columns) {
InsetText & inset = loctab->getCellInset(cell);
- LyXFont const font = inset.text_.getFont(0, 0);
+ Paragraph & par = inset.text_.getPar(0);
+ LyXFont const font = inset.text_.getFont(par, 0);
inset.setText(buf.substr(op, p - op), font);
++cols;
++cell;
// we can only set this if we are not too far right
if (cols < columns) {
InsetText & inset = tabular.getCellInset(cell);
- LyXFont const font = inset.text_.getFont(0, 0);
+ Paragraph & par = inset.text_.getPar(0);
+ LyXFont const font = inset.text_.getFont(par, 0);
inset.setText(buf.substr(op, p - op), font);
}
cols = ocol;
// check for the last cell if there is no trailing '\n'
if (cell < cells && op < len) {
InsetText & inset = loctab->getCellInset(cell);
- LyXFont const font = inset.text_.getFont(0, 0);
+ Paragraph & par = inset.text_.getPar(0);
+ LyXFont const font = inset.text_.getFont(par, 0);
inset.setText(buf.substr(op, len - op), font);
}
return true;