Export patch from Dekel

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1009 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-09-11 15:42:17 +00:00
parent 21f8cd3385
commit b9df4a9322
22 changed files with 259 additions and 120 deletions

View File

@ -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> 2000-09-11 Juergen Vigna <jug@sad.it>
* src/lyx_gui.C (runTime): uses global guiruntime variable. * src/lyx_gui.C (runTime): uses global guiruntime variable.

View File

@ -44,10 +44,10 @@
\bind "C-s" "buffer-write" \bind "C-s" "buffer-write"
\bind "C-S-S" "buffer-write-as" \bind "C-S-S" "buffer-write-as"
\bind "C-p" "buffer-print" \bind "C-p" "buffer-print"
\bind "C-d" "buffer-view" # 'd' for dvi \bind "C-d" "buffer-view dvi" # 'd' for dvi
\bind "C-t" "buffer-view-ps" \bind "C-t" "buffer-view ps"
\bind "C-S-D" "buffer-typeset" # 'd' for dvi \bind "C-S-D" "buffer-update dvi" # 'd' for dvi
\bind "C-S-T" "buffer-typeset-ps" \bind "C-S-T" "buffer-update ps"
\bind "C-q" "lyx-quit" \bind "C-q" "lyx-quit"
\bind "C-b" "font-bold" \bind "C-b" "font-bold"

View File

@ -52,10 +52,10 @@
\bind "M-d s" "buffer-write" \bind "M-d s" "buffer-write"
\bind "M-d u" "buffer-write-as" \bind "M-d u" "buffer-write-as"
\bind "M-d w" "buffer-reload" \bind "M-d w" "buffer-reload"
\bind "M-d a" "buffer-view" \bind "M-d a" "buffer-view dvi"
\bind "M-d p" "buffer-view-ps" \bind "M-d p" "buffer-view ps"
\bind "M-d i" "buffer-typeset" \bind "M-d i" "buffer-update dvi"
\bind "M-d k" "buffer-typeset-ps" \bind "M-d k" "buffer-update ps"
\bind "M-d r" "build-program" \bind "M-d r" "build-program"
\bind "M-d d" "buffer-print" \bind "M-d d" "buffer-print"
\bind "M-d f" "buffer-fax" \bind "M-d f" "buffer-fax"

View File

@ -72,13 +72,13 @@
\bind "C-x a" "buffer-auto-save" \bind "C-x a" "buffer-auto-save"
#\bind "C-x b" "buffer-previous" #\bind "C-x b" "buffer-previous"
\bind "C-x d" "buffer-new" \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 k" "buffer-close"
\bind "C-x p" "buffer-view" \bind "C-x p" "buffer-view dvi"
\bind "C-x r" "buffer-typeset" \bind "C-x r" "buffer-update dvi"
# Should have been "buffer-write-some" # Should have been "buffer-write-some"
# \bind "C-x s" "buffer-write" # \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 u" "undo"
\bind "C-x v h" "vc-history" \bind "C-x v h" "vc-history"
\bind "C-x v v" "vc-check-in" \bind "C-x v v" "vc-check-in"
@ -92,12 +92,12 @@
\bind "C-x C-c" "lyx-quit" \bind "C-x C-c" "lyx-quit"
\bind "C-x C-d" "buffer-new" \bind "C-x C-d" "buffer-new"
\bind "C-x C-f" "buffer-open" \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-p" "buffer-view" \bind "C-x C-p" "buffer-view dvi"
\bind "C-x C-q" "buffer-toggle-read-only" \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-s" "buffer-write"
\bind "C-x C-t" "buffer-typeset" \bind "C-x C-t" "buffer-update dvi"
# this is "upcase-region" in emacs # this is "upcase-region" in emacs

View File

