1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 * ======================================================
19 #pragma implementation
22 #include "insettabular.h"
25 #include "commandtags.h"
27 #include "LaTeXFeatures.h"
31 #include "lyx_gui_misc.h"
34 #include "insets/insettext.h"
35 #include "frontends/Dialogs.h"
38 const int ADD_TO_HEIGHT = 2;
39 const int ADD_TO_TABULAR_WIDTH = 2;
48 struct tabular_features {
53 //static tabular_features * tabularFeatures = 0;
55 static tabular_features tabularFeatures[] =
57 { LyXTabular::APPEND_ROW, "append-row" },
58 { LyXTabular::APPEND_COLUMN, "append-column" },
59 { LyXTabular::DELETE_ROW, "delete-row" },
60 { LyXTabular::DELETE_COLUMN, "delete-column" },
61 { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
62 { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
63 { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
64 { LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
65 { LyXTabular::ALIGN_LEFT, "align-left" },
66 { LyXTabular::ALIGN_RIGHT, "align-right" },
67 { LyXTabular::ALIGN_CENTER, "align-center" },
68 { LyXTabular::VALIGN_TOP, "valign-top" },
69 { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
70 { LyXTabular::VALIGN_CENTER, "valign-center" },
71 { LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
72 { LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
73 { LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
74 { LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
75 { LyXTabular::M_ALIGN_LEFT, "m-align-left" },
76 { LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
77 { LyXTabular::M_ALIGN_CENTER, "m-align-center" },
78 { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
79 { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
80 { LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
81 { LyXTabular::DELETE_TABULAR, "delete-tabular" },
82 { LyXTabular::MULTICOLUMN, "multicolumn" },
83 { LyXTabular::SET_ALL_LINES, "set-all-lines" },
84 { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
85 { LyXTabular::SET_LONGTABULAR, "set-longtabular" },
86 { LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
87 { LyXTabular::SET_PWIDTH, "set-pwidth" },
88 { LyXTabular::SET_MPWIDTH, "set-mpwidth" },
89 { LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
90 { LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
91 { LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
92 { LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
93 { LyXTabular::SET_USEBOX, "set-usebox" },
94 { LyXTabular::SET_LTHEAD, "set-lthead" },
95 { LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
96 { LyXTabular::SET_LTFOOT, "set-ltfoot" },
97 { LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
98 { LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
99 { LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
100 { LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
101 { LyXTabular::LAST_ACTION, "" }
104 //#define cellstart(p) ((p % 2) == 0)
106 bool cellstart(LyXParagraph::size_type p)
108 return ((p % 2) == 0);
112 InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
119 tabular = new LyXTabular(this, rows,columns);
120 // for now make it always display as display() inset
122 the_locking_inset = 0;
123 locked = no_selection = cursor_visible = false;
128 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
134 InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
137 tabular = new LyXTabular(this, *(tab.tabular));
138 the_locking_inset = 0;
139 locked = no_selection = cursor_visible = false;
144 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
150 InsetTabular::~InsetTabular()
154 dialogs_->hideTabular(this);
158 Inset * InsetTabular::Clone() const
160 InsetTabular * t = new InsetTabular(*this, buffer);
162 t->tabular = tabular->Clone(t);
167 void InsetTabular::Write(Buffer const * buf, ostream & os) const
169 os << " Tabular" << endl;
170 tabular->Write(buf, os);
174 void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
176 bool old_format = (lex.GetString() == "\\LyXTable");
181 tabular = new LyXTabular(buf, this, lex);
189 token = lex.GetString();
190 while (lex.IsOK() && (token != "\\end_inset")) {
192 token = lex.GetString();
194 if (token != "\\end_inset") {
195 lex.printError("Missing \\end_inset at this point. "
201 int InsetTabular::ascent(BufferView *, LyXFont const &) const
203 return tabular->GetAscentOfRow(0);
207 int InsetTabular::descent(BufferView *, LyXFont const &) const
209 return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
213 int InsetTabular::width(BufferView *, LyXFont const &) const
215 return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
219 void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
220 float & x, bool cleared) const
222 Painter & pain = bv->painter();
227 UpdatableInset::draw(bv,font,baseline,x,cleared);
228 if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
229 (top_x != int(x)) || (top_baseline != baseline))) {
230 int h = ascent(bv, font) + descent(bv, font);
231 int tx = display()||!owner()? 0:top_x;
232 int w = tx? width(bv, font):pain.paperWidth();
233 int ty = baseline - ascent(bv, font);
237 if ((ty + h) > pain.paperHeight())
238 h = pain.paperHeight();
239 if ((top_x + w) > pain.paperWidth())
240 w = pain.paperWidth();
241 pain.fillRectangle(tx, ty, w, h);
246 top_baseline = baseline;
247 if (bv->text->status == LyXText::CHANGED_IN_DRAW)
250 x += ADD_TO_TABULAR_WIDTH;
251 if (cleared || (need_update == FULL) || (need_update == CELL)) {
252 for(i=0;i<tabular->rows();++i) {
254 dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
255 (baseline-tabular->GetAscentOfRow(i)) < pain.paperHeight();
256 for(j=0;j<tabular->columns();++j) {
257 if (tabular->IsPartOfMultiColumn(i,j))
259 cx = nx + tabular->GetBeginningOfTextInCell(cell);
261 DrawCellSelection(pain, nx, baseline, i, j, cell);
262 if (dodraw && !cleared && locked && the_locking_inset) {
263 if (the_locking_inset == tabular->GetCellInset(cell)) {
264 LyXText::text_status st = bv->text->status;
266 bv->text->status = st;
267 if (need_update == CELL) {
268 // clear before the inset
271 baseline - tabular->GetAscentOfRow(i)+1,
273 tabular->GetAscentOfRow(i) +
274 tabular->GetDescentOfRow(i) - 1);
275 // clear behind the inset
277 cx + the_locking_inset->width(bv,font) + 1,
278 baseline - tabular->GetAscentOfRow(i)+1,
279 tabular->GetWidthOfColumn(cell) -
280 tabular->GetBeginningOfTextInCell(cell) -
281 the_locking_inset->width(bv,font) - 1,
282 tabular->GetAscentOfRow(i) +
283 tabular->GetDescentOfRow(i) - 1);
285 tabular->GetCellInset(cell)->draw(
286 bv, font, baseline, cx, false);
287 // if (need_update == CELL)
288 // DrawCellLines(pain, nx, baseline, i, cell);
289 } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
292 tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
294 DrawCellLines(pain, nx, baseline, i, cell);
296 nx += tabular->GetWidthOfColumn(cell);
299 baseline += tabular->GetDescentOfRow(i) +
300 tabular->GetAscentOfRow(i+1)+
301 tabular->GetAdditionalHeight(cell+1);
304 x += width(bv, font);
305 if (bv->text->status == LyXText::CHANGED_IN_DRAW)
312 void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
313 int row, int cell) const
315 int x2 = x + tabular->GetWidthOfColumn(cell);
318 if (!tabular->TopAlreadyDrawed(cell)) {
319 on_off = !tabular->TopLine(cell);
320 pain.line(x, baseline - tabular->GetAscentOfRow(row),
321 x2, baseline - tabular->GetAscentOfRow(row),
322 on_off ? LColor::tabularonoffline:LColor::tabularline,
323 on_off ? Painter::line_onoffdash:Painter::line_solid);
325 on_off = !tabular->BottomLine(cell);
326 pain.line(x,baseline + tabular->GetDescentOfRow(row),
327 x2, baseline + tabular->GetDescentOfRow(row),
328 on_off ? LColor::tabularonoffline:LColor::tabularline,
329 on_off ? Painter::line_onoffdash:Painter::line_solid);
330 if (!tabular->LeftAlreadyDrawed(cell)) {
331 on_off = !tabular->LeftLine(cell);
332 pain.line(x, baseline - tabular->GetAscentOfRow(row),
333 x, baseline + tabular->GetDescentOfRow(row),
334 on_off ? LColor::tabularonoffline:LColor::tabularline,
335 on_off ? Painter::line_onoffdash:Painter::line_solid);
337 on_off = !tabular->RightLine(cell);
338 pain.line(x2 - tabular->GetAdditionalWidth(cell),
339 baseline - tabular->GetAscentOfRow(row),
340 x2 - tabular->GetAdditionalWidth(cell),
341 baseline + tabular->GetDescentOfRow(row),
342 on_off ? LColor::tabularonoffline:LColor::tabularline,
343 on_off ? Painter::line_onoffdash:Painter::line_solid);
347 void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
348 int row, int column, int cell) const
350 int cs = tabular->column_of_cell(sel_cell_start);
351 int ce = tabular->column_of_cell(sel_cell_end);
354 cs = tabular->column_of_cell(sel_cell_end);
356 ce = tabular->right_column_of_cell(sel_cell_end);
359 int rs = tabular->row_of_cell(sel_cell_start);
360 int re = tabular->row_of_cell(sel_cell_end);
361 if (rs > re) swap(rs, re);
363 if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
364 int w = tabular->GetWidthOfColumn(cell);
365 int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
366 pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
367 w, h, LColor::selection);
372 void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
376 calculate_dimensions_of_cells(bv, font, true);
378 owner()->update(bv, font, true);
381 if (the_locking_inset)
382 the_locking_inset->update(bv, font, reinit);
383 switch(need_update) {
387 if (calculate_dimensions_of_cells(bv, font, false))
399 char const * InsetTabular::EditMessage() const
401 return _("Opened Tabular Inset");
405 void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
407 UpdatableInset::Edit(bv, x, y, button);
409 if (!bv->lockInset(this)) {
410 lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
414 the_locking_inset = 0;
415 inset_pos = inset_x = inset_y = 0;
417 sel_pos_start = sel_pos_end = cursor.pos();
418 sel_cell_start = sel_cell_end = actcell;
419 bv->text->FinishUndo();
420 if (InsetHit(bv, x, y)) {
421 ActivateCellInset(bv, x, y, button);
423 UpdateLocal(bv, NONE, false);
424 // bv->getOwner()->getPopups().updateFormTabular();
428 void InsetTabular::InsetUnlock(BufferView * bv)
430 if (the_locking_inset) {
431 the_locking_inset->InsetUnlock(bv);
432 the_locking_inset = 0;
435 no_selection = false;
438 if (scroll() || hasSelection()) {
440 scroll(bv, (float)0.0);
442 sel_pos_start = sel_pos_end = 0;
443 sel_cell_start = sel_cell_end = 0;
445 UpdateLocal(bv, FULL, false);
450 void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
451 bool mark_dirty) const
454 bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
455 if (locked && (what != NONE))
460 bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
462 lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" <<inset<< "): ";
466 if (inset == tabular->GetCellInset(actcell)) {
467 lyxerr[Debug::INSETS] << "OK" << endl;
468 the_locking_inset = tabular->GetCellInset(actcell);
470 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
471 inset_y = cursor.y();
472 inset_pos = cursor.pos();
474 } else if (the_locking_inset && (the_locking_inset == inset)) {
475 if (cursor.pos() == inset_pos) {
476 lyxerr[Debug::INSETS] << "OK" << endl;
478 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
479 inset_y = cursor.y();
481 lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
483 } else if (the_locking_inset) {
484 lyxerr[Debug::INSETS] << "MAYBE" << endl;
485 return the_locking_inset->LockInsetInInset(bv, inset);
487 lyxerr[Debug::INSETS] << "NOT OK" << endl;
492 bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
495 if (!the_locking_inset)
497 if (the_locking_inset == inset) {
498 the_locking_inset->InsetUnlock(bv);
499 the_locking_inset = 0;
501 moveRight(bv, false);
502 UpdateLocal(bv, CELL, false);
505 if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
506 if ((inset->LyxCode() == TABULAR_CODE) &&
507 !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))
509 dialogs_ = bv->owner()->getDialogs();
510 dialogs_->updateTabular(const_cast<InsetTabular *>(this));
519 bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
521 if (!the_locking_inset)
523 if (the_locking_inset != inset)
524 return the_locking_inset->UpdateInsetInInset(bv, inset);
525 UpdateLocal(bv, CELL, false);
530 int InsetTabular::InsetInInsetY()
532 if (!the_locking_inset)
535 return (inset_y + the_locking_inset->InsetInInsetY());
539 UpdatableInset * InsetTabular::GetLockingInset()
541 return the_locking_inset ? the_locking_inset->GetLockingInset() : this;
545 UpdatableInset * InsetTabular::GetFirstLockingInsetOfType(Inset::Code c)
549 if (the_locking_inset)
550 return the_locking_inset->GetFirstLockingInsetOfType(c);
555 bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
557 if (the_locking_inset)
558 return the_locking_inset->InsertInset(bv, inset);
563 void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
565 if (hasSelection()) {
566 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
567 UpdateLocal(bv, SELECTION, false);
569 no_selection = false;
577 UpdateLocal(bv, NONE, false);
578 sel_pos_start = sel_pos_end = cursor.pos();
579 sel_cell_start = sel_cell_end = actcell;
581 bool inset_hit = InsetHit(bv, x, y);
583 if ((ocell == actcell) && the_locking_inset && inset_hit) {
584 the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
586 } else if (the_locking_inset) {
587 the_locking_inset->InsetUnlock(bv);
589 the_locking_inset = 0;
590 if (inset_hit && bv->the_locking_inset) {
591 ActivateCellInset(bv, x, y, button);
592 the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
598 void InsetTabular::InsetButtonRelease(BufferView * bv,
599 int x, int y, int button)
602 if (the_locking_inset) {
604 if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
605 i->InsetButtonRelease(bv, x, y, button);
609 dialogs_ = bv->owner()->getDialogs();
610 dialogs_->showTabular(this);
612 else if (ocell != actcell)
613 bview->getOwner()->getPopups().updateTabular();
617 if (the_locking_inset) {
618 the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
621 no_selection = false;
625 void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
627 if (the_locking_inset) {
628 the_locking_inset->InsetMotionNotify(bv, x - inset_x,
629 y - inset_y, button);
633 // int ocell = actcell,
634 int old = sel_pos_end;
637 sel_pos_end = cursor.pos();
638 sel_cell_end = actcell;
639 if (old != sel_pos_end)
640 UpdateLocal(bv, SELECTION, false);
642 if (ocell != actcell)
643 bview->getOwner()->getPopups().updateFormTabular();
646 no_selection = false;
650 void InsetTabular::InsetKeyPress(XKeyEvent * xke)
652 if (the_locking_inset) {
653 the_locking_inset->InsetKeyPress(xke);
659 UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
662 UpdatableInset::RESULT
665 no_selection = false;
666 if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
667 || (result == DISPATCHED_NOUPDATE)) {
673 if ((action < 0) && arg.empty())
676 if ((action != LFUN_DOWN) && (action != LFUN_UP) &&
677 (action != LFUN_DOWNSEL) && (action != LFUN_UPSEL))
679 if (the_locking_inset) {
680 result=the_locking_inset->LocalDispatch(bv, action, arg);
681 if (result == DISPATCHED_NOUPDATE)
683 else if (result == DISPATCHED) {
684 the_locking_inset->ToggleInsetCursor(bv);
685 UpdateLocal(bv, CELL, false);
686 the_locking_inset->ToggleInsetCursor(bv);
688 } else if (result == FINISHED) {
689 if ((action == LFUN_RIGHT) || (action == -1)) {
690 cursor.pos(inset_pos + 1);
693 sel_pos_start = sel_pos_end = cursor.pos();
694 sel_cell_start = sel_cell_end = actcell;
701 bool hs = hasSelection();
705 // Normal chars not handled here
708 // --- Cursor Movements ---------------------------------------------
710 if (tabular->IsLastCellInRow(actcell) && !cellstart(cursor.pos()))
712 moveRight(bv, false);
713 sel_pos_end = cursor.pos();
714 if (!cellstart(cursor.pos())) {
715 if (tabular->right_column_of_cell(sel_cell_start) >
716 tabular->right_column_of_cell(actcell))
717 sel_cell_end = actcell+1;
719 sel_cell_end = actcell;
721 UpdateLocal(bv, SELECTION, false);
724 result = moveRight(bv);
725 sel_pos_start = sel_pos_end = cursor.pos();
726 sel_cell_start = sel_cell_end = actcell;
728 UpdateLocal(bv, SELECTION, false);
731 if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
734 sel_pos_end = cursor.pos();
735 if (cellstart(cursor.pos())) {
736 if (tabular->column_of_cell(sel_cell_start) >=
737 tabular->column_of_cell(actcell))
738 sel_cell_end = actcell;
740 sel_cell_end = actcell-1;
742 UpdateLocal(bv, SELECTION, false);
745 result = moveLeft(bv);
746 sel_pos_start = sel_pos_end = cursor.pos();
747 sel_cell_start = sel_cell_end = actcell;
749 UpdateLocal(bv, SELECTION, false);
755 sel_pos_end = cursor.pos();
756 if ((ocell == sel_cell_end) ||
757 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
758 sel_cell_end = tabular->GetCellBelow(sel_cell_end);
760 sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
761 UpdateLocal(bv, SELECTION, false);
765 result= moveDown(bv);
766 sel_pos_start = sel_pos_end = cursor.pos();
767 sel_cell_start = sel_cell_end = actcell;
769 UpdateLocal(bv, SELECTION, false);
775 sel_pos_end = cursor.pos();
776 if ((ocell == sel_cell_end) ||
777 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
778 sel_cell_end = tabular->GetCellAbove(sel_cell_end);
780 sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
781 UpdateLocal(bv, SELECTION, false);
786 sel_pos_start = sel_pos_end = cursor.pos();
787 sel_cell_start = sel_cell_end = actcell;
789 UpdateLocal(bv, SELECTION, false);
801 if (the_locking_inset) {
802 UnlockInsetInInset(bv, the_locking_inset);
803 the_locking_inset = 0;
805 if (action == LFUN_TAB)
809 sel_pos_start = sel_pos_end = cursor.pos();
810 sel_cell_start = sel_cell_end = actcell;
812 UpdateLocal(bv, SELECTION, false);
814 case LFUN_LAYOUT_TABLE:
816 dialogs_ = bv->owner()->getDialogs();
817 dialogs_->showTabular(this);
820 case LFUN_TABULAR_FEATURE:
821 if (!TabularFeatures(bv, arg))
822 result = UNDISPATCHED;
826 result = UNDISPATCHED;
829 if (result!=FINISHED) {
830 if (!the_locking_inset) {
832 if (ocell != actcell)
833 bview->getOwner()->getPopups().updateFormTabular();
838 bv->unlockInset(this);
843 int InsetTabular::Latex(Buffer const * buf, ostream & os,
844 bool fragile, bool fp) const
846 return tabular->Latex(buf, os, fragile, fp);
850 int InsetTabular::Ascii(Buffer const *, ostream &) const
856 int InsetTabular::Linuxdoc(Buffer const *, ostream &) const
862 int InsetTabular::DocBook(Buffer const *, ostream &) const
868 void InsetTabular::Validate(LaTeXFeatures & features) const
870 tabular->Validate(features);
874 bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
875 LyXFont const & font,
881 bool changed = false;
883 for(int i = 0; i < tabular->rows(); ++i) {
884 maxAsc = maxDesc = 0;
885 for(int j= 0; j < tabular->columns(); ++j) {
886 if (tabular->IsPartOfMultiColumn(i,j))
889 inset = tabular->GetCellInset(cell);
891 inset->update(bv, font, false);
892 maxAsc = max(maxAsc, inset->ascent(bv, font));
893 maxDesc = max(maxDesc, inset->descent(bv, font));
894 changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
896 changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
897 changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
903 void InsetTabular::GetCursorPos(BufferView *, int & x, int & y) const
905 x = cursor.x() - top_x;
910 void InsetTabular::ToggleInsetCursor(BufferView * bv)
912 if (the_locking_inset) {
913 the_locking_inset->ToggleInsetCursor(bv);
917 LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
919 int asc = lyxfont::maxAscent(font);
920 int desc = lyxfont::maxDescent(font);
923 bv->hideLockedInsetCursor();
925 bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
926 cursor_visible = !cursor_visible;
930 void InsetTabular::ShowInsetCursor(BufferView * bv)
932 if (!cursor_visible) {
933 LyXFont font; // = GetFont(par, cursor.pos);
935 int asc = lyxfont::maxAscent(font);
936 int desc = lyxfont::maxDescent(font);
937 bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
938 bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
939 cursor_visible = true;
944 void InsetTabular::HideInsetCursor(BufferView * bv)
946 if (cursor_visible) {
947 bv->hideLockedInsetCursor();
948 cursor_visible = false;
950 // if (cursor_visible)
951 // ToggleInsetCursor(bv);
955 void InsetTabular::setPos(BufferView * bv, int x, int y) const
960 actcell = actrow = actcol = 0;
961 int ly = tabular->GetDescentOfRow(actrow);
963 // first search the right row
964 while((ly < y) && (actrow < tabular->rows())) {
965 cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
966 tabular->GetAscentOfRow(actrow+1) +
967 tabular->GetAdditionalHeight(tabular->GetCellNumber(actrow + 1,
970 ly = cursor.y() + tabular->GetDescentOfRow(actrow);
972 actcell = tabular->GetCellNumber(actrow, actcol);
974 // now search the right column
975 int lx = tabular->GetWidthOfColumn(actcell) -
976 tabular->GetAdditionalWidth(actcell);
977 for(; !tabular->IsLastCellInRow(actcell) && (lx < x);
978 ++actcell,lx += tabular->GetWidthOfColumn(actcell) +
979 tabular->GetAdditionalWidth(actcell - 1));
982 if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
983 cursor.x(lx + top_x - 2);
986 cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
992 int InsetTabular::getCellXPos(int cell) const
996 for(c=cell;!tabular->IsFirstCellInRow(c);--c)
998 int lx = tabular->GetWidthOfColumn(cell);
999 for(; (c < cell); ++c) {
1000 lx += tabular->GetWidthOfColumn(c);
1002 return (lx - tabular->GetWidthOfColumn(cell) + top_x);
1006 void InsetTabular::resetPos(BufferView * bv) const
1010 actcol = tabular->column_of_cell(actcell);
1015 for(; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
1016 if (tabular->IsLastCellInRow(cell)) {
1017 cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
1018 tabular->GetAscentOfRow(actrow + 1) +
1019 tabular->GetAdditionalHeight(cell + 1));
1023 static int offset = ADD_TO_TABULAR_WIDTH + 2;
1024 cursor.x(getCellXPos(actcell) + offset);
1025 if (((cursor.x() - offset) > 20) &&
1026 ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
1027 (bv->workWidth()-20)))
1029 scroll(bv, -tabular->GetWidthOfColumn(actcell)-20);
1030 UpdateLocal(bv, FULL, false);
1031 } else if ((cursor.x() - offset) < 20) {
1032 scroll(bv, 20 - cursor.x() + offset);
1033 UpdateLocal(bv, FULL, false);
1034 } else if (!cellstart(cursor.pos())) {
1035 LyXFont font(LyXFont::ALL_SANE);
1036 cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
1037 tabular->GetBeginningOfTextInCell(actcell));
1039 if ((!the_locking_inset ||
1040 !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
1041 (actcell != oldcell)) {
1042 dialogs_ = bv->owner()->getDialogs();
1043 dialogs_->updateTabular(const_cast<InsetTabular *>(this));
1049 UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
1051 if (!cellstart(cursor.pos())) {
1052 if (tabular->IsLastCell(actcell))
1055 cursor.pos(cursor.pos() + 1);
1057 if (ActivateCellInset(bv))
1059 } else { // before the inset
1060 cursor.pos(cursor.pos() + 1);
1063 return DISPATCHED_NOUPDATE;
1067 UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
1069 if (!cursor.pos()) {
1074 cursor.pos(cursor.pos() - 1);
1075 if (!cellstart(cursor.pos())) {
1077 } else if (lock) { // behind the inset
1078 if (ActivateCellInset(bv, 0, 0, 0, true))
1082 return DISPATCHED_NOUPDATE;
1086 UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv)
1088 int ocell = actcell;
1089 actcell = tabular->GetCellAbove(actcell);
1090 if (actcell == ocell) // we moved out of the inset
1093 return DISPATCHED_NOUPDATE;
1097 UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv)
1099 int ocell = actcell;
1100 actcell = tabular->GetCellBelow(actcell);
1101 if (actcell == ocell) // we moved out of the inset
1104 return DISPATCHED_NOUPDATE;
1108 bool InsetTabular::moveNextCell(BufferView * bv)
1110 if (tabular->IsLastCell(actcell))
1113 cursor.pos(cursor.pos() + 1);
1114 if (!cellstart(cursor.pos()))
1115 cursor.pos(cursor.pos() + 1);
1121 bool InsetTabular::movePrevCell(BufferView * bv)
1123 if (!actcell) // first cell
1126 cursor.pos(cursor.pos() - 1);
1127 if (cellstart(cursor.pos()))
1128 cursor.pos(cursor.pos() - 1);
1134 bool InsetTabular::Delete()
1140 void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
1142 if (the_locking_inset)
1143 the_locking_inset->SetFont(bv, font, tall);
1147 bool InsetTabular::TabularFeatures(BufferView * bv, string what)
1149 int action = LyXTabular::LAST_ACTION;
1153 for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
1154 if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
1155 tabularFeatures[i].feature.length())) {
1156 action = tabularFeatures[i].action;
1160 if (action == LyXTabular::LAST_ACTION)
1163 val = frontStrip(what.substr(tabularFeatures[i].feature.length()));
1164 TabularFeatures(bv, action, val);
1169 void InsetTabular::TabularFeatures(BufferView * bv, int feature, string value)
1178 setAlign = LYX_ALIGN_LEFT,
1184 case LyXTabular::M_ALIGN_LEFT:
1185 case LyXTabular::ALIGN_LEFT:
1186 setAlign=LYX_ALIGN_LEFT;
1188 case LyXTabular::M_ALIGN_RIGHT:
1189 case LyXTabular::ALIGN_RIGHT:
1190 setAlign=LYX_ALIGN_RIGHT;
1192 case LyXTabular::M_ALIGN_CENTER:
1193 case LyXTabular::ALIGN_CENTER:
1194 setAlign=LYX_ALIGN_CENTER;
1196 case LyXTabular::M_VALIGN_TOP:
1197 case LyXTabular::VALIGN_TOP:
1198 setAlign=LyXTabular::LYX_VALIGN_TOP;
1200 case LyXTabular::M_VALIGN_BOTTOM:
1201 case LyXTabular::VALIGN_BOTTOM:
1202 setAlign=LyXTabular::LYX_VALIGN_BOTTOM;
1204 case LyXTabular::M_VALIGN_CENTER:
1205 case LyXTabular::VALIGN_CENTER:
1206 setAlign=LyXTabular::LYX_VALIGN_CENTER;
1211 if (hasSelection()) {
1213 sel_col_start = tabular->column_of_cell(sel_cell_start);
1214 sel_col_end = tabular->column_of_cell(sel_cell_end);
1215 if (sel_col_start > sel_col_end) {
1216 sel_col_end = sel_col_start;
1217 sel_col_start = tabular->column_of_cell(sel_cell_end);
1219 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
1222 sel_row_start = tabular->row_of_cell(sel_cell_start);
1223 sel_row_end = tabular->row_of_cell(sel_cell_end);
1224 if (sel_row_start > sel_row_end) {
1225 tmp = sel_row_start;
1226 sel_row_start = sel_row_end;
1230 sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
1231 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1233 bv->text->SetUndo(bv->buffer(), Undo::FINISH,
1235 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
1236 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
1238 bv->text->cursor.par()->previous,
1239 bv->text->cursor.par()->next
1243 int row = tabular->row_of_cell(actcell);
1244 int column = tabular->column_of_cell(actcell);
1248 case LyXTabular::SET_PWIDTH:
1250 bool update = (tabular->GetColumnPWidth(actcell) != value);
1251 tabular->SetColumnPWidth(actcell,value);
1253 for (int i=0; i < tabular->rows(); ++i) {
1254 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1257 UpdateLocal(bv, INIT, true);
1261 case LyXTabular::SET_MPWIDTH:
1263 bool update = (tabular->GetPWidth(actcell) != value);
1264 tabular->SetMColumnPWidth(actcell,value);
1266 for (int i=0; i < tabular->rows(); ++i) {
1267 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1270 UpdateLocal(bv, INIT, true);
1274 case LyXTabular::SET_SPECIAL_COLUMN:
1275 case LyXTabular::SET_SPECIAL_MULTI:
1276 tabular->SetAlignSpecial(actcell,value,feature);
1278 case LyXTabular::APPEND_ROW:
1279 // append the row into the tabular
1280 UnlockInsetInInset(bv, the_locking_inset);
1281 tabular->AppendRow(actcell);
1282 UpdateLocal(bv, INIT, true);
1284 case LyXTabular::APPEND_COLUMN:
1285 // append the column into the tabular
1286 tabular->AppendColumn(actcell);
1287 actcell = tabular->GetCellNumber(row, column);
1288 UpdateLocal(bv, INIT, true);
1290 case LyXTabular::DELETE_ROW:
1291 tabular->DeleteRow(tabular->row_of_cell(actcell));
1292 if ((row+1) > tabular->rows())
1294 actcell = tabular->GetCellNumber(row, column);
1295 UpdateLocal(bv, INIT, true);
1297 case LyXTabular::DELETE_COLUMN:
1298 tabular->DeleteColumn(tabular->column_of_cell(actcell));
1299 if ((column+1) > tabular->columns())
1301 actcell = tabular->GetCellNumber(row, column);
1302 UpdateLocal(bv, INIT, true);
1304 case LyXTabular::M_TOGGLE_LINE_TOP:
1306 case LyXTabular::TOGGLE_LINE_TOP:
1307 lineSet = !tabular->TopLine(actcell, flag);
1308 for(i=sel_row_start; i<=sel_row_end; ++i)
1309 for(j=sel_col_start; j<=sel_col_end; ++j)
1310 tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet, flag);
1311 UpdateLocal(bv, INIT, true);
1314 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1316 case LyXTabular::TOGGLE_LINE_BOTTOM:
1317 lineSet = !tabular->BottomLine(actcell, flag);
1318 for(i=sel_row_start; i<=sel_row_end; ++i)
1319 for(j=sel_col_start; j<=sel_col_end; ++j)
1320 tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet,
1322 UpdateLocal(bv, INIT, true);
1325 case LyXTabular::M_TOGGLE_LINE_LEFT:
1327 case LyXTabular::TOGGLE_LINE_LEFT:
1328 lineSet = !tabular->LeftLine(actcell, flag);
1329 for(i=sel_row_start; i<=sel_row_end; ++i)
1330 for(j=sel_col_start; j<=sel_col_end; ++j)
1331 tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet,
1333 UpdateLocal(bv, INIT, true);
1336 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1338 case LyXTabular::TOGGLE_LINE_RIGHT:
1339 lineSet = !tabular->RightLine(actcell, flag);
1340 for(i=sel_row_start; i<=sel_row_end; ++i)
1341 for(j=sel_col_start; j<=sel_col_end; ++j)
1342 tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet,
1344 UpdateLocal(bv, INIT, true);
1346 case LyXTabular::M_ALIGN_LEFT:
1347 case LyXTabular::M_ALIGN_RIGHT:
1348 case LyXTabular::M_ALIGN_CENTER:
1350 case LyXTabular::ALIGN_LEFT:
1351 case LyXTabular::ALIGN_RIGHT:
1352 case LyXTabular::ALIGN_CENTER:
1353 for(i=sel_row_start; i<=sel_row_end; ++i)
1354 for(j=sel_col_start; j<=sel_col_end; ++j)
1355 tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign,
1358 UpdateLocal(bv, INIT, true);
1360 UpdateLocal(bv, CELL, true);
1362 case LyXTabular::M_VALIGN_TOP:
1363 case LyXTabular::M_VALIGN_BOTTOM:
1364 case LyXTabular::M_VALIGN_CENTER:
1366 case LyXTabular::VALIGN_TOP:
1367 case LyXTabular::VALIGN_BOTTOM:
1368 case LyXTabular::VALIGN_CENTER:
1369 for(i=sel_row_start; i<=sel_row_end; ++i)
1370 for(j=sel_col_start; j<=sel_col_end; ++j)
1371 tabular->SetVAlignment(tabular->GetCellNumber(i,j), setAlign,
1374 UpdateLocal(bv, INIT, true);
1376 UpdateLocal(bv, CELL, true);
1378 case LyXTabular::MULTICOLUMN:
1380 if (sel_row_start != sel_row_end) {
1381 WriteAlert(_("Impossible Operation!"),
1382 _("Multicolumns can only be horizontally."),
1386 // just multicol for one Single Cell
1387 if (!hasSelection()) {
1388 // check wether we are completly in a multicol
1389 if (tabular->IsMultiColumn(actcell)) {
1390 tabular->UnsetMultiColumn(actcell);
1391 UpdateLocal(bv, INIT, true);
1393 tabular->SetMultiColumn(actcell, 1);
1394 UpdateLocal(bv, CELL, true);
1398 // we have a selection so this means we just add all this
1399 // cells to form a multicolumn cell
1403 if (sel_cell_start > sel_cell_end) {
1404 s_start = sel_cell_end;
1405 s_end = sel_cell_start;
1407 s_start = sel_cell_start;
1408 s_end = sel_cell_end;
1410 tabular->SetMultiColumn(s_start, s_end - s_start + 1);
1413 sel_cell_end = sel_cell_start;
1414 sel_pos_end = sel_pos_start;
1415 UpdateLocal(bv, INIT, true);
1418 case LyXTabular::SET_ALL_LINES:
1420 case LyXTabular::UNSET_ALL_LINES:
1421 for(i=sel_row_start; i<=sel_row_end; ++i)
1422 for(j=sel_col_start; j<=sel_col_end; ++j)
1423 tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
1424 UpdateLocal(bv, INIT, true);
1426 case LyXTabular::SET_LONGTABULAR:
1427 tabular->SetLongTabular(true);
1428 UpdateLocal(bv, INIT, true); // because this toggles displayed
1430 case LyXTabular::UNSET_LONGTABULAR:
1431 tabular->SetLongTabular(false);
1432 UpdateLocal(bv, INIT, true); // because this toggles displayed
1434 case LyXTabular::SET_ROTATE_TABULAR:
1435 tabular->SetRotateTabular(true);
1437 case LyXTabular::UNSET_ROTATE_TABULAR:
1438 tabular->SetRotateTabular(false);
1440 case LyXTabular::SET_ROTATE_CELL:
1441 for(i=sel_row_start; i<=sel_row_end; ++i)
1442 for(j=sel_col_start; j<=sel_col_end; ++j)
1443 tabular->SetRotateCell(tabular->GetCellNumber(i,j),true);
1445 case LyXTabular::UNSET_ROTATE_CELL:
1446 for(i=sel_row_start; i<=sel_row_end; ++i)
1447 for(j=sel_col_start; j<=sel_col_end; ++j)
1448 tabular->SetRotateCell(tabular->GetCellNumber(i,j),false);
1450 case LyXTabular::SET_USEBOX:
1452 int val = strToInt(value);
1453 if (val == tabular->GetUsebox(actcell))
1455 for(i=sel_row_start; i<=sel_row_end; ++i)
1456 for(j=sel_col_start; j<=sel_col_end; ++j)
1457 tabular->SetUsebox(tabular->GetCellNumber(i,j),val);
1460 case LyXTabular::SET_LTFIRSTHEAD:
1461 tabular->SetLTHead(actcell,true);
1463 case LyXTabular::SET_LTHEAD:
1464 tabular->SetLTHead(actcell,false);
1466 case LyXTabular::SET_LTFOOT:
1467 tabular->SetLTFoot(actcell,false);
1469 case LyXTabular::SET_LTLASTFOOT:
1470 tabular->SetLTFoot(actcell,true);
1472 case LyXTabular::SET_LTNEWPAGE:
1473 what = !tabular->GetLTNewPage(actcell);
1474 tabular->SetLTNewPage(actcell,what);
1480 bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
1483 // the cursor.pos has to be before the inset so if it isn't now just
1484 // reset the curor pos first!
1485 if (cursor.pos() % 2) { // behind the inset
1486 cursor.pos(cursor.pos() - 1);
1489 UpdatableInset * inset =
1490 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
1491 LyXFont font(LyXFont::ALL_SANE);
1493 x = inset->x() + inset->width(bv, font);
1494 y = inset->descent(bv, font);
1496 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1497 inset_y = cursor.y();
1498 inset->Edit(bv, x - inset_x, y - inset_y, button);
1499 if (!the_locking_inset)
1501 UpdateLocal(bv, CELL, false);
1506 bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
1508 InsetText * inset = tabular->GetCellInset(actcell);
1511 if (cursor.pos() % 2) { // behind the inset
1512 return (((x + top_x) < cursor.x()) &&
1513 ((x + top_x) > (cursor.x() - inset->width(bv,
1514 LyXFont(LyXFont::ALL_SANE)))));
1516 int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
1517 return ((x1 > x2) &&
1518 (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))));
1523 // This returns paperWidth() if the cell-width is unlimited or the width
1524 // in pixels if we have a pwidth for this cell.
1525 int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
1527 string s = tabular->GetPWidth(cell);
1531 return VSpace(s).inPixels( 0, 0);
1535 int InsetTabular::getMaxWidth(Painter & pain,
1536 UpdatableInset const * inset) const
1539 int n = tabular->GetNumberOfCells();
1540 for(cell=0; cell < n; ++cell) {
1541 if (tabular->GetCellInset(cell) == inset)
1546 int w = GetMaxWidthOfCell(pain, cell);
1548 // because the inset then subtracts it's top_x and owner->x()
1549 w += (inset->x() - top_x);
1554 void InsetTabular::resizeLyXText(BufferView *) const
1559 LyXText * InsetTabular::getLyXText(BufferView * bv) const
1561 if (the_locking_inset)
1562 return the_locking_inset->getLyXText(bv);
1563 return Inset::getLyXText(bv);
1567 void InsetTabular::OpenLayoutDialog(BufferView * bv) const
1569 if (the_locking_inset) {
1570 InsetTabular * i = static_cast<InsetTabular *>
1571 (the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE));
1573 i->OpenLayoutDialog(bv);
1577 dialogs_ = bv->owner()->getDialogs();
1578 dialogs_->showTabular(const_cast<InsetTabular *>(this));
1582 // functions returns:
1586 // 3 ... toggled off
1588 int InsetTabular::getStatus(string what) const
1590 int action = LyXTabular::LAST_ACTION;
1594 for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
1595 if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
1596 tabularFeatures[i].feature.length())) {
1597 action = tabularFeatures[i].action;
1601 if (action == LyXTabular::LAST_ACTION)
1604 argument = frontStrip(what.substr(tabularFeatures[i].feature.length()));
1606 int sel_row_start, sel_row_end;
1610 if (hasSelection()) {
1612 sel_row_start = tabular->row_of_cell(sel_cell_start);
1613 sel_row_end = tabular->row_of_cell(sel_cell_end);
1614 if (sel_row_start > sel_row_end) {
1615 tmp = sel_row_start;
1616 sel_row_start = sel_row_end;
1620 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1624 case LyXTabular::SET_PWIDTH:
1625 case LyXTabular::SET_MPWIDTH:
1626 case LyXTabular::SET_SPECIAL_COLUMN:
1627 case LyXTabular::SET_SPECIAL_MULTI:
1630 case LyXTabular::APPEND_ROW:
1631 case LyXTabular::APPEND_COLUMN:
1632 case LyXTabular::DELETE_ROW:
1633 case LyXTabular::DELETE_COLUMN:
1634 case LyXTabular::SET_ALL_LINES:
1635 case LyXTabular::UNSET_ALL_LINES:
1638 case LyXTabular::MULTICOLUMN:
1639 if (tabular->IsMultiColumn(actcell))
1643 case LyXTabular::M_TOGGLE_LINE_TOP:
1645 case LyXTabular::TOGGLE_LINE_TOP:
1646 if (tabular->TopLine(actcell, flag))
1650 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1652 case LyXTabular::TOGGLE_LINE_BOTTOM:
1653 if (tabular->BottomLine(actcell, flag))
1657 case LyXTabular::M_TOGGLE_LINE_LEFT:
1659 case LyXTabular::TOGGLE_LINE_LEFT:
1660 if (tabular->LeftLine(actcell, flag))
1664 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1666 case LyXTabular::TOGGLE_LINE_RIGHT:
1667 if (tabular->RightLine(actcell, flag))
1671 case LyXTabular::M_ALIGN_LEFT:
1673 case LyXTabular::ALIGN_LEFT:
1674 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT)
1678 case LyXTabular::M_ALIGN_RIGHT:
1680 case LyXTabular::ALIGN_RIGHT:
1681 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT)
1685 case LyXTabular::M_ALIGN_CENTER:
1687 case LyXTabular::ALIGN_CENTER:
1688 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER)
1692 case LyXTabular::M_VALIGN_TOP:
1694 case LyXTabular::VALIGN_TOP:
1695 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP)
1699 case LyXTabular::M_VALIGN_BOTTOM:
1701 case LyXTabular::VALIGN_BOTTOM:
1702 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM)
1706 case LyXTabular::M_VALIGN_CENTER:
1708 case LyXTabular::VALIGN_CENTER:
1709 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER)
1713 case LyXTabular::SET_LONGTABULAR:
1714 if (tabular->IsLongTabular())
1718 case LyXTabular::UNSET_LONGTABULAR:
1719 if (!tabular->IsLongTabular())
1723 case LyXTabular::SET_ROTATE_TABULAR:
1724 if (tabular->GetRotateTabular())
1728 case LyXTabular::UNSET_ROTATE_TABULAR:
1729 if (!tabular->GetRotateTabular())
1733 case LyXTabular::SET_ROTATE_CELL:
1734 if (tabular->GetRotateCell(actcell))
1738 case LyXTabular::UNSET_ROTATE_CELL:
1739 if (!tabular->GetRotateCell(actcell))
1743 case LyXTabular::SET_USEBOX:
1744 if (strToInt(argument) == tabular->GetUsebox(actcell))
1748 case LyXTabular::SET_LTFIRSTHEAD:
1749 if (tabular->GetRowOfLTHead(actcell, dummy))
1753 case LyXTabular::SET_LTHEAD:
1754 if (tabular->GetRowOfLTHead(actcell, dummy))
1758 case LyXTabular::SET_LTFOOT:
1759 if (tabular->GetRowOfLTFoot(actcell, dummy))
1763 case LyXTabular::SET_LTLASTFOOT:
1764 if (tabular->GetRowOfLTFoot(actcell, dummy))
1768 case LyXTabular::SET_LTNEWPAGE:
1769 if (tabular->GetLTNewPage(actcell))