The main engine for KLatexFormula. More...
#include <klfbackend.h>
Classes | |
struct | klfInput |
Specific input to KLFBackend::getLatexFormula() More... | |
struct | klfOutput |
KLFBackend::getLatexFormula() result. More... | |
struct | klfSettings |
General settings for KLFBackend::getLatexFormula() More... | |
Static Public Member Functions | |
static klfOutput | getLatexFormula (const klfInput &in, const klfSettings &settings) |
The function that processes everything. More... | |
static bool | saveOutputToFile (const klfOutput &output, const QString &fileName, const QString &format=QString(), QString *errorString=NULL) |
Save the output to image file. More... | |
static bool | saveOutputToDevice (const klfOutput &output, QIODevice *device, const QString &format=QString("PNG"), QString *errorString=NULL) |
Saves the given output into the given device. More... | |
static bool | detectSettings (klfSettings *settings, const QString &extraPath=QString()) |
Detects the system settings and stores the guessed values in settings . More... | |
The main engine for KLatexFormula.
The main engine for KLatexFormula, providing core functionality of transforming LaTeX code into graphics.
Don't instanciate this class, use the static function KLFBackend::getLatexFormula() to do all the processing.
Definition at line 120 of file klfbackend.h.
|
static |
Detects the system settings and stores the guessed values in settings
.
This function tries to find the latex, dvips, gs, and epstopdf in standard locations on the current platform.
The temporary directory is set to the system temporary directory.
Definition at line 767 of file klfbackend.cpp.
References KLFBackend::klfSettings::bborderoffset, KLFBackend::klfSettings::dvipsexec, KLFBackend::klfSettings::epstopdfexec, QDir::fromNativeSeparators(), KLFBackend::klfSettings::gsexec, QString::isEmpty(), QStringList::join(), KLF_DEBUG_TIME_BLOCK, klf_detect_execenv(), KLF_FUNC_NAME, KLF_PATH_SEP, klfDbg, klfFmtCC, klfSearchPath(), KLFBackend::klfSettings::latexexec, KLFBackend::klfSettings::lborderoffset, KLFBackend::klfSettings::rborderoffset, QString::replace(), KLFBackend::klfSettings::tborderoffset, KLFBackend::klfSettings::tempdir, and QDir::tempPath().
|
static |
The function that processes everything.
Pass on a valid klfInput input object, as well as a klfSettings object filled with your input and settings, and you will get output in klfOutput.
If an error occurs, klfOutput::status is non-zero and klfOutput::errorstr contains an explicit error in human-readable form. The latter is Qt-Translated with QObject::tr() with "KLFBackend" comment.
Usage example:
Definition at line 208 of file klfbackend.cpp.
References QString::arg(), KLFBackend::klfSettings::bborderoffset, KLFBackend::klfInput::bg_color, KLFBackend::klfInput::bypassTemplate, QString::contains(), QDateTime::currentDateTime(), QByteArray::data(), KLFBackend::klfInput::dpi, KLFBackend::klfSettings::dvipsexec, KLFBackend::klfSettings::epstopdfexec, KLFBackend::klfSettings::execenv, QFile::exists(), KLFBackend::klfInput::fg_color, QByteArray::find(), QString::fromLatin1(), QString::fromLocal8Bit(), KLFBackend::klfSettings::gsexec, QByteArray::indexOf(), QString::isEmpty(), QStringList::join(), klf_cur_environ(), KLF_FUNC_NAME, klfDbg, KLFERR_BADEPSBBOX, KLFERR_DVIPSNONORMALEXIT, KLFERR_EPSREADFAIL, KLFERR_EPSREADFAIL_OF, KLFERR_EPSTOPDFNONORMALEXIT, KLFERR_EPSWRITEFAIL, KLFERR_GSNONORMALEXIT, KLFERR_LATEXNONORMALEXIT, KLFERR_MISSINGLATEXFORMULA, KLFERR_MISSINGMATHMODETHREEDOTS, KLFERR_NODVIFILE, KLFERR_NODVIPSPROG, KLFERR_NOEPSBBOX, KLFERR_NOEPSFILE, KLFERR_NOEPSFILE_OF, KLFERR_NOEPSTOPDFPROG, KLFERR_NOERROR, KLFERR_NOGSPROG, KLFERR_NOLATEXPROG, KLFERR_NOPDFFILE, KLFERR_NOPNGFILE, KLFERR_PDFREADFAIL, KLFERR_PNGREADFAIL, KLFERR_PROGERR_DVIPS, KLFERR_PROGERR_EPSTOPDF, KLFERR_PROGERR_GS, KLFERR_PROGERR_GS_OF, KLFERR_PROGERR_LATEX, KLFERR_TEXWRITEFAIL, KLFBackend::klfInput::latex, KLFBackend::klfSettings::latexexec, KLFBackend::klfSettings::lborderoffset, KLFBackend::klfInput::mathmode, QString::number(), QFile::open(), KLFBackend::klfSettings::outlineFonts, KLFBackend::klfInput::preamble, KLFBlockProcess::processExitStatus(), KLFBlockProcess::processNormalExit(), KLFBackend::klfSettings::rborderoffset, KLFBlockProcess::readStderrString(), KLFBlockProcess::readStdoutString(), QByteArray::replace(), QString::replace(), QProcess::setWorkingDirectory(), QByteArray::size(), KLFBlockProcess::startProcess(), KLFBackend::klfOutput::status, QString::stripWhiteSpace(), KLFBackend::klfSettings::tborderoffset, KLFBackend::klfSettings::tempdir, and QObject::tr().
|
static |
Saves the given output into the given device.
Overloaded function, provided for convenience. Behaves very much like saveOutputToFile(), except that the format cannot be guessed.
Definition at line 691 of file klfbackend.cpp.
References KLFBackend::klfOutput::epsdata, QByteArray::isEmpty(), QString::operator(), KLFBackend::klfOutput::pdfdata, KLFBackend::klfOutput::pngdata, KLFBackend::klfOutput::result, QImage::save(), and QObject::tr().
Referenced by saveOutputToFile().
|
static |
Save the output to image file.
This function can be used to write output obtained with the getLatexFormula() function, to a file named fileName
with format format
.
output | the data to save (e.g. as returned by getLatexFormula() ) |
fileName | the file name to save to. If empty or equal to "-" then standard output is used. |
format | the format to use to save to fileName |
errorString | if a valid pointer, then when an error occurs this string is set to a text describing the error. |
If format
is an empty string, then format is guessed from filename extension; if no extension is found then format defaults to PNG.
fileName
's extension is NOT adjusted if it does not match an explicitely given format, for example
will output PDF data to the file "myfile.jpg"
.
If errorString
is non-NULL, then it is set to a human-readable description of the error that occurred if this function returns FALSE. It is left untouched if success.
qWarning()s are emitted in case of failure.
Definition at line 726 of file klfbackend.cpp.
References QString::isEmpty(), QFile::open(), saveOutputToDevice(), and QObject::tr().