[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfbackend.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfbackend.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist@bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfbackend.h 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 #ifndef KLFBACKEND_H
25 #define KLFBACKEND_H
26 
27 #include <klfdefs.h>
28 
29 #include <qstring.h>
30 #include <qstringlist.h>
31 #ifdef KLFBACKEND_QT4
32 #include <QByteArray>
33 #else
34 #include <qmemarray.h>
35 #endif
36 #include <qimage.h>
37 #include <qmutex.h>
38 
39 
40 
42 
47 #define KLFERR_NOERROR 0
49 
51 #define KLFERR_MISSINGLATEXFORMULA -1
52 #define KLFERR_MISSINGMATHMODETHREEDOTS -2
54 #define KLFERR_TEXWRITEFAIL -3
56 #define KLFERR_NOLATEXPROG -4
58 #define KLFERR_LATEXNONORMALEXIT -5
60 #define KLFERR_NODVIFILE -6
62 #define KLFERR_NODVIPSPROG -7
64 #define KLFERR_DVIPSNONORMALEXIT -8
66 #define KLFERR_NOEPSFILE -9
68 #define KLFERR_EPSREADFAIL -10
70 #define KLFERR_NOEPSBBOX -11
72 #define KLFERR_BADEPSBBOX -12
74 #define KLFERR_EPSWRITEFAIL -13
76 #define KLFERR_NOEPSFILE_OF -22
78 #define KLFERR_EPSREADFAIL_OF -23
80 #define KLFERR_NOGSPROG -14
82 #define KLFERR_GSNONORMALEXIT -15
84 #define KLFERR_NOPNGFILE -16
86 #define KLFERR_PNGREADFAIL -17
88 #define KLFERR_NOEPSTOPDFPROG -18
90 #define KLFERR_EPSTOPDFNONORMALEXIT -19
92 #define KLFERR_NOPDFFILE -20
94 #define KLFERR_PDFREADFAIL -21
96 // last error defined: -23
97 
99 #define KLFERR_PROGERR_LATEX 1
100 #define KLFERR_PROGERR_DVIPS 2
102 #define KLFERR_PROGERR_GS 3
104 #define KLFERR_PROGERR_GS_OF 5
106 #define KLFERR_PROGERR_EPSTOPDF 4
108 // last error defined: 5
109 
110 
112 
120 class KLF_EXPORT KLFBackend
121 {
122 public:
123 
125 
130  struct klfSettings {
132  klfSettings() : tborderoffset(0), rborderoffset(0), bborderoffset(0), lborderoffset(0),
133  outlineFonts(true), execenv() { }
147 
164 
170 
174  };
175 
177 
179  struct klfInput {
181  klfInput() : fg_color(0x00), bg_color(0xffffffff), dpi(600), bypassTemplate(false) { }
195  unsigned long fg_color;
201  unsigned long bg_color;
204  int dpi;
212  };
213 
215 
217  struct klfOutput {
227  int status;
236 
239 
244 
273  };
274 
328  static klfOutput getLatexFormula(const klfInput& in, const klfSettings& settings);
329 
356  static bool saveOutputToFile(const klfOutput& output, const QString& fileName,
357  const QString& format = QString(), QString* errorString = NULL);
358 
364  static bool saveOutputToDevice(const klfOutput& output, QIODevice *device,
365  const QString& format = QString("PNG"), QString* errorString = NULL);
366 
374  static bool detectSettings(klfSettings *settings, const QString& extraPath = QString());
375 
376 
377 private:
378  KLFBackend();
379 
380  friend struct cleanup_caller;
381  static void cleanup(QString tempfname);
382 
383  static QMutex __mutex;
384 };
385 
386 
388 bool KLF_EXPORT operator==(const KLFBackend::klfInput& a, const KLFBackend::klfInput& b);
389 
390 bool KLF_EXPORT klf_detect_execenv(KLFBackend::klfSettings *settings);
391 
392 #endif
QByteArray pngdata_raw
Definition: klfbackend.h:249
bool KLF_EXPORT klf_detect_execenv(KLFBackend::klfSettings *settings)
detects any additional settings to environment variables
Definition: klfbackend.cpp:852
QString errorstr
An explicit error string.
Definition: klfbackend.h:235
Base declarations for klatexformula and some utilities.
klfSettings settings
Definition: klfbackend.h:243
General settings for KLFBackend::getLatexFormula()
Definition: klfbackend.h:130
KLFBackend::getLatexFormula() result.
Definition: klfbackend.h:217
unsigned long fg_color
Definition: klfbackend.h:195
Specific input to KLFBackend::getLatexFormula()
Definition: klfbackend.h:179
unsigned long bg_color
Definition: klfbackend.h:201
The main engine for KLatexFormula.
Definition: klfbackend.h:120
bool KLF_EXPORT operator==(const KLFBackend::klfInput &a, const KLFBackend::klfInput &b)
Definition: klfbackend.cpp:680
int status
A code describing the status of the request.
Definition: klfbackend.h:227

Generated by doxygen 1.8.5