Scribus
Open source desktop publishing at your fingertips
oodrawimp.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 #ifndef OODPLUG_H
8 #define OODPLUG_H
9 
10 #include "pluginapi.h"
11 #include "loadsaveplugin.h"
12 #include "../../formatidlist.h"
13 #include "stylestack.h"
14 #include "scribusstructs.h"
15 
16 class PageItem;
17 class ScrAction;
18 class ScribusDoc;
19 class Selection;
21 
22 class PLUGIN_API OODrawImportPlugin : public LoadSavePlugin
23 {
24  Q_OBJECT
25 
26  public:
27  // Standard plugin implementation
29  virtual ~OODrawImportPlugin();
30  virtual const QString fullTrName() const;
31  virtual const AboutData* getAboutData() const;
32  virtual void deleteAboutData(const AboutData* about) const;
33  virtual void languageChange();
34  virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
35  virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
36  virtual QImage readThumbnail(const QString& fileName);
38 
39  // Special features - File->Import slot
40  public slots:
41  virtual bool import(QString target = QString::null, int flags = lfUseCurrentPage|lfInteractive);
42 
43  private:
44  void registerFormats();
45  ScrAction* importAction;
46 };
47 
48 extern "C" PLUGIN_API int oodrawimp_getPluginAPIVersion();
49 extern "C" PLUGIN_API ScPlugin* oodrawimp_getPlugin();
50 extern "C" PLUGIN_API void oodrawimp_freePlugin(ScPlugin* plugin);
51 
52 class QWidget;
53 class ScribusMainWindow;
54 class ScribusDoc;
55 class FPointArray;
56 class QDomDocument;
57 class QDomElement;
58 
60 {
61 public:
62  OODrawStyle() :
63  fillColor("None"),
64  strokeColor("None"),
65  fillTrans(0.0),
66  strokeTrans(0.0),
67  strokeWidth(0.0),
68  haveGradient(false),
69  gradientType(0),
70  gradientAngle(0.0),
71  gradientPointX(0.0),
72  gradientPointY(0.0)
73  {}
74  QString fillColor;
75  QString strokeColor;
76  double fillTrans;
77  double strokeTrans;
78  double strokeWidth;
79  QVector<double> dashes;
80  bool haveGradient;
81  int gradientType;
82  VGradient gradient;
83  double gradientAngle;
84  double gradientPointX;
85  double gradientPointY;
86 };
87 
88 class OODPlug : public QObject
89 {
90  Q_OBJECT
91 
92 public:
93 
94  OODPlug(ScribusDoc* doc);
95  ~OODPlug();
96 
99  bool importFailed;
100  bool importCanceled;
101  bool import(QString fName, const TransactionSettings& trSettings, int flags);
102  QImage readThumbnail(QString fileName );
103  static double parseUnit(const QString &unit);
104 
105 protected:
106 
107  bool convert(const TransactionSettings& trSettings, int flags);
108  QList<PageItem*> parseGroup(const QDomElement &e);
109  QList<PageItem*> parseElement(const QDomElement &e);
110  QList<PageItem*> parseRect(const QDomElement &e);
111  QList<PageItem*> parseEllipse(const QDomElement &e);
112  QList<PageItem*> parseLine(const QDomElement &e);
113  QList<PageItem*> parsePolygon(const QDomElement &e);
114  QList<PageItem*> parsePolyline(const QDomElement &e);
115  QList<PageItem*> parsePath(const QDomElement &e);
116  QList<PageItem*> parseTextBox(const QDomElement &e);
117  QList<PageItem*> parseFrame(const QDomElement &e);
118  QList<PageItem*> parseConnector(const QDomElement &e);
119  void parseStyle(OODrawStyle& style, const QDomElement &e);
120  void parseCharStyle(CharStyle& style, const QDomElement &e);
121  void parseParagraphStyle(ParagraphStyle& style, const QDomElement &e);
122  PageItem* parseTextP(const QDomElement& e, PageItem* item);
123  PageItem* parseTextSpans(const QDomElement& elm, PageItem* item);
124  PageItem* finishNodeParsing(const QDomElement &elm, PageItem* item, OODrawStyle& oostyle);
125  void createStyleMap( QDomDocument &docstyles );
126  void insertDraws( const QDomElement& styles );
127  void insertStyles( const QDomElement& styles );
128  void fillStyleStack( const QDomElement& object );
129  void addStyles( const QDomElement* style );
130  void storeObjectStyles( const QDomElement& object );
131  QColor parseColorN( const QString &rgbColor );
132  QString parseColor( const QString &s );
133  void parseTransform(FPointArray *composite, const QString &transform);
134  void parseViewBox( const QDomElement& object, double *x, double *y, double *w, double *h );
135  void appendPoints(FPointArray *composite, const QDomElement& object, bool closePath);
136  const char * getCoord( const char *ptr, double &number );
137  bool parseSVG( const QString &s, FPointArray *ite );
138  void calculateArc(FPointArray *ite, bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
139  void svgClosePath(FPointArray *i);
140  void svgMoveTo(double x1, double y1);
141  void svgLineTo(FPointArray *i, double x1, double y1);
142  void svgCurveToCubic(FPointArray *i, double x1, double y1, double x2, double y2, double x3, double y3);
143 
144  QDomDocument inpContents;
145  QDomDocument inpStyles;
146  QDomDocument inpMeta;
147  QHash<QString,QDomElement*> m_styles, m_draws;
148  StyleStack m_styleStack;
149  double CurrX, CurrY, StartX, StartY;
150  int PathLen;
151  bool FirstM, WasM, PathClosed, HaveMeta;
152 
153  bool interactive;
154  ScribusDoc* m_Doc;
155  Selection* tmpSel;
156  QStringList importedColors;
157 };
158 
159 #endif
Definition: charstyle.h:78
Definition: loadsaveplugin.h:190
Definition: oodrawimp.h:59
virtual const QString fullTrName() const =0
Plug-in's human-readable, translated name.
Abstract super class for all Scribus plug-ins.
Definition: scplugin.h:90
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
virtual void languageChange()=0
Update all user-visible text to reflect current UI language.
Definition: vgradient.h:78
Definition: paragraphstyle.h:27
the Document Class
Definition: scribusdoc.h:90
bool unsupported
Indicator if there is any unsupported feature in imported svg.
Definition: oodrawimp.h:98
virtual void addToMainWindowMenu(ScribusMainWindow *)
Allow plugins to add to a main menu.
Definition: oodrawimp.h:37
ScPlugin provides an interface to ask plugins for information about themselves.
Definition: scplugin.h:103
Definition: undomanager.h:52
Definition: scraction.h:33
Definition: oodrawimp.h:22
Superclass for all file import/export/load/save plugins.
Definition: loadsaveplugin.h:33
virtual const AboutData * getAboutData() const =0
Return descriptive information about the plug-in.
Definition: pageitem.h:92
Definition: fpointarray.h:42
Definition: oodrawimp.h:88
Definition: stylestack.h:58
Definition: selection.h:34