From 8f47da7b8f8d83bd79cde05dee6046b14a292ba9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 12 Aug 2011 14:19:23 +0200 Subject: first version of a public API to generate PDFs The class is required to be able to move the printing subsystem out into a module of it's own. Change-Id: I80703b8a8725504c7e6884a34f76e0735efcf95a Reviewed-on: http://codereview.qt.nokia.com/3200 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta --- src/gui/painting/qpdfwriter.h | 79 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/gui/painting/qpdfwriter.h (limited to 'src/gui/painting/qpdfwriter.h') diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h new file mode 100644 index 0000000000..4493e58f34 --- /dev/null +++ b/src/gui/painting/qpdfwriter.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPDFWRITER_H +#define QPDFWRITER_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPdfWriterPrivate; + +class Q_GUI_EXPORT QPdfWriter : public QObject, public QPaintDevice +{ + Q_OBJECT +public: + QPdfWriter(const QString &filename); + QPdfWriter(QIODevice *device); + ~QPdfWriter(); + + void newPage(); + +protected: + QPaintEngine *paintEngine() const; + int metric(PaintDeviceMetric id) const; + +private: + Q_DISABLE_COPY(QPdfWriter) + Q_DECLARE_PRIVATE(QPdfWriter) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif -- cgit v1.2.3 From 9ebdc333a6a6485fd60a50a742a1d6edec211f53 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 17 Aug 2011 11:26:51 +0200 Subject: Introduce a paged paintdevice and use it Introduce a QPagedPaintDevice class that has a newPage() method and page dimensions. QPdfWriter and QPrinter inherit from it. Add a bit of API to QPdfWriter. Change-Id: Ibf23e7fe741f3a5ed854faf5d249a272acc75f35 Reviewed-on: http://codereview.qt.nokia.com/3206 Reviewed-by: Gunnar Sletta --- src/gui/painting/qpdfwriter.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/gui/painting/qpdfwriter.h') diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index 4493e58f34..4e617aa617 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -43,7 +43,7 @@ #define QPDFWRITER_H #include -#include +#include QT_BEGIN_HEADER @@ -53,7 +53,7 @@ QT_MODULE(Gui) class QPdfWriterPrivate; -class Q_GUI_EXPORT QPdfWriter : public QObject, public QPaintDevice +class Q_GUI_EXPORT QPdfWriter : public QObject, public QPagedPaintDevice { Q_OBJECT public: @@ -61,7 +61,16 @@ public: QPdfWriter(QIODevice *device); ~QPdfWriter(); - void newPage(); + QString title() const; + void setTitle(const QString &title); + + QString creator() const; + void setCreator(const QString &creator); + + bool newPage(); + + void setPageSize(PageSize size); + void setPageSizeMM(const QSizeF &size); protected: QPaintEngine *paintEngine() const; -- cgit v1.2.3 From 28f1c1b9ef10fc3a49a64a535c7747a009939453 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 18 Aug 2011 11:04:06 +0200 Subject: Restore feature compatibility with QPrinter in QTextDocument::print Add a margin method to QPagedPaintDevice. The other variables required are stored in QPagedPaintDevicePrivate without a public API for now. This needs cleaning up once we have a new printing system. Change-Id: Id3f2d7ac7f3cbce8619072a897d91f3a588add64 Reviewed-on: http://codereview.qt.nokia.com/3211 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta --- src/gui/painting/qpdfwriter.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui/painting/qpdfwriter.h') diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index 4e617aa617..b224c12ed7 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -72,6 +72,8 @@ public: void setPageSize(PageSize size); void setPageSizeMM(const QSizeF &size); + void setMargins(const Margins &m); + protected: QPaintEngine *paintEngine() const; int metric(PaintDeviceMetric id) const; -- cgit v1.2.3 From 2e95ce7459c98f17f5b8d0c983bfb32102fd9932 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Aug 2011 10:39:45 +0200 Subject: Fix build. - Introduced EXPORT definition for new QPrintSupport library. - Fixed dependencies in src.pro - Fixed some includes. Change-Id: I9863233ca2767928b37cf3fd1fdec31351b5da6b Reviewed-on: http://codereview.qt.nokia.com/3253 Reviewed-by: Qt Sanity Bot Reviewed-by: Friedemann Kleint --- src/gui/painting/qpdfwriter.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui/painting/qpdfwriter.h') diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index b224c12ed7..005d8e640b 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) +class QIODevice; class QPdfWriterPrivate; class Q_GUI_EXPORT QPdfWriter : public QObject, public QPagedPaintDevice -- cgit v1.2.3