]> git.lyx.org Git - features.git/commitdiff
Export patch from Dekel
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 11 Sep 2000 15:42:17 +0000 (15:42 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 11 Sep 2000 15:42:17 +0000 (15:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1009 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
ChangeLog
lib/bind/cua.bind
lib/bind/de_menus.bind
lib/bind/emacs.bind
lib/bind/fi_menus.bind
lib/bind/fr_menus.bind
lib/bind/hu_menus.bind
lib/bind/menus.bind
lib/bind/pt_menus.bind
lib/bind/sciword.bind
lib/bind/sv_menus.bind
lib/bind/xemacs.bind
lib/configure
lib/configure.m4
src/converter.C
src/converter.h
src/exporter.C
src/exporter.h
src/frontends/Liason.C
src/frontends/xforms/GUIRunTime.C
src/lyx_main.C
src/support/filetools.C

index 60c8ade7053f6dc34282ab97049dda054eb960fd..2c5b47c8db82504389b19a001e26c719f87a08a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2000-09-11  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/frontends/xforms/GUIRunTime.C (initApplication): use lyxerr,
+       not cerr.
+
+2000-09-09  Dekel Tsur  <dekel@math.tau.ac.il>
+
+       * src/converter.C (Add, Convert): Added support for converter flags:
+       needaux, resultdir, resultfile.
+       (Convert): Added new parameter view_file.
+       (dvips_options): Fixed letter paper option.
+
+       * src/exporter.C (Export, BufferExtension): Added support for Docbook.
+       (Export, GetExportableFormats, GetViewableFormats): Added support
+       for Ascii.
+
+       * src/lyx_main.C (LyX): Call to QuitLyX() to remove temporary
+       directory!
+       (easyParse): Fixed to work with new export code.
+       
+       * src/support/filetools.C (DeleteAllFilesInDir) Fixed to delete
+       directories.
+
+       * lyx-devel-export/lib/configure.m4: Changed flags of tth.
+
+       * lib/bind/*.bind: Replaced
+       buffer-view,buffer-view-ps,buffer-typeset,buffer-typeset-ps by
+       buffer-view dvi,buffer-view ps,buffer-update dvi,buffer-update ps
+
 2000-09-11  Juergen Vigna  <jug@sad.it>
 
        * src/lyx_gui.C (runTime): uses global guiruntime variable.
index c691c7cd985458cd86794950d55104ddc929dc22..b7f493eaa33ef95a2bb6a09c5ddb900f758f45a1 100644 (file)
 \bind "C-s"                    "buffer-write"
 \bind "C-S-S"                  "buffer-write-as"
 \bind "C-p"                    "buffer-print" 
-\bind "C-d"                    "buffer-view"           # 'd' for dvi
-\bind "C-t"                    "buffer-view-ps"
-\bind "C-S-D"                  "buffer-typeset"        # 'd' for dvi
-\bind "C-S-T"                  "buffer-typeset-ps"
+\bind "C-d"                    "buffer-view dvi"       # 'd' for dvi
+\bind "C-t"                    "buffer-view ps"
+\bind "C-S-D"                  "buffer-update dvi"     # 'd' for dvi
+\bind "C-S-T"                  "buffer-update ps"
 \bind "C-q"                    "lyx-quit"
 
 \bind "C-b"                    "font-bold"
index 684b9989515aa0a314781d2a728aa48b1928402b..bda956b99be8c2611da7590eadadd78f0057382e 100644 (file)
 \bind "M-d s"                  "buffer-write"
 \bind "M-d u"                  "buffer-write-as"
 \bind "M-d w"                  "buffer-reload"
-\bind "M-d a"                  "buffer-view"
-\bind "M-d p"                  "buffer-view-ps"
-\bind "M-d i"                  "buffer-typeset"
-\bind "M-d k"                  "buffer-typeset-ps"
+\bind "M-d a"                  "buffer-view dvi"
+\bind "M-d p"                  "buffer-view ps"
+\bind "M-d i"                  "buffer-update dvi"
+\bind "M-d k"                  "buffer-update ps"
 \bind "M-d r"                   "build-program"
 \bind "M-d d"                  "buffer-print" 
 \bind "M-d f"                  "buffer-fax"
index 1cfc1808a6bffc5cc48a3b6f79e6eafcb545c6f6..4359b270c8fb9153877d697281ec71169111b687 100644 (file)
 \bind "C-x a"                  "buffer-auto-save"
 #\bind "C-x b"                 "buffer-previous"
 \bind "C-x d"                  "buffer-new"
-\bind "C-x g"                  "buffer-view-ps"
+\bind "C-x g"                  "buffer-view ps"
 \bind "C-x k"                  "buffer-close"
-\bind "C-x p"                  "buffer-view"
-\bind "C-x r"                  "buffer-typeset"
+\bind "C-x p"                  "buffer-view dvi"
+\bind "C-x r"                  "buffer-update dvi"
 # Should have been "buffer-write-some"
 # \bind "C-x s"                  "buffer-write"
-\bind "C-x t"                  "buffer-typeset"
+\bind "C-x t"                  "buffer-update dvi"
 \bind "C-x u"                  "undo"
 \bind "C-x v h"                "vc-history"
 \bind "C-x v v"                "vc-check-in"
 \bind "C-x C-c"                "lyx-quit"
 \bind "C-x C-d"                "buffer-new"
 \bind "C-x C-f"                "buffer-open"
-\bind "C-x C-g"                "buffer-view-ps"
-\bind "C-x C-p"                "buffer-view"
+\bind "C-x C-g"                "buffer-view ps"
+\bind "C-x C-p"                "buffer-view dvi"
 \bind "C-x C-q"                "buffer-toggle-read-only"
-#\bind "C-x C-r"                "buffer-typeset"
+#\bind "C-x C-r"                "buffer-update dvi"
 \bind "C-x C-s"                "buffer-write"
-\bind "C-x C-t"                "buffer-typeset"
+\bind "C-x C-t"                "buffer-update dvi"
 
 
 # this is "upcase-region" in emacs
index 912e324f404205d0c6e2afd8e8fec55fc8bdb3b3..03c257047b0f27b973fd6bc187717c2c86b25a5c 100644 (file)
 \bind "M-t t"                  "buffer-write"
 \bind "M-t n"                  "buffer-write-as"
 \bind "M-t h"                  "buffer-reload"
-\bind "M-t d"                  "buffer-view"
-\bind "M-t c"                  "buffer-view-ps"
-\bind "M-t v"                  "buffer-typeset"
-\bind "M-t i"                  "buffer-typeset-ps"
+\bind "M-t d"                  "buffer-view dvi"
+\bind "M-t c"                  "buffer-view ps"
+\bind "M-t v"                  "buffer-update dvi"
+\bind "M-t i"                  "buffer-update ps"
 \bind "M-t l"                  "buffer-print" 
 \bind "M-t f"                  "buffer-fax"
 \bind "M-t o l"                 "buffer-import latex"
index 352f04aeeb1be09a9db95b877a0a4638344ae3ff..dcd1a0f024e29c7d1d8b8930f7bed00d09289399 100644 (file)
 \bind "M-f e"                  "buffer-write"          #Enregistrer
 \bind "M-f s"                  "buffer-write-as"       #Enregistrer Sous
 \bind "M-f r"                  "buffer-reload"         #Recharger
-\bind "M-f S-D"                        "buffer-view"           #Visualiser DVI
-\bind "M-f S-P"                        "buffer-view-ps"        #Visualiser Postscript
-\bind "M-f d"                  "buffer-typeset"        #Mise à jour dvi
-\bind "M-f p"                  "buffer-typeset-ps"     #Mise à jour Postscript
+\bind "M-f S-D"                        "buffer-view dvi"       #Visualiser DVI
+\bind "M-f S-P"                        "buffer-view ps"        #Visualiser Postscript
+\bind "M-f d"                  "buffer-update dvi"     #Mise à jour dvi
+\bind "M-f p"                  "buffer-update ps"      #Mise à jour Postscript
 \bind "M-f c"                  "build-program"         #Compiler programme
 \bind "M-f i"                  "buffer-print"          #Imprimer
 \bind "M-f v"                  "buffer-fax"            #Fax
index f7e63eb16195d29ee18716774414cb16f968a844..bdbbb7e1d8d4e48f14159842e3094ac90341bdc3 100644 (file)
 \bind "M-f m"                  "buffer-write"
 \bind "M-f t"                  "buffer-write-as"
 \bind "M-f i"                  "buffer-reload"
-\bind "M-f d"                  "buffer-view"
-\bind "M-f p"                  "buffer-view-ps"
-\bind "M-f v"                  "buffer-typeset"
-\bind "M-f o"                  "buffer-typeset-ps"
+\bind "M-f d"                  "buffer-view dvi"
+\bind "M-f p"                  "buffer-view ps"
+\bind "M-f v"                  "buffer-update dvi"
+\bind "M-f o"                  "buffer-update ps"
 \bind "M-f y"                  "buffer-print" 
 \bind "M-f f"                  "buffer-fax"
 \bind "M-f l"                  "buffer-export latex"
index 69aa6e781ffb920b701a01ef4c59d1134e300e4c..07d7a1c390866c958ec0e2e7cd02e8f40ae9dc25 100644 (file)
 \bind "M-f s"                  "buffer-write"
 \bind "M-f a"                  "buffer-write-as"
 \bind "M-f r"                  "buffer-reload"
-\bind "M-f d"                  "buffer-view"
-\bind "M-f w"                  "buffer-view-ps"
-\bind "M-f v"                  "buffer-typeset"
-\bind "M-f u"                  "buffer-typeset-ps"
+\bind "M-f d"                  "buffer-view dvi"
+\bind "M-f w"                  "buffer-view ps"
+\bind "M-f v"                  "buffer-update dvi"
+\bind "M-f u"                  "buffer-update ps"
 \bind "M-f p"                  "buffer-print" 
 \bind "M-f f"                  "buffer-fax"
 \bind "M-f i l"                 "buffer-import latex"
index 6b04f6b6574150919b0611c1ecbf803a210103df..179091711c793df19c34787a776e420ab4f0da29 100644 (file)
 \bind "M-a l"                  "buffer-write"
 \bind "M-a c"                  "buffer-write-as"
 \bind "M-a r"                  "buffer-reload"
-\bind "M-a d"                  "buffer-view"
-\bind "M-a o"                  "buffer-view-ps"
-\bind "M-a v"                  "buffer-typeset"
-\bind "M-a z"                  "buffer-typeset-ps"
+\bind "M-a d"                  "buffer-view dvi"
+\bind "M-a o"                  "buffer-view ps"
+\bind "M-a v"                  "buffer-update dvi"
+\bind "M-a z"                  "buffer-update ps"
 \bind "M-a p"                  "buffer-print" 
 \bind "M-a x"                  "buffer-fax"
 \bind "M-a i l"                 "buffer-import latex"
index ed1513631eaf35c2ccb3cb17f7e440b48af98e5c..577d71d7697c730ad6f5d2872ccf0c38adaafbb6 100644 (file)
 \bind "M-f o"                  "buffer-open"
 \bind "M-f p"                  "buffer-print"
 \bind "M-f q"                  "lyx-quit"
-\bind "M-f r"                  "buffer-typeset"
+\bind "M-f r"                  "buffer-update dvi"
         # Obsolete
 \bind "M-f s"                  "buffer-write"
-\bind "M-f t"                  "buffer-typeset"
+\bind "M-f t"                  "buffer-update dvi"
 
-\bind "M-f x"                  "buffer-view"
-\bind "M-f g"                  "buffer-view-ps"
+\bind "M-f x"                  "buffer-view dvi"
+\bind "M-f g"                  "buffer-view ps"
 \bind "M-f space"              "menu-open File"
 
 
index 91d97db4976514185ba349767ae7f3a92a72e3f1..165613617f84c89ca955589291dfcae604744085 100644 (file)
 \bind "M-f s"                  "buffer-write"
 \bind "M-f o"                  "buffer-write-as"
 \bind "M-f t"                  "buffer-reload"
-\bind "M-f v"                  "buffer-view"
-\bind "M-f i"                  "buffer-view-ps"
-\bind "M-f u"                  "buffer-typeset"
-\bind "M-f d"                  "buffer-typeset-ps"
+\bind "M-f v"                  "buffer-view dvi"
+\bind "M-f i"                  "buffer-view ps"
+\bind "M-f u"                  "buffer-update dvi"
+\bind "M-f d"                  "buffer-update ps"
 \bind "M-f k"                  "buffer-print" 
 \bind "M-f f"                  "buffer-fax"
 \bind "M-f l"                  "buffer-export latex"
index a7f9bcc121a11d3237081833254e68db4480193e..13acaf88166d46b53a4345780e9284bc75a2621b 100644 (file)
 # not currently supported
 #\bind "C-x b"                 "buffer-previous"
 \bind "C-x d"                  "buffer-new"
-\bind "C-x g"                  "buffer-view-ps"
+\bind "C-x g"                  "buffer-view ps"
 \bind "C-x k"                  "buffer-close"
-\bind "C-x p"                  "buffer-view"
-\bind "C-x r"                  "buffer-typeset"
+\bind "C-x p"                  "buffer-view dvi"
+\bind "C-x r"                  "buffer-update dvi"
 # Should have been "buffer-write-some"
 # \bind "C-x s"                  "buffer-write"
-\bind "C-x t"                  "buffer-typeset"
+\bind "C-x t"                  "buffer-update dvi"
 \bind "C-x u"                  "undo"
 \bind "C-x v h"                "vc-history"
 \bind "C-x v v"                "vc-check-in"
 \bind "C-x C-c"                "lyx-quit"
 \bind "C-x C-d"                "buffer-new"
 \bind "C-x C-f"                "buffer-open"
-\bind "C-x C-g"                "buffer-view-ps"
+\bind "C-x C-g"                "buffer-view ps"
 \bind "C-x C-l"                        "word-lowcase"          # downcase-region!
-\bind "C-x C-p"                "buffer-view"
+\bind "C-x C-p"                "buffer-view dvi"
 \bind "C-x C-q"                "buffer-toggle-read-only"
-#\bind "C-x C-r"                "buffer-typeset"
+#\bind "C-x C-r"                "buffer-update dvi"
 \bind "C-x C-s"                "buffer-write"
-\bind "C-x C-t"                "buffer-typeset"
+\bind "C-x C-t"                "buffer-update dvi"
 \bind "C-x C-u"                        "word-upcase"           # upcase-region!
 \bind "C-x C-w"                "buffer-write-as"
 
 #
 ## Start TeX mode, some overlap with AucTeX mode
 #
-\bind "C-c C-b"                        "buffer-typeset"
+\bind "C-c C-b"                        "buffer-update dvi"
 \bind "C-c C-p"                        "buffer-print"
-\bind "C-c C-r"                        "buffer-typeset"        # tex region
+\bind "C-c C-r"                        "buffer-update dvi"     # tex region
 #
 ## End TeX mode
 #
index 8c8081660bc6ce22c327b840d8fb5f48c68b09fb..a0becb63fd82e5738b748a3ab8c05f0ccbee4318 100755 (executable)
@@ -857,7 +857,7 @@ fi
 
 latex_to_html_command = $TOHTML
 case $TOHTML in
-       tth) latex_to_html_command="tth -t < \$\$FName > \$\$OutName";;
+       tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
       hevea) latex_to_html_command="hevea -s \$\$FName";;
 esac
@@ -945,15 +945,16 @@ cat >lyxrc.defaults <<EOF
 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
 # override the values given here.
-\\converter tex dvi "$LATEX" noflags
-\\converter tex pdf "$PDFLATEX" noflags
-\\converter dvi ps "$dvi_to_ps_command" noflags
-\\converter ps pdf "$ps_to_pdf_command" noflags
-\\converter sgml tex "$linuxdoc_to_latex_command" noflags
-\\converter sgml html "$linuxdoc_to_html_command" noflags
-\\converter docbook dvi "$docbook_to_dvi_command" noflags
-\\converter docbook html "$docbook_to_html_command" noflags
-\\converter tex html "$latex_to_html_command" noflags
+\\converter tex dvi "$LATEX" ""
+\\converter tex pdf "$PDFLATEX" ""
+\\converter dvi ps "$dvi_to_ps_command" ""
+\\converter ps pdf "$ps_to_pdf_command" ""
+\\converter sgml tex "$linuxdoc_to_latex_command" ""
+\\converter sgml html "$linuxdoc_to_html_command" ""
+\\converter docbook dvi "$docbook_to_dvi_command" ""
+\\converter docbook html "$docbook_to_html_command" ""
+\\converter tex html "$latex_to_html_command"
+       originaldir
 
 \\viewer dvi "$DVI_VIEWER"
 \\viewer html "$HTML_VIEWER"
index 4874a815a144d605aedeabc721ee9b6c2079a896..95110a0519d42a2a41b4a51288481504e9c127f6 100644 (file)
@@ -291,7 +291,7 @@ esac
 SEARCH_PROG([for an HTML converter], TOHTML, tth latex2html hevea)
 latex_to_html_command = $TOHTML
 case $TOHTML in
-       tth) latex_to_html_command="tth -t < \$\$FName > \$\$OutName";;
+       tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
       hevea) latex_to_html_command="hevea -s \$\$FName";;
 esac
@@ -367,15 +367,16 @@ cat >lyxrc.defaults <<EOF
 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
 # override the values given here.
-\\converter tex dvi "$LATEX" noflags
-\\converter tex pdf "$PDFLATEX" noflags
-\\converter dvi ps "$dvi_to_ps_command" noflags
-\\converter ps pdf "$ps_to_pdf_command" noflags
-\\converter sgml tex "$linuxdoc_to_latex_command" noflags
-\\converter sgml html "$linuxdoc_to_html_command" noflags
-\\converter docbook dvi "$docbook_to_dvi_command" noflags
-\\converter docbook html "$docbook_to_html_command" noflags
-\\converter tex html "$latex_to_html_command" noflags
+\\converter tex dvi "$LATEX" ""
+\\converter tex pdf "$PDFLATEX" ""
+\\converter dvi ps "$dvi_to_ps_command" ""
+\\converter ps pdf "$ps_to_pdf_command" ""
+\\converter sgml tex "$linuxdoc_to_latex_command" ""
+\\converter sgml html "$linuxdoc_to_html_command" ""
+\\converter docbook dvi "$docbook_to_dvi_command" ""
+\\converter docbook html "$docbook_to_html_command" ""
+\\converter tex html "$latex_to_html_command"
+       "originaldir,needaux"
 
 \\viewer dvi "$DVI_VIEWER"
 \\viewer html "$HTML_VIEWER"
index 2601feab985de19bd6c297943422cb7bf76dcda3..860d6c2ae657526d8c2421f39ce3f0e45ff5ab15 100644 (file)
@@ -40,6 +40,7 @@ using std::endl;
 
 map<string, Format> Formats::formats;
 vector<Command> Converter::commands;
+string Converter::latex_command;
 
 inline
 string add_options(string const & command, string const & options)
@@ -98,6 +99,9 @@ void Formats::SetViewer(string const & name, string const & command)
 
 bool Formats::View(Buffer * buffer, string const & filename)
 {
+       if (filename.empty())
+               return false;
+
        string extension = GetExtension(filename);
        Format * format = GetFormat(extension);
        if (!format || format->viewer.empty()) {
@@ -167,19 +171,43 @@ void Converter::Add(string const & from, string const & to,
        if (command == "none")
                return;
 
-       bool original_dir = flags == "origdir";
        string command2 = 
                   subst(command, "$$FName", "'$$FName'");
        command2 = subst(command2, "$$BaseName", "'$$BaseName'");
        command2 = subst(command2, "$$OutName", "'$$OutName'");
+       Command Com(from, to, command2);
+
+       if (from == "tex" &&
+           (to == "dvi" ||
+            (to == "pdf" && latex_command.empty())))
+               latex_command = command2;
+
+       // Read the flags
+       string flag_name,flag_value;
+       string flag_list(flags);
+       while (!flag_list.empty()) {
+               flag_list = split(flag_list, flag_value,',');
+               flag_value = split(flag_value, flag_name, '=');
+               if (flag_name == "originaldir")
+                       Com.original_dir = true;
+               else if (flag_name == "needaux")
+                       Com.need_aux = true;
+               else if (flag_name == "resultdir")
+                       Com.result_dir = (flag_value.empty())
+                               ? "$$BaseName" : flag_value;
+               else if (flag_name == "resultfile")
+                       Com.result_file = flag_value;
+       }
+       if (!Com.result_dir.empty() && Com.result_file.empty())
+               Com.result_file = "index." + to;
 
        for (vector<Command>::iterator it = commands.begin();
             it != commands.end(); ++it)
                if ((*it).from == from && (*it).to == to) {
-                       *it = Command(from, to, command2, original_dir);
+                       *it = Com;
                        return;
                }
-       commands.push_back(Command(from, to, command2, original_dir));
+       commands.push_back(Com);
        Formats::Add(from);
        Formats::Add(to);
        ++Formats::GetFormat(to)->in_degree;
@@ -237,8 +265,12 @@ Converter::GetReachable(string const & from, bool only_viewable)
 
 
 bool Converter::Convert(Buffer * buffer, string const & from_file,
-                       string const & to_file, string const & using_format)
+                       string const & to_file, string const & using_format,
+                       string * view_file)
 {
+       if (view_file)
+               *view_file = to_file;
+
        string from_format = GetExtension(from_file);
        string to_format = GetExtension(to_file);
        if (from_format == to_format)
@@ -296,30 +328,51 @@ bool Converter::Convert(Buffer * buffer, string const & from_file,
                it = (*it).previous;
        }
 
-       Path p(OnlyPath(from_file));
+       string path = OnlyPath(from_file);
+       Path p(path);
 
-       string basename = ChangeExtension(from_file, "");
+       bool run_latex = false;
+       string from_base = ChangeExtension(from_file, "");
+       string to_base = ChangeExtension(to_file, "");
+       string infile;
+       string outfile = from_file;
        for (vector< vector<Command>::iterator >::reverse_iterator rit =
                     S.rbegin(); rit != S.rend(); ++rit) {
                it = *rit;
                lyxerr << "Converting from  "
                       << (*it).from << " to " << (*it).to << endl;
+               infile = outfile;
+               outfile = (*it).result_dir.empty()
+                       ? ChangeExtension(from_file, (*it).to)
+                       : AddName(subst((*it).result_dir,
+                                       "$$BaseName", from_base),
+                                 subst((*it).result_file,
+                                       "$$BaseName", OnlyFilename(from_base)));
 
                if ((*it).from == "tex" &&
                    ( (*it).to == "dvi" || (*it).to == "pdf") ) {
                        lyxrc.pdf_mode = (*it).to == "pdf";
+                       lyxerr << "Running " << (*it).command << endl;
+                       run_latex = true;
                        if (!runLaTeX(buffer, (*it).command))
                                return false;
                } else {
-                       string infile = ChangeExtension(from_file, (*it).from);
-                       if (!(*it).original_dir)
-                               infile = OnlyFilename(infile);
-                       string outfile = ChangeExtension(infile, (*it).to);
+                       if ((*it).need_aux && !run_latex
+                           && !latex_command.empty()) {
+                               lyxerr << "Running " << latex_command 
+                                      << " to update aux file"<<  endl;
+                               runLaTeX(buffer, latex_command);
+                       }
+
+                       string infile2 = ((*it).original_dir)
+                               ? infile : MakeRelPath(infile, path);
+                       string outfile2 = ((*it).original_dir)
+                               ? outfile : MakeRelPath(outfile, path);
 
                        string command = (*it).command;
-                       command = subst(command, "$$FName", infile);
-                       command = subst(command, "$$BaseName", basename);
-                       command = subst(command, "$$OutName", outfile);
+                       command = subst(command, "$$FName", infile2);
+                       command = subst(command, "$$BaseName", from_base);
+                       command = subst(command, "$$OutName", outfile2);
 
                        if ((*it).from == "dvi" && (*it).to == "ps")
                                command = add_options(command,
@@ -344,13 +397,26 @@ bool Converter::Convert(Buffer * buffer, string const & from_file,
                }
        }
 
-       string result_file = ChangeExtension(from_file, to_format);
-       if (result_file != to_file)
+       if (!(*it).result_dir.empty()) {
+               if (view_file)
+                       *view_file = AddName(subst((*it).result_dir,
+                                                  "$$BaseName", to_base),
+                                            subst((*it).result_file,
+                                                  "$$BaseName", OnlyFilename(to_base)));
+               if (from_base != to_base) {
+                       string from = subst((*it).result_dir,
+                                           "$$BaseName", from_base);
+                       string to = subst((*it).result_dir,
+                                         "$$BaseName", to_base);
+                       return lyx::rename(from.c_str(), to.c_str());
+               }
+
+       } else if (outfile != to_file)
                if ((*it).from == "tex" &&
                    ( (*it).to == "dvi" || (*it).to == "pdf") )
-                       return lyx::copy(result_file.c_str(), to_file.c_str());
+                       return lyx::copy(outfile.c_str(), to_file.c_str());
                else
-                       return lyx::rename(result_file.c_str(), to_file.c_str());
+                       return lyx::rename(outfile.c_str(), to_file.c_str());
 
         return true;
 }
@@ -466,6 +532,8 @@ string Converter::dvips_options(Buffer * buffer)
                result += ',' + buffer->params.paperheight;
        } else {
                string paper_option = dvi_papersize(buffer);
+               if (paper_option == "us")
+                       paper_option = "letter";
                if (paper_option != "letter" ||
                    buffer->params.orientation != BufferParams::ORIENTATION_LANDSCAPE) {
                        // dvips won't accept -t letter -t landscape.  In all other
index dc151dba05dd98ee597840c6ee8df873d4ee90ef..8556952a6c736449d6a8e0c52cd8af28de882f9c 100644 (file)
@@ -25,17 +25,25 @@ class Buffer;
 ///
 struct Command {
        ///
-       Command(string const & f, string const & t, string const & c,
-               bool o)
-               : from(f), to(t), command(c), original_dir(o) {}
+       Command(string const & f, string const & t, string const & c)
+               : from(f), to(t), command(c),
+                 original_dir(false), need_aux(false) {}
        ///
        string from;
        ///
        string to;
        ///
        string command;
-       ///
+       /// Do we need to run the converter in the original directory?
        bool original_dir;
+       /// This converter needs the .aux files
+       bool need_aux;
+       /// If the converter put the result in a directory, then result_dir
+       /// is the name of the directory
+       string result_dir;
+       /// If the converter put the result in a directory, then result_file
+       /// is the name of the main file in that directory
+       string result_file;
        ///
        bool visited;
        ///
@@ -98,7 +106,8 @@ public:
        ///
        static
        bool Convert(Buffer * buffer, string const & from_file,
-                    string const & to_file, string const & using_format);
+                    string const & to_file, string const & using_format,
+                    string * view_file = 0);
        static
        string const SplitFormat(string const & str, string & format);
        ///
@@ -114,6 +123,9 @@ private:
        ///
        static
        std::vector<Command> commands;
+       ///
+       static
+       string latex_command;
 };
 
 #endif
index 419ae573805f7f2be30ecb5fdf72544730f263a2..2ce558e6cad435febde5ba866ad944860d422dd3 100644 (file)
 #include "buffer.h"
 #include "lyx_cb.h" //ShowMessage()
 #include "support/filetools.h"
+#include "lyxrc.h"
 
 using std::vector;
 using std::pair;
 
 bool Exporter::Export(Buffer * buffer, string const & format0,
-                     bool put_in_tempdir)
+                     bool put_in_tempdir, string * view_file)
 {
        string format;
        string using_format = Converter::SplitFormat(format0, format);
 
-       string backend_format = BufferExtension(buffer);
+       string backend_format = (format == "txt") 
+               ? format : BufferExtension(buffer);
        bool only_backend = backend_format == format;
 
        string filename = buffer->getLatexName(false);
@@ -37,8 +39,16 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
                filename = AddName(buffer->tmppath, filename);
        filename = ChangeExtension(filename, backend_format);
 
-       if (buffer->isLinuxDoc())
-               buffer->makeLinuxDocFile(filename, only_backend);
+       // Ascii backend
+       if (backend_format == "txt")
+               buffer->writeFileAscii(filename, lyxrc.ascii_linelen);
+       // Linuxdoc backend
+       else if (buffer->isLinuxDoc())
+               buffer->makeLinuxDocFile(filename, true);
+       // Docbook backend
+       else if (buffer->isDocBook())
+               buffer->makeDocBookFile(filename, true);
+       // LaTeX backend
        else if (only_backend)
                buffer->makeLaTeXFile(filename, string(), true);
        else
@@ -48,7 +58,8 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
                ? ChangeExtension(filename, format)
                : ChangeExtension(buffer->getLatexName(false), format);
 
-       if (!Converter::Convert(buffer, filename, outfile, using_format))
+       if (!Converter::Convert(buffer, filename, outfile, using_format, 
+                               view_file))
                return false;
 
        if (!put_in_tempdir)
@@ -63,31 +74,33 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
 
 bool Exporter::Preview(Buffer * buffer, string const & format0)
 {
-       if (!Export(buffer, format0, true))
+       string view_file;
+       if (!Export(buffer, format0, true, &view_file))
                return false;
 
-       string format;
-       Converter::SplitFormat(format0, format);
-
-       string filename = buffer->getLatexName(false);
-       if (!buffer->tmppath.empty())
-               filename = AddName(buffer->tmppath, filename);
-       filename = ChangeExtension(filename, format);
-       return Formats::View(buffer, filename);
+       return Formats::View(buffer, view_file);
 }
 
 
 vector<pair<string, string> > const
 Exporter::GetExportableFormats(Buffer const * buffer)
 {
-       return Converter::GetReachable(BufferExtension(buffer), false);
+       vector<pair<string, string> > result = 
+               Converter::GetReachable(BufferExtension(buffer), false);
+       result.push_back(pair<string,string>("txt", "Ascii"));
+       return result;
 }
 
 
 vector<pair<string, string> > const
 Exporter::GetViewableFormats(Buffer const * buffer)
 {
-       return Converter::GetReachable(BufferExtension(buffer), true);
+       vector<pair<string, string> > result = 
+               Converter::GetReachable(BufferExtension(buffer), false);
+       Format * format = Formats::GetFormat("txt");
+       if (format && !format->viewer.empty())
+               result.push_back(pair<string,string>("txt", "Ascii"));
+       return result;
 }
 
 
@@ -95,6 +108,8 @@ string const Exporter::BufferExtension(Buffer const * buffer)
 {
        if (buffer->isLinuxDoc())
                return "sgml";
+       else if (buffer->isDocBook())
+               return "docbook";
        else
                return "tex";
 }
index fb286f7a2d29b333633cc300a65185bbabe6246e..b052f591b3796a7bbb4e8e76869cc12d5cca7b15 100644 (file)
@@ -27,7 +27,7 @@ public:
        ///
        static
        bool Export(Buffer * buffer, string const & format,
-                   bool put_in_tempdir);
+                   bool put_in_tempdir, string * view_file = 0);
        ///
        static
        bool Preview(Buffer * buffer, string const & format);
index dd9be1651d6233037c38a2b03016ea692326d5d1..c0a4b31fc3de67765c1283d952d0630151a96c9c 100644 (file)
@@ -145,8 +145,6 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                        command2 += QuoteName(psname);
                        // First run dvips.
                        // If successful, then spool command
-                       lyxerr << "command1 = " << command << endl;
-                       lyxerr << "command2 = " << command2 << endl;
                        res = one.startscript(Systemcalls::System, command);
                        if (res == 0)
                                res = one.startscript(Systemcalls::SystemDontWait,
@@ -161,7 +159,6 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                command += lyxrc.print_to_file
                        + QuoteName(MakeAbsPath(pp.file_name, path));
                command += ' ' + QuoteName(dviname);
-               lyxerr << "command1 = " << command << endl;
                res = one.startscript(Systemcalls::SystemDontWait, command);
                break;
        }
index 1b1e2338d32f91d02ea3d5d32c893761358ba493..74742508434fc31d80fb7430cb48af2bce56f91e 100644 (file)
@@ -49,7 +49,7 @@ int GUIRunTime::initApplication(int argc, char * argv[])
        // }
        int xforms_lib_version = fl_library_version(0, 0);
        if (xforms_include_version != xforms_lib_version) {
-               cerr << "You are either running LyX with wrong "
+               lyxerr << "You are either running LyX with wrong "
                        "version of a dynamic XForms library\n"
                        "or you have build LyX with conflicting header "
                        "and library (different\n"
index 1b6149b65bd96b6d66c906d0a3d930c61224063d..de72dc36782d90d97e0952f5c8de0e8eb25bb730 100644 (file)
 #endif
 #include "ToolbarDefaults.h"
 #include "lyxlex.h"
+#if 1
+// only to get access to NEW_EXPORT
+#include "exporter.h"
+#endif
 
 using std::endl;
 
 extern void LoadLyXFile(string const &);
+extern void QuitLyX();
 
 string system_lyxdir;
 string build_lyxdir;
@@ -151,6 +156,7 @@ LyX::LyX(int * argc, char * argv[])
                // Maybe we could do something more clever than aborting...
                if (dispatched) {
                        lyxerr << "We are done!" << endl;
+                       QuitLyX();
                        return;
                }
 
@@ -750,7 +756,9 @@ bool LyX::easyParse(int * argc, char * argv[])
                        if (i + 1 < *argc) {
                                string type(argv[i+1]);
                                removeargs = 2;
-
+#ifdef NEW_EXPORT
+                               batch_command = "buffer-export " + type;
+#else
                                if (type == "tex")
                                        type = "latex";
                                else if (type == "ps")
@@ -766,6 +774,7 @@ bool LyX::easyParse(int * argc, char * argv[])
                                        lyxerr << _("Unknown file type '")
                                               << type << _("' after ")
                                               << arg << _(" switch!") << endl;
+#endif
                        } else
                                lyxerr << _("Missing file type [eg latex, "
                                            "ps...] after ")
index 85f5d826d5df5f4d30a3e2671f20f5fd357ac045..e4c2ee6096f221f08874d4f244a81612ec5cde65 100644 (file)
@@ -387,6 +387,7 @@ int DeleteAllFilesInDir (string const & path)
                return -1;
        }
        struct dirent * de;
+       int return_value = 0;
        while ((de = readdir(dir))) {
                string temp = de->d_name;
                if (temp == "." || temp == "..") 
@@ -395,12 +396,18 @@ int DeleteAllFilesInDir (string const & path)
 
                lyxerr.debug() << "Deleting file: " << unlinkpath << endl;
 
-               if (remove(unlinkpath.c_str()))
+               bool deleted = true;
+               if (FileInfo(unlinkpath).isDir())
+                       deleted = (DeleteAllFilesInDir(unlinkpath) == 0);
+               deleted &= (remove(unlinkpath.c_str()) == 0);
+               if (!deleted) {
                        WriteFSAlert (_("Error! Could not remove file:"), 
                                      unlinkpath);
+                       return_value = -1;
+               }
         }
        closedir(dir);
-       return 0;
+       return return_value;
 }