setBottomLine(i, false);
setLeftLine(i, false);
setRightLine(i, false);
- } else
+ // When a row is set as caption, then also insert a caption. Otherwise
+ // the LaTeX output is broken, when the user don't add a caption.
+ dispatch(FuncRequest(LFUN_CAPTION_INSERT));
+ } else {
unsetMultiColumn(i);
+ // FIXME: when unsetting a caption row, also all existing captions
+ // in this row must be dissolved, see (bug 5754)
+ // dispatch(FuncRequest(LFUN_INSET_DISSOLVE, "caption-insert"));
+ }
row_info[row].caption = what;
return i;
}
}
+bool Tabular::haveLTCaption() const
+{
+ for (row_type i = 0; i < row_info.size(); ++i)
+ if (row_info[i].caption)
+ return true;
+ return false;
+}
+
+
// end longtable support functions
void Tabular::setRowAscent(row_type row, int height)
return 0;
int ret = 0;
- // output header info
- if (haveLTHead()) {
- if (endhead.topDL) {
+ // caption handling
+ // the caption must be output befrore the headers
+ if (haveLTCaption()) {
+ for (row_type i = 0; i < row_info.size(); ++i) {
+ if (row_info[i].caption) {
+ ret += TeXRow(os, i, runparams);
+ }
+ }
+ }
+ // output first header info
+ // first header must be output before the header, otherwise the
+ // correct caption placement becomes really wierd
+ if (haveLTFirstHead()) {
+ if (endfirsthead.topDL) {
os << "\\hline\n";
++ret;
}
for (row_type i = 0; i < row_info.size(); ++i) {
- if (row_info[i].endhead) {
+ if (row_info[i].endfirsthead) {
ret += TeXRow(os, i, runparams);
}
}
- if (endhead.bottomDL) {
+ if (endfirsthead.bottomDL) {
os << "\\hline\n";
++ret;
}
- os << "\\endhead\n";
+ os << "\\endfirsthead\n";
++ret;
- if (endfirsthead.empty) {
+ }
+ // output header info
+ if (haveLTHead()) {
+ if (!haveLTFirstHead()) {
os << "\\endfirsthead\n";
++ret;
}
- }
- // output firstheader info
- if (haveLTFirstHead()) {
- if (endfirsthead.topDL) {
+ if (endhead.topDL) {
os << "\\hline\n";
++ret;
}
for (row_type i = 0; i < row_info.size(); ++i) {
- if (row_info[i].endfirsthead) {
+ if (row_info[i].endhead) {
ret += TeXRow(os, i, runparams);
}
}
- if (endfirsthead.bottomDL) {
+ if (endhead.bottomDL) {
os << "\\hline\n";
++ret;
}
- os << "\\endfirsthead\n";
+ os << "\\endhead\n";
++ret;
}
// output footer info
}
os << "\\endfoot\n";
++ret;
- if (endlastfoot.empty) {
+ if (!haveLTLastFoot()) {
os << "\\endlastfoot\n";
++ret;
}
{
if (!is_long_tabular)
return true;
- return !row_info[row].endhead && !row_info[row].endfirsthead &&
- !row_info[row].endfoot && !row_info[row].endlastfoot;
+ return !row_info[row].endhead && !row_info[row].endfirsthead
+ && !row_info[row].endfoot && !row_info[row].endlastfoot
+ && !row_info[row].caption;
}
//+---------------------------------------------------------------------
// output header info
- if (haveLTHead() || haveLTFirstHead()) {
+ if (haveLTHead() || haveLTFirstHead()|| haveLTCaption()) {
os << "<thead>\n";
++ret;
for (row_type i = 0; i < row_info.size(); ++i) {
- if (row_info[i].endhead || row_info[i].endfirsthead) {
+ if (row_info[i].endhead || row_info[i].endfirsthead
+ || row_info[i].caption) {
ret += docbookRow(os, i, runparams);
}
}
status.setOnOff(convert<int>(argument) == tabular.getUsebox(cur.idx()));
break;
- case Tabular::SET_LTFIRSTHEAD:
- status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
+ // every row can only be one thing:
+ // either a footer or header or caption
+ case Tabular::SET_LTFIRSTHEAD:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start));
+ status.setOnOff(tabular.getRowOfLTFirstHead(sel_row_start, dummyltt));
break;
case Tabular::UNSET_LTFIRSTHEAD:
- status.setOnOff(!tabular.getRowOfLTHead(sel_row_start, dummyltt));
+ status.setOnOff(!tabular.getRowOfLTFirstHead(sel_row_start, dummyltt));
break;
case Tabular::SET_LTHEAD:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start));
status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
break;
break;
case Tabular::SET_LTFOOT:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start));
status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
break;
break;
case Tabular::SET_LTLASTFOOT:
- status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start));
+ status.setOnOff(tabular.getRowOfLTLastFoot(sel_row_start, dummyltt));
break;
case Tabular::UNSET_LTLASTFOOT:
- status.setOnOff(!tabular.getRowOfLTFoot(sel_row_start, dummyltt));
+ status.setOnOff(!tabular.getRowOfLTLastFoot(sel_row_start, dummyltt));
break;
case Tabular::SET_LTNEWPAGE:
break;
case Tabular::TOGGLE_LTCAPTION:
- status.setEnabled(sel_row_start == sel_row_end);
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt));
status.setOnOff(tabular.ltCaption(sel_row_start));
break;