Scribus
Open source desktop publishing at your fingertips
pageitem_latexframe.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  pageitem_latexframe.h - description
9  -------------------
10 copyright : Scribus Team
11 ***************************************************************************/
12 
13 /***************************************************************************
14 * *
15 * This program is free software; you can redistribute it and/or modify *
16 * it under the terms of the GNU General Public License as published by *
17 * the Free Software Foundation; either version 2 of the License, or *
18 * (at your option) any later version. *
19 * *
20 ***************************************************************************/
21 
22 #ifndef PAGEITEM_LATEXFRAME_H
23 #define PAGEITEM_LATEXFRAME_H
24 
25 #include <QObject>
26 #include <QWidget>
27 #include <QString>
28 #include <QProcess>
29 #include <QMap>
30 
31 #include "scribusapi.h"
32 #include "pageitem.h"
33 #include "pageitem_imageframe.h"
34 
35 class QTemporaryFile;
36 class LatexEditor;
37 class LatexConfigParser;
38 class QTimer;
39 
43 class SCRIBUS_API PageItem_LatexFrame : public PageItem_ImageFrame
44 {
45  Q_OBJECT
46 
47  public:
48  PageItem_LatexFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline);
50 
51  virtual PageItem_LatexFrame * asLatexFrame() { return this; }
52  virtual bool isLatexFrame() const { return true; }
53 
54  virtual void clearContents();
55  virtual ItemType realItemType() const { return PageItem::LatexFrame; }
56  virtual void applicableActions(QStringList& actionList);
57  virtual QString infoDescription();
58  void layout();
59 
61  void restore(UndoState *state, bool isUndo);
62 
63 
65  void runEditor();
66  /*TODO void convertToVector(); */
67 
72  bool setFormula(QString formula, bool undoable=true);
74  QString formula() const { return formulaText; }
75 
78  void runApplication();
79 
80  void rerunApplication(bool updateDisplay=false);
81 
82  QString configFile() const;
83  void setConfigFile(QString newConfig, bool relative=false);
84  QString application() const;
85  bool usePreamble() const { return m_usePreamble; }
86  int dpi() const { return m_dpi; }
87  int realDpi() const;
88 
89  const QString output() const { return appStdout; }
90  QProcess::ProcessState state() const { return latex->state(); }
91  int error() const { return err; }
92 
93  QMap<QString,QString> editorProperties;
94  protected:
95  virtual void DrawObj_Item(ScPainter *p, QRectF e);
96  double lastWidth, lastHeight;
97 
98  QString formulaText;
99 
100  void writeFileContents(QFile *tempfile);
101  void deleteImageFile();
102  /* Last error code */
103  int err;
104  int m_dpi;
105 
106  QString imageFile, tempFileBase;
107  QString appStdout;
108  QString configFilename;
109 
110  QProcess *latex;
111  LatexEditor *internalEditor;
112  LatexConfigParser *config;
113  bool imgValid;
114  bool m_usePreamble;
115  bool killed;
116  signals:
117  void formulaAutoUpdate(QString oldText, QString newText);
118  void latexFinished();
119  void stateChanged(QProcess::ProcessState state);
120  void applicationChanged();
121  protected slots:
122  void updateImage(int exitCode, QProcess::ExitStatus exitStatus);
123  void latexError(QProcess::ProcessError error);
124  public slots:
125  void killProcess();
126  void setDpi(int dpi);
127  void setUsePreamble(bool);
128 };
129 
130 #endif
virtual PageItem_LatexFrame * asLatexFrame()
Return self if Render frame item, otherwise null.
Definition: pageitem_latexframe.h:51
Displays all kinds of content generated by external programs. Named LatexFrame because it initally on...
Definition: pageitem_latexframe.h:43
Definition: pageitem_imageframe.h:34
UndoState describes an undoable state (action).
Definition: undostate.h:59
virtual void layout()
creates valid layout information
Definition: pageitem.h:383
the Document Class
Definition: scribusdoc.h:90
void restore(UndoState *state, bool isUndo)
Required by the UndoObject.
Definition: pageitem.cpp:5224
Definition: scpainter.h:33
virtual ItemType realItemType() const
Get the subclass item type.
Definition: pageitem_latexframe.h:55
Definition: latexhelpers.h:62
ItemType
Item Type.
Definition: pageitem.h:174
virtual void clearContents()
Clear the contents of a frame. WARNING: Currently they do not check if the user wants this...
Definition: pageitem_imageframe.cpp:210
virtual bool isLatexFrame() const
Return true if Render frame item, otherwise false.
Definition: pageitem_latexframe.h:52
QString formula() const
Get current source.
Definition: pageitem_latexframe.h:74