Rev 16764 | Rev 16767 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16729 | fschmid | 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 SLAOUTPUT_H |
||
8 | #define SLAOUTPUT_H |
||
9 | |||
10 | #include <QString> |
||
11 | #include <QTextStream> |
||
12 | #include <QSizeF> |
||
13 | #include <QBuffer> |
||
14 | #include <QColor> |
||
15 | #include <QBrush> |
||
16 | #include <QPen> |
||
17 | #include <QImage> |
||
18 | #include <QList> |
||
19 | #include <QTransform> |
||
20 | #include <QStack> |
||
21 | #include <QDebug> |
||
22 | #include "fpointarray.h" |
||
23 | #include "pageitem.h" |
||
24 | #include "scribusdoc.h" |
||
25 | #include "selection.h" |
||
26 | #include "vgradient.h" |
||
27 | |||
28 | #include <goo/gtypes.h> |
||
29 | #include <Object.h> |
||
30 | #include <OutputDev.h> |
||
31 | #include <Gfx.h> |
||
32 | #include <GfxState.h> |
||
33 | #include <Stream.h> |
||
34 | #include <GfxFont.h> |
||
35 | #include <PDFDoc.h> |
||
36 | #include <Error.h> |
||
37 | #include <Page.h> |
||
38 | #include <Catalog.h> |
||
39 | #include <CharCodeToUnicode.h> |
||
40 | #include <FontEncodingTables.h> |
||
41 | #include <fofi/FoFiTrueType.h> |
||
42 | #include <splash/SplashFontFileID.h> |
||
43 | #include <splash/SplashFontFile.h> |
||
44 | #include <splash/SplashFontEngine.h> |
||
45 | #include <splash/SplashFont.h> |
||
46 | #include <splash/SplashMath.h> |
||
47 | #include <splash/SplashPath.h> |
||
48 | #include <splash/SplashGlyphBitmap.h> |
||
49 | |||
50 | //------------------------------------------------------------------------ |
||
51 | // SplashOutFontFileID |
||
52 | //------------------------------------------------------------------------ |
||
53 | |||
54 | class SplashOutFontFileID: public SplashFontFileID |
||
55 | { |
||
56 | public: |
||
57 | |||
58 | SplashOutFontFileID(Ref *rA) { r = *rA; } |
||
59 | ~SplashOutFontFileID() {} |
||
60 | GBool matches(SplashFontFileID *id) |
||
61 | { |
||
62 | return ((SplashOutFontFileID *)id)->r.num == r.num && ((SplashOutFontFileID *)id)->r.gen == r.gen; |
||
63 | } |
||
64 | |||
65 | private: |
||
66 | |||
67 | Ref r; |
||
68 | }; |
||
69 | |||
70 | |||
71 | class SlaOutputDev : public OutputDev |
||
72 | { |
||
73 | public: |
||
74 | SlaOutputDev(ScribusDoc* doc, QList<PageItem*> *Elements, QStringList *importedColors, int flags); |
||
75 | virtual ~SlaOutputDev(); |
||
76 | void startDoc(XRef *xrefA, Catalog *catA); |
||
77 | |||
78 | GBool isOk() { return gTrue; } |
||
79 | virtual GBool upsideDown() { return gTrue; } |
||
80 | virtual GBool useDrawChar() { return gTrue; } |
||
81 | virtual GBool interpretType3Chars() { return gTrue; } |
||
82 | virtual GBool useTilingPatternFill() { return gTrue; } |
||
83 | virtual GBool useShadedFills(int type) { return type <= 7; } |
||
84 | virtual GBool useFillColorStop() { return gTrue; } |
||
85 | virtual void startPage(int pageNum, GfxState *state); |
||
86 | virtual void endPage(); |
||
87 | // grapics state |
||
88 | virtual void saveState(GfxState *state); |
||
89 | virtual void restoreState(GfxState *state); |
||
90 | |||
91 | //----- path painting |
||
92 | virtual void stroke(GfxState *state); |
||
93 | virtual void fill(GfxState *state); |
||
94 | virtual void eoFill(GfxState *state); |
||
95 | virtual void clipToStrokePath(GfxState *state) { qDebug() << "clip to stroke path"; } |
||
96 | virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str, double *pmat, int paintType, Dict *resDict, |
||
97 | double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); |
||
98 | virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); |
||
99 | virtual GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) { return (shading->getExtend0() == shading->getExtend1()); } |
||
100 | virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax); |
||
101 | virtual GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) { return (shading->getExtend0() == shading->getExtend1()); } |
||
16745 | fschmid | 102 | virtual GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading); |
16729 | fschmid | 103 | virtual GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading); |
104 | //----- path clipping |
||
105 | virtual void clip(GfxState *state); |
||
106 | virtual void eoClip(GfxState *state); |
||
107 | virtual GBool deviceHasTextClip(GfxState *state) { return gFalse; } |
||
108 | |||
109 | // If current colorspace is pattern, |
||
110 | // does this device support text in pattern colorspace? |
||
16764 | fschmid | 111 | virtual GBool supportTextCSPattern(GfxState *state) |
112 | { |
||
113 | return state->getFillColorSpace()->getMode() == csPattern; |
||
114 | } |
||
16729 | fschmid | 115 | |
116 | // If current colorspace is pattern, |
||
117 | // need this device special handling for masks in pattern colorspace? |
||
16764 | fschmid | 118 | virtual GBool fillMaskCSPattern(GfxState * state) |
119 | { |
||
120 | return state->getFillColorSpace()->getMode() == csPattern; |
||
121 | } |
||
16729 | fschmid | 122 | |
123 | virtual void endMaskClip(GfxState *state) { qDebug() << "End Mask Clip"; } |
||
124 | |||
125 | //----- grouping operators |
||
126 | virtual void beginMarkedContent(char *name, Dict *properties); |
||
127 | virtual void endMarkedContent(GfxState *state); |
||
128 | //----- image drawing |
||
16751 | fschmid | 129 | virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool interpolate, GBool inlineImg); |
16729 | fschmid | 130 | virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg); |
131 | virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, |
||
132 | int width, int height, |
||
133 | GfxImageColorMap *colorMap, |
||
134 | GBool interpolate, |
||
135 | Stream *maskStr, |
||
136 | int maskWidth, int maskHeight, |
||
137 | GfxImageColorMap *maskColorMap, |
||
138 | GBool maskInterpolate); |
||
139 | |||
140 | virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, |
||
141 | int width, int height, |
||
142 | GfxImageColorMap *colorMap, |
||
143 | GBool interpolate, |
||
144 | Stream *maskStr, |
||
145 | int maskWidth, int maskHeight, |
||
146 | GBool maskInvert, GBool maskInterpolate) { qDebug() << "Draw Masked Image"; } |
||
147 | |||
148 | //----- transparency groups and soft masks |
||
149 | virtual void beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace * /*blendingColorSpace*/, GBool /*isolated*/, GBool /*knockout*/, GBool /*forSoftMask*/); |
||
150 | virtual void paintTransparencyGroup(GfxState *state, double *bbox) {} |
||
151 | virtual void endTransparencyGroup(GfxState *state); |
||
152 | virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/); |
||
153 | virtual void clearSoftMask(GfxState * /*state*/); |
||
154 | |||
16764 | fschmid | 155 | // virtual void updateFillColor(GfxState *state); |
16729 | fschmid | 156 | virtual void updateFont(GfxState *state); |
16766 | fschmid | 157 | //----- text drawing |
158 | virtual void beginTextObject(GfxState *state); |
||
159 | virtual void endTextObject(GfxState *state); |
||
160 | virtual void drawChar(GfxState *state, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, double /*originX*/, double /*originY*/, CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/); |
||
161 | virtual GBool beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, CharCode /*code*/, Unicode * /*u*/, int /*uLen*/); |
||
162 | virtual void endType3Char(GfxState * /*state*/); |
||
163 | virtual void type3D0(GfxState * /*state*/, double /*wx*/, double /*wy*/); |
||
164 | virtual void type3D1(GfxState * /*state*/, double /*wx*/, double /*wy*/, double /*llx*/, double /*lly*/, double /*urx*/, double /*ury*/); |
||
16729 | fschmid | 165 | |
166 | private: |
||
167 | void getPenState(GfxState *state); |
||
16746 | fschmid | 168 | QString getColor(GfxColorSpace *color_space, GfxColor *color, int *shade); |
16729 | fschmid | 169 | QString convertPath(GfxPath *path); |
170 | int getBlendMode(GfxState *state); |
||
16732 | fschmid | 171 | void applyMask(PageItem *ite); |
172 | void pushGroup(QString maskName = "", GBool forSoftMask = gFalse, GBool alpha = gFalse, bool inverted = false); |
||
16729 | fschmid | 173 | bool pathIsClosed; |
174 | bool firstLayer; |
||
175 | QString CurrColorFill; |
||
176 | QString CurrColorStroke; |
||
177 | Qt::PenCapStyle PLineEnd; |
||
178 | Qt::PenJoinStyle PLineJoin; |
||
179 | QVector<double> DashValues; |
||
180 | double DashOffset; |
||
181 | QString Coords; |
||
182 | struct clipEntry |
||
183 | { |
||
184 | PageItem* ClipItem; |
||
185 | FPointArray ClipCoords; |
||
186 | int grStackDepth; |
||
187 | }; |
||
188 | QStack<clipEntry> m_clipStack; |
||
189 | struct groupEntry |
||
190 | { |
||
191 | QList<PageItem*> Items; |
||
192 | GBool forSoftMask; |
||
193 | GBool alpha; |
||
194 | QString maskName; |
||
16732 | fschmid | 195 | bool inverted; |
16729 | fschmid | 196 | }; |
197 | QStack<groupEntry> m_groupStack; |
||
198 | QString m_currentMask; |
||
199 | ScribusDoc* m_doc; |
||
200 | Selection* tmpSel; |
||
201 | QList<PageItem*> *m_Elements; |
||
202 | QStringList *m_importedColors; |
||
203 | QTransform m_ctm; |
||
16766 | fschmid | 204 | struct F3Entry |
205 | { |
||
206 | QTransform ctm; |
||
207 | QString glyphRef; |
||
208 | }; |
||
209 | QStack<F3Entry> m_F3Stack; |
||
210 | QMap<QString, QString> m_Font_Pattern_Map; |
||
16729 | fschmid | 211 | int grStackDepth; |
212 | int layerNum; |
||
213 | int currentLayer; |
||
214 | int importerFlags; |
||
215 | bool firstPage; |
||
216 | int pagecount; |
||
217 | XRef *xref; // xref table for current document |
||
218 | Catalog *catalog; |
||
219 | SplashFontEngine *m_fontEngine; |
||
220 | SplashFont *m_font; |
||
221 | }; |
||
222 | |||
223 | #endif |