]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
Table cells are insets, but not from the point of view of DocIterators
[lyx.git] / src / insets / InsetTabular.cpp
index 51f579ea3938b0061a4b2db0bc444d318417d8fa..60a0157cb3056dc33b15cf557a691ebb4334349d 100644 (file)
@@ -2451,10 +2451,12 @@ void Tabular::TeXLongtableHeaderFooter(otexstream & os,
                return;
 
        // caption handling
-       // the caption must be output before the headers
+       // output caption which is in no header or footer
        if (haveLTCaption()) {
                for (row_type r = 0; r < nrows(); ++r) {
-                       if (row_info[r].caption)
+                       if (row_info[r].caption &&
+                           !row_info[r].endfirsthead && !row_info[r].endhead &&
+                           !row_info[r].endfoot && !row_info[r].endlastfoot)
                                TeXRow(os, r, runparams);
                }
        }
@@ -3430,6 +3432,12 @@ docstring InsetTableCell::asString(bool intoInsets)
 }
 
 
+void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
+{
+       InsetText::iterateForToc(di, output_active);
+}
+
+
 docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 {
        if (!isFixedWidth)
@@ -3895,8 +3903,12 @@ 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();
        string const saveflt = cnts.current_float();
-       if (tabular.is_long_tabular)
+       if (tabular.is_long_tabular) {
                cnts.current_float("table");
+               // in longtables, we only step the counter once
+               cnts.step(from_ascii("table"), utype);
+               cnts.isLongtable(true);
+       }
 
        ParIterator it2 = it;
        it2.forwardPos();
@@ -3905,8 +3917,10 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
                buffer().updateBuffer(it2, utype);
 
        //reset afterwards
-       if (tabular.is_long_tabular)
+       if (tabular.is_long_tabular) {
                cnts.current_float(saveflt);
+               cnts.isLongtable(false);
+       }
 }
 
 
@@ -4750,7 +4764,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
 
                case Tabular::UNSET_LTFIRSTHEAD:
-                       status.setEnabled(sel_row_start == sel_row_end && !tabular.ltCaption(sel_row_start));
+                       status.setEnabled(sel_row_start == sel_row_end);
                        status.setOnOff(!tabular.getRowOfLTFirstHead(sel_row_start, dummyltt));
                        break;
 
@@ -4760,7 +4774,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
 
                case Tabular::UNSET_LTHEAD:
-                       status.setEnabled(sel_row_start == sel_row_end && !tabular.ltCaption(sel_row_start));
+                       status.setEnabled(sel_row_start == sel_row_end);
                        status.setOnOff(!tabular.getRowOfLTHead(sel_row_start, dummyltt));
                        break;
 
@@ -4770,7 +4784,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
 
                case Tabular::UNSET_LTFOOT:
-                       status.setEnabled(sel_row_start == sel_row_end && !tabular.ltCaption(sel_row_start));
+                       status.setEnabled(sel_row_start == sel_row_end);
                        status.setOnOff(!tabular.getRowOfLTFoot(sel_row_start, dummyltt));
                        break;
 
@@ -4780,7 +4794,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
 
                case Tabular::UNSET_LTLASTFOOT:
-                       status.setEnabled(sel_row_start == sel_row_end && !tabular.ltCaption(sel_row_start));
+                       status.setEnabled(sel_row_start == sel_row_end);
                        status.setOnOff(!tabular.getRowOfLTLastFoot(sel_row_start, dummyltt));
                        break;