Converter patch from Dekel, Preference patch from Angus, menu patch from Rob

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1212 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-11-13 10:35:02 +00:00
parent 0c978e6a3f
commit 0a16442310
26 changed files with 1445 additions and 1189 deletions

View File

@ -1,3 +1,59 @@
2000-11-13 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/converter.C: add "using" directive.
* src/frontends/xforms/FormPreferences.C: add "using" directive.
(compare_converter): add "int" as return type.
* src/frontends/xforms/Color.C: comment out FL_LIGHTER_COL1 here
too.
2000-11-11 Angus Leeming <a.leeming@ic.ac.uk>
* src/lyx_gui.C (create_forms): map the xform colours, should a
mapping exist. Ie, call XformColor::read().
* src/frontends/xforms/Color.[Ch] renamed struct RGB as RGBColor
and struct HSV as HSVColor.
(XformColor::read, XformColor::write) : new methods that
input/output any changes to the cform GUI colors.
* src/frontends/xforms/Dialogs.C: FORMS_H_LOCATION no longer
included.
* src/frontends/xforms/FormPreferences.C Lots of little changes
associated with the changed name of the RGB and HSV structs. Can
now save changes to xforms GUI to file. Commented out
FL_LIGHTER_COL1 to allow compilation with xforms 0.88. It isn't
used currently anyway.
2000-11-11 Dekel Tsur <dekelts@tau.ac.il>
* src/converter.C: A lot of changes:
- It is no longer possible to choose between two or more ways to
export to some format (the new code uses only the shortest path).
However, it is still possible to choose between pdflatex/ps2pdf
for creating a PDF file, by defining two PDF formats: pdf & pdf2.
- Added several methods that makes the FormPreferences code simpler.
- Changed the tokens $$FName and $$OutName to $$i and $$o.
* src/exporter.C (Export): lyxrc.use_pdf is set before
makeLaTeXFile is called. This works but not very nice.
* src/frontends/xforms/FormPreferences.C: The formats/converters
tabs are now fully functional.
* src/buffer.C (getTocList): Add numbers to the captions.
* lib/lyxrc.example: Removed fax section
* src/support/rename.C (rename): Delete the old file if lyx::copy
is called.
2000-11-13 Rob Lahaye <lahaye@postech.edu>
* lib/ui/default.ui: minor polishing.
2000-11-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 2000-11-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/frontends/xforms/Color.C: include <algorithm> and <cmath> * src/frontends/xforms/Color.C: include <algorithm> and <cmath>
@ -105,7 +161,7 @@
2000-11-08 Dekel Tsur <dekelts@tau.ac.il> 2000-11-08 Dekel Tsur <dekelts@tau.ac.il>
* src/frontends/xforms/FormParagraph.C (updateLanguage): Check * src/frontends/xforms/FormPreferences.C (updateLanguage): Check
iterators to prevent crash. iterators to prevent crash.
2000-11-08 Angus Leeming <a.leeming@ic.ac.uk> 2000-11-08 Angus Leeming <a.leeming@ic.ac.uk>

85
lib/configure vendored
View File

@ -222,7 +222,7 @@ if test -z "$tex_to_lyx_command" ; then
fi fi
PATH=${save_PATH} PATH=${save_PATH}
test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$FName" test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
echo $ac_n "checking for a Noweb -> LyX converter""... $ac_c" echo $ac_n "checking for a Noweb -> LyX converter""... $ac_c"
echo "$ac_t""(noweb2lyx)" echo "$ac_t""(noweb2lyx)"
@ -258,7 +258,7 @@ if test -z "$literate_to_lyx_command" ; then
literate_to_lyx_command=none literate_to_lyx_command=none
fi fi
test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$FName \$\$OutName" test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
# Search something to process a literate document # Search something to process a literate document
echo $ac_n "checking for a Noweb -> LaTeX converter""... $ac_c" echo $ac_n "checking for a Noweb -> LaTeX converter""... $ac_c"
@ -295,7 +295,7 @@ if test -z "$literate_to_tex_command" ; then
literate_to_tex_command=none literate_to_tex_command=none
fi fi
test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$FName > \$\$OutName" test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
echo $ac_n "checking for a HTML -> Latex converter""... $ac_c" echo $ac_n "checking for a HTML -> Latex converter""... $ac_c"
echo "$ac_t""(html2latex)" echo "$ac_t""(html2latex)"
@ -331,7 +331,7 @@ if test -z "$html_to_latex_command" ; then
html_to_latex_command=none html_to_latex_command=none
fi fi
test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$FName" test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
echo $ac_n "checking for a MSWord -> Latex converter""... $ac_c" echo $ac_n "checking for a MSWord -> Latex converter""... $ac_c"
echo "$ac_t""(wvCleanLatex word2x)" echo "$ac_t""(wvCleanLatex word2x)"
@ -367,8 +367,8 @@ if test -z "$word_to_latex_command" ; then
word_to_latex_command=none word_to_latex_command=none
fi fi
test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$FName \$\$OutName" test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$FName" test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
echo $ac_n "checking for Image converter""... $ac_c" echo $ac_n "checking for Image converter""... $ac_c"
echo "$ac_t""(convert)" echo "$ac_t""(convert)"
@ -404,7 +404,7 @@ if test -z "$image_command" ; then
image_command=none image_command=none
fi fi
test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName" test $image_command = "convert" && image_command="convert \$\$i \$\$o"
# Search for a Postscript interpreter # Search for a Postscript interpreter
echo $ac_n "checking for a Postscript interpreter""... $ac_c" echo $ac_n "checking for a Postscript interpreter""... $ac_c"
@ -621,7 +621,7 @@ if test -z "$ps_to_pdf_command" ; then
ps_to_pdf_command=none ps_to_pdf_command=none
fi fi
test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName" test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
# Search for a program to convert dvi to ps # Search for a program to convert dvi to ps
echo $ac_n "checking for a DVI to PS converter""... $ac_c" echo $ac_n "checking for a DVI to PS converter""... $ac_c"
@ -658,7 +658,7 @@ if test -z "$dvi_to_ps_command" ; then
dvi_to_ps_command=none dvi_to_ps_command=none
fi fi
test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName" test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
# Search a *roff program (used to translate tables in ASCII export) # Search a *roff program (used to translate tables in ASCII export)
echo $ac_n "checking for a *roff formatter""... $ac_c" echo $ac_n "checking for a *roff formatter""... $ac_c"
@ -809,7 +809,7 @@ if test -z "$fax_command" ; then
fax_command=none fax_command=none
fi fi
test $fax_command = "ksendfax" && fax_command="ksendfax \$\$FName" test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
# Search for LinuxDoc support # Search for LinuxDoc support
echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c" echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c"
@ -854,10 +854,10 @@ fi
case $LINUXDOC in case $LINUXDOC in
sgml2lyx) sgml2lyx)
linuxdoc_to_latex_command="sgml2latex \$\$FName" linuxdoc_to_latex_command="sgml2latex \$\$i"
linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName" linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
linuxdoc_to_html_command="sgml2html \$\$FName" linuxdoc_to_html_command="sgml2html \$\$i"
linuxdoc_to_lyx_command="sgml2lyx \$\$FName";; linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
none) none)
linuxdoc_to_latex_command="none" linuxdoc_to_latex_command="none"
linuxdoc_to_dvi_command="none" linuxdoc_to_dvi_command="none"
@ -908,11 +908,11 @@ fi
case $DOCBOOK in case $DOCBOOK in
sgmltools) sgmltools)
docbook_to_dvi_command="sgmltools -b dvi \$\$FName" docbook_to_dvi_command="sgmltools -b dvi \$\$i"
docbook_to_html_command="sgmltools -b html \$\$FName";; docbook_to_html_command="sgmltools -b html \$\$i";;
db2dvi) db2dvi)
docbook_to_dvi_command="db2dvi \$\$FName" docbook_to_dvi_command="db2dvi \$\$i"
docbook_to_html_command="db2html \$\$FName";; docbook_to_html_command="db2html \$\$i";;
none) none)
docbook_to_dvi_command="none" docbook_to_dvi_command="none"
docbook_to_html_command="none";; docbook_to_html_command="none";;
@ -997,9 +997,9 @@ fi
latex_to_html_command=$TOHTML latex_to_html_command=$TOHTML
case $TOHTML in case $TOHTML in
tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";; tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
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 \$\$i";;
hevea) latex_to_html_command="hevea -s \$\$FName";; hevea) latex_to_html_command="hevea -s \$\$i";;
esac esac
#### Explore the LaTeX configuration #### Explore the LaTeX configuration
@ -1085,23 +1085,30 @@ 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.
\\Format latex tex LaTeX L \\Format text txt ASCII A
\\Format dvi dvi DVI D \\Format textparagraph txt ASCII(paragraphs) ""
\\Format ps ps Postscript t
\\Format pdf pdf PDF P
\\Format html html HTML H
\\Format text txt ASCII A
\\Format word doc Word W
\\Format literate nw NoWeb N
\\Format linuxdoc sgml LinuxDoc x
\\Format docbook sgml DocBook B \\Format docbook sgml DocBook B
\\Format program "" Program "" \\Format dvi dvi DVI D
\\Format eps eps EPS ""
\\Format fax "" Fax "" \\Format fax "" Fax ""
\\Format gif gif GIF ""
\\Format html html HTML H
\\Format jpg jpg JPEG ""
\\Format latex tex LaTeX L
\\Format linuxdoc sgml LinuxDoc x
\\Format lyx lyx LyX ""
\\Format literate nw NoWeb N
\\Format pdf pdf PDF P
\\Format pdf2 pdf "PDF (pdflatex)" F
\\Format png png PNG ""
\\Format ps ps Postscript t
\\Format program "" Program ""
\\Format word doc Word W
\\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
\\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook" \\converter latex dvi "$LATEX \$\$i" "latex"
\\converter latex html "$latex_to_html_command" \\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
"originaldir,needaux,disable=linuxdoc&docbook" \\converter latex html "$latex_to_html_command" "originaldir,needaux"
\\converter literate latex "$literate_to_tex_command" "" \\converter literate latex "$literate_to_tex_command" ""
\\converter dvi ps "$dvi_to_ps_command" "" \\converter dvi ps "$dvi_to_ps_command" ""
\\converter ps pdf "$ps_to_pdf_command" "" \\converter ps pdf "$ps_to_pdf_command" ""
@ -1113,10 +1120,10 @@ cat >lyxrc.defaults <<EOF
\\converter docbook dvi "$docbook_to_dvi_command" "" \\converter docbook dvi "$docbook_to_dvi_command" ""
\\converter docbook html "$docbook_to_html_command" "" \\converter docbook html "$docbook_to_html_command" ""
\\converter latex lyx "$tex_to_lyx_command" "importer" \\converter latex lyx "$tex_to_lyx_command" ""
\\converter literate lyx "$literate_to_lyx_command" "importer" \\converter literate lyx "$literate_to_lyx_command" ""
\\converter html latex "$html_to_latex_command" "importer" \\converter html latex "$html_to_latex_command" ""
\\converter word latex "$word_to_latex_command" "importer" \\converter word latex "$word_to_latex_command" ""
\converter gif eps "$image_command" "" \converter gif eps "$image_command" ""
\converter png eps "$image_command" "" \converter png eps "$image_command" ""