@ -38,10 +38,10 @@
\bind "M-t t" "buffer-write" \bind "M-t t" "buffer-write"
\bind "M-t n" "buffer-write-as" \bind "M-t n" "buffer-write-as"
\bind "M-t h" "buffer-reload" \bind "M-t h" "buffer-reload"
\bind "M-t d" "buffer-view" \bind "M-t d" "buffer-view dvi"
\bind "M-t c" "buffer-view-ps" \bind "M-t c" "buffer-view ps"
\bind "M-t v" "buffer-typeset" \bind "M-t v" "buffer-update dvi"
\bind "M-t i" "buffer-typeset-ps" \bind "M-t i" "buffer-update ps"
\bind "M-t l" "buffer-print" \bind "M-t l" "buffer-print"
\bind "M-t f" "buffer-fax" \bind "M-t f" "buffer-fax"
\bind "M-t o l" "buffer-import latex" \bind "M-t o l" "buffer-import latex"

View File

@ -34,10 +34,10 @@
\bind "M-f e" "buffer-write" #Enregistrer \bind "M-f e" "buffer-write" #Enregistrer
\bind "M-f s" "buffer-write-as" #Enregistrer Sous \bind "M-f s" "buffer-write-as" #Enregistrer Sous
\bind "M-f r" "buffer-reload" #Recharger \bind "M-f r" "buffer-reload" #Recharger
\bind "M-f S-D" "buffer-view" #Visualiser DVI \bind "M-f S-D" "buffer-view dvi" #Visualiser DVI
\bind "M-f S-P" "buffer-view-ps" #Visualiser Postscript \bind "M-f S-P" "buffer-view ps" #Visualiser Postscript
\bind "M-f d" "buffer-typeset" #Mise à jour dvi \bind "M-f d" "buffer-update dvi" #Mise à jour dvi
\bind "M-f p" "buffer-typeset-ps" #Mise à jour Postscript \bind "M-f p" "buffer-update ps" #Mise à jour Postscript
\bind "M-f c" "build-program" #Compiler programme \bind "M-f c" "build-program" #Compiler programme
\bind "M-f i" "buffer-print" #Imprimer \bind "M-f i" "buffer-print" #Imprimer
\bind "M-f v" "buffer-fax" #Fax \bind "M-f v" "buffer-fax" #Fax

View File

@ -35,10 +35,10 @@
\bind "M-f m" "buffer-write" \bind "M-f m" "buffer-write"
\bind "M-f t" "buffer-write-as" \bind "M-f t" "buffer-write-as"
\bind "M-f i" "buffer-reload" \bind "M-f i" "buffer-reload"
\bind "M-f d" "buffer-view" \bind "M-f d" "buffer-view dvi"
\bind "M-f p" "buffer-view-ps" \bind "M-f p" "buffer-view ps"
\bind "M-f v" "buffer-typeset" \bind "M-f v" "buffer-update dvi"
\bind "M-f o" "buffer-typeset-ps" \bind "M-f o" "buffer-update ps"
\bind "M-f y" "buffer-print" \bind "M-f y" "buffer-print"
\bind "M-f f" "buffer-fax" \bind "M-f f" "buffer-fax"
\bind "M-f l" "buffer-export latex" \bind "M-f l" "buffer-export latex"

View File

@ -34,10 +34,10 @@
\bind "M-f s" "buffer-write" \bind "M-f s" "buffer-write"
\bind "M-f a" "buffer-write-as" \bind "M-f a" "buffer-write-as"
\bind "M-f r" "buffer-reload" \bind "M-f r" "buffer-reload"
\bind "M-f d" "buffer-view" \bind "M-f d" "buffer-view dvi"
\bind "M-f w" "buffer-view-ps" \bind "M-f w" "buffer-view ps"
\bind "M-f v" "buffer-typeset" \bind "M-f v" "buffer-update dvi"
\bind "M-f u" "buffer-typeset-ps" \bind "M-f u" "buffer-update ps"
\bind "M-f p" "buffer-print" \bind "M-f p" "buffer-print"
\bind "M-f f" "buffer-fax" \bind "M-f f" "buffer-fax"
\bind "M-f i l" "buffer-import latex" \bind "M-f i l" "buffer-import latex"

