public class LatexPreProcessor extends AbstractLatexProcessor
processGraphicsSelectMain(File, DirNode)
and in clearing the created files from the latex source directory
in clearCreated(File).| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
LatexPreProcessor.SuffixHandler
Handler for each suffix of a source file.
|
| Modifier and Type | Field and Description |
|---|---|
private static String |
SUFFIX_BB |
private static String |
SUFFIX_BIB |
(package private) static String |
SUFFIX_EPS |
(package private) static String |
SUFFIX_EPSTEX |
private static String |
SUFFIX_FIG |
private static String |
SUFFIX_GP |
private static String |
SUFFIX_JPG |
private static String |
SUFFIX_MP |
private static String |
SUFFIX_MPS |
private static String |
SUFFIX_MPX |
(package private) static String |
SUFFIX_PDFTEX |
private static String |
SUFFIX_PNG |
private static String |
SUFFIX_PTX |
private static String |
SUFFIX_SVG |
private static String |
SUFFIX_TEX |
private static String |
SUFFIX_XBB |
private static Map<String,LatexPreProcessor.SuffixHandler> |
SUFFIX2HANDLER
Maps the suffix to the according handler.
|
private static String |
XFIG_TEX_LANGUAGE
The name of the language
used by the
Settings.getFig2devCommand()
to specify ``special'' text without graphic of an xfig-picture. |
executor, fileUtils, log, settings, SUFFIX_FLS, SUFFIX_LOG, SUFFIX_PDF, SUFFIX_VOID| Constructor and Description |
|---|
LatexPreProcessor(Settings settings,
CommandExecutor executor,
LogWrapper log,
TexFileUtils fileUtils) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addIfLatexMain(File texFile,
Collection<File> latexMainFiles)
If the tex-file
texFile is a latex main file,
add it to latexMainFiles. |
private String[] |
buildArgumentsFig2PdfEps(String language,
String optionsGen,
String optionsPdfEps,
File figFile,
File grpFile)
Returns an array of options of the form
-L <language> <optionsGen> <optionsPdfEps> xxx.fig xxx.pdf/xxx.eps
for invocation of Settings.getFig2devCommand()
for creation of the pdf/eps-part of a fig-figure
as done in runFig2DevInTex(File, LatexDev). |
private String[] |
buildArgumentsFig2Ptx(String optionsGen,
String optionsPtx,
File figFile,
File ptxFile)
Returns an array of options of the form
-L <language> <optionsGen> <optionsPdfEps> -p xxx xxx.fig xxx.ptx for invocation of Settings.getFig2devCommand()
for creation of the tex-part of a fig-figure
as done in runFig2TexInclDev(File). |
protected static String[] |
buildNullArguments(String options,
File file)
Returns an array of strings,
where the 0th entry is
null
and a placeholder for option -x or -m
when used by runEbb(File)
and for the export option
when used by runSvg2Dev(File, LatexDev, boolean)
then follow the options from options
and finally comes the name of file. |
(package private) void |
clearCreated(File texDir)
Deletes all created files
in the directory represented by
texDir
tracing subdirectories recursively. |
private void |
clearCreated(File dir,
DirNode node)
Deletes all created files
in the directory represented by
node, recursively. |
private void |
clearTargetJpgPng(File file)
Deletes the graphic files
created from the svg-file
svgFile. |
private void |
clearTargetMp(File mpFile)
Deletes the graphic files
created from the metapost-file
mpFile. |
private void |
clearTargetPtxPdfEps(File grpFile)
Deletes the files
xxx.ptx, xxx.pdf and
xxx.eps
created from the graphic file grpFile
of the form xxx.y. |
private void |
clearTargetTexIfLatexMain(File texFile)
Deletes the files
created from the tex-file
texFile,
if that is a latex main file. |
private void |
deleteIfExists(File file,
String suffix)
Logging:
EFU05: Failed to delete file
|
private boolean |
isLatexMainFile(File texFile)
Returns whether
texFile is a latex main file,
provided it is readable. |
(package private) Collection<File> |
processGraphicsSelectMain(File dir,
DirNode node)
Detects files in the directory represented by
texNode
and in subdirectories recursively:
those which are in various graphic formats incompatible with LaTeX
are converted into formats which can be inputted or included directly
into a latex file. |
private void |
processGraphicsSelectMain(File dir,
DirNode node,
Collection<String> skipped,
Collection<File> latexMainFiles)
Logging:
WFU03: cannot close file
EFU06: Cannot move file
WPP02: tex file may be latex main file
EEX01, EEX02, EEX03, WEX04, WEX05:
if applications for preprocessing graphic files failed.
|
private void |
processGraphicsSelectMainRec(File dir,
DirNode node,
Collection<String> skipped,
Collection<File> latexMainFiles)
Like
processGraphicsSelectMainRec(File,DirNode,Collection,Collection)
but with recursion to subdirectories. |
private void |
runEbb(File file) |
private void |
runFig2Dev(File figFile)
Converts the fig-file
figFile
into a tex-file with ending ptx
including a pdf-file or an eps-file also created. |
private void |
runFig2DevInTex(File figFile,
LatexDev dev)
From
figFile create pdf/eps-file
containing graphics without text with special flag set. |
private void |
runFig2TexInclDev(File figFile)
From
figFile create tex-file
containing text with special flag set and
including a graphic file containing the rest of figFile. |
private void |
runGnuplot2Dev(File gpFile)
Converts a gnuplot-file into a tex-file with ending ptx
including a pdf-file or an eps-file also created.
|
private void |
runGnuplot2Dev(File gpFile,
LatexDev dev) |
private void |
runMetapost2mps(File mpFile)
Runs mpost on mp-files to generate mps-files.
|
private void |
runSvg2Dev(File svgFile)
Converts an svg-file into a tex-file with ending ptx
including a pdf-file or an eps-file also created.
|
private void |
runSvg2Dev(File svgFile,
LatexDev dev,
boolean renameTex) |
buildArguments, hasErrsWarns, logErrs, logWarn, logWarns, updateprivate static final Map<String,LatexPreProcessor.SuffixHandler> SUFFIX2HANDLER
null, there is no handler.private static final String SUFFIX_TEX
private static final String SUFFIX_PTX
static final String SUFFIX_PDFTEX
static final String SUFFIX_EPSTEX
private static final String SUFFIX_FIG
private static final String SUFFIX_SVG
private static final String SUFFIX_GP
private static final String SUFFIX_MP
private static final String SUFFIX_MPS
private static final String SUFFIX_MPX
private static final String SUFFIX_JPG
private static final String SUFFIX_PNG
private static final String SUFFIX_BIB
static final String SUFFIX_EPS
private static final String SUFFIX_XBB
private static final String SUFFIX_BB
private static final String XFIG_TEX_LANGUAGE
Settings.getFig2devCommand()
to specify ``special'' text without graphic of an xfig-picture.
Note that the languages pdftex_t and pstex_t
are equivalent.LatexPreProcessor(Settings settings, CommandExecutor executor, LogWrapper log, TexFileUtils fileUtils)
private void runFig2Dev(File figFile) throws BuildFailureException
figFile
into a tex-file with ending ptx
including a pdf-file or an eps-file also created.
To that end, invokes runFig2DevInTex(File, LatexDev) twice
to create a pdf-file and an eps-file
and invokes runFig2TexInclDev(File) (once)
to create the tex-file.
Logging:
figFile - the fig file to be processed.BuildFailureException - TEX01 if invocation of the fig2dev command
returned by Settings.getFig2devCommand() failed.
This is invoked twice: once for creating the pdf-file
and once for creating the pdf_t-file.processGraphicsSelectMain(File, DirNode)private void runFig2DevInTex(File figFile, LatexDev dev) throws BuildFailureException
figFile create pdf/eps-file
containing graphics without text with special flag set.
The output format depends on dev.
The resulting file is included in some tex-file
created by runFig2TexInclDev(File).
Conversion is done by Settings.getFig2devCommand().
Logging: FIXME: EEX01, EEX02, EEX03, WEX04, WEX05
figFile - the fig-file to be processeddev - represents the target: either a pdf-file or an eps-file.BuildFailureException - FIXME: TEX01,private String[] buildArgumentsFig2PdfEps(String language, String optionsGen, String optionsPdfEps, File figFile, File grpFile)
-L <language> <optionsGen> <optionsPdfEps> xxx.fig xxx.pdf/xxx.eps
for invocation of Settings.getFig2devCommand()
for creation of the pdf/eps-part of a fig-figure
as done in runFig2DevInTex(File, LatexDev).language - is the output language
which is either pdftex or pstexoptionsGen - the general options, applying to both the pdf/eps part
and the tex part of the figure under consideration.optionsPdfEps - the options, specific for the pdf/eps part (which is the same)
of the figure under consideration.figFile - the fig-file to be transformed.grpFile - the graphics file (pdf/eps-file)
which is the result of the transformation.private void runFig2TexInclDev(File figFile) throws BuildFailureException
figFile create tex-file
containing text with special flag set and
including a graphic file containing the rest of figFile.
Inclusion is without file extension and so both possible results
of runFig2DevInTex(File, LatexDev) can be included
when compiling with latex.
Conversion is done by Settings.getFig2devCommand().
Logging: FIXME: warning EEX01, EEX02, EEX03, WEX04, WEX05
figFile - the fig-file to be processedBuildFailureException - FIXME: TEX01,private String[] buildArgumentsFig2Ptx(String optionsGen, String optionsPtx, File figFile, File ptxFile)
-L <language> <optionsGen> <optionsPdfEps> -p xxx xxx.fig xxx.ptx for invocation of Settings.getFig2devCommand()
for creation of the tex-part of a fig-figure
as done in runFig2TexInclDev(File).
Note that the option -p xxx
specifies the name of the pdf/eps-file
included in the result file ptxFile
without suffix.optionsGen - the general options, applying to both the pdf/eps part
and the tex part of the figure under consideration.optionsPtx - the options, specific for the tex part
of the figure under consideration (for the ptx-file).figFile - the fig-file to be transformed.ptxFile - the ptx-file which is the result of the transformation.private void clearTargetPtxPdfEps(File grpFile)
xxx.ptx, xxx.pdf and
xxx.eps
created from the graphic file grpFile
of the form xxx.y.
Logging: EFU05: Failed to delete file
grpFile - a graphic file.private void runGnuplot2Dev(File gpFile) throws BuildFailureException
runGnuplot2Dev(File, LatexDev) twice
to create a pdf-file and an eps-file
and to create the tex-file which can include both.
Logging:
gpFile - the gp-file (gnuplot format) to be converted to pdf and ptx.BuildFailureException - TEX01 if invocation of the ptx/pdf-conversion built-in
in gnuplot fails.processGraphicsSelectMain(File, DirNode)private void runGnuplot2Dev(File gpFile, LatexDev dev) throws BuildFailureException
BuildFailureExceptionprivate void runMetapost2mps(File mpFile) throws BuildFailureException
Logging:
command failed. For details...
command failed. No log file
mpFile - the metapost file to be processed.BuildFailureException - TEX01 if invocation of the mpost command failed.processGraphicsSelectMain(File, DirNode)private void clearTargetMp(File mpFile)
mpFile.
Logging:
mpFile - a metapost file.private void runSvg2Dev(File svgFile) throws BuildFailureException
runSvg2Dev(File, LatexDev, boolean) twice
to create a pdf-file and an eps-file
and to create the tex-file which can include both.
Logging:
svgFile - the svg-file to be converted to a pdf-file and a ptx-file.BuildFailureException - TEX01 if invocation of the ptx/pdf-conversion built-in
in svg2dev fails.processGraphicsSelectMain(File, DirNode)private void runSvg2Dev(File svgFile, LatexDev dev, boolean renameTex) throws BuildFailureException
BuildFailureExceptionprivate void runEbb(File file) throws BuildFailureException
BuildFailureExceptionprotected static String[] buildNullArguments(String options, File file)
null
and a placeholder for option -x or -m
when used by runEbb(File)
and for the export option
when used by runSvg2Dev(File, LatexDev, boolean)
then follow the options from options
and finally comes the name of file.private void clearTargetJpgPng(File file)
svgFile.
Logging: EFU05: Failed to delete file
private void deleteIfExists(File file, String suffix)
Logging: EFU05: Failed to delete file
private boolean isLatexMainFile(File texFile)
texFile is a latex main file,
provided it is readable.
Otherwise logs a warning and returns false.
Logging:
texFile - the tex-file to decide on whether it is a latex main file.texFile is definitively a latex main file.
If this is not readable, false.private void addIfLatexMain(File texFile, Collection<File> latexMainFiles)
texFile is a latex main file,
add it to latexMainFiles.
Logging:
texFile - the tex-file to be added to latexMainFiles
if it is a latex main file.latexMainFiles - the collection of latex main files found so far.private void clearTargetTexIfLatexMain(File texFile)
texFile,
if that is a latex main file.
Logging:
texFile - the tex-file of which the created files shall be deleted
if it is a latex main file.Collection<File> processGraphicsSelectMain(File dir, DirNode node) throws BuildFailureException
texNode
and in subdirectories recursively:
Logging:
dir - represents the tex source directory or a subdirectory.node - a node associated with dir.BuildFailureException - TEX01 invoking
processGraphicsSelectMain(File, DirNode, Collection, Collection)private void processGraphicsSelectMain(File dir, DirNode node, Collection<String> skipped, Collection<File> latexMainFiles) throws BuildFailureException
Logging:
dir - represents the tex source directory or a subdirectory.node - a node associated with dir.skipped - the collection of suffixes of files with handling skipped so far
because there is no handler.
FIXME: interesting for files without suffix or for hidden files.latexMainFiles - the collection of latex main files found so far.BuildFailureException - TEX01 invoking
LatexPreProcessor.SuffixHandler.procSrc(File, LatexPreProcessor)
only for LatexPreProcessor.SuffixHandler.fig,
LatexPreProcessor.SuffixHandler.gp and
LatexPreProcessor.SuffixHandler.mp
because these invoke external programs.private void processGraphicsSelectMainRec(File dir, DirNode node, Collection<String> skipped, Collection<File> latexMainFiles) throws BuildFailureException
processGraphicsSelectMainRec(File,DirNode,Collection,Collection)
but with recursion to subdirectories.BuildFailureExceptionvoid clearCreated(File texDir)
texDir
tracing subdirectories recursively.
For details of deletions within a single directory
see clearCreated(File, DirNode).
Logging:
texDir - represents the tex source directory or a subdirectory.private void clearCreated(File dir, DirNode node)
node, recursively.
In each directory, the sub-directories are not deleted themselves
but cleaned recursively.
The other files are cleaned, i.e.
their targets are deleted in an ordering reverse to creation
proceeding in the following steps:
LatexPreProcessor.SuffixHandler.clearTarget(File, LatexPreProcessor, Map).
FIXME: what about deletion of a graphic source file in this course?
LatexPreProcessor.SuffixHandler.getSuffix()) it is ignored.
Else its target is cleared as described in
LatexPreProcessor.SuffixHandler.clearTarget(File, LatexPreProcessor, Map).
Logging:
dir - represents the tex source directory or a subdirectory.node - a node associated with dir.Copyright © 2016–2018 Simuline Organization (l2r). All rights reserved.