- // check selected filename
- if (filename.empty()) {
- owner->getMiniBuffer()->Set(_("Canceled."));
- return;
- }
-
- // get absolute path of file
- filename = MakeAbsPath(filename);
-
- // Check if the document already is open
- string LyXfilename = ChangeExtension(filename, ".lyx", false);
- if (bufferlist.exists(LyXfilename)){
- switch(AskConfirmation(_("Document is already open:"),
- MakeDisplayPath(LyXfilename, 50),
- _("Do you want to close that document now?\n"
- "('No' will just switch to the open version)")))
- {
- case 1: // Yes: close the document
- if (!bufferlist.close(bufferlist.getBuffer(LyXfilename)))
- // If close is canceled, we cancel here too.
- return;
- break;
- case 2: // No: switch to the open document
- owner->view()->buffer(
- bufferlist.getBuffer(LyXfilename));
- return;
- case 3: // Cancel: Do nothing
- owner->getMiniBuffer()->Set(_("Canceled."));
- return;
- }
- }
-
- // Check if a LyX document by the same root exists in filesystem
- FileInfo f(LyXfilename, true);
- if (f.exist() && !AskQuestion(_("A document by the name"),
- MakeDisplayPath(LyXfilename),
- _("already exists. Overwrite?"))) {
- owner->getMiniBuffer()->Set(_("Canceled."));
- return;
- }
-
- // loads document
- Buffer * openbuf;
- if (!isnoweb) {
- owner->getMiniBuffer()->Set(_("Importing LaTeX file"),
- MakeDisplayPath(filename), "...");
- ImportLaTeX myImport(filename);
- openbuf = myImport.run();
- } else {
- owner->getMiniBuffer()->Set(_("Importing Noweb file"),
- MakeDisplayPath(filename), "...");
- ImportNoweb myImport(filename);
- openbuf = myImport.run();
- }
- if (openbuf) {
- owner->view()->buffer(openbuf);
- owner->getMiniBuffer()->Set(isnoweb ?
- _("Noweb file ") : _("LateX file "),
- MakeDisplayPath(filename),
- _("imported."));
- } else {
- owner->getMiniBuffer()->Set(isnoweb ?
- _("Could not import Noweb file") :
- _("Could not import LaTeX file"),
- MakeDisplayPath(filename));
- }
-}
-
-
-void LyXFunc::doImportLinuxDoc()
-{
- string initpath = lyxrc.document_path;
- LyXFileDlg fileDlg;
-
- if (owner->view()->available()) {
- string trypath = owner->buffer()->filepath;
- // If directory is writeable, use this as default.
- if (IsDirWriteable(trypath) == 1)
- initpath = trypath;