View File

@ -38,10 +38,10 @@
\bind "M-a l" "buffer-write" \bind "M-a l" "buffer-write"
\bind "M-a c" "buffer-write-as" \bind "M-a c" "buffer-write-as"
\bind "M-a r" "buffer-reload" \bind "M-a r" "buffer-reload"
\bind "M-a d" "buffer-view" \bind "M-a d" "buffer-view dvi"
\bind "M-a o" "buffer-view-ps" \bind "M-a o" "buffer-view ps"
\bind "M-a v" "buffer-typeset" \bind "M-a v" "buffer-update dvi"
\bind "M-a z" "buffer-typeset-ps" \bind "M-a z" "buffer-update ps"
\bind "M-a p" "buffer-print" \bind "M-a p" "buffer-print"
\bind "M-a x" "buffer-fax" \bind "M-a x" "buffer-fax"
\bind "M-a i l" "buffer-import latex" \bind "M-a i l" "buffer-import latex"

View File

@ -252,13 +252,13 @@
\bind "M-f o" "buffer-open" \bind "M-f o" "buffer-open"
\bind "M-f p" "buffer-print" \bind "M-f p" "buffer-print"
\bind "M-f q" "lyx-quit" \bind "M-f q" "lyx-quit"
\bind "M-f r" "buffer-typeset" \bind "M-f r" "buffer-update dvi"
# Obsolete # Obsolete
\bind "M-f s" "buffer-write" \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 x" "buffer-view dvi"
\bind "M-f g" "buffer-view-ps" \bind "M-f g" "buffer-view ps"
\bind "M-f space" "menu-open File" \bind "M-f space" "menu-open File"

View File

@ -44,10 +44,10 @@
\bind "M-f s" "buffer-write" \bind "M-f s" "buffer-write"
\bind "M-f o" "buffer-write-as" \bind "M-f o" "buffer-write-as"
\bind "M-f t" "buffer-reload" \bind "M-f t" "buffer-reload"
\bind "M-f v" "buffer-view" \bind "M-f v" "buffer-view dvi"
\bind "M-f i" "buffer-view-ps" \bind "M-f i" "buffer-view ps"
\bind "M-f u" "buffer-typeset" \bind "M-f u" "buffer-update dvi"
\bind "M-f d" "buffer-typeset-ps" \bind "M-f d" "buffer-update ps"
\bind "M-f k" "buffer-print" \bind "M-f k" "buffer-print"
\bind "M-f f" "buffer-fax" \bind "M-f f" "buffer-fax"
\bind "M-f l" "buffer-export latex" \bind "M-f l" "buffer-export latex"

View File

@ -75,13 +75,13 @@
# not currently supported # not currently supported
#\bind "C-x b" "buffer-previous" #\bind "C-x b" "buffer-previous"
\bind "C-x d" "buffer-new" \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 k" "buffer-close"
\bind "C-x p" "buffer-view" \bind "C-x p" "buffer-view dvi"
\bind "C-x r" "buffer-typeset" \bind "C-x r" "buffer-update dvi"
# Should have been "buffer-write-some" # Should have been "buffer-write-some"
# \bind "C-x s" "buffer-write" # \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 u" "undo"
\bind "C-x v h" "vc-history" \bind "C-x v h" "vc-history"
\bind "C-x v v" "vc-check-in" \bind "C-x v v" "vc-check-in"
@ -97,13 +97,13 @@
\bind "C-x C-c" "lyx-quit" \bind "C-x C-c" "lyx-quit"
\bind "C-x C-d" "buffer-new" \bind "C-x C-d" "buffer-new"
\bind "C-x C-f" "buffer-open" \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-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-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-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-u" "word-upcase" # upcase-region!
\bind "C-x C-w" "buffer-write-as" \bind "C-x C-w" "buffer-write-as"
@ -285,9 +285,9 @@
# #
## Start TeX mode, some overlap with AucTeX mode ## 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-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 ## End TeX mode
# #

