1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
20 #pragma implementation
23 #include "insettabular.h"
26 #include "commandtags.h"
29 #include "LaTeXFeatures.h"
33 #include "lyx_gui_misc.h"
35 #include "insets/insettext.h"
36 #include "frontends/Dialogs.h"
41 #include "BufferView.h"
42 #include "undo_funcs.h"
43 #include "support/LAssert.h"
44 #include "support/lstrings.h"
55 const int ADD_TO_HEIGHT = 2;
56 const int ADD_TO_TABULAR_WIDTH = 2;
58 LyXTabular * paste_tabular = 0;
61 struct TabularFeature {
62 LyXTabular::Feature action;
66 //tabular_features * tabularFeatures = 0;
68 TabularFeature tabularFeature[] =
70 { LyXTabular::APPEND_ROW, "append-row" },
71 { LyXTabular::APPEND_COLUMN, "append-column" },
72 { LyXTabular::DELETE_ROW, "delete-row" },
73 { LyXTabular::DELETE_COLUMN, "delete-column" },
74 { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
75 { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
76 { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
77 { LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
78 { LyXTabular::ALIGN_LEFT, "align-left" },
79 { LyXTabular::ALIGN_RIGHT, "align-right" },
80 { LyXTabular::ALIGN_CENTER, "align-center" },
81 { LyXTabular::VALIGN_TOP, "valign-top" },
82 { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
83 { LyXTabular::VALIGN_CENTER, "valign-center" },
84 { LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
85 { LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
86 { LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
87 { LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
88 { LyXTabular::M_ALIGN_LEFT, "m-align-left" },
89 { LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
90 { LyXTabular::M_ALIGN_CENTER, "m-align-center" },
91 { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
92 { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
93 { LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
94 { LyXTabular::MULTICOLUMN, "multicolumn" },
95 { LyXTabular::SET_ALL_LINES, "set-all-lines" },
96 { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
97 { LyXTabular::SET_LONGTABULAR, "set-longtabular" },
98 { LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
99 { LyXTabular::SET_PWIDTH, "set-pwidth" },
100 { LyXTabular::SET_MPWIDTH, "set-mpwidth" },
101 { LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
102 { LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
103 { LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
104 { LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
105 { LyXTabular::SET_USEBOX, "set-usebox" },
106 { LyXTabular::SET_LTHEAD, "set-lthead" },
107 { LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
108 { LyXTabular::SET_LTFOOT, "set-ltfoot" },
109 { LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
110 { LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
111 { LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
112 { LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
113 { LyXTabular::LAST_ACTION, "" }
119 bool InsetTabular::hasPasteBuffer() const
121 return (paste_tabular != 0);
125 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
132 tabular.reset(new LyXTabular(this, rows, columns));
133 // for now make it always display as display() inset
135 the_locking_inset = 0;
136 locked = no_selection = false;
138 actrow = actcell = 0;
145 InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf,
147 : UpdatableInset(tab, same_id), buffer(&buf)
149 tabular.reset(new LyXTabular(this, *(tab.tabular)));
150 the_locking_inset = 0;
151 locked = no_selection = false;
153 actrow = actcell = 0;
154 sel_cell_start = sel_cell_end = 0;
160 InsetTabular::~InsetTabular()
166 Inset * InsetTabular::clone(Buffer const & buf, bool same_id) const
168 return new InsetTabular(*this, buf, same_id);
172 void InsetTabular::write(Buffer const * buf, ostream & os) const
174 os << " Tabular" << endl;
175 tabular->Write(buf, os);
179 void InsetTabular::read(Buffer const * buf, LyXLex & lex)
181 bool const old_format = (lex.getString() == "\\LyXTable");
185 //tabular = new LyXTabular(buf, this, lex);
186 tabular.reset(new LyXTabular(buf, this, lex));
194 string token = lex.getString();
195 while (lex.isOK() && (token != "\\end_inset")) {
197 token = lex.getString();
199 if (token != "\\end_inset") {
200 lex.printError("Missing \\end_inset at this point. "
206 int InsetTabular::ascent(BufferView *, LyXFont const &) const
208 return tabular->GetAscentOfRow(0);
212 int InsetTabular::descent(BufferView *, LyXFont const &) const
214 return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
218 int InsetTabular::width(BufferView *, LyXFont const &) const
220 return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
224 void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
225 float & x, bool cleared) const
233 if (need_update == INIT) {
234 if (calculate_dimensions_of_cells(bv, font, true))
235 bv->text->status = LyXText::CHANGED_IN_DRAW;
240 Painter & pain = bv->painter();
246 UpdatableInset::draw(bv, font, baseline, x, cleared);
249 x += static_cast<float>(scroll());
251 if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
252 (top_x != int(x)) || (top_baseline != baseline)))
254 int h = ascent(bv, font) + descent(bv, font);
255 int const tx = display() || !owner() ? 0 : top_x;
256 int w = tx ? width(bv, font) : pain.paperWidth();
257 int ty = baseline - ascent(bv, font);
261 if ((ty + h) > pain.paperHeight())
262 h = pain.paperHeight();
263 if ((top_x + w) > pain.paperWidth())
264 w = pain.paperWidth();
265 pain.fillRectangle(tx, ty, w, h, backgroundColor());
271 top_baseline = baseline;
272 x += ADD_TO_TABULAR_WIDTH;
276 first_visible_cell = -1;
277 for (i = 0; i < tabular->rows(); ++i) {
279 cell = tabular->GetCellNumber(i, 0);
280 if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
281 (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
283 baseline += tabular->GetDescentOfRow(i) +
284 tabular->GetAscentOfRow(i + 1) +
285 tabular->GetAdditionalHeight(i + 1);
288 for (j = 0; j < tabular->columns(); ++j) {
289 if (nx > bv->workWidth())
291 if (tabular->IsPartOfMultiColumn(i, j))
293 cx = nx + tabular->GetBeginningOfTextInCell(cell);
294 if (first_visible_cell < 0)
295 first_visible_cell = cell;
297 drawCellSelection(pain, nx, baseline, i, j, cell);
299 tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
301 drawCellLines(pain, nx, baseline, i, cell);
302 nx += tabular->GetWidthOfColumn(cell);
305 baseline += tabular->GetDescentOfRow(i) +
306 tabular->GetAscentOfRow(i + 1) +
307 tabular->GetAdditionalHeight(i + 1);
309 } else if (need_update == CELL) {
312 if (the_locking_inset &&
313 tabular->GetCellInset(actcell) != the_locking_inset)
315 Inset * inset = tabular->GetCellInset(cell);
317 inset != the_locking_inset && i < tabular->rows();
321 inset != the_locking_inset && j < tabular->columns();
324 if (tabular->IsPartOfMultiColumn(i, j))
326 nx += tabular->GetWidthOfColumn(cell);
328 inset = tabular->GetCellInset(cell);
330 if (tabular->row_of_cell(cell) > i) {
332 baseline += tabular->GetDescentOfRow(i) +
333 tabular->GetAscentOfRow(i + 1) +
334 tabular->GetAdditionalHeight(i + 1);
338 // compute baseline for actual row
339 for (i = 0; i < actrow; ++i) {
340 baseline += tabular->GetDescentOfRow(i) +
341 tabular->GetAscentOfRow(i + 1) +
342 tabular->GetAdditionalHeight(i + 1);
344 // now compute the right x position
345 cell = tabular->GetCellNumber(actrow, 0);
346 for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
347 if (tabular->IsPartOfMultiColumn(actrow, j))
349 nx += tabular->GetWidthOfColumn(cell);
353 i = tabular->row_of_cell(cell);
354 if (the_locking_inset != tabular->GetCellInset(cell)) {
355 lyxerr[Debug::INSETS] << "ERROR this shouldn't happen\n";
358 float dx = nx + tabular->GetBeginningOfTextInCell(cell);
360 tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false);
361 // clear only if we didn't have a change
362 if (bv->text->status() != LyXText::CHANGED_IN_DRAW) {
363 // clear before the inset
366 baseline - tabular->GetAscentOfRow(i) + 1,
368 tabular->GetAscentOfRow(i) +
369 tabular->GetDescentOfRow(i) - 1,
371 // clear behind the inset
373 int(cx + the_locking_inset->width(bv,font) + 1),
374 baseline - tabular->GetAscentOfRow(i) + 1,
375 tabular->GetWidthOfColumn(cell) -
376 tabular->GetBeginningOfTextInCell(cell) -
377 the_locking_inset->width(bv,font) -
378 tabular->GetAdditionalWidth(cell) - 1,
379 tabular->GetAscentOfRow(i) +
380 tabular->GetDescentOfRow(i) - 1,
382 // clear below the inset
385 baseline + the_locking_inset->descent(bv, font) + 1,
386 tabular->GetWidthOfColumn(cell) -
387 tabular->GetAdditionalWidth(cell) - 1,
388 tabular->GetAscentOfRow(i) +
389 tabular->GetDescentOfRow(i) -
390 the_locking_inset->ascent(bv, font) -
391 the_locking_inset->descent(bv, font) -
392 TEXT_TO_INSET_OFFSET - 1,
396 x -= ADD_TO_TABULAR_WIDTH;
397 x += width(bv, font);
398 if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
400 for(Inset * inset=owner(); inset; ++i)
401 inset = inset->owner();
402 if (calculate_dimensions_of_cells(bv, font, false))
410 void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
411 int row, int cell) const
413 int x2 = x + tabular->GetWidthOfColumn(cell);
416 if (!tabular->TopAlreadyDrawed(cell)) {
417 on_off = !tabular->TopLine(cell);
418 pain.line(x, baseline - tabular->GetAscentOfRow(row),
419 x2, baseline - tabular->GetAscentOfRow(row),
420 on_off ? LColor::tabularonoffline : LColor::tabularline,
421 on_off ? Painter::line_onoffdash : Painter::line_solid);
423 on_off = !tabular->BottomLine(cell);
424 pain.line(x,baseline + tabular->GetDescentOfRow(row),
425 x2, baseline + tabular->GetDescentOfRow(row),
426 on_off ? LColor::tabularonoffline : LColor::tabularline,
427 on_off ? Painter::line_onoffdash : Painter::line_solid);
428 if (!tabular->LeftAlreadyDrawed(cell)) {
429 on_off = !tabular->LeftLine(cell);
430 pain.line(x, baseline - tabular->GetAscentOfRow(row),
431 x, baseline + tabular->GetDescentOfRow(row),
432 on_off ? LColor::tabularonoffline : LColor::tabularline,
433 on_off ? Painter::line_onoffdash : Painter::line_solid);
435 on_off = !tabular->RightLine(cell);
436 pain.line(x2 - tabular->GetAdditionalWidth(cell),
437 baseline - tabular->GetAscentOfRow(row),
438 x2 - tabular->GetAdditionalWidth(cell),
439 baseline + tabular->GetDescentOfRow(row),
440 on_off ? LColor::tabularonoffline : LColor::tabularline,
441 on_off ? Painter::line_onoffdash : Painter::line_solid);
445 void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
446 int row, int column, int cell) const
448 int cs = tabular->column_of_cell(sel_cell_start);
449 int ce = tabular->column_of_cell(sel_cell_end);
452 cs = tabular->column_of_cell(sel_cell_end);
454 ce = tabular->right_column_of_cell(sel_cell_end);
457 int rs = tabular->row_of_cell(sel_cell_start);
458 int re = tabular->row_of_cell(sel_cell_end);
459 if (rs > re) swap(rs, re);
461 if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
462 int w = tabular->GetWidthOfColumn(cell);
463 int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
464 pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
465 w, h, LColor::selection);
470 void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
476 owner()->update(bv, font, true);
483 if (calculate_dimensions_of_cells(bv, font, true))
486 owner()->update(bv, font, true);
490 if (the_locking_inset)
491 the_locking_inset->update(bv, font, reinit);
492 if (need_update < FULL &&
493 bv->text->status() == LyXText::NEED_MORE_REFRESH)
498 switch (need_update) {
502 if (calculate_dimensions_of_cells(bv, font, false))
515 string const InsetTabular::editMessage() const
517 return _("Opened Tabular Inset");
521 void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
523 UpdatableInset::edit(bv, x, y, button);
525 if (!bv->lockInset(this)) {
526 lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
530 the_locking_inset = 0;
534 sel_cell_start = sel_cell_end = actcell;
536 if (insetHit(bv, x, y) && (button != 3)) {
537 activateCellInsetAbs(bv, x, y, button);
542 void InsetTabular::edit(BufferView * bv, bool front)
544 UpdatableInset::edit(bv, front);
546 if (!bv->lockInset(this)) {
547 lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
551 the_locking_inset = 0;
557 actcell = tabular->GetNumberOfCells() - 1;
558 sel_cell_start = sel_cell_end = actcell;
564 void InsetTabular::insetUnlock(BufferView * bv)
566 if (the_locking_inset) {
567 the_locking_inset->insetUnlock(bv);
568 the_locking_inset = 0;
571 no_selection = false;
574 if (scroll(false) || hasSelection()) {
575 sel_cell_start = sel_cell_end = 0;
579 updateLocal(bv, FULL, false);
584 void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
585 bool mark_dirty) const
587 if (need_update < what) // only set this if it has greater update
589 if ((what == INIT) && hasSelection())
592 if (need_update != NONE) {
593 bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
594 if (locked) // && (what != NONE))
600 bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
602 lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset("
607 if (inset == tabular->GetCellInset(actcell)) {
608 lyxerr[Debug::INSETS] << "OK" << endl;
609 the_locking_inset = tabular->GetCellInset(actcell);
612 } else if (the_locking_inset && (the_locking_inset == inset)) {
613 lyxerr[Debug::INSETS] << "OK" << endl;
615 } else if (the_locking_inset) {
616 lyxerr[Debug::INSETS] << "MAYBE" << endl;
617 return the_locking_inset->lockInsetInInset(bv, inset);
619 lyxerr[Debug::INSETS] << "NOT OK" << endl;
624 bool InsetTabular::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
627 if (!the_locking_inset)
629 if (the_locking_inset == inset) {
630 the_locking_inset->insetUnlock(bv);
631 the_locking_inset = 0;
633 #warning fix scrolling when cellinset has requested a scroll (Jug)!!!
639 updateLocal(bv, CELL, false);
640 showInsetCursor(bv, false);
643 if (the_locking_inset->unlockInsetInInset(bv, inset, lr)) {
644 if (inset->lyxCode() == TABULAR_CODE &&
645 !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) {
646 bv->owner()->getDialogs()->updateTabular(this);
655 bool InsetTabular::updateInsetInInset(BufferView * bv, Inset * inset)
657 if (!the_locking_inset)
659 if (the_locking_inset != inset) {
660 if (!the_locking_inset->updateInsetInInset(bv, inset))
663 updateLocal(bv, CELL, false);
668 unsigned int InsetTabular::insetInInsetY()
670 if (!the_locking_inset)
673 return inset_y + the_locking_inset->insetInInsetY();
677 UpdatableInset * InsetTabular::getLockingInset() const
679 return the_locking_inset ? the_locking_inset->getLockingInset() :
680 const_cast<InsetTabular *>(this);
684 UpdatableInset * InsetTabular::getFirstLockingInsetOfType(Inset::Code c)
688 if (the_locking_inset)
689 return the_locking_inset->getFirstLockingInsetOfType(c);
694 bool InsetTabular::insertInset(BufferView * bv, Inset * inset)
696 if (the_locking_inset)
697 return the_locking_inset->insertInset(bv, inset);
702 void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
704 if (hasSelection() && (button == 3))
707 if (hasSelection()) {
709 updateLocal(bv, SELECTION, false);
712 no_selection = false;
714 int const ocell = actcell;
715 int const orow = actrow;
720 updateLocal(bv, NONE, false);
721 sel_cell_start = sel_cell_end = actcell;
723 if ((ocell != actcell) && the_locking_inset) {
724 the_locking_inset->insetUnlock(bv);
725 the_locking_inset = 0;
731 bool const inset_hit = insetHit(bv, x, y);
733 if ((ocell == actcell) && the_locking_inset && inset_hit) {
735 the_locking_inset->insetButtonPress(bv,
736 x - inset_x, y - inset_y,
739 } else if (the_locking_inset) {
740 the_locking_inset->insetUnlock(bv);
742 the_locking_inset = 0;
744 localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
747 if (inset_hit && bv->theLockingInset()) {
748 if (activateCellInsetAbs(bv, x, y, button))
749 the_locking_inset->insetButtonPress(bv,
759 void InsetTabular::insetButtonRelease(BufferView * bv,
760 int x, int y, int button)
763 if (the_locking_inset) {
765 if ((i = the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE))) {
766 i->insetButtonRelease(bv, x, y, button);
770 bv->owner()->getDialogs()->showTabular(this);
773 if (the_locking_inset) {
774 the_locking_inset->insetButtonRelease(bv,
775 x - inset_x, y - inset_y,
779 no_selection = false;
783 void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
785 if (the_locking_inset) {
786 the_locking_inset->insetMotionNotify(bv,
794 int const old_cell = actcell;
797 sel_cell_end = actcell;
798 if (sel_cell_end != old_cell)
799 updateLocal(bv, SELECTION, false);
802 no_selection = false;
806 void InsetTabular::insetKeyPress(XKeyEvent * xke)
808 if (the_locking_inset) {
809 the_locking_inset->insetKeyPress(xke);
815 UpdatableInset::RESULT
816 InsetTabular::localDispatch(BufferView * bv, kb_action action,
819 // We need to save the value of the_locking_inset as the call to
820 // the_locking_inset->LocalDispatch might unlock it.
821 old_locking_inset = the_locking_inset;
822 no_selection = false;
823 UpdatableInset::RESULT result =
824 UpdatableInset::localDispatch(bv, action, arg);
825 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
830 if ((action < 0) && arg.empty())
833 bool hs = hasSelection();
836 // this one have priority over the locked InsetText, if we're not already
837 // inside another tabular then that one get's priority!
838 if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
843 if (the_locking_inset) {
844 unlockInsetInInset(bv, the_locking_inset);
845 the_locking_inset = 0;
847 if (action == LFUN_TAB)
848 moveNextCell(bv, old_locking_inset != 0);
850 movePrevCell(bv, old_locking_inset != 0);
851 sel_cell_start = sel_cell_end = actcell;
853 updateLocal(bv, SELECTION, false);
854 if (!the_locking_inset) {
856 return DISPATCHED_NOUPDATE;
859 // this to avoid compiler warnings.
865 if (the_locking_inset) {
866 result = the_locking_inset->localDispatch(bv, action, arg);
867 if (result == DISPATCHED_NOUPDATE) {
870 if (sc != scroll()) { // inset has been scrolled
871 the_locking_inset->toggleInsetCursor(bv);
872 updateLocal(bv, FULL, false);
873 the_locking_inset->toggleInsetCursor(bv);
876 } else if (result == DISPATCHED) {
877 the_locking_inset->toggleInsetCursor(bv);
878 updateLocal(bv, CELL, false);
879 the_locking_inset->toggleInsetCursor(bv);
881 } else if (result == FINISHED_UP) {
883 } else if (result == FINISHED_DOWN) {
885 } else if (result == FINISHED_RIGHT) {
893 // --- Cursor Movements ----------------------------------
895 if (tabular->IsLastCellInRow(actcell))
897 moveRight(bv, false);
898 sel_cell_end = actcell;
899 updateLocal(bv, SELECTION, false);
902 result = moveRight(bv);
903 sel_cell_start = sel_cell_end = actcell;
905 updateLocal(bv, SELECTION, false);
908 if (tabular->IsFirstCellInRow(actcell))
911 sel_cell_end = actcell;
912 updateLocal(bv, SELECTION, false);
915 result = moveLeft(bv);
916 sel_cell_start = sel_cell_end = actcell;
918 updateLocal(bv, SELECTION, false);
922 int const ocell = actcell;
924 if ((ocell == sel_cell_end) ||
925 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
926 sel_cell_end = tabular->GetCellBelow(sel_cell_end);
928 sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
929 updateLocal(bv, SELECTION, false);
933 result = moveDown(bv, old_locking_inset != 0);
934 sel_cell_start = sel_cell_end = actcell;
936 updateLocal(bv, SELECTION, false);
940 int const ocell = actcell;
942 if ((ocell == sel_cell_end) ||
943 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
944 sel_cell_end = tabular->GetCellAbove(sel_cell_end);
946 sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
947 updateLocal(bv, SELECTION, false);
951 result = moveUp(bv, old_locking_inset != 0);
952 sel_cell_start = sel_cell_end = actcell;
954 updateLocal(bv, SELECTION, false);
958 if (the_locking_inset) {
959 unlockInsetInInset(bv, the_locking_inset);
960 the_locking_inset = 0;
962 if (bv->text->first + bv->painter().paperHeight() <
963 (top_baseline + tabular->GetHeightOfTabular()))
965 bv->scrollCB(bv->text->first + bv->painter().paperHeight());
966 updateLocal(bv, FULL, false);
967 actcell = tabular->GetCellBelow(first_visible_cell) + column;
969 actcell = tabular->GetFirstCellInRow(tabular->rows() - 1) + column;
972 updateLocal(bv, CURSOR, false);
977 if (the_locking_inset) {
978 unlockInsetInInset(bv, the_locking_inset);
979 the_locking_inset = 0;
981 if (top_baseline < 0) {
982 bv->scrollCB(bv->text->first - bv->painter().paperHeight());
983 updateLocal(bv, FULL, false);
984 if (top_baseline > 0)
987 actcell = tabular->GetCellBelow(first_visible_cell) + column;
992 updateLocal(bv, CURSOR, false);
1003 case LFUN_LAYOUT_TABULAR:
1005 bv->owner()->getDialogs()->showTabular(this);
1008 case LFUN_TABULAR_FEATURE:
1009 if (!tabularFeatures(bv, arg))
1010 result = UNDISPATCHED;
1013 if (!copySelection(bv))
1015 setUndo(bv, Undo::DELETE,
1016 bv->text->cursor.par(),
1017 bv->text->cursor.par()->next());
1019 updateLocal(bv, INIT, true);
1022 if (!hasSelection())
1027 case LFUN_PASTESELECTION:
1029 string const clip(bv->getClipboard());
1033 if (clip.find('\t') != string::npos) {
1037 string::size_type len = clip.length();
1038 string::size_type p = 0;
1041 ((p = clip.find_first_of("\t\n", p)) != string::npos)) {
1049 maxCols = max(cols, maxCols);
1055 maxCols = max(cols, maxCols);
1056 delete paste_tabular;
1057 paste_tabular = new LyXTabular(this, rows, maxCols);
1058 string::size_type op = 0;
1060 int cells = paste_tabular->GetNumberOfCells();
1062 while((cell < cells) && (p < len) &&
1063 (p = clip.find_first_of("\t\n", p)) != string::npos) {
1068 paste_tabular->GetCellInset(cell)->setText(clip.substr(op, p-op));
1073 paste_tabular->GetCellInset(cell)->setText(clip.substr(op, p-op));
1074 while(cols++ < maxCols)
1082 // check for the last cell if there is no trailing '\n'
1083 if ((cell < cells) && (op < len))
1084 paste_tabular->GetCellInset(cell)->setText(clip.substr(op, len-op));
1086 // so that the clipboard is used and it goes on
1088 // and executes LFUN_PASTESELECTION in insettext!
1089 delete paste_tabular;
1094 if (hasPasteBuffer()) {
1095 setUndo(bv, Undo::INSERT,
1096 bv->text->cursor.par(),
1097 bv->text->cursor.par()->next());
1099 updateLocal(bv, INIT, true);
1102 // ATTENTION: the function above has to be PASTE and PASTESELECTION!!!
1104 // we try to activate the actual inset and put this event down to
1105 // the insets dispatch function.
1106 result = UNDISPATCHED;
1107 if (the_locking_inset)
1110 if (activateCellInset(bv)) {
1111 // reset need_update setted in above function!
1113 result = the_locking_inset->localDispatch(bv, action, arg);
1114 if ((result == UNDISPATCHED) || (result >= FINISHED)) {
1115 unlockInsetInInset(bv, the_locking_inset);
1117 the_locking_inset = 0;
1118 // we need to update if this was requested before
1119 updateLocal(bv, NONE, false);
1120 return UNDISPATCHED;
1125 updateLocal(bv, CELL, false);
1130 if (result < FINISHED) {
1131 if (!the_locking_inset) {
1132 showInsetCursor(bv);
1135 bv->unlockInset(this);
1140 int InsetTabular::latex(Buffer const * buf, ostream & os,
1141 bool fragile, bool fp) const
1143 return tabular->Latex(buf, os, fragile, fp);
1147 int InsetTabular::ascii(Buffer const * buf, ostream & os, int) const
1149 // This should be changed to a real ascii export
1150 return tabular->Ascii(buf, os);
1154 int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const
1156 return tabular->Ascii(buf,os);
1160 int InsetTabular::docbook(Buffer const * buf, ostream & os) const
1165 // if the table is inside a float it doesn't need the informaltable
1166 // wrapper. Search for it.
1167 for(master = owner();
1168 master && master->lyxCode() != Inset::FLOAT_CODE;
1169 master = master->owner());
1172 os << "<informaltable>\n";
1175 ret+= tabular->DocBook(buf,os);
1177 os << "</informaltable>\n";
1184 void InsetTabular::validate(LaTeXFeatures & features) const
1186 tabular->Validate(features);
1190 bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
1191 LyXFont const & font,
1198 bool changed = false;
1200 // if we have a locking_inset we should have to check only this cell for
1201 // change so I'll try this to have a boost, but who knows ;)
1202 if ((need_update != INIT) &&
1203 (the_locking_inset == tabular->GetCellInset(actcell))) {
1204 for(int i = 0; i < tabular->columns(); ++i) {
1205 maxAsc = max(tabular->GetCellInset(actrow, i)->ascent(bv, font),
1207 maxDesc = max(tabular->GetCellInset(actrow, i)->descent(bv, font),
1210 changed = tabular->SetWidthOfCell(actcell, the_locking_inset->width(bv, font));
1211 changed = tabular->SetAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed;
1212 changed = tabular->SetDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed;
1215 for (int i = 0; i < tabular->rows(); ++i) {
1218 for (int j = 0; j < tabular->columns(); ++j) {
1219 if (tabular->IsPartOfMultiColumn(i,j))
1222 inset = tabular->GetCellInset(cell);
1223 if (!reinit && !tabular->GetPWidth(cell).empty())
1224 inset->update(bv, font, false);
1225 maxAsc = max(maxAsc, inset->ascent(bv, font));
1226 maxDesc = max(maxDesc, inset->descent(bv, font));
1227 changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
1229 changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
1230 changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
1236 void InsetTabular::getCursorPos(BufferView * bv, int & x, int & y) const
1238 if (the_locking_inset) {
1239 the_locking_inset->getCursorPos(bv, x, y);
1242 x = cursor_.x() - top_x;
1247 void InsetTabular::toggleInsetCursor(BufferView * bv)
1249 if (the_locking_inset) {
1250 the_locking_inset->toggleInsetCursor(bv);
1254 LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
1256 int const asc = lyxfont::maxAscent(font);
1257 int const desc = lyxfont::maxDescent(font);
1259 if (isCursorVisible())
1260 bv->hideLockedInsetCursor();
1262 bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1263 toggleCursorVisible();
1267 void InsetTabular::showInsetCursor(BufferView * bv, bool show)
1269 if (!isCursorVisible()) {
1270 LyXFont font; // = GetFont(par, cursor.pos);
1272 int const asc = lyxfont::maxAscent(font);
1273 int const desc = lyxfont::maxDescent(font);
1274 bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1276 bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1277 setCursorVisible(true);
1282 void InsetTabular::hideInsetCursor(BufferView * bv)
1284 if (isCursorVisible()) {
1285 bv->hideLockedInsetCursor();
1286 setCursorVisible(false);
1291 void InsetTabular::fitInsetCursor(BufferView * bv) const
1293 if (the_locking_inset) {
1294 the_locking_inset->fitInsetCursor(bv);
1299 int const asc = lyxfont::maxAscent(font);
1300 int const desc = lyxfont::maxDescent(font);
1301 bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1305 void InsetTabular::setPos(BufferView * bv, int x, int y) const
1309 actcell = actrow = actcol = 0;
1310 int ly = tabular->GetDescentOfRow(actrow);
1312 // first search the right row
1313 while((ly < y) && ((actrow+1) < tabular->rows())) {
1314 cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) +
1315 tabular->GetAscentOfRow(actrow + 1) +
1316 tabular->GetAdditionalHeight(actrow + 1));
1318 ly = cursor_.y() + tabular->GetDescentOfRow(actrow);
1320 actcell = tabular->GetCellNumber(actrow, actcol);
1322 // now search the right column
1323 int lx = tabular->GetWidthOfColumn(actcell) -
1324 tabular->GetAdditionalWidth(actcell);
1325 for (; !tabular->IsLastCellInRow(actcell) && lx < x; ++actcell) {
1326 lx += tabular->GetWidthOfColumn(actcell + 1)
1327 + tabular->GetAdditionalWidth(actcell);
1329 cursor_.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
1334 int InsetTabular::getCellXPos(int cell) const
1338 for (; !tabular->IsFirstCellInRow(c); --c)
1340 int lx = tabular->GetWidthOfColumn(cell);
1341 for (; c < cell; ++c) {
1342 lx += tabular->GetWidthOfColumn(c);
1344 return (lx - tabular->GetWidthOfColumn(cell) + top_x);
1348 void InsetTabular::resetPos(BufferView * bv) const
1350 if (!locked || nodraw())
1352 actcol = tabular->column_of_cell(actcell);
1357 for (; (cell < actcell) && !tabular->IsLastRow(cell); ++cell) {
1358 if (tabular->IsLastCellInRow(cell)) {
1359 cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) +
1360 tabular->GetAscentOfRow(actrow + 1) +
1361 tabular->GetAdditionalHeight(actrow + 1));
1365 static int const offset = ADD_TO_TABULAR_WIDTH + 2;
1366 int new_x = getCellXPos(actcell);
1367 int old_x = cursor_.x();
1370 // cursor.x(getCellXPos(actcell) + offset);
1371 if ((actcol < tabular->columns()-1) && scroll(false) &&
1372 (tabular->GetWidthOfTabular() < bv->workWidth()-20))
1375 updateLocal(bv, FULL, false);
1376 } else if (the_locking_inset &&
1377 (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20))
1379 int xx = cursor_.x() - offset + bv->text->getRealCursorX(bv);
1380 if (xx > (bv->workWidth()-20)) {
1381 scroll(bv, -(xx - bv->workWidth() + 60));
1382 updateLocal(bv, FULL, false);
1383 } else if (xx < 20) {
1389 updateLocal(bv, FULL, false);
1391 } else if ((cursor_.x() - offset) > 20 &&
1392 (cursor_.x() - offset + tabular->GetWidthOfColumn(actcell))
1393 > (bv->workWidth() - 20)) {
1394 scroll(bv, -tabular->GetWidthOfColumn(actcell) - 20);
1395 updateLocal(bv, FULL, false);
1396 } else if ((cursor_.x() - offset) < 20) {
1397 scroll(bv, 20 - cursor_.x() + offset);
1398 updateLocal(bv, FULL, false);
1399 } else if (scroll(false) && top_x > 20 &&
1400 (top_x + tabular->GetWidthOfTabular()) > (bv->workWidth() - 20)) {
1401 scroll(bv, old_x - cursor_.x());
1402 updateLocal(bv, FULL, false);
1404 if (the_locking_inset) {
1405 inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1406 inset_y = cursor_.y();
1408 if ((!the_locking_inset ||
1409 !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) &&
1410 actcell != oldcell) {
1411 InsetTabular * inset = const_cast<InsetTabular *>(this);
1412 bv->owner()->getDialogs()->updateTabular(inset);
1418 UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
1420 if (lock && !old_locking_inset) {
1421 if (activateCellInset(bv))
1424 bool moved = isRightToLeft(bv)
1425 ? movePrevCell(bv) : moveNextCell(bv);
1427 return FINISHED_RIGHT;
1428 if (lock && activateCellInset(bv))
1432 return DISPATCHED_NOUPDATE;
1436 UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
1438 bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
1441 if (lock) { // behind the inset
1442 if (activateCellInset(bv, 0, 0, 0, true))
1446 return DISPATCHED_NOUPDATE;
1450 UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
1452 int const ocell = actcell;
1453 actcell = tabular->GetCellAbove(actcell);
1454 if (actcell == ocell) // we moved out of the inset
1460 if (old_locking_inset) {
1461 old_locking_inset->getCursorPos(bv, x, y);
1462 x -= cursor_.x() + tabular->GetBeginningOfTextInCell(actcell);
1464 if (activateCellInset(bv, x, 0))
1467 return DISPATCHED_NOUPDATE;
1471 UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
1473 int const ocell = actcell;
1474 actcell = tabular->GetCellBelow(actcell);
1475 if (actcell == ocell) // we moved out of the inset
1476 return FINISHED_DOWN;
1481 if (old_locking_inset) {
1482 old_locking_inset->getCursorPos(bv, x, y);
1483 x -= cursor_.x() + tabular->GetBeginningOfTextInCell(actcell);
1485 if (activateCellInset(bv, x, 0))
1488 return DISPATCHED_NOUPDATE;
1492 bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
1494 if (isRightToLeft(bv)) {
1495 if (tabular->IsFirstCellInRow(actcell)) {
1496 int row = tabular->row_of_cell(actcell);
1497 if (row == tabular->rows() - 1)
1499 actcell = tabular->GetLastCellInRow(row);
1500 actcell = tabular->GetCellBelow(actcell);
1507 if (tabular->IsLastCell(actcell))
1512 bool rtl = tabular->GetCellInset(actcell)->paragraph()->
1513 isRightToLeftPar(bv->buffer()->params);
1514 activateCellInset(bv, 0, 0, 0, !rtl);
1521 bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
1523 if (isRightToLeft(bv)) {
1524 if (tabular->IsLastCellInRow(actcell)) {
1525 int row = tabular->row_of_cell(actcell);
1528 actcell = tabular->GetFirstCellInRow(row);
1529 actcell = tabular->GetCellAbove(actcell);
1531 if (tabular->IsLastCell(actcell))
1536 if (!actcell) // first cell
1541 bool rtl = tabular->GetCellInset(actcell)->paragraph()->
1542 isRightToLeftPar(bv->buffer()->params);
1543 activateCellInset(bv, 0, 0, 0, !rtl);
1550 bool InsetTabular::deletable() const
1556 void InsetTabular::setFont(BufferView * bv, LyXFont const & font, bool tall,
1561 sel_cell_end = tabular->GetNumberOfCells() - 1;
1563 if (hasSelection()) {
1564 setUndo(bv, Undo::EDIT,
1565 bv->text->cursor.par(),
1566 bv->text->cursor.par()->next());
1567 bool frozen = undo_frozen;
1570 // apply the fontchange on the whole selection
1575 getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
1576 for(int i = sel_row_start; i <= sel_row_end; ++i) {
1577 for(int j = sel_col_start; j <= sel_col_end; ++j) {
1578 tabular->GetCellInset(i, j)->setFont(bv, font, tall, true);
1583 updateLocal(bv, INIT, true);
1585 if (the_locking_inset)
1586 the_locking_inset->setFont(bv, font, tall);
1590 bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
1592 LyXTabular::Feature action = LyXTabular::LAST_ACTION;
1595 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
1596 string const tmp = tabularFeature[i].feature;
1598 if (tmp == what.substr(0, tmp.length())) {
1599 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
1600 //tabularFeatures[i].feature.length())) {
1601 action = tabularFeature[i].action;
1605 if (action == LyXTabular::LAST_ACTION)
1609 frontStrip(what.substr(tabularFeature[i].feature.length()));
1610 tabularFeatures(bv, action, val);
1615 void InsetTabular::tabularFeatures(BufferView * bv,
1616 LyXTabular::Feature feature,
1617 string const & value)
1623 bool setLines = false;
1624 LyXAlignment setAlign = LYX_ALIGN_LEFT;
1625 LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
1628 case LyXTabular::M_ALIGN_LEFT:
1629 case LyXTabular::ALIGN_LEFT:
1630 setAlign=LYX_ALIGN_LEFT;
1632 case LyXTabular::M_ALIGN_RIGHT:
1633 case LyXTabular::ALIGN_RIGHT:
1634 setAlign=LYX_ALIGN_RIGHT;
1636 case LyXTabular::M_ALIGN_CENTER:
1637 case LyXTabular::ALIGN_CENTER:
1638 setAlign=LYX_ALIGN_CENTER;
1640 case LyXTabular::M_VALIGN_TOP:
1641 case LyXTabular::VALIGN_TOP:
1642 setVAlign=LyXTabular::LYX_VALIGN_TOP;
1644 case LyXTabular::M_VALIGN_BOTTOM:
1645 case LyXTabular::VALIGN_BOTTOM:
1646 setVAlign=LyXTabular::LYX_VALIGN_BOTTOM;
1648 case LyXTabular::M_VALIGN_CENTER:
1649 case LyXTabular::VALIGN_CENTER:
1650 setVAlign=LyXTabular::LYX_VALIGN_CENTER;
1655 if (hasSelection()) {
1656 getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
1658 sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
1659 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1661 setUndo(bv, Undo::FINISH,
1662 bv->text->cursor.par(),
1663 bv->text->cursor.par()->next());
1665 int row = tabular->row_of_cell(actcell);
1666 int column = tabular->column_of_cell(actcell);
1670 case LyXTabular::SET_PWIDTH:
1672 bool const update = (tabular->GetColumnPWidth(actcell) != value);
1673 tabular->SetColumnPWidth(actcell,value);
1675 for (int i = 0; i < tabular->rows(); ++i) {
1676 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1679 updateLocal(bv, INIT, true);
1683 case LyXTabular::SET_MPWIDTH:
1685 bool const update = (tabular->GetPWidth(actcell) != value);
1686 tabular->SetMColumnPWidth(actcell,value);
1688 for (int i = 0; i < tabular->rows(); ++i) {
1689 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1692 updateLocal(bv, INIT, true);
1696 case LyXTabular::SET_SPECIAL_COLUMN:
1697 case LyXTabular::SET_SPECIAL_MULTI:
1698 tabular->SetAlignSpecial(actcell,value,feature);
1699 updateLocal(bv, FULL, true);
1701 case LyXTabular::APPEND_ROW:
1702 // append the row into the tabular
1703 unlockInsetInInset(bv, the_locking_inset);
1704 tabular->AppendRow(actcell);
1705 updateLocal(bv, INIT, true);
1707 case LyXTabular::APPEND_COLUMN:
1708 // append the column into the tabular
1709 unlockInsetInInset(bv, the_locking_inset);
1710 tabular->AppendColumn(actcell);
1711 actcell = tabular->GetCellNumber(row, column);
1712 updateLocal(bv, INIT, true);
1714 case LyXTabular::DELETE_ROW:
1715 unlockInsetInInset(bv, the_locking_inset);
1716 for(int i = sel_row_start; i <= sel_row_end; ++i) {
1717 tabular->DeleteRow(sel_row_start);
1719 if (sel_row_start >= tabular->rows())
1721 actcell = tabular->GetCellNumber(sel_row_start, column);
1723 updateLocal(bv, INIT, true);
1725 case LyXTabular::DELETE_COLUMN:
1726 unlockInsetInInset(bv, the_locking_inset);
1727 for(int i = sel_col_start; i <= sel_col_end; ++i) {
1728 tabular->DeleteColumn(sel_col_start);
1730 if (sel_col_start >= tabular->columns())
1732 actcell = tabular->GetCellNumber(row, sel_col_start);
1734 updateLocal(bv, INIT, true);
1736 case LyXTabular::M_TOGGLE_LINE_TOP:
1738 case LyXTabular::TOGGLE_LINE_TOP:
1740 bool lineSet = !tabular->TopLine(actcell, flag);
1741 for (int i = sel_row_start; i <= sel_row_end; ++i)
1742 for (int j = sel_col_start; j <= sel_col_end; ++j)
1743 tabular->SetTopLine(
1744 tabular->GetCellNumber(i, j),
1746 updateLocal(bv, INIT, true);
1750 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1752 case LyXTabular::TOGGLE_LINE_BOTTOM:
1754 bool lineSet = !tabular->BottomLine(actcell, flag);
1755 for (int i = sel_row_start; i <= sel_row_end; ++i)
1756 for (int j = sel_col_start; j <= sel_col_end; ++j)
1757 tabular->SetBottomLine(
1758 tabular->GetCellNumber(i, j),
1761 updateLocal(bv, INIT, true);
1765 case LyXTabular::M_TOGGLE_LINE_LEFT:
1767 case LyXTabular::TOGGLE_LINE_LEFT:
1769 bool lineSet = !tabular->LeftLine(actcell, flag);
1770 for (int i = sel_row_start; i <= sel_row_end; ++i)
1771 for (int j = sel_col_start; j <= sel_col_end; ++j)
1772 tabular->SetLeftLine(
1773 tabular->GetCellNumber(i,j),
1776 updateLocal(bv, INIT, true);
1780 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1782 case LyXTabular::TOGGLE_LINE_RIGHT:
1784 bool lineSet = !tabular->RightLine(actcell, flag);
1785 for (int i = sel_row_start; i <= sel_row_end; ++i)
1786 for (int j = sel_col_start; j <= sel_col_end; ++j)
1787 tabular->SetRightLine(
1788 tabular->GetCellNumber(i,j),
1791 updateLocal(bv, INIT, true);
1795 case LyXTabular::M_ALIGN_LEFT:
1796 case LyXTabular::M_ALIGN_RIGHT:
1797 case LyXTabular::M_ALIGN_CENTER:
1799 case LyXTabular::ALIGN_LEFT:
1800 case LyXTabular::ALIGN_RIGHT:
1801 case LyXTabular::ALIGN_CENTER:
1802 for (int i = sel_row_start; i <= sel_row_end; ++i)
1803 for (int j = sel_col_start; j <= sel_col_end; ++j)
1804 tabular->SetAlignment(
1805 tabular->GetCellNumber(i, j),
1808 updateLocal(bv, INIT, true);
1810 case LyXTabular::M_VALIGN_TOP:
1811 case LyXTabular::M_VALIGN_BOTTOM:
1812 case LyXTabular::M_VALIGN_CENTER:
1814 case LyXTabular::VALIGN_TOP:
1815 case LyXTabular::VALIGN_BOTTOM:
1816 case LyXTabular::VALIGN_CENTER:
1817 for (int i = sel_row_start; i <= sel_row_end; ++i)
1818 for (int j = sel_col_start; j <= sel_col_end; ++j)
1819 tabular->SetVAlignment(
1820 tabular->GetCellNumber(i, j),
1822 updateLocal(bv, INIT, true);
1824 case LyXTabular::MULTICOLUMN:
1826 if (sel_row_start != sel_row_end) {
1827 WriteAlert(_("Impossible Operation!"),
1828 _("Multicolumns can only be horizontally."),
1832 // just multicol for one Single Cell
1833 if (!hasSelection()) {
1834 // check wether we are completly in a multicol
1835 if (tabular->IsMultiColumn(actcell)) {
1836 tabular->UnsetMultiColumn(actcell);
1837 updateLocal(bv, INIT, true);
1839 tabular->SetMultiColumn(actcell, 1);
1840 updateLocal(bv, CELL, true);
1844 // we have a selection so this means we just add all this
1845 // cells to form a multicolumn cell
1849 if (sel_cell_start > sel_cell_end) {
1850 s_start = sel_cell_end;
1851 s_end = sel_cell_start;
1853 s_start = sel_cell_start;
1854 s_end = sel_cell_end;
1856 tabular->SetMultiColumn(s_start, s_end - s_start + 1);
1858 sel_cell_end = sel_cell_start;
1859 updateLocal(bv, INIT, true);
1862 case LyXTabular::SET_ALL_LINES:
1864 case LyXTabular::UNSET_ALL_LINES:
1865 for (int i = sel_row_start; i <= sel_row_end; ++i)
1866 for (int j = sel_col_start; j <= sel_col_end; ++j)
1867 tabular->SetAllLines(
1868 tabular->GetCellNumber(i,j), setLines);
1869 updateLocal(bv, INIT, true);
1871 case LyXTabular::SET_LONGTABULAR:
1872 tabular->SetLongTabular(true);
1873 updateLocal(bv, INIT, true); // because this toggles displayed
1875 case LyXTabular::UNSET_LONGTABULAR:
1876 tabular->SetLongTabular(false);
1877 updateLocal(bv, INIT, true); // because this toggles displayed
1879 case LyXTabular::SET_ROTATE_TABULAR:
1880 tabular->SetRotateTabular(true);
1882 case LyXTabular::UNSET_ROTATE_TABULAR:
1883 tabular->SetRotateTabular(false);
1885 case LyXTabular::SET_ROTATE_CELL:
1886 for (int i = sel_row_start; i <= sel_row_end; ++i)
1887 for (int j = sel_col_start; j<=sel_col_end; ++j)
1888 tabular->SetRotateCell(
1889 tabular->GetCellNumber(i, j),
1892 case LyXTabular::UNSET_ROTATE_CELL:
1893 for (int i = sel_row_start; i <= sel_row_end; ++i)
1894 for (int j = sel_col_start; j <= sel_col_end; ++j)
1895 tabular->SetRotateCell(
1896 tabular->GetCellNumber(i, j), false);
1898 case LyXTabular::SET_USEBOX:
1900 LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
1901 if (val == tabular->GetUsebox(actcell))
1902 val = LyXTabular::BOX_NONE;
1903 for (int i = sel_row_start; i <= sel_row_end; ++i)
1904 for (int j = sel_col_start; j <= sel_col_end; ++j)
1906 tabular->GetCellNumber(i, j), val);
1909 case LyXTabular::SET_LTFIRSTHEAD:
1910 tabular->SetLTHead(actcell, true);
1912 case LyXTabular::SET_LTHEAD:
1913 tabular->SetLTHead(actcell, false);
1915 case LyXTabular::SET_LTFOOT:
1916 tabular->SetLTFoot(actcell, false);
1918 case LyXTabular::SET_LTLASTFOOT:
1919 tabular->SetLTFoot(actcell, true);
1921 case LyXTabular::SET_LTNEWPAGE:
1923 bool what = !tabular->GetLTNewPage(actcell);
1924 tabular->SetLTNewPage(actcell, what);
1927 // dummy stuff just to avoid warnings
1928 case LyXTabular::LAST_ACTION:
1934 bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
1937 UpdatableInset * inset =
1938 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
1939 LyXFont font(LyXFont::ALL_SANE);
1941 x = inset->x() + inset->width(bv, font);
1942 y = inset->descent(bv, font);
1944 //inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1945 //inset_y = cursor.y();
1946 inset->edit(bv, x, y, button);
1947 if (!the_locking_inset)
1949 updateLocal(bv, CELL, false);
1950 return (the_locking_inset != 0);
1954 bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
1957 inset_x = cursor_.x()
1958 - top_x + tabular->GetBeginningOfTextInCell(actcell);
1959 inset_y = cursor_.y();
1960 return activateCellInset(bv, x - inset_x, y - inset_y, button);
1964 bool InsetTabular::insetHit(BufferView *, int x, int) const
1967 > (cursor_.x() + tabular->GetBeginningOfTextInCell(actcell));
1971 // This returns paperWidth() if the cell-width is unlimited or the width
1972 // in pixels if we have a pwidth for this cell.
1973 int InsetTabular::getMaxWidthOfCell(BufferView * bv, int cell) const
1975 string const s = tabular->GetPWidth(cell);
1979 return VSpace(s).inPixels(bv);
1983 int InsetTabular::getMaxWidth(BufferView * bv,
1984 UpdatableInset const * inset) const
1986 int cell = tabular->cur_cell;
1987 if (tabular->GetCellInset(cell) != inset) {
1989 if (tabular->GetCellInset(cell) != inset) {
1991 lyxerr << "Actcell not equal to actual cell!\n";
1996 int const n = tabular->GetNumberOfCells();
1999 for (cell = 0; cell < n; ++cell) {
2000 if (tabular->GetCellInset(cell) == inset)
2006 lyxerr << "Own inset not found, shouldn't really happen!\n";
2010 int w = getMaxWidthOfCell(bv, cell);
2012 // because the inset then subtracts it's top_x and owner->x()
2013 w += (inset->x() - top_x);
2020 void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
2022 resizeLyXText(bv, recursive);
2026 void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
2029 for(int i = 0; i < tabular->rows(); ++i) {
2030 for(int j = 0; j < tabular->columns(); ++j) {
2031 tabular->GetCellInset(i, j)->resizeLyXText(bv, true);
2039 LyXText * InsetTabular::getLyXText(BufferView const * bv,
2040 bool const recursive) const
2042 if (the_locking_inset)
2043 return the_locking_inset->getLyXText(bv, recursive);
2045 // if we're locked lock the actual insettext and return it's LyXText!!!
2047 UpdatableInset * inset =
2048 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2049 inset->edit(const_cast<BufferView *>(bv), 0, 0, 0);
2050 return the_locking_inset->getLyXText(bv, recursive);
2053 return Inset::getLyXText(bv, recursive);
2057 bool InsetTabular::showInsetDialog(BufferView * bv) const
2059 if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv))
2060 bv->owner()->getDialogs()
2061 ->showTabular(const_cast<InsetTabular *>(this));
2066 void InsetTabular::openLayoutDialog(BufferView * bv) const
2068 if (the_locking_inset) {
2069 InsetTabular * i = static_cast<InsetTabular *>
2070 (the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE));
2072 i->openLayoutDialog(bv);
2076 bv->owner()->getDialogs()->showTabular(
2077 const_cast<InsetTabular *>(this));
2082 // functions returns:
2086 // 3 ... toggled off
2088 func_status::value_type InsetTabular::getStatus(string const & what) const
2090 int action = LyXTabular::LAST_ACTION;
2091 func_status::value_type status = func_status::OK;
2094 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
2095 string const tmp = tabularFeature[i].feature;
2096 if (tmp == what.substr(0, tmp.length())) {
2097 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
2098 // tabularFeatures[i].feature.length())) {
2099 action = tabularFeature[i].action;
2103 if (action == LyXTabular::LAST_ACTION)
2104 return func_status::Unknown;
2106 string const argument = frontStrip(what.substr(tabularFeature[i].feature.length()));
2113 if (hasSelection()) {
2114 getSelection(sel_row_start, sel_row_end, dummy, dummy);
2116 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
2120 case LyXTabular::SET_PWIDTH:
2121 case LyXTabular::SET_MPWIDTH:
2122 case LyXTabular::SET_SPECIAL_COLUMN:
2123 case LyXTabular::SET_SPECIAL_MULTI:
2124 status |= func_status::Disabled;
2127 case LyXTabular::APPEND_ROW:
2128 case LyXTabular::APPEND_COLUMN:
2129 case LyXTabular::DELETE_ROW:
2130 case LyXTabular::DELETE_COLUMN:
2131 case LyXTabular::SET_ALL_LINES:
2132 case LyXTabular::UNSET_ALL_LINES:
2133 status |= func_status::OK;
2136 case LyXTabular::MULTICOLUMN:
2137 if (tabular->IsMultiColumn(actcell))
2138 status |= func_status::ToggleOn;
2140 status |= func_status::ToggleOff;
2142 case LyXTabular::M_TOGGLE_LINE_TOP:
2144 case LyXTabular::TOGGLE_LINE_TOP:
2145 if (tabular->TopLine(actcell, flag))
2146 status |= func_status::ToggleOn;
2148 status |= func_status::ToggleOff;
2150 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
2152 case LyXTabular::TOGGLE_LINE_BOTTOM:
2153 if (tabular->BottomLine(actcell, flag))
2154 status |= func_status::ToggleOn;
2156 status |= func_status::ToggleOff;
2158 case LyXTabular::M_TOGGLE_LINE_LEFT:
2160 case LyXTabular::TOGGLE_LINE_LEFT:
2161 if (tabular->LeftLine(actcell, flag))
2162 status |= func_status::ToggleOn;
2164 status |= func_status::ToggleOff;
2166 case LyXTabular::M_TOGGLE_LINE_RIGHT:
2168 case LyXTabular::TOGGLE_LINE_RIGHT:
2169 if (tabular->RightLine(actcell, flag))
2170 status |= func_status::ToggleOn;
2172 status |= func_status::ToggleOff;
2174 case LyXTabular::M_ALIGN_LEFT:
2176 case LyXTabular::ALIGN_LEFT:
2177 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT)
2178 status |= func_status::ToggleOn;
2180 status |= func_status::ToggleOff;
2182 case LyXTabular::M_ALIGN_RIGHT:
2184 case LyXTabular::ALIGN_RIGHT:
2185 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT)
2186 status |= func_status::ToggleOn;
2188 status |= func_status::ToggleOff;
2190 case LyXTabular::M_ALIGN_CENTER:
2192 case LyXTabular::ALIGN_CENTER:
2193 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER)
2194 status |= func_status::ToggleOn;
2196 status |= func_status::ToggleOff;
2198 case LyXTabular::M_VALIGN_TOP:
2200 case LyXTabular::VALIGN_TOP:
2201 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP)
2202 status |= func_status::ToggleOn;
2204 status |= func_status::ToggleOff;
2206 case LyXTabular::M_VALIGN_BOTTOM:
2208 case LyXTabular::VALIGN_BOTTOM:
2209 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM)
2210 status |= func_status::ToggleOn;
2212 status |= func_status::ToggleOff;
2214 case LyXTabular::M_VALIGN_CENTER:
2216 case LyXTabular::VALIGN_CENTER:
2217 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER)
2218 status |= func_status::ToggleOn;
2220 status |= func_status::ToggleOff;
2222 case LyXTabular::SET_LONGTABULAR:
2223 if (tabular->IsLongTabular())
2224 status |= func_status::ToggleOn;
2226 status |= func_status::ToggleOff;
2228 case LyXTabular::UNSET_LONGTABULAR:
2229 if (!tabular->IsLongTabular())
2230 status |= func_status::ToggleOn;
2232 status |= func_status::ToggleOff;
2234 case LyXTabular::SET_ROTATE_TABULAR:
2235 if (tabular->GetRotateTabular())
2236 status |= func_status::ToggleOn;
2238 status |= func_status::ToggleOff;
2240 case LyXTabular::UNSET_ROTATE_TABULAR:
2241 if (!tabular->GetRotateTabular())
2242 status |= func_status::ToggleOn;
2244 status |= func_status::ToggleOff;
2246 case LyXTabular::SET_ROTATE_CELL:
2247 if (tabular->GetRotateCell(actcell))
2248 status |= func_status::ToggleOn;
2250 status |= func_status::ToggleOff;
2252 case LyXTabular::UNSET_ROTATE_CELL:
2253 if (!tabular->GetRotateCell(actcell))
2254 status |= func_status::ToggleOn;
2256 status |= func_status::ToggleOff;
2258 case LyXTabular::SET_USEBOX:
2259 if (strToInt(argument) == tabular->GetUsebox(actcell))
2260 status |= func_status::ToggleOn;
2262 status |= func_status::ToggleOff;
2264 case LyXTabular::SET_LTFIRSTHEAD:
2265 if (tabular->GetRowOfLTHead(actcell, dummy))
2266 status |= func_status::ToggleOn;
2268 status |= func_status::ToggleOff;
2270 case LyXTabular::SET_LTHEAD:
2271 if (tabular->GetRowOfLTHead(actcell, dummy))
2272 status |= func_status::ToggleOn;
2274 status |= func_status::ToggleOff;
2276 case LyXTabular::SET_LTFOOT:
2277 if (tabular->GetRowOfLTFoot(actcell, dummy))
2278 status |= func_status::ToggleOn;
2280 status |= func_status::ToggleOff;
2282 case LyXTabular::SET_LTLASTFOOT:
2283 if (tabular->GetRowOfLTFoot(actcell, dummy))
2284 status |= func_status::ToggleOn;
2286 status |= func_status::ToggleOff;
2288 case LyXTabular::SET_LTNEWPAGE:
2289 if (tabular->GetLTNewPage(actcell))
2290 status |= func_status::ToggleOn;
2292 status |= func_status::ToggleOff;
2295 status = func_status::Disabled;
2302 std::vector<string> const InsetTabular::getLabelList() const
2304 return tabular->getLabelList();
2308 bool InsetTabular::copySelection(BufferView * bv)
2310 if (!hasSelection())
2313 int sel_col_start = tabular->column_of_cell(sel_cell_start);
2314 int sel_col_end = tabular->column_of_cell(sel_cell_end);
2315 if (sel_col_start > sel_col_end) {
2316 sel_col_start = sel_col_end;
2317 sel_col_end = tabular->right_column_of_cell(sel_cell_start);
2319 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
2321 int const columns = sel_col_end - sel_col_start + 1;
2323 int sel_row_start = tabular->row_of_cell(sel_cell_start);
2324 int sel_row_end = tabular->row_of_cell(sel_cell_end);
2325 if (sel_row_start > sel_row_end) {
2326 swap(sel_row_start, sel_row_end);
2328 int const rows = sel_row_end - sel_row_start + 1;
2330 delete paste_tabular;
2331 paste_tabular = new LyXTabular(this, *tabular); // rows, columns);
2332 for (int i = 0; i < sel_row_start; ++i)
2333 paste_tabular->DeleteRow(0);
2334 while(paste_tabular->rows() > rows)
2335 paste_tabular->DeleteRow(rows);
2336 paste_tabular->SetTopLine(0, true, true);
2337 paste_tabular->SetBottomLine(paste_tabular->GetFirstCellInRow(rows-1),
2339 for (int i = 0; i < sel_col_start; ++i)
2340 paste_tabular->DeleteColumn(0);
2341 while (paste_tabular->columns() > columns)
2342 paste_tabular->DeleteColumn(columns);
2343 paste_tabular->SetLeftLine(0, true, true);
2344 paste_tabular->SetRightLine(paste_tabular->GetLastCellInRow(0),
2348 paste_tabular->Ascii(bv->buffer(), sstr);
2349 bv->stuffClipboard(sstr.str().c_str());
2354 bool InsetTabular::pasteSelection(BufferView * bv)
2359 for (int r1 = 0, r2 = actrow;
2360 (r1 < paste_tabular->rows()) && (r2 < tabular->rows());
2362 for(int c1 = 0, c2 = actcol;
2363 (c1 < paste_tabular->columns()) && (c2 < tabular->columns());
2365 if (paste_tabular->IsPartOfMultiColumn(r1,c1) &&
2366 tabular->IsPartOfMultiColumn(r2,c2))
2368 if (paste_tabular->IsPartOfMultiColumn(r1,c1)) {
2372 if (tabular->IsPartOfMultiColumn(r2,c2)) {
2376 int const n1 = paste_tabular->GetCellNumber(r1, c1);
2377 int const n2 = tabular->GetCellNumber(r2, c2);
2378 *(tabular->GetCellInset(n2)) = *(paste_tabular->GetCellInset(n1));
2379 tabular->GetCellInset(n2)->setOwner(this);
2380 tabular->GetCellInset(n2)->deleteLyXText(bv);
2387 bool InsetTabular::cutSelection()
2389 if (!hasSelection())
2392 int sel_col_start = tabular->column_of_cell(sel_cell_start);
2393 int sel_col_end = tabular->column_of_cell(sel_cell_end);
2394 if (sel_col_start > sel_col_end) {
2395 sel_col_start = sel_col_end;
2396 sel_col_end = tabular->right_column_of_cell(sel_cell_start);
2398 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
2400 int sel_row_start = tabular->row_of_cell(sel_cell_start);
2401 int sel_row_end = tabular->row_of_cell(sel_cell_end);
2402 if (sel_row_start > sel_row_end) {
2403 swap(sel_row_start, sel_row_end);
2405 if (sel_cell_start > sel_cell_end) {
2406 swap(sel_cell_start, sel_cell_end);
2408 for (int i = sel_row_start; i <= sel_row_end; ++i) {
2409 for (int j = sel_col_start; j <= sel_col_end; ++j) {
2410 tabular->GetCellInset(tabular->GetCellNumber(i, j))->clear();
2417 bool InsetTabular::isRightToLeft(BufferView *bv )
2419 return bv->getParentLanguage(this)->RightToLeft();
2423 bool InsetTabular::nodraw() const
2425 if (!UpdatableInset::nodraw() && the_locking_inset)
2426 return the_locking_inset->nodraw();
2427 return UpdatableInset::nodraw();
2431 int InsetTabular::scroll(bool recursive) const
2433 int sx = UpdatableInset::scroll(false);
2435 if (recursive && the_locking_inset)
2436 sx += the_locking_inset->scroll(recursive);
2442 bool InsetTabular::doClearArea() const
2444 return !locked || (need_update & (FULL|INIT));
2448 void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol) const
2450 srow = tabular->row_of_cell(sel_cell_start);
2451 erow = tabular->row_of_cell(sel_cell_end);
2455 scol = tabular->column_of_cell(sel_cell_start);
2456 ecol = tabular->column_of_cell(sel_cell_end);
2460 ecol = tabular->right_column_of_cell(sel_cell_end);
2464 Paragraph * InsetTabular::getParFromID(int id) const
2467 for(int i = 0; i < tabular->rows(); ++i) {
2468 for(int j = 0; j < tabular->columns(); ++j) {
2469 if ((result = tabular->GetCellInset(i, j)->getParFromID(id)))
2477 Paragraph * InsetTabular::firstParagraph() const
2479 if (the_locking_inset)
2480 return the_locking_inset->firstParagraph();
2485 Paragraph * InsetTabular::getFirstParagraph(int i) const
2487 return (i < tabular->GetNumberOfCells())
2488 ? tabular->GetCellInset(i)->getFirstParagraph(0)
2493 LyXCursor const & InsetTabular::cursor(BufferView * bv) const
2495 if (the_locking_inset)
2496 return the_locking_inset->cursor(bv);
2497 return Inset::cursor(bv);
2501 Inset * InsetTabular::getInsetFromID(int id_arg) const
2504 return const_cast<InsetTabular *>(this);
2507 for(int i=0; i < tabular->rows(); ++i) {
2508 for(int j=0; j < tabular->columns(); ++j) {
2509 if ((result = tabular->GetCellInset(i, j)->getInsetFromID(id_arg)))
2517 string const InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
2519 if (the_locking_inset) {
2520 string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
2523 if (tabular->IsLastCell(actcell)) {
2524 bv->unlockInset(const_cast<InsetTabular *>(this));
2530 // otherwise we have to lock the next inset and ask for it's selecttion
2531 UpdatableInset * inset =
2532 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2533 inset->edit(bv, 0, 0, 0);
2534 string const str(selectNextWordInt(bv, value));
2542 string InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
2544 // when entering this function the inset should be ALWAYS locked!
2545 lyx::Assert(the_locking_inset);
2547 string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
2551 if (tabular->IsLastCell(actcell)) {
2552 bv->unlockInset(const_cast<InsetTabular *>(this));
2556 // otherwise we have to lock the next inset and ask for it's selecttion
2557 UpdatableInset * inset =
2558 static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
2560 return selectNextWordInt(bv, value);
2564 void InsetTabular::selectSelectedWord(BufferView * bv)
2566 if (the_locking_inset) {
2567 the_locking_inset->selectSelectedWord(bv);
2574 void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
2576 if (the_locking_inset) {
2577 the_locking_inset->toggleSelection(bv, kill_selection);
2582 bool InsetTabular::searchForward(BufferView * bv, string const & str,
2583 bool const & cs, bool const & mw)
2585 if (the_locking_inset) {
2586 if (the_locking_inset->searchForward(bv, str, cs, mw))
2588 if (tabular->IsLastCell(actcell)) {
2589 bv->unlockInset(const_cast<InsetTabular *>(this));
2594 // otherwise we have to lock the next inset and search there
2595 UpdatableInset * inset =
2596 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2599 bool const res = searchForward(bv, str, cs, mw);
2600 updateLocal(bv, NONE, false);
2601 bv->updateInset(const_cast<InsetTabular *>(this), false);
2604 return searchForward(bv, str, cs, mw);
2609 bool InsetTabular::searchBackward(BufferView * bv, string const & str,
2610 bool const & cs, bool const & mw)
2612 if (the_locking_inset) {
2613 if (the_locking_inset->searchBackward(bv, str, cs, mw))
2615 if (!actcell) { // we are already in the first cell
2616 bv->unlockInset(const_cast<InsetTabular *>(this));
2621 // otherwise we have to lock the next inset and search there
2622 UpdatableInset * inset =
2623 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2624 inset->edit(bv, false);
2626 bool const res = searchBackward(bv, str, cs, mw);
2627 bv->updateInset(const_cast<InsetTabular *>(this), false);
2630 return searchBackward(bv, str, cs, mw);
2635 bool InsetTabular::insetAllowed(Inset::Code code) const
2637 if (the_locking_inset)
2638 return the_locking_inset->insetAllowed(code);