X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCutAndPaste.C;h=e554ac6311098839dcff14ca605c8e4445001370;hb=52eb91c94fb70d58dceef430659c8781de2eccda;hp=ac539c07d743823a3c50f0015b866413ff2891b3;hpb=bc13b0e09569bbf77842ed72d88c0f214a8f66b5;p=lyx.git diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index ac539c07d7..e554ac6311 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -33,7 +33,6 @@ #include "paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" -#include "ParagraphList_fwd.h" #include "pariterator.h" #include "undo.h" @@ -49,6 +48,7 @@ #include "frontends/Clipboard.h" #include "frontends/Selection.h" +#include #include #include @@ -331,7 +331,9 @@ PitPosPair eraseSelectionHelper(BufferParams const & params, void putClipboard(ParagraphList const & paragraphs, textclass_type textclass, docstring const & plaintext) { - Buffer buffer(string(), false); + // For some strange reason gcc 3.2 and 3.3 do not accept + // Buffer buffer(string(), false); + Buffer buffer("", false); buffer.setUnnamed(true); buffer.paragraphs() = paragraphs; buffer.params().textclass = textclass; @@ -546,16 +548,17 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut) cur.selBegin().pos(), endpos, doclear); - // sometimes necessary - if (doclear) - text->paragraphs()[begpit].stripLeadingSpaces(bp.trackChanges); - // cutSelection can invalidate the cursor so we need to set // it anew. (Lgb) // we prefer the end for when tracking changes cur.pos() = endpos; cur.pit() = endpit; + // sometimes necessary + if (doclear + && text->paragraphs()[begpit].stripLeadingSpaces(bp.trackChanges)) + cur.fixIfBroken(); + // need a valid cursor. (Lgb) cur.clearSelection(); updateLabels(cur.buffer()); @@ -606,9 +609,9 @@ void copySelectionToStack(LCursor & cur, CutStack & cutstack) ParagraphList & pars = text->paragraphs(); pos_type pos = cur.selBegin().pos(); pit_type par = cur.selBegin().pit(); - while (pos < pars[par].size() - && pars[par].isLineSeparator(pos) - && (par != cur.selEnd().pit() || pos < cur.selEnd().pos())) + while (pos < pars[par].size() && + pars[par].isLineSeparator(pos) && + (par != cur.selEnd().pit() || pos < cur.selEnd().pos())) ++pos; copySelectionHelper(cur.buffer(), pars, par, cur.selEnd().pit(), @@ -639,7 +642,20 @@ void copySelectionToStack() void copySelection(LCursor & cur, docstring const & plaintext) { - copySelectionToStack(cur, theCuts); + // In tablemode, because copy and paste actually use special table stack + // we do not attemp to get selected paragraphs under cursor. Instead, a + // paragraph with the plain text version is generated so that table cells + // can be pasted as pure text somewhere else. + if (cur.selBegin().idx() != cur.selEnd().idx()) { + ParagraphList pars; + Paragraph par; + BufferParams const & bp = cur.buffer().params(); + par.layout(bp.getLyXTextClass().defaultLayout()); + par.insert(0, plaintext, LyXFont(), Change(Change::UNCHANGED)); + pars.push_back(par); + theCuts.push(make_pair(pars, bp.textclass)); + } else + copySelectionToStack(cur, theCuts); // stuff the selection onto the X clipboard, from an explicit copy request putClipboard(theCuts[0].first, theCuts[0].second, plaintext); @@ -648,8 +664,10 @@ void copySelection(LCursor & cur, docstring const & plaintext) void saveSelection(LCursor & cur) { - lyxerr[Debug::ACTION] << "cap::saveSelection: `" - << to_utf8(cur.selectionAsString(true)) << "'." << endl; + if (lyxerr.debugging(Debug::ACTION)) + lyxerr << BOOST_CURRENT_FUNCTION << ": `" + << to_utf8(cur.selectionAsString(true)) << "'." + << endl; if (cur.selection()) copySelectionToStack(cur, selectionBuffer); @@ -719,7 +737,7 @@ void pasteClipboard(LCursor & cur, ErrorList & errorList, bool asParagraphs) { // Use internal clipboard if it is the most recent one if (theClipboard().isInternal()) { - pasteClipboard(cur, errorList, 0); + pasteFromStack(cur, errorList, 0); return; } @@ -727,7 +745,9 @@ void pasteClipboard(LCursor & cur, ErrorList & errorList, bool asParagraphs) if (theClipboard().hasLyXContents()) { string lyx = theClipboard().getAsLyX(); if (!lyx.empty()) { - Buffer buffer(string(), false); + // For some strange reason gcc 3.2 and 3.3 do not accept + // Buffer buffer(string(), false); + Buffer buffer("", false); buffer.setUnnamed(true); if (buffer.readString(lyx)) { recordUndo(cur);