author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QPRINTENGINE_PDF_P_H |
|
43 |
#define QPRINTENGINE_PDF_P_H |
|
44 |
||
45 |
// |
|
46 |
// W A R N I N G |
|
47 |
// ------------- |
|
48 |
// |
|
49 |
// This file is not part of the Qt API. It exists purely as an |
|
50 |
// implementation detail. This header file may change from version to |
|
51 |
// version without notice, or even be removed. |
|
52 |
// |
|
53 |
// We mean it. |
|
54 |
// |
|
55 |
||
56 |
#include "QtGui/qprintengine.h" |
|
57 |
||
58 |
#ifndef QT_NO_PRINTER |
|
59 |
#include "QtCore/qmap.h" |
|
60 |
#include "QtGui/qmatrix.h" |
|
61 |
#include "QtCore/qstring.h" |
|
62 |
#include "QtCore/qvector.h" |
|
63 |
#include "QtGui/qpaintengine.h" |
|
64 |
#include "QtGui/qpainterpath.h" |
|
65 |
#include "QtCore/qdatastream.h" |
|
66 |
||
67 |
#include "private/qfontengine_p.h" |
|
68 |
#include "private/qpdf_p.h" |
|
69 |
#include "private/qpaintengine_p.h" |
|
70 |
||
71 |
QT_BEGIN_NAMESPACE |
|
72 |
||
73 |
// #define USE_NATIVE_GRADIENTS |
|
74 |
||
75 |
class QImage; |
|
76 |
class QDataStream; |
|
77 |
class QPen; |
|
78 |
class QPointF; |
|
79 |
class QRegion; |
|
80 |
class QFile; |
|
81 |
class QPdfEngine; |
|
82 |
||
83 |
class QPdfEnginePrivate; |
|
84 |
||
85 |
class QPdfEngine : public QPdfBaseEngine |
|
86 |
{ |
|
87 |
Q_DECLARE_PRIVATE(QPdfEngine) |
|
88 |
public: |
|
89 |
QPdfEngine(QPrinter::PrinterMode m); |
|
90 |
virtual ~QPdfEngine(); |
|
91 |
||
92 |
// reimplementations QPaintEngine |
|
93 |
bool begin(QPaintDevice *pdev); |
|
94 |
bool end(); |
|
95 |
void drawPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QRectF & sr); |
|
96 |
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, |
|
97 |
Qt::ImageConversionFlags flags = Qt::AutoColor); |
|
98 |
void drawTiledPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QPointF & point); |
|
99 |
||
100 |
Type type() const; |
|
101 |
// end reimplementations QPaintEngine |
|
102 |
||
103 |
// reimplementations QPrintEngine |
|
104 |
bool abort() {return false;} |
|
105 |
bool newPage(); |
|
106 |
QPrinter::PrinterState printerState() const {return state;} |
|
107 |
// end reimplementations QPrintEngine |
|
108 |
||
109 |
void setBrush(); |
|
110 |
||
111 |
// ### unused, should have something for this in QPrintEngine |
|
112 |
void setAuthor(const QString &author); |
|
113 |
QString author() const; |
|
114 |
||
115 |
void setDevice(QIODevice* dev); |
|
116 |
||
117 |
private: |
|
118 |
Q_DISABLE_COPY(QPdfEngine) |
|
119 |
||
120 |
QPrinter::PrinterState state; |
|
121 |
}; |
|
122 |
||
123 |
class QPdfEnginePrivate : public QPdfBaseEnginePrivate |
|
124 |
{ |
|
125 |
Q_DECLARE_PUBLIC(QPdfEngine) |
|
126 |
public: |
|
127 |
QPdfEnginePrivate(QPrinter::PrinterMode m); |
|
128 |
~QPdfEnginePrivate(); |
|
129 |
||
130 |
void newPage(); |
|
131 |
||
132 |
int width() const { |
|
133 |
QRect r = paperRect(); |
|
134 |
return qRound(r.width()*72./resolution); |
|
135 |
} |
|
136 |
int height() const { |
|
137 |
QRect r = paperRect(); |
|
138 |
return qRound(r.height()*72./resolution); |
|
139 |
} |
|
140 |
||
141 |
void writeHeader(); |
|
142 |
void writeTail(); |
|
143 |
||
144 |
int addImage(const QImage &image, bool *bitmap, qint64 serial_no); |
|
145 |
int addConstantAlphaObject(int brushAlpha, int penAlpha = 255); |
|
146 |
int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject); |
|
147 |
||
148 |
void drawTextItem(const QPointF &p, const QTextItemInt &ti); |
|
149 |
||
150 |
QTransform pageMatrix() const; |
|
151 |
||
152 |
private: |
|
153 |
Q_DISABLE_COPY(QPdfEnginePrivate) |
|
154 |
||
155 |
#ifdef USE_NATIVE_GRADIENTS |
|
156 |
int gradientBrush(const QBrush &b, const QMatrix &matrix, int *gStateObject); |
|
157 |
#endif |
|
158 |
||
159 |
void writeInfo(); |
|
160 |
void writePageRoot(); |
|
161 |
void writeFonts(); |
|
162 |
void embedFont(QFontSubset *font); |
|
163 |
||
164 |
QVector<int> xrefPositions; |
|
165 |
QDataStream* stream; |
|
166 |
int streampos; |
|
167 |
||
168 |
int writeImage(const QByteArray &data, int width, int height, int depth, |
|
169 |
int maskObject, int softMaskObject, bool dct = false); |
|
170 |
void writePage(); |
|
171 |
||
172 |
int addXrefEntry(int object, bool printostr = true); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
173 |
void printString(const QString &string); |
0 | 174 |
void xprintf(const char* fmt, ...); |
175 |
inline void write(const QByteArray &data) { |
|
176 |
stream->writeRawData(data.constData(), data.size()); |
|
177 |
streampos += data.size(); |
|
178 |
} |
|
179 |
||
180 |
int writeCompressed(const char *src, int len); |
|
181 |
inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.length()); } |
|
182 |
int writeCompressed(QIODevice *dev); |
|
183 |
||
184 |
// various PDF objects |
|
185 |
int pageRoot, catalog, info, graphicsState, patternColorSpace; |
|
186 |
QVector<uint> pages; |
|
187 |
QHash<qint64, uint> imageCache; |
|
188 |
QHash<QPair<uint, uint>, uint > alphaCache; |
|
189 |
}; |
|
190 |
||
191 |
QT_END_NAMESPACE |
|
192 |
||
193 |
#endif // QT_NO_PRINTER |
|
194 |
||
195 |
#endif // QPRINTENGINE_PDF_P_H |