+
+bool import(LyXView * lv, FileName const & filename,
+ string const & format, ErrorList & errorList)
+{
+ docstring const displaypath = makeDisplayPath(filename.absFilename());
+ lv->message(bformat(_("Importing %1$s..."), displaypath));
+
+ FileName const lyxfile(changeExtension(filename.absFilename(), ".lyx"));
+
+ string loader_format;
+ vector<string> loaders = theConverters().loaders();
+ if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
+ for (vector<string>::const_iterator it = loaders.begin();
+ it != loaders.end(); ++it) {
+ if (theConverters().isReachable(format, *it)) {
+ string const tofile =
+ changeExtension(filename.absFilename(),
+ formats.extension(*it));
+ if (!theConverters().convert(0, filename, FileName(tofile),
+ filename, format, *it, errorList))
+ return false;
+ loader_format = *it;
+ break;
+ }
+ }
+ if (loader_format.empty()) {
+ frontend::Alert::error(_("Couldn't import file"),
+ bformat(_("No information for importing the format %1$s."),
+ formats.prettyName(format)));
+ return false;
+ }
+ } else {
+ loader_format = format;
+ }
+
+
+ if (loader_format == "lyx") {
+ Buffer * buf = theLyXFunc().loadAndViewFile(lyxfile);
+ if (!buf) {
+ // we are done
+ lv->message(_("file not imported!"));
+ return false;
+ }
+ updateLabels(*buf);
+ lv->setBuffer(buf);
+ lv->errors("Parse");
+ } else {
+ Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
+ if (b)
+ lv->setBuffer(b);
+ else
+ return false;
+ bool as_paragraphs = loader_format == "textparagraph";
+ string filename2 = (loader_format == format) ? filename.absFilename()
+ : changeExtension(filename.absFilename(),
+ formats.extension(loader_format));
+ lv->view()->insertPlaintextFile(filename2, as_paragraphs);
+ lv->dispatch(FuncRequest(LFUN_MARK_OFF));
+ }
+
+ // we are done
+ lv->message(_("imported."));
+ return true;
+}
+
+
+
+// This function runs "configure" and then rereads lyx.defaults to
+// reconfigure the automatic settings.
+void reconfigure(LyXView & lv, string const & option)
+{
+ // emit message signal.
+ lv.message(_("Running configure..."));
+
+ // Run configure in user lyx directory
+ support::PathChanger p(package().user_support());
+ string configure_command = package().configure_command();
+ configure_command += option;
+ Systemcall one;
+ int ret = one.startscript(Systemcall::Wait, configure_command);
+ p.pop();
+ // emit message signal.
+ lv.message(_("Reloading configuration..."));
+ lyxrc.read(support::libFileSearch(string(), "lyxrc.defaults"));
+ // Re-read packages.lst
+ LaTeXFeatures::getAvailable();
+
+ if (ret)
+ Alert::information(_("System reconfiguration failed"),
+ _("The system reconfiguration has failed.\n"
+ "Default textclass is used but LyX may "
+ "not be able to work properly.\n"
+ "Please reconfigure again if needed."));
+ else
+
+ Alert::information(_("System reconfigured"),
+ _("The system has been reconfigured.\n"
+ "You need to restart LyX to make use of any\n"
+ "updated document class specifications."));
+}
+
+
+bool getLocalStatus(Cursor cursor, FuncRequest const & cmd, FuncStatus & status)