]> git.lyx.org Git - lyx.git/commitdiff
Use lyxconvert script for reading old files
authorDekel Tsur <dekelts@tau.ac.il>
Mon, 22 Jul 2002 17:11:41 +0000 (17:11 +0000)
committerDekel Tsur <dekelts@tau.ac.il>
Mon, 22 Jul 2002 17:11:41 +0000 (17:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4745 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/support/ChangeLog
src/support/filetools.C
src/support/filetools.h

index d44829cada44f5a2726ed4d4372e71e8deceac43..7ef6e4d0fb7f612d04e3d3ce36d5fa6ae9ab149c 100644 (file)
@@ -1,3 +1,8 @@
+2002-07-22  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * buffer.C (readFile): Run the lyxconvert script in order to read
+       old files.
+
 2002-07-22  John Levon  <moz@compsoc.man.ac.uk>
 
        * LyXAction.C:
index f43f74a7043d95098d7d4aca700ed597195cd118..87f38656cf19a046b87c49aae4b82dbb44059f17 100644 (file)
@@ -1713,10 +1713,22 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
                                                     "Use LyX 0.10.x to read this!"));
                                        return false;
                                } else if (file_format < 220) {
-                                       Alert::alert(_("ERROR!"),
-                                                    _("Old LyX file format found. "
-                                                      "Use LyX 1.2.x to read this!"));
-                                       return false;
+                                       //Alert::alert(_("Warning!"),
+                                       //           _("Old LyX file format found. "
+                                       //             "Running conversion script"));
+                                       string command = "lyxconvert "
+                                               + QuoteName(filename_);
+                                       cmd_ret const ret = RunCommand(command);
+                                       if (ret.first) {
+                                               Alert::alert(_("ERROR!"),
+                                                    _("An error occured while "
+                                                      "running the conversion script."));
+                                               return false;
+                                       }
+                                       istringstream is(ret.second);
+                                       LyXLex tmplex(0, 0);
+                                       tmplex.setStream(is);
+                                       return readFile(tmplex);
                                }
                        }
                        bool the_end = readLyXformat2(lex, par);
index 68ec1d4c67bacd482cc04d511516311c1c92adfb..7785c10a8decda328ef520a01dd51ad5d15fe457 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-22  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * filetools.C (RunCommand): Made public
+
 2002-07-22  John Levon  <moz@compsoc.man.ac.uk>
 
        * limited_stack.h: fix comment, remove un-needed header
index 11057b8ddde02c34616230a776306fab31a5a846..a63806850f68e3e797253bc730f61c6f404e14aa 100644 (file)
@@ -1286,11 +1286,7 @@ bool LyXReadLink(string const & file, string & link, bool resolve)
 }
 
 
-namespace {
-
-typedef pair<int, string> cmdret;
-
-cmdret const do_popen(string const & cmd)
+cmd_ret const RunCommand(string const & cmd)
 {
        // One question is if we should use popen or
        // create our own popen based on fork, exec, pipe
@@ -1314,8 +1310,6 @@ cmdret const do_popen(string const & cmd)
        return make_pair(pret, ret);
 }
 
-} // namespace anon
-
 
 string const findtexfile(string const & fil, string const & /*format*/)
 {
@@ -1355,7 +1349,7 @@ string const findtexfile(string const & fil, string const & /*format*/)
        // should help it by setting additional path in the approp. envir.var.
        string const kpsecmd = "kpsewhich " + fil;
 
-       cmdret const c = do_popen(kpsecmd);
+       cmd_ret const c = RunCommand(kpsecmd);
 
        lyxerr[Debug::LATEX] << "kpse status = " << c.first << "\n"
                 << "kpse result = `" << strip(c.second, '\n')
index bd15dfd3df6cb00172c08312a5b13a4f03020163..3815daa32c60d4395d61216af880a46d9a88843e 100644 (file)
@@ -12,6 +12,7 @@
 #endif
 
 #include <vector>
+#include <utility>
 #include "LString.h"
 
 
@@ -209,5 +210,8 @@ void removeAutosaveFile(string const & filename);
 /// read the BoundingBox entry from a ps/eps/pdf-file
 string const readBB_from_PSFile(string const & file);
 
+typedef std::pair<int, string> cmd_ret;
+
+cmd_ret const RunCommand(string const & cmd);
 
 #endif