inset(new InsetTableCell(buf))
{
inset->setBuffer(const_cast<Buffer &>(buf));
- inset->paragraphs().back().setLayout(buf.params().documentClass().plainLayout());
}
}
// 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";
/////////////////////////////////////////////////////////////////////
InsetTableCell::InsetTableCell(Buffer & buf)
- : InsetText(buf), isFixedWidth(false),
+ : InsetText(buf, InsetText::PlainLayout), isFixedWidth(false),
contentAlign(LYX_ALIGN_CENTER)
{}
// 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()) {
cur.recordUndoInset(DELETE_UNDO);
cutSelection(cur);
}
- }
- else
+ } else
cell(cur.idx())->dispatch(cur, cmd);
break;
case LFUN_PASTE:
if (!tabularStackDirty()) {
- cell(cur.idx())->dispatch(cur, cmd);
+ if (!cur.selIsMultiCell())
+ cell(cur.idx())->dispatch(cur, cmd);
break;
}
if (theClipboard().isInternal() ||
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:
- // When a row is set as longtable caption, it must not be allowed
+ // If 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())));
// 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)
- && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
&& !tabular.ltCaption(sel_row_start));
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;
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;
case Tabular::SET_LTLASTFOOT:
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;
return true;
case LFUN_PASTE:
- if (cur.selIsMultiCell()) {
- status.setEnabled(false);
- status.message(_("You cannot paste into a multicell selection."));
- return true;
- }
if (tabularStackDirty() && theClipboard().isInternal()) {
- status.setEnabled(true);
+ if (cur.selIsMultiCell()) {
+ row_type rs, re;
+ col_type cs, ce;
+ getSelection(cur, rs, re, cs, ce);
+ if (paste_tabular && paste_tabular->column_info.size() == ce - cs + 1
+ && paste_tabular->row_info.size() == re - rs + 1)
+ status.setEnabled(true);
+ else {
+ status.setEnabled(false);
+ status.message(_("Selection size should match clipboard content."));
+ }
+ } else
+ status.setEnabled(true);
return true;
- }
+ }
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);
{
if (!paste_tabular)
return false;
- col_type const actcol = tabular.cellColumn(cur.idx());
- row_type const actrow = tabular.cellRow(cur.idx());
+ col_type actcol = tabular.cellColumn(cur.idx());
+ row_type actrow = tabular.cellRow(cur.idx());
+
+ if (cur.selIsMultiCell()) {
+ row_type re;
+ col_type ce;
+ getSelection(cur, actrow, re, actcol, ce);
+ }
+
for (row_type r1 = 0, r2 = actrow;
r1 < paste_tabular->row_info.size() && r2 < tabular.row_info.size();
++r1, ++r2) {
c1 < paste_tabular->column_info.size() && c2 < tabular.column_info.size();
++c1, ++c2) {
if (paste_tabular->isPartOfMultiColumn(r1, c1) &&
- tabular.isPartOfMultiColumn(r2, c2))
+ tabular.isPartOfMultiColumn(r2, c2))
continue;
if (paste_tabular->isPartOfMultiColumn(r1, c1)) {
--c2;