#include "Undo.h"
#include "insets/InsetFlex.h"
+#include "insets/InsetGraphics.h"
+#include "insets/InsetGraphicsParams.h"
#include "insets/InsetTabular.h"
#include "mathed/MathData.h"
using namespace std;
using namespace lyx::support;
+using lyx::frontend::Clipboard;
namespace lyx {
namespace {
-typedef std::pair<pit_type, int> PitPosPair;
+typedef pair<pit_type, int> PitPosPair;
typedef limited_stack<pair<ParagraphList, TextClassPtr> > CutStack;
c1 = p.col(i1.idx());
c2 = p.col(i2.idx());
if (c1 > c2)
- std::swap(c1, c2);
+ swap(c1, c2);
r1 = p.row(i1.idx());
r2 = p.row(i2.idx());
if (r1 > r2)
- std::swap(r1, r2);
+ swap(r1, r2);
}
buffer.setUnnamed(true);
buffer.paragraphs() = paragraphs;
buffer.params().setTextClass(textclass);
- std::ostringstream lyx;
+ ostringstream lyx;
if (buffer.write(lyx))
theClipboard().put(lyx.str(), plaintext);
else
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(
}
-std::vector<docstring> const availableSelections(Buffer const & buffer)
+vector<docstring> const availableSelections(Buffer const & buffer)
{
vector<docstring> selList;
}
-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()) {
}
+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())
// FIXME: What is wrong with the following?
#if 0
- std::ostringstream os;
+ ostringstream os;
for (DocIterator dit = cur.selectionBegin();
dit != cur.selectionEnd(); dit.forwardPos())
os << asString(dit.cell());