21
lib/configure vendored
View File

@ -857,7 +857,7 @@ fi
latex_to_html_command = $TOHTML latex_to_html_command = $TOHTML
case $TOHTML in 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";; latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
hevea) latex_to_html_command="hevea -s \$\$FName";; hevea) latex_to_html_command="hevea -s \$\$FName";;
esac esac
@ -945,15 +945,16 @@ cat >lyxrc.defaults <<EOF
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as # 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 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
# override the values given here. # override the values given here.
\\converter tex dvi "$LATEX" noflags \\converter tex dvi "$LATEX" ""
\\converter tex pdf "$PDFLATEX" noflags \\converter tex pdf "$PDFLATEX" ""
\\converter dvi ps "$dvi_to_ps_command" noflags \\converter dvi ps "$dvi_to_ps_command" ""
\\converter ps pdf "$ps_to_pdf_command" noflags \\converter ps pdf "$ps_to_pdf_command" ""
\\converter sgml tex "$linuxdoc_to_latex_command" noflags \\converter sgml tex "$linuxdoc_to_latex_command" ""
\\converter sgml html "$linuxdoc_to_html_command" noflags \\converter sgml html "$linuxdoc_to_html_command" ""
\\converter docbook dvi "$docbook_to_dvi_command" noflags \\converter docbook dvi "$docbook_to_dvi_command" ""
\\converter docbook html "$docbook_to_html_command" noflags \\converter docbook html "$docbook_to_html_command" ""
\\converter tex html "$latex_to_html_command" noflags \\converter tex html "$latex_to_html_command"
originaldir
\\viewer dvi "$DVI_VIEWER" \\viewer dvi "$DVI_VIEWER"
\\viewer html "$HTML_VIEWER" \\viewer html "$HTML_VIEWER"

View File

@ -291,7 +291,7 @@ esac
SEARCH_PROG([for an HTML converter], TOHTML, tth latex2html hevea) SEARCH_PROG([for an HTML converter], TOHTML, tth latex2html hevea)
latex_to_html_command = $TOHTML latex_to_html_command = $TOHTML
case $TOHTML in 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";; latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
hevea) latex_to_html_command="hevea -s \$\$FName";; hevea) latex_to_html_command="hevea -s \$\$FName";;
esac esac
@ -367,15 +367,16 @@ cat >lyxrc.defaults <<EOF
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as # 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 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
# override the values given here. # override the values given here.
\\converter tex dvi "$LATEX" noflags \\converter tex dvi "$LATEX" ""
\\converter tex pdf "$PDFLATEX" noflags \\converter tex pdf "$PDFLATEX" ""
\\converter dvi ps "$dvi_to_ps_command" noflags \\converter dvi ps "$dvi_to_ps_command" ""
\\converter ps pdf "$ps_to_pdf_command" noflags \\converter ps pdf "$ps_to_pdf_command" ""
\\converter sgml tex "$linuxdoc_to_latex_command" noflags \\converter sgml tex "$linuxdoc_to_latex_command" ""
\\converter sgml html "$linuxdoc_to_html_command" noflags \\converter sgml html "$linuxdoc_to_html_command" ""
\\converter docbook dvi "$docbook_to_dvi_command" noflags \\converter docbook dvi "$docbook_to_dvi_command" ""
\\converter docbook html "$docbook_to_html_command" noflags \\converter docbook html "$docbook_to_html_command" ""
\\converter tex html "$latex_to_html_command" noflags \\converter tex html "$latex_to_html_command"
"originaldir,needaux"
\\viewer dvi "$DVI_VIEWER" \\viewer dvi "$DVI_VIEWER"
\\viewer html "$HTML_VIEWER" \\viewer html "$HTML_VIEWER"

View File

