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