X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetTabular.cpp;h=9df7d463c3832dde51d9d04e4bd87868c4b9a12a;hb=ebc2b1295a0464dde6c20a09ddc249c463a21c79;hp=82c93935de7b466205c51c92040ad642b104718d;hpb=bf5d5e5d66610865cc1c887c001066d1a0a4d06e;p=lyx.git diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 82c93935de..9df7d463c3 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -137,10 +137,10 @@ TabularFeature tabularFeature[] = { Tabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom", false }, { Tabular::TOGGLE_LINE_LEFT, "toggle-line-left", false }, { Tabular::TOGGLE_LINE_RIGHT, "toggle-line-right", false }, - { Tabular::TOGGLE_LTRIM_TOP, "toggle-ltrim-top", true }, - { Tabular::TOGGLE_LTRIM_BOTTOM, "toggle-ltrim-bottom", true }, - { Tabular::TOGGLE_RTRIM_TOP, "toggle-rtrim-top", true }, - { Tabular::TOGGLE_RTRIM_BOTTOM, "toggle-rtrim-bottom", true }, + { Tabular::TOGGLE_LTRIM_TOP, "toggle-ltrim-top", false }, + { Tabular::TOGGLE_LTRIM_BOTTOM, "toggle-ltrim-bottom", false }, + { Tabular::TOGGLE_RTRIM_TOP, "toggle-rtrim-top", false }, + { Tabular::TOGGLE_RTRIM_BOTTOM, "toggle-rtrim-bottom", false }, { Tabular::ALIGN_LEFT, "align-left", false }, { Tabular::ALIGN_RIGHT, "align-right", false }, { Tabular::ALIGN_CENTER, "align-center", false }, @@ -4982,6 +4982,18 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_PASTE: if (!tabularStackDirty()) { + // Check if we have plain text or HTML with rows/columns. + // and if so, pass over to LFUN_CLIPBOARD_PASTE + if (theClipboard().hasTextContents(Clipboard::AnyTextType) + && !theClipboard().hasTextContents(Clipboard::LyXTextType)) { + docstring const clip = + theClipboard().getAsText(Clipboard::AnyTextType); + if (clip.find_first_of(from_ascii("\t\n")) != docstring::npos) { + FuncRequest ncmd = FuncRequest(LFUN_CLIPBOARD_PASTE, cmd.argument()); + doDispatch(cur, ncmd); + break; + } + } if (!cur.selIsMultiCell()) cell(cur.idx())->dispatch(cur, cmd); break; @@ -5572,6 +5584,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, // disable these with multiple cells selected case LFUN_INSET_INSERT: case LFUN_TABULAR_INSERT: + case LFUN_TABULAR_STYLE_INSERT: case LFUN_FLEX_INSERT: case LFUN_FLOAT_INSERT: case LFUN_FLOAT_WIDE_INSERT: @@ -6984,20 +6997,26 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, } size_t op = 0; - idx_type const cells = loctab->numberofcells; + idx_type cells = loctab->numberofcells; p = 0; cols = ocol; rows = loctab->nrows(); - col_type const columns = loctab->ncols(); + col_type columns = loctab->ncols(); - while (cell < cells && p < len && row < rows && + while (p < len && (p = buf.find_first_of(from_ascii("\t\n"), p)) != docstring::npos) { if (p >= len) break; switch (buf[p]) { case '\t': - // we can only set this if we are not too far right + // append column if necessary + if (cols == columns) { + loctab->appendColumn(cols - 1); + columns = loctab->ncols(); + cells = loctab->numberofcells; + ++cell; + } if (cols < columns) { shared_ptr inset = loctab->cellInset(cell); Font const font = bv.textMetrics(&inset->text()). @@ -7019,6 +7038,12 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, } cols = ocol; ++row; + // append row if necessary + if (row == rows && p < len - 1) { + loctab->appendRow(row - 1); + rows = loctab->nrows(); + cells = loctab->numberofcells; + } if (row < rows) cell = loctab->cellIndex(row, cols); break;