View File

@ -184,24 +184,24 @@ save_PATH=${PATH}
PATH=${PATH}:./reLyX/ PATH=${PATH}:./reLyX/
SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX) SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
PATH=${save_PATH} PATH=${save_PATH}
test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$FName" test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx) SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx)
test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$FName \$\$OutName" test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
# Search something to process a literate document # Search something to process a literate document
SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave) SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave)
test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$FName > \$\$OutName" test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex) SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$FName" test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x) SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x)
test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$FName \$\$OutName" test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$FName" test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
SEARCH_PROG([for Image converter],image_command,convert) SEARCH_PROG([for Image converter],image_command,convert)
test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName" test $image_command = "convert" && image_command="convert \$\$i \$\$o"
# Search for a Postscript interpreter # Search for a Postscript interpreter
SEARCH_PROG([for a Postscript interpreter],GS, gs) SEARCH_PROG([for a Postscript interpreter],GS, gs)
@ -220,11 +220,11 @@ SEARCH_PROG([for a HTML previewer],HTML_VIEWER, netscape)
# Search for a program to convert ps to pdf # Search for a program to convert ps to pdf
SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf) SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf)
test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName" test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
# Search for a program to convert dvi to ps # Search for a program to convert dvi to ps
SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips) SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips)
test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName" test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
# Search a *roff program (used to translate tables in ASCII export) # Search a *roff program (used to translate tables in ASCII export)
SEARCH_PROG([for a *roff formatter],ROFF,groff nroff) SEARCH_PROG([for a *roff formatter],ROFF,groff nroff)
@ -254,7 +254,7 @@ dnl fi
# Search a GUI Fax program # Search a GUI Fax program
SEARCH_PROG([for a fax program], fax_command, ksendfax) SEARCH_PROG([for a fax program], fax_command, ksendfax)
test $fax_command = "ksendfax" && fax_command="ksendfax \$\$FName" test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
# Search for LinuxDoc support # Search for LinuxDoc support
SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx) SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
@ -266,10 +266,10 @@ fi
case $LINUXDOC in case $LINUXDOC in
sgml2lyx) sgml2lyx)
linuxdoc_to_latex_command="sgml2latex \$\$FName" linuxdoc_to_latex_command="sgml2latex \$\$i"
linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName" linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
linuxdoc_to_html_command="sgml2html \$\$FName" linuxdoc_to_html_command="sgml2html \$\$i"
linuxdoc_to_lyx_command="sgml2lyx \$\$FName";; linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
none) none)
linuxdoc_to_latex_command="none" linuxdoc_to_latex_command="none"
linuxdoc_to_dvi_command="none" linuxdoc_to_dvi_command="none"
@ -287,11 +287,11 @@ fi
case $DOCBOOK in case $DOCBOOK in
sgmltools) sgmltools)
docbook_to_dvi_command="sgmltools -b dvi \$\$FName" docbook_to_dvi_command="sgmltools -b dvi \$\$i"
docbook_to_html_command="sgmltools -b html \$\$FName";; docbook_to_html_command="sgmltools -b html \$\$i";;
db2dvi) db2dvi)
docbook_to_dvi_command="db2dvi \$\$FName" docbook_to_dvi_command="db2dvi \$\$i"
docbook_to_html_command="db2html \$\$FName";; docbook_to_html_command="db2html \$\$i";;
none) none)
docbook_to_dvi_command="none" docbook_to_dvi_command="none"
docbook_to_html_command="none";; docbook_to_html_command="none";;
@ -310,9 +310,9 @@ esac
SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea) SEARCH_PROG([for a LaTeX -> 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 -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";; tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
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 \$\$i";;
hevea) latex_to_html_command="hevea -s \$\$FName";; hevea) latex_to_html_command="hevea -s \$\$i";;
esac esac
#### Explore the LaTeX configuration #### Explore the LaTeX configuration
@ -386,23 +386,30 @@ 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.
\\Format latex tex LaTeX L \\Format text txt ASCII A
\\Format dvi dvi DVI D \\Format textparagraph txt ASCII(paragraphs) ""
\\Format ps ps Postscript t
\\Format pdf pdf PDF P
\\Format html html HTML H
\\Format text txt ASCII A
\\Format word doc Word W
\\Format literate nw NoWeb N
\\Format linuxdoc sgml LinuxDoc x
\\Format docbook sgml DocBook B \\Format docbook sgml DocBook B
\\Format program "" Program "" \\Format dvi dvi DVI D
\\Format eps eps EPS ""
\\Format fax "" Fax "" \\Format fax "" Fax ""
\\Format gif gif GIF ""
\\Format html html HTML H
\\Format jpg jpg JPEG ""
\\Format latex tex LaTeX L
\\Format linuxdoc sgml LinuxDoc x
\\Format lyx lyx LyX ""
\\Format literate nw NoWeb N
\\Format pdf pdf PDF P
\\Format pdf2 pdf "PDF (pdflatex)" F
\\Format png png PNG ""
\\Format ps ps Postscript t
\\Format program "" Program ""
\\Format word doc Word W
\\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
\\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook" \\converter latex dvi "$LATEX \$\$i" "latex"
\\converter latex html "$latex_to_html_command" \\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
"originaldir,needaux,disable=linuxdoc&docbook" \\converter latex html "$latex_to_html_command" "originaldir,needaux"
\\converter literate latex "$literate_to_tex_command" "" \\converter literate latex "$literate_to_tex_command" ""
\\converter dvi ps "$dvi_to_ps_command" "" \\converter dvi ps "$dvi_to_ps_command" ""
\\converter ps pdf "$ps_to_pdf_command" "" \\converter ps pdf "$ps_to_pdf_command" ""
@ -414,10 +421,10 @@ cat >lyxrc.defaults <<EOF
\\converter docbook dvi "$docbook_to_dvi_command" "" \\converter docbook dvi "$docbook_to_dvi_command" ""
\\converter docbook html "$docbook_to_html_command" "" \\converter docbook html "$docbook_to_html_command" ""
\\converter latex lyx "$tex_to_lyx_command" "importer" \\converter latex lyx "$tex_to_lyx_command" ""
\\converter literate lyx "$literate_to_lyx_command" "importer" \\converter literate lyx "$literate_to_lyx_command" ""
\\converter html latex "$html_to_latex_command" "importer" \\converter html latex "$html_to_latex_command" ""
\\converter word latex "$word_to_latex_command" "importer" \\converter word latex "$word_to_latex_command" ""
\converter gif eps "$image_command" "" \converter gif eps "$image_command" ""
\converter png eps "$image_command" "" \converter png eps "$image_command" ""

