[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfuserscript.h
1/***************************************************************************
2 * file klfuserscript.h
3 * This file is part of the KLatexFormula Project.
4 * Copyright (C) 2012 by Philippe Faist
5 * philippe.faist at 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$ */
23
24#ifndef KLFUSERSCRIPT_H
25#define KLFUSERSCRIPT_H
26
27#include <klfdefs.h>
28#include <klfbackend.h>
29#include <klffilterprocess.h>
30
31
32
33
35
38{
39public:
45 virtual ~KLFUserScriptInfo();
46
47 static bool hasScriptInfoInCache(const QString& userScriptPath);
48 static KLFUserScriptInfo forceReloadScriptInfo(const QString& scriptFileName);
49 static void clearCacheAll();
50 static QMap<QString,QString> usConfigToStrMap(const QVariantMap& usconfig);
51 static QStringList usConfigToEnvList(const QVariantMap& usconfig);
52
53 int scriptInfoError() const;
54 QString scriptInfoErrorString() const;
55
57 QString userScriptPath() const;
59 QString userScriptName() const;
62
64 ExeScript = 0,
65 Category,
66 Name,
67 Author,
68 Version,
69 License,
70 KLFMinVersion,
71 KLFMaxVersion,
72 SettingsFormUI,
73 CanProvideDefaultSettings,
76 };
77
78 QString relativeFile(const QString& fname) const;
79
80 QString exeScript() const;
81 QString exeScriptFullPath() const;
82
83 QString category() const;
84
85 QString name() const;
86 QString author() const;
87 QStringList authorList() const;
88 QString version() const;
89 QString license() const;
90 QString klfMinVersion() const;
91 QString klfMaxVersion() const;
92
94 QString settingsFormUI() const;
95
96 bool canProvideDefaultSettings() const;
97
98 QMap<QString,QVariant> queryDefaultSettings(const KLFBackend::klfSettings * settings = NULL) const;
99
100 bool hasNotices() const;
101 QStringList notices() const;
102 bool hasWarnings() const;
103 QStringList warnings() const;
104 bool hasErrors() const;
105 QStringList errors() const;
106
108 QString htmlInfo(const QString& extra_css = QString()) const;
109
110
111 QVariant scriptInfo(int propId) const;
113 QVariant scriptInfo(const QString& key) const;
114
118 QStringList scriptInfosList() const;
119
120 // reimplemented from KLFAbstractPropertizedObject
121 virtual QString objectKind() const;
122 virtual QVariant property(const QString& propName) const { return scriptInfo(propName); }
123 virtual QStringList propertyNameList() const { return scriptInfosList(); }
124 virtual bool setProperty(const QString&, const QVariant&) { return false; }
125
126protected:
127
128 void internalSetProperty(const QString& key, const QVariant &val);
129 const KLFPropertizedObject * pobj();
130
136 QByteArray categorySpecificXmlConfig() const;
137
138 void setScriptInfoError(int code, const QString & msg);
139
140private:
141 struct Private;
142
143 KLFRefPtr<Private> d;
144 inline Private * d_func() { return d(); }
145 inline const Private * d_func() const { return d(); }
146};
147
148
149KLF_DECLARE_POBJ_TYPE(KLFUserScriptInfo) ;
150
151
152struct KLFBackendEngineUserScriptInfoPrivate;
153
154class KLF_EXPORT KLFBackendEngineUserScriptInfo : public KLFUserScriptInfo
155{
156public:
157 KLFBackendEngineUserScriptInfo(const QString& userScriptPath);
158 virtual ~KLFBackendEngineUserScriptInfo();
159
160 enum BackendEngineProperties {
161 SpitsOut = 0,
162 SkipFormats,
163 DisableInputs,
164 InputFormUI
165 };
166
168 QStringList spitsOut() const;
169
171
175 QStringList skipFormats() const;
176
179
181 QString inputFormUI() const;
182
183 QVariant klfBackendEngineInfo(int propId) const;
184 QVariant klfBackendEngineInfo(const QString& key) const;
185 QStringList klfBackendEngineInfosList() const;
186
187private:
188 KLF_DECLARE_PRIVATE(KLFBackendEngineUserScriptInfo) ;
189};
190
191
192
193
194
195
196
197struct KLFUserScriptFilterProcessPrivate;
198
199class KLF_EXPORT KLFUserScriptFilterProcess : public KLFFilterProcess
200{
201public:
207 KLFUserScriptFilterProcess(const QString& scriptFileName,
208 const KLFBackend::klfSettings * settings = NULL);
210
211 void addUserScriptConfig(const QVariantMap& usconfig);
212
218 static QString getUserScriptLogHtml(bool include_head=true) ;
219
220protected:
227 virtual bool do_run(const QByteArray& indata, const QMap<QString, QByteArray*> outdatalist);
228
229private:
230 KLF_DECLARE_PRIVATE(KLFUserScriptFilterProcess);
231};
232
233
234
235
236#endif
virtual QVariant property(const QString &propName) const=0
virtual QString objectKind() const=0
virtual bool setProperty(const QString &pname, const QVariant &value)=0
virtual QStringList propertyNameList() const=0
QStringList spitsOut() const
List of formats that this script will generate.
QString inputFormUI() const
A UI input form file (Qt designer file) for additional input.
QStringList skipFormats() const
List of formats that klfbackend should not attempt to generate.
QStringList disableInputs() const
List of user input fields that should be disabled.
static QString getUserScriptLogHtml(bool include_head=true)
Return the user script log, formatted in human-readable HTML.
virtual bool do_run(const QByteArray &indata, const QMap< QString, QByteArray * > outdatalist)
KLFUserScriptFilterProcess(const QString &scriptFileName, const KLFBackend::klfSettings *settings=NULL)
Summary of the info returned by a user script.
QString userScriptPath() const
e.g. "/path/to/klffeynmf.klfuserscript"
@ CategorySpecificXmlConfig
XML representation of the category-specific configuration (QByteArray)
QString userScriptName() const
e.g. "klffeynmf.klfuserscript"
QString userScriptBaseName() const
e.g. "klffeynmf"
KLFUserScriptInfo(const QString &userScriptPath)
Definition of class KLFBackend.
int propId
const char * key
#define KLF_EXPORT
General settings for KLFBackend::getLatexFormula()
Definition klfbackend.h:219

Generated by doxygen 1.13.1