]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
InsetTabular.cpp: fix bug that LyX allowed to specify the vertical alignment of table...
[lyx.git] / src / insets / InsetTabular.cpp
index 8f2c5c38da4e3663ce42fb03262a49f39c89461b..65ae8b912f43da27203f35629f8d5fe7354e850b 100644 (file)
@@ -101,87 +101,81 @@ boost::scoped_ptr<Tabular> paste_tabular;
 struct TabularFeature {
        Tabular::Feature action;
        string feature;
+       bool need_value;
 };
 
 
 TabularFeature tabularFeature[] =
 {
-       { Tabular::APPEND_ROW, "append-row" },
-       { Tabular::APPEND_COLUMN, "append-column" },
-       { Tabular::DELETE_ROW, "delete-row" },
-       { Tabular::DELETE_COLUMN, "delete-column" },
-       { Tabular::COPY_ROW, "copy-row" },
-       { Tabular::COPY_COLUMN, "copy-column" },
-       { Tabular::TOGGLE_LINE_TOP, "toggle-line-top" },
-       { Tabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
-       { Tabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
-       { Tabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
-       { Tabular::ALIGN_LEFT, "align-left" },
-       { Tabular::ALIGN_RIGHT, "align-right" },
-       { Tabular::ALIGN_CENTER, "align-center" },
-       { Tabular::ALIGN_BLOCK, "align-block" },
-       { Tabular::VALIGN_TOP, "valign-top" },
-       { Tabular::VALIGN_BOTTOM, "valign-bottom" },
-       { Tabular::VALIGN_MIDDLE, "valign-middle" },
-       { Tabular::M_ALIGN_LEFT, "m-align-left" },
-       { Tabular::M_ALIGN_RIGHT, "m-align-right" },
-       { Tabular::M_ALIGN_CENTER, "m-align-center" },
-       { Tabular::M_VALIGN_TOP, "m-valign-top" },
-       { Tabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
-       { Tabular::M_VALIGN_MIDDLE, "m-valign-middle" },
-       { Tabular::MULTICOLUMN, "multicolumn" },
-       { Tabular::MULTIROW, "multirow" },
-       { Tabular::SET_ALL_LINES, "set-all-lines" },
-       { Tabular::UNSET_ALL_LINES, "unset-all-lines" },
-       { Tabular::SET_LONGTABULAR, "set-longtabular" },
-       { Tabular::UNSET_LONGTABULAR, "unset-longtabular" },
-       { Tabular::SET_PWIDTH, "set-pwidth" },
-       { Tabular::SET_MPWIDTH, "set-mpwidth" },
-       { Tabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
-       { Tabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
-       { Tabular::TOGGLE_ROTATE_TABULAR, "toggle-rotate-tabular" },
-       { Tabular::SET_ROTATE_CELL, "set-rotate-cell" },
-       { Tabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
-       { Tabular::TOGGLE_ROTATE_CELL, "toggle-rotate-cell" },
-       { Tabular::SET_USEBOX, "set-usebox" },
-       { Tabular::SET_LTHEAD, "set-lthead" },
-       { Tabular::UNSET_LTHEAD, "unset-lthead" },
-       { Tabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
-       { Tabular::UNSET_LTFIRSTHEAD, "unset-ltfirsthead" },
-       { Tabular::SET_LTFOOT, "set-ltfoot" },
-       { Tabular::UNSET_LTFOOT, "unset-ltfoot" },
-       { Tabular::SET_LTLASTFOOT, "set-ltlastfoot" },
-       { Tabular::UNSET_LTLASTFOOT, "unset-ltlastfoot" },
-       { Tabular::SET_LTNEWPAGE, "set-ltnewpage" },
-       { Tabular::TOGGLE_LTCAPTION, "toggle-ltcaption" },
-       { Tabular::SET_SPECIAL_COLUMN, "set-special-column" },
-       { Tabular::SET_SPECIAL_MULTICOLUMN, "set-special-multicolumn" },
-       { Tabular::SET_SPECIAL_MULTIROW, "set-special-multirow" },
-       { Tabular::SET_BOOKTABS, "set-booktabs" },
-       { Tabular::UNSET_BOOKTABS, "unset-booktabs" },
-       { Tabular::SET_TOP_SPACE, "set-top-space" },
-       { Tabular::SET_BOTTOM_SPACE, "set-bottom-space" },
-       { Tabular::SET_INTERLINE_SPACE, "set-interline-space" },
-       { Tabular::SET_BORDER_LINES, "set-border-lines" },
-       { Tabular::TABULAR_VALIGN_TOP, "tabular-valign-top"},
-       { Tabular::TABULAR_VALIGN_MIDDLE, "tabular-valign-middle"},
-       { Tabular::TABULAR_VALIGN_BOTTOM, "tabular-valign-bottom"},
-       { Tabular::LONGTABULAR_ALIGN_LEFT, "longtabular-align-left" },
-       { Tabular::LONGTABULAR_ALIGN_CENTER, "longtabular-align-center" },
-       { Tabular::LONGTABULAR_ALIGN_RIGHT, "longtabular-align-right" },        
-       { Tabular::LAST_ACTION, "" }
-};
-
-
-class FeatureEqual : public unary_function<TabularFeature, bool> {
-public:
-       FeatureEqual(Tabular::Feature feature)
-               : feature_(feature) {}
-       bool operator()(TabularFeature const & tf) const {
-               return tf.action == feature_;
-       }
-private:
-       Tabular::Feature feature_;
+       { Tabular::APPEND_ROW, "append-row", false },
+       { Tabular::APPEND_COLUMN, "append-column", false },
+       { Tabular::DELETE_ROW, "delete-row", false },
+       { Tabular::DELETE_COLUMN, "delete-column", false },
+       { Tabular::COPY_ROW, "copy-row", false },
+       { Tabular::COPY_COLUMN, "copy-column", false },
+       { Tabular::SET_LINE_TOP, "set-line-top", true },
+       { Tabular::SET_LINE_BOTTOM, "set-line-bottom", true },
+       { Tabular::SET_LINE_LEFT, "set-line-left", true },
+       { Tabular::SET_LINE_RIGHT, "set-line-right", true },
+       //FIXME: get rid of those 4 TOGGLE actions in favor of the 4 above.
+       { Tabular::TOGGLE_LINE_TOP, "toggle-line-top", false },
+       { Tabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom", false },
+       { Tabular::TOGGLE_LINE_LEFT, "toggle-line-left", false },
+       { Tabular::TOGGLE_LINE_RIGHT, "toggle-line-right", false },
+       { Tabular::ALIGN_LEFT, "align-left", false },
+       { Tabular::ALIGN_RIGHT, "align-right", false },
+       { Tabular::ALIGN_CENTER, "align-center", false },
+       { Tabular::ALIGN_BLOCK, "align-block", false },
+       { Tabular::VALIGN_TOP, "valign-top", false },
+       { Tabular::VALIGN_BOTTOM, "valign-bottom", false },
+       { Tabular::VALIGN_MIDDLE, "valign-middle", false },
+       { Tabular::M_ALIGN_LEFT, "m-align-left", false },
+       { Tabular::M_ALIGN_RIGHT, "m-align-right", false },
+       { Tabular::M_ALIGN_CENTER, "m-align-center", false },
+       { Tabular::M_VALIGN_TOP, "m-valign-top", false },
+       { Tabular::M_VALIGN_BOTTOM, "m-valign-bottom", false },
+       { Tabular::M_VALIGN_MIDDLE, "m-valign-middle", false },
+       { Tabular::MULTICOLUMN, "multicolumn", false },
+       { Tabular::MULTIROW, "multirow", false },
+       { Tabular::SET_ALL_LINES, "set-all-lines", false },
+       { Tabular::UNSET_ALL_LINES, "unset-all-lines", false },
+       { Tabular::SET_LONGTABULAR, "set-longtabular", false },
+       { Tabular::UNSET_LONGTABULAR, "unset-longtabular", false },
+       { Tabular::SET_PWIDTH, "set-pwidth", true },
+       { Tabular::SET_MPWIDTH, "set-mpwidth", true },
+       { Tabular::SET_ROTATE_TABULAR, "set-rotate-tabular", false },
+       { Tabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular", false },
+       { Tabular::TOGGLE_ROTATE_TABULAR, "toggle-rotate-tabular", false },
+       { Tabular::SET_ROTATE_CELL, "set-rotate-cell", false },
+       { Tabular::UNSET_ROTATE_CELL, "unset-rotate-cell", false },
+       { Tabular::TOGGLE_ROTATE_CELL, "toggle-rotate-cell", false },
+       { Tabular::SET_USEBOX, "set-usebox", true },
+       { Tabular::SET_LTHEAD, "set-lthead", true },
+       { Tabular::UNSET_LTHEAD, "unset-lthead", true },
+       { Tabular::SET_LTFIRSTHEAD, "set-ltfirsthead", true },
+       { Tabular::UNSET_LTFIRSTHEAD, "unset-ltfirsthead", true },
+       { Tabular::SET_LTFOOT, "set-ltfoot", true },
+       { Tabular::UNSET_LTFOOT, "unset-ltfoot", true },
+       { Tabular::SET_LTLASTFOOT, "set-ltlastfoot", true },
+       { Tabular::UNSET_LTLASTFOOT, "unset-ltlastfoot", true },
+       { Tabular::SET_LTNEWPAGE, "set-ltnewpage", false },
+       { Tabular::TOGGLE_LTCAPTION, "toggle-ltcaption", false },
+       { Tabular::SET_SPECIAL_COLUMN, "set-special-column", true },
+       { Tabular::SET_SPECIAL_MULTICOLUMN, "set-special-multicolumn", true },
+       { Tabular::SET_SPECIAL_MULTIROW, "set-special-multirow", false },
+       { Tabular::SET_BOOKTABS, "set-booktabs", false },
+       { Tabular::UNSET_BOOKTABS, "unset-booktabs", false },
+       { Tabular::SET_TOP_SPACE, "set-top-space", true },
+       { Tabular::SET_BOTTOM_SPACE, "set-bottom-space", true },
+       { Tabular::SET_INTERLINE_SPACE, "set-interline-space", true },
+       { Tabular::SET_BORDER_LINES, "set-border-lines", false },
+       { Tabular::TABULAR_VALIGN_TOP, "tabular-valign-top", false},
+       { Tabular::TABULAR_VALIGN_MIDDLE, "tabular-valign-middle", false},
+       { Tabular::TABULAR_VALIGN_BOTTOM, "tabular-valign-bottom", false},
+       { Tabular::LONGTABULAR_ALIGN_LEFT, "longtabular-align-left", false },
+       { Tabular::LONGTABULAR_ALIGN_CENTER, "longtabular-align-center", false },
+       { Tabular::LONGTABULAR_ALIGN_RIGHT, "longtabular-align-right", false },
+       { Tabular::LAST_ACTION, "", false }
 };
 
 
@@ -499,13 +493,13 @@ void l_getline(istream & is, string & str)
 } // namespace
 
 
-string const featureAsString(Tabular::Feature feature)
+string const featureAsString(Tabular::Feature action)
 {
-       TabularFeature * end = tabularFeature +
-               sizeof(tabularFeature) / sizeof(TabularFeature);
-       TabularFeature * it = find_if(tabularFeature, end,
-                                          FeatureEqual(feature));
-       return (it == end) ? string() : it->feature;
+       for (size_t i = 0; i != Tabular::LAST_ACTION; ++i) {
+               if (tabularFeature[i].action == action)
+                       return tabularFeature[i].feature;
+       }
+       return string();
 }
 
 
@@ -873,32 +867,6 @@ bool Tabular::rightLine(idx_type cell) const
 }
 
 
-bool Tabular::topAlreadyDrawn(idx_type cell) const
-{
-       row_type const row = cellRow(cell);
-       if (row == 0)
-               return false;
-       
-       return !rowTopLine(row) && bottomLine(cellAbove(cell));
-}
-
-
-bool Tabular::leftAlreadyDrawn(idx_type cell) const
-{
-       col_type col = cellColumn(cell);
-       if (col == 0)
-               return false;
-       idx_type i = cellIndex(cellRow(cell), col - 1);
-       return rightLine(i) && !leftLine(cell);
-}
-
-
-bool Tabular::isLastRow(idx_type cell) const
-{
-       return cellRow(cell) == row_info.size() - 1;
-}
-
-
 int Tabular::interRowSpace(row_type row) const
 {
        if (!row || row >= row_info.size())
@@ -1067,6 +1035,11 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
        col_type const j = cellColumn(cell);
 
        column_info[j].p_width = width;
+       // reset the vertical alignment to top if the fixed with
+       // is removed or zero because only fixed width columns can
+       // have a vertical alignment
+       if (column_info[j].p_width.zero())
+               column_info[j].valignment = LYX_VALIGN_TOP;
        for (row_type i = 0; i < row_info.size(); ++i) {
                idx_type const cell = cellIndex(i, j);
                // because of multicolumns
@@ -3466,7 +3439,10 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int y,
                onoffcol = change.color();
        }
 
-       if (!tabular.topAlreadyDrawn(cell)) {
+       bool topalreadydrawn = row > 0 && !tabular.rowTopLine(row) 
+               && tabular.bottomLine(tabular.cellAbove(cell));
+
+       if (!topalreadydrawn) {
                on_off = !tabular.topLine(cell);
                pain.line(x, y, x + w, y,
                        on_off ? onoffcol : col,
@@ -3476,7 +3452,12 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int y,
        pain.line(x, y + h, x + w, y + h,
                on_off ? onoffcol : col,
                on_off ? Painter::line_onoffdash : Painter::line_solid);
-       if (!tabular.leftAlreadyDrawn(cell)) {
+
+       col_type const column = tabular.cellColumn(cell);
+       bool leftalreadydrawn = column > 0  && !tabular.leftLine(cell)
+               && tabular.rightLine(tabular.cellIndex(row, column - 1));
+
+       if (!leftalreadydrawn) {
                on_off = !tabular.leftLine(cell);
                pain.line(x, y, x, y + h,
                        on_off ? onoffcol : col,
@@ -3518,7 +3499,7 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection)
 }
 
 
-void InsetTabular::updateLabels(ParIterator const & it, UpdateType utype)
+void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
 {
        // In a longtable, tell captions what the current float is
        Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
@@ -3530,7 +3511,7 @@ void InsetTabular::updateLabels(ParIterator const & it, UpdateType utype)
        it2.forwardPos();
        size_t const end = it2.nargs();
        for ( ; it2.idx() < end; it2.top().forwardIdx())
-               buffer().updateLabels(it2, utype);
+               buffer().updateBuffer(it2, utype);
 
        //reset afterwards
        if (tabular.is_long_tabular)
@@ -3858,14 +3839,10 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
 //     }
 
        case LFUN_LAYOUT_TABULAR:
-               cur.bv().showDialog("tabular", params2string(*this), this);
-               break;
-
-       case LFUN_INSET_DIALOG_UPDATE:
-               cur.bv().updateDialog("tabular", params2string(*this));
+               cur.bv().showDialog("tabular");
                break;
 
-       case LFUN_TABULAR_FEATURE:
+       case LFUN_INSET_MODIFY:
                if (!tabularFeatures(cur, to_utf8(cmd.argument())))
                        cur.undispatched();
                break;
@@ -4032,12 +4009,22 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
        FuncStatus & status) const
 {
        switch (cmd.action) {
-       case LFUN_TABULAR_FEATURE: {
+       case LFUN_INSET_MODIFY: {
+               istringstream is(to_utf8(cmd.argument()));
+               string s;
+               is >> s;
+               if (insetCode(s) != TABULAR_CODE) {
+                       status.clear();
+                       status.setEnabled(false);
+                       break;
+               }
+               is >> s;
+               // FIXME: We only check for the very first argument...
                int action = Tabular::LAST_ACTION;
                int i = 0;
                for (; tabularFeature[i].action != Tabular::LAST_ACTION; ++i) {
                        string const tmp = tabularFeature[i].feature;
-                       if (tmp == to_utf8(cmd.argument()).substr(0, tmp.length())) {
+                       if (tmp == s.substr(0, tmp.length())) {
                                action = tabularFeature[i].action;
                                break;
                        }
@@ -4049,7 +4036,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                }
 
                string const argument
-                       = ltrim(to_utf8(cmd.argument()).substr(tabularFeature[i].feature.length()));
+                       = ltrim(s.substr(tabularFeature[i].feature.length()));
 
                row_type sel_row_start = 0;
                row_type sel_row_end = 0;
@@ -4081,16 +4068,20 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                case Tabular::MULTICOLUMN:
                        // If a row is set as longtable caption, it must not be allowed
                        // to unset that this row is a multicolumn.
+                       // don't allow to set a multirow as multicolumn
                        status.setEnabled(sel_row_start == sel_row_end
-                               && !tabular.ltCaption(tabular.cellRow(cur.idx())));
+                               && !tabular.ltCaption(tabular.cellRow(cur.idx()))
+                               && !tabular.isMultiRow(cur.idx()) );
                        status.setOnOff(tabular.isMultiColumn(cur.idx()));
                        break;
 
                case Tabular::MULTIROW:
                        // If a row is set as longtable caption, it must not be allowed
                        // to unset that this row is a multirow.
+                       // don't allow to set a multicolumn as multirow
                        status.setEnabled(sel_col_start == sel_col_end
-                               && !tabular.ltCaption(tabular.cellRow(cur.idx())));
+                               && !tabular.ltCaption(tabular.cellRow(cur.idx()))
+                               && !tabular.isMultiColumn(cur.idx()) );
                        status.setOnOff(tabular.isMultiRow(cur.idx()));
                        break;
 
@@ -4100,6 +4091,13 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
                        break;
 
+               case Tabular::SET_LINE_TOP:
+               case Tabular::SET_LINE_BOTTOM:
+               case Tabular::SET_LINE_LEFT:
+               case Tabular::SET_LINE_RIGHT:
+                       status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+                       break;
+
                case Tabular::TOGGLE_LINE_TOP:
                        status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
                        status.setOnOff(tabular.topLine(cur.idx()));
@@ -4146,6 +4144,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                case Tabular::M_VALIGN_TOP:
                        flag = false;
                case Tabular::VALIGN_TOP:
+                       status.setEnabled(!tabular.getPWidth(cur.idx()).zero());
                        status.setOnOff(
                                tabular.getVAlignment(cur.idx(), flag) == Tabular::LYX_VALIGN_TOP);
                        break;
@@ -4153,6 +4152,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                case Tabular::M_VALIGN_BOTTOM:
                        flag = false;
                case Tabular::VALIGN_BOTTOM:
+                       status.setEnabled(!tabular.getPWidth(cur.idx()).zero());
                        status.setOnOff(
                                tabular.getVAlignment(cur.idx(), flag) == Tabular::LYX_VALIGN_BOTTOM);
                        break;
@@ -4160,6 +4160,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                case Tabular::M_VALIGN_MIDDLE:
                        flag = false;
                case Tabular::VALIGN_MIDDLE:
+                       status.setEnabled(!tabular.getPWidth(cur.idx()).zero());
                        status.setOnOff(
                                tabular.getVAlignment(cur.idx(), flag) == Tabular::LYX_VALIGN_MIDDLE);
                        break;
@@ -4269,6 +4270,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
 
                // only one row can be the caption
+               // and a multirow cannot be set as caption
                case Tabular::TOGGLE_LTCAPTION:
                        status.setEnabled(sel_row_start == sel_row_end
                                && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
@@ -4276,7 +4278,8 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                                && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
                                && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
                                && (!tabular.haveLTCaption()
-                                       || tabular.ltCaption(sel_row_start)));
+                                       || tabular.ltCaption(sel_row_start))
+                               && !tabular.isMultiRow(sel_row_start));
                        status.setOnOff(tabular.ltCaption(sel_row_start));
                        break;
 
@@ -4365,17 +4368,11 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                // relay this lfun to Inset, not to the cell.
                return Inset::getStatus(cur, cmd, status);
 
-       case LFUN_INSET_MODIFY:
-               if (insetCode(cmd.getArg(0)) == TABULAR_CODE) {
-                       status.setEnabled(true);
-                       return true;
-               }
-               // Fall through
-
        default:
                // we try to handle this event in the insets dispatch function.
                return cell(cur.idx())->getStatus(cur, cmd, status);
        }
+       return false;
 }
 
 
@@ -4732,27 +4729,45 @@ void InsetTabular::movePrevCell(Cursor & cur, EntryDirection entry_from)
 }
 
 
-bool InsetTabular::tabularFeatures(Cursor & cur, string const & what)
+bool InsetTabular::tabularFeatures(Cursor & cur, string const & argument)
 {
-       Tabular::Feature action = Tabular::LAST_ACTION;
+       istringstream is(argument);
+       string s;
+       is >> s;
+       if (insetCode(s) != TABULAR_CODE)
+               return false;
 
-       int i = 0;
-       for (; tabularFeature[i].action != Tabular::LAST_ACTION; ++i) {
-               string const tmp = tabularFeature[i].feature;
+       // Safe guard.
+       size_t safe_guard = 0;
+       for (;;) {
+               if (is.eof())
+                       break;
+               safe_guard++;
+               if (safe_guard > 1000) {
+                       LYXERR0("parameter max count reached!");
+                       break;
+               }
+               is >> s;
+               Tabular::Feature action = Tabular::LAST_ACTION;
+
+               size_t i = 0;
+               for (; tabularFeature[i].action != Tabular::LAST_ACTION; ++i) {
+                       if (s != tabularFeature[i].feature)
+                               continue;
 
-               if (tmp == what.substr(0, tmp.length())) {
-                       //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
-                       //tabularFeatures[i].feature.length()))
                        action = tabularFeature[i].action;
                        break;
                }
+               if (action == Tabular::LAST_ACTION) {
+                       LYXERR0("Feature not found " << s);
+                       continue;
+               }
+               string val;
+               if (tabularFeature[i].need_value)
+                       is >> val;
+               LYXERR(Debug::DEBUG, "Feature: " << s << "\t\tvalue: " << val);
+               tabularFeatures(cur, action, val);
        }
-       if (action == Tabular::LAST_ACTION)
-               return false;
-
-       string const val =
-               ltrim(what.substr(tabularFeature[i].feature.length()));
-       tabularFeatures(cur, action, val);
        return true;
 }
 
@@ -4866,7 +4881,14 @@ void InsetTabular::tabularFeatures(Cursor & cur,
 
        case Tabular::SET_SPECIAL_COLUMN:
        case Tabular::SET_SPECIAL_MULTICOLUMN:
-               tabular.setAlignSpecial(cur.idx(), from_utf8(value), feature);
+               if (value == "none")
+                       tabular.setAlignSpecial(cur.idx(), docstring(), feature);
+               else
+                       tabular.setAlignSpecial(cur.idx(), from_utf8(value), feature);
+               break;
+
+       case Tabular::SET_SPECIAL_MULTIROW:
+               //FIXME: noting to do here?
                break;
 
        case Tabular::APPEND_ROW:
@@ -4911,32 +4933,40 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                cur.idx() = tabular.cellIndex(row, column);
                break;
 
+       case Tabular::SET_LINE_TOP:
        case Tabular::TOGGLE_LINE_TOP: {
-               bool lineSet = !tabular.topLine(cur.idx());
+               bool lineSet = (feature == Tabular::SET_LINE_TOP)
+                              ? (value == "true") : !tabular.topLine(cur.idx());
                for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                        for (col_type j = sel_col_start; j <= sel_col_end; ++j)
                                tabular.setTopLine(tabular.cellIndex(i, j), lineSet);
                break;
        }
 
+       case Tabular::SET_LINE_BOTTOM:
        case Tabular::TOGGLE_LINE_BOTTOM: {
-               bool lineSet = !tabular.bottomLine(cur.idx());
+               bool lineSet = (feature == Tabular::SET_LINE_BOTTOM)
+                              ? (value == "true") : !tabular.bottomLine(cur.idx());
                for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                        for (col_type j = sel_col_start; j <= sel_col_end; ++j)
                                tabular.setBottomLine(tabular.cellIndex(i, j), lineSet);
                break;
        }
 
+       case Tabular::SET_LINE_LEFT:
        case Tabular::TOGGLE_LINE_LEFT: {
-               bool lineSet = !tabular.leftLine(cur.idx());
+               bool lineSet = (feature == Tabular::SET_LINE_LEFT)
+                              ? (value == "true") : !tabular.leftLine(cur.idx());
                for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                        for (col_type j = sel_col_start; j <= sel_col_end; ++j)
                                tabular.setLeftLine(tabular.cellIndex(i, j), lineSet);
                break;
        }
 
+       case Tabular::SET_LINE_RIGHT:
        case Tabular::TOGGLE_LINE_RIGHT: {
-               bool lineSet = !tabular.rightLine(cur.idx());
+               bool lineSet = (feature == Tabular::SET_LINE_RIGHT)
+                              ? (value == "true") : !tabular.rightLine(cur.idx());
                for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                        for (col_type j = sel_col_start; j <= sel_col_end; ++j)
                                tabular.setRightLine(tabular.cellIndex(i, j), lineSet);
@@ -5192,12 +5222,12 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                if (value == "default")
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                                tabular.row_info[i].top_space_default = true;
-               else if (isValidLength(value, &len))
+               else if (value == "none")
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
                                tabular.row_info[i].top_space_default = false;
                                tabular.row_info[i].top_space = len;
                        }
-               else
+               else if (isValidLength(value, &len))
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
                                tabular.row_info[i].top_space_default = false;
                                tabular.row_info[i].top_space = len;
@@ -5210,12 +5240,12 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                if (value == "default")
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                                tabular.row_info[i].bottom_space_default = true;
-               else if (isValidLength(value, &len))
+               else if (value == "none")
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
                                tabular.row_info[i].bottom_space_default = false;
                                tabular.row_info[i].bottom_space = len;
                        }
-               else
+               else if (isValidLength(value, &len))
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
                                tabular.row_info[i].bottom_space_default = false;
                                tabular.row_info[i].bottom_space = len;
@@ -5228,12 +5258,12 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                if (value == "default")
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i)
                                tabular.row_info[i].interline_space_default = true;
-               else if (isValidLength(value, &len))
+               else if (value == "none")
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
                                tabular.row_info[i].interline_space_default = false;
                                tabular.row_info[i].interline_space = len;
                        }
-               else
+               else if (isValidLength(value, &len))
                        for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
                                tabular.row_info[i].interline_space_default = false;
                                tabular.row_info[i].interline_space = len;
@@ -5248,21 +5278,6 @@ void InsetTabular::tabularFeatures(Cursor & cur,
 }
 
 
-bool InsetTabular::showInsetDialog(BufferView * bv) const
-{
-       bv->showDialog("tabular", params2string(*this),
-               const_cast<InsetTabular *>(this));
-       return true;
-}
-
-
-void InsetTabular::openLayoutDialog(BufferView * bv) const
-{
-       bv->showDialog("tabular", params2string(*this),
-               const_cast<InsetTabular *>(this));
-}
-
-
 bool InsetTabular::copySelection(Cursor & cur)
 {
        if (!cur.selection())