]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / CutAndPaste.cpp
index 1e9b74190d2e9aafa77dac0955b5c774f2abc3ec..a30f40040714e0bfbdbe4642bea3f03b661db4d1 100644 (file)
@@ -33,7 +33,6 @@
 #include "LyXRC.h"
 #include "Text.h"
 #include "Paragraph.h"
-#include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
 #include "ParIterator.h"
 #include "Undo.h"
@@ -164,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
@@ -430,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)
@@ -594,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(_(
@@ -941,9 +958,9 @@ void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs)
                return;
        cur.recordUndo();
        if (asParagraphs)
-               cur.text()->insertStringAsParagraphs(cur, text);
+               cur.text()->insertStringAsParagraphs(cur, text, cur.current_font);
        else
-               cur.text()->insertStringAsLines(cur, text);
+               cur.text()->insertStringAsLines(cur, text, cur.current_font);
 }
 
 
@@ -958,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);
@@ -1087,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");
                }