View File

@ -340,13 +340,12 @@
# The converter command has 4 arguments: The source format, the target format, # The converter command has 4 arguments: The source format, the target format,
# the command, and additional flags. # the command, and additional flags.
# For example, the following defines a DVI->Postscript converter: # For example, the following defines a DVI->Postscript converter:
#\converter dvi ps "dvips -o $$OutName $$FName" "" #\converter dvi ps "dvips -o $$o $$i" ""
# The variable name $$FName is replaced with the name of the source file, # The variable name $$i is replaced with the name of the source file,
# and $$OutName is replaced with the name of the target file. # and $$o is replaced with the name of the target file.
# The flags argument is a list of comma separated flags. # The flags argument is a list of comma separated flags.
# Known flags are # Known flags are
# - * : copy the previously defined flags # - * : copy the previously defined flags
# - importer : The converter is used for importing.
# - latex : The converter is latex or its derivatives (pdflatex). # - latex : The converter is latex or its derivatives (pdflatex).
# - originaldir : The converter must be invoked in the directory of the lyx # - originaldir : The converter must be invoked in the directory of the lyx
# file and not in the temporary directory. This is needed for tex->html # file and not in the temporary directory. This is needed for tex->html
@ -354,26 +353,24 @@
# - needaux : The converted uses the .aux file, so we need to call latex # - needaux : The converted uses the .aux file, so we need to call latex
# before running the converter. # before running the converter.
# - resultdir=dir : The converter put all the files in dir. # - resultdir=dir : The converter put all the files in dir.
# Using "resultdir" is same as "resultdir=$$Basename". # Using "resultdir" is same as "resultdir=$$b".
# Note: When exporting, the whole directory will be moved from the temporary # Note: When exporting, the whole directory will be moved from the temporary
# directory to the target directory. # directory to the target directory.
# - resultfile=file : Name of main file in the result directory, for example # - resultfile=file : Name of main file in the result directory, for example
# "index.html" or "$$BaseName.html" # "index.html" or "$$b.html"
# If "resultfile" is omitted, the name of this file is assumed to be # If "resultfile" is omitted, the name of this file is assumed to be
# "index.format" # "index.format"
# - parselog=filtername : filtername is a name of a filter command that takes # - parselog=filtername : filtername is a name of a filter command that takes
# the converter error log (from stderr), and converts it to a fake latex .log # the converter error log (from stderr), and converts it to a fake latex .log
# file. # file.
# - disable=backends : A list of & seperated backend in which the converter
# should not be used.
# For example: # For example:
#\converter latex html "latex2html -split 0 $$FName" #\converter latex html "latex2html -split 0 $$i"
# "originaldir,needaux,resultdir,disable=linuxdoc&docbook" # "originaldir,needaux,resultdir"
# #
# For literate programming, use something like # For literate programming, use something like
#\converter literate latex "noweave -delay -index $$FName >$$OutName" #\converter literate latex "noweave -delay -index $$i >$$o"
# "parselog=listerrors g" # "parselog=listerrors g"
#\converter literate program "build-script $$FName" #\converter literate program "build-script $$i"
# "originaldir,parselog=listerrors g" # "originaldir,parselog=listerrors g"
# The format command is used to define file formats. It has 4 arguments: # The format command is used to define file formats. It has 4 arguments:
@ -459,28 +456,6 @@
# Default is "". # Default is "".
#\backupdir_path "~/Desktop/Trash/" #\backupdir_path "~/Desktop/Trash/"
#
# FAX SECTION #############################################################
#
# In the following, the <$$something> strings are substituted by
# reasonable values by LyX. The 's are important as there may be spaces in
# the string. The default is auto-detected.
# This one is what is used with HylaFax:
#\fax_command "sendfax -n -h '$$Host' -c '$$Comment' -x '$$Enterprise' -d '$$Name'@'$$Phone' '$$FName'"
# Use this for the efax-command:
#\fax_command "faxsend '$$Phone' '$$FName'"
# This is the name of your phone book. It's per default situated in ~/.lyx/,
# but you can override that with an absolute path.
#\phone_book phonebook
# This is how to call an external FAX-program instead of the built-in.
# You may also insert $$FName to reference the PostScript file.
#\fax_program "myfaxprg '$$FName'"
#\fax_program tkhylafax
# #
# ASCII EXPORT SECTION ################################################### # ASCII EXPORT SECTION ###################################################
# #

View File

@ -45,11 +45,11 @@ Menuset
Item "Close|C" "buffer-close" Item "Close|C" "buffer-close"
Item "Save|S" "buffer-write" Item "Save|S" "buffer-write"
Item "Save As...|A" "buffer-write-as" Item "Save As...|A" "buffer-write-as"
Item "Revert to saved|R" "buffer-reload" Item "Revert to saved|d" "buffer-reload"
Submenu "Version control|V" "file_vc" Submenu "Version control|V" "file_vc"
Separator Separator
Submenu "Import|m" "file_import" Submenu "Import|I" "file_import"
Submenu "Insert|I" "file_insert" Submenu "Insert|r" "file_insert"
Separator Separator
Submenu "Export|E" "file_export" Submenu "Export|E" "file_export"
Item "Print...|P" "buffer-print" Item "Print...|P" "buffer-print"
@ -70,8 +70,6 @@ Menuset
End End
Menu "file_import" Menu "file_import"
Item "Ascii text as lines...|A" "buffer-import text"
Item "Ascii text as paragraphs...|p" "buffer-import textparagraph"
ImportFormats ImportFormats
End End
@ -98,23 +96,23 @@ Menuset
Menu "edit" Menu "edit"
Item "Undo|U" "undo" Item "Undo|U" "undo"
Item "Redo|R" "redo" Item "Redo|d" "redo"
Separator Separator
Item "Cut|C" "cut" Item "Cut|C" "cut"
Item "Copy|o" "copy" Item "Copy|o" "copy"
Item "Paste|P" "paste" Item "Paste|a" "paste"
Submenu "Paste external selection|x" "edit_paste" Submenu "Paste external selection|x" "edit_paste"
Separator Separator
Item "Find & Replace...|F" "find-replace" Item "Find & Replace...|F" "find-replace"
Separator
Submenu "Tabular|T" "edit_tabular" Submenu "Tabular|T" "edit_tabular"
Submenu "Floats & Insets|I" "edit_floats" Submenu "Floats & Insets|I" "edit_floats"
Separator
Item "Spellchecker...|S" "spellchecker" Item "Spellchecker...|S" "spellchecker"
Item "Check TeX|h" "buffer-chktex" Item "Check TeX|h" "buffer-chktex"
Item "Remove all Error boxes|E" "error-remove-all" Item "Remove all Error boxes|E" "error-remove-all"
Separator Separator
Item "Preferences...|n" "dialog-preferences" Item "Preferences...|P" "dialog-preferences"
Item "Reconfigure|g" "reconfigure" Item "Reconfigure|R" "reconfigure"
End End
Menu "edit_paste" Menu "edit_paste"
@ -158,7 +156,7 @@ Menuset
# INSERT MENU # INSERT MENU
# #
Menu "insert" Menu "insert"
Item "Math text|M" "math-mode" Item "Math text|t" "math-mode"
Item "Math display|d" "math-display" Item "Math display|d" "math-display"
Item "Math panel...|p" "math-panel" Item "Math panel...|p" "math-panel"
Separator Separator
@ -167,17 +165,17 @@ Menuset
Item "Cross reference...|r" "reference-insert" Item "Cross reference...|r" "reference-insert"
Item "Label...|L" "label-insert" Item "Label...|L" "label-insert"
Item "Footnote|F" "footnote-insert" Item "Footnote|F" "footnote-insert"
Item "Marginal note|n" "marginpar-insert" Item "Marginal note|M" "marginpar-insert"
Item "Index entry...|x" "index-insert" Item "Index entry...|I" "index-insert"
Item "Index entry of last word|w" "index-insert-last" Item "Index entry of last word|w" "index-insert-last"
Item "URL...|U" "url-insert" Item "URL...|U" "url-insert"
Item "Note...|o" "note-insert" Item "Note...|N" "note-insert"
Separator Separator
Item "Figure...|g" "figure-insert" Item "Figure...|g" "figure-insert"
Item "Tabular...|T" "dialog-tabular-insert" Item "Tabular...|b" "dialog-tabular-insert"
Submenu "Floats|a" "insert_floats" Submenu "Floats|a" "insert_floats"
Separator Separator
Submenu "Lists & TOC|i" "insert_toc" Submenu "Lists & TOC|O" "insert_toc"
End End
Menu "insert_special" Menu "insert_special"

