[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klfbackend/klfuserscript.h
00001 /***************************************************************************
00002  *   file klfuserscript.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2012 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id$ */
00023 
00024 #ifndef KLFUSERSCRIPT_H
00025 #define KLFUSERSCRIPT_H
00026 
00027 #include <klfdefs.h>
00028 #include <klfbackend.h>
00029 #include <klffilterprocess.h>
00030 
00031 
00032 
00033 
00035 
00037 class KLF_EXPORT KLFUserScriptInfo : public KLFAbstractPropertizedObject
00038 {
00039 public:
00043   KLFUserScriptInfo(const QString& userScriptPath);
00044   KLFUserScriptInfo(const KLFUserScriptInfo& copy);
00045   virtual ~KLFUserScriptInfo();
00046 
00047   static bool hasScriptInfoInCache(const QString& userScriptPath);
00048   static KLFUserScriptInfo forceReloadScriptInfo(const QString& scriptFileName);
00049   static void clearCacheAll();
00050   static QMap<QString,QString> usConfigToStrMap(const QVariantMap& usconfig);
00051   static QStringList usConfigToEnvList(const QVariantMap& usconfig);
00052 
00053   int scriptInfoError() const;
00054   QString scriptInfoErrorString() const;
00055 
00057   QString userScriptPath() const;
00059   QString userScriptName() const;
00061   QString userScriptBaseName() const;
00062 
00063   enum Properties {
00064     ExeScript = 0,
00065     Category,
00066     Name,
00067     Author,
00068     Version,
00069     License,
00070     KLFMinVersion,
00071     KLFMaxVersion,
00072     SettingsFormUI,
00073     CanProvideDefaultSettings,
00075     CategorySpecificXmlConfig
00076   };
00077 
00078   QString relativeFile(const QString& fname) const;
00079 
00080   QString exeScript() const;
00081   QString exeScriptFullPath() const;
00082 
00083   QString category() const;
00084 
00085   QString name() const;
00086   QString author() const;
00087   QStringList authorList() const;
00088   QString version() const;
00089   QString license() const;
00090   QString klfMinVersion() const;
00091   QString klfMaxVersion() const;
00092 
00094   QString settingsFormUI() const;
00095 
00096   bool canProvideDefaultSettings() const;
00097 
00098   QMap<QString,QVariant> queryDefaultSettings(const KLFBackend::klfSettings * settings = NULL) const;
00099 
00100   bool hasNotices() const;
00101   QStringList notices() const;
00102   bool hasWarnings() const;
00103   QStringList warnings() const;
00104   bool hasErrors() const;
00105   QStringList errors() const;
00106 
00108   QString htmlInfo(const QString& extra_css = QString()) const;
00109 
00110 
00111   QVariant scriptInfo(int propId) const;
00113   QVariant scriptInfo(const QString& key) const;
00114 
00118   QStringList scriptInfosList() const;
00119 
00120   // reimplemented from KLFAbstractPropertizedObject
00121   virtual QString objectKind() const;
00122   virtual QVariant property(const QString& propName) const { return scriptInfo(propName); }
00123   virtual QStringList propertyNameList() const { return scriptInfosList(); }
00124   virtual bool setProperty(const QString&, const QVariant&) { return false; }
00125 
00126 protected:
00127 
00128   void internalSetProperty(const QString& key, const QVariant &val);
00129   const KLFPropertizedObject * pobj();
00130 
00136   QByteArray categorySpecificXmlConfig() const;
00137   
00138   void setScriptInfoError(int code, const QString & msg);
00139 
00140 private:
00141   struct Private;
00142 
00143   KLFRefPtr<Private> d;
00144   inline Private * d_func() { return d(); }
00145   inline const Private * d_func() const { return d(); }
00146 };
00147 
00148 
00149 KLF_DECLARE_POBJ_TYPE(KLFUserScriptInfo) ;
00150 
00151 
00152 struct KLFBackendEngineUserScriptInfoPrivate;
00153 
00154 class KLF_EXPORT KLFBackendEngineUserScriptInfo : public KLFUserScriptInfo
00155 {
00156 public:
00157   KLFBackendEngineUserScriptInfo(const QString& userScriptPath);
00158   virtual ~KLFBackendEngineUserScriptInfo();
00159     
00160   enum BackendEngineProperties {
00161     SpitsOut = 0,
00162     SkipFormats,
00163     DisableInputs,
00164     InputFormUI
00165   };
00166 
00168   QStringList spitsOut() const;
00169 
00171 
00175   QStringList skipFormats() const;
00176 
00178   QStringList disableInputs() const;
00179   
00181   QString inputFormUI() const;
00182 
00183   QVariant klfBackendEngineInfo(int propId) const;
00184   QVariant klfBackendEngineInfo(const QString& key) const;
00185   QStringList klfBackendEngineInfosList() const;
00186 
00187 private:
00188   KLF_DECLARE_PRIVATE(KLFBackendEngineUserScriptInfo) ;
00189 };
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 struct KLFUserScriptFilterProcessPrivate;
00198 
00199 class KLF_EXPORT KLFUserScriptFilterProcess : public KLFFilterProcess
00200 {
00201 public:
00207   KLFUserScriptFilterProcess(const QString& scriptFileName,
00208                              const KLFBackend::klfSettings * settings = NULL);
00209   ~KLFUserScriptFilterProcess();
00210 
00211   void addUserScriptConfig(const QVariantMap& usconfig);
00212 
00218   static QString getUserScriptLogHtml(bool include_head=true) ;
00219 
00220 protected:
00227   virtual bool do_run(const QByteArray& indata, const QMap<QString, QByteArray*> outdatalist);
00228 
00229 private:
00230   KLF_DECLARE_PRIVATE(KLFUserScriptFilterProcess);
00231 };
00232 
00233 
00234 
00235 
00236 #endif

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net