mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Dekel's import/export patch
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1144 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d7a20664db
commit
8aff605cae
18
ChangeLog
18
ChangeLog
@ -1,3 +1,21 @@
|
||||
2000-10-23 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/converter.h: add a std:: qualifier
|
||||
|
||||
2000-10-21 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* src/importer.[Ch]: New files. Used for importing files into LyX.
|
||||
|
||||
* src/lyxfunc.C (doImport): Use the new Importer class.
|
||||
|
||||
* src/converter.h: Add shortcut member to the Format class.
|
||||
Used for holding the menu shortcut.
|
||||
|
||||
* src/converter.C and other files: Made a distinction between
|
||||
format name and format extension. New formats can be defined using
|
||||
the \format lyxrc tag.
|
||||
Added two new converter flags: latex and disable.
|
||||
|
||||
2000-10-20 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/support/lyxlib.h: unify namespace/struct implementation.
|
||||
|
@ -21,7 +21,7 @@ else
|
||||
lyx=lyx
|
||||
fi
|
||||
|
||||
$lyx --export nw $dir/examples/Literate.lyx
|
||||
$lyx --export literate $dir/examples/Literate.lyx
|
||||
# if no literate support stuff is installed nothing will be output
|
||||
if [ -f $dir/examples/Literate.nw ]
|
||||
then
|
||||
|
189
lib/configure
vendored
189
lib/configure
vendored
@ -187,9 +187,9 @@ fi
|
||||
# Search for an installed reLyX or a ready-to-install one
|
||||
save_PATH=${PATH}
|
||||
PATH=${PATH}:./reLyX/
|
||||
echo $ac_n "checking for reLyX LaTeX-to-LyX translator""... $ac_c"
|
||||
echo $ac_n "checking for a LaTeX -> LyX converter""... $ac_c"
|
||||
echo "$ac_t""(reLyX)"
|
||||
RELYX=
|
||||
tex_to_lyx_command=
|
||||
for ac_prog in reLyX
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
@ -200,33 +200,70 @@ if test -n "$ac_word"; then
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
RELYX="$ac_prog"
|
||||
tex_to_lyx_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$RELYX"; then
|
||||
if test -n "$tex_to_lyx_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$RELYX" && break
|
||||
test -n "$tex_to_lyx_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$RELYX" ; then
|
||||
RELYX=none
|
||||
if test -z "$tex_to_lyx_command" ; then
|
||||
tex_to_lyx_command=none
|
||||
fi
|
||||
|
||||
PATH=${save_PATH}
|
||||
test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$FName"
|
||||
|
||||
echo $ac_n "checking for a Noweb -> LyX converter""... $ac_c"
|
||||
echo "$ac_t""(noweb2lyx)"
|
||||
literate_to_lyx_command=
|
||||
for ac_prog in noweb2lyx
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
if test -n "$ac_word"; then
|
||||
echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
literate_to_lyx_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$literate_to_lyx_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$literate_to_lyx_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$literate_to_lyx_command" ; then
|
||||
literate_to_lyx_command=none
|
||||
fi
|
||||
|
||||
test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$FName \$\$OutName"
|
||||
|
||||
# Search something to process a literate document
|
||||
echo $ac_n "checking for a Literate programming processor""... $ac_c"
|
||||
echo $ac_n "checking for a Noweb -> LaTeX converter""... $ac_c"
|
||||
echo "$ac_t""(noweave)"
|
||||
LITERATE=
|
||||
literate_to_tex_command=
|
||||
for ac_prog in noweave
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
@ -237,29 +274,100 @@ if test -n "$ac_word"; then
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
LITERATE="$ac_prog"
|
||||
literate_to_tex_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$LITERATE"; then
|
||||
if test -n "$literate_to_tex_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$LITERATE" && break
|
||||
test -n "$literate_to_tex_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$LITERATE" ; then
|
||||
LITERATE=none
|
||||
if test -z "$literate_to_tex_command" ; then
|
||||
literate_to_tex_command=none
|
||||
fi
|
||||
|
||||
test $LITERATE = "noweave" && LITERATE="noweave -delay -index \$\$FName > \$\$OutName"
|
||||
LITERATE_EXT="nw"
|
||||
test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$FName > \$\$OutName"
|
||||
|
||||
echo $ac_n "checking for a HTML -> Latex converter""... $ac_c"
|
||||
echo "$ac_t""(html2latex)"
|
||||
html_to_latex_command=
|
||||
for ac_prog in html2latex
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
if test -n "$ac_word"; then
|
||||
echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
html_to_latex_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$html_to_latex_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$html_to_latex_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$html_to_latex_command" ; then
|
||||
html_to_latex_command=none
|
||||
fi
|
||||
|
||||
test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$FName"
|
||||
|
||||
echo $ac_n "checking for Image converter""... $ac_c"
|
||||
echo "$ac_t""(convert)"
|
||||
image_command=
|
||||
for ac_prog in convert
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
if test -n "$ac_word"; then
|
||||
echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
image_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$image_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$image_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$image_command" ; then
|
||||
image_command=none
|
||||
fi
|
||||
|
||||
test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName"
|
||||
|
||||
# Search for a Postscript interpreter
|
||||
echo $ac_n "checking for a Postscript interpreter""... $ac_c"
|
||||
@ -335,9 +443,9 @@ fi
|
||||
|
||||
# Search for a program to preview pdf
|
||||
echo $ac_n "checking for a PDF preview""... $ac_c"
|
||||
echo "$ac_t""(xpdf acroread gv ghostview)"
|
||||
echo "$ac_t""(acroread gv ghostview xpdf)"
|
||||
PDF_VIEWER=
|
||||
for ac_prog in xpdf acroread gv ghostview
|
||||
for ac_prog in acroread gv ghostview xpdf
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
@ -719,7 +827,7 @@ case $LINUXDOC in
|
||||
linuxdoc_to_latex_command="sgml2latex \$\$FName"
|
||||
linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName"
|
||||
linuxdoc_to_html_command="sgml2html \$\$FName"
|
||||
linuxdoc_to_lyx_command="sgml2lyx";;
|
||||
linuxdoc_to_lyx_command="sgml2lyx \$\$FName";;
|
||||
none)
|
||||
linuxdoc_to_latex_command="none"
|
||||
linuxdoc_to_dvi_command="none"
|
||||
@ -823,8 +931,7 @@ case $LPR in
|
||||
*) :;; # leave to empty values
|
||||
esac
|
||||
|
||||
# Search for a latex to html converter
|
||||
echo $ac_n "checking for an HTML converter""... $ac_c"
|
||||
echo $ac_n "checking for a LaTeX -> HTML converter""... $ac_c"
|
||||
echo "$ac_t""(tth latex2html hevea)"
|
||||
TOHTML=
|
||||
for ac_prog in tth latex2html hevea
|
||||
@ -948,18 +1055,39 @@ cat >lyxrc.defaults <<EOF
|
||||
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as
|
||||
# ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
|
||||
# override the values given here.
|
||||
\\converter tex dvi "$LATEX" ""
|
||||
\\converter tex pdf "$PDFLATEX" ""
|
||||
\\Format latex tex LaTeX L
|
||||
\\Format dvi dvi DVI D
|
||||
\\Format ps ps Postscript t
|
||||
\\Format pdf pdf PDF P
|
||||
\\Format html html HTML H
|
||||
\\Format text txt ASCII A
|
||||
\\Format literate nw NoWeb W
|
||||
\\Format linuxdoc sgml LinuxDoc x
|
||||
\\Format docbook sgml DocBook B
|
||||
\\Format program run Program r
|
||||
|
||||
\\converter latex lyx "$tex_to_lyx_command" ""
|
||||
\\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
|
||||
\\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook"
|
||||
\\converter latex html "$latex_to_html_command"
|
||||
"originaldir,needaux,disable=linuxdoc&docbook"
|
||||
\\converter literate lyx "$literate_to_lyx_command" ""
|
||||
\\converter literate latex "$literate_to_tex_command" ""
|
||||
\\converter dvi ps "$dvi_to_ps_command" ""
|
||||
\\converter ps pdf "$ps_to_pdf_command" ""
|
||||
\\converter sgml tex "$linuxdoc_to_latex_command" ""
|
||||
\\converter sgml dvi "$linuxdoc_to_dvi_command" ""
|
||||
\\converter sgml html "$linuxdoc_to_html_command" ""
|
||||
\\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
|
||||
\\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
|
||||
\\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
|
||||
\\converter linuxdoc html "$linuxdoc_to_html_command" ""
|
||||
\\converter docbook dvi "$docbook_to_dvi_command" ""
|
||||
\\converter docbook html "$docbook_to_html_command" ""
|
||||
\\converter tex html "$latex_to_html_command"
|
||||
"originaldir,needaux"
|
||||
\\converter $LITERATE_EXT tex "$LITERATE" ""
|
||||
\\converter html latex "$html_to_latex_command"
|
||||
"disable=latex&literate&linuxdoc&docbook"
|
||||
|
||||
\converter gif eps "$image_command" ""
|
||||
\converter png eps "$image_command" ""
|
||||
\converter jpg eps "$image_command" ""
|
||||
\converter gif png "$image_command" ""
|
||||
|
||||
\\viewer dvi "$DVI_VIEWER"
|
||||
\\viewer html "$HTML_VIEWER"
|
||||
@ -967,9 +1095,6 @@ cat >lyxrc.defaults <<EOF
|
||||
\\viewer ps "$GHOSTVIEW -swap"
|
||||
\\viewer eps "$GHOSTVIEW"
|
||||
|
||||
\\relyx_command "$RELYX"
|
||||
\\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
|
||||
\\literate_extension "$LITERATE_EXT"
|
||||
\\ps_command "$GS"
|
||||
\\ascii_roff_command "$ascii_roff_command"
|
||||
\\chktex_command "$chktex_command"
|
||||
|
@ -182,13 +182,22 @@ fi
|
||||
# Search for an installed reLyX or a ready-to-install one
|
||||
save_PATH=${PATH}
|
||||
PATH=${PATH}:./reLyX/
|
||||
SEARCH_PROG([for reLyX LaTeX-to-LyX translator],RELYX,reLyX)
|
||||
SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
|
||||
PATH=${save_PATH}
|
||||
test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$FName"
|
||||
|
||||
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"
|
||||
|
||||
# Search something to process a literate document
|
||||
SEARCH_PROG([for a Literate programming processor],LITERATE,noweave)
|
||||
test $LITERATE = "noweave" && LITERATE="noweave -delay -index \$\$FName > \$\$OutName"
|
||||
LITERATE_EXT="nw"
|
||||
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"
|
||||
|
||||
SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
|
||||
test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$FName"
|
||||
|
||||
SEARCH_PROG([for Image converter],image_command,convert)
|
||||
test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName"
|
||||
|
||||
# Search for a Postscript interpreter
|
||||
SEARCH_PROG([for a Postscript interpreter],GS, gs)
|
||||
@ -197,7 +206,7 @@ SEARCH_PROG([for a Postscript interpreter],GS, gs)
|
||||
SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
|
||||
|
||||
# Search for a program to preview pdf
|
||||
SEARCH_PROG([for a PDF preview],PDF_VIEWER,xpdf acroread gv ghostview)
|
||||
SEARCH_PROG([for a PDF preview],PDF_VIEWER,acroread gv ghostview xpdf)
|
||||
|
||||
# Search something to preview dvi
|
||||
SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi)
|
||||
@ -252,7 +261,7 @@ case $LINUXDOC in
|
||||
linuxdoc_to_latex_command="sgml2latex \$\$FName"
|
||||
linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName"
|
||||
linuxdoc_to_html_command="sgml2html \$\$FName"
|
||||
linuxdoc_to_lyx_command="sgml2lyx";;
|
||||
linuxdoc_to_lyx_command="sgml2lyx \$\$FName";;
|
||||
none)
|
||||
linuxdoc_to_latex_command="none"
|
||||
linuxdoc_to_dvi_command="none"
|
||||
@ -290,8 +299,7 @@ case $LPR in
|
||||
*) :;; # leave to empty values
|
||||
esac
|
||||
|
||||
# Search for a latex to html converter
|
||||
SEARCH_PROG([for an HTML converter], TOHTML, tth latex2html hevea)
|
||||
SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea)
|
||||
latex_to_html_command = $TOHTML
|
||||
case $TOHTML in
|
||||
tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
|
||||
@ -370,18 +378,39 @@ cat >lyxrc.defaults <<EOF
|
||||
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as
|
||||
# ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
|
||||
# override the values given here.
|
||||
\\converter tex dvi "$LATEX" ""
|
||||
\\converter tex pdf "$PDFLATEX" ""
|
||||
\\Format latex tex LaTeX L
|
||||
\\Format dvi dvi DVI D
|
||||
\\Format ps ps Postscript t
|
||||
\\Format pdf pdf PDF P
|
||||
\\Format html html HTML H
|
||||
\\Format text txt ASCII A
|
||||
\\Format literate nw NoWeb W
|
||||
\\Format linuxdoc sgml LinuxDoc x
|
||||
\\Format docbook sgml DocBook B
|
||||
\\Format program run Program r
|
||||
|
||||
\\converter latex lyx "$tex_to_lyx_command" ""
|
||||
\\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
|
||||
\\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook"
|
||||
\\converter latex html "$latex_to_html_command"
|
||||
"originaldir,needaux,disable=linuxdoc&docbook"
|
||||
\\converter literate lyx "$literate_to_lyx_command" ""
|
||||
\\converter literate latex "$literate_to_tex_command" ""
|
||||
\\converter dvi ps "$dvi_to_ps_command" ""
|
||||
\\converter ps pdf "$ps_to_pdf_command" ""
|
||||
\\converter sgml tex "$linuxdoc_to_latex_command" ""
|
||||
\\converter sgml dvi "$linuxdoc_to_dvi_command" ""
|
||||
\\converter sgml html "$linuxdoc_to_html_command" ""
|
||||
\\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
|
||||
\\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
|
||||
\\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
|
||||
\\converter linuxdoc html "$linuxdoc_to_html_command" ""
|
||||
\\converter docbook dvi "$docbook_to_dvi_command" ""
|
||||
\\converter docbook html "$docbook_to_html_command" ""
|
||||
\\converter tex html "$latex_to_html_command"
|
||||
"originaldir,needaux"
|
||||
\\converter $LITERATE_EXT tex "$LITERATE" ""
|
||||
\\converter html latex "$html_to_latex_command"
|
||||
"disable=latex&literate&linuxdoc&docbook"
|
||||
|
||||
\converter gif eps "$image_command" ""
|
||||
\converter png eps "$image_command" ""
|
||||
\converter jpg eps "$image_command" ""
|
||||
\converter gif png "$image_command" ""
|
||||
|
||||
\\viewer dvi "$DVI_VIEWER"
|
||||
\\viewer html "$HTML_VIEWER"
|
||||
@ -389,9 +418,6 @@ cat >lyxrc.defaults <<EOF
|
||||
\\viewer ps "$GHOSTVIEW -swap"
|
||||
\\viewer eps "$GHOSTVIEW"
|
||||
|
||||
\\relyx_command "$RELYX"
|
||||
\\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
|
||||
\\literate_extension "$LITERATE_EXT"
|
||||
\\ps_command "$GS"
|
||||
\\ascii_roff_command "$ascii_roff_command"
|
||||
\\chktex_command "$chktex_command"
|
||||
|
@ -149,18 +149,6 @@
|
||||
# '.in' and '.out'. Only for advanced users.
|
||||
# \serverpipe "/home/chb/.lyxpipe"
|
||||
|
||||
# Which command to use to invoke the reLyX script to convert
|
||||
# LaTeX files to LyX files. This setting is automatically
|
||||
# disabled if you do not have the appropriate Perl version
|
||||
# installed. In that case, the File->Import LaTeX command
|
||||
# will be disabled. If the reLyX command does work for you,
|
||||
# you can override that here by uncommenting this line:
|
||||
#\relyx_command "reLyX"
|
||||
#
|
||||
# If it doesn't work, you can disable the command by uncommenting
|
||||
# this line:
|
||||
#\relyx_command "none"
|
||||
|
||||
# Default format string for the date-insert command
|
||||
#
|
||||
# This accepts the normal strftime formats; see man strftime for full
|
||||
@ -356,6 +344,8 @@
|
||||
# and $$OutName is replaced with the name of the target file.
|
||||
# The flags argument is a list of comma separated flags.
|
||||
# Known flags are
|
||||
# - * : copy the previously defined flags
|
||||
# - latex : The converter is latex or its derivatives (pdflatex).
|
||||
# - 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
|
||||
# converters in order to be able to read the eps files.
|
||||
@ -372,18 +362,24 @@
|
||||
# - 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
|
||||
# file.
|
||||
# - disable=backends : A list of & seperated backend in which the converter
|
||||
# should not be used.
|
||||
# For example:
|
||||
# \converter tex html "latex2html -split 0 $$FName"
|
||||
# "originaldir,needaux,resultdir"
|
||||
#\converter latex html "latex2html -split 0 $$FName"
|
||||
# "originaldir,needaux,resultdir,disable=linuxdoc&docbook"
|
||||
#
|
||||
# For literate programming, use something like
|
||||
# \converter nw tex "noweave -delay -index $$FName >$$OutName"
|
||||
# "parselog=listerrors g"
|
||||
# \converter nw Program "build-script $$FName"
|
||||
# "originaldir,parselog=listerrors g"
|
||||
#\converter literate latex "noweave -delay -index $$FName >$$OutName"
|
||||
# "parselog=listerrors g"
|
||||
#\converter literate program "build-script $$FName"
|
||||
# "originaldir,parselog=listerrors g"
|
||||
|
||||
# The format command is used to define file formats. It has 4 arguments:
|
||||
# the format name, the extension, and "pretty name" and menu shortcut.
|
||||
# For example
|
||||
#\Format latex tex LaTeX L
|
||||
|
||||
# The \viewer command is used to define viewers for new file-formats,
|
||||
# The \viewer command is used to define viewers for new formats,
|
||||
# or to change the already defined viewers.
|
||||
# For example, to use xdvi as the viewer to dvi files use
|
||||
#\viewer dvi "xdvi"
|
||||
@ -401,13 +397,6 @@
|
||||
# Choose "default" if T1 doesn't work for you for some reason:
|
||||
#\font_encoding default
|
||||
|
||||
#
|
||||
# LINUXDOC SECTION #######################################################
|
||||
#
|
||||
|
||||
# The LinuxDoc to LyX converter
|
||||
#\linuxdoc_to_lyx_command "sgml2lyx"
|
||||
|
||||
#
|
||||
# FILE SECTION ##########################################################
|
||||
#
|
||||
|
@ -36,10 +36,10 @@ Menuset
|
||||
Separator
|
||||
Item "View dvi|d" "buffer-view dvi"
|
||||
Item "View Postscript|w" "buffer-view ps"
|
||||
Submenu "View" "view"
|
||||
Item "Update dvi|v" "buffer-update dvi"
|
||||
Item "Update Postscript|U" "buffer-update ps"
|
||||
Submenu "Update" "update"
|
||||
Submenu "View|V" "view"
|
||||
Item "Update dvi" "buffer-update dvi"
|
||||
Item "Update Postscript" "buffer-update ps"
|
||||
Submenu "Update|U" "update"
|
||||
OptItem "Build program|B" "build-program"
|
||||
Separator
|
||||
Item "Print...|P" "buffer-print"
|
||||
@ -74,9 +74,11 @@ Menuset
|
||||
|
||||
Menu "import"
|
||||
Item "LaTeX|L" "buffer-import latex"
|
||||
Item "Ascii text as lines|A" "buffer-import ascii"
|
||||
Item "Ascii text as paragraphs|p" "buffer-import ascii"
|
||||
Item "Noweb|N" "buffer-import noweb"
|
||||
Item "Ascii text as lines|A" "buffer-import text"
|
||||
Item "Ascii text as paragraphs|p" "buffer-import textparagraph"
|
||||
Item "HTML|H" "buffer-import html"
|
||||
Item "Noweb|N" "buffer-import literate"
|
||||
Item "LinuxDoc|D" "buffer-import linuxdoc"
|
||||
End
|
||||
|
||||
Menu "export"
|
||||
|
@ -76,6 +76,7 @@ src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/Menubar_pimpl.C
|
||||
src/gettext.h
|
||||
src/importer.C
|
||||
src/insets/figinset.C
|
||||
src/insets/form_graphics.C
|
||||
src/insets/insetbib.C
|
||||
|
@ -1,51 +0,0 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* This file is Copyright 1998
|
||||
* Asger Alstrup
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "ImportLaTeX.h"
|
||||
#include "lyxrc.h"
|
||||
#include "support/syscall.h"
|
||||
#include "support/filetools.h"
|
||||
#include "bufferlist.h"
|
||||
|
||||
extern BufferList bufferlist;
|
||||
|
||||
/*
|
||||
* CLASS ImportLaTeX
|
||||
*/
|
||||
|
||||
ImportLaTeX::ImportLaTeX(string const & file)
|
||||
: file(file)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Buffer * ImportLaTeX::run()
|
||||
{
|
||||
// run reLyX
|
||||
string tmp = lyxrc.relyx_command + " -f " + file;
|
||||
Systemcalls one;
|
||||
Buffer * buf = 0;
|
||||
int result = one.startscript(Systemcalls::System, tmp);
|
||||
if (result == 0) {
|
||||
string filename = ChangeExtension(file, ".lyx");
|
||||
// File was generated without problems. Load it.
|
||||
buf = bufferlist.loadLyXFile(filename);
|
||||
}
|
||||
return buf;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* This file is Copyright 1998
|
||||
* Asger Alstrup
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#ifndef IMPORTLATEX_H
|
||||
#define IMPORTLATEX_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
class Buffer;
|
||||
|
||||
///
|
||||
class ImportLaTeX {
|
||||
public:
|
||||
/**
|
||||
file = name and path of the latex file
|
||||
*/
|
||||
explicit ImportLaTeX(string const & file);
|
||||
|
||||
/** Imports the document.
|
||||
Return 0 if fail.
|
||||
*/
|
||||
Buffer * run();
|
||||
private:
|
||||
///
|
||||
string file;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* This file is Copyright 1999
|
||||
* Kayvan A. Sylvan
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ImportNoweb.h"
|
||||
#include "lyxrc.h"
|
||||
#include "support/syscall.h"
|
||||
#include "bufferlist.h"
|
||||
|
||||
using std::ifstream;
|
||||
using std::getline;
|
||||
|
||||
extern BufferList bufferlist;
|
||||
|
||||
/*
|
||||
* Implementation the ImportNoweb methods.
|
||||
*/
|
||||
|
||||
Buffer * ImportNoweb::run()
|
||||
{
|
||||
// run reLyX -n
|
||||
string tmp = lyxrc.relyx_command + " -n -c " +
|
||||
documentclass() + " -f " + file;
|
||||
Systemcalls one;
|
||||
Buffer * buf = 0;
|
||||
int result= one.startscript(Systemcalls::System, tmp);
|
||||
if (result == 0) {
|
||||
string filename = file + ".lyx";
|
||||
// File was generated without problems. Load it.
|
||||
buf = bufferlist.loadLyXFile(filename);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
// Provide the literate documentclass by parsing the file.
|
||||
string const ImportNoweb::documentclass()
|
||||
{
|
||||
string result = "literate-article"; // Default
|
||||
|
||||
ifstream ifs(file.c_str());
|
||||
|
||||
if (!ifs) return "nofile"; // Should not happen!
|
||||
string line;
|
||||
while (getline(ifs, line)) {
|
||||
string::size_type p = line.find("\\documentclass");
|
||||
if (p != string::npos) {
|
||||
p = line.find('{', p);
|
||||
string::size_type q = line.find('}', p);
|
||||
result = "literate-" + line.substr(p + 1, q - p - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* This file is Copyright 1999
|
||||
* Kayvan A. Sylvan
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#ifndef IMPORTNOWEB_H
|
||||
#define IMPORTNOWEB_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
class Buffer;
|
||||
|
||||
///
|
||||
class ImportNoweb {
|
||||
public:
|
||||
/**
|
||||
file = name and path of the noweb file to import
|
||||
*/
|
||||
explicit ImportNoweb(string const & file) : file(file) {}
|
||||
|
||||
/** Imports the document.
|
||||
Return 0 if fail.
|
||||
*/
|
||||
Buffer * run();
|
||||
private:
|
||||
///
|
||||
string file;
|
||||
///
|
||||
string const documentclass();
|
||||
///
|
||||
enum {
|
||||
///
|
||||
BUFSIZE = 512
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -12,6 +12,7 @@
|
||||
#include "lyxrc.h"
|
||||
#include "BufferView.h"
|
||||
#include "gettext.h"
|
||||
#include "converter.h"
|
||||
|
||||
extern FD_LaTeXLog *fd_latex_log;
|
||||
extern BufferView *current_view;
|
||||
@ -26,7 +27,7 @@ void ShowLatexLog()
|
||||
if (!filename.empty()) {
|
||||
fname = OnlyFilename(ChangeExtension(filename, ".log"));
|
||||
bname = OnlyFilename(ChangeExtension(filename,
|
||||
lyxrc.literate_extension + ".out"));
|
||||
Formats::Extension("literate") + ".out"));
|
||||
path = OnlyPath(filename);
|
||||
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
||||
path = current_view->buffer()->tmppath;
|
||||
|
@ -45,10 +45,6 @@ lyx_SOURCES = \
|
||||
FontInfo.h \
|
||||
FontLoader.C \
|
||||
FontLoader.h \
|
||||
ImportLaTeX.C \
|
||||
ImportLaTeX.h \
|
||||
ImportNoweb.C \
|
||||
ImportNoweb.h \
|
||||
LColor.C \
|
||||
LColor.h \
|
||||
LString.h \
|
||||
@ -129,6 +125,8 @@ lyx_SOURCES = \
|
||||
form1.h \
|
||||
gettext.C \
|
||||
gettext.h \
|
||||
importer.C \
|
||||
importer.h \
|
||||
include_form.h \
|
||||
intl.C \
|
||||
intl.h \
|
||||
|
@ -262,16 +262,23 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const
|
||||
fit != names.end() ; ++fit) {
|
||||
string fmt = (*fit).format->name;
|
||||
string label = (*fit).format->prettyname;
|
||||
bool same_before =
|
||||
fit != names.begin() &&
|
||||
(*fit).format == (*(fit-1)).format;
|
||||
bool same_after =
|
||||
fit+1 != names.end() &&
|
||||
(*fit).format == (*(fit+1)).format;
|
||||
if ((*fit).from &&
|
||||
( (fit != names.begin() &&
|
||||
(*fit).format == (*(fit-1)).format) ||
|
||||
(fit+1 != names.end() &&
|
||||
(*fit).format == (*(fit+1)).format) )) {
|
||||
(same_before || same_after)) {
|
||||
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));
|
||||
|
275
src/converter.C
275
src/converter.C
@ -33,6 +33,8 @@ using std::vector;
|
||||
using std::queue;
|
||||
using std::pair;
|
||||
using std::endl;
|
||||
using std::find;
|
||||
using std::find_if;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -50,37 +52,17 @@ string const add_options(string const & command, string const & options)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Format::Format(string const & n)
|
||||
: name(n)
|
||||
{
|
||||
struct Item {
|
||||
char const * name;
|
||||
char const * prettyname;
|
||||
};
|
||||
Item items[] = {
|
||||
{ "tex", "LaTeX" },
|
||||
{ "dvi", "DVI" },
|
||||
{ "ps", "PostScript" },
|
||||
{ "txt", "Ascii" },
|
||||
{ "html", "HTML" },
|
||||
{ "pdf", "PDF" },
|
||||
{ "nw", "NoWeb/LaTeX"},
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
prettyname = n;
|
||||
for (int i = 0; items[i].name != 0; ++i)
|
||||
if (items[i].name == n) {
|
||||
prettyname = items[i].prettyname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Formats::Add(string const & name)
|
||||
{
|
||||
if (formats.find(name) == formats.end())
|
||||
formats[name] = Format(name);
|
||||
formats[name] = Format(name, name, name, string());
|
||||
}
|
||||
|
||||
|
||||
void Formats::Add(string const & name, string const & extension,
|
||||
string const & prettyname, string const & shortcut)
|
||||
{
|
||||
formats[name] = Format(name, extension, prettyname, shortcut);
|
||||
}
|
||||
|
||||
|
||||
@ -96,23 +78,23 @@ void Formats::SetViewer(string const & name, string const & command)
|
||||
}
|
||||
|
||||
|
||||
bool Formats::View(Buffer const * buffer, string const & filename)
|
||||
bool Formats::View(Buffer const * buffer, string const & filename,
|
||||
string const & format_name)
|
||||
{
|
||||
if (filename.empty())
|
||||
return false;
|
||||
|
||||
string extension = GetExtension(filename);
|
||||
Format * format = GetFormat(extension);
|
||||
Format const * format = GetFormat(format_name);
|
||||
if (!format || format->viewer.empty()) {
|
||||
WriteAlert(_("Can not view file"),
|
||||
_("No information for viewing ")
|
||||
+ Formats::PrettyName(extension));
|
||||
+ Formats::PrettyName(format_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
string command = format->viewer;
|
||||
|
||||
if (extension == "dvi" &&
|
||||
if (format_name == "dvi" &&
|
||||
!lyxrc.view_dvi_paper_option.empty()) {
|
||||
string options = lyxrc.view_dvi_paper_option;
|
||||
options += " " + Converter::dvi_papersize(buffer);
|
||||
@ -152,38 +134,68 @@ Format * Formats::GetFormat(string const & name)
|
||||
|
||||
string const Formats::PrettyName(string const & name)
|
||||
{
|
||||
string format;
|
||||
Converter::SplitFormat(name, format);
|
||||
Format * f = GetFormat(format);
|
||||
if (f)
|
||||
return f->prettyname;
|
||||
Format const * format = GetFormat(name);
|
||||
if (format)
|
||||
return format->prettyname;
|
||||
else
|
||||
return format;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
string const Formats::Extension(string const & name)
|
||||
{
|
||||
Format const * format = GetFormat(name);
|
||||
if (format)
|
||||
return format->extension;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class compare_Command {
|
||||
public:
|
||||
compare_Command(Command const & c) : com(c) {}
|
||||
bool operator()(Command const & c) {
|
||||
return c.from == com.from && c.to == com.to;
|
||||
}
|
||||
private:
|
||||
Command com;
|
||||
};
|
||||
|
||||
|
||||
void Converter::Add(string const & from, string const & to,
|
||||
string const & command, string const & flags)
|
||||
{
|
||||
if (command == "none")
|
||||
Formats::Add(from);
|
||||
Formats::Add(to);
|
||||
Command Com(Formats::GetFormat(from), Formats::GetFormat(to), command);
|
||||
vector<Command>::iterator it = find_if(commands.begin(),
|
||||
commands.end(),
|
||||
compare_Command(Com));
|
||||
|
||||
if (command.empty() || command == "none") {
|
||||
if (it != commands.end())
|
||||
commands.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
Command Com(from, to, command);
|
||||
|
||||
if (from == "tex" &&
|
||||
(to == "dvi" ||
|
||||
(to == "pdf" && latex_command.empty())))
|
||||
latex_command = command;
|
||||
|
||||
// Read the flags
|
||||
string flag_name,flag_value;
|
||||
string flag_list(flags);
|
||||
while (!flag_list.empty()) {
|
||||
flag_list = split(flag_list, flag_value,',');
|
||||
string flag_name, flag_value;
|
||||
flag_list = split(flag_list, flag_value, ',');
|
||||
flag_value = split(flag_value, flag_name, '=');
|
||||
if (flag_name == "originaldir")
|
||||
if (flag_name == "*") {
|
||||
if (it != commands.end()) {
|
||||
Com = *it;
|
||||
Com.command = command;
|
||||
}
|
||||
}
|
||||
else if (flag_name == "latex")
|
||||
Com.latex = true;
|
||||
else if (flag_name == "originaldir")
|
||||
Com.original_dir = true;
|
||||
else if (flag_name == "needaux")
|
||||
Com.need_aux = true;
|
||||
@ -194,27 +206,47 @@ void Converter::Add(string const & from, string const & to,
|
||||
Com.result_file = flag_value;
|
||||
else if (flag_name == "parselog")
|
||||
Com.parselog = flag_value;
|
||||
else if (flag_name == "disable") {
|
||||
while (!flag_value.empty()) {
|
||||
string tmp;
|
||||
flag_value = split(flag_value, tmp, '&');
|
||||
Com.disable.push_back(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Com.result_dir.empty() && Com.result_file.empty())
|
||||
Com.result_file = "index." + to;
|
||||
//if (!contains(command, "$$FName"))
|
||||
// Com.latex = true;
|
||||
|
||||
for (vector<Command>::iterator it = commands.begin();
|
||||
it != commands.end(); ++it)
|
||||
if ((*it).from == from && (*it).to == to) {
|
||||
*it = Com;
|
||||
return;
|
||||
}
|
||||
if (Com.latex && (latex_command.empty() || to == "dvi"))
|
||||
latex_command = command;
|
||||
// If we have both latex & pdflatex, we set latex_command to latex.
|
||||
// The latex_command is used to update the .aux file when running
|
||||
// a converter that uses it.
|
||||
|
||||
if (it != commands.end()) {
|
||||
*it = Com;
|
||||
return;
|
||||
}
|
||||
commands.push_back(Com);
|
||||
Formats::Add(from);
|
||||
Formats::Add(to);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool enable(vector<Command>::iterator it, string const & from)
|
||||
{
|
||||
return find((*it).disable.begin(), (*it).disable.end(), from)
|
||||
== (*it).disable.end();
|
||||
}
|
||||
|
||||
|
||||
vector<FormatPair> const
|
||||
Converter::GetReachable(string const & from, bool only_viewable)
|
||||
Converter::GetReachable(string const & from, string const & stop_format,
|
||||
bool only_viewable)
|
||||
{
|
||||
vector<FormatPair> result;
|
||||
Format * format = Formats::GetFormat(from);
|
||||
Format const * format = Formats::GetFormat(from);
|
||||
if (!format)
|
||||
return result;
|
||||
|
||||
@ -224,7 +256,8 @@ Converter::GetReachable(string const & from, bool only_viewable)
|
||||
queue< vector<Command>::iterator > Q;
|
||||
for (vector<Command>::iterator it = commands.begin();
|
||||
it != commands.end(); ++it)
|
||||
if ((*it).from == from) {
|
||||
if ((*it).from->name == from && enable(it, from)
|
||||
&& (*it).to->name != stop_format) {
|
||||
Q.push(it);
|
||||
(*it).visited = true;
|
||||
} else
|
||||
@ -233,14 +266,14 @@ Converter::GetReachable(string const & from, bool only_viewable)
|
||||
while (!Q.empty()) {
|
||||
vector<Command>::iterator it = Q.front();
|
||||
Q.pop();
|
||||
format = Formats::GetFormat((*it).to);
|
||||
if (!only_viewable || !format->viewer.empty())
|
||||
result.push_back(FormatPair(format,
|
||||
Formats::GetFormat((*it).from),
|
||||
if (!only_viewable || !(*it).to->viewer.empty())
|
||||
result.push_back(FormatPair((*it).to, (*it).from,
|
||||
(*it).command));
|
||||
for (vector<Command>::iterator it2 = commands.begin();
|
||||
it2 != commands.end(); ++it2)
|
||||
if (!(*it2).visited && (*it).to == (*it2).from) {
|
||||
if (!(*it2).visited && (*it).to == (*it2).from &&
|
||||
enable(it2, from) &&
|
||||
(*it2).to->name != stop_format) {
|
||||
Q.push(it2);
|
||||
(*it2).visited = true;
|
||||
}
|
||||
@ -249,18 +282,16 @@ Converter::GetReachable(string const & from, bool only_viewable)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Converter::IsReachable(string const & from, string const & target_format)
|
||||
|
||||
bool Converter::IsReachable(string const & from, string const & to)
|
||||
{
|
||||
Format * format = Formats::GetFormat(from);
|
||||
if (!format)
|
||||
return false;
|
||||
else if (format->name == target_format)
|
||||
if (from == to)
|
||||
return true;
|
||||
|
||||
queue< vector<Command>::iterator > Q;
|
||||
for (vector<Command>::iterator it = commands.begin();
|
||||
it != commands.end(); ++it)
|
||||
if ((*it).from == from) {
|
||||
if ((*it).from->name == from && enable(it, from)) {
|
||||
Q.push(it);
|
||||
(*it).visited = true;
|
||||
} else
|
||||
@ -269,12 +300,12 @@ bool Converter::IsReachable(string const & from, string const & target_format)
|
||||
while (!Q.empty()) {
|
||||
vector<Command>::iterator it = Q.front();
|
||||
Q.pop();
|
||||
format = Formats::GetFormat((*it).to);
|
||||
if (format->name == target_format)
|
||||
if ((*it).to->name == to)
|
||||
return true;
|
||||
for (vector<Command>::iterator it2 = commands.begin();
|
||||
it2 != commands.end(); ++it2)
|
||||
if (!(*it2).visited && (*it).to == (*it2).from) {
|
||||
if (!(*it2).visited && (*it).to == (*it2).from &&
|
||||
enable(it2, from)) {
|
||||
Q.push(it2);
|
||||
(*it2).visited = true;
|
||||
}
|
||||
@ -283,15 +314,14 @@ bool Converter::IsReachable(string const & from, string const & target_format)
|
||||
}
|
||||
|
||||
|
||||
bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
string const & to_file, string const & using_format,
|
||||
string * view_file)
|
||||
bool Converter::Convert(Buffer const * buffer,
|
||||
string const & from_file, string const & to_file_base,
|
||||
string const & from_format, string const & to_format,
|
||||
string const & using_format, string & to_file)
|
||||
{
|
||||
if (view_file)
|
||||
*view_file = to_file;
|
||||
to_file = ChangeExtension(to_file_base,
|
||||
Formats::Extension(to_format));
|
||||
|
||||
string from_format = GetExtension(from_file);
|
||||
string to_format = GetExtension(to_file);
|
||||
if (from_format == to_format)
|
||||
if (from_file != to_file)
|
||||
return lyx::rename(from_file, to_file);
|
||||
@ -301,7 +331,7 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
queue< vector<Command>::iterator > Q;
|
||||
for (vector<Command>::iterator it = commands.begin();
|
||||
it != commands.end(); ++it)
|
||||
if ((*it).from == from_format) {
|
||||
if ((*it).from->name == from_format && enable(it, from_format)) {
|
||||
Q.push(it);
|
||||
(*it).visited = true;
|
||||
(*it).previous = commands.end();
|
||||
@ -318,15 +348,16 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
vector<Command>::iterator it;
|
||||
while (!Q.empty()) {
|
||||
it = Q.front();
|
||||
if ((*it).to == to_format &&
|
||||
(using_format.empty() || using_format == (*it).from)) {
|
||||
if ((*it).to->name == to_format &&
|
||||
(using_format.empty() || using_format == (*it).from->name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
Q.pop();
|
||||
for (vector<Command>::iterator it2 = commands.begin();
|
||||
it2 != commands.end(); ++it2)
|
||||
if (!(*it2).visited && (*it).to == (*it2).from) {
|
||||
if (!(*it2).visited && (*it).to == (*it2).from &&
|
||||
enable(it2, from_format)) {
|
||||
Q.push(it2);
|
||||
(*it2).visited = true;
|
||||
(*it2).previous = it;
|
||||
@ -359,18 +390,17 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
S.rbegin(); rit != S.rend(); ++rit) {
|
||||
it = *rit;
|
||||
lyxerr << "Converting from "
|
||||
<< (*it).from << " to " << (*it).to << endl;
|
||||
<< (*it).from->name << " to " << (*it).to->name << endl;
|
||||
infile = outfile;
|
||||
outfile = (*it).result_dir.empty()
|
||||
? ChangeExtension(from_file, (*it).to)
|
||||
? ChangeExtension(from_file, (*it).to->extension)
|
||||
: AddName(subst((*it).result_dir,
|
||||
"$$BaseName", from_base),
|
||||
subst((*it).result_file,
|
||||
"$$BaseName", OnlyFilename(from_base)));
|
||||
|
||||
if ((*it).from == "tex" &&
|
||||
( (*it).to == "dvi" || (*it).to == "pdf") ) {
|
||||
lyxrc.pdf_mode = (*it).to == "pdf";
|
||||
if ((*it).latex) {
|
||||
lyxrc.pdf_mode = (*it).to->name == "pdf";
|
||||
lyxerr << "Running " << (*it).command << endl;
|
||||
run_latex = true;
|
||||
if (!runLaTeX(buffer, (*it).command))
|
||||
@ -396,16 +426,17 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
if (!(*it).parselog.empty())
|
||||
command += " 2> " + QuoteName(infile2 + ".out");
|
||||
|
||||
if ((*it).from == "dvi" && (*it).to == "ps")
|
||||
if ((*it).from->name == "dvi" && (*it).to->name == "ps")
|
||||
command = add_options(command,
|
||||
dvips_options(buffer));
|
||||
|
||||
lyxerr << "Calling " << command << endl;
|
||||
ShowMessage(buffer, _("Executing command:"), command);
|
||||
if (buffer)
|
||||
ShowMessage(buffer, _("Executing command:"), command);
|
||||
|
||||
Systemcalls one;
|
||||
int res;
|
||||
if ((*it).original_dir) {
|
||||
if ((*it).original_dir && buffer) {
|
||||
Path p(buffer->filepath);
|
||||
res = one.startscript(Systemcalls::System, command);
|
||||
} else
|
||||
@ -422,7 +453,7 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
}
|
||||
|
||||
if (res) {
|
||||
if ((*it).to == "Program")
|
||||
if ((*it).to->name == "program")
|
||||
WriteAlert(_("There were errors during the Build process."),
|
||||
_("You should try to fix them."));
|
||||
else
|
||||
@ -435,11 +466,10 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
}
|
||||
|
||||
if (!(*it).result_dir.empty()) {
|
||||
if (view_file)
|
||||
*view_file = AddName(subst((*it).result_dir,
|
||||
"$$BaseName", to_base),
|
||||
subst((*it).result_file,
|
||||
"$$BaseName", OnlyFilename(to_base)));
|
||||
to_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);
|
||||
@ -447,10 +477,8 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
"$$BaseName", to_base);
|
||||
return lyx::rename(from, to);
|
||||
}
|
||||
|
||||
} else if (outfile != to_file)
|
||||
if ((*it).from == "tex" &&
|
||||
( (*it).to == "dvi" || (*it).to == "pdf") )
|
||||
if ((*it).latex)
|
||||
return lyx::copy(outfile, to_file);
|
||||
else
|
||||
return lyx::rename(outfile, to_file);
|
||||
@ -459,6 +487,17 @@ bool Converter::Convert(Buffer const * buffer, string const & from_file,
|
||||
}
|
||||
|
||||
|
||||
bool Converter::Convert(Buffer const * buffer,
|
||||
string const & from_file, string const & to_file_base,
|
||||
string const & from_format, string const & to_format,
|
||||
string const & using_format)
|
||||
{
|
||||
string to_file;
|
||||
return Convert(buffer, from_file, to_file_base, from_format, to_format,
|
||||
using_format, to_file);
|
||||
}
|
||||
|
||||
|
||||
string const Converter::SplitFormat(string const & str, string & format)
|
||||
{
|
||||
string using_format = split(str, format, ':');
|
||||
@ -467,9 +506,13 @@ string const Converter::SplitFormat(string const & str, string & format)
|
||||
return using_format;
|
||||
}
|
||||
|
||||
|
||||
bool Converter::scanLog(Buffer const * buffer, string const & command,
|
||||
string const & filename)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
BufferView * bv = buffer->getUser();
|
||||
bool need_redraw = false;
|
||||
if (bv) {
|
||||
@ -491,14 +534,9 @@ bool Converter::scanLog(Buffer const * buffer, string const & command,
|
||||
bv->redraw();
|
||||
bv->fitCursor(bv->text);
|
||||
}
|
||||
if (result & LaTeX::NO_OUTPUT) {
|
||||
string const s = _("The operation resulted in");
|
||||
string const t = _("an empty file.");
|
||||
WriteAlert(_("Resulting file is empty"), s, t);
|
||||
return false;
|
||||
}
|
||||
AllowInput(bv);
|
||||
}
|
||||
|
||||
if ((result & LaTeX::ERRORS)) {
|
||||
int num_errors = latex.getNumErrors();
|
||||
string s;
|
||||
@ -516,12 +554,20 @@ bool Converter::scanLog(Buffer const * buffer, string const & command,
|
||||
WriteAlert(_("There were errors during running of ") + head,
|
||||
s, t);
|
||||
return false;
|
||||
} else if (result & LaTeX::NO_OUTPUT) {
|
||||
string const s = _("The operation resulted in");
|
||||
string const t = _("an empty file.");
|
||||
WriteAlert(_("Resulting file is empty"), s, t);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Converter::runLaTeX(Buffer const * buffer, string const & command)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
BufferView * bv = buffer->getUser();
|
||||
string name = buffer->getLatexName();
|
||||
@ -555,10 +601,6 @@ bool Converter::runLaTeX(Buffer const * buffer, string const & command)
|
||||
bv->redraw();
|
||||
bv->fitCursor(bv->text);
|
||||
}
|
||||
} else if (result & LaTeX::NO_OUTPUT) {
|
||||
string const s = _("The operation resulted in");
|
||||
string const t = _("an empty file.");
|
||||
WriteAlert(_("Resulting file is empty"), s, t);
|
||||
}
|
||||
|
||||
// check return value from latex.run().
|
||||
@ -579,6 +621,10 @@ bool Converter::runLaTeX(Buffer const * buffer, string const & command)
|
||||
}
|
||||
WriteAlert(_("There were errors during the LaTeX run."),
|
||||
s, t);
|
||||
} else if (result & LaTeX::NO_OUTPUT) {
|
||||
string const s = _("The operation resulted in");
|
||||
string const t = _("an empty file.");
|
||||
WriteAlert(_("Resulting file is empty"), s, t);
|
||||
}
|
||||
|
||||
if (bv)
|
||||
@ -623,6 +669,9 @@ string const Converter::dvi_papersize(Buffer const * buffer)
|
||||
string const Converter::dvips_options(Buffer const * buffer)
|
||||
{
|
||||
string result;
|
||||
if (!buffer)
|
||||
return result;
|
||||
|
||||
if (buffer->params.use_geometry
|
||||
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
||||
&& !lyxrc.print_paper_dimension_flag.empty()
|
||||
@ -649,7 +698,7 @@ string const Converter::dvips_options(Buffer const * buffer)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Converter::init()
|
||||
{
|
||||
Formats::Add("txt");
|
||||
}
|
||||
|
@ -22,18 +22,41 @@
|
||||
|
||||
class Buffer;
|
||||
|
||||
///
|
||||
class Format {
|
||||
public:
|
||||
///
|
||||
Format() {}
|
||||
///
|
||||
Format(string const & n, string const & e, string const & p,
|
||||
string const & s) :
|
||||
name(n), extension(e), prettyname(p), shortcut(s) {};
|
||||
///
|
||||
string name;
|
||||
///
|
||||
string extension;
|
||||
///
|
||||
string prettyname;
|
||||
///
|
||||
string shortcut;
|
||||
///
|
||||
string viewer;
|
||||
};
|
||||
|
||||
///
|
||||
struct Command {
|
||||
///
|
||||
Command(string const & f, string const & t, string const & c)
|
||||
Command(Format const * f, Format const * t, string const & c)
|
||||
: from(f), to(t), command(c),
|
||||
original_dir(false), need_aux(false) {}
|
||||
latex(false), original_dir(false), need_aux(false) {}
|
||||
///
|
||||
string from;
|
||||
Format const * from;
|
||||
///
|
||||
string to;
|
||||
Format const * to;
|
||||
///
|
||||
string command;
|
||||
/// The converter is latex or its derivatives
|
||||
bool latex;
|
||||
/// Do we need to run the converter in the original directory?
|
||||
bool original_dir;
|
||||
/// This converter needs the .aux files
|
||||
@ -46,6 +69,8 @@ struct Command {
|
||||
string result_file;
|
||||
/// Command to convert the program output to a LaTeX log file format
|
||||
string parselog;
|
||||
/// Backends in which the converter is not used
|
||||
std::vector<string> disable;
|
||||
|
||||
/// Used by the BFS algorithm
|
||||
bool visited;
|
||||
@ -53,31 +78,16 @@ struct Command {
|
||||
std::vector<Command>::iterator previous;
|
||||
};
|
||||
|
||||
///
|
||||
class Format {
|
||||
public:
|
||||
///
|
||||
Format() {}
|
||||
///
|
||||
Format(string const & n);
|
||||
///
|
||||
string name;
|
||||
///
|
||||
string prettyname;
|
||||
///
|
||||
string viewer;
|
||||
};
|
||||
|
||||
class FormatPair {
|
||||
public:
|
||||
///
|
||||
Format * format;
|
||||
Format const * format;
|
||||
///
|
||||
Format * from;
|
||||
Format const * from;
|
||||
///
|
||||
string command;
|
||||
///
|
||||
FormatPair(Format * f1, Format * f2, string c)
|
||||
FormatPair(Format const * f1, Format const * f2, string c)
|
||||
: format(f1), from(f2), command(c) {}
|
||||
};
|
||||
|
||||
@ -89,16 +99,24 @@ public:
|
||||
void Add(string const & name);
|
||||
///
|
||||
static
|
||||
void Add(string const & name, string const & extension,
|
||||
string const & prettyname, string const & shortcut);
|
||||
///
|
||||
static
|
||||
void SetViewer(string const & name, string const & command);
|
||||
///
|
||||
static
|
||||
bool View(Buffer const * buffer, string const & filename);
|
||||
bool View(Buffer const * buffer, string const & filename,
|
||||
string const & format_name);
|
||||
///
|
||||
static
|
||||
Format * GetFormat(string const & name);
|
||||
///
|
||||
static
|
||||
string const PrettyName(string const & name);
|
||||
///
|
||||
static
|
||||
string const Extension(string const & name);
|
||||
private:
|
||||
///
|
||||
static
|
||||
@ -117,16 +135,23 @@ public:
|
||||
///
|
||||
static
|
||||
std::vector<FormatPair> const
|
||||
GetReachable(string const & from,
|
||||
bool only_viewable = false);
|
||||
GetReachable(string const & from, string const & stop_format,
|
||||
bool only_viewable);
|
||||
///
|
||||
static
|
||||
bool IsReachable(string const & from, string const & target_format);
|
||||
bool IsReachable(string const & from, string const & to);
|
||||
///
|
||||
static
|
||||
bool Convert(Buffer const * buffer, string const & from_file,
|
||||
string const & to_file, string const & using_format,
|
||||
string * view_file = 0);
|
||||
bool Convert(Buffer const * buffer,
|
||||
string const & from_file, string const & to_file_base,
|
||||
string const & from_format, string const & to_format,
|
||||
string const & using_format, string & to_file);
|
||||
///
|
||||
static
|
||||
bool Convert(Buffer const * buffer,
|
||||
string const & from_file, string const & to_file_base,
|
||||
string const & from_format, string const & to_format,
|
||||
string const & using_format = string());
|
||||
///
|
||||
static
|
||||
string const SplitFormat(string const & str, string & format);
|
||||
|
@ -24,22 +24,23 @@
|
||||
using std::vector;
|
||||
|
||||
bool Exporter::Export(Buffer * buffer, string const & format0,
|
||||
bool put_in_tempdir, string * view_file)
|
||||
bool put_in_tempdir, string & result_file)
|
||||
{
|
||||
string format;
|
||||
string using_format = Converter::SplitFormat(format0, format);
|
||||
|
||||
string backend_format = (format == "txt")
|
||||
? format : BufferExtension(buffer);
|
||||
string backend_format = (format == "text")
|
||||
? format : BufferFormat(buffer);
|
||||
bool only_backend = backend_format == format;
|
||||
|
||||
string filename = buffer->getLatexName(false);
|
||||
if (!buffer->tmppath.empty())
|
||||
filename = AddName(buffer->tmppath, filename);
|
||||
filename = ChangeExtension(filename, backend_format);
|
||||
filename = ChangeExtension(filename,
|
||||
Formats::Extension(backend_format));
|
||||
|
||||
// Ascii backend
|
||||
if (backend_format == "txt")
|
||||
if (backend_format == "text")
|
||||
buffer->writeFileAscii(filename, lyxrc.ascii_linelen);
|
||||
// Linuxdoc backend
|
||||
else if (buffer->isLinuxDoc())
|
||||
@ -53,12 +54,12 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
|
||||
else
|
||||
buffer->makeLaTeXFile(filename, buffer->filepath, false);
|
||||
|
||||
string outfile = (put_in_tempdir)
|
||||
? ChangeExtension(filename, format)
|
||||
: ChangeExtension(buffer->getLatexName(false), format);
|
||||
string outfile_base = (put_in_tempdir)
|
||||
? filename : buffer->getLatexName(false);
|
||||
|
||||
if (!Converter::Convert(buffer, filename, outfile, using_format,
|
||||
view_file))
|
||||
if (!Converter::Convert(buffer, filename, outfile_base,
|
||||
backend_format, format, using_format,
|
||||
result_file))
|
||||
return false;
|
||||
|
||||
if (!put_in_tempdir)
|
||||
@ -66,25 +67,32 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
|
||||
_("Document exported as ")
|
||||
+ Formats::PrettyName(format)
|
||||
+ _(" to file `")
|
||||
+ MakeDisplayPath(outfile) +'\'');
|
||||
+ MakeDisplayPath(result_file) +'\'');
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Exporter::Export(Buffer * buffer, string const & format,
|
||||
bool put_in_tempdir)
|
||||
{
|
||||
string result_file;
|
||||
return Export(buffer, format, put_in_tempdir, result_file);
|
||||
}
|
||||
|
||||
bool Exporter::Preview(Buffer * buffer, string const & format0)
|
||||
{
|
||||
string view_file;
|
||||
if (!Export(buffer, format0, true, &view_file))
|
||||
string result_file;
|
||||
if (!Export(buffer, format0, true, result_file))
|
||||
return false;
|
||||
|
||||
return Formats::View(buffer, view_file);
|
||||
string format;
|
||||
Converter::SplitFormat(format0, format);
|
||||
return Formats::View(buffer, result_file, format);
|
||||
}
|
||||
|
||||
|
||||
bool Exporter::IsExportable(Buffer const * buffer, string const & format)
|
||||
{
|
||||
return format == "txt" ||
|
||||
Converter::IsReachable(BufferExtension(buffer), format);
|
||||
return format == "text" ||
|
||||
Converter::IsReachable(BufferFormat(buffer), format);
|
||||
}
|
||||
|
||||
|
||||
@ -92,8 +100,8 @@ vector<FormatPair> const
|
||||
Exporter::GetExportableFormats(Buffer const * buffer)
|
||||
{
|
||||
vector<FormatPair> result =
|
||||
Converter::GetReachable(BufferExtension(buffer), false);
|
||||
Format * format = Formats::GetFormat("txt");
|
||||
Converter::GetReachable(BufferFormat(buffer), "lyx", false);
|
||||
Format * format = Formats::GetFormat("text");
|
||||
if (format)
|
||||
result.push_back(FormatPair(format , 0, ""));
|
||||
return result;
|
||||
@ -104,22 +112,22 @@ vector<FormatPair> const
|
||||
Exporter::GetViewableFormats(Buffer const * buffer)
|
||||
{
|
||||
vector<FormatPair> result =
|
||||
Converter::GetReachable(BufferExtension(buffer), true);
|
||||
Format * format = Formats::GetFormat("txt");
|
||||
Converter::GetReachable(BufferFormat(buffer), "lyx", true);
|
||||
Format * format = Formats::GetFormat("text");
|
||||
if (format && !format->viewer.empty())
|
||||
result.push_back(FormatPair(format , 0, ""));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
string const Exporter::BufferExtension(Buffer const * buffer)
|
||||
string const Exporter::BufferFormat(Buffer const * buffer)
|
||||
{
|
||||
if (buffer->isLinuxDoc())
|
||||
return "sgml";
|
||||
return "linuxdoc";
|
||||
else if (buffer->isDocBook())
|
||||
return "docbook";
|
||||
else if (buffer->isLiterate())
|
||||
return lyxrc.literate_extension;
|
||||
return "literate";
|
||||
else
|
||||
return "tex";
|
||||
return "latex";
|
||||
}
|
||||
|
@ -27,7 +27,11 @@ public:
|
||||
///
|
||||
static
|
||||
bool Export(Buffer * buffer, string const & format,
|
||||
bool put_in_tempdir, string * view_file = 0);
|
||||
bool put_in_tempdir, string & result_file);
|
||||
///
|
||||
static
|
||||
bool Export(Buffer * buffer, string const & format,
|
||||
bool put_in_tempdir);
|
||||
///
|
||||
static
|
||||
bool Preview(Buffer * buffer, string const & format);
|
||||
@ -44,6 +48,6 @@ public:
|
||||
GetViewableFormats(Buffer const * buffer);
|
||||
///
|
||||
static
|
||||
string const BufferExtension(Buffer const * buffer);
|
||||
string const BufferFormat(Buffer const * buffer);
|
||||
};
|
||||
#endif
|
||||
|
69
src/importer.C
Normal file
69
src/importer.C
Normal file
@ -0,0 +1,69 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "importer.h"
|
||||
#include "converter.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "minibuffer.h"
|
||||
#include "bufferlist.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
extern BufferList bufferlist;
|
||||
extern void InsertAsciiFile(BufferView *, string const &, bool);
|
||||
|
||||
|
||||
void Importer::Import(LyXView * lv, string const & filename,
|
||||
string const & format)
|
||||
{
|
||||
string displaypath = MakeDisplayPath(filename);
|
||||
lv->getMiniBuffer()->Set(_("Importing"), displaypath, "...");
|
||||
|
||||
string lyxfile = ChangeExtension(filename, ".lyx");
|
||||
|
||||
bool result = true;
|
||||
if (format == "text" || format == "textparagraph") {
|
||||
lv->view()->buffer(bufferlist.newFile(lyxfile, string(), true));
|
||||
bool as_paragraphs = format == "textparagraph";
|
||||
InsertAsciiFile(lv->view(), filename, as_paragraphs);
|
||||
lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF);
|
||||
} else {
|
||||
result = Converter::Convert(0, filename, filename, format, "lyx");
|
||||
if (result) {
|
||||
Buffer * buffer = bufferlist.loadLyXFile(lyxfile);
|
||||
if (buffer)
|
||||
lv->view()->buffer(buffer);
|
||||
else
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
// we are done
|
||||
if (result)
|
||||
lv->getMiniBuffer()->Set(displaypath, _("imported."));
|
||||
else
|
||||
lv->getMiniBuffer()->Set(displaypath, _(": import failed."));
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool Importer::IsImportable(string const & format)
|
||||
{
|
||||
if (format == "text" || format == "textparagraph")
|
||||
return true;
|
||||
else
|
||||
return Converter::IsReachable(format, "lyx");
|
||||
}
|
32
src/importer.h
Normal file
32
src/importer.h
Normal file
@ -0,0 +1,32 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef IMPORTER_H
|
||||
#define IMPORTER_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
class LyXView;
|
||||
|
||||
class Importer {
|
||||
public:
|
||||
///
|
||||
static
|
||||
void Import(LyXView * lv, string const & filename,
|
||||
string const & format);
|
||||
static
|
||||
bool IsImportable(string const & format);
|
||||
};
|
||||
#endif
|
@ -1902,7 +1902,7 @@ void InsetFig::Preview(string const & p)
|
||||
tfname += ".eps";
|
||||
string buf1 = OnlyPath(owner->fileName());
|
||||
string buf2 = MakeAbsPath(tfname, buf1);
|
||||
if (!Formats::View(owner, buf2))
|
||||
if (!Formats::View(owner, buf2, "eps"))
|
||||
lyxerr << "Can't view " << buf2 << endl;
|
||||
}
|
||||
|
||||
|
@ -183,6 +183,7 @@ TODO Extended features:
|
||||
#include "lyxtext.h"
|
||||
#include "font.h" // For the lyxfont class.
|
||||
#include <algorithm> // For the std::max
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@ -655,12 +656,15 @@ int InsetGraphics::Latex(Buffer const *buf, ostream & os,
|
||||
}
|
||||
|
||||
// How do we decide to what format should we export?
|
||||
const string empty_string = string();
|
||||
const string eps_outfile = ChangeExtension(params.filename, "eps");
|
||||
const string png_outfile = ChangeExtension(params.filename, "png");
|
||||
|
||||
Converter::Convert(buf, params.filename, eps_outfile, empty_string);
|
||||
Converter::Convert(buf, params.filename, png_outfile, empty_string);
|
||||
string extension = GetExtension(params.filename);
|
||||
//if (pdf) {
|
||||
if (extension != "jpg")
|
||||
Converter::Convert(buf,
|
||||
params.filename, params.filename,
|
||||
extension, "png");
|
||||
//} else
|
||||
Converter::Convert(buf, params.filename, params.filename,
|
||||
extension, "eps");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -159,13 +159,11 @@ void ShowMessage(Buffer const * buf,
|
||||
string const & msg2,
|
||||
string const & msg3, int delay)
|
||||
{
|
||||
if (lyxrc.use_gui) {
|
||||
if (lyxrc.use_gui)
|
||||
buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
|
||||
msg3, delay);
|
||||
} else {
|
||||
// can somebody think of something more clever? cerr?
|
||||
cout << msg1 << msg2 << msg3 << endl;
|
||||
}
|
||||
else
|
||||
lyxerr << msg1 << msg2 << msg3 << endl;
|
||||
}
|
||||
|
||||
|
||||
|
137
src/lyxfunc.C
137
src/lyxfunc.C
@ -74,8 +74,6 @@
|
||||
#include "lyxtext.h"
|
||||
#include "gettext.h"
|
||||
#include "trans_mgr.h"
|
||||
#include "ImportLaTeX.h"
|
||||
#include "ImportNoweb.h"
|
||||
#include "layout.h"
|
||||
#include "WorkArea.h"
|
||||
#include "lyxfr1.h"
|
||||
@ -84,7 +82,9 @@
|
||||
#include "frontends/Toolbar.h"
|
||||
#include "frontends/Menubar.h"
|
||||
#include "FloatList.h"
|
||||
#include "converter.h"
|
||||
#include "exporter.h"
|
||||
#include "importer.h"
|
||||
#include "FontLoader.h"
|
||||
#include "TextCache.h"
|
||||
|
||||
@ -479,10 +479,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
||||
|| lyxrc.fax_command == "none";
|
||||
break;
|
||||
case LFUN_IMPORT:
|
||||
if (argument == "latex" || argument == "noweb")
|
||||
disable = lyxrc.relyx_command == "none";
|
||||
else if (argument == "linuxdoc")
|
||||
disable = lyxrc.linuxdoc_to_lyx_command == "none";
|
||||
disable = !Importer::IsImportable(argument);
|
||||
break;
|
||||
case LFUN_UNDO:
|
||||
disable = buf->undostack.empty();
|
||||
@ -497,7 +494,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
||||
disable = lyxrc.chktex_command == "none";
|
||||
break;
|
||||
case LFUN_BUILDPROG:
|
||||
disable = !Exporter::IsExportable(buf, "Program");
|
||||
disable = !Exporter::IsExportable(buf, "program");
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
@ -932,7 +929,7 @@ string const LyXFunc::Dispatch(int ac,
|
||||
break;
|
||||
|
||||
case LFUN_BUILDPROG:
|
||||
Exporter::Export(owner->buffer(), "Program", true);
|
||||
Exporter::Export(owner->buffer(), "program", true);
|
||||
break;
|
||||
|
||||
case LFUN_RUNCHKTEX:
|
||||
@ -3242,18 +3239,13 @@ void LyXFunc::MenuOpen()
|
||||
}
|
||||
}
|
||||
|
||||
// returns filename if file must be imported,
|
||||
// empty string if either file not found or already loaded
|
||||
// checks for running without gui are missing.
|
||||
|
||||
void LyXFunc::doImportHelper(
|
||||
string const & file, // filename (possibly empty)
|
||||
string const & text, // info when asking for filename
|
||||
string const & pattern, // filetype
|
||||
bool func(BufferView *, string const &) // the real import function
|
||||
)
|
||||
void LyXFunc::doImport(string const & argument)
|
||||
{
|
||||
string filename = file;
|
||||
string format;
|
||||
string filename = split(argument, format, ' ');
|
||||
lyxerr.debug() << "LyXFunc::doImport: " << format
|
||||
<< " file: " << filename << endl;
|
||||
|
||||
if (filename.empty()) { // need user interaction
|
||||
string initpath = lyxrc.document_path;
|
||||
@ -3271,7 +3263,11 @@ void LyXFunc::doImportHelper(
|
||||
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
|
||||
fileDlg.SetButton(1, _("Examples"),
|
||||
AddPath(system_lyxdir, "examples"));
|
||||
filename = fileDlg.Select(text, initpath, pattern);
|
||||
string text = _("Select ") + Formats::PrettyName(format)
|
||||
+ _(" file to import");
|
||||
string format2 = (format == "textparagraph") ? "text" : format;
|
||||
string extension = "*." + Formats::Extension(format2);
|
||||
filename = fileDlg.Select(text, initpath, extension);
|
||||
AllowInput(owner->view());
|
||||
|
||||
// check selected filename
|
||||
@ -3319,78 +3315,7 @@ void LyXFunc::doImportHelper(
|
||||
}
|
||||
// filename should be valid now
|
||||
|
||||
// notify user of import ahead
|
||||
string displaypath = MakeDisplayPath(filename);
|
||||
owner->getMiniBuffer()->Set(_("Importing"), displaypath, "...");
|
||||
|
||||
// call real importer
|
||||
bool result = func(owner->view(), filename);
|
||||
|
||||
// we are done
|
||||
if (result)
|
||||
owner->getMiniBuffer()->Set(displaypath, _("imported."));
|
||||
else
|
||||
owner->getMiniBuffer()->Set(displaypath, _(": import failed."));
|
||||
}
|
||||
|
||||
static
|
||||
bool doImportASCIIasLines(BufferView * view, string const & filename)
|
||||
{
|
||||
view->buffer(bufferlist.newFile(filename, string()));
|
||||
InsertAsciiFile(view, filename, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
static
|
||||
bool doImportASCIIasParagraphs(BufferView * view, string const & filename)
|
||||
{
|
||||
view->buffer(bufferlist.newFile(filename, string()));
|
||||
InsertAsciiFile(view, filename, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static
|
||||
bool doImportLaTeX(BufferView * view, string const & filename)
|
||||
{
|
||||
ImportLaTeX myImport(filename);
|
||||
Buffer * openbuf = myImport.run();
|
||||
if (openbuf) {
|
||||
view->buffer(openbuf);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
bool doImportNoweb(BufferView * view, string const & filename)
|
||||
{
|
||||
ImportNoweb myImport(filename);
|
||||
Buffer * openbuf = myImport.run();
|
||||
if (openbuf) {
|
||||
view->buffer(openbuf);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
bool doImportLinuxDoc(BufferView *, string const & filename)
|
||||
{
|
||||
// run sgml2lyx
|
||||
string tmp = lyxrc.linuxdoc_to_lyx_command + filename;
|
||||
Systemcalls one;
|
||||
Buffer * buf = 0;
|
||||
|
||||
int result = one.startscript(Systemcalls::System, tmp);
|
||||
if (result == 0) {
|
||||
string filename = ChangeExtension(filename, ".lyx");
|
||||
// File was generated without problems. Load it.
|
||||
buf = bufferlist.loadLyXFile(filename);
|
||||
}
|
||||
|
||||
return result == 0;
|
||||
Importer::Import(owner, filename, format);
|
||||
}
|
||||
|
||||
|
||||
@ -3446,36 +3371,6 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
|
||||
}
|
||||
}
|
||||
|
||||
void LyXFunc::doImport(string const & argument)
|
||||
{
|
||||
string type;
|
||||
string filename = split(argument, type, ' ');
|
||||
lyxerr.debug() << "LyXFunc::doImport: " << type
|
||||
<< " file: " << filename << endl;
|
||||
|
||||
if (type == "latex")
|
||||
doImportHelper(filename,
|
||||
_("Select LaTeX file to import"), "*.tex",
|
||||
doImportLaTeX);
|
||||
else if (type == "ascii")
|
||||
doImportHelper(filename,
|
||||
_("Select ASCII file to import"), "*.txt",
|
||||
doImportASCIIasLines);
|
||||
else if (type == "asciiparagraph")
|
||||
doImportHelper(filename,
|
||||
_("Select ASCII file to import"), "*.txt",
|
||||
doImportASCIIasParagraphs);
|
||||
else if (type == "noweb")
|
||||
doImportHelper(filename,
|
||||
_("Select NoWeb file to import"), "*.nw",
|
||||
doImportNoweb);
|
||||
else if (type == "linuxdoc")
|
||||
doImportHelper(filename,
|
||||
_("Select LinuxDoc file to import"), "*.doc",
|
||||
doImportLinuxDoc);
|
||||
else
|
||||
setErrorMessage(string(N_("Unknown import type: ")) + type);
|
||||
}
|
||||
|
||||
void LyXFunc::reloadBuffer()
|
||||
{
|
||||
|
@ -125,10 +125,6 @@ private:
|
||||
|
||||
///
|
||||
void doImport(string const &);
|
||||
///
|
||||
void doImportHelper(string const &, string const &, string const &,
|
||||
bool func(BufferView *, string const &) );
|
||||
|
||||
///
|
||||
void MenuInsertLyXFile(string const &);
|
||||
|
||||
|
66
src/lyxrc.C
66
src/lyxrc.C
@ -68,7 +68,6 @@ enum LyXRCTags {
|
||||
RC_PRINTPAPERDIMENSIONFLAG,
|
||||
RC_CUSTOM_EXPORT_COMMAND,
|
||||
RC_CUSTOM_EXPORT_FORMAT,
|
||||
RC_LITERATE_EXTENSION,
|
||||
RC_SCREEN_DPI,
|
||||
RC_SCREEN_ZOOM,
|
||||
RC_SCREEN_FONT_SIZES,
|
||||
@ -120,7 +119,6 @@ enum LyXRCTags {
|
||||
RC_CURSOR_FOLLOWS_SCROLLBAR,
|
||||
RC_EXIT_CONFIRMATION,
|
||||
RC_DISPLAY_SHORTCUTS,
|
||||
RC_RELYX_COMMAND,
|
||||
RC_MAKE_BACKUP,
|
||||
RC_BACKUPDIR_PATH,
|
||||
RC_RTL_SUPPORT,
|
||||
@ -133,10 +131,10 @@ enum LyXRCTags {
|
||||
RC_LANGUAGE_COMMAND_END,
|
||||
RC_DATE_INSERT_FORMAT,
|
||||
RC_SHOW_BANNER,
|
||||
RC_LINUXDOC_TO_LYX_COMMAND,
|
||||
RC_WHEEL_JUMP,
|
||||
RC_CONVERTER,
|
||||
RC_VIEWER,
|
||||
RC_FORMAT,
|
||||
RC_NEW_ASK_FILENAME,
|
||||
RC_DEFAULT_LANGUAGE,
|
||||
RC_LAST
|
||||
@ -171,6 +169,7 @@ keyword_item lyxrcTags[] = {
|
||||
{ "\\fax_command", RC_FAX_COMMAND },
|
||||
{ "\\fax_program", RC_FAXPROGRAM },
|
||||
{ "\\font_encoding", RC_FONT_ENCODING },
|
||||
{ "\\format", RC_FORMAT },
|
||||
{ "\\input", RC_INPUT },
|
||||
{ "\\kbmap", RC_KBMAP },
|
||||
{ "\\kbmap_primary", RC_KBMAP_PRIMARY },
|
||||
@ -181,8 +180,6 @@ keyword_item lyxrcTags[] = {
|
||||
{ "\\language_command_end", RC_LANGUAGE_COMMAND_END },
|
||||
{ "\\language_package", RC_LANGUAGE_PACKAGE },
|
||||
{ "\\lastfiles", RC_LASTFILES },
|
||||
{ "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
|
||||
{ "\\literate_extension", RC_LITERATE_EXTENSION },
|
||||
{ "\\make_backup", RC_MAKE_BACKUP },
|
||||
{ "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
|
||||
{ "\\new_ask_filename", RC_NEW_ASK_FILENAME },
|
||||
@ -209,7 +206,6 @@ keyword_item lyxrcTags[] = {
|
||||
{ "\\print_to_printer", RC_PRINTTOPRINTER },
|
||||
{ "\\printer", RC_PRINTER },
|
||||
{ "\\ps_command", RC_PS_COMMAND },
|
||||
{ "\\relyx_command", RC_RELYX_COMMAND },
|
||||
{ "\\rtl", RC_RTL_SUPPORT },
|
||||
{ "\\screen_dpi", RC_SCREEN_DPI },
|
||||
{ "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
|
||||
@ -271,8 +267,6 @@ void LyXRC::setDefaults() {
|
||||
document_path = GetEnvPath("HOME");
|
||||
tempdir_path = "/tmp";
|
||||
use_tempdir = true;
|
||||
literate_extension = "none";
|
||||
relyx_command = "reLyX";
|
||||
ps_command = "gs";
|
||||
view_dvi_paper_option = "-paper";
|
||||
default_papersize = BufferParams::PAPER_USLETTER;
|
||||
@ -338,8 +332,6 @@ void LyXRC::setDefaults() {
|
||||
date_insert_format = "%A, %e %B %Y";
|
||||
show_banner = true;
|
||||
cursor_follows_scrollbar = false;
|
||||
//
|
||||
linuxdoc_to_lyx_command="none";
|
||||
|
||||
/// These variables are not stored on disk (perhaps they
|
||||
// should be moved from the LyXRC class).
|
||||
@ -568,16 +560,6 @@ int LyXRC::read(string const & filename)
|
||||
custom_export_format = lexrc.GetString();
|
||||
break;
|
||||
|
||||
case RC_LITERATE_EXTENSION:
|
||||
if (lexrc.next())
|
||||
literate_extension = lexrc.GetString();
|
||||
break;
|
||||
|
||||
case RC_RELYX_COMMAND:
|
||||
if (lexrc.next())
|
||||
relyx_command = lexrc.GetString();
|
||||
break;
|
||||
|
||||
case RC_DEFAULT_PAPERSIZE:
|
||||
if (lexrc.next()) {
|
||||
string size = lowercase(lexrc.GetString());
|
||||
@ -954,17 +936,12 @@ int LyXRC::read(string const & filename)
|
||||
if (lexrc.next())
|
||||
show_banner = lexrc.GetBool();
|
||||
break;
|
||||
case RC_LINUXDOC_TO_LYX_COMMAND:
|
||||
if ( lexrc.next())
|
||||
linuxdoc_to_lyx_command = lexrc.GetString();
|
||||
break;
|
||||
|
||||
case RC_NEW_ASK_FILENAME:
|
||||
if ( lexrc.next())
|
||||
new_ask_filename = lexrc.GetBool();
|
||||
break;
|
||||
case RC_CONVERTER:
|
||||
{
|
||||
case RC_CONVERTER: {
|
||||
string from, to, command, flags;
|
||||
if (lexrc.next())
|
||||
from = lexrc.GetString();
|
||||
@ -977,8 +954,7 @@ int LyXRC::read(string const & filename)
|
||||
Converter::Add(from, to, command, flags);
|
||||
break;
|
||||
}
|
||||
case RC_VIEWER:
|
||||
{
|
||||
case RC_VIEWER: {
|
||||
string format, command;
|
||||
if (lexrc.next())
|
||||
format = lexrc.GetString();
|
||||
@ -987,6 +963,19 @@ int LyXRC::read(string const & filename)
|
||||
Formats::SetViewer(format, command);
|
||||
break;
|
||||
}
|
||||
case RC_FORMAT: {
|
||||
string format, extension, prettyname, shortcut;
|
||||
if (lexrc.next())
|
||||
format = lexrc.GetString();
|
||||
if (lexrc.next())
|
||||
extension = lexrc.GetString();
|
||||
if (lexrc.next())
|
||||
prettyname = lexrc.GetString();
|
||||
if (lexrc.next())
|
||||
shortcut = lexrc.GetString();
|
||||
Formats::Add(format, extension, prettyname, shortcut);
|
||||
break;
|
||||
}
|
||||
case RC_DEFAULT_LANGUAGE:
|
||||
if ( lexrc.next())
|
||||
default_language = lexrc.GetString();
|
||||
@ -1148,10 +1137,6 @@ void LyXRC::output(ostream & os) const
|
||||
if (lyxpipes != system_lyxrc.lyxpipes) {
|
||||
os << "\\serverpipe \"" << lyxpipes << "\"\n";
|
||||
}
|
||||
case RC_RELYX_COMMAND:
|
||||
if (relyx_command != system_lyxrc.relyx_command) {
|
||||
os << "\\relyx_command \"" << relyx_command << "\"\n";
|
||||
}
|
||||
case RC_DATE_INSERT_FORMAT:
|
||||
if (date_insert_format != system_lyxrc.date_insert_format) {
|
||||
os << "\\date_insert_format \"" << date_insert_format
|
||||
@ -1382,18 +1367,6 @@ void LyXRC::output(ostream & os) const
|
||||
os << "\\font_encoding \"" << fontenc << "\"\n";
|
||||
}
|
||||
|
||||
os << "\n#\n"
|
||||
<< "# LINUXDOC SECTION ##################################\n"
|
||||
<< "#\n\n";
|
||||
|
||||
case RC_LINUXDOC_TO_LYX_COMMAND:
|
||||
if (linuxdoc_to_lyx_command
|
||||
!= system_lyxrc.linuxdoc_to_lyx_command) {
|
||||
os << "\\linuxdoc_to_lyx_command \""
|
||||
<< linuxdoc_to_lyx_command
|
||||
<< "\"\n";
|
||||
}
|
||||
|
||||
os << "\n#\n"
|
||||
<< "# FILE SECTION ######################################\n"
|
||||
<< "#\n\n";
|
||||
@ -1565,11 +1538,6 @@ void LyXRC::output(ostream & os) const
|
||||
<< "# 2nd MISC SUPPORT SECTION ##########################\n"
|
||||
<< "#\n\n";
|
||||
|
||||
case RC_LITERATE_EXTENSION:
|
||||
if (literate_extension != system_lyxrc.literate_extension) {
|
||||
os << "\\literate_extension \"" << literate_extension
|
||||
<< "\"\n";
|
||||
}
|
||||
case RC_OVERRIDE_X_DEADKEYS:
|
||||
if (override_x_deadkeys != system_lyxrc.override_x_deadkeys) {
|
||||
os << "\\override_x_deadkeys "
|
||||
|
@ -87,10 +87,6 @@ public:
|
||||
string custom_export_format;
|
||||
///
|
||||
bool pdf_mode;
|
||||
///
|
||||
string literate_extension;
|
||||
/// program for running relyx
|
||||
string relyx_command;
|
||||
/// postscript interpreter (in general "gs", if it is installed)
|
||||
string ps_command;
|
||||
/// option for telling the dvi viewer about the paper size
|
||||
@ -225,8 +221,6 @@ public:
|
||||
/// Do we have to use a GUI?
|
||||
bool use_gui;
|
||||
///
|
||||
string linuxdoc_to_lyx_command;
|
||||
///
|
||||
bool new_ask_filename;
|
||||
///
|
||||
string default_language;
|
||||
|
Loading…
Reference in New Issue
Block a user