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;
248 x += ADD_TO_TABULAR_WIDTH;
249 if (cleared || (need_update == FULL) || (need_update == CELL)) {
250 for(i=0;i<tabular->rows();++i) {
252 dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
253 (baseline-tabular->GetAscentOfRow(i)) < pain.paperHeight();
254 for(j=0;j<tabular->columns();++j) {
255 if (tabular->IsPartOfMultiColumn(i,j))
257 cx = nx + tabular->GetBeginningOfTextInCell(cell);
259 DrawCellSelection(pain, nx, baseline, i, j, cell);
260 if (dodraw && !cleared && locked && the_locking_inset) {
261 if (the_locking_inset == tabular->GetCellInset(cell))
262 #warning Reminder make this better! (Jug)
263 if (need_update == CELL) // clear this cell
264 pain.fillRectangle(cx,
266 tabular->GetAscentOfRow(i),
267 tabular->GetWidthOfColumn(cell),
268 tabular->GetAscentOfRow(i) +
269 tabular->GetDescentOfRow(i));
270 tabular->GetCellInset(cell)->draw(bv, font,
273 if (need_update == CELL)
274 DrawCellLines(pain, nx, baseline, i, cell);
276 tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
278 DrawCellLines(pain, nx, baseline, i, cell);
280 nx += tabular->GetWidthOfColumn(cell);
283 baseline += tabular->GetDescentOfRow(i) +
284 tabular->GetAscentOfRow(i+1)+
285 tabular->GetAdditionalHeight(cell+1);
288 x += width(bv, font);
289 if (bv->text->status == LyXText::CHANGED_IN_DRAW)
296 void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
297 int row, int cell) const
299 int x2 = x + tabular->GetWidthOfColumn(cell);
302 if (!tabular->TopAlreadyDrawed(cell)) {
303 on_off = !tabular->TopLine(cell);
304 pain.line(x, baseline - tabular->GetAscentOfRow(row),
305 x2, baseline - tabular->GetAscentOfRow(row),
306 on_off ? LColor::tabularonoffline:LColor::tabularline,
307 on_off ? Painter::line_onoffdash:Painter::line_solid);
309 on_off = !tabular->BottomLine(cell);
310 pain.line(x,baseline + tabular->GetDescentOfRow(row),
311 x2, baseline + tabular->GetDescentOfRow(row),
312 on_off ? LColor::tabularonoffline:LColor::tabularline,
313 on_off ? Painter::line_onoffdash:Painter::line_solid);
314 if (!tabular->LeftAlreadyDrawed(cell)) {
315 on_off = !tabular->LeftLine(cell);
316 pain.line(x, baseline - tabular->GetAscentOfRow(row),
317 x, baseline + tabular->GetDescentOfRow(row),
318 on_off ? LColor::tabularonoffline:LColor::tabularline,
319 on_off ? Painter::line_onoffdash:Painter::line_solid);
321 on_off = !tabular->RightLine(cell);
322 pain.line(x2 - tabular->GetAdditionalWidth(cell),
323 baseline - tabular->GetAscentOfRow(row),
324 x2 - tabular->GetAdditionalWidth(cell),
325 baseline + tabular->GetDescentOfRow(row),
326 on_off ? LColor::tabularonoffline:LColor::tabularline,
327 on_off ? Painter::line_onoffdash:Painter::line_solid);
331 void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
332 int row, int column, int cell) const
334 int cs = tabular->column_of_cell(sel_cell_start);
335 int ce = tabular->column_of_cell(sel_cell_end);
338 cs = tabular->column_of_cell(sel_cell_end);
340 ce = tabular->right_column_of_cell(sel_cell_end);
343 int rs = tabular->row_of_cell(sel_cell_start);
344 int re = tabular->row_of_cell(sel_cell_end);
345 if (rs > re) swap(rs, re);
347 if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
348 int w = tabular->GetWidthOfColumn(cell);
349 int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
350 pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
351 w, h, LColor::selection);
356 void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
360 calculate_dimensions_of_cells(bv, font, true);
362 owner()->update(bv, font, true);
365 if (the_locking_inset)
366 the_locking_inset->update(bv, font, reinit);
367 switch(need_update) {
371 if (calculate_dimensions_of_cells(bv, font, false))
383 char const * InsetTabular::EditMessage() const
385 return _("Opened Tabular Inset");
389 void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
391 UpdatableInset::Edit(bv, x, y, button);
393 if (!bv->lockInset(this)) {
394 lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
398 the_locking_inset = 0;
399 inset_pos = inset_x = inset_y = 0;
401 sel_pos_start = sel_pos_end = cursor.pos();
402 sel_cell_start = sel_cell_end = actcell;
403 bv->text->FinishUndo();
404 if (InsetHit(bv, x, y)) {
405 ActivateCellInset(bv, x, y, button);
407 UpdateLocal(bv, NONE, false);
408 // bv->getOwner()->getPopups().updateFormTabular();
412 void InsetTabular::InsetUnlock(BufferView * bv)
414 if (the_locking_inset) {
415 the_locking_inset->InsetUnlock(bv);
416 the_locking_inset = 0;
419 no_selection = false;
422 if (scroll() || hasSelection()) {
424 scroll(bv, (float)0.0);
426 sel_pos_start = sel_pos_end = 0;
427 sel_cell_start = sel_cell_end = 0;
429 UpdateLocal(bv, FULL, false);
434 void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
435 bool mark_dirty) const
438 bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
439 if (locked && (what != NONE))
444 bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
446 lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" <<inset<< "): ";
450 if (inset == tabular->GetCellInset(actcell)) {
451 lyxerr[Debug::INSETS] << "OK" << endl;
452 the_locking_inset = tabular->GetCellInset(actcell);
454 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
455 inset_y = cursor.y();
456 inset_pos = cursor.pos();
458 } else if (the_locking_inset && (the_locking_inset == inset)) {
459 if (cursor.pos() == inset_pos) {
460 lyxerr[Debug::INSETS] << "OK" << endl;
462 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
463 inset_y = cursor.y();
465 lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
467 } else if (the_locking_inset) {
468 lyxerr[Debug::INSETS] << "MAYBE" << endl;
469 return the_locking_inset->LockInsetInInset(bv, inset);
471 lyxerr[Debug::INSETS] << "NOT OK" << endl;
476 bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
479 if (!the_locking_inset)
481 if (the_locking_inset == inset) {
482 the_locking_inset->InsetUnlock(bv);
483 the_locking_inset = 0;
485 moveRight(bv, false);
486 UpdateLocal(bv, CELL, false);
489 if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
490 if ((inset->LyxCode() == TABULAR_CODE) &&
491 !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))
493 dialogs_ = bv->owner()->getDialogs();
494 dialogs_->updateTabular(const_cast<InsetTabular *>(this));
503 bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
505 if (!the_locking_inset)
507 if (the_locking_inset != inset)
508 return the_locking_inset->UpdateInsetInInset(bv, inset);
509 UpdateLocal(bv, CELL, false);
514 int InsetTabular::InsetInInsetY()
516 if (!the_locking_inset)
519 return (inset_y + the_locking_inset->InsetInInsetY());
523 UpdatableInset * InsetTabular::GetLockingInset()
525 return the_locking_inset ? the_locking_inset->GetLockingInset() : this;
529 UpdatableInset * InsetTabular::GetFirstLockingInsetOfType(Inset::Code c)
533 if (the_locking_inset)
534 return the_locking_inset->GetFirstLockingInsetOfType(c);
539 bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
541 if (the_locking_inset)
542 return the_locking_inset->InsertInset(bv, inset);
547 void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
549 if (hasSelection()) {
550 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
551 UpdateLocal(bv, SELECTION, false);
553 no_selection = false;
561 UpdateLocal(bv, NONE, false);
562 sel_pos_start = sel_pos_end = cursor.pos();
563 sel_cell_start = sel_cell_end = actcell;
565 bool inset_hit = InsetHit(bv, x, y);
567 if ((ocell == actcell) && the_locking_inset && inset_hit) {
568 the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
570 } else if (the_locking_inset) {
571 the_locking_inset->InsetUnlock(bv);
573 the_locking_inset = 0;
574 if (inset_hit && bv->the_locking_inset) {
575 ActivateCellInset(bv, x, y, button);
576 the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
582 void InsetTabular::InsetButtonRelease(BufferView * bv,
583 int x, int y, int button)
586 if (the_locking_inset) {
588 if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
589 i->InsetButtonRelease(bv, x, y, button);
593 dialogs_ = bv->owner()->getDialogs();
594 dialogs_->showTabular(this);
596 else if (ocell != actcell)
597 bview->getOwner()->getPopups().updateTabular();
601 if (the_locking_inset) {
602 the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
605 no_selection = false;
609 void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
611 if (the_locking_inset) {
612 the_locking_inset->InsetMotionNotify(bv, x - inset_x,
613 y - inset_y, button);
617 // int ocell = actcell,
618 int old = sel_pos_end;
621 sel_pos_end = cursor.pos();
622 sel_cell_end = actcell;
623 if (old != sel_pos_end)
624 UpdateLocal(bv, SELECTION, false);
626 if (ocell != actcell)
627 bview->getOwner()->getPopups().updateFormTabular();
630 no_selection = false;
634 void InsetTabular::InsetKeyPress(XKeyEvent * xke)
636 if (the_locking_inset) {
637 the_locking_inset->InsetKeyPress(xke);
643 UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
646 UpdatableInset::RESULT
649 no_selection = false;
650 if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
651 || (result == DISPATCHED_NOUPDATE)) {
657 if ((action < 0) && arg.empty())
660 if ((action != LFUN_DOWN) && (action != LFUN_UP) &&
661 (action != LFUN_DOWNSEL) && (action != LFUN_UPSEL))
663 if (the_locking_inset) {
664 result=the_locking_inset->LocalDispatch(bv, action, arg);
665 if (result == DISPATCHED_NOUPDATE)
667 else if (result == DISPATCHED) {
668 the_locking_inset->ToggleInsetCursor(bv);
669 UpdateLocal(bv, CELL, false);
670 the_locking_inset->ToggleInsetCursor(bv);
672 } else if (result == FINISHED) {
673 if ((action == LFUN_RIGHT) || (action == -1)) {
674 cursor.pos(inset_pos + 1);
677 sel_pos_start = sel_pos_end = cursor.pos();
678 sel_cell_start = sel_cell_end = actcell;
685 bool hs = hasSelection();
689 // Normal chars not handled here
692 // --- Cursor Movements ---------------------------------------------
694 if (tabular->IsLastCellInRow(actcell) && !cellstart(cursor.pos()))
696 moveRight(bv, false);
697 sel_pos_end = cursor.pos();
698 if (!cellstart(cursor.pos())) {
699 if (tabular->right_column_of_cell(sel_cell_start) >
700 tabular->right_column_of_cell(actcell))
701 sel_cell_end = actcell+1;
703 sel_cell_end = actcell;
705 UpdateLocal(bv, SELECTION, false);
708 result = moveRight(bv);
709 sel_pos_start = sel_pos_end = cursor.pos();
710 sel_cell_start = sel_cell_end = actcell;
712 UpdateLocal(bv, SELECTION, false);
715 if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
718 sel_pos_end = cursor.pos();
719 if (cellstart(cursor.pos())) {
720 if (tabular->column_of_cell(sel_cell_start) >=
721 tabular->column_of_cell(actcell))
722 sel_cell_end = actcell;
724 sel_cell_end = actcell-1;
726 UpdateLocal(bv, SELECTION, false);
729 result = moveLeft(bv);
730 sel_pos_start = sel_pos_end = cursor.pos();
731 sel_cell_start = sel_cell_end = actcell;
733 UpdateLocal(bv, SELECTION, false);
739 sel_pos_end = cursor.pos();
740 if ((ocell == sel_cell_end) ||
741 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
742 sel_cell_end = tabular->GetCellBelow(sel_cell_end);
744 sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
745 UpdateLocal(bv, SELECTION, false);
749 result= moveDown(bv);
750 sel_pos_start = sel_pos_end = cursor.pos();
751 sel_cell_start = sel_cell_end = actcell;
753 UpdateLocal(bv, SELECTION, false);
759 sel_pos_end = cursor.pos();
760 if ((ocell == sel_cell_end) ||
761 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
762 sel_cell_end = tabular->GetCellAbove(sel_cell_end);
764 sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
765 UpdateLocal(bv, SELECTION, false);
770 sel_pos_start = sel_pos_end = cursor.pos();
771 sel_cell_start = sel_cell_end = actcell;
773 UpdateLocal(bv, SELECTION, false);
785 if (the_locking_inset) {
786 UnlockInsetInInset(bv, the_locking_inset);
787 the_locking_inset = 0;
789 if (action == LFUN_TAB)
793 sel_pos_start = sel_pos_end = cursor.pos();
794 sel_cell_start = sel_cell_end = actcell;
796 UpdateLocal(bv, SELECTION, false);
798 case LFUN_LAYOUT_TABLE:
800 dialogs_ = bv->owner()->getDialogs();
801 dialogs_->showTabular(this);
804 case LFUN_TABULAR_FEATURE:
805 if (!TabularFeatures(bv, arg))
806 result = UNDISPATCHED;
810 result = UNDISPATCHED;
813 if (result!=FINISHED) {
814 if (!the_locking_inset) {
816 if (ocell != actcell)
817 bview->getOwner()->getPopups().updateFormTabular();
822 bv->unlockInset(this);
827 int InsetTabular::Latex(Buffer const * buf, ostream & os,
828 bool fragile, bool fp) const
830 return tabular->Latex(buf, os, fragile, fp);
834 int InsetTabular::Ascii(Buffer const *, ostream &) const
840 int InsetTabular::Linuxdoc(Buffer const *, ostream &) const
846 int InsetTabular::DocBook(Buffer const *, ostream &) const
852 void InsetTabular::Validate(LaTeXFeatures & features) const
854 tabular->Validate(features);
858 bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
859 LyXFont const & font,
865 bool changed = false;
867 for(int i = 0; i < tabular->rows(); ++i) {
868 maxAsc = maxDesc = 0;
869 for(int j= 0; j < tabular->columns(); ++j) {
870 if (tabular->IsPartOfMultiColumn(i,j))
873 inset = tabular->GetCellInset(cell);
875 inset->update(bv, font, false);
876 maxAsc = max(maxAsc, inset->ascent(bv, font));
877 maxDesc = max(maxDesc, inset->descent(bv, font));
878 changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
880 changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
881 changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
887 void InsetTabular::GetCursorPos(BufferView *, int & x, int & y) const
889 x = cursor.x() - top_x;
894 void InsetTabular::ToggleInsetCursor(BufferView * bv)
896 if (the_locking_inset) {
897 the_locking_inset->ToggleInsetCursor(bv);
901 LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
903 int asc = lyxfont::maxAscent(font);
904 int desc = lyxfont::maxDescent(font);
907 bv->hideLockedInsetCursor();
909 bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
910 cursor_visible = !cursor_visible;
914 void InsetTabular::ShowInsetCursor(BufferView * bv)
916 if (!cursor_visible) {
917 LyXFont font; // = GetFont(par, cursor.pos);
919 int asc = lyxfont::maxAscent(font);
920 int desc = lyxfont::maxDescent(font);
921 bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
922 bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
923 cursor_visible = true;
928 void InsetTabular::HideInsetCursor(BufferView * bv)
930 if (cursor_visible) {
931 bv->hideLockedInsetCursor();
932 cursor_visible = false;
934 // if (cursor_visible)
935 // ToggleInsetCursor(bv);
939 void InsetTabular::setPos(BufferView * bv, int x, int y) const
944 actcell = actrow = actcol = 0;
945 int ly = tabular->GetDescentOfRow(actrow);
947 // first search the right row
948 while((ly < y) && (actrow < tabular->rows())) {
949 cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
950 tabular->GetAscentOfRow(actrow+1) +
951 tabular->GetAdditionalHeight(tabular->GetCellNumber(actrow + 1,
954 ly = cursor.y() + tabular->GetDescentOfRow(actrow);
956 actcell = tabular->GetCellNumber(actrow, actcol);
958 // now search the right column
959 int lx = tabular->GetWidthOfColumn(actcell) -
960 tabular->GetAdditionalWidth(actcell);
961 for(; !tabular->IsLastCellInRow(actcell) && (lx < x);
962 ++actcell,lx += tabular->GetWidthOfColumn(actcell) +
963 tabular->GetAdditionalWidth(actcell - 1));
966 if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
967 cursor.x(lx + top_x - 2);
970 cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
976 int InsetTabular::getCellXPos(int cell) const
980 for(c=cell;!tabular->IsFirstCellInRow(c);--c)
982 int lx = tabular->GetWidthOfColumn(cell);
983 for(; (c < cell); ++c) {
984 lx += tabular->GetWidthOfColumn(c);
986 return (lx - tabular->GetWidthOfColumn(cell) + top_x);
990 void InsetTabular::resetPos(BufferView * bv) const
994 actcol = tabular->column_of_cell(actcell);
999 for(; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
1000 if (tabular->IsLastCellInRow(cell)) {
1001 cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
1002 tabular->GetAscentOfRow(actrow + 1) +
1003 tabular->GetAdditionalHeight(cell + 1));
1007 static int offset = ADD_TO_TABULAR_WIDTH + 2;
1008 cursor.x(getCellXPos(actcell) + offset);
1009 if (((cursor.x() - offset) > 20) &&
1010 ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
1011 (bv->workWidth()-20)))
1013 scroll(bv, -tabular->GetWidthOfColumn(actcell)-20);
1014 UpdateLocal(bv, FULL, false);
1015 } else if ((cursor.x() - offset) < 20) {
1016 scroll(bv, 20 - cursor.x() + offset);
1017 UpdateLocal(bv, FULL, false);
1018 } else if (!cellstart(cursor.pos())) {
1019 LyXFont font(LyXFont::ALL_SANE);
1020 cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
1021 tabular->GetBeginningOfTextInCell(actcell));
1023 if ((!the_locking_inset ||
1024 !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
1025 (actcell != oldcell)) {
1026 dialogs_ = bv->owner()->getDialogs();
1027 dialogs_->updateTabular(const_cast<InsetTabular *>(this));
1033 UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
1035 if (!cellstart(cursor.pos())) {
1036 if (tabular->IsLastCell(actcell))
1039 cursor.pos(cursor.pos() + 1);
1041 if (ActivateCellInset(bv))
1043 } else { // before the inset
1044 cursor.pos(cursor.pos() + 1);
1047 return DISPATCHED_NOUPDATE;
1051 UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
1053 if (!cursor.pos()) {
1058 cursor.pos(cursor.pos() - 1);
1059 if (!cellstart(cursor.pos())) {
1061 } else if (lock) { // behind the inset
1062 if (ActivateCellInset(bv, 0, 0, 0, true))
1066 return DISPATCHED_NOUPDATE;
1070 UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv)
1072 int ocell = actcell;
1073 actcell = tabular->GetCellAbove(actcell);
1074 if (actcell == ocell) // we moved out of the inset
1077 return DISPATCHED_NOUPDATE;
1081 UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv)
1083 int ocell = actcell;
1084 actcell = tabular->GetCellBelow(actcell);
1085 if (actcell == ocell) // we moved out of the inset
1088 return DISPATCHED_NOUPDATE;
1092 bool InsetTabular::moveNextCell(BufferView * bv)
1094 if (tabular->IsLastCell(actcell))
1097 cursor.pos(cursor.pos() + 1);
1098 if (!cellstart(cursor.pos()))
1099 cursor.pos(cursor.pos() + 1);
1105 bool InsetTabular::movePrevCell(BufferView * bv)
1107 if (!actcell) // first cell
1110 cursor.pos(cursor.pos() - 1);
1111 if (cellstart(cursor.pos()))
1112 cursor.pos(cursor.pos() - 1);
1118 bool InsetTabular::Delete()
1124 void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
1126 if (the_locking_inset)
1127 the_locking_inset->SetFont(bv, font, tall);
1131 bool InsetTabular::TabularFeatures(BufferView * bv, string what)
1133 int action = LyXTabular::LAST_ACTION;
1137 for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
1138 if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
1139 tabularFeatures[i].feature.length())) {
1140 action = tabularFeatures[i].action;
1144 if (action == LyXTabular::LAST_ACTION)
1147 val = frontStrip(what.substr(tabularFeatures[i].feature.length()));
1148 TabularFeatures(bv, action, val);
1153 void InsetTabular::TabularFeatures(BufferView * bv, int feature, string value)
1162 setAlign = LYX_ALIGN_LEFT,
1168 case LyXTabular::M_ALIGN_LEFT:
1169 case LyXTabular::ALIGN_LEFT:
1170 setAlign=LYX_ALIGN_LEFT;
1172 case LyXTabular::M_ALIGN_RIGHT:
1173 case LyXTabular::ALIGN_RIGHT:
1174 setAlign=LYX_ALIGN_RIGHT;
1176 case LyXTabular::M_ALIGN_CENTER:
1177 case LyXTabular::ALIGN_CENTER:
1178 setAlign=LYX_ALIGN_CENTER;
1180 case LyXTabular::M_VALIGN_TOP:
1181 case LyXTabular::VALIGN_TOP:
1182 setAlign=LyXTabular::LYX_VALIGN_TOP;
1184 case LyXTabular::M_VALIGN_BOTTOM:
1185 case LyXTabular::VALIGN_BOTTOM:
1186 setAlign=LyXTabular::LYX_VALIGN_BOTTOM;
1188 case LyXTabular::M_VALIGN_CENTER:
1189 case LyXTabular::VALIGN_CENTER:
1190 setAlign=LyXTabular::LYX_VALIGN_CENTER;
1195 if (hasSelection()) {
1197 sel_col_start = tabular->column_of_cell(sel_cell_start);
1198 sel_col_end = tabular->column_of_cell(sel_cell_end);
1199 if (sel_col_start > sel_col_end) {
1200 sel_col_end = sel_col_start;
1201 sel_col_start = tabular->column_of_cell(sel_cell_end);
1203 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
1206 sel_row_start = tabular->row_of_cell(sel_cell_start);
1207 sel_row_end = tabular->row_of_cell(sel_cell_end);
1208 if (sel_row_start > sel_row_end) {
1209 tmp = sel_row_start;
1210 sel_row_start = sel_row_end;
1214 sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
1215 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1217 bv->text->SetUndo(bv->buffer(), Undo::FINISH,
1219 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
1220 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
1222 bv->text->cursor.par()->previous,
1223 bv->text->cursor.par()->next
1227 int row = tabular->row_of_cell(actcell);
1228 int column = tabular->column_of_cell(actcell);
1232 case LyXTabular::SET_PWIDTH:
1234 bool update = (tabular->GetColumnPWidth(actcell) != value);
1235 tabular->SetColumnPWidth(actcell,value);
1237 for (int i=0; i < tabular->rows(); ++i) {
1238 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1241 UpdateLocal(bv, INIT, true);
1245 case LyXTabular::SET_MPWIDTH:
1247 bool update = (tabular->GetPWidth(actcell) != value);
1248 tabular->SetMColumnPWidth(actcell,value);
1250 for (int i=0; i < tabular->rows(); ++i) {
1251 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1254 UpdateLocal(bv, INIT, true);
1258 case LyXTabular::SET_SPECIAL_COLUMN:
1259 case LyXTabular::SET_SPECIAL_MULTI:
1260 tabular->SetAlignSpecial(actcell,value,feature);
1262 case LyXTabular::APPEND_ROW:
1263 // append the row into the tabular
1264 UnlockInsetInInset(bv, the_locking_inset);
1265 tabular->AppendRow(actcell);
1266 UpdateLocal(bv, INIT, true);
1268 case LyXTabular::APPEND_COLUMN:
1269 // append the column into the tabular
1270 tabular->AppendColumn(actcell);
1271 actcell = tabular->GetCellNumber(row, column);
1272 UpdateLocal(bv, INIT, true);
1274 case LyXTabular::DELETE_ROW:
1275 tabular->DeleteRow(tabular->row_of_cell(actcell));
1276 if ((row+1) > tabular->rows())
1278 actcell = tabular->GetCellNumber(row, column);
1279 UpdateLocal(bv, INIT, true);
1281 case LyXTabular::DELETE_COLUMN:
1282 tabular->DeleteColumn(tabular->column_of_cell(actcell));
1283 if ((column+1) > tabular->columns())
1285 actcell = tabular->GetCellNumber(row, column);
1286 UpdateLocal(bv, INIT, true);
1288 case LyXTabular::M_TOGGLE_LINE_TOP:
1290 case LyXTabular::TOGGLE_LINE_TOP:
1291 lineSet = !tabular->TopLine(actcell, flag);
1292 for(i=sel_row_start; i<=sel_row_end; ++i)
1293 for(j=sel_col_start; j<=sel_col_end; ++j)
1294 tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet, flag);
1295 UpdateLocal(bv, INIT, true);
1298 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1300 case LyXTabular::TOGGLE_LINE_BOTTOM:
1301 lineSet = !tabular->BottomLine(actcell, flag);
1302 for(i=sel_row_start; i<=sel_row_end; ++i)
1303 for(j=sel_col_start; j<=sel_col_end; ++j)
1304 tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet,
1306 UpdateLocal(bv, INIT, true);
1309 case LyXTabular::M_TOGGLE_LINE_LEFT:
1311 case LyXTabular::TOGGLE_LINE_LEFT:
1312 lineSet = !tabular->LeftLine(actcell, flag);
1313 for(i=sel_row_start; i<=sel_row_end; ++i)
1314 for(j=sel_col_start; j<=sel_col_end; ++j)
1315 tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet,
1317 UpdateLocal(bv, INIT, true);
1320 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1322 case LyXTabular::TOGGLE_LINE_RIGHT:
1323 lineSet = !tabular->RightLine(actcell, flag);
1324 for(i=sel_row_start; i<=sel_row_end; ++i)
1325 for(j=sel_col_start; j<=sel_col_end; ++j)
1326 tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet,
1328 UpdateLocal(bv, INIT, true);
1330 case LyXTabular::M_ALIGN_LEFT:
1331 case LyXTabular::M_ALIGN_RIGHT:
1332 case LyXTabular::M_ALIGN_CENTER:
1334 case LyXTabular::ALIGN_LEFT:
1335 case LyXTabular::ALIGN_RIGHT:
1336 case LyXTabular::ALIGN_CENTER:
1337 for(i=sel_row_start; i<=sel_row_end; ++i)
1338 for(j=sel_col_start; j<=sel_col_end; ++j)
1339 tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign,
1342 UpdateLocal(bv, INIT, true);
1344 UpdateLocal(bv, CELL, true);
1346 case LyXTabular::M_VALIGN_TOP:
1347 case LyXTabular::M_VALIGN_BOTTOM:
1348 case LyXTabular::M_VALIGN_CENTER:
1350 case LyXTabular::VALIGN_TOP:
1351 case LyXTabular::VALIGN_BOTTOM:
1352 case LyXTabular::VALIGN_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->SetVAlignment(tabular->GetCellNumber(i,j), setAlign,
1358 UpdateLocal(bv, INIT, true);
1360 UpdateLocal(bv, CELL, true);
1362 case LyXTabular::MULTICOLUMN:
1364 if (sel_row_start != sel_row_end) {
1365 WriteAlert(_("Impossible Operation!"),
1366 _("Multicolumns can only be horizontally."),
1370 // just multicol for one Single Cell
1371 if (!hasSelection()) {
1372 // check wether we are completly in a multicol
1373 if (tabular->IsMultiColumn(actcell)) {
1374 tabular->UnsetMultiColumn(actcell);
1375 UpdateLocal(bv, INIT, true);
1377 tabular->SetMultiColumn(actcell, 1);
1378 UpdateLocal(bv, CELL, true);
1382 // we have a selection so this means we just add all this
1383 // cells to form a multicolumn cell
1387 if (sel_cell_start > sel_cell_end) {
1388 s_start = sel_cell_end;
1389 s_end = sel_cell_start;
1391 s_start = sel_cell_start;
1392 s_end = sel_cell_end;
1394 tabular->SetMultiColumn(s_start, s_end - s_start + 1);
1397 sel_cell_end = sel_cell_start;
1398 sel_pos_end = sel_pos_start;
1399 UpdateLocal(bv, INIT, true);
1402 case LyXTabular::SET_ALL_LINES:
1404 case LyXTabular::UNSET_ALL_LINES:
1405 for(i=sel_row_start; i<=sel_row_end; ++i)
1406 for(j=sel_col_start; j<=sel_col_end; ++j)
1407 tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
1408 UpdateLocal(bv, INIT, true);
1410 case LyXTabular::SET_LONGTABULAR:
1411 tabular->SetLongTabular(true);
1412 UpdateLocal(bv, INIT, true); // because this toggles displayed
1414 case LyXTabular::UNSET_LONGTABULAR:
1415 tabular->SetLongTabular(false);
1416 UpdateLocal(bv, INIT, true); // because this toggles displayed
1418 case LyXTabular::SET_ROTATE_TABULAR:
1419 tabular->SetRotateTabular(true);
1421 case LyXTabular::UNSET_ROTATE_TABULAR:
1422 tabular->SetRotateTabular(false);
1424 case LyXTabular::SET_ROTATE_CELL:
1425 for(i=sel_row_start; i<=sel_row_end; ++i)
1426 for(j=sel_col_start; j<=sel_col_end; ++j)
1427 tabular->SetRotateCell(tabular->GetCellNumber(i,j),true);
1429 case LyXTabular::UNSET_ROTATE_CELL:
1430 for(i=sel_row_start; i<=sel_row_end; ++i)
1431 for(j=sel_col_start; j<=sel_col_end; ++j)
1432 tabular->SetRotateCell(tabular->GetCellNumber(i,j),false);
1434 case LyXTabular::SET_USEBOX:
1436 int val = strToInt(value);
1437 if (val == tabular->GetUsebox(actcell))
1439 for(i=sel_row_start; i<=sel_row_end; ++i)
1440 for(j=sel_col_start; j<=sel_col_end; ++j)
1441 tabular->SetUsebox(tabular->GetCellNumber(i,j),val);
1444 case LyXTabular::SET_LTFIRSTHEAD:
1445 tabular->SetLTHead(actcell,true);
1447 case LyXTabular::SET_LTHEAD:
1448 tabular->SetLTHead(actcell,false);
1450 case LyXTabular::SET_LTFOOT:
1451 tabular->SetLTFoot(actcell,false);
1453 case LyXTabular::SET_LTLASTFOOT:
1454 tabular->SetLTFoot(actcell,true);
1456 case LyXTabular::SET_LTNEWPAGE:
1457 what = !tabular->GetLTNewPage(actcell);
1458 tabular->SetLTNewPage(actcell,what);
1464 bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
1467 // the cursor.pos has to be before the inset so if it isn't now just
1468 // reset the curor pos first!
1469 if (cursor.pos() % 2) { // behind the inset
1470 cursor.pos(cursor.pos() - 1);
1473 UpdatableInset * inset =
1474 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
1475 LyXFont font(LyXFont::ALL_SANE);
1477 x = inset->x() + inset->width(bv, font);
1478 y = inset->descent(bv, font);
1480 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1481 inset_y = cursor.y();
1482 inset->Edit(bv, x - inset_x, y - inset_y, button);
1483 if (!the_locking_inset)
1485 UpdateLocal(bv, CELL, false);
1490 bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
1492 InsetText * inset = tabular->GetCellInset(actcell);
1495 if (cursor.pos() % 2) { // behind the inset
1496 return (((x + top_x) < cursor.x()) &&
1497 ((x + top_x) > (cursor.x() - inset->width(bv,
1498 LyXFont(LyXFont::ALL_SANE)))));
1500 int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
1501 return ((x1 > x2) &&
1502 (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))));
1507 // This returns paperWidth() if the cell-width is unlimited or the width
1508 // in pixels if we have a pwidth for this cell.
1509 int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
1511 string s = tabular->GetPWidth(cell);
1515 return VSpace(s).inPixels( 0, 0);
1519 int InsetTabular::getMaxWidth(Painter & pain,
1520 UpdatableInset const * inset) const
1523 int n = tabular->GetNumberOfCells();
1524 for(cell=0; cell < n; ++cell) {
1525 if (tabular->GetCellInset(cell) == inset)
1530 int w = GetMaxWidthOfCell(pain, cell);
1532 // because the inset then subtracts it's top_x and owner->x()
1533 w += (inset->x() - top_x);
1538 void InsetTabular::resizeLyXText(BufferView *) const
1543 LyXText * InsetTabular::getLyXText(BufferView * bv) const
1545 if (the_locking_inset)
1546 return the_locking_inset->getLyXText(bv);
1547 return Inset::getLyXText(bv);
1551 void InsetTabular::OpenLayoutDialog(BufferView * bv) const
1553 if (the_locking_inset) {
1554 InsetTabular * i = static_cast<InsetTabular *>
1555 (the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE));
1557 i->OpenLayoutDialog(bv);
1561 dialogs_ = bv->owner()->getDialogs();
1562 dialogs_->showTabular(const_cast<InsetTabular *>(this));
1566 // functions returns:
1570 // 3 ... toggled off
1572 int InsetTabular::getStatus(string what) const
1574 int action = LyXTabular::LAST_ACTION;
1578 for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
1579 if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
1580 tabularFeatures[i].feature.length())) {
1581 action = tabularFeatures[i].action;
1585 if (action == LyXTabular::LAST_ACTION)
1588 argument = frontStrip(what.substr(tabularFeatures[i].feature.length()));
1590 int sel_row_start, sel_row_end;
1594 if (hasSelection()) {
1596 sel_row_start = tabular->row_of_cell(sel_cell_start);
1597 sel_row_end = tabular->row_of_cell(sel_cell_end);
1598 if (sel_row_start > sel_row_end) {
1599 tmp = sel_row_start;
1600 sel_row_start = sel_row_end;
1604 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1608 case LyXTabular::SET_PWIDTH:
1609 case LyXTabular::SET_MPWIDTH:
1610 case LyXTabular::SET_SPECIAL_COLUMN:
1611 case LyXTabular::SET_SPECIAL_MULTI:
1614 case LyXTabular::APPEND_ROW:
1615 case LyXTabular::APPEND_COLUMN:
1616 case LyXTabular::DELETE_ROW:
1617 case LyXTabular::DELETE_COLUMN:
1618 case LyXTabular::SET_ALL_LINES:
1619 case LyXTabular::UNSET_ALL_LINES:
1622 case LyXTabular::MULTICOLUMN:
1623 if (tabular->IsMultiColumn(actcell))
1627 case LyXTabular::M_TOGGLE_LINE_TOP:
1629 case LyXTabular::TOGGLE_LINE_TOP:
1630 if (tabular->TopLine(actcell, flag))
1634 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1636 case LyXTabular::TOGGLE_LINE_BOTTOM:
1637 if (tabular->BottomLine(actcell, flag))
1641 case LyXTabular::M_TOGGLE_LINE_LEFT:
1643 case LyXTabular::TOGGLE_LINE_LEFT:
1644 if (tabular->LeftLine(actcell, flag))
1648 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1650 case LyXTabular::TOGGLE_LINE_RIGHT:
1651 if (tabular->RightLine(actcell, flag))
1655 case LyXTabular::M_ALIGN_LEFT:
1657 case LyXTabular::ALIGN_LEFT:
1658 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT)
1662 case LyXTabular::M_ALIGN_RIGHT:
1664 case LyXTabular::ALIGN_RIGHT:
1665 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT)
1669 case LyXTabular::M_ALIGN_CENTER:
1671 case LyXTabular::ALIGN_CENTER:
1672 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER)
1676 case LyXTabular::M_VALIGN_TOP:
1678 case LyXTabular::VALIGN_TOP:
1679 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP)
1683 case LyXTabular::M_VALIGN_BOTTOM:
1685 case LyXTabular::VALIGN_BOTTOM:
1686 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM)
1690 case LyXTabular::M_VALIGN_CENTER:
1692 case LyXTabular::VALIGN_CENTER:
1693 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER)
1697 case LyXTabular::SET_LONGTABULAR:
1698 if (tabular->IsLongTabular())
1702 case LyXTabular::UNSET_LONGTABULAR:
1703 if (!tabular->IsLongTabular())
1707 case LyXTabular::SET_ROTATE_TABULAR:
1708 if (tabular->GetRotateTabular())
1712 case LyXTabular::UNSET_ROTATE_TABULAR:
1713 if (!tabular->GetRotateTabular())
1717 case LyXTabular::SET_ROTATE_CELL:
1718 if (tabular->GetRotateCell(actcell))
1722 case LyXTabular::UNSET_ROTATE_CELL:
1723 if (!tabular->GetRotateCell(actcell))
1727 case LyXTabular::SET_USEBOX:
1728 if (strToInt(argument) == tabular->GetUsebox(actcell))
1732 case LyXTabular::SET_LTFIRSTHEAD:
1733 if (tabular->GetRowOfLTHead(actcell, dummy))
1737 case LyXTabular::SET_LTHEAD:
1738 if (tabular->GetRowOfLTHead(actcell, dummy))
1742 case LyXTabular::SET_LTFOOT:
1743 if (tabular->GetRowOfLTFoot(actcell, dummy))
1747 case LyXTabular::SET_LTLASTFOOT:
1748 if (tabular->GetRowOfLTFoot(actcell, dummy))
1752 case LyXTabular::SET_LTNEWPAGE:
1753 if (tabular->GetLTNewPage(actcell))