Subversion Repositories Scribus

Rev

Rev 17089 | Rev 17439 | 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);
129
        //----- image drawing
16751 fschmid 130
        virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool interpolate, GBool inlineImg);
16729 fschmid 131
        virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg);
132
        virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
133
                                   int width, int height,
134
                                   GfxImageColorMap *colorMap,
135
                                   GBool interpolate,
136
                                   Stream *maskStr,
137
                                   int maskWidth, int maskHeight,
138
                                   GfxImageColorMap *maskColorMap,
139
                                   GBool maskInterpolate);
140
 
141
        virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
142
                                   int width, int height,
143
                                   GfxImageColorMap *colorMap,
144
                                   GBool interpolate,
145
                                   Stream *maskStr,
146
                                   int maskWidth, int maskHeight,
147
                                   GBool maskInvert, GBool maskInterpolate) { qDebug() << "Draw Masked Image"; }
148
 
149
        //----- transparency groups and soft masks
150
        virtual void beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace * /*blendingColorSpace*/, GBool /*isolated*/, GBool /*knockout*/, GBool /*forSoftMask*/);
151
        virtual void paintTransparencyGroup(GfxState *state, double *bbox) {}
152
        virtual void endTransparencyGroup(GfxState *state);
153
        virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/);
154
        virtual void clearSoftMask(GfxState * /*state*/);
155
 
16764 fschmid 156
//      virtual void updateFillColor(GfxState *state);
16729 fschmid 157
        virtual void updateFont(GfxState *state);
16766 fschmid 158
        //----- text drawing
159
        virtual void beginTextObject(GfxState *state);
160
        virtual void endTextObject(GfxState *state);
161
        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*/);
162
        virtual GBool beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, CharCode /*code*/, Unicode * /*u*/, int /*uLen*/);
163
        virtual void endType3Char(GfxState * /*state*/);
164
        virtual void type3D0(GfxState * /*state*/, double /*wx*/, double /*wy*/);
165
        virtual void type3D1(GfxState * /*state*/, double /*wx*/, double /*wy*/, double /*llx*/, double /*lly*/, double /*urx*/, double /*ury*/);
16729 fschmid 166
 
167
private:
168
        void getPenState(GfxState *state);
16746 fschmid 169
        QString getColor(GfxColorSpace *color_space, GfxColor *color, int *shade);
16729 fschmid 170
        QString convertPath(GfxPath *path);
171
        int getBlendMode(GfxState *state);
16732 fschmid 172
        void applyMask(PageItem *ite);
173
        void pushGroup(QString maskName = "", GBool forSoftMask = gFalse, GBool alpha = gFalse, bool inverted = false);
16729 fschmid 174
        bool pathIsClosed;
175
        bool firstLayer;
176
        QString CurrColorFill;
177
        QString CurrColorStroke;
178
        Qt::PenCapStyle PLineEnd;
179
        Qt::PenJoinStyle PLineJoin;
180
        QVector<double> DashValues;
181
        double DashOffset;
182
        QString Coords;
183
        struct clipEntry
184
        {
185
                PageItem* ClipItem;
186
                FPointArray ClipCoords;
187
                int grStackDepth;
188
        };
189
        QStack<clipEntry> m_clipStack;
190
        struct groupEntry
191
        {
192
                QList<PageItem*> Items;
193
                GBool forSoftMask;
194
                GBool alpha;
195
                QString maskName;
16732 fschmid 196
                bool inverted;
16729 fschmid 197
        };
198
        QStack<groupEntry> m_groupStack;
199
        QString m_currentMask;
200
        ScribusDoc* m_doc;
201
        Selection* tmpSel;
202
        QList<PageItem*> *m_Elements;
203
        QStringList *m_importedColors;
204
        QTransform m_ctm;
16766 fschmid 205
        struct F3Entry
206
        {
207
                QTransform ctm;
208
                QString glyphRef;
16767 fschmid 209
                bool colored;
16766 fschmid 210
        };
211
        QStack<F3Entry> m_F3Stack;
16767 fschmid 212
        struct F3GlyphEntry
213
        {
214
                QString pattern;
215
                bool colored;
216
        };
217
        QMap<QString, F3GlyphEntry> m_Font_Pattern_Map;
16729 fschmid 218
        int grStackDepth;
219
        int layerNum;
220
        int currentLayer;
221
        int importerFlags;
222
        bool firstPage;
223
        int pagecount;
16774 fschmid 224
        int updateGUICounter;
16729 fschmid 225
        XRef *xref;             // xref table for current document
17419 fschmid 226
        PDFDoc *pdfDoc;
16729 fschmid 227
        Catalog *catalog;
228
        SplashFontEngine *m_fontEngine;
229
        SplashFont *m_font;
230
};
231
 
232
#endif