inset(new InsetTableCell(buf))
{
inset->setBuffer(const_cast<Buffer &>(buf));
- inset->paragraphs().back().setLayout(buf.params().documentClass().plainLayout());
}
setBottomLine(i, false);
setLeftLine(i, false);
setRightLine(i, false);
- // 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
}
// output first header info
// first header must be output before the header, otherwise the
- // correct caption placement becomes really wierd
+ // correct caption placement becomes really weird
if (haveLTFirstHead()) {
if (endfirsthead.topDL) {
os << "\\hline\n";
}
// output header info
if (haveLTHead()) {
- if (!haveLTFirstHead()) {
+ if (endfirsthead.empty && !haveLTFirstHead()) {
os << "\\endfirsthead\n";
++ret;
}
}
os << "\\endfoot\n";
++ret;
- if (!haveLTLastFoot()) {
+ if (endlastfoot.empty && !haveLTLastFoot()) {
os << "\\endlastfoot\n";
++ret;
}
//+ Long Tabular case +
//+---------------------------------------------------------------------
+ // output caption info
+ if (haveLTCaption()) {
+ os << "<caption>\n";
+ ++ret;
+ for (row_type i = 0; i < row_info.size(); ++i) {
+ if (row_info[i].caption) {
+ ret += docbookRow(os, i, runparams);
+ }
+ }
+ os << "</caption>\n";
+ ++ret;
+ }
// output header info
if (haveLTHead() || haveLTFirstHead()) {
os << "<thead>\n";
/////////////////////////////////////////////////////////////////////
InsetTableCell::InsetTableCell(Buffer & buf)
- : InsetText(buf), isFixedWidth(false),
+ : InsetText(buf, InsetText::PlainLayout), isFixedWidth(false),
contentAlign(LYX_ALIGN_CENTER)
{}
bool InsetTabular::insetAllowed(InsetCode code) const
{
- if (code == MATHMACRO_CODE)
+ if (code == MATHMACRO_CODE
+ || (code == CAPTION_CODE && !tabular.is_long_tabular))
return false;
return true;
// insert file functions
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
- case LFUN_FILE_INSERT_PLAINTEXT: {
+ case LFUN_FILE_INSERT_PLAINTEXT:
// FIXME UNICODE
- docstring const tmpstr = cur.bv().contentsOfPlaintextFile(
- FileName(to_utf8(cmd.argument())));
- if (tmpstr.empty())
- break;
- cur.recordUndoInset(INSERT_UNDO);
- if (insertPlaintextString(cur.bv(), tmpstr, false)) {
- // content has been replaced,
- // so cursor might be invalid
- cur.pos() = cur.lastpos();
- cur.pit() = cur.lastpit();
- bvcur.setCursor(cur);
- } else
- cur.undispatched();
+ if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
+ docstring const tmpstr = cur.bv().contentsOfPlaintextFile(
+ FileName(to_utf8(cmd.argument())));
+ if (tmpstr.empty())
+ break;
+ cur.recordUndoInset(INSERT_UNDO);
+ if (insertPlaintextString(cur.bv(), tmpstr, false)) {
+ // content has been replaced,
+ // so cursor might be invalid
+ cur.pos() = cur.lastpos();
+ cur.pit() = cur.lastpit();
+ bvcur.setCursor(cur);
+ } else
+ cur.undispatched();
+ }
break;
- }
case LFUN_CUT:
if (cur.selIsMultiCell()) {
case LFUN_TEXTSTYLE_UPDATE:
case LFUN_FONT_SIZE:
case LFUN_FONT_UNDERLINE:
+ case LFUN_FONT_STRIKEOUT:
+ case LFUN_FONT_UULINE:
+ case LFUN_FONT_UWAVE:
case LFUN_LANGUAGE:
case LFUN_WORD_CAPITALIZE:
case LFUN_WORD_UPCASE:
cell(cur.idx())->dispatch(cur, cmd);
break;
}
+
+ case LFUN_INSET_SETTINGS:
+ // relay this lfun to Inset, not to the cell.
+ Inset::doDispatch(cur, cmd);
+ break;
+
default:
// we try to handle this event in the insets dispatch function.
cell(cur.idx())->dispatch(cur, cmd);
return true;
case Tabular::MULTICOLUMN:
- status.setEnabled(sel_row_start == sel_row_end);
+ // When a row is set as longtable caption, it must not be allowed
+ // to unset that this row is a multicolumn.
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.ltCaption(tabular.cellRow(cur.idx())));
status.setOnOff(tabular.isMultiColumn(cur.idx()));
break;
// every row can only be one thing:
// either a footer or header or caption
- case Tabular::SET_LTFIRSTHEAD:
+ case Tabular::SET_LTFIRSTHEAD:
status.setEnabled(sel_row_start == sel_row_end
&& !tabular.getRowOfLTHead(sel_row_start, dummyltt)
&& !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
status.setOnOff(tabular.getLTNewPage(sel_row_start));
break;
+ // only one row can be the caption
case Tabular::TOGGLE_LTCAPTION:
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));
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && (!tabular.haveLTCaption()
+ || tabular.ltCaption(sel_row_start)));
status.setOnOff(tabular.ltCaption(sel_row_start));
break;
}
return cell(cur.idx())->getStatus(cur, cmd, status);
+ case LFUN_INSET_SETTINGS:
+ // 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);
tabular.setLTNewPage(row, !tabular.getLTNewPage(row));
break;
- case Tabular::TOGGLE_LTCAPTION:
- cur.idx() = tabular.setLTCaption(row, !tabular.ltCaption(row));
+ case Tabular::TOGGLE_LTCAPTION: {
+ bool 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)
+ lyx::dispatch(FuncRequest(LFUN_CAPTION_INSERT));
break;
+ }
case Tabular::SET_BOOKTABS:
tabular.use_booktabs = true;