]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
Restore XHTML output for InsetListings.
[lyx.git] / src / insets / InsetTabular.cpp
index 476541f1e221e339038a3fc1775f2d1d39867050..2678cd9d76d50040c2e1a1652790a99a3f122c16 100644 (file)
@@ -1800,8 +1800,6 @@ Tabular::idx_type Tabular::setLTCaption(row_type row, bool what)
                unsetMultiColumn(i);
                // When unsetting a caption row, also all existing
                // captions in this row must be dissolved.
-               lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN));
-               lyx::dispatch(FuncRequest(LFUN_INSET_DISSOLVE, "caption"));
        }
        row_info[row].caption = what;
        return i;
@@ -3322,7 +3320,7 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection)
 }
 
 
-void InsetTabular::updateLabels(ParIterator const & it)
+void InsetTabular::updateLabels(ParIterator const & it, bool out)
 {
        // In a longtable, tell captions what the current float is
        Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
@@ -3334,7 +3332,7 @@ void InsetTabular::updateLabels(ParIterator const & it)
        it2.forwardPos();
        size_t const end = it2.nargs();
        for ( ; it2.idx() < end; it2.top().forwardIdx())
-               buffer().updateLabels(it2);
+               buffer().updateLabels(it2, out);
 
        //reset afterwards
        if (tabular.is_long_tabular)
@@ -4763,6 +4761,14 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                break;
 
        case Tabular::UNSET_LONGTABULAR:
+               for (row_type i = 0; i < tabular.row_info.size(); ++i) {
+                       if (tabular.ltCaption(i)) {
+                               cur.idx() = tabular.cellIndex(i, 0);
+                               cur.pit() = 0;
+                               cur.pos() = 0;
+                               tabularFeatures(cur, Tabular::TOGGLE_LTCAPTION);
+                       }
+               }
                tabular.is_long_tabular = false;
                break;
 
@@ -4876,15 +4882,22 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                break;
 
        case Tabular::TOGGLE_LTCAPTION: {
-               bool set = !tabular.ltCaption(row);
+               bool const set = !tabular.ltCaption(row);
                cur.idx() = tabular.setLTCaption(row, set);
                cur.pit() = 0;
                cur.pos() = 0;
                cur.setSelection(false);
-               // When a row is set as caption, then also insert a caption. Otherwise
-               // the LaTeX output is broken, when the user doesn't add a caption.
-               if (set)
+
+               if (set) {
+                       // When a row is set as caption, then also insert
+                       // a caption. Otherwise the LaTeX output is broken.
+                       lyx::dispatch(FuncRequest(LFUN_INSET_SELECT_ALL));
                        lyx::dispatch(FuncRequest(LFUN_CAPTION_INSERT));
+               } else {
+                       FuncRequest fr(LFUN_INSET_DISSOLVE, "caption");
+                       if (lyx::getStatus(fr).enabled())
+                               lyx::dispatch(fr);
+               }
                break;
        }
 
@@ -5276,13 +5289,19 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf,
 }
 
 
-void InsetTabular::addPreview(PreviewLoader & loader) const
+void InsetTabular::addPreview(DocIterator const & inset_pos,
+       PreviewLoader & loader) const
 {
        row_type const rows = tabular.row_info.size();
        col_type const columns = tabular.column_info.size();
+       DocIterator cell_pos = inset_pos;
+
+       cell_pos.push_back(CursorSlice(*const_cast<InsetTabular *>(this)));
        for (row_type i = 0; i < rows; ++i) {
-               for (col_type j = 0; j < columns; ++j)
-                       tabular.cellInset(i, j)->addPreview(loader);
+               for (col_type j = 0; j < columns; ++j) {
+                       cell_pos.top().idx() = tabular.cellIndex(i, j);
+                       tabular.cellInset(i, j)->addPreview(cell_pos, loader);
+               }
        }
 }