View File

@ -11,6 +11,7 @@ src/credits.C
src/credits_form.C src/credits_form.C
src/CutAndPaste.C src/CutAndPaste.C
src/exporter.C src/exporter.C
src/ext_l10n.h
src/filedlg.C src/filedlg.C
src/FontLoader.C src/FontLoader.C
src/form1.C src/form1.C

View File

@ -25,6 +25,7 @@
#include "bufferlist.h" #include "bufferlist.h"
#include "converter.h" #include "converter.h"
#include "exporter.h" #include "exporter.h"
#include "importer.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
@ -199,11 +200,6 @@ Menu & Menu::read(LyXLex & lex)
return *this; return *this;
} }
struct compare_formatpair {
bool operator()(FormatPair const & a, FormatPair const & b) {
return a.format->prettyname < b.format->prettyname;
}
};
void Menu::checkShortcuts() const void Menu::checkShortcuts() const
{ {
@ -273,66 +269,45 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const
} }
break; break;
case MenuItem::ImportFormats:
case MenuItem::ViewFormats: case MenuItem::ViewFormats:
case MenuItem::UpdateFormats: case MenuItem::UpdateFormats:
case MenuItem::ExportFormats: { case MenuItem::ExportFormats: {
vector<FormatPair> names; vector<Format const *> formats;
kb_action action; kb_action action;
if ((*cit).kind() == MenuItem::ViewFormats) { switch ((*cit).kind()) {
names = Exporter::GetExportableFormats(buf, true); case MenuItem::ImportFormats:
formats = Importer::GetImportableFormats();
action = LFUN_IMPORT;
break;
case MenuItem::ViewFormats:
formats = Exporter::GetExportableFormats(buf, true);
action = LFUN_PREVIEW; action = LFUN_PREVIEW;
} else if ((*cit).kind() == MenuItem::UpdateFormats) { break;
names = Exporter::GetExportableFormats(buf, true); case MenuItem::UpdateFormats:
formats = Exporter::GetExportableFormats(buf, true);
action = LFUN_UPDATE; action = LFUN_UPDATE;
} else { break;
names = Exporter::GetExportableFormats(buf, false); default:
formats = Exporter::GetExportableFormats(buf, false);
action = LFUN_EXPORT; action = LFUN_EXPORT;
} }
sort(names.begin(), names.end(), compare_formatpair()); sort(formats.begin(), formats.end());
for (vector<FormatPair>::const_iterator fit = names.begin(); for (vector<Format const *>::const_iterator fit = formats.begin();
fit != names.end() ; ++fit) { fit != formats.end() ; ++fit) {
if ((*fit).format->dummy()) if ((*fit)->dummy())
continue; continue;
string fmt = (*fit).format->name; string label = (*fit)->prettyname();
string label = (*fit).format->prettyname; if ((*cit).kind() == MenuItem::ImportFormats)
bool same_before = if ((*fit)->name() == "text")
fit != names.begin() && label = _("Ascii text as lines");
(*fit).format == (*(fit-1)).format; else if ((*fit)->name() == "textparagraph")
bool same_after = label = _("Ascii text as paragraphs");
fit+1 != names.end() && if (!(*fit)->shortcut().empty())
(*fit).format == (*(fit+1)).format; label += "|" + (*fit)->shortcut();
if ((*fit).from && int action2 = lyxaction.
(same_before || same_after)) { getPseudoAction(action, (*fit)->name());
fmt += ":" + (*fit).from->name;
string head;
split((*fit).command, head, ' ');
label += _(" (using ") + head + ")";
if (!(*fit).format->shortcut.empty() &&
!same_before)
label += "|" + (*fit).format->shortcut;
} else if (!(*fit).format->shortcut.empty())
label += "|" + (*fit).format->shortcut;
int action2 = lyxaction.getPseudoAction(action, fmt);
tomenu.add(MenuItem(MenuItem::Command,
label, action2));
}
}
break;
case MenuItem::ImportFormats: {
vector<FormatPair> names = Converter::GetReachableTo("lyx");
sort(names.begin(), names.end(), compare_formatpair());
for (vector<FormatPair>::const_iterator fit = names.begin();
fit != names.end() ; ++fit) {
if ((*fit).format->dummy())
continue;
string fmt = (*fit).format->name;
string label = (*fit).format->prettyname;
if (!(*fit).format->shortcut.empty())
label += "|" + (*fit).format->shortcut;
int action2 = lyxaction.getPseudoAction(LFUN_IMPORT, fmt);
tomenu.add(MenuItem(MenuItem::Command, tomenu.add(MenuItem(MenuItem::Command,
label, action2)); label, action2));
} }

View File

@ -3547,6 +3547,9 @@ vector<string> const Buffer::getLabelList()
vector<vector<Buffer::TocItem> > const Buffer::getTocList() vector<vector<Buffer::TocItem> > const Buffer::getTocList()
{ {
int figs = 0;
int tables = 0;
int algs = 0;
vector<vector<TocItem> > l(4); vector<vector<TocItem> > l(4);
LyXParagraph * par = paragraph; LyXParagraph * par = paragraph;
while (par) { while (par) {
@ -3562,13 +3565,19 @@ vector<vector<Buffer::TocItem> > const Buffer::getTocList()
switch (par->footnotekind) { switch (par->footnotekind) {
case LyXParagraph::FIG: case LyXParagraph::FIG:
case LyXParagraph::WIDE_FIG: case LyXParagraph::WIDE_FIG:
tmp.str = tostr(++figs) + ". "
+ tmp.str;
l[TOC_LOF].push_back(tmp); l[TOC_LOF].push_back(tmp);
break; break;
case LyXParagraph::TAB: case LyXParagraph::TAB:
case LyXParagraph::WIDE_TAB: case LyXParagraph::WIDE_TAB:
tmp.str = tostr(++tables) + ". "
+ tmp.str;
l[TOC_LOT].push_back(tmp); l[TOC_LOT].push_back(tmp);
break; break;
case LyXParagraph::ALGORITHM: case LyXParagraph::ALGORITHM:
tmp.str = tostr(++algs) + ". "
+ tmp.str;
l[TOC_LOA].push_back(tmp); l[TOC_LOA].push_back(tmp);
break; break;
case LyXParagraph::FOOTNOTE: case LyXParagraph::FOOTNOTE:

File diff suppressed because it is too large Load Diff

View File

@ -16,58 +16,142 @@
#pragma interface #pragma interface
#endif #endif
#include <map>
#include <vector> #include <vector>
#include <queue>
#include "LString.h" #include "LString.h"
#include "support/lstrings.h"
class Buffer; class Buffer;
/// ///
class Format { class Format {
public: public:
///
Format() {}
/// ///
Format(string const & n, string const & e, string const & p, Format(string const & n, string const & e, string const & p,
string const & s, string const & v) : string const & s, string const & v) :
name(n), extension(e), prettyname(p), shortcut(s), name_(n), extension_(e), prettyname_(p), shortcut_(s),
viewer(v) {}; viewer_(v) {};
///
string name;
///
string extension;
///
string prettyname;
///
string shortcut;
///
string viewer;
/// ///
bool dummy() const; bool dummy() const;
/// ///
string const getname() const { bool IsChildFormat() const;
return name; ///
string const ParentFormat() const;
///
string const & name() const {
return name_;
} }
/// ///
string const getprettyname() const { string const & extension() const {
return prettyname; return extension_;
} }
///
string const & prettyname() const {
return prettyname_;
}
///
string const & shortcut() const {
return shortcut_;
}
///
string const & viewer() const {
return viewer_;
}
///
void setViewer(string const & v) {
viewer_ = v;
}
friend bool operator<(Format const & a, Format const & b) {
return compare_no_case(a.prettyname(),b.prettyname()) < 0;
}
private:
string name_;
///
string extension_;
///
string prettyname_;
///
string shortcut_;
///
string viewer_;
}; };
/// ///
struct Command { class Formats {
public:
///
typedef std::vector<Format> FormatList;
/// ///
Command(Format const * f, Format const * t, string const & c) typedef FormatList::const_iterator const_iterator;
: from(f), to(t), command(c), importer(false), ///
Format const & Get(int i) const {
return formatlist[i];
}
///
Format const * GetFormat(string const & name) const;
///
int GetNumber(string const & name) const;
///
void Add(string const & name);
///
void Add(string const & name, string const & extension,
string const & prettyname, string const & shortcut);
///
void Delete(string const & name);
///
void Sort();
///
void SetViewer(string const & name, string const & command);
///
bool View(Buffer const * buffer, string const & filename,
string const & format_name) const;
///
string const PrettyName(string const & name) const;
///
string const Extension(string const & name) const;
///
const_iterator begin() const {
return formatlist.begin();
}
///
const_iterator end() const {
return formatlist.end();
}
///
FormatList::size_type size() const {
return formatlist.size();
}
private:
///
FormatList formatlist;
};
///////////////////////////////////////////////////////////////////////
///
class Converter {
public:
///
Converter(string const & f, string const & t, string const & c,
string const & l)
: from(f), to(t), command(c), flags(l), From(0), To(0),
latex(false), original_dir(false), need_aux(false) {} latex(false), original_dir(false), need_aux(false) {}
/// ///
Format const * from; void ReadFlags();
/// ///
Format const * to; string from;
///
string to;
/// ///
string command; string command;
/// The converter is used for importing ///
bool importer; string flags;
///
Format const * From;
///
Format const * To;
/// The converter is latex or its derivatives /// The converter is latex or its derivatives
bool latex; bool latex;
/// Do we need to run the converter in the original directory? /// Do we need to run the converter in the original directory?
@ -82,123 +166,104 @@ struct Command {
string result_file; string result_file;
/// Command to convert the program output to a LaTeX log file format /// Command to convert the program output to a LaTeX log file format
string parselog; string parselog;
/// Backends in which the converter is not used };
std::vector<string> disable;
/// Used by the BFS algorithm
bool visited; ///
/// Used by the BFS algorithm class Converters {
std::vector<Command>::iterator previous; public:
typedef std::vector<Converter> ConverterList;
/// ///
std::pair<string, string> const getFromToPrettyname() const { typedef ConverterList::const_iterator const_iterator;
return std::pair<string, string>(from->prettyname, ///
to->prettyname); typedef std::vector<int> EdgePath;
///
Converter const & Get(int i) const {
return converterlist[i];
} }
};
class FormatPair {
public:
/// ///
Format const * format; Converter const * GetConverter(string const & from, string const & to);
/// ///
Format const * from; int GetNumber(string const & from, string const & to);
/// ///
string command;
///
FormatPair(Format const * f1, Format const * f2, string c)
: format(f1), from(f2), command(c) {}
};
///
class Formats {
public:
///
typedef std::map<string, Format> FormatList;
///
void Add(string const & name);
///
void Add(string const & name, string const & extension,
string const & prettyname, string const & shortcut);
///
void SetViewer(string const & name, string const & command);
///
bool View(Buffer const * buffer, string const & filename,
string const & format_name);
///
Format * GetFormat(string const & name);
///
string const PrettyName(string const & name);
///
string const Extension(string const & name);
///
std::vector<Format> const GetAllFormats() const;
private:
///
FormatList formats;
};
///
class Converter {
public:
///
static
void Add(string const & from, string const & to, void Add(string const & from, string const & to,
string const & command, string const & flags); string const & command, string const & flags);
//
void Delete(string const & from, string const & to);
/// ///
static void Sort();
std::vector<FormatPair> const GetReachableTo(string const & target);
/// ///
static std::vector<Format const *> const
std::vector<FormatPair> const GetReachableTo(string const & target, bool clear_visited);
GetReachable(string const & from, bool only_viewable); ///
std::vector<Format const *> const
GetReachable(string const & from, bool only_viewable,
bool clear_visited);
/// ///
static
bool IsReachable(string const & from, string const & to); bool IsReachable(string const & from, string const & to);
/// ///
static EdgePath const GetPath(string const & from, string const & to);
///
bool UsePdflatex(EdgePath const & path);
///
bool Convert(Buffer const * buffer, bool Convert(Buffer const * buffer,
string const & from_file, string const & to_file_base, string const & from_file, string const & to_file_base,
string const & from_format, string const & to_format, string const & from_format, string const & to_format,
string const & using_format, string & to_file); string & to_file);
/// ///
static
bool Convert(Buffer const * buffer, bool Convert(Buffer const * buffer,
string const & from_file, string const & to_file_base, string const & from_file, string const & to_file_base,
string const & from_format, string const & to_format, string const & from_format, string const & to_format);
string const & using_format = string());
/// ///
static
string const SplitFormat(string const & str, string & format);
///
static
string const dvi_papersize(Buffer const * buffer); string const dvi_papersize(Buffer const * buffer);
/// ///
static
string const dvips_options(Buffer const * buffer); string const dvips_options(Buffer const * buffer);
/// ///
static void Update(Formats const & formats);
void init();
/// ///
static void UpdateLast(Formats const & formats);
std::vector<Command> const GetAllCommands(); ///
void BuildGraph();
///
bool FormatIsUsed(string const & format);
///
const_iterator begin() const {
return converterlist.begin();
}
const_iterator end() const {
return converterlist.end();
}
private: private:
/// ///
static
bool scanLog(Buffer const * buffer, string const & command, bool scanLog(Buffer const * buffer, string const & command,
string const & filename); string const & filename);
/// ///
static
bool runLaTeX(Buffer const * buffer, string const & command); bool runLaTeX(Buffer const * buffer, string const & command);
/// ///
static ConverterList converterlist;
std::vector<Command> commands; ///
string latex_command;
///
struct Vertex {
std::vector<int> in_vertices;
std::vector<int> out_vertices;
std::vector<int> out_edges;
};
/// ///
static static
string latex_command; std::vector<Vertex> vertices;
///
std::vector<bool> visited;
///
std::queue<int> Q;
///
int BFS_init(string const & start, bool clear_visited = true);
}; };
extern Formats formats; extern Formats formats;
extern Formats system_formats; extern Converters converters;
extern Formats system_formats;
extern Converters system_converters;
#endif #endif

View File

@ -14,24 +14,43 @@
#pragma implementation #pragma implementation
#endif #endif
#include <algorithm>
#include "exporter.h" #include "exporter.h"
#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" #include "lyxrc.h"
#include "converter.h" #include "converter.h"
#include "lyx_gui_misc.h" //WriteAlert
using std::vector; using std::vector;
using std::find;
bool Exporter::Export(Buffer * buffer, string const & format0, bool Exporter::Export(Buffer * buffer, string const & format,
bool put_in_tempdir, string & result_file) bool put_in_tempdir, string & result_file)
{ {
string format; string backend_format;
string using_format = Converter::SplitFormat(format0, format); vector<string> backends = Backends(buffer);
if (find(backends.begin(), backends.end(), format) == backends.end()) {
string backend_format = (format == "text") for (vector<string>::const_iterator it = backends.begin();
? format : BufferFormat(buffer); it != backends.end(); ++it) {
bool only_backend = backend_format == format; Converters::EdgePath p =
converters.GetPath(*it, format);
if (!p.empty()) {
lyxrc.pdf_mode = converters.UsePdflatex(p);
backend_format = *it;
break;
}
}
if (backend_format.empty()) {
WriteAlert(_("Can not export file"),
_("No information for exporting to ")
+ formats.PrettyName(format));
return false;
}
} else
backend_format = format;
string filename = buffer->getLatexName(false); string filename = buffer->getLatexName(false);
if (!buffer->tmppath.empty()) if (!buffer->tmppath.empty())
@ -49,7 +68,7 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
else if (buffer->isDocBook()) else if (buffer->isDocBook())
buffer->makeDocBookFile(filename, true); buffer->makeDocBookFile(filename, true);
// LaTeX backend // LaTeX backend
else if (only_backend) else if (backend_format == format)
buffer->makeLaTeXFile(filename, string(), true); buffer->makeLaTeXFile(filename, string(), true);
else else
buffer->makeLaTeXFile(filename, buffer->filepath, false); buffer->makeLaTeXFile(filename, buffer->filepath, false);
@ -57,9 +76,8 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
string outfile_base = (put_in_tempdir) string outfile_base = (put_in_tempdir)
? filename : buffer->getLatexName(false); ? filename : buffer->getLatexName(false);
if (!Converter::Convert(buffer, filename, outfile_base, if (!converters.Convert(buffer, filename, outfile_base,
backend_format, format, using_format, backend_format, format, result_file))
result_file))
return false; return false;
if (!put_in_tempdir) if (!put_in_tempdir)
@ -78,32 +96,38 @@ bool Exporter::Export(Buffer * buffer, string const & format,
return Export(buffer, format, put_in_tempdir, result_file); return Export(buffer, format, put_in_tempdir, result_file);
} }
bool Exporter::Preview(Buffer * buffer, string const & format0) bool Exporter::Preview(Buffer * buffer, string const & format)
{ {
string result_file; string result_file;
if (!Export(buffer, format0, true, result_file)) if (!Export(buffer, format, true, result_file))
return false; return false;
string format;
Converter::SplitFormat(format0, format);
return formats.View(buffer, result_file, format); return formats.View(buffer, result_file, format);
} }
bool Exporter::IsExportable(Buffer const * buffer, string const & format) bool Exporter::IsExportable(Buffer const * buffer, string const & format)
{ {
return format == "text" || vector<string> backends = Backends(buffer);
Converter::IsReachable(BufferFormat(buffer), format); for (vector<string>::const_iterator it = backends.begin();
it != backends.end(); ++it)
if (converters.IsReachable(*it, format))
return true;
return false;
} }
vector<FormatPair> const vector<Format const *> const
Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable) Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable)
{ {
vector<FormatPair> result = vector<string> backends = Backends(buffer);
Converter::GetReachable(BufferFormat(buffer), only_viewable); vector<Format const *> result =
Format * format = formats.GetFormat("text"); converters.GetReachable(backends[0], only_viewable, true);
if (format && (!only_viewable || !format->viewer.empty())) for (vector<string>::const_iterator it = backends.begin() + 1;
result.push_back(FormatPair(format , 0, "")); it != backends.end(); ++it) {
vector<Format const *> r =
converters.GetReachable(*it, only_viewable, false);
result.insert(result.end(), r.begin(), r.end());
}
return result; return result;
} }
@ -119,3 +143,11 @@ string const Exporter::BufferFormat(Buffer const * buffer)
else else
return "latex"; return "latex";
} }
vector<string> const Exporter::Backends(Buffer const * buffer)
{
vector<string> v;
v.push_back(BufferFormat(buffer));
v.push_back("text");
return v;
}

View File

@ -20,7 +20,7 @@
#include "LString.h" #include "LString.h"
class Buffer; class Buffer;
class FormatPair; class Format;
class Exporter { class Exporter {
public: public:
@ -40,12 +40,14 @@ public:
bool IsExportable(Buffer const * buffer, string const & format); bool IsExportable(Buffer const * buffer, string const & format);
/// ///
static static
std::vector<FormatPair> const std::vector<Format const *> const
GetExportableFormats(Buffer const * buffer, bool only_viewable); GetExportableFormats(Buffer const * buffer, bool only_viewable);
/// ///
private:
///
static static
string const BufferFormat(Buffer const * buffer); string const BufferFormat(Buffer const * buffer);
///
static
std::vector<string> const Backends(Buffer const * buffer);
}; };
#endif #endif

View File

@ -103,7 +103,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
command += lyxrc.print_extra_options + ' '; command += lyxrc.print_extra_options + ' ';
} }
command += Converter::dvips_options(buffer) + ' '; command += converters.dvips_options(buffer) + ' ';
if (!Exporter::Export(buffer, "dvi", true)) if (!Exporter::Export(buffer, "dvi", true))
return false; return false;

View File

@ -10,6 +10,7 @@
*======================================================*/ *======================================================*/
#include <config.h> #include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG_ #ifdef __GNUG_
#pragma implementation #pragma implementation
@ -17,14 +18,17 @@
#include <algorithm> // max #include <algorithm> // max
#include <cmath> // floor #include <cmath> // floor
#include <fstream> // ofstream
#include "Color.h" #include "Color.h"
#include "lyxlex.h"
using std::max; using std::max;
using std::min; using std::min;
using std::ofstream;
static int const nohue = -1; static int const nohue = -1;
RGB::RGB( HSV const & hsv ) RGBColor::RGBColor( HSVColor const & hsv )
{ {
double h = hsv.h; double h = hsv.h;
double s = hsv.s; double s = hsv.s;
@ -91,7 +95,7 @@ RGB::RGB( HSV const & hsv )
} }
HSV::HSV( RGB const & rgb ) HSVColor::HSVColor( RGBColor const & rgb )
{ {
// r, g, b lie in the range 0-1, not 0-255. // r, g, b lie in the range 0-1, not 0-255.
double r = rgb.r / 255.0; double r = rgb.r / 255.0;
@ -128,3 +132,91 @@ HSV::HSV( RGB const & rgb )
} }
} }
// sorted by hand to prevent LyXLex from complaining on read().
static
keyword_item xformTags[] = {
// { "\\gui_active_tab", FL_LIGHTER_COL1 },
{ "\\gui_background", FL_COL1 },
{ "\\gui_buttonbottom", FL_BOTTOM_BCOL },
{ "\\gui_buttonleft", FL_LEFT_BCOL },
{ "\\gui_buttonright", FL_RIGHT_BCOL },
{ "\\gui_buttontop", FL_TOP_BCOL },
{ "\\gui_inactive", FL_INACTIVE },
{ "\\gui_push_button", FL_YELLOW },
{ "\\gui_selected", FL_MCOL },
{ "\\gui_text", FL_BLACK }
};
static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
bool XformColor::read(string const & filename)
{
LyXLex lexrc( xformTags, xformCount );
if( !lexrc.setFile( filename ) )
return false;
while( lexrc.IsOK() ) {
int le = lexrc.lex();
switch( le ) {
case LyXLex::LEX_UNDEF:
lexrc.printError("Unknown tag `$$Token'");
continue;
case LyXLex::LEX_FEOF:
continue;
default: break;
}
RGBColor col;
if( !lexrc.next() ) break;
col.r = lexrc.GetInteger();
if( !lexrc.next() ) break;
col.g = lexrc.GetInteger();
if( !lexrc.next() ) break;
col.b = lexrc.GetInteger();
fl_mapcolor(le, col.r, col.g, col.b);
}
return true;
}
bool XformColor::write(string const & filename)
{
ofstream os(filename.c_str());
if (!os)
return false;
os << "### This file is part of\n"
<< "### ========================================================\n"
<< "### LyX, The Document Processor\n"
<< "###\n"
<< "### Copyright 1995 Matthias Ettrich\n"
<< "### Copyright 1995-2000 The LyX Team.\n"
<< "###\n"
<< "### ========================================================\n"
<< "\n"
<< "# This file is written by LyX, if you want to make your own\n"
<< "# modifications you should do them from inside LyX and save\n"
<< "\n";
for( int i = 0; i < xformCount; ++i ) {
string tag = xformTags[i].tag;
int colorID = xformTags[i].code;
RGBColor color;
fl_getmcolor(colorID, &color.r, &color.g, &color.b);
os << tag + " "
<< color.r << " " << color.g << " " << color.b << "\n";
}
return true;
}

View File

@ -12,7 +12,7 @@
#ifndef COLOR_H #ifndef COLOR_H
#define COLOR_H #define COLOR_H
#include<utility> // for pair #include <utility> // for pair
#ifdef __GNUG_ #ifdef __GNUG_
#pragma interface #pragma interface
@ -20,47 +20,49 @@
#include "LString.h" #include "LString.h"
class HSV; class HSVColor;
class RGB; class RGBColor;
struct HSV { struct HSVColor {
double h; double h;
double s; double s;
double v; double v;
HSV() : h(0.0), s(0.0), v(0.0) {} HSVColor() : h(0.0), s(0.0), v(0.0) {}
HSV(double hue, double sat, double val) : h(hue), s(sat), v(val) {} HSVColor(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
HSV( RGB const & ); HSVColor( RGBColor const & );
}; };
struct RGB { struct RGBColor {
int r; int r;
int g; int g;
int b; int b;
RGB() : r(0), g(0), b(0) {} RGBColor() : r(0), g(0), b(0) {}
RGB(int red, int green, int blue) : r(red), g(green), b(blue) {} RGBColor(int red, int green, int blue) : r(red), g(green), b(blue) {}
RGB( HSV const & ); RGBColor( HSVColor const & );
}; };
typedef std::pair<string, RGB> X11Color; typedef std::pair<string, RGBColor> X11Color;
/// struct holding xform-specific colors /// struct holding xform-specific colors
struct XFormColor { struct XformColor {
string name; string name;
int colorID; int colorID;
RGB col; RGBColor col;
XFormColor() : colorID(0) {} XformColor() : colorID(0) {}
string const getname() { return name; } string const getname() { return name; }
static bool read( string const & );
static bool write( string const & );
}; };
inline inline
bool operator==(RGB const & c1, RGB const & c2) bool operator==(RGBColor const & c1, RGBColor const & c2)
{ {
return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b); return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
} }
inline inline
bool operator!=(RGB const & c1, RGB const & c2) bool operator!=(RGBColor const & c1, RGBColor const & c2)
{ {
return !(c1 == c2); return !(c1 == c2);
} }

View File

@ -1,5 +1,15 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ======================================================
*/
#include <config.h> #include <config.h>
#include FORMS_H_LOCATION
#include "Dialogs.h" #include "Dialogs.h"
#include "FormCitation.h" #include "FormCitation.h"

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,7 @@ struct FD_form_printer;
struct FD_form_screen_fonts; struct FD_form_screen_fonts;
struct FD_form_spellchecker; struct FD_form_spellchecker;
/** This class provides an XForms implementation of the FormPreferences Dialog. /** This class provides an XForms implementation of the FormPreferences Dialog.
The preferences dialog allows users to set/save their preferences. The preferences dialog allows users to set/save their preferences.
*/ */
@ -88,7 +89,7 @@ private:
*/ */
/// ///
void applyColors() const; void applyColors(); // not const as modifies modifiedXformPrefs.
/// ///
void applyConverters() const; void applyConverters() const;
/// ///
@ -224,6 +225,8 @@ private:
/// ///
bool ColorsBrowserX11() const; bool ColorsBrowserX11() const;
/// ///
bool ColorsBrowseDatabase() const;
///
bool ColorsDatabase() const; bool ColorsDatabase() const;
/// ///
void ColorsLoadBrowserLyX(); void ColorsLoadBrowserLyX();
@ -234,30 +237,30 @@ private:
/// ///
bool ColorsRGB() const; bool ColorsRGB() const;
/// ///
int ColorsSearchEntry(RGB const &) const; int ColorsSearchEntry(RGBColor const &) const;
/// ///
bool ConvertersAdd(); bool ConvertersAdd();
/// ///
bool ConvertersBrowser(); bool ConvertersBrowser();
/// ///
void ConvertersClear() const; void ConvertersUpdateBrowser();
///
bool ConvertersContainFormat( Format const &) const;
/// ///
bool ConvertersDelete(); bool ConvertersDelete();
/// ///
bool ConvertersInput(); bool ConvertersInput();
/// ///
bool ConvertersSetCommand( Command & ) const; string const ConverterGetFrom() const;
/// ///
void ConvertersUpdateChoices(); string const ConverterGetTo() const;
///
void ConvertersUpdateChoices() const;
bool FormatsAdd(); bool FormatsAdd();
/// ///
bool FormatsBrowser(); bool FormatsBrowser();
/// ///
void FormatsClear() const; void FormatsUpdateBrowser();
/// ///
bool FormatsDelete(); bool FormatsDelete();
/// ///
@ -347,22 +350,21 @@ private:
/// ///
Combox * combo_kbmap_2; Combox * combo_kbmap_2;
/// A vector of Formats, to be manipulated in the Format browser.
std::vector<Format> formats_vec;
/// A vector of Commands, to be manipulated in the Converter browser.
std::vector<Command> commands_vec;
/// A vector of RGB colors and associated name. /// A vector of RGB colors and associated name.
static std::vector<X11Color> colorDB; static std::vector<X11Color> colorDB;
/// A vector of xform RGB colors and associated name. /// A vector of xform RGB colors and associated name.
static std::vector<XFormColor> xformColorDB; static std::vector<XformColor> xformColorDB;
/** A collection of kmap files. /** A collection of kmap files.
First entry is the file name, full path. First entry is the file name, full path.
Second entry is the shorthand, as appears in the fl_choice. Second entry is the shorthand, as appears in the fl_choice.
Eg, system_lyxdir/kbd/american2.kmap, american2 Eg, system_lyxdir/kbd/american2.kmap, american2
*/ */
static std::pair<std::vector<string>, std::vector<string> > dirlist; static std::pair<std::vector<string>, std::vector<string> > dirlist;
/// /** Flag whether a warning has been posted to the text window.
If so, don't redraw the window when the mouse leaves an object. */
bool warningPosted; bool warningPosted;
/// Flag whether Xforms colors have been changed since last file save.
bool modifiedXformPrefs;
}; };
#endif #endif