@ -40,6 +40,7 @@ using std::endl;
map<string, Format> Formats::formats; map<string, Format> Formats::formats;
vector<Command> Converter::commands; vector<Command> Converter::commands;
string Converter::latex_command;
inline inline
string add_options(string const & command, string const & options) 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) bool Formats::View(Buffer * buffer, string const & filename)
{ {
if (filename.empty())
return false;
string extension = GetExtension(filename); string extension = GetExtension(filename);
Format * format = GetFormat(extension); Format * format = GetFormat(extension);
if (!format || format->viewer.empty()) { if (!format || format->viewer.empty()) {
@ -167,19 +171,43 @@ void Converter::Add(string const & from, string const & to,
if (command == "none") if (command == "none")
return; return;
bool original_dir = flags == "origdir";
string command2 = string command2 =
subst(command, "$$FName", "'$$FName'"); subst(command, "$$FName", "'$$FName'");
command2 = subst(command2, "$$BaseName", "'$$BaseName'"); command2 = subst(command2, "$$BaseName", "'$$BaseName'");
command2 = subst(command2, "$$OutName", "'$$OutName'"); 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(); for (vector<Command>::iterator it = commands.begin();
it != commands.end(); ++it) it != commands.end(); ++it)
if ((*it).from == from && (*it).to == to) { if ((*it).from == from && (*it).to == to) {
*it = Command(from, to, command2, original_dir); *it = Com;
return; return;
} }
commands.push_back(Command(from, to, command2, original_dir)); commands.push_back(Com);
Formats::Add(from); Formats::Add(from);
Formats::Add(to); Formats::Add(to);
++Formats::GetFormat(to)->in_degree; ++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, 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 from_format = GetExtension(from_file);
string to_format = GetExtension(to_file); string to_format = GetExtension(to_file);
if (from_format == to_format) if (from_format == to_format)
@ -296,30 +328,51 @@ bool Converter::Convert(Buffer * buffer, string const & from_file,
it = (*it).previous; 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 = for (vector< vector<Command>::iterator >::reverse_iterator rit =
S.rbegin(); rit != S.rend(); ++rit) { S.rbegin(); rit != S.rend(); ++rit) {
it = *rit; it = *rit;
lyxerr << "Converting from " lyxerr << "Converting from "
<< (*it).from << " to " << (*it).to << endl; << (*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" && if ((*it).from == "tex" &&
( (*it).to == "dvi" || (*it).to == "pdf") ) { ( (*it).to == "dvi" || (*it).to == "pdf") ) {
lyxrc.pdf_mode = (*it).to == "pdf"; lyxrc.pdf_mode = (*it).to == "pdf";
lyxerr << "Running " << (*it).command << endl;
run_latex = true;
if (!runLaTeX(buffer, (*it).command)) if (!runLaTeX(buffer, (*it).command))
return false; return false;
} else { } else {
string infile = ChangeExtension(from_file, (*it).from); if ((*it).need_aux && !run_latex
if (!(*it).original_dir) && !latex_command.empty()) {
infile = OnlyFilename(infile); lyxerr << "Running " << latex_command
string outfile = ChangeExtension(infile, (*it).to); << " 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; string command = (*it).command;
command = subst(command, "$$FName", infile); command = subst(command, "$$FName", infile2);
command = subst(command, "$$BaseName", basename); command = subst(command, "$$BaseName", from_base);
command = subst(command, "$$OutName", outfile); command = subst(command, "$$OutName", outfile2);
if ((*it).from == "dvi" && (*it).to == "ps") if ((*it).from == "dvi" && (*it).to == "ps")
command = add_options(command, 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 (!(*it).result_dir.empty()) {
if (result_file != to_file) 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" && if ((*it).from == "tex" &&
( (*it).to == "dvi" || (*it).to == "pdf") ) ( (*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 else
return lyx::rename(result_file.c_str(), to_file.c_str()); return lyx::rename(outfile.c_str(), to_file.c_str());
return true; return true;
} }
@ -466,6 +532,8 @@ string Converter::dvips_options(Buffer * buffer)
result += ',' + buffer->params.paperheight; result += ',' + buffer->params.paperheight;
} else { } else {
string paper_option = dvi_papersize(buffer); string paper_option = dvi_papersize(buffer);
if (paper_option == "us")
paper_option = "letter";
if (paper_option != "letter" || if (paper_option != "letter" ||
buffer->params.orientation != BufferParams::ORIENTATION_LANDSCAPE) { buffer->params.orientation != BufferParams::ORIENTATION_LANDSCAPE) {
// dvips won't accept -t letter -t landscape. In all other // dvips won't accept -t letter -t landscape. In all other

View File

@ -25,17 +25,25 @@ class Buffer;
/// ///
struct Command { struct Command {
/// ///
Command(string const & f, string const & t, string const & c, Command(string const & f, string const & t, string const & c)
bool o) : from(f), to(t), command(c),
: from(f), to(t), command(c), original_dir(o) {} original_dir(false), need_aux(false) {}
/// ///
string from; string from;
/// ///
string to; string to;
/// ///
string command; string command;
/// /// Do we need to run the converter in the original directory?
bool original_dir; 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; bool visited;
/// ///
@ -98,7 +106,8 @@ public:
/// ///
static static
bool Convert(Buffer * buffer, string const & from_file, 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 static
string const SplitFormat(string const & str, string & format); string const SplitFormat(string const & str, string & format);
/// ///
@ -114,6 +123,9 @@ private:
/// ///
static static
std::vector<Command> commands; std::vector<Command> commands;
///
static
string latex_command;
}; };
#endif #endif

View File

@ -19,17 +19,19 @@
#include "buffer.h" #include "buffer.h"
#include "lyx_cb.h" //ShowMessage() #include "lyx_cb.h" //ShowMessage()
#include "support/filetools.h" #include "support/filetools.h"
#include "lyxrc.h"
using std::vector; using std::vector;
using std::pair; using std::pair;
bool Exporter::Export(Buffer * buffer, string const & format0, bool Exporter::Export(Buffer * buffer, string const & format0,
bool put_in_tempdir) bool put_in_tempdir, string * view_file)
{ {
string format; string format;
string using_format = Converter::SplitFormat(format0, 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; bool only_backend = backend_format == format;
string filename = buffer->getLatexName(false); string filename = buffer->getLatexName(false);
@ -37,8 +39,16 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
filename = AddName(buffer->tmppath, filename); filename = AddName(buffer->tmppath, filename);
filename = ChangeExtension(filename, backend_format); filename = ChangeExtension(filename, backend_format);
if (buffer->isLinuxDoc()) // Ascii backend
buffer->makeLinuxDocFile(filename, only_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) else if (only_backend)
buffer->makeLaTeXFile(filename, string(), true); buffer->makeLaTeXFile(filename, string(), true);
else else
@ -48,7 +58,8 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
? ChangeExtension(filename, format) ? ChangeExtension(filename, format)
: ChangeExtension(buffer->getLatexName(false), 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; return false;
if (!put_in_tempdir) if (!put_in_tempdir)
@ -63,31 +74,33 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
bool Exporter::Preview(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; return false;
string format; return Formats::View(buffer, view_file);
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);
} }
vector<pair<string, string> > const vector<pair<string, string> > const
Exporter::GetExportableFormats(Buffer const * buffer) 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 vector<pair<string, string> > const
Exporter::GetViewableFormats(Buffer const * buffer) 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()) if (buffer->isLinuxDoc())
return "sgml"; return "sgml";
else if (buffer->isDocBook())
return "docbook";
else else
return "tex"; return "tex";
} }

View File

@ -27,7 +27,7 @@ public:
/// ///
static static
bool Export(Buffer * buffer, string const & format, bool Export(Buffer * buffer, string const & format,
bool put_in_tempdir); bool put_in_tempdir, string * view_file = 0);
/// ///
static static
bool Preview(Buffer * buffer, string const & format); bool Preview(Buffer * buffer, string const & format);

View File

@ -145,8 +145,6 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
command2 += QuoteName(psname); command2 += QuoteName(psname);
// First run dvips. // First run dvips.
// If successful, then spool command // If successful, then spool command
lyxerr << "command1 = " << command << endl;
lyxerr << "command2 = " << command2 << endl;
res = one.startscript(Systemcalls::System, command); res = one.startscript(Systemcalls::System, command);
if (res == 0) if (res == 0)
res = one.startscript(Systemcalls::SystemDontWait, res = one.startscript(Systemcalls::SystemDontWait,
@ -161,7 +159,6 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
command += lyxrc.print_to_file command += lyxrc.print_to_file
+ QuoteName(MakeAbsPath(pp.file_name, path)); + QuoteName(MakeAbsPath(pp.file_name, path));
command += ' ' + QuoteName(dviname); command += ' ' + QuoteName(dviname);
lyxerr << "command1 = " << command << endl;
res = one.startscript(Systemcalls::SystemDontWait, command); res = one.startscript(Systemcalls::SystemDontWait, command);
break; break;
} }

View File

@ -49,7 +49,7 @@ int GUIRunTime::initApplication(int argc, char * argv[])
// } // }
int xforms_lib_version = fl_library_version(0, 0); int xforms_lib_version = fl_library_version(0, 0);
if (xforms_include_version != xforms_lib_version) { 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" "version of a dynamic XForms library\n"
"or you have build LyX with conflicting header " "or you have build LyX with conflicting header "
"and library (different\n" "and library (different\n"

View File

@ -40,10 +40,15 @@
#endif #endif
#include "ToolbarDefaults.h" #include "ToolbarDefaults.h"
#include "lyxlex.h" #include "lyxlex.h"
#if 1
// only to get access to NEW_EXPORT
#include "exporter.h"
#endif
using std::endl; using std::endl;
extern void LoadLyXFile(string const &); extern void LoadLyXFile(string const &);
extern void QuitLyX();
string system_lyxdir; string system_lyxdir;
string build_lyxdir; string build_lyxdir;
@ -151,6 +156,7 @@ LyX::LyX(int * argc, char * argv[])
// Maybe we could do something more clever than aborting... // Maybe we could do something more clever than aborting...
if (dispatched) { if (dispatched) {
lyxerr << "We are done!" << endl; lyxerr << "We are done!" << endl;
QuitLyX();
return; return;
} }
@ -750,7 +756,9 @@ bool LyX::easyParse(int * argc, char * argv[])
if (i + 1 < *argc) { if (i + 1 < *argc) {
string type(argv[i+1]); string type(argv[i+1]);
removeargs = 2; removeargs = 2;
#ifdef NEW_EXPORT
batch_command = "buffer-export " + type;
#else
if (type == "tex") if (type == "tex")
type = "latex"; type = "latex";
else if (type == "ps") else if (type == "ps")
@ -766,6 +774,7 @@ bool LyX::easyParse(int * argc, char * argv[])
lyxerr << _("Unknown file type '") lyxerr << _("Unknown file type '")
<< type << _("' after ") << type << _("' after ")
<< arg << _(" switch!") << endl; << arg << _(" switch!") << endl;
#endif
} else } else
lyxerr << _("Missing file type [eg latex, " lyxerr << _("Missing file type [eg latex, "
"ps...] after ") "ps...] after ")

View File

@ -387,6 +387,7 @@ int DeleteAllFilesInDir (string const & path)
return -1; return -1;
} }
struct dirent * de; struct dirent * de;
int return_value = 0;
while ((de = readdir(dir))) { while ((de = readdir(dir))) {
string temp = de->d_name; string temp = de->d_name;
if (temp == "." || temp == "..") if (temp == "." || temp == "..")
@ -395,12 +396,18 @@ int DeleteAllFilesInDir (string const & path)
lyxerr.debug() << "Deleting file: " << unlinkpath << endl; 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:"), WriteFSAlert (_("Error! Could not remove file:"),
unlinkpath); unlinkpath);
return_value = -1;
}
} }
closedir(dir); closedir(dir);
return 0; return return_value;
} }