Scribus
Open source desktop publishing at your fingertips
xpsexplugin.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  xpsexport.cpp - description
9  -------------------
10  begin : Sun Nov 24 08:00:00 CEST 2013
11  copyright : (C) 2013 by Franz Schmid
12  email : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 #ifndef XPSPLUG_H
15 #define XPSPLUG_H
16 
17 #include <QObject>
18 #include <QDomElement>
19 #include "pluginapi.h"
20 #include "loadsaveplugin.h"
21 #include "tableborder.h"
22 
23 class QString;
24 class QTemporaryDir;
25 class ScLayer;
26 class ScribusDoc;
27 class ScribusMainWindow;
28 class PageItem;
29 class ScPage;
30 class ScText;
31 class ScZipHandler;
32 
33 class PLUGIN_API XPSExportPlugin : public ScActionPlugin
34 {
35  Q_OBJECT
36 
37 public:
38  // Standard plugin implementation
40  virtual ~XPSExportPlugin();
47  virtual bool run(ScribusDoc* doc=0, QString filename = QString::null);
48  virtual const QString fullTrName() const;
49  virtual const AboutData* getAboutData() const;
50  virtual void deleteAboutData(const AboutData* about) const;
51  virtual void languageChange();
53 };
54 
55 extern "C" PLUGIN_API int xpsexplugin_getPluginAPIVersion();
56 extern "C" PLUGIN_API ScPlugin* xpsexplugin_getPlugin();
57 extern "C" PLUGIN_API void xpsexplugin_freePlugin(ScPlugin* plugin);
58 
59 class XPSExPlug : public QObject
60 {
61  Q_OBJECT
62 
63 public:
69  XPSExPlug(ScribusDoc* doc, int output_res);
70  ~XPSExPlug();
71 
72  bool doExport(QString fName);
73 
74 private:
75  void writePages(QDomElement &root);
76  void writePage(QDomElement &doc_root, QDomElement &rel_root, ScPage *Page);
77  void writePageLayer(QDomElement &doc_root, QDomElement &rel_root, ScPage *page, ScLayer& layer);
78  void writeItemOnPage(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
79  void handleImageFallBack(PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
80  void processPolyItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
81  void processLineItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
82  void processImageItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
83  void processTextItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
84  void processPathTextItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
85  void processSymbolItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
86  void processTableItem(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
87  void paintBorder(const TableBorder &border, const QPointF &start, const QPointF &end, const QPointF &startOffsetFactors, const QPointF &endOffsetFactors, QDomElement &ob);
88  void processHatchFill(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
89  void processSymbolStroke(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
90  void processArrows(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root);
91  void drawArrow(double xOffset, double yOffset, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, FPointArray &arrow);
92  QString embedFont(const ScFace *font, QDomElement &rel_root);
93  void GetMultiStroke(struct SingleLine *sl, QDomElement &parentElem);
94  void getStrokeStyle(PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, double xOffset, double yOffset, bool forArrow = false);
95  void getFillStyle(PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, double xOffset, double yOffset, bool withTransparency = true);
96  void handleMask(int type, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, double xOffset, double yOffset);
97  QString SetColor(QString farbe, int shad, double transparency);
98  void SetClipAttr(QDomElement &elem, FPointArray *ite, bool fillRule);
99  QString SetClipPath(FPointArray *ite, bool closed);
100  void writeDocRels();
101  void writeCore();
102  void writeContentType();
103  void writeBaseRel();
104  QString FToStr(double c);
105  QString IToStr(int c);
106  QString MatrixToStr(QTransform &mat);
107  int hex2int(char hex);
108  bool checkForFallback(PageItem *Item);
109  ScribusDoc* m_Doc;
110  ScZipHandler *zip;
111  QTemporaryDir *dir;
112  QString baseDir;
113  QDomDocument f_docu;
114  QDomDocument p_docu;
115  QDomDocument r_docu;
116  double conversionFactor;
117  int imageCounter;
118  int fontCounter;
119  QMap<QString, QString> xps_fontMap;
120  struct txtRunItem
121  {
122  QChar chr;
123  GlyphLayout* glyphs;
124  CharStyle style;
125  int index;
126  double CurX;
127  PageItem* embItem;
128  };
129  double m_dpi;
130 };
131 
132 #endif
A plug-in that performs a single action.
Definition: scplugin.h:248
Definition: charstyle.h:78
virtual void addToMainWindowMenu(ScribusMainWindow *)
Allow plugins to add to a main menu.
Definition: xpsexplugin.h:52
virtual const QString fullTrName() const =0
Plug-in's human-readable, translated name.
Definition: scribusstructs.h:120
Abstract super class for all Scribus plug-ins.
Definition: scplugin.h:90
Definition: sctextstruct.h:109
Definition: scpage.h:46
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
virtual bool run(ScribusDoc *doc, QString target=QString::null)=0
Run the plug-in's main action.
Definition: tableborder.h:86
virtual void languageChange()=0
Update all user-visible text to reflect current UI language.
the Document Class
Definition: scribusdoc.h:90
ScPlugin provides an interface to ask plugins for information about themselves.
Definition: scplugin.h:103
Definition: xpsexplugin.h:33
Base Class ScFace : This is a total rewrite of the old Foi class.
Definition: scface.h:73
Definition: sclayer.h:17
virtual const AboutData * getAboutData() const =0
Return descriptive information about the plug-in.
Definition: pageitem.h:92
Definition: scribus_zip.h:28
Definition: fpointarray.h:42
Definition: xpsexplugin.h:59
Definition: sctextstruct.h:54
XPSExPlug(ScribusDoc *doc, int output_res)
Create the XPS exporter window.
Definition: xpsexplugin.cpp:202