summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpdfoutputintent.cpp
blob: 519dab6db280e3729e74d5d1f1d63cd2a18be092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qpdfoutputintent.h"

#ifndef QT_NO_PDF

#include <QtCore/qfile.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
#include <QtCore/qurl.h>

#include <QtGui/qcolorspace.h>

QT_BEGIN_NAMESPACE

class QPdfOutputIntentPrivate : public QSharedData
{
public:
    QPdfOutputIntentPrivate()
    {
        QFile colorProfileFile(QStringLiteral(":/qpdf/sRGB2014.icc"));
        bool ok = colorProfileFile.open(QIODevice::ReadOnly);
        Q_ASSERT(ok);
        outputProfile = QColorSpace::fromIccProfile(colorProfileFile.readAll());
    }

    QString outputConditionIdentifier = QStringLiteral("sRGB_IEC61966-2-1_black_scaled");
    QString outputCondition = QStringLiteral("sRGB IEC61966 v2.1 with black scaling");
    QUrl registryName = QStringLiteral("http://www.color.org");
    QColorSpace outputProfile;
};

/*!
    \class QPdfOutputIntent
    \inmodule QtGui
    \ingroup painting
    \since 6.8

    The QPdfOutputIntent class contains metadata that characterize
    the printing condition for which painting data has been prepared
    when generating a PDF file.

    \sa QPdfWriter
*/

/*!
    Constructs a new PDF output intent.
*/
QPdfOutputIntent::QPdfOutputIntent()
    : d(new QPdfOutputIntentPrivate)
{}

/*!
    Constructs a copy of the output intent \a other.
*/
QPdfOutputIntent::QPdfOutputIntent(const QPdfOutputIntent &other) = default;

/*!
    \fn QPdfOutputIntent::QPdfOutputIntent(QPdfOutputIntent &&other) noexcept

    Constructs a QPdfOutputIntent object by moving from \a other.
*/

/*!
    Assigns the output intent \a other over this intent.
*/
QPdfOutputIntent &QPdfOutputIntent::operator=(const QPdfOutputIntent &other) = default;

/*!
    \fn QPdfOutputIntent &QPdfOutputIntent::operator=(QPdfOutputIntent &&other) noexcept

    Move-assigns the output intent \a other over this intent.
*/

/*!
    Destroys this output intent.
*/
QPdfOutputIntent::~QPdfOutputIntent() = default;

/*!
    \fn void QPdfOutputIntent::swap(QPdfOutputIntent &other) noexcept
    \memberswap{output intent}
*/

/*!
    Returns the identifier of the output condition.

    If a registry name is provided, then this identifier should should
    match the reference name of an entry in that registry.

    The default identifier is \c{sRGB_IEC61966-2-1_black_scaled}.

    \sa setOutputConditionIdentifier()
*/
QString QPdfOutputIntent::outputConditionIdentifier() const
{
    return d->outputConditionIdentifier;
}

/*!
    Sets the identifier of the output condition to \a identifier.

    If a registry name is provided, then this identifier should should
    match the reference name of an entry in that registry.

    \sa setOutputCondition(), setRegistryName()
*/
void QPdfOutputIntent::setOutputConditionIdentifier(const QString &identifier)
{
    d.detach();
    d->outputConditionIdentifier = identifier;
}

/*!
    Returns the human-readable output condition.

    This is a string that concisely identifies the characterized
    printing condition in a form that will be meaningful to a
    human operator.

    The default output condition is
    \c{sRGB IEC61966 v2.1 with black scaling}.

    \sa setOutputCondition()
*/
QString QPdfOutputIntent::outputCondition() const
{
    return d->outputCondition;
}

/*!
    Sets the human-readable output condition to \a condition.

    \sa setOutputConditionIdentifier(), setRegistryName()
*/
void QPdfOutputIntent::setOutputCondition(const QString &condition)
{
    d.detach();
    d->outputCondition = condition;
}

/*!
    Returns the URL of a characterization registry for the intended
    printing condition.

    The default registry is \c{http://www.color.org}.

    \sa setOutputConditionIdentifier()
*/
QUrl QPdfOutputIntent::registryName() const
{
    return d->registryName;
}

/*!
    Sets the URL of the characterization registry to \a name.

    \sa setOutputConditionIdentifier()
*/
void QPdfOutputIntent::setRegistryName(const QUrl &name)
{
    d.detach();
    d->registryName = name;
}

/*!
    Returns the output device profile.

    The default profile is the sRGB v2 profile available
    from the
    \l{https://www.color.org/srgbprofiles.xalter#v2}{International
    Color Consortium}.
*/
QColorSpace QPdfOutputIntent::outputProfile() const
{
    return d->outputProfile;
}

/*!
    Sets the output device profile to \a profile.

    \note PDF/X-4 requires all the color specifications in the
    document to match the same colorspace of \a profile. It is
    the application's responsibility to ensure this is the case.

    \sa QColorSpace::fromIccProfile, QPdfWriter::setColorModel
*/
void QPdfOutputIntent::setOutputProfile(const QColorSpace &profile)
{
    d.detach();
    d->outputProfile = profile;
}

QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QPdfOutputIntentPrivate)

QT_END_NAMESPACE

#endif // QT_NO_PDF