]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / CutAndPaste.cpp
index 1efca23341064d63d4f91d4294ed68194abbe0e8..a30f40040714e0bfbdbe4642bea3f03b661db4d1 100644 (file)
@@ -163,7 +163,7 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                }
        }
 
-       InsetText in(buffer);
+       InsetText in(cur.buffer());
        // Make sure there is no class difference.
        in.paragraphs().clear();
        // This works without copying any paragraph data because we have
@@ -429,6 +429,21 @@ void putClipboard(ParagraphList const & paragraphs,
 }
 
 
+/// return true if the whole ParagraphList is deleted
+static bool isFullyDeleted(ParagraphList const & pars)
+{
+       pit_type const pars_size = static_cast<pit_type>(pars.size());
+
+       // check all paragraphs
+       for (pit_type pit = 0; pit < pars_size; ++pit) {
+               if (!pars[pit].empty())   // prevent assertion failure
+                       if (!pars[pit].isDeleted(0, pars[pit].size()))
+                               return false;
+       }
+       return true;
+}
+
+
 void copySelectionHelper(Buffer const & buf, Text const & text,
        pit_type startpit, pit_type endpit,
        int start, int end, DocumentClass const * const dc, CutStack & cutstack)
@@ -593,7 +608,10 @@ void switchBetweenClasses(DocumentClass const * const oldone,
                if (it->lyxCode() != FLEX_CODE)
                        // FIXME: Should we verify all InsetCollapsable?
                        continue;
-               if (!it->undefined())
+               docstring const & n = newone->insetLayout(it->name()).name();
+               bool const is_undefined = n.empty() ||
+                       n == DocumentClass::plainInsetLayout().name();
+               if (!is_undefined)
                        continue;
                // The flex inset is undefined in newtc
                docstring const s = bformat(_(
@@ -957,7 +975,7 @@ void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */,
                return;
 
        // create inset for graphic
-       InsetGraphics * inset = new InsetGraphics(*cur.buffer());
+       InsetGraphics * inset = new InsetGraphics(cur.buffer());
        InsetGraphicsParams params;
        params.filename = support::DocFileName(filename.absFilename());
        inset->setParams(params);
@@ -1086,7 +1104,8 @@ docstring grabSelection(Cursor const & cur)
        if (i1.idx() == i2.idx()) {
                if (i1.inset().asInsetMath()) {
                        MathData::const_iterator it = i1.cell().begin();
-                       return asString(MathData(it + i1.pos(), it + i2.pos()));
+                       Buffer * buf = cur.buffer();
+                       return asString(MathData(buf, it + i1.pos(), it + i2.pos()));
                } else {
                        return from_ascii("unknown selection 1");
                }