painting/qpdfwriter.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <qpdfwriter.h> -
43#include <QtCore/private/qobject_p.h> -
44#include "private/qpdf_p.h" -
45#include <QtCore/qfile.h> -
46 -
47QT_BEGIN_NAMESPACE -
48 -
49class QPdfWriterPrivate : public QObjectPrivate -
50{ -
51public: -
52 QPdfWriterPrivate() -
53 : QObjectPrivate() -
54 { -
55 engine = new QPdfEngine();
never executed (the execution status of this line is deduced): engine = new QPdfEngine();
-
56 output = 0;
never executed (the execution status of this line is deduced): output = 0;
-
57 }
never executed: }
0
58 ~QPdfWriterPrivate() -
59 { -
60 delete engine;
never executed (the execution status of this line is deduced): delete engine;
-
61 delete output;
never executed (the execution status of this line is deduced): delete output;
-
62 }
never executed: }
0
63 -
64 QPdfEngine *engine; -
65 QFile *output; -
66}; -
67 -
68 -
69/*! \class QPdfWriter -
70 \inmodule QtGui -
71 -
72 \brief The QPdfWriter class is a class to generate PDFs -
73 that can be used as a paint device. -
74 -
75 \ingroup painting -
76 -
77 QPdfWriter generates PDF out of a series of drawing commands using QPainter. -
78 The newPage() method can be used to create several pages. -
79 */ -
80 -
81/*! -
82 Constructs a PDF writer that will write the pdf to \a filename. -
83 */ -
84QPdfWriter::QPdfWriter(const QString &filename) -
85 : QObject(*new QPdfWriterPrivate) -
86{ -
87 Q_D(QPdfWriter);
never executed (the execution status of this line is deduced): QPdfWriterPrivate * const d = d_func();
-
88 -
89 d->engine->setOutputFilename(filename);
never executed (the execution status of this line is deduced): d->engine->setOutputFilename(filename);
-
90}
never executed: }
0
91 -
92/*! -
93 Constructs a PDF writer that will write the pdf to \a device. -
94 */ -
95QPdfWriter::QPdfWriter(QIODevice *device) -
96 : QObject(*new QPdfWriterPrivate) -
97{ -
98 Q_D(QPdfWriter);
never executed (the execution status of this line is deduced): QPdfWriterPrivate * const d = d_func();
-
99 -
100 d->engine->d_func()->outDevice = device;
never executed (the execution status of this line is deduced): d->engine->d_func()->outDevice = device;
-
101}
never executed: }
0
102 -
103/*! -
104 Destroys the pdf writer. -
105 */ -
106QPdfWriter::~QPdfWriter() -
107{ -
108 -
109} -
110 -
111/*! -
112 Returns the title of the document. -
113 */ -
114QString QPdfWriter::title() const -
115{ -
116 Q_D(const QPdfWriter);
never executed (the execution status of this line is deduced): const QPdfWriterPrivate * const d = d_func();
-
117 return d->engine->d_func()->title;
never executed: return d->engine->d_func()->title;
0
118} -
119 -
120/*! -
121 Sets the title of the document being created to \a title. -
122 */ -
123void QPdfWriter::setTitle(const QString &title) -
124{ -
125 Q_D(QPdfWriter);
never executed (the execution status of this line is deduced): QPdfWriterPrivate * const d = d_func();
-
126 d->engine->d_func()->title = title;
never executed (the execution status of this line is deduced): d->engine->d_func()->title = title;
-
127}
never executed: }
0
128 -
129/*! -
130 Returns the creator of the document. -
131 */ -
132QString QPdfWriter::creator() const -
133{ -
134 Q_D(const QPdfWriter);
never executed (the execution status of this line is deduced): const QPdfWriterPrivate * const d = d_func();
-
135 return d->engine->d_func()->creator;
never executed: return d->engine->d_func()->creator;
0
136} -
137 -
138/*! -
139 Sets the creator of the document to \a creator. -
140 */ -
141void QPdfWriter::setCreator(const QString &creator) -
142{ -
143 Q_D(QPdfWriter);
never executed (the execution status of this line is deduced): QPdfWriterPrivate * const d = d_func();
-
144 d->engine->d_func()->creator = creator;
never executed (the execution status of this line is deduced): d->engine->d_func()->creator = creator;
-
145}
never executed: }
0
146 -
147 -
148/*! -
149 \reimp -
150 */ -
151QPaintEngine *QPdfWriter::paintEngine() const -
152{ -
153 Q_D(const QPdfWriter);
never executed (the execution status of this line is deduced): const QPdfWriterPrivate * const d = d_func();
-
154 -
155 return d->engine;
never executed: return d->engine;
0
156} -
157 -
158/*! -
159 \reimp -
160 */ -
161void QPdfWriter::setPageSize(PageSize size) -
162{ -
163 Q_D(const QPdfWriter);
never executed (the execution status of this line is deduced): const QPdfWriterPrivate * const d = d_func();
-
164 -
165 QPagedPaintDevice::setPageSize(size);
never executed (the execution status of this line is deduced): QPagedPaintDevice::setPageSize(size);
-
166 d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.;
never executed (the execution status of this line is deduced): d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.;
-
167}
never executed: }
0
168 -
169/*! -
170 \reimp -
171 */ -
172void QPdfWriter::setPageSizeMM(const QSizeF &size) -
173{ -
174 Q_D(const QPdfWriter);
never executed (the execution status of this line is deduced): const QPdfWriterPrivate * const d = d_func();
-
175 -
176 QPagedPaintDevice::setPageSizeMM(size);
never executed (the execution status of this line is deduced): QPagedPaintDevice::setPageSizeMM(size);
-
177 d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.;
never executed (the execution status of this line is deduced): d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.;
-
178}
never executed: }
0
179 -
180/*! -
181 \internal -
182 -
183 Returns the metric for the given \a id. -
184*/ -
185int QPdfWriter::metric(PaintDeviceMetric id) const -
186{ -
187 Q_D(const QPdfWriter);
never executed (the execution status of this line is deduced): const QPdfWriterPrivate * const d = d_func();
-
188 return d->engine->metric(id);
never executed: return d->engine->metric(id);
0
189} -
190 -
191/*! -
192 \reimp -
193*/ -
194bool QPdfWriter::newPage() -
195{ -
196 Q_D(QPdfWriter);
never executed (the execution status of this line is deduced): QPdfWriterPrivate * const d = d_func();
-
197 -
198 return d->engine->newPage();
never executed: return d->engine->newPage();
0
199} -
200 -
201 -
202/*! -
203 \reimp -
204 */ -
205void QPdfWriter::setMargins(const Margins &m) -
206{ -
207 Q_D(QPdfWriter);
never executed (the execution status of this line is deduced): QPdfWriterPrivate * const d = d_func();
-
208 -
209 const qreal multiplier = 72./25.4;
never executed (the execution status of this line is deduced): const qreal multiplier = 72./25.4;
-
210 d->engine->d_func()->leftMargin = m.left*multiplier;
never executed (the execution status of this line is deduced): d->engine->d_func()->leftMargin = m.left*multiplier;
-
211 d->engine->d_func()->rightMargin = m.right*multiplier;
never executed (the execution status of this line is deduced): d->engine->d_func()->rightMargin = m.right*multiplier;
-
212 d->engine->d_func()->topMargin = m.top*multiplier;
never executed (the execution status of this line is deduced): d->engine->d_func()->topMargin = m.top*multiplier;
-
213 d->engine->d_func()->bottomMargin = m.bottom*multiplier;
never executed (the execution status of this line is deduced): d->engine->d_func()->bottomMargin = m.bottom*multiplier;
-
214}
never executed: }
0
215 -
216QT_END_NAMESPACE -
217 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial