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"
37 #include "frontends/Alert.h"
42 #include "BufferView.h"
43 #include "undo_funcs.h"
44 #include "support/LAssert.h"
45 #include "support/lstrings.h"
56 const int ADD_TO_HEIGHT = 2;
57 const int ADD_TO_TABULAR_WIDTH = 2;
59 LyXTabular * paste_tabular = 0;
62 struct TabularFeature {
63 LyXTabular::Feature action;
67 //tabular_features * tabularFeatures = 0;
69 TabularFeature tabularFeature[] =
71 { LyXTabular::APPEND_ROW, "append-row" },
72 { LyXTabular::APPEND_COLUMN, "append-column" },
73 { LyXTabular::DELETE_ROW, "delete-row" },
74 { LyXTabular::DELETE_COLUMN, "delete-column" },
75 { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
76 { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
77 { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
78 { LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
79 { LyXTabular::ALIGN_LEFT, "align-left" },
80 { LyXTabular::ALIGN_RIGHT, "align-right" },
81 { LyXTabular::ALIGN_CENTER, "align-center" },
82 { LyXTabular::VALIGN_TOP, "valign-top" },
83 { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
84 { LyXTabular::VALIGN_CENTER, "valign-center" },
85 { LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
86 { LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
87 { LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
88 { LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
89 { LyXTabular::M_ALIGN_LEFT, "m-align-left" },
90 { LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
91 { LyXTabular::M_ALIGN_CENTER, "m-align-center" },
92 { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
93 { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
94 { LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
95 { LyXTabular::MULTICOLUMN, "multicolumn" },
96 { LyXTabular::SET_ALL_LINES, "set-all-lines" },
97 { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
98 { LyXTabular::SET_LONGTABULAR, "set-longtabular" },
99 { LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
100 { LyXTabular::SET_PWIDTH, "set-pwidth" },
101 { LyXTabular::SET_MPWIDTH, "set-mpwidth" },
102 { LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
103 { LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
104 { LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
105 { LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
106 { LyXTabular::SET_USEBOX, "set-usebox" },
107 { LyXTabular::SET_LTHEAD, "set-lthead" },
108 { LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
109 { LyXTabular::SET_LTFOOT, "set-ltfoot" },
110 { LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
111 { LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
112 { LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
113 { LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
114 { LyXTabular::LAST_ACTION, "" }
120 bool InsetTabular::hasPasteBuffer() const
122 return (paste_tabular != 0);
126 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
133 tabular.reset(new LyXTabular(this, rows, columns));
134 // for now make it always display as display() inset
136 the_locking_inset = 0;
137 locked = no_selection = false;
139 actrow = actcell = 0;
143 in_reset_pos = false;
147 InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf,
149 : UpdatableInset(tab, same_id), buffer(&buf)
151 tabular.reset(new LyXTabular(this, *(tab.tabular), same_id));
152 the_locking_inset = 0;
153 locked = no_selection = false;
155 actrow = actcell = 0;
156 sel_cell_start = sel_cell_end = 0;
159 in_reset_pos = false;
163 InsetTabular::~InsetTabular()
169 Inset * InsetTabular::clone(Buffer const & buf, bool same_id) const
171 return new InsetTabular(*this, buf, same_id);
175 void InsetTabular::write(Buffer const * buf, ostream & os) const
177 os << " Tabular" << endl;
178 tabular->Write(buf, os);
182 void InsetTabular::read(Buffer const * buf, LyXLex & lex)
184 bool const old_format = (lex.getString() == "\\LyXTable");
188 //tabular = new LyXTabular(buf, this, lex);
189 tabular.reset(new LyXTabular(buf, this, lex));
197 string token = lex.getString();
198 while (lex.isOK() && (token != "\\end_inset")) {
200 token = lex.getString();
202 if (token != "\\end_inset") {
203 lex.printError("Missing \\end_inset at this point. "
209 int InsetTabular::ascent(BufferView *, LyXFont const &) const
211 return tabular->GetAscentOfRow(0);
215 int InsetTabular::descent(BufferView *, LyXFont const &) const
217 return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
221 int InsetTabular::width(BufferView *, LyXFont const &) const
223 return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
227 void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
228 float & x, bool cleared) const
236 if (need_update == INIT) {
237 if (calculate_dimensions_of_cells(bv, font, true))
238 bv->text->status = LyXText::CHANGED_IN_DRAW;
243 Painter & pain = bv->painter();
249 UpdatableInset::draw(bv, font, baseline, x, cleared);
252 x += static_cast<float>(scroll());
254 if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
255 (top_x != int(x)) || (top_baseline != baseline)))
257 int h = ascent(bv, font) + descent(bv, font);
258 int const tx = display() || !owner() ? 0 : top_x;
259 int w = tx ? width(bv, font) : pain.paperWidth();
260 int ty = baseline - ascent(bv, font);
264 if ((ty + h) > pain.paperHeight())
265 h = pain.paperHeight();
266 if ((top_x + w) > pain.paperWidth())
267 w = pain.paperWidth();
268 pain.fillRectangle(tx, ty, w, h, backgroundColor());
274 top_baseline = baseline;
275 x += ADD_TO_TABULAR_WIDTH;
279 first_visible_cell = -1;
280 for (i = 0; i < tabular->rows(); ++i) {
282 cell = tabular->GetCellNumber(i, 0);
283 if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
284 (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
286 baseline += tabular->GetDescentOfRow(i) +
287 tabular->GetAscentOfRow(i + 1) +
288 tabular->GetAdditionalHeight(i + 1);
291 for (j = 0; j < tabular->columns(); ++j) {
292 if (nx > bv->workWidth())
294 if (tabular->IsPartOfMultiColumn(i, j))
296 cx = nx + tabular->GetBeginningOfTextInCell(cell);
297 if (first_visible_cell < 0)
298 first_visible_cell = cell;
300 drawCellSelection(pain, nx, baseline, i, j, cell);
302 tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
304 drawCellLines(pain, nx, baseline, i, cell);
305 nx += tabular->GetWidthOfColumn(cell);
308 baseline += tabular->GetDescentOfRow(i) +
309 tabular->GetAscentOfRow(i + 1) +
310 tabular->GetAdditionalHeight(i + 1);
312 } else if (need_update == CELL) {
315 if (the_locking_inset &&
316 tabular->GetCellInset(actcell) != the_locking_inset)
318 Inset * inset = tabular->GetCellInset(cell);
320 inset != the_locking_inset && i < tabular->rows();
324 inset != the_locking_inset && j < tabular->columns();
327 if (tabular->IsPartOfMultiColumn(i, j))
329 nx += tabular->GetWidthOfColumn(cell);
331 inset = tabular->GetCellInset(cell);
333 if (tabular->row_of_cell(cell) > i) {
335 baseline += tabular->GetDescentOfRow(i) +
336 tabular->GetAscentOfRow(i + 1) +
337 tabular->GetAdditionalHeight(i + 1);
341 // compute baseline for actual row
342 for (i = 0; i < actrow; ++i) {
343 baseline += tabular->GetDescentOfRow(i) +
344 tabular->GetAscentOfRow(i + 1) +
345 tabular->GetAdditionalHeight(i + 1);
347 // now compute the right x position
348 cell = tabular->GetCellNumber(actrow, 0);
349 for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
350 if (tabular->IsPartOfMultiColumn(actrow, j))
352 nx += tabular->GetWidthOfColumn(cell);
356 i = tabular->row_of_cell(cell);
357 if (the_locking_inset != tabular->GetCellInset(cell)) {
358 lyxerr[Debug::INSETTEXT] << "ERROR this shouldn't happen\n";
361 float dx = nx + tabular->GetBeginningOfTextInCell(cell);
363 tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false);
364 // clear only if we didn't have a change
365 if (bv->text->status() != LyXText::CHANGED_IN_DRAW) {
366 // clear before the inset
369 baseline - tabular->GetAscentOfRow(i) + 1,
371 tabular->GetAscentOfRow(i) +
372 tabular->GetDescentOfRow(i) - 1,
374 // clear behind the inset
376 int(cx + the_locking_inset->width(bv,font) + 1),
377 baseline - tabular->GetAscentOfRow(i) + 1,
378 tabular->GetWidthOfColumn(cell) -
379 tabular->GetBeginningOfTextInCell(cell) -
380 the_locking_inset->width(bv,font) -
381 tabular->GetAdditionalWidth(cell) - 1,
382 tabular->GetAscentOfRow(i) +
383 tabular->GetDescentOfRow(i) - 1,
385 // clear below the inset
388 baseline + the_locking_inset->descent(bv, font) + 1,
389 tabular->GetWidthOfColumn(cell) -
390 tabular->GetAdditionalWidth(cell) - 1,
391 tabular->GetAscentOfRow(i) +
392 tabular->GetDescentOfRow(i) -
393 the_locking_inset->ascent(bv, font) -
394 the_locking_inset->descent(bv, font) -
395 TEXT_TO_INSET_OFFSET - 1,
399 x -= ADD_TO_TABULAR_WIDTH;
400 x += width(bv, font);
401 if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
403 for(Inset * inset=owner(); inset; ++i)
404 inset = inset->owner();
405 if (calculate_dimensions_of_cells(bv, font, false))
413 void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
414 int row, int cell) const
416 int x2 = x + tabular->GetWidthOfColumn(cell);
419 if (!tabular->TopAlreadyDrawed(cell)) {
420 on_off = !tabular->TopLine(cell);
421 pain.line(x, baseline - tabular->GetAscentOfRow(row),
422 x2, baseline - tabular->GetAscentOfRow(row),
423 on_off ? LColor::tabularonoffline : LColor::tabularline,
424 on_off ? Painter::line_onoffdash : Painter::line_solid);
426 on_off = !tabular->BottomLine(cell);
427 pain.line(x,baseline + tabular->GetDescentOfRow(row),
428 x2, baseline + tabular->GetDescentOfRow(row),
429 on_off ? LColor::tabularonoffline : LColor::tabularline,
430 on_off ? Painter::line_onoffdash : Painter::line_solid);
431 if (!tabular->LeftAlreadyDrawed(cell)) {
432 on_off = !tabular->LeftLine(cell);
433 pain.line(x, baseline - tabular->GetAscentOfRow(row),
434 x, baseline + tabular->GetDescentOfRow(row),
435 on_off ? LColor::tabularonoffline : LColor::tabularline,
436 on_off ? Painter::line_onoffdash : Painter::line_solid);
438 on_off = !tabular->RightLine(cell);
439 pain.line(x2 - tabular->GetAdditionalWidth(cell),
440 baseline - tabular->GetAscentOfRow(row),
441 x2 - tabular->GetAdditionalWidth(cell),
442 baseline + tabular->GetDescentOfRow(row),
443 on_off ? LColor::tabularonoffline : LColor::tabularline,
444 on_off ? Painter::line_onoffdash : Painter::line_solid);
448 void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
449 int row, int column, int cell) const
451 int cs = tabular->column_of_cell(sel_cell_start);
452 int ce = tabular->column_of_cell(sel_cell_end);
455 cs = tabular->column_of_cell(sel_cell_end);
457 ce = tabular->right_column_of_cell(sel_cell_end);
460 int rs = tabular->row_of_cell(sel_cell_start);
461 int re = tabular->row_of_cell(sel_cell_end);
462 if (rs > re) swap(rs, re);
464 if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
465 int w = tabular->GetWidthOfColumn(cell);
466 int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
467 pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
468 w, h, LColor::selection);
473 void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
479 owner()->update(bv, font, true);
486 if (calculate_dimensions_of_cells(bv, font, true))
489 owner()->update(bv, font, true);
493 if (the_locking_inset)
494 the_locking_inset->update(bv, font, reinit);
495 if (need_update < FULL &&
496 bv->text->status() == LyXText::NEED_MORE_REFRESH)
501 switch (need_update) {
505 if (calculate_dimensions_of_cells(bv, font, false))
518 string const InsetTabular::editMessage() const
520 return _("Opened Tabular Inset");
524 void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
526 UpdatableInset::edit(bv, x, y, button);
528 if (!bv->lockInset(this)) {
529 lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
533 the_locking_inset = 0;
537 sel_cell_start = sel_cell_end = actcell;
539 if (insetHit(bv, x, y) && (button != 3)) {
540 activateCellInsetAbs(bv, x, y, button);
545 void InsetTabular::edit(BufferView * bv, bool front)
547 UpdatableInset::edit(bv, front);
549 if (!bv->lockInset(this)) {
550 lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
554 the_locking_inset = 0;
560 actcell = tabular->GetNumberOfCells() - 1;
561 sel_cell_start = sel_cell_end = actcell;
567 void InsetTabular::insetUnlock(BufferView * bv)
569 if (the_locking_inset) {
570 the_locking_inset->insetUnlock(bv);
571 the_locking_inset = 0;
574 no_selection = false;
577 if (scroll(false) || hasSelection()) {
578 sel_cell_start = sel_cell_end = 0;
582 updateLocal(bv, FULL, false);
587 void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
588 bool mark_dirty) const
590 if (need_update < what) // only set this if it has greater update
592 if ((what == INIT) && hasSelection())
595 if (need_update != NONE) {
596 bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
597 if (locked) // && (what != NONE))
603 bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
605 lyxerr[Debug::INSETTEXT] << "InsetTabular::LockInsetInInset("
610 if (inset == tabular->GetCellInset(actcell)) {
611 lyxerr[Debug::INSETTEXT] << "OK" << endl;
612 the_locking_inset = tabular->GetCellInset(actcell);
615 } else if (the_locking_inset && (the_locking_inset == inset)) {
616 lyxerr[Debug::INSETTEXT] << "OK" << endl;
618 } else if (the_locking_inset) {
619 lyxerr[Debug::INSETTEXT] << "MAYBE" << endl;
620 return the_locking_inset->lockInsetInInset(bv, inset);
622 lyxerr[Debug::INSETTEXT] << "NOT OK" << endl;
627 bool InsetTabular::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
630 if (!the_locking_inset)
632 if (the_locking_inset == inset) {
633 the_locking_inset->insetUnlock(bv);
634 the_locking_inset = 0;
636 #warning fix scrolling when cellinset has requested a scroll (Jug)!!!
642 updateLocal(bv, CELL, false);
643 showInsetCursor(bv, false);
646 if (the_locking_inset->unlockInsetInInset(bv, inset, lr)) {
647 if (inset->lyxCode() == TABULAR_CODE &&
648 !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) {
649 bv->owner()->getDialogs()->updateTabular(this);
658 bool InsetTabular::updateInsetInInset(BufferView * bv, Inset * inset)
660 if (!the_locking_inset)
662 if (the_locking_inset != inset) {
663 if (!the_locking_inset->updateInsetInInset(bv, inset))
666 updateLocal(bv, CELL, false);
671 unsigned int InsetTabular::insetInInsetY()
673 if (!the_locking_inset)
676 return inset_y + the_locking_inset->insetInInsetY();
680 UpdatableInset * InsetTabular::getLockingInset() const
682 return the_locking_inset ? the_locking_inset->getLockingInset() :
683 const_cast<InsetTabular *>(this);
687 UpdatableInset * InsetTabular::getFirstLockingInsetOfType(Inset::Code c)
691 if (the_locking_inset)
692 return the_locking_inset->getFirstLockingInsetOfType(c);
697 bool InsetTabular::insertInset(BufferView * bv, Inset * inset)
699 if (the_locking_inset)
700 return the_locking_inset->insertInset(bv, inset);
705 void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
707 if (hasSelection() && (button == 3))
710 if (hasSelection()) {
712 updateLocal(bv, SELECTION, false);
715 no_selection = false;
717 int const ocell = actcell;
718 int const orow = actrow;
723 updateLocal(bv, NONE, false);
724 sel_cell_start = sel_cell_end = actcell;
726 if ((ocell != actcell) && the_locking_inset) {
727 the_locking_inset->insetUnlock(bv);
728 the_locking_inset = 0;
734 bool const inset_hit = insetHit(bv, x, y);
736 if ((ocell == actcell) && the_locking_inset && inset_hit) {
738 the_locking_inset->insetButtonPress(bv,
739 x - inset_x, y - inset_y,
742 } else if (the_locking_inset) {
743 the_locking_inset->insetUnlock(bv);
745 the_locking_inset = 0;
747 localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
750 if (inset_hit && bv->theLockingInset()) {
751 if (activateCellInsetAbs(bv, x, y, button))
752 the_locking_inset->insetButtonPress(bv,
762 void InsetTabular::insetButtonRelease(BufferView * bv,
763 int x, int y, int button)
766 if (the_locking_inset) {
768 if ((i = the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE))) {
769 i->insetButtonRelease(bv, x, y, button);
773 bv->owner()->getDialogs()->showTabular(this);
776 if (the_locking_inset) {
777 the_locking_inset->insetButtonRelease(bv,
778 x - inset_x, y - inset_y,
782 no_selection = false;
786 void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
788 if (the_locking_inset) {
789 the_locking_inset->insetMotionNotify(bv,
797 int const old_cell = actcell;
800 sel_cell_end = actcell;
801 if (sel_cell_end != old_cell)
802 updateLocal(bv, SELECTION, false);
805 no_selection = false;
809 void InsetTabular::insetKeyPress(XKeyEvent * xke)
811 if (the_locking_inset) {
812 the_locking_inset->insetKeyPress(xke);
818 UpdatableInset::RESULT
819 InsetTabular::localDispatch(BufferView * bv, kb_action action,
822 // We need to save the value of the_locking_inset as the call to
823 // the_locking_inset->LocalDispatch might unlock it.
824 old_locking_inset = the_locking_inset;
825 no_selection = false;
826 UpdatableInset::RESULT result =
827 UpdatableInset::localDispatch(bv, action, arg);
828 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
833 if ((action < 0) && arg.empty())
836 bool hs = hasSelection();
839 // this one have priority over the locked InsetText, if we're not already
840 // inside another tabular then that one get's priority!
841 if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
846 if (the_locking_inset) {
847 unlockInsetInInset(bv, the_locking_inset);
848 the_locking_inset = 0;
850 if (action == LFUN_TAB)
851 moveNextCell(bv, old_locking_inset != 0);
853 movePrevCell(bv, old_locking_inset != 0);
854 sel_cell_start = sel_cell_end = actcell;
856 updateLocal(bv, SELECTION, false);
857 if (!the_locking_inset) {
859 return DISPATCHED_NOUPDATE;
862 // this to avoid compiler warnings.
868 if (the_locking_inset) {
869 result = the_locking_inset->localDispatch(bv, action, arg);
870 if (result == DISPATCHED_NOUPDATE) {
873 if (sc != scroll()) { // inset has been scrolled
874 the_locking_inset->toggleInsetCursor(bv);
875 updateLocal(bv, FULL, false);
876 the_locking_inset->toggleInsetCursor(bv);
879 } else if (result == DISPATCHED) {
880 the_locking_inset->toggleInsetCursor(bv);
881 updateLocal(bv, CELL, false);
882 the_locking_inset->toggleInsetCursor(bv);
884 } else if (result == FINISHED_UP) {
886 } else if (result == FINISHED_DOWN) {
888 } else if (result == FINISHED_RIGHT) {
896 // --- Cursor Movements ----------------------------------
898 if (tabular->IsLastCellInRow(actcell))
900 moveRight(bv, false);
901 sel_cell_end = actcell;
902 updateLocal(bv, SELECTION, false);
905 result = moveRight(bv);
906 sel_cell_start = sel_cell_end = actcell;
908 updateLocal(bv, SELECTION, false);
911 if (tabular->IsFirstCellInRow(actcell))
914 sel_cell_end = actcell;
915 updateLocal(bv, SELECTION, false);
918 result = moveLeft(bv);
919 sel_cell_start = sel_cell_end = actcell;
921 updateLocal(bv, SELECTION, false);
925 int const ocell = actcell;
927 if ((ocell == sel_cell_end) ||
928 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
929 sel_cell_end = tabular->GetCellBelow(sel_cell_end);
931 sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
932 updateLocal(bv, SELECTION, false);
936 result = moveDown(bv, old_locking_inset != 0);
937 sel_cell_start = sel_cell_end = actcell;
939 updateLocal(bv, SELECTION, false);
943 int const ocell = actcell;
945 if ((ocell == sel_cell_end) ||
946 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
947 sel_cell_end = tabular->GetCellAbove(sel_cell_end);
949 sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
950 updateLocal(bv, SELECTION, false);
954 result = moveUp(bv, old_locking_inset != 0);
955 sel_cell_start = sel_cell_end = actcell;
957 updateLocal(bv, SELECTION, false);
961 if (the_locking_inset) {
962 unlockInsetInInset(bv, the_locking_inset);
963 the_locking_inset = 0;
965 if (bv->text->first + bv->painter().paperHeight() <
966 (top_baseline + tabular->GetHeightOfTabular()))
968 bv->scrollCB(bv->text->first + bv->painter().paperHeight());
969 updateLocal(bv, FULL, false);
970 actcell = tabular->GetCellBelow(first_visible_cell) + column;
972 actcell = tabular->GetFirstCellInRow(tabular->rows() - 1) + column;
975 updateLocal(bv, CURSOR, false);
980 if (the_locking_inset) {
981 unlockInsetInInset(bv, the_locking_inset);
982 the_locking_inset = 0;
984 if (top_baseline < 0) {
985 bv->scrollCB(bv->text->first - bv->painter().paperHeight());
986 updateLocal(bv, FULL, false);
987 if (top_baseline > 0)
990 actcell = tabular->GetCellBelow(first_visible_cell) + column;
995 updateLocal(bv, CURSOR, false);
1006 case LFUN_LAYOUT_TABULAR:
1008 bv->owner()->getDialogs()->showTabular(this);
1011 case LFUN_TABULAR_FEATURE:
1012 if (!tabularFeatures(bv, arg))
1013 result = UNDISPATCHED;
1016 if (!copySelection(bv))
1018 setUndo(bv, Undo::DELETE,
1019 bv->text->cursor.par(),
1020 bv->text->cursor.par()->next());
1022 updateLocal(bv, INIT, true);
1025 if (!hasSelection())
1030 case LFUN_PASTESELECTION:
1032 string const clip(bv->getClipboard());
1036 if (clip.find('\t') != string::npos) {
1040 string::size_type len = clip.length();
1041 string::size_type p = 0;
1044 ((p = clip.find_first_of("\t\n", p)) != string::npos)) {
1052 maxCols = max(cols, maxCols);
1058 maxCols = max(cols, maxCols);
1059 delete paste_tabular;
1060 paste_tabular = new LyXTabular(this, rows, maxCols);
1061 string::size_type op = 0;
1063 int cells = paste_tabular->GetNumberOfCells();
1065 while((cell < cells) && (p < len) &&
1066 (p = clip.find_first_of("\t\n", p)) != string::npos) {
1071 paste_tabular->GetCellInset(cell)->setText(clip.substr(op, p-op));
1076 paste_tabular->GetCellInset(cell)->setText(clip.substr(op, p-op));
1077 while(cols++ < maxCols)
1085 // check for the last cell if there is no trailing '\n'
1086 if ((cell < cells) && (op < len))
1087 paste_tabular->GetCellInset(cell)->setText(clip.substr(op, len-op));
1089 // so that the clipboard is used and it goes on
1091 // and executes LFUN_PASTESELECTION in insettext!
1092 delete paste_tabular;
1097 if (hasPasteBuffer()) {
1098 setUndo(bv, Undo::INSERT,
1099 bv->text->cursor.par(),
1100 bv->text->cursor.par()->next());
1102 updateLocal(bv, INIT, true);
1105 // ATTENTION: the function above has to be PASTE and PASTESELECTION!!!
1107 // we try to activate the actual inset and put this event down to
1108 // the insets dispatch function.
1109 result = UNDISPATCHED;
1110 if (the_locking_inset)
1113 if (activateCellInset(bv)) {
1114 // reset need_update setted in above function!
1116 result = the_locking_inset->localDispatch(bv, action, arg);
1117 if ((result == UNDISPATCHED) || (result >= FINISHED)) {
1118 unlockInsetInInset(bv, the_locking_inset);
1120 the_locking_inset = 0;
1121 // we need to update if this was requested before
1122 updateLocal(bv, NONE, false);
1123 return UNDISPATCHED;
1128 updateLocal(bv, CELL, false);
1133 if (result < FINISHED) {
1134 if (!the_locking_inset) {
1135 showInsetCursor(bv);
1138 bv->unlockInset(this);
1143 int InsetTabular::latex(Buffer const * buf, ostream & os,
1144 bool fragile, bool fp) const
1146 return tabular->Latex(buf, os, fragile, fp);
1150 int InsetTabular::ascii(Buffer const * buf, ostream & os, int) const
1152 // This should be changed to a real ascii export
1153 return tabular->Ascii(buf, os);
1157 int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const
1159 return tabular->Ascii(buf,os);
1163 int InsetTabular::docbook(Buffer const * buf, ostream & os) const
1168 // if the table is inside a float it doesn't need the informaltable
1169 // wrapper. Search for it.
1170 for(master = owner();
1171 master && master->lyxCode() != Inset::FLOAT_CODE;
1172 master = master->owner());
1175 os << "<informaltable>\n";
1178 ret+= tabular->DocBook(buf,os);
1180 os << "</informaltable>\n";
1187 void InsetTabular::validate(LaTeXFeatures & features) const
1189 tabular->Validate(features);
1193 bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
1194 LyXFont const & font,
1201 bool changed = false;
1203 // if we have a locking_inset we should have to check only this cell for
1204 // change so I'll try this to have a boost, but who knows ;)
1205 if ((need_update != INIT) &&
1206 (the_locking_inset == tabular->GetCellInset(actcell))) {
1207 for(int i = 0; i < tabular->columns(); ++i) {
1208 maxAsc = max(tabular->GetCellInset(actrow, i)->ascent(bv, font),
1210 maxDesc = max(tabular->GetCellInset(actrow, i)->descent(bv, font),
1213 changed = tabular->SetWidthOfCell(actcell, the_locking_inset->width(bv, font));
1214 changed = tabular->SetAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed;
1215 changed = tabular->SetDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed;
1218 for (int i = 0; i < tabular->rows(); ++i) {
1221 for (int j = 0; j < tabular->columns(); ++j) {
1222 if (tabular->IsPartOfMultiColumn(i,j))
1225 inset = tabular->GetCellInset(cell);
1226 if (!reinit && !tabular->GetPWidth(cell).empty())
1227 inset->update(bv, font, false);
1228 maxAsc = max(maxAsc, inset->ascent(bv, font));
1229 maxDesc = max(maxDesc, inset->descent(bv, font));
1230 changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
1232 changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
1233 changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
1239 void InsetTabular::getCursorPos(BufferView * bv, int & x, int & y) const
1241 if (the_locking_inset) {
1242 the_locking_inset->getCursorPos(bv, x, y);
1245 x = cursor_.x() - top_x;
1250 void InsetTabular::toggleInsetCursor(BufferView * bv)
1252 if (the_locking_inset) {
1253 the_locking_inset->toggleInsetCursor(bv);
1257 LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
1259 int const asc = lyxfont::maxAscent(font);
1260 int const desc = lyxfont::maxDescent(font);
1262 if (isCursorVisible())
1263 bv->hideLockedInsetCursor();
1265 bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1266 toggleCursorVisible();
1270 void InsetTabular::showInsetCursor(BufferView * bv, bool show)
1272 if (!isCursorVisible()) {
1273 LyXFont font; // = GetFont(par, cursor.pos);
1275 int const asc = lyxfont::maxAscent(font);
1276 int const desc = lyxfont::maxDescent(font);
1277 bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1279 bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1280 setCursorVisible(true);
1285 void InsetTabular::hideInsetCursor(BufferView * bv)
1287 if (isCursorVisible()) {
1288 bv->hideLockedInsetCursor();
1289 setCursorVisible(false);
1294 void InsetTabular::fitInsetCursor(BufferView * bv) const
1296 if (the_locking_inset) {
1297 the_locking_inset->fitInsetCursor(bv);
1302 int const asc = lyxfont::maxAscent(font);
1303 int const desc = lyxfont::maxDescent(font);
1304 bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
1308 void InsetTabular::setPos(BufferView * bv, int x, int y) const
1312 actcell = actrow = actcol = 0;
1313 int ly = tabular->GetDescentOfRow(actrow);
1315 // first search the right row
1316 while((ly < y) && ((actrow+1) < tabular->rows())) {
1317 cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) +
1318 tabular->GetAscentOfRow(actrow + 1) +
1319 tabular->GetAdditionalHeight(actrow + 1));
1321 ly = cursor_.y() + tabular->GetDescentOfRow(actrow);
1323 actcell = tabular->GetCellNumber(actrow, actcol);
1325 // now search the right column
1326 int lx = tabular->GetWidthOfColumn(actcell) -
1327 tabular->GetAdditionalWidth(actcell);
1328 for (; !tabular->IsLastCellInRow(actcell) && lx < x; ++actcell) {
1329 lx += tabular->GetWidthOfColumn(actcell + 1)
1330 + tabular->GetAdditionalWidth(actcell);
1332 cursor_.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
1337 int InsetTabular::getCellXPos(int cell) const
1341 for (; !tabular->IsFirstCellInRow(c); --c)
1343 int lx = tabular->GetWidthOfColumn(cell);
1344 for (; c < cell; ++c) {
1345 lx += tabular->GetWidthOfColumn(c);
1347 return (lx - tabular->GetWidthOfColumn(cell) + top_x);
1351 void InsetTabular::resetPos(BufferView * bv) const
1353 if (!locked || nodraw())
1355 #warning This should be fixed in the right manner (20011128 Jug)
1356 // fast hack to fix infinite repaintings!
1359 in_reset_pos = true;
1361 actcol = tabular->column_of_cell(actcell);
1366 for (; (cell < actcell) && !tabular->IsLastRow(cell); ++cell) {
1367 if (tabular->IsLastCellInRow(cell)) {
1368 cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) +
1369 tabular->GetAscentOfRow(actrow + 1) +
1370 tabular->GetAdditionalHeight(actrow + 1));
1374 static int const offset = ADD_TO_TABULAR_WIDTH + 2;
1375 int new_x = getCellXPos(actcell);
1376 int old_x = cursor_.x();
1379 // cursor.x(getCellXPos(actcell) + offset);
1380 if ((actcol < tabular->columns()-1) && scroll(false) &&
1381 (tabular->GetWidthOfTabular() < bv->workWidth()-20))
1384 updateLocal(bv, FULL, false);
1385 } else if (the_locking_inset &&
1386 (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20))
1388 int xx = cursor_.x() - offset + bv->text->getRealCursorX(bv);
1389 if (xx > (bv->workWidth()-20)) {
1390 scroll(bv, -(xx - bv->workWidth() + 60));
1391 updateLocal(bv, FULL, false);
1392 } else if (xx < 20) {
1398 updateLocal(bv, FULL, false);
1400 } else if ((cursor_.x() - offset) > 20 &&
1401 (cursor_.x() - offset + tabular->GetWidthOfColumn(actcell))
1402 > (bv->workWidth() - 20)) {
1403 scroll(bv, -tabular->GetWidthOfColumn(actcell) - 20);
1404 updateLocal(bv, FULL, false);
1405 } else if ((cursor_.x() - offset) < 20) {
1406 scroll(bv, 20 - cursor_.x() + offset);
1407 updateLocal(bv, FULL, false);
1408 } else if (scroll(false) && top_x > 20 &&
1409 (top_x + tabular->GetWidthOfTabular()) > (bv->workWidth() - 20)) {
1410 scroll(bv, old_x - cursor_.x());
1411 updateLocal(bv, FULL, false);
1413 if (the_locking_inset) {
1414 inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1415 inset_y = cursor_.y();
1417 if ((!the_locking_inset ||
1418 !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) &&
1419 actcell != oldcell) {
1420 InsetTabular * inset = const_cast<InsetTabular *>(this);
1421 bv->owner()->getDialogs()->updateTabular(inset);
1424 in_reset_pos = false;
1428 UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
1430 if (lock && !old_locking_inset) {
1431 if (activateCellInset(bv))
1434 bool moved = isRightToLeft(bv)
1435 ? movePrevCell(bv) : moveNextCell(bv);
1437 return FINISHED_RIGHT;
1438 if (lock && activateCellInset(bv))
1442 return DISPATCHED_NOUPDATE;
1446 UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
1448 bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
1451 if (lock) { // behind the inset
1452 if (activateCellInset(bv, 0, 0, 0, true))
1456 return DISPATCHED_NOUPDATE;
1460 UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
1462 int const ocell = actcell;
1463 actcell = tabular->GetCellAbove(actcell);
1464 if (actcell == ocell) // we moved out of the inset
1470 if (old_locking_inset) {
1471 old_locking_inset->getCursorPos(bv, x, y);
1472 x -= cursor_.x() + tabular->GetBeginningOfTextInCell(actcell);
1474 if (activateCellInset(bv, x, 0))
1477 return DISPATCHED_NOUPDATE;
1481 UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
1483 int const ocell = actcell;
1484 actcell = tabular->GetCellBelow(actcell);
1485 if (actcell == ocell) // we moved out of the inset
1486 return FINISHED_DOWN;
1491 if (old_locking_inset) {
1492 old_locking_inset->getCursorPos(bv, x, y);
1493 x -= cursor_.x() + tabular->GetBeginningOfTextInCell(actcell);
1495 if (activateCellInset(bv, x, 0))
1498 return DISPATCHED_NOUPDATE;
1502 bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
1504 if (isRightToLeft(bv)) {
1505 if (tabular->IsFirstCellInRow(actcell)) {
1506 int row = tabular->row_of_cell(actcell);
1507 if (row == tabular->rows() - 1)
1509 actcell = tabular->GetLastCellInRow(row);
1510 actcell = tabular->GetCellBelow(actcell);
1517 if (tabular->IsLastCell(actcell))
1522 bool rtl = tabular->GetCellInset(actcell)->paragraph()->
1523 isRightToLeftPar(bv->buffer()->params);
1524 activateCellInset(bv, 0, 0, 0, !rtl);
1531 bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
1533 if (isRightToLeft(bv)) {
1534 if (tabular->IsLastCellInRow(actcell)) {
1535 int row = tabular->row_of_cell(actcell);
1538 actcell = tabular->GetFirstCellInRow(row);
1539 actcell = tabular->GetCellAbove(actcell);
1541 if (tabular->IsLastCell(actcell))
1546 if (!actcell) // first cell
1551 bool rtl = tabular->GetCellInset(actcell)->paragraph()->
1552 isRightToLeftPar(bv->buffer()->params);
1553 activateCellInset(bv, 0, 0, 0, !rtl);
1560 bool InsetTabular::deletable() const
1566 void InsetTabular::setFont(BufferView * bv, LyXFont const & font, bool tall,
1571 sel_cell_end = tabular->GetNumberOfCells() - 1;
1573 if (hasSelection()) {
1574 setUndo(bv, Undo::EDIT,
1575 bv->text->cursor.par(),
1576 bv->text->cursor.par()->next());
1577 bool frozen = undo_frozen;
1580 // apply the fontchange on the whole selection
1585 getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
1586 for(int i = sel_row_start; i <= sel_row_end; ++i) {
1587 for(int j = sel_col_start; j <= sel_col_end; ++j) {
1588 tabular->GetCellInset(i, j)->setFont(bv, font, tall, true);
1593 updateLocal(bv, INIT, true);
1595 if (the_locking_inset)
1596 the_locking_inset->setFont(bv, font, tall);
1600 bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
1602 LyXTabular::Feature action = LyXTabular::LAST_ACTION;
1605 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
1606 string const tmp = tabularFeature[i].feature;
1608 if (tmp == what.substr(0, tmp.length())) {
1609 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
1610 //tabularFeatures[i].feature.length())) {
1611 action = tabularFeature[i].action;
1615 if (action == LyXTabular::LAST_ACTION)
1619 frontStrip(what.substr(tabularFeature[i].feature.length()));
1620 tabularFeatures(bv, action, val);
1625 void InsetTabular::tabularFeatures(BufferView * bv,
1626 LyXTabular::Feature feature,
1627 string const & value)
1633 bool setLines = false;
1634 LyXAlignment setAlign = LYX_ALIGN_LEFT;
1635 LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
1638 case LyXTabular::M_ALIGN_LEFT:
1639 case LyXTabular::ALIGN_LEFT:
1640 setAlign=LYX_ALIGN_LEFT;
1642 case LyXTabular::M_ALIGN_RIGHT:
1643 case LyXTabular::ALIGN_RIGHT:
1644 setAlign=LYX_ALIGN_RIGHT;
1646 case LyXTabular::M_ALIGN_CENTER:
1647 case LyXTabular::ALIGN_CENTER:
1648 setAlign=LYX_ALIGN_CENTER;
1650 case LyXTabular::M_VALIGN_TOP:
1651 case LyXTabular::VALIGN_TOP:
1652 setVAlign=LyXTabular::LYX_VALIGN_TOP;
1654 case LyXTabular::M_VALIGN_BOTTOM:
1655 case LyXTabular::VALIGN_BOTTOM:
1656 setVAlign=LyXTabular::LYX_VALIGN_BOTTOM;
1658 case LyXTabular::M_VALIGN_CENTER:
1659 case LyXTabular::VALIGN_CENTER:
1660 setVAlign=LyXTabular::LYX_VALIGN_CENTER;
1665 if (hasSelection()) {
1666 getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
1668 sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
1669 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1671 setUndo(bv, Undo::FINISH,
1672 bv->text->cursor.par(),
1673 bv->text->cursor.par()->next());
1675 LyXTabular::ltType ltt;
1676 int row = ltt.row = tabular->row_of_cell(actcell);
1677 int column = tabular->column_of_cell(actcell);
1681 case LyXTabular::SET_PWIDTH:
1683 bool const update = (tabular->GetColumnPWidth(actcell) != value);
1684 tabular->SetColumnPWidth(actcell,value);
1686 for (int i = 0; i < tabular->rows(); ++i) {
1687 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1690 updateLocal(bv, INIT, true);
1694 case LyXTabular::SET_MPWIDTH:
1696 bool const update = (tabular->GetPWidth(actcell) != value);
1697 tabular->SetMColumnPWidth(actcell,value);
1699 for (int i = 0; i < tabular->rows(); ++i) {
1700 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1703 updateLocal(bv, INIT, true);
1707 case LyXTabular::SET_SPECIAL_COLUMN:
1708 case LyXTabular::SET_SPECIAL_MULTI:
1709 tabular->SetAlignSpecial(actcell,value,feature);
1710 updateLocal(bv, FULL, true);
1712 case LyXTabular::APPEND_ROW:
1713 // append the row into the tabular
1714 unlockInsetInInset(bv, the_locking_inset);
1715 tabular->AppendRow(actcell);
1716 updateLocal(bv, INIT, true);
1718 case LyXTabular::APPEND_COLUMN:
1719 // append the column into the tabular
1720 unlockInsetInInset(bv, the_locking_inset);
1721 tabular->AppendColumn(actcell);
1722 actcell = tabular->GetCellNumber(row, column);
1723 updateLocal(bv, INIT, true);
1725 case LyXTabular::DELETE_ROW:
1726 unlockInsetInInset(bv, the_locking_inset);
1727 for(int i = sel_row_start; i <= sel_row_end; ++i) {
1728 tabular->DeleteRow(sel_row_start);
1730 if (sel_row_start >= tabular->rows())
1732 actcell = tabular->GetCellNumber(sel_row_start, column);
1734 updateLocal(bv, INIT, true);
1736 case LyXTabular::DELETE_COLUMN:
1737 unlockInsetInInset(bv, the_locking_inset);
1738 for(int i = sel_col_start; i <= sel_col_end; ++i) {
1739 tabular->DeleteColumn(sel_col_start);
1741 if (sel_col_start >= tabular->columns())
1743 actcell = tabular->GetCellNumber(row, sel_col_start);
1745 updateLocal(bv, INIT, true);
1747 case LyXTabular::M_TOGGLE_LINE_TOP:
1749 case LyXTabular::TOGGLE_LINE_TOP:
1751 bool lineSet = !tabular->TopLine(actcell, flag);
1752 for (int i = sel_row_start; i <= sel_row_end; ++i)
1753 for (int j = sel_col_start; j <= sel_col_end; ++j)
1754 tabular->SetTopLine(
1755 tabular->GetCellNumber(i, j),
1757 updateLocal(bv, INIT, true);
1761 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1763 case LyXTabular::TOGGLE_LINE_BOTTOM:
1765 bool lineSet = !tabular->BottomLine(actcell, flag);
1766 for (int i = sel_row_start; i <= sel_row_end; ++i)
1767 for (int j = sel_col_start; j <= sel_col_end; ++j)
1768 tabular->SetBottomLine(
1769 tabular->GetCellNumber(i, j),
1772 updateLocal(bv, INIT, true);
1776 case LyXTabular::M_TOGGLE_LINE_LEFT:
1778 case LyXTabular::TOGGLE_LINE_LEFT:
1780 bool lineSet = !tabular->LeftLine(actcell, flag);
1781 for (int i = sel_row_start; i <= sel_row_end; ++i)
1782 for (int j = sel_col_start; j <= sel_col_end; ++j)
1783 tabular->SetLeftLine(
1784 tabular->GetCellNumber(i,j),
1787 updateLocal(bv, INIT, true);
1791 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1793 case LyXTabular::TOGGLE_LINE_RIGHT:
1795 bool lineSet = !tabular->RightLine(actcell, flag);
1796 for (int i = sel_row_start; i <= sel_row_end; ++i)
1797 for (int j = sel_col_start; j <= sel_col_end; ++j)
1798 tabular->SetRightLine(
1799 tabular->GetCellNumber(i,j),
1802 updateLocal(bv, INIT, true);
1806 case LyXTabular::M_ALIGN_LEFT:
1807 case LyXTabular::M_ALIGN_RIGHT:
1808 case LyXTabular::M_ALIGN_CENTER:
1810 case LyXTabular::ALIGN_LEFT:
1811 case LyXTabular::ALIGN_RIGHT:
1812 case LyXTabular::ALIGN_CENTER:
1813 for (int i = sel_row_start; i <= sel_row_end; ++i)
1814 for (int j = sel_col_start; j <= sel_col_end; ++j)
1815 tabular->SetAlignment(
1816 tabular->GetCellNumber(i, j),
1819 updateLocal(bv, INIT, true);
1821 case LyXTabular::M_VALIGN_TOP:
1822 case LyXTabular::M_VALIGN_BOTTOM:
1823 case LyXTabular::M_VALIGN_CENTER:
1825 case LyXTabular::VALIGN_TOP:
1826 case LyXTabular::VALIGN_BOTTOM:
1827 case LyXTabular::VALIGN_CENTER:
1828 for (int i = sel_row_start; i <= sel_row_end; ++i)
1829 for (int j = sel_col_start; j <= sel_col_end; ++j)
1830 tabular->SetVAlignment(
1831 tabular->GetCellNumber(i, j),
1833 updateLocal(bv, INIT, true);
1835 case LyXTabular::MULTICOLUMN:
1837 if (sel_row_start != sel_row_end) {
1838 Alert::alert(_("Impossible Operation!"),
1839 _("Multicolumns can only be horizontally."),
1843 // just multicol for one Single Cell
1844 if (!hasSelection()) {
1845 // check wether we are completly in a multicol
1846 if (tabular->IsMultiColumn(actcell)) {
1847 tabular->UnsetMultiColumn(actcell);
1848 updateLocal(bv, INIT, true);
1850 tabular->SetMultiColumn(actcell, 1);
1851 updateLocal(bv, CELL, true);
1855 // we have a selection so this means we just add all this
1856 // cells to form a multicolumn cell
1860 if (sel_cell_start > sel_cell_end) {
1861 s_start = sel_cell_end;
1862 s_end = sel_cell_start;
1864 s_start = sel_cell_start;
1865 s_end = sel_cell_end;
1867 tabular->SetMultiColumn(s_start, s_end - s_start + 1);
1869 sel_cell_end = sel_cell_start;
1870 updateLocal(bv, INIT, true);
1873 case LyXTabular::SET_ALL_LINES:
1875 case LyXTabular::UNSET_ALL_LINES:
1876 for (int i = sel_row_start; i <= sel_row_end; ++i)
1877 for (int j = sel_col_start; j <= sel_col_end; ++j)
1878 tabular->SetAllLines(
1879 tabular->GetCellNumber(i,j), setLines);
1880 updateLocal(bv, INIT, true);
1882 case LyXTabular::SET_LONGTABULAR:
1883 tabular->SetLongTabular(true);
1884 updateLocal(bv, INIT, true); // because this toggles displayed
1886 case LyXTabular::UNSET_LONGTABULAR:
1887 tabular->SetLongTabular(false);
1888 updateLocal(bv, INIT, true); // because this toggles displayed
1890 case LyXTabular::SET_ROTATE_TABULAR:
1891 tabular->SetRotateTabular(true);
1893 case LyXTabular::UNSET_ROTATE_TABULAR:
1894 tabular->SetRotateTabular(false);
1896 case LyXTabular::SET_ROTATE_CELL:
1897 for (int i = sel_row_start; i <= sel_row_end; ++i)
1898 for (int j = sel_col_start; j<=sel_col_end; ++j)
1899 tabular->SetRotateCell(
1900 tabular->GetCellNumber(i, j),
1903 case LyXTabular::UNSET_ROTATE_CELL:
1904 for (int i = sel_row_start; i <= sel_row_end; ++i)
1905 for (int j = sel_col_start; j <= sel_col_end; ++j)
1906 tabular->SetRotateCell(
1907 tabular->GetCellNumber(i, j), false);
1909 case LyXTabular::SET_USEBOX:
1911 LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
1912 if (val == tabular->GetUsebox(actcell))
1913 val = LyXTabular::BOX_NONE;
1914 for (int i = sel_row_start; i <= sel_row_end; ++i)
1915 for (int j = sel_col_start; j <= sel_col_end; ++j)
1917 tabular->GetCellNumber(i, j), val);
1920 case LyXTabular::UNSET_LTFIRSTHEAD:
1922 case LyXTabular::SET_LTFIRSTHEAD:
1923 tabular->SetLTHead(ltt, true);
1925 case LyXTabular::UNSET_LTHEAD:
1927 case LyXTabular::SET_LTHEAD:
1928 tabular->SetLTHead(ltt, false);
1930 case LyXTabular::UNSET_LTFOOT:
1932 case LyXTabular::SET_LTFOOT:
1933 tabular->SetLTFoot(ltt, false);
1935 case LyXTabular::UNSET_LTLASTFOOT:
1937 case LyXTabular::SET_LTLASTFOOT:
1938 tabular->SetLTFoot(ltt, true);
1940 case LyXTabular::SET_LTNEWPAGE:
1942 bool what = !tabular->GetLTNewPage(actcell);
1943 tabular->SetLTNewPage(actcell, what);
1946 // dummy stuff just to avoid warnings
1947 case LyXTabular::LAST_ACTION:
1953 bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
1956 UpdatableInset * inset =
1957 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
1958 LyXFont font(LyXFont::ALL_SANE);
1960 x = inset->x() + inset->width(bv, font);
1961 y = inset->descent(bv, font);
1963 //inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1964 //inset_y = cursor.y();
1965 inset->edit(bv, x, y, button);
1966 if (!the_locking_inset)
1968 updateLocal(bv, CELL, false);
1969 return (the_locking_inset != 0);
1973 bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
1976 inset_x = cursor_.x()
1977 - top_x + tabular->GetBeginningOfTextInCell(actcell);
1978 inset_y = cursor_.y();
1979 return activateCellInset(bv, x - inset_x, y - inset_y, button);
1983 bool InsetTabular::insetHit(BufferView *, int x, int) const
1986 > (cursor_.x() + tabular->GetBeginningOfTextInCell(actcell));
1990 // This returns paperWidth() if the cell-width is unlimited or the width
1991 // in pixels if we have a pwidth for this cell.
1992 int InsetTabular::getMaxWidthOfCell(BufferView * bv, int cell) const
1994 string const s = tabular->GetPWidth(cell);
1998 return VSpace(s).inPixels(bv);
2002 int InsetTabular::getMaxWidth(BufferView * bv,
2003 UpdatableInset const * inset) const
2005 int cell = tabular->cur_cell;
2006 if (tabular->GetCellInset(cell) != inset) {
2008 if (tabular->GetCellInset(cell) != inset) {
2010 lyxerr[Debug::INSETTEXT] << "Actcell not equal to actual cell!\n";
2015 int const n = tabular->GetNumberOfCells();
2018 for (cell = 0; cell < n; ++cell) {
2019 if (tabular->GetCellInset(cell) == inset)
2025 lyxerr << "Own inset not found, shouldn't really happen!\n";
2029 int w = getMaxWidthOfCell(bv, cell);
2031 // because the inset then subtracts it's top_x and owner->x()
2032 w += (inset->x() - top_x);
2039 void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
2041 resizeLyXText(bv, recursive);
2045 void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
2048 for(int i = 0; i < tabular->rows(); ++i) {
2049 for(int j = 0; j < tabular->columns(); ++j) {
2050 tabular->GetCellInset(i, j)->resizeLyXText(bv, true);
2058 LyXText * InsetTabular::getLyXText(BufferView const * bv,
2059 bool const recursive) const
2061 if (the_locking_inset)
2062 return the_locking_inset->getLyXText(bv, recursive);
2064 // if we're locked lock the actual insettext and return it's LyXText!!!
2066 UpdatableInset * inset =
2067 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2068 inset->edit(const_cast<BufferView *>(bv), 0, 0, 0);
2069 return the_locking_inset->getLyXText(bv, recursive);
2072 return Inset::getLyXText(bv, recursive);
2076 bool InsetTabular::showInsetDialog(BufferView * bv) const
2078 if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv))
2079 bv->owner()->getDialogs()
2080 ->showTabular(const_cast<InsetTabular *>(this));
2085 void InsetTabular::openLayoutDialog(BufferView * bv) const
2087 if (the_locking_inset) {
2088 InsetTabular * i = static_cast<InsetTabular *>
2089 (the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE));
2091 i->openLayoutDialog(bv);
2095 bv->owner()->getDialogs()->showTabular(
2096 const_cast<InsetTabular *>(this));
2101 // functions returns:
2105 // 3 ... toggled off
2107 func_status::value_type InsetTabular::getStatus(string const & what) const
2109 int action = LyXTabular::LAST_ACTION;
2110 func_status::value_type status = func_status::OK;
2113 for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
2114 string const tmp = tabularFeature[i].feature;
2115 if (tmp == what.substr(0, tmp.length())) {
2116 //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
2117 // tabularFeatures[i].feature.length())) {
2118 action = tabularFeature[i].action;
2122 if (action == LyXTabular::LAST_ACTION)
2123 return func_status::Unknown;
2125 string const argument = frontStrip(what.substr(tabularFeature[i].feature.length()));
2130 LyXTabular::ltType dummyltt;
2133 if (hasSelection()) {
2134 getSelection(sel_row_start, sel_row_end, dummy, dummy);
2136 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
2140 case LyXTabular::SET_PWIDTH:
2141 case LyXTabular::SET_MPWIDTH:
2142 case LyXTabular::SET_SPECIAL_COLUMN:
2143 case LyXTabular::SET_SPECIAL_MULTI:
2144 status |= func_status::Disabled;
2147 case LyXTabular::APPEND_ROW:
2148 case LyXTabular::APPEND_COLUMN:
2149 case LyXTabular::DELETE_ROW:
2150 case LyXTabular::DELETE_COLUMN:
2151 case LyXTabular::SET_ALL_LINES:
2152 case LyXTabular::UNSET_ALL_LINES:
2153 status |= func_status::OK;
2156 case LyXTabular::MULTICOLUMN:
2157 if (tabular->IsMultiColumn(actcell))
2158 status |= func_status::ToggleOn;
2160 status |= func_status::ToggleOff;
2162 case LyXTabular::M_TOGGLE_LINE_TOP:
2164 case LyXTabular::TOGGLE_LINE_TOP:
2165 if (tabular->TopLine(actcell, flag))
2166 status |= func_status::ToggleOn;
2168 status |= func_status::ToggleOff;
2170 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
2172 case LyXTabular::TOGGLE_LINE_BOTTOM:
2173 if (tabular->BottomLine(actcell, flag))
2174 status |= func_status::ToggleOn;
2176 status |= func_status::ToggleOff;
2178 case LyXTabular::M_TOGGLE_LINE_LEFT:
2180 case LyXTabular::TOGGLE_LINE_LEFT:
2181 if (tabular->LeftLine(actcell, flag))
2182 status |= func_status::ToggleOn;
2184 status |= func_status::ToggleOff;
2186 case LyXTabular::M_TOGGLE_LINE_RIGHT:
2188 case LyXTabular::TOGGLE_LINE_RIGHT:
2189 if (tabular->RightLine(actcell, flag))
2190 status |= func_status::ToggleOn;
2192 status |= func_status::ToggleOff;
2194 case LyXTabular::M_ALIGN_LEFT:
2196 case LyXTabular::ALIGN_LEFT:
2197 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT)
2198 status |= func_status::ToggleOn;
2200 status |= func_status::ToggleOff;
2202 case LyXTabular::M_ALIGN_RIGHT:
2204 case LyXTabular::ALIGN_RIGHT:
2205 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT)
2206 status |= func_status::ToggleOn;
2208 status |= func_status::ToggleOff;
2210 case LyXTabular::M_ALIGN_CENTER:
2212 case LyXTabular::ALIGN_CENTER:
2213 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER)
2214 status |= func_status::ToggleOn;
2216 status |= func_status::ToggleOff;
2218 case LyXTabular::M_VALIGN_TOP:
2220 case LyXTabular::VALIGN_TOP:
2221 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP)
2222 status |= func_status::ToggleOn;
2224 status |= func_status::ToggleOff;
2226 case LyXTabular::M_VALIGN_BOTTOM:
2228 case LyXTabular::VALIGN_BOTTOM:
2229 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM)
2230 status |= func_status::ToggleOn;
2232 status |= func_status::ToggleOff;
2234 case LyXTabular::M_VALIGN_CENTER:
2236 case LyXTabular::VALIGN_CENTER:
2237 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER)
2238 status |= func_status::ToggleOn;
2240 status |= func_status::ToggleOff;
2242 case LyXTabular::SET_LONGTABULAR:
2243 if (tabular->IsLongTabular())
2244 status |= func_status::ToggleOn;
2246 status |= func_status::ToggleOff;
2248 case LyXTabular::UNSET_LONGTABULAR:
2249 if (!tabular->IsLongTabular())
2250 status |= func_status::ToggleOn;
2252 status |= func_status::ToggleOff;
2254 case LyXTabular::SET_ROTATE_TABULAR:
2255 if (tabular->GetRotateTabular())
2256 status |= func_status::ToggleOn;
2258 status |= func_status::ToggleOff;
2260 case LyXTabular::UNSET_ROTATE_TABULAR:
2261 if (!tabular->GetRotateTabular())
2262 status |= func_status::ToggleOn;
2264 status |= func_status::ToggleOff;
2266 case LyXTabular::SET_ROTATE_CELL:
2267 if (tabular->GetRotateCell(actcell))
2268 status |= func_status::ToggleOn;
2270 status |= func_status::ToggleOff;
2272 case LyXTabular::UNSET_ROTATE_CELL:
2273 if (!tabular->GetRotateCell(actcell))
2274 status |= func_status::ToggleOn;
2276 status |= func_status::ToggleOff;
2278 case LyXTabular::SET_USEBOX:
2279 if (strToInt(argument) == tabular->GetUsebox(actcell))
2280 status |= func_status::ToggleOn;
2282 status |= func_status::ToggleOff;
2284 case LyXTabular::SET_LTFIRSTHEAD:
2285 if (tabular->GetRowOfLTHead(actcell, dummyltt))
2286 status |= func_status::ToggleOn;
2288 status |= func_status::ToggleOff;
2290 case LyXTabular::SET_LTHEAD:
2291 if (tabular->GetRowOfLTHead(actcell, dummyltt))
2292 status |= func_status::ToggleOn;
2294 status |= func_status::ToggleOff;
2296 case LyXTabular::SET_LTFOOT:
2297 if (tabular->GetRowOfLTFoot(actcell, dummyltt))
2298 status |= func_status::ToggleOn;
2300 status |= func_status::ToggleOff;
2302 case LyXTabular::SET_LTLASTFOOT:
2303 if (tabular->GetRowOfLTFoot(actcell, dummyltt))
2304 status |= func_status::ToggleOn;
2306 status |= func_status::ToggleOff;
2308 case LyXTabular::SET_LTNEWPAGE:
2309 if (tabular->GetLTNewPage(actcell))
2310 status |= func_status::ToggleOn;
2312 status |= func_status::ToggleOff;
2315 status = func_status::Disabled;
2322 std::vector<string> const InsetTabular::getLabelList() const
2324 return tabular->getLabelList();
2328 bool InsetTabular::copySelection(BufferView * bv)
2330 if (!hasSelection())
2333 int sel_col_start = tabular->column_of_cell(sel_cell_start);
2334 int sel_col_end = tabular->column_of_cell(sel_cell_end);
2335 if (sel_col_start > sel_col_end) {
2336 sel_col_start = sel_col_end;
2337 sel_col_end = tabular->right_column_of_cell(sel_cell_start);
2339 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
2341 int const columns = sel_col_end - sel_col_start + 1;
2343 int sel_row_start = tabular->row_of_cell(sel_cell_start);
2344 int sel_row_end = tabular->row_of_cell(sel_cell_end);
2345 if (sel_row_start > sel_row_end) {
2346 swap(sel_row_start, sel_row_end);
2348 int const rows = sel_row_end - sel_row_start + 1;
2350 delete paste_tabular;
2351 paste_tabular = new LyXTabular(this, *tabular); // rows, columns);
2352 for (int i = 0; i < sel_row_start; ++i)
2353 paste_tabular->DeleteRow(0);
2354 while(paste_tabular->rows() > rows)
2355 paste_tabular->DeleteRow(rows);
2356 paste_tabular->SetTopLine(0, true, true);
2357 paste_tabular->SetBottomLine(paste_tabular->GetFirstCellInRow(rows-1),
2359 for (int i = 0; i < sel_col_start; ++i)
2360 paste_tabular->DeleteColumn(0);
2361 while (paste_tabular->columns() > columns)
2362 paste_tabular->DeleteColumn(columns);
2363 paste_tabular->SetLeftLine(0, true, true);
2364 paste_tabular->SetRightLine(paste_tabular->GetLastCellInRow(0),
2368 paste_tabular->Ascii(bv->buffer(), sstr);
2369 bv->stuffClipboard(sstr.str().c_str());
2374 bool InsetTabular::pasteSelection(BufferView * bv)
2379 for (int r1 = 0, r2 = actrow;
2380 (r1 < paste_tabular->rows()) && (r2 < tabular->rows());
2382 for(int c1 = 0, c2 = actcol;
2383 (c1 < paste_tabular->columns()) && (c2 < tabular->columns());
2385 if (paste_tabular->IsPartOfMultiColumn(r1,c1) &&
2386 tabular->IsPartOfMultiColumn(r2,c2))
2388 if (paste_tabular->IsPartOfMultiColumn(r1,c1)) {
2392 if (tabular->IsPartOfMultiColumn(r2,c2)) {
2396 int const n1 = paste_tabular->GetCellNumber(r1, c1);
2397 int const n2 = tabular->GetCellNumber(r2, c2);
2398 *(tabular->GetCellInset(n2)) = *(paste_tabular->GetCellInset(n1));
2399 tabular->GetCellInset(n2)->setOwner(this);
2400 tabular->GetCellInset(n2)->deleteLyXText(bv);
2407 bool InsetTabular::cutSelection()
2409 if (!hasSelection())
2412 int sel_col_start = tabular->column_of_cell(sel_cell_start);
2413 int sel_col_end = tabular->column_of_cell(sel_cell_end);
2414 if (sel_col_start > sel_col_end) {
2415 sel_col_start = sel_col_end;
2416 sel_col_end = tabular->right_column_of_cell(sel_cell_start);
2418 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
2420 int sel_row_start = tabular->row_of_cell(sel_cell_start);
2421 int sel_row_end = tabular->row_of_cell(sel_cell_end);
2422 if (sel_row_start > sel_row_end) {
2423 swap(sel_row_start, sel_row_end);
2425 if (sel_cell_start > sel_cell_end) {
2426 swap(sel_cell_start, sel_cell_end);
2428 for (int i = sel_row_start; i <= sel_row_end; ++i) {
2429 for (int j = sel_col_start; j <= sel_col_end; ++j) {
2430 tabular->GetCellInset(tabular->GetCellNumber(i, j))->clear();
2437 bool InsetTabular::isRightToLeft(BufferView *bv )
2439 return bv->getParentLanguage(this)->RightToLeft();
2443 bool InsetTabular::nodraw() const
2445 if (!UpdatableInset::nodraw() && the_locking_inset)
2446 return the_locking_inset->nodraw();
2447 return UpdatableInset::nodraw();
2451 int InsetTabular::scroll(bool recursive) const
2453 int sx = UpdatableInset::scroll(false);
2455 if (recursive && the_locking_inset)
2456 sx += the_locking_inset->scroll(recursive);
2462 bool InsetTabular::doClearArea() const
2464 return !locked || (need_update & (FULL|INIT));
2468 void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol) const
2470 srow = tabular->row_of_cell(sel_cell_start);
2471 erow = tabular->row_of_cell(sel_cell_end);
2475 scol = tabular->column_of_cell(sel_cell_start);
2476 ecol = tabular->column_of_cell(sel_cell_end);
2480 ecol = tabular->right_column_of_cell(sel_cell_end);
2484 Paragraph * InsetTabular::getParFromID(int id) const
2487 for(int i = 0; i < tabular->rows(); ++i) {
2488 for(int j = 0; j < tabular->columns(); ++j) {
2489 if ((result = tabular->GetCellInset(i, j)->getParFromID(id)))
2497 Paragraph * InsetTabular::firstParagraph() const
2499 if (the_locking_inset)
2500 return the_locking_inset->firstParagraph();
2505 Paragraph * InsetTabular::getFirstParagraph(int i) const
2507 return (i < tabular->GetNumberOfCells())
2508 ? tabular->GetCellInset(i)->getFirstParagraph(0)
2513 LyXCursor const & InsetTabular::cursor(BufferView * bv) const
2515 if (the_locking_inset)
2516 return the_locking_inset->cursor(bv);
2517 return Inset::cursor(bv);
2521 Inset * InsetTabular::getInsetFromID(int id_arg) const
2524 return const_cast<InsetTabular *>(this);
2527 for(int i=0; i < tabular->rows(); ++i) {
2528 for(int j=0; j < tabular->columns(); ++j) {
2529 if ((result = tabular->GetCellInset(i, j)->getInsetFromID(id_arg)))
2537 string const InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
2539 if (the_locking_inset) {
2540 string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
2543 if (tabular->IsLastCell(actcell)) {
2544 bv->unlockInset(const_cast<InsetTabular *>(this));
2550 // otherwise we have to lock the next inset and ask for it's selecttion
2551 UpdatableInset * inset =
2552 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2553 inset->edit(bv, 0, 0, 0);
2554 string const str(selectNextWordInt(bv, value));
2562 string InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
2564 // when entering this function the inset should be ALWAYS locked!
2565 lyx::Assert(the_locking_inset);
2567 string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
2571 if (tabular->IsLastCell(actcell)) {
2572 bv->unlockInset(const_cast<InsetTabular *>(this));
2576 // otherwise we have to lock the next inset and ask for it's selecttion
2577 UpdatableInset * inset =
2578 static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
2580 return selectNextWordInt(bv, value);
2584 void InsetTabular::selectSelectedWord(BufferView * bv)
2586 if (the_locking_inset) {
2587 the_locking_inset->selectSelectedWord(bv);
2594 void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
2596 if (the_locking_inset) {
2597 the_locking_inset->toggleSelection(bv, kill_selection);
2602 bool InsetTabular::searchForward(BufferView * bv, string const & str,
2603 bool const & cs, bool const & mw)
2605 if (the_locking_inset) {
2606 if (the_locking_inset->searchForward(bv, str, cs, mw))
2608 if (tabular->IsLastCell(actcell)) {
2609 bv->unlockInset(const_cast<InsetTabular *>(this));
2614 // otherwise we have to lock the next inset and search there
2615 UpdatableInset * inset =
2616 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2619 bool const res = searchForward(bv, str, cs, mw);
2620 updateLocal(bv, NONE, false);
2621 bv->updateInset(const_cast<InsetTabular *>(this), false);
2624 return searchForward(bv, str, cs, mw);
2629 bool InsetTabular::searchBackward(BufferView * bv, string const & str,
2630 bool const & cs, bool const & mw)
2632 if (the_locking_inset) {
2633 if (the_locking_inset->searchBackward(bv, str, cs, mw))
2635 if (!actcell) { // we are already in the first cell
2636 bv->unlockInset(const_cast<InsetTabular *>(this));
2641 // otherwise we have to lock the next inset and search there
2642 UpdatableInset * inset =
2643 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
2644 inset->edit(bv, false);
2646 bool const res = searchBackward(bv, str, cs, mw);
2647 bv->updateInset(const_cast<InsetTabular *>(this), false);
2650 return searchBackward(bv, str, cs, mw);
2655 bool InsetTabular::insetAllowed(Inset::Code code) const
2657 if (the_locking_inset)
2658 return the_locking_inset->insetAllowed(code);