1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
18 #include "converter.h"
21 #include "minibuffer.h"
22 #include "bufferlist.h"
23 #include "support/filetools.h"
25 extern BufferList bufferlist;
26 extern void InsertAsciiFile(BufferView *, string const &, bool);
29 void Importer::Import(LyXView * lv, string const & filename,
30 string const & format)
32 string displaypath = MakeDisplayPath(filename);
33 lv->getMiniBuffer()->Set(_("Importing"), displaypath, "...");
35 string lyxfile = ChangeExtension(filename, ".lyx");
38 if (format == "text" || format == "textparagraph") {
39 lv->view()->buffer(bufferlist.newFile(lyxfile, string(), true));
40 bool as_paragraphs = format == "textparagraph";
41 InsertAsciiFile(lv->view(), filename, as_paragraphs);
42 lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF);
44 result = Converter::Convert(0, filename, filename, format, "lyx");
46 Buffer * buffer = bufferlist.loadLyXFile(lyxfile);
48 lv->view()->buffer(buffer);
56 lv->getMiniBuffer()->Set(displaypath, _("imported."));
58 lv->getMiniBuffer()->Set(displaypath, _(": import failed."));
63 bool Importer::IsImportable(string const & format)
65 if (format == "text" || format == "textparagraph")
68 return Converter::IsReachable(format, "lyx");