]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
compil fix for Qt-4.2
[lyx.git] / src / CutAndPaste.cpp
index d470a294f9cc3b83ae3dcb0168c5045032c0f4d0..63f25267adbe5bfccf098a4a3aead7c4c1d413ee 100644 (file)
@@ -38,6 +38,8 @@
 #include "Undo.h"
 
 #include "insets/InsetFlex.h"
+#include "insets/InsetGraphics.h"
+#include "insets/InsetGraphicsParams.h"
 #include "insets/InsetTabular.h"
 
 #include "mathed/MathData.h"
@@ -60,6 +62,7 @@
 
 using namespace std;
 using namespace lyx::support;
+using lyx::frontend::Clipboard;
 
 namespace lyx {
 
@@ -442,17 +445,15 @@ void switchBetweenClasses(TextClassPtr const & c1,
                if (inset->lyxCode() != FLEX_CODE)
                        // FIXME: Should we verify all InsetCollapsable?
                        continue;
-               docstring const name = inset->name();
-               InsetLayout const & il = tclass2.insetlayout(name);
-               inset->setLayout(il);
-               if (il.labelstring != from_utf8("UNDEFINED"))
+               inset->setLayout(c2);
+               if (inset->getLayout().labelstring != from_utf8("UNDEFINED"))
                        continue;
                // The flex inset is undefined in tclass2
                docstring const s = bformat(_(
                        "Flex inset %1$s is "
                        "undefined because of class "
                        "conversion from\n%2$s to %3$s"),
-                       name, from_utf8(tclass1.name()),
+                       inset->name(), from_utf8(tclass1.name()),
                        from_utf8(tclass2.name()));
                // To warn the user that something had to be done.
                errorlist.push_back(ErrorItem(
@@ -734,7 +735,7 @@ void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index)
 }
 
 
-void pasteClipboard(Cursor & cur, ErrorList & errorList, bool asParagraphs)
+void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs)
 {
        // Use internal clipboard if it is the most recent one
        if (theClipboard().isInternal()) {
@@ -772,6 +773,26 @@ void pasteClipboard(Cursor & cur, ErrorList & errorList, bool asParagraphs)
 }
 
 
+void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
+                           Clipboard::GraphicsType preferedType)
+{
+       BOOST_ASSERT(theClipboard().hasGraphicsContents(preferedType));
+
+       // get picture from clipboard
+       FileName filename = theClipboard().getAsGraphics(cur, preferedType);
+       if (filename.empty())
+               return;
+
+       // create inset for graphic
+       InsetGraphics * inset = new InsetGraphics;
+       InsetGraphicsParams params;
+       params.filename = EmbeddedFile(filename.absFilename(), cur.buffer().filePath());
+       inset->setParams(params);
+       cur.recordUndo();
+       cur.insert(inset);
+}
+
+
 void pasteSelection(Cursor & cur, ErrorList & errorList)
 {
        if (selectionBuffer.empty())