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"
43 using lyx::graphics::PreviewLoader;
45 using lyx::support::ltrim;
46 using lyx::support::strToInt;
47 using lyx::support::strToDbl;
53 using std::istringstream;
55 using std::ostringstream;
62 int const ADD_TO_HEIGHT = 2;
63 int const ADD_TO_TABULAR_WIDTH = 2;
66 boost::scoped_ptr<LyXTabular> paste_tabular;
69 struct TabularFeature {
70 LyXTabular::Feature action;
75 TabularFeature tabularFeature[] =
77 { LyXTabular::APPEND_ROW, "append-row" },
78 { LyXTabular::APPEND_COLUMN, "append-column" },
79 { LyXTabular::DELETE_ROW, "delete-row" },
80 { LyXTabular::DELETE_COLUMN, "delete-column" },
81 { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
82 { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
83 { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
84 { LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
85 { LyXTabular::ALIGN_LEFT, "align-left" },
86 { LyXTabular::ALIGN_RIGHT, "align-right" },
87 { LyXTabular::ALIGN_CENTER, "align-center" },
88 { LyXTabular::ALIGN_BLOCK, "align-block" },
89 { LyXTabular::VALIGN_TOP, "valign-top" },
90 { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
91 { LyXTabular::VALIGN_MIDDLE, "valign-middle" },
92 { LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
93 { LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
94 { LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
95 { LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
96 { LyXTabular::M_ALIGN_LEFT, "m-align-left" },
97 { LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
98 { LyXTabular::M_ALIGN_CENTER, "m-align-center" },
99 { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
100 { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
101 { LyXTabular::M_VALIGN_MIDDLE, "m-valign-middle" },
102 { LyXTabular::MULTICOLUMN, "multicolumn" },
103 { LyXTabular::SET_ALL_LINES, "set-all-lines" },
104 { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
105 { LyXTabular::SET_LONGTABULAR, "set-longtabular" },
106 { LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
107 { LyXTabular::SET_PWIDTH, "set-pwidth" },
108 { LyXTabular::SET_MPWIDTH, "set-mpwidth" },
109 { LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
110 { LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
111 { LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
112 { LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
113 { LyXTabular::SET_USEBOX, "set-usebox" },
114 { LyXTabular::SET_LTHEAD, "set-lthead" },
115 { LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
116 { LyXTabular::SET_LTFOOT, "set-ltfoot" },
117 { LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
118 { LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
119 { LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
120 { LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
121 { LyXTabular::LAST_ACTION, "" }
125 class FeatureEqual : public std::unary_function<TabularFeature, bool> {
127 FeatureEqual(LyXTabular::Feature feature)
128 : feature_(feature) {}
129 bool operator()(TabularFeature const & tf) const {
130 return tf.action == feature_;
133 LyXTabular::Feature feature_;
139 string const featureAsString(LyXTabular::Feature feature)
141 TabularFeature * end = tabularFeature +
142 sizeof(tabularFeature) / sizeof(TabularFeature);
143 TabularFeature * it = std::find_if(tabularFeature, end,
144 FeatureEqual(feature));
145 return (it == end) ? string() : it->feature;
149 bool InsetTabular::hasPasteBuffer() const
151 return (paste_tabular.get() != 0);
155 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
156 : tabular(buf.params(), max(rows, 1), max(columns, 1)),
157 buffer_(&buf), cursorx_(0)
161 InsetTabular::InsetTabular(InsetTabular const & tab)
162 : UpdatableInset(tab), tabular(tab.tabular),
163 buffer_(tab.buffer_), cursorx_(0)
167 InsetTabular::~InsetTabular()
169 InsetTabularMailer(*this).hideDialog();
173 auto_ptr<InsetBase> InsetTabular::clone() const
175 return auto_ptr<InsetBase>(new InsetTabular(*this));
179 Buffer const & InsetTabular::buffer() const
185 void InsetTabular::buffer(Buffer const * b)
191 void InsetTabular::write(Buffer const & buf, ostream & os) const
193 os << "Tabular" << endl;
194 tabular.write(buf, os);
198 void InsetTabular::read(Buffer const & buf, LyXLex & lex)
200 bool const old_format = (lex.getString() == "\\LyXTable");
202 tabular.read(buf, lex);
208 string token = lex.getString();
209 while (lex.isOK() && (token != "\\end_inset")) {
211 token = lex.getString();
213 if (token != "\\end_inset") {
214 lex.printError("Missing \\end_inset at this point. "
220 void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
222 //lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
223 // mi.base.textwidth << "\n";
225 lyxerr << "InsetTabular::metrics: need bv" << endl;
229 for (int i = 0, cell = -1; i < tabular.rows(); ++i) {
232 for (int j = 0; j < tabular.columns(); ++j) {
233 if (tabular.isPartOfMultiColumn(i, j))
239 tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
240 tabular.getCellInset(cell).metrics(m, dim);
241 maxAsc = max(maxAsc, dim.asc);
242 maxDesc = max(maxDesc, dim.des);
243 tabular.setWidthOfCell(cell, dim.wid);
245 tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
246 tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
249 dim.asc = tabular.getAscentOfRow(0);
250 dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1;
251 dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH;
256 void InsetTabular::draw(PainterInfo & pi, int x, int y) const
258 //lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
260 BufferView * bv = pi.base.bv;
261 setPosCache(pi, x, y);
264 x += ADD_TO_TABULAR_WIDTH;
267 first_visible_cell = -1;
268 for (int i = 0; i < tabular.rows(); ++i) {
270 idx = tabular.getCellNumber(i, 0);
271 if (y + tabular.getDescentOfRow(i) <= 0 &&
272 y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
274 y += tabular.getDescentOfRow(i) +
275 tabular.getAscentOfRow(i + 1) +
276 tabular.getAdditionalHeight(i + 1);
279 for (int j = 0; j < tabular.columns(); ++j) {
280 if (nx > bv->workWidth())
282 if (tabular.isPartOfMultiColumn(i, j))
284 if (first_visible_cell < 0)
285 first_visible_cell = idx;
286 if (bv->cursor().selection())
287 drawCellSelection(pi, nx, y, i, j, idx);
289 int const cx = nx + tabular.getBeginningOfTextInCell(idx);
290 cell(idx).draw(pi, cx, y);
291 drawCellLines(pi.pain, nx, y, i, idx);
292 nx += tabular.getWidthOfColumn(idx);
296 // Would be nice, but for some completely unfathomable reason,
297 // on a col resize to a new fixed width, even though the insettexts
298 // are resized, the cell isn't, but drawing all cells in a tall table
299 // has the desired effect somehow. Complete dark magic.
301 // avoiding drawing the rest of a long table is
302 // a pretty big speedup
303 if (y > bv->workHeight())
307 y += tabular.getDescentOfRow(i) +
308 tabular.getAscentOfRow(i + 1) +
309 tabular.getAdditionalHeight(i + 1);
314 void InsetTabular::drawCellLines(Painter & pain, int x, int y,
315 int row, int cell) const
317 int x2 = x + tabular.getWidthOfColumn(cell);
320 if (!tabular.topAlreadyDrawn(cell)) {
321 on_off = !tabular.topLine(cell);
322 pain.line(x, y - tabular.getAscentOfRow(row),
323 x2, y - tabular.getAscentOfRow(row),
324 on_off ? LColor::tabularonoffline : LColor::tabularline,
325 on_off ? Painter::line_onoffdash : Painter::line_solid);
327 on_off = !tabular.bottomLine(cell);
328 pain.line(x, y + tabular.getDescentOfRow(row),
329 x2, y + tabular.getDescentOfRow(row),
330 on_off ? LColor::tabularonoffline : LColor::tabularline,
331 on_off ? Painter::line_onoffdash : Painter::line_solid);
332 if (!tabular.leftAlreadyDrawn(cell)) {
333 on_off = !tabular.leftLine(cell);
334 pain.line(x, y - tabular.getAscentOfRow(row),
335 x, y + tabular.getDescentOfRow(row),
336 on_off ? LColor::tabularonoffline : LColor::tabularline,
337 on_off ? Painter::line_onoffdash : Painter::line_solid);
339 on_off = !tabular.rightLine(cell);
340 pain.line(x2 - tabular.getAdditionalWidth(cell),
341 y - tabular.getAscentOfRow(row),
342 x2 - tabular.getAdditionalWidth(cell),
343 y + tabular.getDescentOfRow(row),
344 on_off ? LColor::tabularonoffline : LColor::tabularline,
345 on_off ? Painter::line_onoffdash : Painter::line_solid);
349 void InsetTabular::drawCellSelection(PainterInfo & pi, int x, int y,
350 int row, int column, int cell) const
352 LCursor & cur = pi.base.bv->cursor();
353 BOOST_ASSERT(cur.selection());
354 if (tablemode(cur)) {
356 getSelection(cur, rs, re, cs, ce);
357 if (column >= cs && column <= ce && row >= rs && row <= re) {
358 int w = tabular.getWidthOfColumn(cell);
359 int h = tabular.getAscentOfRow(row) + tabular.getDescentOfRow(row)-1;
360 pi.pain.fillRectangle(x, y - tabular.getAscentOfRow(row) + 1,
361 w, h, LColor::selection);
367 string const InsetTabular::editMessage() const
369 return _("Opened table");
373 void InsetTabular::edit(LCursor & cur, bool left)
375 lyxerr << "InsetTabular::edit: " << this << endl;
379 if (isRightToLeft(cur))
380 cell = tabular.getLastCellInRow(0);
384 if (isRightToLeft(cur))
385 cell = tabular.getFirstCellInRow(tabular.rows()-1);
387 cell = tabular.getNumberOfCells() - 1;
389 cur.selection() = false;
391 cur.bv().fitCursor();
397 InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y)
399 //lyxerr << "InsetTabular::editXY: " << this << endl;
400 cur.selection() = false;
402 return setPos(cur, x, y);
403 //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
407 void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
409 lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
410 //lyxerr << " cur:\n" << cur << endl;
411 CursorSlice sl = cur.top();
412 LCursor & bvcur = cur.bv().cursor();
414 switch (cmd.action) {
416 case LFUN_MOUSE_PRESS:
417 // we'll pop up the table dialog on release
418 if (cmd.button() == mouse_button::button3)
420 cur.selection() = false;
421 setPos(cur, cmd.x, cmd.y);
424 //if (cmd.button() == mouse_button::button2)
425 // dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
426 //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
429 case LFUN_MOUSE_MOTION:
430 if (cmd.button() != mouse_button::button1)
432 // ignore motions deeper nested than the real anchor
433 if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
435 setPos(cur, cmd.x, cmd.y);
436 bvcur.setCursor(cur, true);
437 //lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
440 case LFUN_MOUSE_RELEASE:
441 //lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
442 if (cmd.button() == mouse_button::button3)
443 InsetTabularMailer(*this).showDialog(&cur.bv());
446 case LFUN_CELL_BACKWARD:
448 cur.selection() = false;
451 case LFUN_CELL_FORWARD:
453 cur.selection() = false;
456 case LFUN_SCROLL_INSET:
457 if (cmd.argument.empty())
459 if (cmd.argument.find('.') != cmd.argument.npos)
460 scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
462 scroll(cur.bv(), strToInt(cmd.argument));
467 cell(cur.idx()).dispatch(cur, cmd);
468 cur.dispatched(); // override the cell's decision
470 isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
471 if (sl == cur.top()) {
472 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
479 cell(cur.idx()).dispatch(cur, cmd);
480 cur.dispatched(); // override the cell's decision
482 isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
483 if (sl == cur.top()) {
484 cmd = FuncRequest(LFUN_FINISHED_LEFT);
491 cell(cur.idx()).dispatch(cur, cmd);
492 cur.dispatched(); // override the cell's decision
494 if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) {
495 cur.idx() = tabular.getCellBelow(cur.idx());
500 if (sl == cur.top()) {
501 cmd = FuncRequest(LFUN_FINISHED_DOWN);
508 cell(cur.idx()).dispatch(cur, cmd);
509 cur.dispatched(); // override the cell's decision
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))
583 if (copySelection(cur)) {
584 recordUndo(cur, Undo::DELETE);
591 recordUndo(cur, Undo::DELETE);
595 cell(cur.idx()).dispatch(cur, cmd);
599 if (!cur.selection())
605 case LFUN_PASTESELECTION: {
606 string const clip = cur.bv().getClipboard();
609 if (clip.find('\t') != string::npos) {
613 size_t len = clip.length();
614 for (size_t p = 0; p < len; ++p) {
615 p = clip.find_first_of("\t\n", p);
616 if (p == string::npos)
625 maxCols = max(cols, maxCols);
630 maxCols = max(cols, maxCols);
633 new LyXTabular(cur.buffer().params(), rows, maxCols));
635 string::size_type op = 0;
637 int cells = paste_tabular->getNumberOfCells();
640 for (size_t p = 0; cell < cells && p < len; ++p) {
641 p = clip.find_first_of("\t\n", p);
642 if (p == string::npos || p >= len)
646 paste_tabular->getCellInset(cell).
647 setText(clip.substr(op, p - op), font);
652 paste_tabular->getCellInset(cell).
653 setText(clip.substr(op, p - op), font);
654 while (cols++ < maxCols)
661 // check for the last cell if there is no trailing '\n'
662 if (cell < cells && op < len)
663 paste_tabular->getCellInset(cell).
664 setText(clip.substr(op, len - op), font);
665 } else if (!insertAsciiString(cur.bv(), clip, true)) {
666 // so that the clipboard is used and it goes on
668 // and executes LFUN_PASTESELECTION in insettext!
669 paste_tabular.reset();
675 if (hasPasteBuffer()) {
676 recordUndo(cur, Undo::INSERT);
680 cell(cur.idx()).dispatch(cur, cmd);
684 // we try to handle this event in the insets dispatch function.
685 cell(cur.idx()).dispatch(cur, cmd);
689 InsetTabularMailer(*this).updateDialog(&cur.bv());
693 // function sets an object as defined in func_status.h:
694 // states OK, Unknown, Disabled, On, Off.
695 bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
696 FuncStatus & status) const
698 switch (cmd.action) {
699 case LFUN_TABULAR_FEATURE: {
700 int actcell = cur.idx();
701 int action = LyXTabular::LAST_ACTION;
703 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
704 string const tmp = tabularFeature[i].feature;
705 if (tmp == cmd.argument.substr(0, tmp.length())) {
706 action = tabularFeature[i].action;
710 if (action == LyXTabular::LAST_ACTION) {
712 status.unknown(true);
716 string const argument
717 = ltrim(cmd.argument.substr(tabularFeature[i].feature.length()));
719 int sel_row_start = 0;
722 LyXTabular::ltType dummyltt;
725 getSelection(cur, sel_row_start, sel_row_end, dummy, dummy);
728 case LyXTabular::SET_PWIDTH:
729 case LyXTabular::SET_MPWIDTH:
730 case LyXTabular::SET_SPECIAL_COLUMN:
731 case LyXTabular::SET_SPECIAL_MULTI:
732 case LyXTabular::APPEND_ROW:
733 case LyXTabular::APPEND_COLUMN:
734 case LyXTabular::DELETE_ROW:
735 case LyXTabular::DELETE_COLUMN:
736 case LyXTabular::SET_ALL_LINES:
737 case LyXTabular::UNSET_ALL_LINES:
741 case LyXTabular::MULTICOLUMN:
742 status.setOnOff(tabular.isMultiColumn(actcell));
745 case LyXTabular::M_TOGGLE_LINE_TOP:
747 case LyXTabular::TOGGLE_LINE_TOP:
748 status.setOnOff(tabular.topLine(actcell, flag));
751 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
753 case LyXTabular::TOGGLE_LINE_BOTTOM:
754 status.setOnOff(tabular.bottomLine(actcell, flag));
757 case LyXTabular::M_TOGGLE_LINE_LEFT:
759 case LyXTabular::TOGGLE_LINE_LEFT:
760 status.setOnOff(tabular.leftLine(actcell, flag));
763 case LyXTabular::M_TOGGLE_LINE_RIGHT:
765 case LyXTabular::TOGGLE_LINE_RIGHT:
766 status.setOnOff(tabular.rightLine(actcell, flag));
769 case LyXTabular::M_ALIGN_LEFT:
771 case LyXTabular::ALIGN_LEFT:
772 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_LEFT);
775 case LyXTabular::M_ALIGN_RIGHT:
777 case LyXTabular::ALIGN_RIGHT:
778 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_RIGHT);
781 case LyXTabular::M_ALIGN_CENTER:
783 case LyXTabular::ALIGN_CENTER:
784 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_CENTER);
787 case LyXTabular::ALIGN_BLOCK:
788 status.enabled(!tabular.getPWidth(actcell).zero());
789 status.setOnOff(tabular.getAlignment(actcell, flag) == LYX_ALIGN_BLOCK);
792 case LyXTabular::M_VALIGN_TOP:
794 case LyXTabular::VALIGN_TOP:
796 tabular.getVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP);
799 case LyXTabular::M_VALIGN_BOTTOM:
801 case LyXTabular::VALIGN_BOTTOM:
803 tabular.getVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM);
806 case LyXTabular::M_VALIGN_MIDDLE:
808 case LyXTabular::VALIGN_MIDDLE:
810 tabular.getVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_MIDDLE);
813 case LyXTabular::SET_LONGTABULAR:
814 status.setOnOff(tabular.isLongTabular());
817 case LyXTabular::UNSET_LONGTABULAR:
818 status.setOnOff(!tabular.isLongTabular());
821 case LyXTabular::SET_ROTATE_TABULAR:
822 status.setOnOff(tabular.getRotateTabular());
825 case LyXTabular::UNSET_ROTATE_TABULAR:
826 status.setOnOff(!tabular.getRotateTabular());
829 case LyXTabular::SET_ROTATE_CELL:
830 status.setOnOff(tabular.getRotateCell(actcell));
833 case LyXTabular::UNSET_ROTATE_CELL:
834 status.setOnOff(!tabular.getRotateCell(actcell));
837 case LyXTabular::SET_USEBOX:
838 status.setOnOff(strToInt(argument) == tabular.getUsebox(actcell));
841 case LyXTabular::SET_LTFIRSTHEAD:
842 status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
845 case LyXTabular::SET_LTHEAD:
846 status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
849 case LyXTabular::SET_LTFOOT:
850 status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
853 case LyXTabular::SET_LTLASTFOOT:
854 status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
857 case LyXTabular::SET_LTNEWPAGE:
858 status.setOnOff(tabular.getLTNewPage(sel_row_start));
863 status.enabled(false);
870 // we try to handle this event in the insets dispatch function.
871 return cell(cur.idx()).getStatus(cur, cmd, status);
876 int InsetTabular::latex(Buffer const & buf, ostream & os,
877 OutputParams const & runparams) const
879 return tabular.latex(buf, os, runparams);
883 int InsetTabular::plaintext(Buffer const & buf, ostream & os,
884 OutputParams const & runparams) const
886 int dp = runparams.linelen ? ownerPar(buf, this).params().depth() : 0;
887 return tabular.plaintext(buf, os, runparams, dp, false, 0);
891 int InsetTabular::linuxdoc(Buffer const & buf, ostream & os,
892 OutputParams const & runparams) const
894 return tabular.linuxdoc(buf,os, runparams);
898 int InsetTabular::docbook(Buffer const & buf, ostream & os,
899 OutputParams const & runparams) const
902 InsetOld * master = 0;
905 #warning Why not pass a proper DocIterator here?
908 // if the table is inside a float it doesn't need the informaltable
909 // wrapper. Search for it.
910 for (master = owner(); master; master = master->owner())
911 if (master->lyxCode() == InsetOld::FLOAT_CODE)
916 os << "<informaltable>";
917 if (runparams.mixed_content)
921 ret += tabular.docbook(buf, os, runparams);
923 os << "</informaltable>";
924 if (runparams.mixed_content)
932 void InsetTabular::validate(LaTeXFeatures & features) const
934 tabular.validate(features);
938 InsetText const & InsetTabular::cell(int idx) const
940 return tabular.getCellInset(idx);
944 InsetText & InsetTabular::cell(int idx)
946 return tabular.getCellInset(idx);
950 void InsetTabular::getCursorPos(LCursor const & cur, int & x, int & y) const
952 cell(cur.idx()).getCursorPos(cur, x, y);
956 InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
959 int dist_min = 1000000;
960 for (idx_type i = 0; i < nargs(); ++i) {
961 int d = getText(i)->dist(x, y);
968 InsetBase * inset = cell(cur.idx()).text_.editXY(cur, x, y);
969 //lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
974 int InsetTabular::getCellXPos(int cell) const
978 for (; !tabular.isFirstCellInRow(c); --c)
980 int lx = tabular.getWidthOfColumn(cell);
981 for (; c < cell; ++c)
982 lx += tabular.getWidthOfColumn(c);
984 return lx - tabular.getWidthOfColumn(cell) + xo_;
988 void InsetTabular::resetPos(LCursor & cur) const
990 BufferView & bv = cur.bv();
991 int actcell = cur.idx();
992 int actcol = tabular.column_of_cell(actcell);
994 int const offset = ADD_TO_TABULAR_WIDTH + 2;
995 int new_x = getCellXPos(actcell) + offset;
996 int old_x = cursorx_;
998 // cursor.x(getCellXPos(actcell) + offset);
999 if (actcol < tabular.columns() - 1 && scroll(false) &&
1000 tabular.getWidthOfTabular() < bv.workWidth()-20)
1003 } else if (cursorx_ - offset > 20 &&
1004 cursorx_ - offset + tabular.getWidthOfColumn(actcell)
1005 > bv.workWidth() - 20) {
1006 scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
1007 } else if (cursorx_ - offset < 20) {
1008 scroll(bv, 20 - cursorx_ + offset);
1009 } else if (scroll() && xo_ > 20 &&
1010 xo_ + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
1011 scroll(bv, old_x - cursorx_);
1014 InsetTabularMailer(*this).updateDialog(&bv);
1018 void InsetTabular::moveNextCell(LCursor & cur)
1020 lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur.top() << endl;
1021 if (isRightToLeft(cur)) {
1022 lyxerr << "InsetTabular::moveNextCell A cur: " << endl;
1023 if (tabular.isFirstCellInRow(cur.idx())) {
1024 int row = tabular.row_of_cell(cur.idx());
1025 if (row == tabular.rows() - 1)
1027 cur.idx() = tabular.getLastCellInRow(row);
1028 cur.idx() = tabular.getCellBelow(cur.idx());
1035 lyxerr << "InsetTabular::moveNextCell B cur: " << endl;
1036 if (tabular.isLastCell(cur.idx()))
1042 lyxerr << "InsetTabular::moveNextCell 2 cur: " << cur.top() << endl;
1047 void InsetTabular::movePrevCell(LCursor & cur)
1049 if (isRightToLeft(cur)) {
1050 if (tabular.isLastCellInRow(cur.idx())) {
1051 int row = tabular.row_of_cell(cur.idx());
1054 cur.idx() = tabular.getFirstCellInRow(row);
1055 cur.idx() = tabular.getCellAbove(cur.idx());
1057 if (tabular.isLastCell(cur.idx()))
1062 if (cur.idx() == 0) // first cell
1072 bool InsetTabular::tabularFeatures(LCursor & cur, string const & what)
1074 LyXTabular::Feature action = LyXTabular::LAST_ACTION;
1077 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
1078 string const tmp = tabularFeature[i].feature;
1080 if (tmp == what.substr(0, tmp.length())) {
1081 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
1082 //tabularFeatures[i].feature.length())) {
1083 action = tabularFeature[i].action;
1087 if (action == LyXTabular::LAST_ACTION)
1091 ltrim(what.substr(tabularFeature[i].feature.length()));
1092 tabularFeatures(cur, action, val);
1099 void checkLongtableSpecial(LyXTabular::ltType & ltt,
1100 string const & special, bool & flag)
1102 if (special == "dl_above") {
1105 } else if (special == "dl_below") {
1106 ltt.bottomDL = flag;
1108 } else if (special == "empty") {
1120 void InsetTabular::tabularFeatures(LCursor & cur,
1121 LyXTabular::Feature feature, string const & value)
1123 BufferView & bv = cur.bv();
1124 int actcell = cur.idx();
1129 bool setLines = false;
1130 LyXAlignment setAlign = LYX_ALIGN_LEFT;
1131 LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
1135 case LyXTabular::M_ALIGN_LEFT:
1136 case LyXTabular::ALIGN_LEFT:
1137 setAlign = LYX_ALIGN_LEFT;
1140 case LyXTabular::M_ALIGN_RIGHT:
1141 case LyXTabular::ALIGN_RIGHT:
1142 setAlign = LYX_ALIGN_RIGHT;
1145 case LyXTabular::M_ALIGN_CENTER:
1146 case LyXTabular::ALIGN_CENTER:
1147 setAlign = LYX_ALIGN_CENTER;
1150 case LyXTabular::ALIGN_BLOCK:
1151 setAlign = LYX_ALIGN_BLOCK;
1154 case LyXTabular::M_VALIGN_TOP:
1155 case LyXTabular::VALIGN_TOP:
1156 setVAlign = LyXTabular::LYX_VALIGN_TOP;
1159 case LyXTabular::M_VALIGN_BOTTOM:
1160 case LyXTabular::VALIGN_BOTTOM:
1161 setVAlign = LyXTabular::LYX_VALIGN_BOTTOM;
1164 case LyXTabular::M_VALIGN_MIDDLE:
1165 case LyXTabular::VALIGN_MIDDLE:
1166 setVAlign = LyXTabular::LYX_VALIGN_MIDDLE;
1173 recordUndo(cur, Undo::ATOMIC);
1175 getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end);
1176 int row = tabular.row_of_cell(actcell);
1177 int column = tabular.column_of_cell(actcell);
1179 LyXTabular::ltType ltt;
1183 case LyXTabular::SET_PWIDTH: {
1184 LyXLength const len(value);
1185 tabular.setColumnPWidth(actcell, len);
1187 && tabular.getAlignment(actcell, true) == LYX_ALIGN_BLOCK)
1188 tabularFeatures(cur, LyXTabular::ALIGN_CENTER, string());
1189 else if (!len.zero()
1190 && tabular.getAlignment(actcell, true) != LYX_ALIGN_BLOCK)
1191 tabularFeatures(cur, LyXTabular::ALIGN_BLOCK, string());
1195 case LyXTabular::SET_MPWIDTH:
1196 tabular.setMColumnPWidth(actcell, LyXLength(value));
1199 case LyXTabular::SET_SPECIAL_COLUMN:
1200 case LyXTabular::SET_SPECIAL_MULTI:
1201 tabular.setAlignSpecial(actcell,value,feature);
1204 case LyXTabular::APPEND_ROW:
1205 // append the row into the tabular
1206 tabular.appendRow(bv.buffer()->params(), actcell);
1209 case LyXTabular::APPEND_COLUMN:
1210 // append the column into the tabular
1211 tabular.appendColumn(bv.buffer()->params(), actcell);
1212 actcell = tabular.getCellNumber(row, column);
1215 case LyXTabular::DELETE_ROW:
1216 for (int i = sel_row_start; i <= sel_row_end; ++i)
1217 tabular.deleteRow(sel_row_start);
1218 if (sel_row_start >= tabular.rows())
1220 actcell = tabular.getCellNumber(sel_row_start, column);
1221 cur.selection() = false;
1224 case LyXTabular::DELETE_COLUMN:
1225 for (int i = sel_col_start; i <= sel_col_end; ++i)
1226 tabular.deleteColumn(sel_col_start);
1227 if (sel_col_start >= tabular.columns())
1229 actcell = tabular.getCellNumber(row, sel_col_start);
1230 cur.selection() = false;
1233 case LyXTabular::M_TOGGLE_LINE_TOP:
1235 case LyXTabular::TOGGLE_LINE_TOP: {
1236 bool lineSet = !tabular.topLine(actcell, flag);
1237 for (int i = sel_row_start; i <= sel_row_end; ++i)
1238 for (int j = sel_col_start; j <= sel_col_end; ++j)
1240 tabular.getCellNumber(i, j),
1245 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1247 case LyXTabular::TOGGLE_LINE_BOTTOM: {
1248 bool lineSet = !tabular.bottomLine(actcell, flag);
1249 for (int i = sel_row_start; i <= sel_row_end; ++i)
1250 for (int j = sel_col_start; j <= sel_col_end; ++j)
1251 tabular.setBottomLine(
1252 tabular.getCellNumber(i, j),
1258 case LyXTabular::M_TOGGLE_LINE_LEFT:
1260 case LyXTabular::TOGGLE_LINE_LEFT: {
1261 bool lineSet = !tabular.leftLine(actcell, flag);
1262 for (int i = sel_row_start; i <= sel_row_end; ++i)
1263 for (int j = sel_col_start; j <= sel_col_end; ++j)
1264 tabular.setLeftLine(
1265 tabular.getCellNumber(i,j),
1271 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1273 case LyXTabular::TOGGLE_LINE_RIGHT: {
1274 bool lineSet = !tabular.rightLine(actcell, flag);
1275 for (int i = sel_row_start; i <= sel_row_end; ++i)
1276 for (int j = sel_col_start; j <= sel_col_end; ++j)
1277 tabular.setRightLine(
1278 tabular.getCellNumber(i,j),
1284 case LyXTabular::M_ALIGN_LEFT:
1285 case LyXTabular::M_ALIGN_RIGHT:
1286 case LyXTabular::M_ALIGN_CENTER:
1288 case LyXTabular::ALIGN_LEFT:
1289 case LyXTabular::ALIGN_RIGHT:
1290 case LyXTabular::ALIGN_CENTER:
1291 case LyXTabular::ALIGN_BLOCK:
1292 for (int i = sel_row_start; i <= sel_row_end; ++i)
1293 for (int j = sel_col_start; j <= sel_col_end; ++j)
1294 tabular.setAlignment(
1295 tabular.getCellNumber(i, j),
1300 case LyXTabular::M_VALIGN_TOP:
1301 case LyXTabular::M_VALIGN_BOTTOM:
1302 case LyXTabular::M_VALIGN_MIDDLE:
1304 case LyXTabular::VALIGN_TOP:
1305 case LyXTabular::VALIGN_BOTTOM:
1306 case LyXTabular::VALIGN_MIDDLE:
1307 for (int i = sel_row_start; i <= sel_row_end; ++i)
1308 for (int j = sel_col_start; j <= sel_col_end; ++j)
1309 tabular.setVAlignment(
1310 tabular.getCellNumber(i, j),
1314 case LyXTabular::MULTICOLUMN: {
1315 if (sel_row_start != sel_row_end) {
1316 #ifdef WITH_WARNINGS
1317 #warning Need I say it ? This is horrible.
1319 Alert::error(_("Error setting multicolumn"),
1320 _("You cannot set multicolumn vertically."));
1324 // just multicol for one Single Cell
1325 if (!hasSelection()) {
1326 // check whether we are completly in a multicol
1327 if (tabular.isMultiColumn(actcell))
1328 tabular.unsetMultiColumn(actcell);
1330 tabular.setMultiColumn(bv.buffer(), actcell, 1);
1333 // we have a selection so this means we just add all this
1334 // cells to form a multicolumn cell
1338 if (sel_cell_start > sel_cell_end) {
1339 s_start = sel_cell_end;
1340 s_end = sel_cell_start;
1342 s_start = sel_cell_start;
1343 s_end = sel_cell_end;
1345 tabular.setMultiColumn(bv.buffer(), s_start, s_end - s_start + 1);
1348 cur.selection() = false;
1352 case LyXTabular::SET_ALL_LINES:
1354 case LyXTabular::UNSET_ALL_LINES:
1356 for (int i = sel_row_start; i <= sel_row_end; ++i)
1357 for (int j = sel_col_start; j <= sel_col_end; ++j)
1358 tabular.setAllLines(
1359 tabular.getCellNumber(i,j), setLines);
1363 case LyXTabular::SET_LONGTABULAR:
1364 tabular.setLongTabular(true);
1367 case LyXTabular::UNSET_LONGTABULAR:
1368 tabular.setLongTabular(false);
1371 case LyXTabular::SET_ROTATE_TABULAR:
1372 tabular.setRotateTabular(true);
1375 case LyXTabular::UNSET_ROTATE_TABULAR:
1376 tabular.setRotateTabular(false);
1379 case LyXTabular::SET_ROTATE_CELL:
1380 for (int i = sel_row_start; i <= sel_row_end; ++i)
1381 for (int j = sel_col_start; j <= sel_col_end; ++j)
1382 tabular.setRotateCell(
1383 tabular.getCellNumber(i, j), true);
1386 case LyXTabular::UNSET_ROTATE_CELL:
1387 for (int i = sel_row_start; i <= sel_row_end; ++i)
1388 for (int j = sel_col_start; j <= sel_col_end; ++j)
1389 tabular.setRotateCell(
1390 tabular.getCellNumber(i, j), false);
1393 case LyXTabular::SET_USEBOX: {
1394 LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
1395 if (val == tabular.getUsebox(actcell))
1396 val = LyXTabular::BOX_NONE;
1397 for (int i = sel_row_start; i <= sel_row_end; ++i)
1398 for (int j = sel_col_start; j <= sel_col_end; ++j)
1399 tabular.setUsebox(tabular.getCellNumber(i, j), val);
1403 case LyXTabular::UNSET_LTFIRSTHEAD:
1405 case LyXTabular::SET_LTFIRSTHEAD:
1406 tabular.getRowOfLTFirstHead(row, ltt);
1407 checkLongtableSpecial(ltt, value, flag);
1408 tabular.setLTHead(row, flag, ltt, true);
1411 case LyXTabular::UNSET_LTHEAD:
1413 case LyXTabular::SET_LTHEAD:
1414 tabular.getRowOfLTHead(row, ltt);
1415 checkLongtableSpecial(ltt, value, flag);
1416 tabular.setLTHead(row, flag, ltt, false);
1419 case LyXTabular::UNSET_LTFOOT:
1421 case LyXTabular::SET_LTFOOT:
1422 tabular.getRowOfLTFoot(row, ltt);
1423 checkLongtableSpecial(ltt, value, flag);
1424 tabular.setLTFoot(row, flag, ltt, false);
1427 case LyXTabular::UNSET_LTLASTFOOT:
1429 case LyXTabular::SET_LTLASTFOOT:
1430 tabular.getRowOfLTLastFoot(row, ltt);
1431 checkLongtableSpecial(ltt, value, flag);
1432 tabular.setLTFoot(row, flag, ltt, true);
1435 case LyXTabular::SET_LTNEWPAGE:
1436 tabular.setLTNewPage(row, !tabular.getLTNewPage(row));
1439 // dummy stuff just to avoid warnings
1440 case LyXTabular::LAST_ACTION:
1444 InsetTabularMailer(*this).updateDialog(&bv);
1448 bool InsetTabular::showInsetDialog(BufferView * bv) const
1450 InsetTabularMailer(*this).showDialog(bv);
1455 void InsetTabular::openLayoutDialog(BufferView * bv) const
1457 InsetTabularMailer(*this).showDialog(bv);
1461 void InsetTabular::getLabelList(Buffer const & buffer,
1462 vector<string> & list) const
1464 tabular.getLabelList(buffer, list);
1468 bool InsetTabular::copySelection(LCursor & cur)
1470 if (!cur.selection())
1474 getSelection(cur, rs, re, cs, ce);
1476 paste_tabular.reset(new LyXTabular(tabular));
1478 for (int i = 0; i < rs; ++i)
1479 paste_tabular->deleteRow(0);
1481 int const rows = re - rs + 1;
1482 while (paste_tabular->rows() > rows)
1483 paste_tabular->deleteRow(rows);
1485 paste_tabular->setTopLine(0, true, true);
1486 paste_tabular->setBottomLine(paste_tabular->getFirstCellInRow(rows - 1),
1489 for (int i = 0; i < cs; ++i)
1490 paste_tabular->deleteColumn(0);
1492 int const columns = ce - cs + 1;
1493 while (paste_tabular->columns() > columns)
1494 paste_tabular->deleteColumn(columns);
1496 paste_tabular->setLeftLine(0, true, true);
1497 paste_tabular->setRightLine(paste_tabular->getLastCellInRow(0),
1501 OutputParams const runparams;
1502 paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
1503 cur.bv().stuffClipboard(os.str());
1508 bool InsetTabular::pasteSelection(LCursor & cur)
1512 int actcell = cur.idx();
1513 int actcol = tabular.column_of_cell(actcell);
1514 int actrow = tabular.row_of_cell(actcell);
1515 for (int r1 = 0, r2 = actrow;
1516 r1 < paste_tabular->rows() && r2 < tabular.rows();
1518 for (int c1 = 0, c2 = actcol;
1519 c1 < paste_tabular->columns() && c2 < tabular.columns();
1521 if (paste_tabular->isPartOfMultiColumn(r1, c1) &&
1522 tabular.isPartOfMultiColumn(r2, c2))
1524 if (paste_tabular->isPartOfMultiColumn(r1, c1)) {
1528 if (tabular.isPartOfMultiColumn(r2, c2)) {
1532 InsetText & inset = tabular.getCellInset(r2, c2);
1533 inset = paste_tabular->getCellInset(r1, c1);
1541 void InsetTabular::cutSelection(LCursor & cur)
1543 if (!cur.selection())
1546 bool const track = cur.buffer().params().tracking_changes;
1548 getSelection(cur, rs, re, cs, ce);
1549 for (int i = rs; i <= re; ++i)
1550 for (int j = cs; j <= ce; ++j)
1551 cell(tabular.getCellNumber(i, j)).clear(track);
1555 bool InsetTabular::isRightToLeft(LCursor & cur)
1557 return cur.bv().getParentLanguage(this)->RightToLeft();
1561 void InsetTabular::getSelection(LCursor & cur,
1562 int & rs, int & re, int & cs, int & ce) const
1564 CursorSlice const & beg = cur.selBegin();
1565 CursorSlice const & end = cur.selEnd();
1566 cs = tabular.column_of_cell(beg.idx());
1567 ce = tabular.column_of_cell(end.idx());
1570 cs = tabular.column_of_cell(end.idx());
1572 ce = tabular.right_column_of_cell(end.idx());
1575 rs = tabular.row_of_cell(beg.idx());
1576 re = tabular.row_of_cell(end.idx());
1582 size_t InsetTabular::nargs() const
1584 return tabular.getNumberOfCells();
1588 LyXText * InsetTabular::getText(int idx) const
1590 return size_t(idx) < nargs() ? cell(idx).getText(0) : 0;
1594 void InsetTabular::markErased()
1596 for (idx_type idx = 0; idx < nargs(); ++idx)
1597 cell(idx).markErased();
1601 bool InsetTabular::forceDefaultParagraphs(InsetBase const *) const
1604 const int cell = tabular.getCellFromInset(in);
1607 return tabular.getPWidth(cell).zero();
1609 // this is a workaround for a crash (New, Insert->Tabular,
1610 // Insert->FootNote)
1614 // well we didn't obviously find it so maybe our owner knows more
1615 BOOST_ASSERT(owner());
1616 return owner()->forceDefaultParagraphs(in);
1622 bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
1625 if (buf.length() <= 0)
1631 string::size_type len = buf.length();
1632 string::size_type p = 0;
1634 int actcell = bv.cursor().idx();
1635 int actcol = tabular.column_of_cell(actcell);
1636 int actrow = tabular.row_of_cell(actcell);
1638 while (p < len && (p = buf.find_first_of("\t\n", p)) != string::npos) {
1646 maxCols = max(cols, maxCols);
1652 maxCols = max(cols, maxCols);
1653 LyXTabular * loctab;
1658 paste_tabular.reset(
1659 new LyXTabular(bv.buffer()->params(), rows, maxCols));
1660 loctab = paste_tabular.get();
1669 string::size_type op = 0;
1670 int cells = loctab->getNumberOfCells();
1673 rows = loctab->rows();
1674 int const columns = loctab->columns();
1676 while (cell < cells && p < len && row < rows &&
1677 (p = buf.find_first_of("\t\n", p)) != string::npos)
1683 // we can only set this if we are not too far right
1684 if (cols < columns) {
1685 InsetText & inset = loctab->getCellInset(cell);
1686 LyXFont const font = inset.text_.getFont(0, 0);
1687 inset.setText(buf.substr(op, p - op), font);
1693 // we can only set this if we are not too far right
1694 if (cols < columns) {
1695 InsetText & inset = tabular.getCellInset(cell);
1696 LyXFont const font = inset.text_.getFont(0, 0);
1697 inset.setText(buf.substr(op, p - op), font);
1702 cell = loctab->getCellNumber(row, cols);
1708 // check for the last cell if there is no trailing '\n'
1709 if (cell < cells && op < len) {
1710 InsetText & inset = loctab->getCellInset(cell);
1711 LyXFont const font = inset.text_.getFont(0, 0);
1712 inset.setText(buf.substr(op, len - op), font);
1718 void InsetTabular::addPreview(PreviewLoader & loader) const
1720 int const rows = tabular.rows();
1721 int const columns = tabular.columns();
1722 for (int i = 0; i < rows; ++i) {
1723 for (int j = 0; j < columns; ++j)
1724 tabular.getCellInset(i, j).addPreview(loader);
1729 bool InsetTabular::tablemode(LCursor & cur) const
1731 return cur.selection() && cur.selBegin().idx() != cur.selEnd().idx();
1738 string const InsetTabularMailer::name_("tabular");
1740 InsetTabularMailer::InsetTabularMailer(InsetTabular const & inset)
1741 : inset_(const_cast<InsetTabular &>(inset))
1745 string const InsetTabularMailer::inset2string(Buffer const &) const
1747 return params2string(inset_);
1751 int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
1753 istringstream data(in);
1755 lex.setStream(data);
1757 #ifdef WITH_WARNINGS
1758 #warning CHECK verify that this is a sane value to return.
1765 string const token = lex.getString();
1773 string const token = lex.getString();
1774 if (token != "\\active_cell")
1777 cell = lex.getInteger();
1780 // This is part of the inset proper that is usually swallowed
1781 // by Buffer::readInset
1784 string const token = lex.getString();
1785 if (token != "Tabular")
1792 Buffer const & buffer = inset.buffer();
1793 inset.read(buffer, lex);
1795 // We can't set the active cell, but we can tell the frontend
1801 string const InsetTabularMailer::params2string(InsetTabular const & inset)
1804 #ifdef WITH_WARNINGS
1807 //data << name_ << " \\active_cell " << inset.getActCell() << '\n';
1808 data << name_ << " \\active_cell " << 0 << '\n';
1809 inset.write(inset.buffer(), data);
1810 data << "\\end_inset\n";