28 #include <qapplication.h>
31 #include <qdatetime.h>
32 #include <qtextstream.h>
40 #include "klfqt34common.h"
75 #ifdef KLF_EXTRA_SEARCH_PATHS
76 # define EXTRA_PATHS_PRE KLF_EXTRA_SEARCH_PATHS ,
77 # define EXTRA_PATHS KLF_EXTRA_SEARCH_PATHS
79 # define EXTRA_PATHS_PRE
84 #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
89 static const char * standard_extra_paths[] = {
91 "C:\\Program Files\\MiKTeX*\\miktex\\bin",
92 "C:\\Program Files\\gs\\gs*\\bin",
95 #elif defined(Q_WS_MAC)
100 static const char * standard_extra_paths[] = {
102 "/usr/texbin:/usr/local/bin:/sw/bin:/sw/usr/bin",
110 static const char * standard_extra_paths[] = {
120 KLFBackend::KLFBackend()
128 QString stdouthtml = stdoutstr;
129 QString stderrhtml = stderrstr;
130 stdouthtml.
replace(
"&",
"&");
131 stdouthtml.
replace(
"<",
"<");
132 stdouthtml.
replace(
">",
">");
133 stderrhtml.
replace(
"&",
"&");
134 stderrhtml.
replace(
"<",
"<");
135 stderrhtml.
replace(
">",
">");
138 return QObject::tr(
"<p><b>%1</b> reported an error (exit status %2). No Output was generated.</p>",
140 .arg(progname).arg(exitstatus);
143 QObject::tr(
"<p><b>%1</b> reported an error (exit status %2). Here is full stdout output:</p>\n"
144 "<pre>\n%3</pre>",
"KLFBackend")
145 .arg(progname).arg(exitstatus).arg(stdouthtml);
148 QObject::tr(
"<p><b>%1</b> reported an error (exit status %2). Here is full stderr output:</p>\n"
149 "<pre>\n%3</pre>",
"KLFBackend")
150 .arg(progname).arg(exitstatus).arg(stderrhtml);
152 return QObject::tr(
"<p><b>%1</b> reported an error (exit status %2). Here is full stderr output:</p>\n"
153 "<pre>\n%3</pre><p>And here is full stdout output:</p><pre>\n%4</pre>",
"KLFBackend")
154 .arg(progname).arg(exitstatus).arg(stderrhtml).arg(stdouthtml);
160 struct cleanup_caller {
162 cleanup_caller(
QString fn) : tempfname(fn) { }
164 KLFBackend::cleanup(tempfname);
171 QRegExp rx(
"\\$(?:(\\$|(?:[A-Za-z0-9_]+))|\\{([A-Za-z0-9_]+)\\})");
173 while ( (i = rx.rx_indexin_i(s, i)) != -1 ) {
175 QString envvarname = rx.cap(1);
182 const char *svalue = getenv(qPrintable(envvarname));
184 s.
replace(i, rx.matchedLength(), qsvalue);
195 for (k = 0; k < (int)list->size(); ++k) {
196 if (list->operator[](k).startsWith(var+
QString(
"="))) {
197 list->operator[](k) = line;
212 double x1, x2, y1, y2;
215 static void correct_eps_bbox(
const QByteArray& epsdata,
const klfbbox& bbox_corrected,
const klfbbox& bbox_orig,
216 double vectorscale,
QByteArray * epsdatacorrected);
230 qDebug(
"%s: %s: KLFBackend::getLatexFormula() called. latex=%s",
KLF_FUNC_NAME, KLF_SHORT_TIME,
231 qPrintable(in.
latex));
235 for (k = 0; k < (int)settings.
execenv.size(); ++k) {
238 qWarning(
"%s: badly formed environment definition in `environ': %s",
KLF_FUNC_NAME,
239 qPrintable(settings.
execenv[k]));
244 __klf_append_replace_env_var(&execenv, varname, newenvdef);
247 klfDbg(
"execution environment for sub-processes:\n"+execenv.
join(
"\n")) ;
258 res.settings = settings;
271 QString tempfname = settings.
tempdir +
"/klatexformulatmp" KLF_VERSION_STRING
"-"
273 #ifdef KLFBACKEND_QT4
274 +
"-p"+
QString(
"%1").
arg(QApplication::applicationPid(), 0, 26)
276 +
"-p" +
QString(
"%1").
arg(rand()%100000, 0, 26)
280 QString fnTex = tempfname +
".tex";
281 QString fnDvi = tempfname +
".dvi";
282 QString fnRawEps = tempfname +
"-raw.eps";
283 QString fnBBCorrEps = tempfname +
"-bbcorr.eps";
284 QString fnOutlFontsEps = tempfname +
"-outlfonts.eps";
286 QString fnPng = tempfname +
".png";
287 QString fnPdf = tempfname +
".pdf";
291 cleanup_caller cleanupcallerinstance(tempfname);
293 #ifdef KLFBACKEND_QT4
298 if (latexsimplified.
isEmpty()) {
299 res.errorstr =
QObject::tr(
"You must specify a LaTeX formula!",
"KLFBackend");
308 res.errorstr =
QObject::tr(
"The math mode string doesn't contain '...'!",
"KLFBackend");
317 bool r = file.
open(dev_WRITEONLY);
320 res.errorstr =
QObject::tr(
"Can't open file for writing: '%1'!",
"KLFBackend")
326 stream <<
"\\documentclass{article}\n"
327 <<
"\\usepackage[dvips]{color}\n"
329 <<
"\\begin{document}\n"
330 <<
"\\thispagestyle{empty}\n"
335 << ( (qAlpha(in.
bg_color)>0) ?
"\\pagecolor{klfbgcolor}\n" :
"" )
336 <<
"{\\color{klffgcolor} " << latexin <<
" }\n"
337 <<
"\\end{document}\n";
350 args << settings.
latexexec << dir_native_separators(fnTex);
352 qDebug(
"%s: %s: about to exec latex...",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
354 qDebug(
"%s: %s: latex returned.",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
358 res.errorstr =
QObject::tr(
"Unable to start Latex program %1!",
"KLFBackend")
364 res.errorstr =
QObject::tr(
"Latex was killed!",
"KLFBackend");
376 res.errorstr =
QObject::tr(
"DVI file didn't appear after having called Latex!",
"KLFBackend");
386 args << settings.
dvipsexec <<
"-E" << dir_native_separators(fnDvi)
387 <<
"-o" << dir_native_separators(fnRawEps);
389 qDebug(
"%s: %s: about to dvips... %s",
KLF_FUNC_NAME, KLF_SHORT_TIME, qPrintable(args.
join(
" "))) ;
391 qDebug(
"%s: %s: dvips returned.",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
395 res.errorstr =
QObject::tr(
"Unable to start dvips!\n",
"KLFBackend");
400 res.errorstr =
QObject::tr(
"Dvips was mercilessly killed!\n",
"KLFBackend");
411 res.errorstr =
QObject::tr(
"EPS file didn't appear after dvips call!\n",
"KLFBackend");
488 QFile epsfile(fnRawEps);
489 r = epsfile.
open(dev_READONLY);
492 res.errorstr =
QObject::tr(
"Can't read file '%1'!\n",
"KLFBackend").arg(fnRawEps);
497 klfbbox bbox, bbox_corrected;
498 bool ok = read_eps_bbox(rawepsdata, &bbox, &res);
507 int width_pt = bbox.x2 - bbox.x1;
508 int height_pt = bbox.y2 - bbox.y1;
512 bbox_corrected.x1 = 0;
513 bbox_corrected.y1 = 0;
514 bbox_corrected.x2 = width_pt;
515 bbox_corrected.y2 = height_pt;
518 correct_eps_bbox(rawepsdata, bbox_corrected, bbox, 1.0,
521 QFile epsgoodfile(fnBBCorrEps);
522 r = epsgoodfile.
open(dev_WRITEONLY);
525 res.errorstr =
QObject::tr(
"Can't write to file '%1'!\n",
"KLFBackend")
529 epsgoodfile.dev_write(res.epsdata);
532 qDebug(
"%s: %s: eps bbox set.",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
552 const char *env_gs_device = getenv(
"KLFBACKEND_GS_PS_DEVICE");
553 if (env_gs_device != NULL) {
560 int try_ps_dev_i = 0;
561 for (try_ps_dev_i = 0; try_ps_dev_i < try_ps_devices.size(); try_ps_dev_i++) {
562 QString psdev = try_ps_devices[try_ps_dev_i];
563 qDebug(
"trying with gs device %s ...", qPrintable(psdev));
566 args << settings.
gsexec <<
"-dNOCACHE" <<
"-dNOPAUSE" <<
"-dSAFER" <<
"-dEPSCrop"
568 <<
"-sOutputFile="+dir_native_separators(fnOutlFontsEps)
569 <<
"-q" <<
"-dBATCH" << dir_native_separators(fnBBCorrEps);
571 qDebug(
"%s: %s: about to gs (for outline fonts)...\n%s",
KLF_FUNC_NAME, KLF_SHORT_TIME,
572 qPrintable(args.
join(
" ")));
574 qDebug(
"%s: %s: gs returned (for outline fonts).",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
584 res.errorstr =
QObject::tr(
"Unable to start gs!\n",
"KLFBackend");
589 res.errorstr =
QObject::tr(
"gs died abnormally!\n",
"KLFBackend");
600 res.errorstr =
QObject::tr(
"EPS file (with outlined fonts) didn't appear after call to gs!\n",
606 QFile ofepsfile(fnOutlFontsEps);
607 r = ofepsfile.
open(dev_READONLY);
610 res.errorstr =
QObject::tr(
"Unable to read file %1!\n",
"KLFBackend")
611 .arg(fnOutlFontsEps);
614 res.epsdata = ofepsfile.readAll();
622 args << settings.
gsexec <<
"-dNOPAUSE" <<
"-dSAFER" <<
"-dEPSCrop"
624 <<
"-dGraphicsAlphaBits=4";
626 args <<
"-sDEVICE=png16m";
628 args <<
"-sDEVICE=pngalpha";
630 args <<
"-sOutputFile="+dir_native_separators(fnPng) <<
"-q" <<
"-dBATCH"
631 << dir_native_separators(fnFinalEps);
633 qDebug(
"%s: %s: about to gs... %s",
KLF_FUNC_NAME, KLF_SHORT_TIME, qPrintable(args.
join(
" "))) ;
635 qDebug(
"%s: %s: gs returned.",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
639 res.errorstr =
QObject::tr(
"Unable to start gs!\n",
"KLFBackend");
644 res.errorstr =
QObject::tr(
"gs died abnormally!\n",
"KLFBackend");
655 res.errorstr =
QObject::tr(
"PNG file didn't appear after call to gs!\n",
"KLFBackend");
660 QFile pngfile(fnPng);
661 r = pngfile.
open(dev_READONLY);
664 res.errorstr =
QObject::tr(
"Unable to read file %1!\n",
"KLFBackend")
668 res.pngdata_raw = pngfile.readAll();
671 res.result.loadFromData(res.pngdata_raw,
"PNG");
674 res.result.img_settext(
"AppVersion",
QString::fromLatin1(
"KLatexFormula " KLF_VERSION_STRING));
675 res.result.img_settext(
"Application",
676 QObject::tr(
"Created with KLatexFormula version %1",
"KLFBackend::saveOutputToFile"));
677 res.result.img_settext(
"Software",
QString::fromLatin1(
"KLatexFormula " KLF_VERSION_STRING));
678 res.result.img_settext(
"InputLatex", in.
latex);
679 res.result.img_settext(
"InputMathMode", in.
mathmode);
680 res.result.img_settext(
"InputPreamble", in.
preamble);
681 res.result.img_settext(
"InputFgColor",
QString(
"rgb(%1, %2, %3)").arg(qRed(in.
fg_color))
683 res.result.img_settext(
"InputBgColor",
QString(
"rgba(%1, %2, %3, %4)").arg(qRed(in.
bg_color))
695 #ifdef KLFBACKEND_QT4
700 buf.open(dev_WRITEONLY);
701 bool r = res.result.save(&buf,
"PNG");
703 qWarning(
"%s: Error: Can't save \"final\" PNG data.",
KLF_FUNC_NAME);
704 res.pngdata.ba_assign(res.pngdata_raw);
712 args << settings.
epstopdfexec << dir_native_separators(fnFinalEps)
713 << (
"--outfile="+dir_native_separators(fnPdf));
715 qDebug(
"%s: %s: about to epstopdf... %s",
KLF_FUNC_NAME, KLF_SHORT_TIME, qPrintable(args.
join(
" "))) ;
717 qDebug(
"%s: %s: epstopdf returned.",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
721 res.errorstr =
QObject::tr(
"Unable to start epstopdf!\n",
"KLFBackend");
726 res.errorstr =
QObject::tr(
"epstopdf died nastily!\n",
"KLFBackend");
736 qDebug(
"%s: %s: pdf file '%s' didn't appear after epstopdf!",
KLF_FUNC_NAME, KLF_SHORT_TIME,
739 res.errorstr =
QObject::tr(
"PDF file didn't appear after call to epstopdf!\n",
"KLFBackend");
744 QFile pdffile(fnPdf);
745 r = pdffile.
open(dev_READONLY);
748 res.errorstr =
QObject::tr(
"Unable to read file %1!\n",
"KLFBackend").arg(fnPdf);
751 res.pdfdata = pdffile.readAll();
755 qDebug(
"%s: %s: end of function.",
KLF_FUNC_NAME, KLF_SHORT_TIME) ;
762 static bool s_starts_with(
const char * x,
int len_x,
const char *test,
int len_test)
764 if (len_x < len_test)
766 return !strncmp(x, test, len_test);
769 #define D_RX "([0-9eE.-]+)"
771 static bool parse_bbox_values(
const QString& str, klfbbox *bbox)
774 QRegExp rx_bbvalues(
"" D_RX
"\\s+" D_RX
"\\s+" D_RX
"\\s+" D_RX
"");
775 int i = rx_bbvalues.rx_indexin(str);
779 bbox->x1 = rx_bbvalues.cap(1).toDouble();
780 bbox->y1 = rx_bbvalues.cap(2).toDouble();
781 bbox->x2 = rx_bbvalues.cap(3).toDouble();
782 bbox->y2 = rx_bbvalues.cap(4).toDouble();
788 static const char * hibboxtag =
"%%HiResBoundingBox:";
789 static const char * bboxtag =
"%%BoundingBox:";
790 static const int hibboxtaglen = strlen(hibboxtag);
791 static const int bboxtaglen = strlen(bboxtag);
795 buf_setdata(buf, epsdata);
796 bool r = buf.open(dev_READONLY);
798 qWarning(
"What's going on!!?! can't open buffer for reading? Will Fail!!!") ;
802 QObject::tr(
"DVIPS did not provide parsable %%BoundingBox: in its output!",
"KLFBackend");
804 char linebuffer[512];
806 bool gotepsbbox =
false;
807 int still_look_for_hiresbbox_lines = 5;
808 while ((n = buf.readLine(linebuffer,
sizeof(linebuffer)-1)) > 0) {
809 if (gotepsbbox && still_look_for_hiresbbox_lines-- < 0) {
812 klfDbg(
"stopped looking for hires-bbox.") ;
815 if (s_starts_with(linebuffer, n-1, hibboxtag, hibboxtaglen)) {
823 klfDbg(
"got hires-bbox.") ;
827 if (s_starts_with(linebuffer, n-1, bboxtag, bboxtaglen)) {
835 klfDbg(
"got normal bbox.") ;
871 static void correct_eps_bbox(
const QByteArray& rawepsdata,
const klfbbox& bbox_corrected,
872 const klfbbox& bbox_orig,
double vectorscale,
875 static const char * bboxdecl =
"%%BoundingBox:";
876 static int bboxdecl_len = strlen(bboxdecl);
878 double offx = bbox_corrected.x1 - bbox_orig.x1;
879 double offy = bbox_corrected.y1 - bbox_orig.y1;
883 char nl[] =
"\0\0\0";
884 #ifdef KLFBACKEND_QT4
885 i = rawepsdata.
indexOf(bboxdecl);
887 QCString rawepsdata_s(rawepsdata.
data(), rawepsdata.
size());
888 i = rawepsdata_s.find(bboxdecl);
894 int j = i+bboxdecl_len;
895 while (j < (
int)rawepsdata.
size() && rawepsdata[j] !=
'\r' && rawepsdata[j] !=
'\n')
899 if (rawepsdata[j] ==
'\r' && j < (
int)rawepsdata.
size()-1 && rawepsdata[j+1] ==
'\n') {
900 nl[0] =
'\r', nl[1] =
'\n';
902 nl[0] = rawepsdata[j];
906 double dwi = bbox_corrected.x2 * vectorscale;
907 double dhi = bbox_corrected.y2 * vectorscale;
908 int wi = (int)(dwi + 0.99999) ;
909 int hi = (int)(dhi + 0.99999) ;
913 snprintf(buffer,
sizeof(buffer)-1,
914 "%%%%BoundingBox: 0 0 %d %d%s"
915 "%%%%HiResBoundingBox: 0 0 %.6g %.6g%s",
918 buffer_len = strlen(buffer);
949 snprintf(buffer2,
sizeof(buffer2)-1,
952 "%%%%PageBoundingBox 0 0 %d %d%s"
953 "<< /PageSize [%d %d] >> setpagedevice%s"
963 vectorscale, vectorscale, nl,
965 buffer2_len = strlen(buffer2);
974 #ifdef KLFBACKEND_QT4
978 QCString neweps(rawepsdata.
data(), rawepsdata.
size());
980 neweps.
replace(i, len, buffer);
982 const char * endsetupstr =
"%%EndSetup";
983 int i2 = neweps.s_indexOf(endsetupstr);
987 i2 += strlen(endsetupstr);
989 neweps.
replace(i2, 0, buffer2);
991 qDebug(
"neweps has now length=%d",neweps.
size());
992 qDebug(
"New eps bbox is [0 0 %.6g %.6g] with translate [%.6g %.6g] and scale %.6g.",
993 dwi, dhi, offx, offy, vectorscale);
995 epsdatacorrected->ba_assign(neweps);
1008 void KLFBackend::cleanup(
QString tempfname)
1010 const char *skipcleanup = getenv(
"KLFBACKEND_LEAVE_TEMP_FILES");
1011 if (skipcleanup != NULL && (*skipcleanup ==
'1' || *skipcleanup ==
't' || *skipcleanup ==
'T' ||
1012 *skipcleanup ==
'y' || *skipcleanup ==
'Y'))
1033 QMutex KLFBackend::__mutex;
1051 QString format = fmt.s_trimmed().s_toUpper();
1054 if (format ==
"EPS" || format ==
"PS") {
1055 device->dev_write(klfoutput.
epsdata);
1056 }
else if (format ==
"PNG") {
1057 device->dev_write(klfoutput.
pngdata);
1058 }
else if (format ==
"PDF") {
1061 "KLFBackend::saveOutputToFile");
1062 qWarning(
"%s", qPrintable(error));
1063 if (errorStringPtr != NULL)
1067 device->dev_write(klfoutput.
pdfdata);
1069 bool res = klfoutput.
result.
save(device, format.s_toLatin1());
1072 "KLFBackend::saveOutputToDevice").arg(format);
1073 qWarning(
"%s", qPrintable(errstr));
1074 if (errorStringPtr != NULL)
1075 *errorStringPtr = errstr;
1090 if ( ! fi.fi_suffix().isEmpty() )
1091 format = fi.fi_suffix();
1095 format = format.s_trimmed().s_toUpper();
1098 if (fileName.
isEmpty() || fileName ==
"-") {
1099 if ( ! fout.f_open_fp(stdout) ) {
1101 "KLFBackend::saveOutputToFile").arg(fout.f_error());
1102 qWarning(
"%s", qPrintable(error));
1103 if (errorStringPtr != NULL)
1104 *errorStringPtr = error;
1108 fout.f_setFileName(fileName);
1109 if ( ! fout.
open(dev_WRITEONLY) ) {
1111 "KLFBackend::saveOutputToFile")
1112 .arg(fileName).arg(fout.f_error());
1113 qWarning(
"%s", qPrintable(error));
1114 if (errorStringPtr != NULL)
1115 *errorStringPtr = error;
1130 for (k = 0; standard_extra_paths[k] != NULL; ++k) {
1131 stdextrapaths.append(standard_extra_paths[k]);
1138 #ifdef KLFBACKEND_QT4
1141 # if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN) || defined(Q_OS_MACX)
1143 # elif defined(Q_OS_WIN32)
1144 settings->
tempdir = getenv(
"TEMP");
1160 { & settings->
gsexec, progGS },
1165 klfDbg(
klfFmtCC(
"Our base extra paths are: %s", qPrintable(extra_paths))) ;
1166 QString ourextrapaths = extra_paths;
1167 ourextrapaths.
replace(
"@executable_path", qApp->applicationDirPath());
1168 klfDbg(
klfFmtCC(
"Our extra paths are: %s", qPrintable(ourextrapaths))) ;
1170 for (k = 0; progs_to_find[k].target_setting != NULL; ++k) {
1171 klfDbg(
"Looking for "+progs_to_find[k].prog_names.join(
" or ")) ;
1172 for (j = 0; j < (int)progs_to_find[k].prog_names.size(); ++j) {
1173 klfDbg(
"Testing `"+progs_to_find[k].prog_names[j]+
"'") ;
1174 *progs_to_find[k].target_setting
1175 =
klfSearchPath(progs_to_find[k].prog_names[j], ourextrapaths);
1176 if (!progs_to_find[k].target_setting->isEmpty()) {
1177 klfDbg(
"Found! at `"+ *progs_to_find[k].target_setting+
"'") ;
1185 bool result_failure =
1189 return !result_failure;
1213 if (gsfi.
fileName() ==
"mgs.exe") {
1215 + dir_native_separators(gsfi.fi_absolutePath()+
"/../../ghostscript/base")
1217 + dir_native_separators(gsfi.fi_absolutePath()+
"/../../fonts");
1218 __klf_append_replace_env_var(& settings->
execenv,
"MIKTEX_GS_LIB", mgsenv);
1219 klfDbg(
"Adjusting environment for mgs.exe: `"+mgsenv+
"'") ;
1227 QString execenvpath =
QString(
"PATH=%1:$PATH").
arg(epstopdf_fi.fi_absolutePath());
1228 __klf_append_replace_env_var(& settings->
execenv,
"PATH", execenvpath);
#define KLFERR_PNGREADFAIL
Error while opening .png file for reading.
Defines the KLFBlockProcess class.
#define KLFERR_PROGERR_LATEX
latex exited with a non-zero status
#define KLFERR_EPSREADFAIL
Error while opening .eps file for reading.
fromNativeSeparators(const QString &pathName)
bool KLF_EXPORT klf_detect_execenv(KLFBackend::klfSettings *settings)
detects any additional settings to environment variables
#define KLFERR_TEXWRITEFAIL
Error while opening .tex file for writing.
#define KLFERR_MISSINGMATHMODETHREEDOTS
The "..." is missing in math mode string.
save(const QString &fileName, const char *format=0, int quality=-1)
QString errorstr
An explicit error string.
#define KLFERR_PROGERR_EPSTOPDF
epstopdf exited with non-zero status (if epstopdf is to be used)
arg(const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char( ' ')
#define KLFERR_EPSREADFAIL_OF
Error while opening -outlfonts.eps after outlining fonts with gs.
#define klfDbg(streamableItems)
print debug stream items
#define KLFERR_PDFREADFAIL
Error while opening .pdf file for reading.
bool startProcess(QStringList cmd, QByteArray stdindata, QStringList env=QStringList())
replace(int pos, int len, const QByteArray &after)
#define KLFERR_EPSTOPDFNONORMALEXIT
epstopdf program did not exit properly (program killed) (see also KLFERR_PROGERR_EPSTOPDF) ...
#define KLFERR_NOERROR
No Error.
join(const QString &separator)
#define KLFERR_NOLATEXPROG
Error while launching the given latex program.
static bool saveOutputToDevice(const klfOutput &output, QIODevice *device, const QString &format=QString("PNG"), QString *errorString=NULL)
Saves the given output into the given device.
tr(const char *sourceText, const char *comment=0, int n=-1)
replace(int position, int n, const QString &after)
#define KLFERR_NODVIFILE
No .dvi file appeared after runnig latex program.
number(long n, int base=10)
indexOf(const QByteArray &ba, int from=0)
fromLocal8Bit(const char *str, int size=-1)
General settings for KLFBackend::getLatexFormula()
KLF_EXPORT QString klfSearchPath(const QString &prog, const QString &extra_path="")
Smart executable searching in a given path list with wildcards.
#define KLFERR_PROGERR_GS_OF
gs (while outlining fonts) exited with non-zero status
KLFBackend::getLatexFormula() result.
KLF_EXPORT QStringList klf_cur_environ()
The current process environment.
#define KLFERR_NOEPSFILE
no .eps file appeared after running dvips program
#define KLFERR_GSNONORMALEXIT
gs program did not exit properly (program killed) (see also KLFERR_PROGERR_GS)
#define KLFERR_NOEPSTOPDFPROG
Error while launching the given epstopdf program (if given)
#define KLF_DEBUG_TIME_BLOCK(msg)
Utility to time the execution of a block.
#define KLFERR_NOPDFFILE
No .pdf file appeared after running epstopdf program.
QString readStderrString()
contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive)
setWorkingDirectory(const QString &dir)
#define KLFERR_PROGERR_DVIPS
dvips exited with a non-zero status
Definition of class KLFBackend.
#define KLFERR_DVIPSNONORMALEXIT
dvips program did not exit properly (program killed) (see also KLFERR_PROGERR_DVIPS) ...
bool processNormalExit() const
#define KLFERR_NOPNGFILE
No .png file appeared after running gs program.
#define KLFERR_NOEPSFILE_OF
No -outlfonts.eps file appeared after calling gs for outlining fonts.
int processExitStatus() const
#define KLFERR_EPSWRITEFAIL
Error while opening ...-good.eps file for writing.
QString readStdoutString()
#define KLFERR_MISSINGLATEXFORMULA
No LaTeX formula is specified (empty string)
#define KLFERR_NODVIPSPROG
Error while launching the given dvips program.
static bool saveOutputToFile(const klfOutput &output, const QString &fileName, const QString &format=QString(), QString *errorString=NULL)
Save the output to image file.
A QProcess subclass for code-blocking process execution.
#define KLFERR_NOGSPROG
Error while launching the given gs program.
fromLatin1(const char *str, int size=-1)
#define KLFERR_LATEXNONORMALEXIT
latex program did not exit properly (program killed) (see also KLFERR_PROGERR_LATEX) ...
#define KLFERR_PROGERR_GS
gs exited with a non-zero status
static bool detectSettings(klfSettings *settings, const QString &extraPath=QString())
Detects the system settings and stores the guessed values in settings.
bool KLF_EXPORT operator==(const KLFBackend::klfInput &a, const KLFBackend::klfInput &b)
static klfOutput getLatexFormula(const klfInput &in, const klfSettings &settings)
The function that processes everything.
#define KLFERR_BADEPSBBOX
Error while parsing value for %BoundingBox instruction in EPS.
int status
A code describing the status of the request.
#define KLF_PATH_SEP
The character used in the $PATH environment variable to separate different locations.