Subversion Repositories Scribus

Rev

Rev 16732 | Rev 16746 | 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
        //----- text drawing
108
        virtual void beginTextObject(GfxState *state);
109
        virtual GBool deviceHasTextClip(GfxState *state) { return gFalse; }
110
        virtual void endTextObject(GfxState *state);
111
        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*/);
112
 
113
  // If current colorspace is pattern,
114
  // does this device support text in pattern colorspace?
115
        virtual GBool supportTextCSPattern(GfxState *state) {
116
          return state->getFillColorSpace()->getMode() == csPattern; }
117
 
118
  // If current colorspace is pattern,
119
  // need this device special handling for masks in pattern colorspace?
120
        virtual GBool fillMaskCSPattern(GfxState * state) {
121
          return state->getFillColorSpace()->getMode() == csPattern; }
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
129
        virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
130
                                 int width, int height, GBool invert, GBool interpolate,
131
                                 GBool inlineImg)  { qDebug() << "Draw Image Mask"; }
132
        virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg);
133
        virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
134
                                   int width, int height,
135
                                   GfxImageColorMap *colorMap,
136
                                   GBool interpolate,
137
                                   Stream *maskStr,
138
                                   int maskWidth, int maskHeight,
139
                                   GfxImageColorMap *maskColorMap,
140
                                   GBool maskInterpolate);
141
 
142
        virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
143
                                   int width, int height,
144
                                   GfxImageColorMap *colorMap,
145
                                   GBool interpolate,
146
                                   Stream *maskStr,
147
                                   int maskWidth, int maskHeight,
148
                                   GBool maskInvert, GBool maskInterpolate) { qDebug() << "Draw Masked Image"; }
149
 
150
        //----- transparency groups and soft masks
151
        virtual void beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace * /*blendingColorSpace*/, GBool /*isolated*/, GBool /*knockout*/, GBool /*forSoftMask*/);
152
        virtual void paintTransparencyGroup(GfxState *state, double *bbox) {}
153
        virtual void endTransparencyGroup(GfxState *state);
154
        virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/);
155
        virtual void clearSoftMask(GfxState * /*state*/);
156
 
157
        virtual void updateFillColor(GfxState *state);
158
        virtual void updateFont(GfxState *state);
159
 
160
private:
161
        void getPenState(GfxState *state);
162
        QString getColor(GfxColorSpace *color_space, GfxColor *color);
163
        QString convertPath(GfxPath *path);
164
        int getBlendMode(GfxState *state);
16732 fschmid 165
        void applyMask(PageItem *ite);
166
        void pushGroup(QString maskName = "", GBool forSoftMask = gFalse, GBool alpha = gFalse, bool inverted = false);
16729 fschmid 167
        bool pathIsClosed;
168
        bool firstLayer;
169
        QString CurrColorFill;
170
        QString CurrColorStroke;
171
        Qt::PenCapStyle PLineEnd;
172
        Qt::PenJoinStyle PLineJoin;
173
        QVector<double> DashValues;
174
        double DashOffset;
175
        QString Coords;
176
        struct clipEntry
177
        {
178
                PageItem* ClipItem;
179
                FPointArray ClipCoords;
180
                int grStackDepth;
181
        };
182
        QStack<clipEntry> m_clipStack;
183
        struct groupEntry
184
        {
185
                QList<PageItem*> Items;
186
                GBool forSoftMask;
187
                GBool alpha;
188
                QString maskName;
16732 fschmid 189
                bool inverted;
16729 fschmid 190
        };
191
        QStack<groupEntry> m_groupStack;
192
        QString m_currentMask;
193
        ScribusDoc* m_doc;
194
        Selection* tmpSel;
195
        QList<PageItem*> *m_Elements;
196
        QStringList *m_importedColors;
197
        QTransform m_ctm;
198
        int grStackDepth;
199
        int layerNum;
200
        int currentLayer;
201
        int importerFlags;
202
        bool firstPage;
203
        int pagecount;
204
        XRef *xref;             // xref table for current document
205
        Catalog *catalog;
206
        SplashFontEngine *m_fontEngine;
207
        SplashFont *m_font;
208
};
209
 
210
#endif