Subversion Repositories Scribus

Rev

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