]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
remove redundant code
[lyx.git] / src / insets / insettabular.C
index 02ba39335340a53702b1830649e00c5ac65e9d43..5e3c7fd2d5415ba6470325fec27356165a0a99b0 100644 (file)
@@ -587,6 +587,10 @@ void InsetTabular::insetUnlock(BufferView * bv)
 void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
                               bool mark_dirty) const
 {
+       if (what == INIT) {
+               LyXFont font;
+               calculate_dimensions_of_cells(bv, font, true);
+       }
        if (need_update < what) // only set this if it has greater update
                need_update = what;
        if ((what == INIT) && hasSelection())
@@ -843,10 +847,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                case LFUN_SHIFT_TAB:
                case LFUN_TAB:
                        hideInsetCursor(bv);
-                       if (the_locking_inset) {
-                               unlockInsetInInset(bv, the_locking_inset);
-                               the_locking_inset = 0;
-                       }
+                       unlockInsetInInset(bv, the_locking_inset);
                        if (action == LFUN_TAB)
                                moveNextCell(bv, old_locking_inset != 0);
                        else
@@ -958,10 +959,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                break;
        case LFUN_NEXT: {
                int column = actcol;
-               if (the_locking_inset) {
-                       unlockInsetInInset(bv, the_locking_inset);
-                       the_locking_inset = 0;
-               }
+               unlockInsetInInset(bv, the_locking_inset);
                if (bv->text->first + bv->painter().paperHeight() <
                    (top_baseline + tabular->GetHeightOfTabular()))
                        {
@@ -977,10 +975,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
        }
        case LFUN_PRIOR: {
                int column = actcol;
-               if (the_locking_inset) {
-                       unlockInsetInInset(bv, the_locking_inset);
-                       the_locking_inset = 0;
-               }
+               unlockInsetInInset(bv, the_locking_inset);
                if (top_baseline < 0) {
                        bv->scrollCB(bv->text->first - bv->painter().paperHeight());
                        updateLocal(bv, FULL, false);
@@ -1052,7 +1047,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                        string::size_type len = clip.length();
                        string::size_type p = 0;
 
-                       while(p < len &&
+                       while (p < len &&
                              ((p = clip.find_first_of("\t\n", p)) != string::npos)) {
                                switch(clip[p]) {
                                case '\t':
@@ -1074,7 +1069,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                        int cell = 0;
                        int cells = paste_tabular->GetNumberOfCells();
                        p = cols = 0;
-                       while((cell < cells) && (p < len) &&
+                       while ((cell < cells) && (p < len) &&
                              (p = clip.find_first_of("\t\n", p)) != string::npos) {
                                if (p >= len)
                                        break;
@@ -1086,7 +1081,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                                        break;
                                case '\n':
                                        paste_tabular->GetCellInset(cell)->setText(clip.substr(op, p-op));
-                                       while(cols++ < maxCols)
+                                       while (cols++ < maxCols)
                                                ++cell;
                                        cols = 0;
                                        break;
@@ -1129,7 +1124,6 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                        if ((result == UNDISPATCHED) || (result >= FINISHED)) {
                                unlockInsetInInset(bv, the_locking_inset);
                                nodraw(false);
-                               the_locking_inset = 0;
                                // we need to update if this was requested before
                                updateLocal(bv, NONE, false);
                                return UNDISPATCHED;
@@ -1244,6 +1238,8 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
                changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
                changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
        }
+       if (changed)
+               tabular->reinit();
        return changed;
 }
 
@@ -1325,7 +1321,7 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const
        int ly = tabular->GetDescentOfRow(actrow);
 
        // first search the right row
-       while((ly < y) && ((actrow+1) < tabular->rows())) {
+       while ((ly < y) && ((actrow+1) < tabular->rows())) {
                cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) +
                                 tabular->GetAscentOfRow(actrow + 1) +
                                 tabular->GetAdditionalHeight(actrow + 1));
@@ -2363,7 +2359,7 @@ bool InsetTabular::copySelection(BufferView * bv)
        paste_tabular = new LyXTabular(this, *tabular); // rows, columns);
        for (int i = 0; i < sel_row_start; ++i)
                paste_tabular->DeleteRow(0);
-       while(paste_tabular->rows() > rows)
+       while (paste_tabular->rows() > rows)
                paste_tabular->DeleteRow(rows);
        paste_tabular->SetTopLine(0, true, true);
        paste_tabular->SetBottomLine(paste_tabular->GetFirstCellInRow(rows-1),