Move the PDF related functionality into QPdf
Goal is to have all functionality related to PDF generation in QPdf, and then separate out the parts related to interfacing with the printing system into the pdf printengine. Change-Id: I8c30cb65365c503945fc270fad5cbcaabe59495d Reviewed-on: http://codereview.qt.nokia.com/3201 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>bb10
parent
8f47da7b8f
commit
b91d30eae1
File diff suppressed because it is too large
Load Diff
|
|
@ -56,14 +56,12 @@
|
|||
#include "QtCore/qstring.h"
|
||||
#include "QtCore/qvector.h"
|
||||
#include "private/qstroker_p.h"
|
||||
#include "private/qfontengine_p.h"
|
||||
#include "QtGui/qprinter.h"
|
||||
#include "private/qfontsubset_p.h"
|
||||
#include "private/qpaintengine_alpha_p.h"
|
||||
#include "qprintengine.h"
|
||||
#include "qbuffer.h"
|
||||
#include "private/qfontengine_p.h"
|
||||
#include "private/qfontsubset_p.h"
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
// ### remove!
|
||||
#include <qprinter.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -179,7 +177,7 @@ private:
|
|||
|
||||
class QPdfBaseEnginePrivate;
|
||||
|
||||
class QPdfBaseEngine : public QAlphaPaintEngine, public QPrintEngine
|
||||
class QPdfBaseEngine : public QAlphaPaintEngine
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QPdfBaseEngine)
|
||||
public:
|
||||
|
|
@ -198,18 +196,22 @@ public:
|
|||
|
||||
void drawTextItem(const QPointF &p, const QTextItem &textItem);
|
||||
|
||||
void drawPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QRectF & sr);
|
||||
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
|
||||
Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||
void drawTiledPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QPointF & point);
|
||||
|
||||
void updateState(const QPaintEngineState &state);
|
||||
|
||||
int metric(QPaintDevice::PaintDeviceMetric metricType) const;
|
||||
Type type() const;
|
||||
// end reimplementations QPaintEngine
|
||||
|
||||
// Printer stuff...
|
||||
bool newPage();
|
||||
void setProperty(PrintEnginePropertyKey key, const QVariant &value);
|
||||
QVariant property(PrintEnginePropertyKey key) const;
|
||||
|
||||
void setPen();
|
||||
virtual void setBrush() = 0;
|
||||
void setBrush();
|
||||
void setupGraphicsState(QPaintEngine::DirtyFlags flags);
|
||||
|
||||
private:
|
||||
|
|
@ -223,16 +225,33 @@ public:
|
|||
QPdfBaseEnginePrivate(QPrinter::PrinterMode m);
|
||||
~QPdfBaseEnginePrivate();
|
||||
|
||||
bool openPrintDevice();
|
||||
void closePrintDevice();
|
||||
|
||||
|
||||
virtual void drawTextItem(const QPointF &p, const QTextItemInt &ti);
|
||||
inline uint requestObject() { return currentObject++; }
|
||||
|
||||
QRect paperRect() const;
|
||||
QRect pageRect() const;
|
||||
|
||||
int width() const {
|
||||
QRect r = paperRect();
|
||||
return qRound(r.width()*72./resolution);
|
||||
}
|
||||
int height() const {
|
||||
QRect r = paperRect();
|
||||
return qRound(r.height()*72./resolution);
|
||||
}
|
||||
|
||||
void writeHeader();
|
||||
void writeTail();
|
||||
|
||||
int addImage(const QImage &image, bool *bitmap, qint64 serial_no);
|
||||
int addConstantAlphaObject(int brushAlpha, int penAlpha = 255);
|
||||
int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject);
|
||||
|
||||
void drawTextItem(const QPointF &p, const QTextItemInt &ti);
|
||||
|
||||
QTransform pageMatrix() const;
|
||||
|
||||
void newPage();
|
||||
|
||||
bool postscript;
|
||||
int currentObject;
|
||||
|
||||
|
|
@ -289,11 +308,45 @@ public:
|
|||
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||
QString cupsTempFile;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef USE_NATIVE_GRADIENTS
|
||||
int gradientBrush(const QBrush &b, const QMatrix &matrix, int *gStateObject);
|
||||
#endif
|
||||
|
||||
void writeInfo();
|
||||
void writePageRoot();
|
||||
void writeFonts();
|
||||
void embedFont(QFontSubset *font);
|
||||
|
||||
QVector<int> xrefPositions;
|
||||
QDataStream* stream;
|
||||
int streampos;
|
||||
|
||||
int writeImage(const QByteArray &data, int width, int height, int depth,
|
||||
int maskObject, int softMaskObject, bool dct = false);
|
||||
void writePage();
|
||||
|
||||
int addXrefEntry(int object, bool printostr = true);
|
||||
void printString(const QString &string);
|
||||
void xprintf(const char* fmt, ...);
|
||||
inline void write(const QByteArray &data) {
|
||||
stream->writeRawData(data.constData(), data.size());
|
||||
streampos += data.size();
|
||||
}
|
||||
|
||||
int writeCompressed(const char *src, int len);
|
||||
inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.length()); }
|
||||
int writeCompressed(QIODevice *dev);
|
||||
|
||||
// various PDF objects
|
||||
int pageRoot, catalog, info, graphicsState, patternColorSpace;
|
||||
QVector<uint> pages;
|
||||
QHash<qint64, uint> imageCache;
|
||||
QHash<QPair<uint, uint>, uint > alphaCache;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_PRINTER
|
||||
|
||||
#endif // QPDF_P_H
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -67,6 +67,7 @@
|
|||
#include "private/qfontengine_p.h"
|
||||
#include "private/qpdf_p.h"
|
||||
#include "private/qpaintengine_p.h"
|
||||
#include "qprintengine.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ class QPdfEngine;
|
|||
|
||||
class QPdfEnginePrivate;
|
||||
|
||||
class QPdfEngine : public QPdfBaseEngine
|
||||
class QPdfEngine : public QPdfBaseEngine, public QPrintEngine
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QPdfEngine)
|
||||
public:
|
||||
|
|
@ -92,32 +93,22 @@ public:
|
|||
// reimplementations QPaintEngine
|
||||
bool begin(QPaintDevice *pdev);
|
||||
bool end();
|
||||
void drawPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QRectF & sr);
|
||||
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
|
||||
Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||
void drawTiledPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QPointF & point);
|
||||
|
||||
Type type() const;
|
||||
// end reimplementations QPaintEngine
|
||||
|
||||
// reimplementations QPrintEngine
|
||||
bool abort() {return false;}
|
||||
bool newPage();
|
||||
QPrinter::PrinterState printerState() const {return state;}
|
||||
|
||||
bool newPage();
|
||||
int metric(QPaintDevice::PaintDeviceMetric) const;
|
||||
void setProperty(PrintEnginePropertyKey key, const QVariant &value);
|
||||
QVariant property(PrintEnginePropertyKey key) const;
|
||||
// end reimplementations QPrintEngine
|
||||
|
||||
void setBrush();
|
||||
|
||||
// ### unused, should have something for this in QPrintEngine
|
||||
void setAuthor(const QString &author);
|
||||
QString author() const;
|
||||
|
||||
void setDevice(QIODevice* dev);
|
||||
QPrinter::PrinterState state;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QPdfEngine)
|
||||
|
||||
QPrinter::PrinterState state;
|
||||
};
|
||||
|
||||
class QPdfEnginePrivate : public QPdfBaseEnginePrivate
|
||||
|
|
@ -127,65 +118,12 @@ public:
|
|||
QPdfEnginePrivate(QPrinter::PrinterMode m);
|
||||
~QPdfEnginePrivate();
|
||||
|
||||
void newPage();
|
||||
|
||||
int width() const {
|
||||
QRect r = paperRect();
|
||||
return qRound(r.width()*72./resolution);
|
||||
}
|
||||
int height() const {
|
||||
QRect r = paperRect();
|
||||
return qRound(r.height()*72./resolution);
|
||||
}
|
||||
|
||||
void writeHeader();
|
||||
void writeTail();
|
||||
|
||||
int addImage(const QImage &image, bool *bitmap, qint64 serial_no);
|
||||
int addConstantAlphaObject(int brushAlpha, int penAlpha = 255);
|
||||
int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject);
|
||||
|
||||
void drawTextItem(const QPointF &p, const QTextItemInt &ti);
|
||||
|
||||
QTransform pageMatrix() const;
|
||||
bool openPrintDevice();
|
||||
void closePrintDevice();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QPdfEnginePrivate)
|
||||
|
||||
#ifdef USE_NATIVE_GRADIENTS
|
||||
int gradientBrush(const QBrush &b, const QMatrix &matrix, int *gStateObject);
|
||||
#endif
|
||||
|
||||
void writeInfo();
|
||||
void writePageRoot();
|
||||
void writeFonts();
|
||||
void embedFont(QFontSubset *font);
|
||||
|
||||
QVector<int> xrefPositions;
|
||||
QDataStream* stream;
|
||||
int streampos;
|
||||
|
||||
int writeImage(const QByteArray &data, int width, int height, int depth,
|
||||
int maskObject, int softMaskObject, bool dct = false);
|
||||
void writePage();
|
||||
|
||||
int addXrefEntry(int object, bool printostr = true);
|
||||
void printString(const QString &string);
|
||||
void xprintf(const char* fmt, ...);
|
||||
inline void write(const QByteArray &data) {
|
||||
stream->writeRawData(data.constData(), data.size());
|
||||
streampos += data.size();
|
||||
}
|
||||
|
||||
int writeCompressed(const char *src, int len);
|
||||
inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.length()); }
|
||||
int writeCompressed(QIODevice *dev);
|
||||
|
||||
// various PDF objects
|
||||
int pageRoot, catalog, info, graphicsState, patternColorSpace;
|
||||
QVector<uint> pages;
|
||||
QHash<qint64, uint> imageCache;
|
||||
QHash<QPair<uint, uint>, uint > alphaCache;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue