]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
Fix wrongly copy-pasted entries in SpellcheckerUi.ui
[lyx.git] / src / insets / InsetTabular.cpp
index 2f0a111fee411a681237cfdbe2a9c657edaf5674..5eb59e54d2513c8100e86b0ba3de223c4ec22f7d 100644 (file)
@@ -1342,8 +1342,9 @@ Tabular::idx_type Tabular::getFirstCellInRow(row_type row) const
 Tabular::idx_type Tabular::getLastCellInRow(row_type row) const
 {
        col_type c = ncols() - 1;
-       while (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW
-               || cell_info[row][c].multicolumn == CELL_PART_OF_MULTICOLUMN)
+       while (c > 0
+              && (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW
+                  || cell_info[row][c].multicolumn == CELL_PART_OF_MULTICOLUMN))
                --c;
        return cell_info[row][c].cellno;
 }
@@ -2441,14 +2442,16 @@ void Tabular::TeXRow(otexstream & os, row_type row,
        for (col_type c = 0; c < ncols(); ++c) {
                if (isPartOfMultiColumn(row, c))
                        continue;
-                       
-               if (isPartOfMultiRow(row, c) && 
-                       column_info[c].alignment != LYX_ALIGN_DECIMAL) {
-                       os << " & "; 
+
+               cell = cellIndex(row, c);
+
+               if (isPartOfMultiRow(row, c)
+                   && column_info[c].alignment != LYX_ALIGN_DECIMAL) {
+                       if (cell != getLastCellInRow(row))
+                               os << " & "; 
                        continue;
                }
 
-               cell = cellIndex(row, c);
                TeXCellPreamble(os, cell, ismulticol, ismultirow);
                shared_ptr<InsetTableCell> inset = cellInset(cell);
 
@@ -2560,6 +2563,10 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const
        //+                      first the opening preamble                    +
        //+---------------------------------------------------------------------
 
+       os << safebreakln;
+       if (runparams.lastid != -1)
+               os.texrow().start(runparams.lastid, runparams.lastpos);
+
        if (rotate)
                os << "\\begin{sideways}\n";
 
@@ -2880,9 +2887,9 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
                if (isMultiColumn(cell))
                        attr << " colspan='" << columnSpan(cell) << "'";
 
-               xs << html::StartTag(celltag, attr.str());
+               xs << html::StartTag(celltag, attr.str()) << html::CR();
                ret += cellInset(cell)->xhtml(xs, runparams);
-               xs << html::EndTag(celltag);
+               xs << html::EndTag(celltag) << html::CR();
                ++cell;
        }
        xs << html::EndTag("tr");
@@ -2908,17 +2915,19 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
                        align = "right";
                        break;
                }
-               xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'");
+               xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'")
+                  << html::CR();
                if (haveLTCaption()) {
-                       xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'");
+                       xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'")
+                          << html::CR();
                        for (row_type r = 0; r < nrows(); ++r)
                                if (row_info[r].caption)
                                        ret += xhtmlRow(xs, r, runparams);
-                       xs << html::EndTag("div");
+                       xs << html::EndTag("div") << html::CR();
                }
        }
 
-       xs << html::StartTag("table");
+       xs << html::StartTag("table") << html::CR();
 
        // output header info
        bool const havefirsthead = haveLTFirstHead();
@@ -2927,40 +2936,42 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
        // in XHTML. this test accomplishes that.
        bool const havehead = !havefirsthead && haveLTHead();
        if (havehead || havefirsthead) {
-               xs << html::StartTag("thead");
+               xs << html::StartTag("thead") << html::CR();
                for (row_type r = 0; r < nrows(); ++r) {
                        if ((havefirsthead && row_info[r].endfirsthead)
                            || (havehead && row_info[r].endhead)) {
                                ret += xhtmlRow(xs, r, runparams, true);
                        }
                }
-               xs << html::EndTag("thead");
+               xs << html::EndTag("thead") << html::CR();
        }
        // output footer info
        bool const havelastfoot = haveLTLastFoot();
        // as before.
        bool const havefoot = !havelastfoot && haveLTFoot();
        if (havefoot || havelastfoot) {
-               xs << html::StartTag("tfoot");
+               xs << html::StartTag("tfoot") << html::CR();
                for (row_type r = 0; r < nrows(); ++r) {
                        if ((havelastfoot && row_info[r].endlastfoot)
                            || (havefoot && row_info[r].endfoot)) {
                                ret += xhtmlRow(xs, r, runparams);
                        }
                }
-               xs << html::EndTag("tfoot");
+               xs << html::EndTag("tfoot") << html::CR();
        }
 
-       xs << html::StartTag("tbody");
+       xs << html::StartTag("tbody") << html::CR();
        for (row_type r = 0; r < nrows(); ++r) {
                if (isValidRow(r)) {
                        ret += xhtmlRow(xs, r, runparams);
                }
        }
        xs << html::EndTag("tbody")
-          << html::EndTag("table");
+          << html::CR()
+          << html::EndTag("table")
+          << html::CR();
        if (is_long_tabular)
-               xs << html::EndTag("div");
+               xs << html::EndTag("div") << html::CR();
        return ret;
 }
 
@@ -3998,6 +4009,8 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cmd = FuncRequest(finish_lfun);
                else
                        cur.dispatched();
+
+               cur.screenUpdateFlags(Update::Force | Update::FitCursor);
                break;
 
        }
@@ -4034,6 +4047,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cur.setCurrentFont();
                        return;
                }
+               cur.screenUpdateFlags(Update::FitCursor);
                break;
 
        case LFUN_UP_SELECT:
@@ -4067,6 +4081,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cur.setCurrentFont();
                        return;
                }
+               cur.screenUpdateFlags(Update::FitCursor);
                break;
 
 //     case LFUN_SCREEN_DOWN: {
@@ -4278,8 +4293,16 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                if (&cur.inset() != this || cmd.getArg(0) != "tabular") 
                        break;
 
-               string const s = cmd.getArg(1);
                // FIXME: We only check for the very first argument...
+               string const s = cmd.getArg(1);
+               // We always enable the lfun if it is coming from the dialog
+               // because the dialog makes sure all the settings are valid,
+               // even though the first argument might not be valid now.
+               if (s == "from-dialog") {
+                       status.setEnabled(true);
+                       return true;
+               }
+
                int action = Tabular::LAST_ACTION;
                int i = 0;
                for (; tabularFeature[i].action != Tabular::LAST_ACTION; ++i) {