View File

@ -14,6 +14,8 @@
#pragma implementation #pragma implementation
#endif #endif
#include <algorithm>
#include "importer.h" #include "importer.h"
#include "converter.h" #include "converter.h"
#include "LyXView.h" #include "LyXView.h"
@ -21,12 +23,16 @@
#include "minibuffer.h" #include "minibuffer.h"
#include "bufferlist.h" #include "bufferlist.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "lyx_gui_misc.h" //WriteAlert
using std::vector;
using std::find;
extern BufferList bufferlist; extern BufferList bufferlist;
extern void InsertAsciiFile(BufferView *, string const &, bool); extern void InsertAsciiFile(BufferView *, string const &, bool);
void Importer::Import(LyXView * lv, string const & filename, bool Importer::Import(LyXView * lv, string const & filename,
string const & format) string const & format)
{ {
string displaypath = MakeDisplayPath(filename); string displaypath = MakeDisplayPath(filename);
@ -34,36 +40,80 @@ void Importer::Import(LyXView * lv, string const & filename,
string lyxfile = ChangeExtension(filename, ".lyx"); string lyxfile = ChangeExtension(filename, ".lyx");
bool result = true; string loader_format;
if (format == "text" || format == "textparagraph") { vector<string> loaders = Loaders();
lv->view()->buffer(bufferlist.newFile(lyxfile, string(), true)); if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
bool as_paragraphs = format == "textparagraph"; for (vector<string>::const_iterator it = loaders.begin();
InsertAsciiFile(lv->view(), filename, as_paragraphs); it != loaders.end(); ++it) {
lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF); if (converters.IsReachable(format, *it)) {
} else { if (!converters.Convert(0, filename, filename,
result = Converter::Convert(0, filename, filename, format, "lyx"); format, *it))
if (result) { return false;
Buffer * buffer = bufferlist.loadLyXFile(lyxfile); loader_format = *it;
if (buffer) break;
lv->view()->buffer(buffer); }
else
result = false;
} }
if (loader_format.empty()) {
WriteAlert(_("Can not import file"),
_("No information for importing from ")
+ formats.PrettyName(format));
return false;
}
} else
loader_format = format;
if (loader_format == "lyx") {
Buffer * buffer = bufferlist.loadLyXFile(lyxfile);
if (buffer)
lv->view()->buffer(buffer);
} else {
lv->view()->buffer(bufferlist.newFile(lyxfile, string(), true));
bool as_paragraphs = loader_format == "textparagraph";
string filename2 = (loader_format == format) ? filename
: ChangeExtension(filename,
formats.Extension(loader_format));
InsertAsciiFile(lv->view(), filename2, as_paragraphs);
lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF);
} }
// we are done // we are done
if (result) lv->getMiniBuffer()->Set(displaypath, _("imported."));
lv->getMiniBuffer()->Set(displaypath, _("imported.")); return true;
else
lv->getMiniBuffer()->Set(displaypath, _(": import failed."));
} }
#if 0
bool Importer::IsImportable(string const & format) bool Importer::IsImportable(string const & format)
{ {
if (format == "text" || format == "textparagraph") vector<string> loaders = Loaders();
return true; for (vector<string>::const_iterator it = loaders.begin();
else it != loaders.end(); ++it)
return Converter::IsReachable(format, "lyx"); if (converters.IsReachable(format, *it))
return true;
return false;
}
#endif
vector<Format const *> const Importer::GetImportableFormats()
{
vector<string> loaders = Loaders();
vector<Format const *> result =
converters.GetReachableTo(loaders[0], true);
for (vector<string>::const_iterator it = loaders.begin() + 1;
it != loaders.end(); ++it) {
vector<Format const *> r =
converters.GetReachableTo(*it, false);
result.insert(result.end(), r.begin(), r.end());
}
return result;
}
vector<string> const Importer::Loaders()
{
vector<string> v;
v.push_back("lyx");
v.push_back("text");
v.push_back("textparagraph");
return v;
} }

