3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "insettabular.h"
16 #include "bufferparams.h"
17 #include "BufferView.h"
20 #include "dispatchresult.h"
21 #include "funcrequest.h"
22 #include "FuncStatus.h"
28 #include "metricsinfo.h"
29 #include "outputparams.h"
30 #include "paragraph.h"
31 #include "paragraph_funcs.h"
32 #include "ParagraphParameters.h"
35 #include "frontends/Alert.h"
36 #include "frontends/font_metrics.h"
37 #include "frontends/LyXView.h"
38 #include "frontends/Painter.h"
40 #include "support/std_sstream.h"
44 using lyx::graphics::PreviewLoader;
46 using lyx::support::ltrim;
47 using lyx::support::strToInt;
48 using lyx::support::strToDbl;
54 using std::istringstream;
56 using std::ostringstream;
63 int const ADD_TO_HEIGHT = 2;
64 int const ADD_TO_TABULAR_WIDTH = 2;
67 boost::scoped_ptr<LyXTabular> paste_tabular;
70 struct TabularFeature {
71 LyXTabular::Feature action;
76 TabularFeature tabularFeature[] =
78 { LyXTabular::APPEND_ROW, "append-row" },
79 { LyXTabular::APPEND_COLUMN, "append-column" },
80 { LyXTabular::DELETE_ROW, "delete-row" },
81 { LyXTabular::DELETE_COLUMN, "delete-column" },
82 { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
83 { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
84 { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
85 { LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
86 { LyXTabular::ALIGN_LEFT, "align-left" },
87 { LyXTabular::ALIGN_RIGHT, "align-right" },
88 { LyXTabular::ALIGN_CENTER, "align-center" },
89 { LyXTabular::ALIGN_BLOCK, "align-block" },
90 { LyXTabular::VALIGN_TOP, "valign-top" },
91 { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
92 { LyXTabular::VALIGN_MIDDLE, "valign-middle" },
93 { LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
94 { LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
95 { LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
96 { LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
97 { LyXTabular::M_ALIGN_LEFT, "m-align-left" },
98 { LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
99 { LyXTabular::M_ALIGN_CENTER, "m-align-center" },
100 { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
101 { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
102 { LyXTabular::M_VALIGN_MIDDLE, "m-valign-middle" },
103 { LyXTabular::MULTICOLUMN, "multicolumn" },
104 { LyXTabular::SET_ALL_LINES, "set-all-lines" },
105 { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
106 { LyXTabular::SET_LONGTABULAR, "set-longtabular" },
107 { LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
108 { LyXTabular::SET_PWIDTH, "set-pwidth" },
109 { LyXTabular::SET_MPWIDTH, "set-mpwidth" },
110 { LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
111 { LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
112 { LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
113 { LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
114 { LyXTabular::SET_USEBOX, "set-usebox" },
115 { LyXTabular::SET_LTHEAD, "set-lthead" },
116 { LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
117 { LyXTabular::SET_LTFOOT, "set-ltfoot" },
118 { LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
119 { LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
120 { LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
121 { LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
122 { LyXTabular::LAST_ACTION, "" }
126 class FeatureEqual : public std::unary_function<TabularFeature, bool> {
128 FeatureEqual(LyXTabular::Feature feature)
129 : feature_(feature) {}
130 bool operator()(TabularFeature const & tf) const {
131 return tf.action == feature_;
134 LyXTabular::Feature feature_;
140 string const featureAsString(LyXTabular::Feature feature)
142 TabularFeature * end = tabularFeature +
143 sizeof(tabularFeature) / sizeof(TabularFeature);
144 TabularFeature * it = std::find_if(tabularFeature, end,
145 FeatureEqual(feature));
146 return (it == end) ? string() : it->feature;
150 bool InsetTabular::hasPasteBuffer() const
152 return (paste_tabular.get() != 0);
156 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
157 : tabular(buf.params(), max(rows, 1), max(columns, 1)),
158 buffer_(&buf), cursorx_(0)
160 tabular.setOwner(this);
164 InsetTabular::InsetTabular(InsetTabular const & tab)
165 : UpdatableInset(tab), tabular(tab.tabular),
166 buffer_(tab.buffer_), cursorx_(0)
168 tabular.setOwner(this);
172 InsetTabular::~InsetTabular()
174 InsetTabularMailer(*this).hideDialog();
178 auto_ptr<InsetBase> InsetTabular::clone() const
180 return auto_ptr<InsetBase>(new InsetTabular(*this));
184 Buffer const & InsetTabular::buffer() const
190 void InsetTabular::buffer(Buffer * b)
196 void InsetTabular::write(Buffer const & buf, ostream & os) const
198 os << "Tabular" << endl;
199 tabular.write(buf, os);
203 void InsetTabular::read(Buffer const & buf, LyXLex & lex)
205 bool const old_format = (lex.getString() == "\\LyXTable");
207 tabular.read(buf, lex);
213 string token = lex.getString();
214 while (lex.isOK() && (token != "\\end_inset")) {
216 token = lex.getString();
218 if (token != "\\end_inset") {
219 lex.printError("Missing \\end_inset at this point. "
225 void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
227 //lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
228 // mi.base.textwidth << "\n";
230 lyxerr << "InsetTabular::metrics: need bv" << endl;
234 for (int i = 0, cell = -1; i < tabular.rows(); ++i) {
237 for (int j = 0; j < tabular.columns(); ++j) {
238 if (tabular.isPartOfMultiColumn(i, j))
244 tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
245 tabular.getCellInset(cell).metrics(m, dim);
246 maxAsc = max(maxAsc, dim.asc);
247 maxDesc = max(maxDesc, dim.des);
248 tabular.setWidthOfCell(cell, dim.wid);
250 tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
251 tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
254 dim.asc = tabular.getAscentOfRow(0);
255 dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1;
256 dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH;
261 void InsetTabular::draw(PainterInfo & pi, int x, int y) const
263 //lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
265 BufferView * bv = pi.base.bv;
266 setPosCache(pi, x, y);
271 x += ADD_TO_TABULAR_WIDTH;
274 first_visible_cell = -1;
275 for (int i = 0; i < tabular.rows(); ++i) {
277 idx = tabular.getCellNumber(i, 0);
278 if (y + tabular.getDescentOfRow(i) <= 0 &&
279 y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
281 y += tabular.getDescentOfRow(i) +
282 tabular.getAscentOfRow(i + 1) +
283 tabular.getAdditionalHeight(i + 1);
286 for (int j = 0; j < tabular.columns(); ++j) {
287 if (nx > bv->workWidth())
289 if (tabular.isPartOfMultiColumn(i, j))
291 if (first_visible_cell < 0)
292 first_visible_cell = idx;
293 if (bv->cursor().selection())
294 drawCellSelection(pi, nx, y, i, j, idx);
296 int const cx = nx + tabular.getBeginningOfTextInCell(idx);
297 cell(idx).draw(pi, cx, y);
298 drawCellLines(pi.pain, nx, y, i, idx);
299 nx += tabular.getWidthOfColumn(idx);
303 // Would be nice, but for some completely unfathomable reason,
304 // on a col resize to a new fixed width, even though the insettexts
305 // are resized, the cell isn't, but drawing all cells in a tall table
306 // has the desired effect somehow. Complete dark magic.
308 // avoiding drawing the rest of a long table is
309 // a pretty big speedup
310 if (y > bv->workHeight())
314 y += tabular.getDescentOfRow(i) +
315 tabular.getAscentOfRow(i + 1) +
316 tabular.getAdditionalHeight(i + 1);
321 void InsetTabular::drawCellLines(Painter & pain, int x, int y,
322 int row, int cell) const
324 int x2 = x + tabular.getWidthOfColumn(cell);
327 if (!tabular.topAlreadyDrawn(cell)) {
328 on_off = !tabular.topLine(cell);
329 pain.line(x, y - tabular.getAscentOfRow(row),
330 x2, y - tabular.getAscentOfRow(row),
331 on_off ? LColor::tabularonoffline : LColor::tabularline,
332 on_off ? Painter::line_onoffdash : Painter::line_solid);
334 on_off = !tabular.bottomLine(cell);
335 pain.line(x, y + tabular.getDescentOfRow(row),
336 x2, y + tabular.getDescentOfRow(row),
337 on_off ? LColor::tabularonoffline : LColor::tabularline,
338 on_off ? Painter::line_onoffdash : Painter::line_solid);
339 if (!tabular.leftAlreadyDrawn(cell)) {
340 on_off = !tabular.leftLine(cell);
341 pain.line(x, y - tabular.getAscentOfRow(row),
342 x, y + tabular.getDescentOfRow(row),
343 on_off ? LColor::tabularonoffline : LColor::tabularline,
344 on_off ? Painter::line_onoffdash : Painter::line_solid);
346 on_off = !tabular.rightLine(cell);
347 pain.line(x2 - tabular.getAdditionalWidth(cell),
348 y - tabular.getAscentOfRow(row),
349 x2 - tabular.getAdditionalWidth(cell),
350 y + tabular.getDescentOfRow(row),
351 on_off ? LColor::tabularonoffline : LColor::tabularline,
352 on_off ? Painter::line_onoffdash : Painter::line_solid);
356 void InsetTabular::drawCellSelection(PainterInfo & pi, int x, int y,
357 int row, int column, int cell) const
359 LCursor & cur = pi.base.bv->cursor();
360 BOOST_ASSERT(cur.selection());
361 if (tablemode(cur)) {
363 getSelection(cur, rs, re, cs, ce);
364 if (column >= cs && column <= ce && row >= rs && row <= re) {
365 int w = tabular.getWidthOfColumn(cell);
366 int h = tabular.getAscentOfRow(row) + tabular.getDescentOfRow(row)-1;
367 pi.pain.fillRectangle(x, y - tabular.getAscentOfRow(row) + 1,
368 w, h, LColor::selection);
374 string const InsetTabular::editMessage() const
376 return _("Opened table");
380 void InsetTabular::edit(LCursor & cur, bool left)
382 lyxerr << "InsetTabular::edit: " << this << endl;
386 if (isRightToLeft(cur))
387 cell = tabular.getLastCellInRow(0);
391 if (isRightToLeft(cur))
392 cell = tabular.getFirstCellInRow(tabular.rows()-1);
394 cell = tabular.getNumberOfCells() - 1;
396 cur.selection() = false;
398 cur.bv().fitCursor();
404 InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y)
406 //lyxerr << "InsetTabular::editXY: " << this << endl;
407 cur.selection() = false;
409 return setPos(cur, x, y);
410 //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
414 void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
416 lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
417 //lyxerr << " cur:\n" << cur << endl;
418 CursorSlice sl = cur.top();
420 switch (cmd.action) {
422 case LFUN_MOUSE_PRESS:
423 // we'll pop up the table dialog on release
424 if (cmd.button() == mouse_button::button3)
426 cur.selection() = false;
427 setPos(cur, cmd.x, cmd.y);
429 cur.bv().cursor().setCursor(cur, false);
430 //if (cmd.button() == mouse_button::button2)
431 // dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
432 //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
435 case LFUN_MOUSE_MOTION:
436 if (cmd.button() != mouse_button::button1)
438 setPos(cur, cmd.x, cmd.y);
439 cur.bv().cursor().setCursor(cur, true);
440 //lyxerr << "# InsetTabular::MouseMotion\n" << cur.bv().cursor() << endl;
443 case LFUN_MOUSE_RELEASE:
444 //lyxerr << "# InsetTabular::MouseRelease\n" << cur.bv().cursor() << endl;
445 if (cmd.button() == mouse_button::button3)
446 InsetTabularMailer(*this).showDialog(&cur.bv());
449 case LFUN_CELL_BACKWARD:
451 cur.selection() = false;
454 case LFUN_CELL_FORWARD:
456 cur.selection() = false;
459 case LFUN_SCROLL_INSET:
460 if (cmd.argument.empty())
462 if (cmd.argument.find('.') != cmd.argument.npos)
463 scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
465 scroll(cur.bv(), strToInt(cmd.argument));
471 cell(cur.idx()).dispatch(cur, cmd);
473 isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
474 if (sl == cur.top()) {
475 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
482 cell(cur.idx()).dispatch(cur, cmd);
484 isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
485 if (sl == cur.top()) {
486 cmd = FuncRequest(LFUN_FINISHED_LEFT);
493 cell(cur.idx()).dispatch(cur, cmd);
495 if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) {
496 cur.idx() = tabular.getCellBelow(cur.idx());
501 if (sl == cur.top()) {
502 cmd = FuncRequest(LFUN_FINISHED_DOWN);
509 cell(cur.idx()).dispatch(cur, cmd);
511 if (tabular.row_of_cell(cur.idx()) != 0) {
512 cur.idx() = tabular.getCellAbove(cur.idx());
513 cur.par() = cur.lastpar();
514 cur.pos() = cur.lastpos();
517 if (sl == cur.top()) {
518 cmd = FuncRequest(LFUN_FINISHED_UP);
524 //if (hasSelection())
525 // cur.selection() = false;
526 int actcell = cur.idx();
527 int actcol = tabular.column_of_cell(actcell);
529 if (cur.bv().top_y() + cur.bv().painter().paperHeight()
530 < yo_ + tabular.getHeightOfTabular())
532 cur.bv().scrollDocView(
533 cur.bv().top_y() + cur.bv().painter().paperHeight());
534 cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
536 cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
543 //if (hasSelection())
544 // cur.selection() = false;
545 int column = tabular.column_of_cell(cur.idx());
547 cur.bv().scrollDocView(
548 cur.bv().top_y() - cur.bv().painter().paperHeight());
552 cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
560 case LFUN_LAYOUT_TABULAR:
561 InsetTabularMailer(*this).showDialog(&cur.bv());
564 case LFUN_INSET_DIALOG_UPDATE:
565 InsetTabularMailer(*this).updateDialog(&cur.bv());
568 case LFUN_TABULAR_FEATURE:
569 if (!tabularFeatures(cur, cmd.argument))
573 // insert file functions
574 case LFUN_FILE_INSERT_ASCII_PARA:
575 case LFUN_FILE_INSERT_ASCII: {
576 string tmpstr = getContentsOfAsciiFile(&cur.bv(), cmd.argument, false);
577 if (!tmpstr.empty() && !insertAsciiString(cur.bv(), tmpstr, false))
592 lyxerr << "font changes not re-implemented for tables after LOCK" << endl;
596 if (copySelection(cur)) {
597 recordUndo(cur, Undo::DELETE);
604 recordUndo(cur, Undo::DELETE);
608 cell(cur.idx()).dispatch(cur, cmd);
612 if (!cur.selection())
618 case LFUN_PASTESELECTION: {
619 string const clip = cur.bv().getClipboard();
622 if (clip.find('\t') != string::npos) {
626 size_t len = clip.length();
627 for (size_t p = 0; p < len; ++p) {
628 p = clip.find_first_of("\t\n", p);
629 if (p == string::npos)
638 maxCols = max(cols, maxCols);
643 maxCols = max(cols, maxCols);
646 new LyXTabular(cur.bv().buffer()->params(), rows, maxCols));
648 string::size_type op = 0;
650 int cells = paste_tabular->getNumberOfCells();
653 for (size_t p = 0; cell < cells && p < len; ++p) {
654 p = clip.find_first_of("\t\n", p);
655 if (p == string::npos || p >= len)
659 paste_tabular->getCellInset(cell).
660 setText(clip.substr(op, p - op), font);
665 paste_tabular->getCellInset(cell).
666 setText(clip.substr(op, p - op), font);
667 while (cols++ < maxCols)
674 // check for the last cell if there is no trailing '\n'
675 if (cell < cells && op < len)
676 paste_tabular->getCellInset(cell).
677 setText(clip.substr(op, len - op), font);
678 } else if (!insertAsciiString(cur.bv(), clip, true)) {
679 // so that the clipboard is used and it goes on
681 // and executes LFUN_PASTESELECTION in insettext!
682 paste_tabular.reset();
688 if (hasPasteBuffer()) {
689 recordUndo(cur, Undo::INSERT);
693 cell(cur.idx()).dispatch(cur, cmd);
697 // we try to handle this event in the insets dispatch function.
698 cell(cur.idx()).dispatch(cur, cmd);
702 InsetTabularMailer(*this).updateDialog(&cur.bv());
706 int InsetTabular::latex(Buffer const & buf, ostream & os,
707 OutputParams const & runparams) const
709 return tabular.latex(buf, os, runparams);
713 int InsetTabular::plaintext(Buffer const & buf, ostream & os,
714 OutputParams const & runparams) const
716 int dp = runparams.linelen ? ownerPar(buf, this).params().depth() : 0;
717 return tabular.plaintext(buf, os, runparams, dp, false, 0);
721 int InsetTabular::linuxdoc(Buffer const & buf, ostream & os,
722 OutputParams const & runparams) const
724 return tabular.linuxdoc(buf,os, runparams);
728 int InsetTabular::docbook(Buffer const & buf, ostream & os,
729 OutputParams const & runparams) const
734 // if the table is inside a float it doesn't need the informaltable
735 // wrapper. Search for it.
736 for (master = owner(); master; master = master->owner())
737 if (master->lyxCode() == InsetOld::FLOAT_CODE)
741 os << "<informaltable>";
742 if (runparams.mixed_content)
746 ret += tabular.docbook(buf, os, runparams);
748 os << "</informaltable>";
749 if (runparams.mixed_content)
757 void InsetTabular::validate(LaTeXFeatures & features) const
759 tabular.validate(features);
763 InsetText const & InsetTabular::cell(int idx) const
765 return tabular.getCellInset(idx);
769 InsetText & InsetTabular::cell(int idx)
771 return tabular.getCellInset(idx);
775 void InsetTabular::getCursorPos(CursorSlice const & cur, int & x, int & y) const
777 cell(cur.idx()).getCursorPos(cur, x, y);
781 InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
784 int dist_min = 1000000;
785 for (idx_type i = 0; i < nargs(); ++i) {
786 int d = getText(i)->dist(x, y);
793 InsetBase * inset = cell(cur.idx()).text_.editXY(cur, x, y);
794 //lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
799 int InsetTabular::getCellXPos(int cell) const
803 for (; !tabular.isFirstCellInRow(c); --c)
805 int lx = tabular.getWidthOfColumn(cell);
806 for (; c < cell; ++c)
807 lx += tabular.getWidthOfColumn(c);
809 return lx - tabular.getWidthOfColumn(cell) + xo_;
813 void InsetTabular::resetPos(LCursor & cur) const
815 BufferView & bv = cur.bv();
816 int actcell = cur.idx();
817 int actcol = tabular.column_of_cell(actcell);
819 int const offset = ADD_TO_TABULAR_WIDTH + 2;
820 int new_x = getCellXPos(actcell) + offset;
821 int old_x = cursorx_;
823 // cursor.x(getCellXPos(actcell) + offset);
824 if (actcol < tabular.columns() - 1 && scroll(false) &&
825 tabular.getWidthOfTabular() < bv.workWidth()-20)
828 } else if (cursorx_ - offset > 20 &&
829 cursorx_ - offset + tabular.getWidthOfColumn(actcell)
830 > bv.workWidth() - 20) {
831 scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
832 } else if (cursorx_ - offset < 20) {
833 scroll(bv, 20 - cursorx_ + offset);
834 } else if (scroll() && xo_ > 20 &&
835 xo_ + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
836 scroll(bv, old_x - cursorx_);
839 InsetTabularMailer(*this).updateDialog(&bv);
843 void InsetTabular::moveNextCell(LCursor & cur)
845 lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur << endl;
846 if (isRightToLeft(cur)) {
847 if (tabular.isFirstCellInRow(cur.idx())) {
848 int row = tabular.row_of_cell(cur.idx());
849 if (row == tabular.rows() - 1)
851 cur.idx() = tabular.getLastCellInRow(row);
852 cur.idx() = tabular.getCellBelow(cur.idx());
859 if (tabular.isLastCell(cur.idx()))
865 lyxerr << "InsetTabular::moveNextCell 2 cur: " << cur << endl;
870 void InsetTabular::movePrevCell(LCursor & cur)
872 if (isRightToLeft(cur)) {
873 if (tabular.isLastCellInRow(cur.idx())) {
874 int row = tabular.row_of_cell(cur.idx());
877 cur.idx() = tabular.getFirstCellInRow(row);
878 cur.idx() = tabular.getCellAbove(cur.idx());
880 if (tabular.isLastCell(cur.idx()))
885 if (cur.idx() == 0) // first cell
895 bool InsetTabular::tabularFeatures(LCursor & cur, string const & what)
897 LyXTabular::Feature action = LyXTabular::LAST_ACTION;
900 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
901 string const tmp = tabularFeature[i].feature;
903 if (tmp == what.substr(0, tmp.length())) {
904 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
905 //tabularFeatures[i].feature.length())) {
906 action = tabularFeature[i].action;
910 if (action == LyXTabular::LAST_ACTION)
914 ltrim(what.substr(tabularFeature[i].feature.length()));
915 tabularFeatures(cur, action, val);
922 void checkLongtableSpecial(LyXTabular::ltType & ltt,
923 string const & special, bool & flag)
925 if (special == "dl_above") {
928 } else if (special == "dl_below") {
931 } else if (special == "empty") {
943 void InsetTabular::tabularFeatures(LCursor & cur,
944 LyXTabular::Feature feature, string const & value)
946 BufferView & bv = cur.bv();
947 int actcell = cur.idx();
952 bool setLines = false;
953 LyXAlignment setAlign = LYX_ALIGN_LEFT;
954 LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
958 case LyXTabular::M_ALIGN_LEFT:
959 case LyXTabular::ALIGN_LEFT:
960 setAlign = LYX_ALIGN_LEFT;
963 case LyXTabular::M_ALIGN_RIGHT:
964 case LyXTabular::ALIGN_RIGHT:
965 setAlign = LYX_ALIGN_RIGHT;
968 case LyXTabular::M_ALIGN_CENTER:
969 case LyXTabular::ALIGN_CENTER:
970 setAlign = LYX_ALIGN_CENTER;
973 case LyXTabular::ALIGN_BLOCK:
974 setAlign = LYX_ALIGN_BLOCK;
977 case LyXTabular::M_VALIGN_TOP:
978 case LyXTabular::VALIGN_TOP:
979 setVAlign = LyXTabular::LYX_VALIGN_TOP;
982 case LyXTabular::M_VALIGN_BOTTOM:
983 case LyXTabular::VALIGN_BOTTOM:
984 setVAlign = LyXTabular::LYX_VALIGN_BOTTOM;
987 case LyXTabular::M_VALIGN_MIDDLE:
988 case LyXTabular::VALIGN_MIDDLE:
989 setVAlign = LyXTabular::LYX_VALIGN_MIDDLE;
996 recordUndo(cur, Undo::ATOMIC);
998 getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end);
999 int row = tabular.row_of_cell(actcell);
1000 int column = tabular.column_of_cell(actcell);
1002 LyXTabular::ltType ltt;
1006 case LyXTabular::SET_PWIDTH: {
1007 LyXLength const len(value);
1008 tabular.setColumnPWidth(actcell, len);
1010 && tabular.getAlignment(actcell, true) == LYX_ALIGN_BLOCK)
1011 tabularFeatures(cur, LyXTabular::ALIGN_CENTER, string());
1012 else if (!len.zero()
1013 && tabular.getAlignment(actcell, true) != LYX_ALIGN_BLOCK)
1014 tabularFeatures(cur, LyXTabular::ALIGN_BLOCK, string());
1018 case LyXTabular::SET_MPWIDTH:
1019 tabular.setMColumnPWidth(actcell, LyXLength(value));
1022 case LyXTabular::SET_SPECIAL_COLUMN:
1023 case LyXTabular::SET_SPECIAL_MULTI:
1024 tabular.setAlignSpecial(actcell,value,feature);
1027 case LyXTabular::APPEND_ROW:
1028 // append the row into the tabular
1029 tabular.appendRow(bv.buffer()->params(), actcell);
1030 tabular.setOwner(this);
1033 case LyXTabular::APPEND_COLUMN:
1034 // append the column into the tabular
1035 tabular.appendColumn(bv.buffer()->params(), actcell);
1036 tabular.setOwner(this);
1037 actcell = tabular.getCellNumber(row, column);
1040 case LyXTabular::DELETE_ROW:
1041 for (int i = sel_row_start; i <= sel_row_end; ++i)
1042 tabular.deleteRow(sel_row_start);
1043 if (sel_row_start >= tabular.rows())
1045 actcell = tabular.getCellNumber(sel_row_start, column);
1046 cur.selection() = false;
1049 case LyXTabular::DELETE_COLUMN:
1050 for (int i = sel_col_start; i <= sel_col_end; ++i)
1051 tabular.deleteColumn(sel_col_start);
1052 if (sel_col_start >= tabular.columns())
1054 actcell = tabular.getCellNumber(row, sel_col_start);
1055 cur.selection() = false;
1058 case LyXTabular::M_TOGGLE_LINE_TOP:
1060 case LyXTabular::TOGGLE_LINE_TOP: {
1061 bool lineSet = !tabular.topLine(actcell, flag);
1062 for (int i = sel_row_start; i <= sel_row_end; ++i)
1063 for (int j = sel_col_start; j <= sel_col_end; ++j)
1065 tabular.getCellNumber(i, j),
1070 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1072 case LyXTabular::TOGGLE_LINE_BOTTOM: {
1073 bool lineSet = !tabular.bottomLine(actcell, flag);
1074 for (int i = sel_row_start; i <= sel_row_end; ++i)
1075 for (int j = sel_col_start; j <= sel_col_end; ++j)
1076 tabular.setBottomLine(
1077 tabular.getCellNumber(i, j),
1083 case LyXTabular::M_TOGGLE_LINE_LEFT:
1085 case LyXTabular::TOGGLE_LINE_LEFT: {
1086 bool lineSet = !tabular.leftLine(actcell, flag);
1087 for (int i = sel_row_start; i <= sel_row_end; ++i)
1088 for (int j = sel_col_start; j <= sel_col_end; ++j)
1089 tabular.setLeftLine(
1090 tabular.getCellNumber(i,j),
1096 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1098 case LyXTabular::TOGGLE_LINE_RIGHT: {
1099 bool lineSet = !tabular.rightLine(actcell, flag);
1100 for (int i = sel_row_start; i <= sel_row_end; ++i)
1101 for (int j = sel_col_start; j <= sel_col_end; ++j)
1102 tabular.setRightLine(
1103 tabular.getCellNumber(i,j),
1109 case LyXTabular::M_ALIGN_LEFT:
1110 case LyXTabular::M_ALIGN_RIGHT:
1111 case LyXTabular::M_ALIGN_CENTER:
1113 case LyXTabular::ALIGN_LEFT:
1114 case LyXTabular::ALIGN_RIGHT:
1115 case LyXTabular::ALIGN_CENTER:
1116 case LyXTabular::ALIGN_BLOCK:
1117 for (int i = sel_row_start; i <= sel_row_end; ++i)
1118 for (int j = sel_col_start; j <= sel_col_end; ++j)
1119 tabular.setAlignment(
1120 tabular.getCellNumber(i, j),
1125 case LyXTabular::M_VALIGN_TOP:
1126 case LyXTabular::M_VALIGN_BOTTOM:
1127 case LyXTabular::M_VALIGN_MIDDLE:
1129 case LyXTabular::VALIGN_TOP:
1130 case LyXTabular::VALIGN_BOTTOM:
1131 case LyXTabular::VALIGN_MIDDLE:
1132 for (int i = sel_row_start; i <= sel_row_end; ++i)
1133 for (int j = sel_col_start; j <= sel_col_end; ++j)
1134 tabular.setVAlignment(
1135 tabular.getCellNumber(i, j),
1139 case LyXTabular::MULTICOLUMN: {
1140 if (sel_row_start != sel_row_end) {
1141 #ifdef WITH_WARNINGS
1142 #warning Need I say it ? This is horrible.
1144 Alert::error(_("Error setting multicolumn"),
1145 _("You cannot set multicolumn vertically."));
1149 // just multicol for one Single Cell
1150 if (!hasSelection()) {
1151 // check wether we are completly in a multicol
1152 if (tabular.isMultiColumn(actcell))
1153 tabular.unsetMultiColumn(actcell);
1155 tabular.setMultiColumn(bv.buffer(), actcell, 1);
1158 // we have a selection so this means we just add all this
1159 // cells to form a multicolumn cell
1163 if (sel_cell_start > sel_cell_end) {
1164 s_start = sel_cell_end;
1165 s_end = sel_cell_start;
1167 s_start = sel_cell_start;
1168 s_end = sel_cell_end;
1170 tabular.setMultiColumn(bv.buffer(), s_start, s_end - s_start + 1);
1173 cur.selection() = false;
1177 case LyXTabular::SET_ALL_LINES:
1179 case LyXTabular::UNSET_ALL_LINES:
1181 for (int i = sel_row_start; i <= sel_row_end; ++i)
1182 for (int j = sel_col_start; j <= sel_col_end; ++j)
1183 tabular.setAllLines(
1184 tabular.getCellNumber(i,j), setLines);
1188 case LyXTabular::SET_LONGTABULAR:
1189 tabular.setLongTabular(true);
1192 case LyXTabular::UNSET_LONGTABULAR:
1193 tabular.setLongTabular(false);
1196 case LyXTabular::SET_ROTATE_TABULAR:
1197 tabular.setRotateTabular(true);
1200 case LyXTabular::UNSET_ROTATE_TABULAR:
1201 tabular.setRotateTabular(false);
1204 case LyXTabular::SET_ROTATE_CELL:
1205 for (int i = sel_row_start; i <= sel_row_end; ++i)
1206 for (int j = sel_col_start; j <= sel_col_end; ++j)
1207 tabular.setRotateCell(
1208 tabular.getCellNumber(i, j), true);
1211 case LyXTabular::UNSET_ROTATE_CELL:
1212 for (int i = sel_row_start; i <= sel_row_end; ++i)
1213 for (int j = sel_col_start; j <= sel_col_end; ++j)
1214 tabular.setRotateCell(
1215 tabular.getCellNumber(i, j), false);
1218 case LyXTabular::SET_USEBOX: {
1219 LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
1220 if (val == tabular.getUsebox(actcell))
1221 val = LyXTabular::BOX_NONE;
1222 for (int i = sel_row_start; i <= sel_row_end; ++i)
1223 for (int j = sel_col_start; j <= sel_col_end; ++j)
1224 tabular.setUsebox(tabular.getCellNumber(i, j), val);
1228 case LyXTabular::UNSET_LTFIRSTHEAD:
1230 case LyXTabular::SET_LTFIRSTHEAD:
1231 tabular.getRowOfLTFirstHead(row, ltt);
1232 checkLongtableSpecial(ltt, value, flag);
1233 tabular.setLTHead(row, flag, ltt, true);
1236 case LyXTabular::UNSET_LTHEAD:
1238 case LyXTabular::SET_LTHEAD:
1239 tabular.getRowOfLTHead(row, ltt);
1240 checkLongtableSpecial(ltt, value, flag);
1241 tabular.setLTHead(row, flag, ltt, false);
1244 case LyXTabular::UNSET_LTFOOT:
1246 case LyXTabular::SET_LTFOOT:
1247 tabular.getRowOfLTFoot(row, ltt);
1248 checkLongtableSpecial(ltt, value, flag);
1249 tabular.setLTFoot(row, flag, ltt, false);
1252 case LyXTabular::UNSET_LTLASTFOOT:
1254 case LyXTabular::SET_LTLASTFOOT:
1255 tabular.getRowOfLTLastFoot(row, ltt);
1256 checkLongtableSpecial(ltt, value, flag);
1257 tabular.setLTFoot(row, flag, ltt, true);
1260 case LyXTabular::SET_LTNEWPAGE:
1261 tabular.setLTNewPage(row, !tabular.getLTNewPage(row));
1264 // dummy stuff just to avoid warnings
1265 case LyXTabular::LAST_ACTION:
1269 InsetTabularMailer(*this).updateDialog(&bv);
1273 bool InsetTabular::showInsetDialog(BufferView * bv) const
1275 InsetTabularMailer(*this).showDialog(bv);
1280 void InsetTabular::openLayoutDialog(BufferView * bv) const
1282 InsetTabularMailer(*this).showDialog(bv);
1287 // function returns an object as defined in func_status.h:
1288 // states OK, Unknown, Disabled, On, Off.
1290 FuncStatus InsetTabular::getStatus(BufferView & bv,
1291 string const & what, int actcell) const
1294 int action = LyXTabular::LAST_ACTION;
1295 LCursor & cur = bv.cursor();
1298 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
1299 string const tmp = tabularFeature[i].feature;
1300 if (tmp == what.substr(0, tmp.length())) {
1301 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
1302 // tabularFeatures[i].feature.length()))
1303 action = tabularFeature[i].action;
1307 if (action == LyXTabular::LAST_ACTION) {
1309 status.unknown(true);
1313 string const argument
1314 = ltrim(what.substr(tabularFeature[i].feature.length()));
1316 int sel_row_start = 0;
1317 int sel_row_end = 0;
1319 LyXTabular::ltType dummyltt;
1322 getSelection(cur, sel_row_start, sel_row_end, dummy, dummy);
1325 case LyXTabular::SET_PWIDTH:
1326 case LyXTabular::SET_MPWIDTH:
1327 case LyXTabular::SET_SPECIAL_COLUMN:
1328 case LyXTabular::SET_SPECIAL_MULTI:
1329 case LyXTabular::APPEND_ROW:
1330 case LyXTabular::APPEND_COLUMN:
1331 case LyXTabular::DELETE_ROW:
1332 case LyXTabular::DELETE_COLUMN:
1333 case LyXTabular::SET_ALL_LINES:
1334 case LyXTabular::UNSET_ALL_LINES:
1338 case LyXTabular::MULTICOLUMN:
1339 status.setOnOff(tabular.isMultiColumn(actcell));
1342 case LyXTabular::M_TOGGLE_LINE_TOP:
1344 case LyXTabular::TOGGLE_LINE_TOP:
1345 status.setOnOff(tabular.topLine(actcell, flag));
1348 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1350 case LyXTabular::TOGGLE_LINE_BOTTOM:
1351 status.setOnOff(tabular.bottomLine(actcell, flag));
1354 case LyXTabular::M_TOGGLE_LINE_LEFT:
1356 case LyXTabular::TOGGLE_LINE_LEFT:
1357 status.setOnOff(tabular.leftLine(actcell, flag));
1360 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1362 case LyXTabular::TOGGLE_LINE_RIGHT:
1363 status.setOnOff(tabular.rightLine(actcell, flag));
1366 case LyXTabular::M_ALIGN_LEFT:
1368 case LyXTabular::ALIGN_LEFT:
1369 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_LEFT);
1372 case LyXTabular::M_ALIGN_RIGHT:
1374 case LyXTabular::ALIGN_RIGHT:
1375 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_RIGHT);
1378 case LyXTabular::M_ALIGN_CENTER:
1380 case LyXTabular::ALIGN_CENTER:
1381 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_CENTER);
1384 case LyXTabular::ALIGN_BLOCK:
1385 status.disabled(tabular.getPWidth(actcell).zero());
1386 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_BLOCK);
1389 case LyXTabular::M_VALIGN_TOP:
1391 case LyXTabular::VALIGN_TOP:
1393 tabular.getVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP);
1396 case LyXTabular::M_VALIGN_BOTTOM:
1398 case LyXTabular::VALIGN_BOTTOM:
1400 tabular.getVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM);
1403 case LyXTabular::M_VALIGN_MIDDLE:
1405 case LyXTabular::VALIGN_MIDDLE:
1407 tabular.getVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_MIDDLE);
1410 case LyXTabular::SET_LONGTABULAR:
1411 status.setOnOff(tabular.isLongTabular());
1414 case LyXTabular::UNSET_LONGTABULAR:
1415 status.setOnOff(!tabular.isLongTabular());
1418 case LyXTabular::SET_ROTATE_TABULAR:
1419 status.setOnOff(tabular.getRotateTabular());
1422 case LyXTabular::UNSET_ROTATE_TABULAR:
1423 status.setOnOff(!tabular.getRotateTabular());
1426 case LyXTabular::SET_ROTATE_CELL:
1427 status.setOnOff(tabular.getRotateCell(actcell));
1430 case LyXTabular::UNSET_ROTATE_CELL:
1431 status.setOnOff(!tabular.getRotateCell(actcell));
1434 case LyXTabular::SET_USEBOX:
1435 status.setOnOff(strToInt(argument) == tabular.getUsebox(actcell));
1438 case LyXTabular::SET_LTFIRSTHEAD:
1439 status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
1442 case LyXTabular::SET_LTHEAD:
1443 status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
1446 case LyXTabular::SET_LTFOOT:
1447 status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
1450 case LyXTabular::SET_LTLASTFOOT:
1451 status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
1454 case LyXTabular::SET_LTNEWPAGE:
1455 status.setOnOff(tabular.getLTNewPage(sel_row_start));
1460 status.disabled(true);
1467 void InsetTabular::getLabelList(Buffer const & buffer,
1468 vector<string> & list) const
1470 tabular.getLabelList(buffer, list);
1474 bool InsetTabular::copySelection(LCursor & cur)
1476 if (!cur.selection())
1480 getSelection(cur, rs, re, cs, ce);
1482 paste_tabular.reset(new LyXTabular(tabular));
1483 paste_tabular->setOwner(this);
1485 for (int i = 0; i < rs; ++i)
1486 paste_tabular->deleteRow(0);
1488 int const rows = re - rs + 1;
1489 while (paste_tabular->rows() > rows)
1490 paste_tabular->deleteRow(rows);
1492 paste_tabular->setTopLine(0, true, true);
1493 paste_tabular->setBottomLine(paste_tabular->getFirstCellInRow(rows - 1),
1496 for (int i = 0; i < cs; ++i)
1497 paste_tabular->deleteColumn(0);
1499 int const columns = ce - cs + 1;
1500 while (paste_tabular->columns() > columns)
1501 paste_tabular->deleteColumn(columns);
1503 paste_tabular->setLeftLine(0, true, true);
1504 paste_tabular->setRightLine(paste_tabular->getLastCellInRow(0),
1508 OutputParams const runparams;
1509 paste_tabular->plaintext(*cur.bv().buffer(), os, runparams, 0, true, '\t');
1510 cur.bv().stuffClipboard(os.str());
1515 bool InsetTabular::pasteSelection(LCursor & cur)
1519 int actcell = cur.idx();
1520 int actcol = tabular.column_of_cell(actcell);
1521 int actrow = tabular.row_of_cell(actcell);
1522 for (int r1 = 0, r2 = actrow;
1523 r1 < paste_tabular->rows() && r2 < tabular.rows();
1525 for (int c1 = 0, c2 = actcol;
1526 c1 < paste_tabular->columns() && c2 < tabular.columns();
1528 if (paste_tabular->isPartOfMultiColumn(r1, c1) &&
1529 tabular.isPartOfMultiColumn(r2, c2))
1531 if (paste_tabular->isPartOfMultiColumn(r1, c1)) {
1535 if (tabular.isPartOfMultiColumn(r2, c2)) {
1539 InsetText & inset = tabular.getCellInset(r2, c2);
1540 inset = paste_tabular->getCellInset(r1, c1);
1541 inset.setOwner(this);
1549 void InsetTabular::cutSelection(LCursor & cur)
1551 if (!cur.selection())
1554 bool const track = cur.bv().buffer()->params().tracking_changes;
1556 getSelection(cur, rs, re, cs, ce);
1557 for (int i = rs; i <= re; ++i)
1558 for (int j = cs; j <= ce; ++j)
1559 cell(tabular.getCellNumber(i, j)).clear(track);
1563 bool InsetTabular::isRightToLeft(LCursor & cur)
1565 return cur.bv().getParentLanguage(this)->RightToLeft();
1569 void InsetTabular::getSelection(LCursor & cur,
1570 int & rs, int & re, int & cs, int & ce) const
1572 CursorSlice & beg = cur.selBegin();
1573 CursorSlice & end = cur.selEnd();
1574 cs = tabular.column_of_cell(beg.idx());
1575 ce = tabular.column_of_cell(end.idx());
1578 cs = tabular.column_of_cell(end.idx());
1580 ce = tabular.right_column_of_cell(end.idx());
1583 rs = tabular.row_of_cell(beg.idx());
1584 re = tabular.row_of_cell(end.idx());
1590 size_t InsetTabular::nargs() const
1592 return tabular.getNumberOfCells();
1596 LyXText * InsetTabular::getText(int idx) const
1598 return size_t(idx) < nargs() ? cell(idx).getText(0) : 0;
1602 void InsetTabular::markErased()
1604 for (idx_type idx = 0; idx < nargs(); ++idx)
1605 cell(idx).markErased();
1609 bool InsetTabular::forceDefaultParagraphs(InsetBase const *) const
1612 const int cell = tabular.getCellFromInset(in);
1615 return tabular.getPWidth(cell).zero();
1617 // this is a workaround for a crash (New, Insert->Tabular,
1618 // Insert->FootNote)
1622 // well we didn't obviously find it so maybe our owner knows more
1623 BOOST_ASSERT(owner());
1624 return owner()->forceDefaultParagraphs(in);
1630 bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
1633 if (buf.length() <= 0)
1639 string::size_type len = buf.length();
1640 string::size_type p = 0;
1642 int actcell = bv.cursor().idx();
1643 int actcol = tabular.column_of_cell(actcell);
1644 int actrow = tabular.row_of_cell(actcell);
1646 while (p < len && (p = buf.find_first_of("\t\n", p)) != string::npos) {
1654 maxCols = max(cols, maxCols);
1660 maxCols = max(cols, maxCols);
1661 LyXTabular * loctab;
1666 paste_tabular.reset(
1667 new LyXTabular(bv.buffer()->params(), rows, maxCols));
1668 paste_tabular->setOwner(this);
1669 loctab = paste_tabular.get();
1678 string::size_type op = 0;
1679 int cells = loctab->getNumberOfCells();
1682 rows = loctab->rows();
1683 int const columns = loctab->columns();
1685 while (cell < cells && p < len && row < rows &&
1686 (p = buf.find_first_of("\t\n", p)) != string::npos)
1692 // we can only set this if we are not too far right
1693 if (cols < columns) {
1694 InsetText & inset = loctab->getCellInset(cell);
1695 LyXFont const font = inset.text_.
1696 getFont(inset.paragraphs().begin(), 0);
1697 inset.setText(buf.substr(op, p - op), font);
1703 // we can only set this if we are not too far right
1704 if (cols < columns) {
1705 InsetText & inset = tabular.getCellInset(cell);
1706 LyXFont const font = inset.text_.
1707 getFont(inset.paragraphs().begin(), 0);
1708 inset.setText(buf.substr(op, p - op), font);
1713 cell = loctab->getCellNumber(row, cols);
1719 // check for the last cell if there is no trailing '\n'
1720 if (cell < cells && op < len) {
1721 InsetText & inset = loctab->getCellInset(cell);
1722 LyXFont const font = inset.text_.getFont(inset.paragraphs().begin(), 0);
1723 inset.setText(buf.substr(op, len - op), font);
1729 void InsetTabular::addPreview(PreviewLoader & loader) const
1731 int const rows = tabular.rows();
1732 int const columns = tabular.columns();
1733 for (int i = 0; i < rows; ++i) {
1734 for (int j = 0; j < columns; ++j)
1735 tabular.getCellInset(i, j).addPreview(loader);
1740 bool InsetTabular::tablemode(LCursor & cur) const
1742 return cur.selBegin().idx() != cur.selEnd().idx();
1749 string const InsetTabularMailer::name_("tabular");
1751 InsetTabularMailer::InsetTabularMailer(InsetTabular const & inset)
1752 : inset_(const_cast<InsetTabular &>(inset))
1756 string const InsetTabularMailer::inset2string(Buffer const &) const
1758 return params2string(inset_);
1762 int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
1764 istringstream data(in);
1766 lex.setStream(data);
1768 #warning CHECK verify that this is a sane value to return.
1774 string const token = lex.getString();
1782 string const token = lex.getString();
1783 if (token != "\\active_cell")
1786 cell = lex.getInteger();
1789 // This is part of the inset proper that is usually swallowed
1790 // by Buffer::readInset
1793 string const token = lex.getString();
1794 if (token != "Tabular")
1801 Buffer const & buffer = inset.buffer();
1802 inset.read(buffer, lex);
1804 // We can't set the active cell, but we can tell the frontend
1810 string const InsetTabularMailer::params2string(InsetTabular const & inset)
1814 //data << name_ << " \\active_cell " << inset.getActCell() << '\n';
1815 data << name_ << " \\active_cell " << 0 << '\n';
1816 inset.write(inset.buffer(), data);
1817 data << "\\end_inset\n";