View File

@ -16,17 +16,29 @@
#pragma interface #pragma interface
#endif #endif
#include <vector>
#include "LString.h" #include "LString.h"
class LyXView; class LyXView;
class Format;
class Importer { class Importer {
public: public:
/// ///
static static
void Import(LyXView * lv, string const & filename, bool Import(LyXView * lv, string const & filename,
string const & format); string const & format);
#if 0
///
static static
bool IsImportable(string const & format); bool IsImportable(string const & format);
#endif
///
static
std::vector<Format const *> const GetImportableFormats();
private:
///
static
std::vector<string> const Loaders();
}; };
#endif #endif

View File

@ -657,13 +657,13 @@ int InsetGraphics::Latex(Buffer const *buf, ostream & os,
// How do we decide to what format should we export? // How do we decide to what format should we export?
string extension = GetExtension(params.filename); string extension = GetExtension(params.filename);
//if (pdf) { if (lyxrc.pdf_mode) {
if (extension != "jpg") if (extension != "jpg")
Converter::Convert(buf, converters.Convert(buf,
params.filename, params.filename, params.filename, params.filename,
extension, "png"); extension, "png");
//} else } else
Converter::Convert(buf, params.filename, params.filename, converters.Convert(buf, params.filename, params.filename,
extension, "eps"); extension, "eps");
return 1; return 1;

View File

@ -42,6 +42,7 @@
#include "language.h" #include "language.h"
#include "ColorHandler.h" #include "ColorHandler.h"
#include "frontends/GUIRunTime.h" #include "frontends/GUIRunTime.h"
#include "frontends/xforms/Color.h"
using std::endl; using std::endl;
@ -58,6 +59,7 @@ extern LyXServer * lyxserver;
extern bool finished; // flag, that we are quitting the program extern bool finished; // flag, that we are quitting the program
extern BufferList bufferlist; extern BufferList bufferlist;
extern GUIRunTime guiruntime; extern GUIRunTime guiruntime;
extern string user_lyxdir;
FL_CMD_OPT cmdopt[] = FL_CMD_OPT cmdopt[] =
{ {
@ -368,6 +370,13 @@ void LyXGUI::create_forms()
fl_set_form_atclose(fd_latex_log->LaTeXLog, fl_set_form_atclose(fd_latex_log->LaTeXLog,
CancelCloseBoxCB, 0); CancelCloseBoxCB, 0);
// This is probably as good a time as any to map the xform colours,
// should a mapping exist.
{
string filename = user_lyxdir + "/preferences.xform";
XformColor::read( filename );
}
// Show the main & title form // Show the main & title form
int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE; int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
int title_placement = FL_PLACE_CENTER; int title_placement = FL_PLACE_CENTER;

View File

@ -401,6 +401,7 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
ReadRcFile("lyxrc.defaults"); ReadRcFile("lyxrc.defaults");
system_lyxrc = lyxrc; system_lyxrc = lyxrc;
system_formats = formats; system_formats = formats;
system_converters = converters;
// If there is a preferences file we read that instead // If there is a preferences file we read that instead
// of the old lyxrc file. // of the old lyxrc file.
@ -408,7 +409,8 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
ReadRcFile("lyxrc"); ReadRcFile("lyxrc");
/// Init Converter /// Init Converter
Converter::init(); converters.Update(formats);
converters.BuildGraph();
// Read encodings // Read encodings
ReadEncodingsFile("encodings"); ReadEncodingsFile("encodings");

View File

@ -351,9 +351,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
!Exporter::IsExportable(buf, argument); !Exporter::IsExportable(buf, argument);
break; break;
#endif #endif
case LFUN_IMPORT:
disable = !Importer::IsImportable(argument);
break;
case LFUN_UNDO: case LFUN_UNDO:
disable = buf->undostack.empty(); disable = buf->undostack.empty();
break; break;
@ -3156,8 +3153,7 @@ void LyXFunc::doImport(string const & argument)
AddPath(system_lyxdir, "examples")); AddPath(system_lyxdir, "examples"));
string text = _("Select ") + formats.PrettyName(format) string text = _("Select ") + formats.PrettyName(format)
+ _(" file to import"); + _(" file to import");
string format2 = (format == "textparagraph") ? "text" : format; string extension = "*." + formats.Extension(format);
string extension = "*." + formats.Extension(format2);
filename = fileDlg.Select(text, initpath, extension); filename = fileDlg.Select(text, initpath, extension);
AllowInput(owner->view()); AllowInput(owner->view());

View File

@ -859,7 +859,10 @@ int LyXRC::read(string const & filename)
command = lexrc.GetString(); command = lexrc.GetString();
if (lexrc.next()) if (lexrc.next())
flags = lexrc.GetString(); flags = lexrc.GetString();
Converter::Add(from, to, command, flags); if (command.empty() || command == "none")
converters.Delete(from, to);
else
converters.Add(from, to, command, flags);
break; break;
} }
case RC_VIEWER: { case RC_VIEWER: {
@ -881,7 +884,16 @@ int LyXRC::read(string const & filename)
prettyname = lexrc.GetString(); prettyname = lexrc.GetString();
if (lexrc.next()) if (lexrc.next())
shortcut = lexrc.GetString(); shortcut = lexrc.GetString();
formats.Add(format, extension, prettyname, shortcut); if (prettyname.empty()) {
if (converters.FormatIsUsed(format))
lyxerr << "Can't delete format "
<< format << endl;
else
formats.Delete(format);
} else
formats.Add(format, extension, prettyname,
shortcut);
break; break;
} }
case RC_DEFAULT_LANGUAGE: case RC_DEFAULT_LANGUAGE:
@ -1475,39 +1487,65 @@ void LyXRC::output(ostream & os) const
<< "# FORMATS SECTION ##########################\n" << "# FORMATS SECTION ##########################\n"
<< "#\n\n"; << "#\n\n";
case RC_FORMAT: { case RC_FORMAT:
vector<Format> formats_vec = formats.GetAllFormats(); // Look for deleted formats
vector<Format> sys_formats_vec = system_formats.GetAllFormats(); for (Formats::const_iterator cit = formats.begin();
for (vector<Format>::const_iterator it = formats_vec.begin(); cit != formats.end(); ++cit) {
it != formats_vec.end(); ++it) { Format const * format =
Format const * format = system_formats.GetFormat(it->name); system_formats.GetFormat(cit->name());
if (!format || format->extension != it->extension || if (!format ||
format->prettyname != it->prettyname || format->extension() != cit->extension() ||
format->shortcut != it->shortcut) format->prettyname() != cit->prettyname() ||
os << "\\format \"" << it->name << "\" \"" format->shortcut() != cit->shortcut())
<< it->extension << "\" \"" os << "\\format \"" << cit->name() << "\" \""
<< it->prettyname << "\" \"" << cit->extension() << "\" \""
<< it->shortcut << "\"\n"; << cit->prettyname() << "\" \""
<< cit->shortcut() << "\"\n";
} }
for (vector<Format>::const_iterator it = sys_formats_vec.begin(); // New/modifed formats
it != sys_formats_vec.end(); ++it) for (Formats::const_iterator cit = system_formats.begin();
if (!formats.GetFormat(it->name)) cit != system_formats.end(); ++cit)
os << "\\format \"" << it->name if (!formats.GetFormat(cit->name()))
os << "\\format \"" << cit->name()
<< "\" \"\" \"\" \"\"\n"; << "\" \"\" \"\" \"\"\n";
} case RC_VIEWER:
case RC_VIEWER: { for (Formats::const_iterator cit = formats.begin();
vector<Format> formats_vec = formats.GetAllFormats(); cit != formats.end(); ++cit) {
for (vector<Format>::const_iterator it = formats_vec.begin(); Format const * format =
it != formats_vec.end(); ++it) { system_formats.GetFormat(cit->name());
Format const * format = system_formats.GetFormat(it->name); if ((!format || format->viewer() != cit->viewer()) &&
if ((!format || format->viewer != it->viewer) && (format || !cit->viewer().empty()))
(format || !it->viewer.empty())) os << "\\viewer \"" << cit->name() << "\" \""
os << "\\viewer \"" << it->name << "\" \"" << cit->viewer() << "\"\n";
<< it->viewer << "\"\n";
} }
}
os << "\n#\n"
<< "# CONVERTERS SECTION ##########################\n"
<< "#\n\n";
case RC_CONVERTER:
// Look for new converters
for (Converters::const_iterator cit = converters.begin();
cit != converters.end(); ++cit) {
Converter const * converter =
system_converters.GetConverter(cit->from,
cit->to);
if (!converter ||
converter->command != cit->command ||
converter->flags != cit->flags)
os << "\\converter \"" << cit->from << "\" \""
<< cit->to << "\" \""
<< cit->command << "\" \""
<< cit->flags << "\"\n";
}
// New/modifed converters
for (Converters::const_iterator cit = system_converters.begin();
cit != system_converters.end(); ++cit)
if (!converters.GetConverter(cit->from, cit->to))
os << "\\converter \"" << cit->from
<< "\" \"" << cit->to << "\" \"\" \"\"\n";
} }
os.flush(); os.flush();
} }

View File

@ -7,6 +7,10 @@
bool lyx::rename(string const & from, string const & to) bool lyx::rename(string const & from, string const & to)
{ {
if (::rename(from.c_str(), to.c_str()) == -1) if (::rename(from.c_str(), to.c_str()) == -1)
return lyx::copy(from, to); if (lyx::copy(from, to)) {
lyx::unlink(from);
return true;
} else
return false;
return true; return true;
} }