mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Implement downstream patch to add Qt5 support
This commit is contained in:
parent
ca112d25ed
commit
1bcf0e8111
@ -39,7 +39,11 @@ public:
|
||||
inline ~PDFOpenSSLGlobalLock() = default;
|
||||
|
||||
private:
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QMutexLocker<QRecursiveMutex> m_mutexLocker;
|
||||
#else
|
||||
QMutexLocker m_mutexLocker;
|
||||
#endif
|
||||
static QRecursiveMutex s_globalOpenSSLMutex;
|
||||
};
|
||||
|
||||
|
@ -1232,7 +1232,11 @@ cmsHTRANSFORM PDFLittleCMS::getTransformBetweenColorSpaces(const PDFCMS::ColorSp
|
||||
QString getInfoFromProfile(cmsHPROFILE profile, cmsInfoType infoType)
|
||||
{
|
||||
QLocale locale;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString country = QLocale::territoryToString(locale.territory());
|
||||
#else
|
||||
QString country = QLocale::countryToString(locale.country());
|
||||
#endif
|
||||
QString language = QLocale::languageToString(locale.language());
|
||||
|
||||
char countryCode[3] = { };
|
||||
@ -1493,7 +1497,11 @@ PDFCMSSettings PDFCMSManager::getDefaultSettings() const
|
||||
|
||||
void PDFCMSManager::setDocument(const PDFDocument* document)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
std::optional<QMutexLocker<QRecursiveMutex>> lock;
|
||||
#else
|
||||
std::optional<QMutexLocker> lock;
|
||||
#endif
|
||||
lock.emplace(&m_mutex);
|
||||
|
||||
if (m_document == document)
|
||||
|
@ -116,10 +116,17 @@ QImage PDFColorConvertor::convert(QImage image) const
|
||||
|
||||
case Mode::Grayscale:
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QImage alpha = image.convertedTo(QImage::Format_Alpha8);
|
||||
QImage grayscaleImage = image.convertedTo(QImage::Format_Grayscale8);
|
||||
#else
|
||||
QImage alpha = image;
|
||||
alpha.convertTo(QImage::Format_Alpha8);
|
||||
QImage grayscaleImage = image;
|
||||
grayscaleImage.convertTo(QImage::Format_Grayscale8);
|
||||
#endif
|
||||
QImage resultImage = grayscaleImage;
|
||||
resultImage = resultImage.convertedTo(QImage::Format_ARGB32);
|
||||
resultImage.convertTo(QImage::Format_ARGB32);
|
||||
resultImage.setAlphaChannel(std::move(alpha));
|
||||
return resultImage;
|
||||
}
|
||||
|
@ -884,8 +884,13 @@ void PDFDiff::finalizeGraphicsPieces(PDFDiffPageContext& context)
|
||||
continue;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QByteArrayView view(reinterpret_cast<const char*>(info.hash.data()), info.hash.size());
|
||||
hasher.addData(view);
|
||||
#else
|
||||
hasher.addData(reinterpret_cast<const char*>(info.hash.data()), info.hash.size());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
QByteArray hash = hasher.result();
|
||||
|
@ -506,7 +506,11 @@ PDFObject PDFObjectFactory::createTextString(QString textString)
|
||||
|
||||
{
|
||||
QTextStream textStream(&ba, QIODevice::WriteOnly);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
textStream.setEncoding(QStringConverter::Utf16BE);
|
||||
#else
|
||||
textStream.setCodec("UTF-16BE");
|
||||
#endif
|
||||
textStream.setGenerateByteOrderMark(true);
|
||||
textStream << textString;
|
||||
}
|
||||
|
@ -16,11 +16,14 @@
|
||||
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "pdfencoding.h"
|
||||
#include "pdfdbgheap.h"
|
||||
|
||||
#include <QTimeZone>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QStringDecoder>
|
||||
|
||||
#include "pdfdbgheap.h"
|
||||
#else
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
@ -2375,6 +2378,7 @@ QString PDFEncoding::convertSmartFromByteStringToUnicode(const QByteArray& strea
|
||||
if (hasUnicodeLeadMarkings(stream))
|
||||
{
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QStringDecoder decoder(QStringDecoder::Utf16BE);
|
||||
QString text = decoder.decode(stream);
|
||||
|
||||
@ -2382,9 +2386,16 @@ QString PDFEncoding::convertSmartFromByteStringToUnicode(const QByteArray& strea
|
||||
{
|
||||
return text;
|
||||
}
|
||||
#else
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-16BE");
|
||||
QString text = codec->toUnicode(stream);
|
||||
// TODO -- how to detect errors?
|
||||
return text;
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QStringDecoder decoder(QStringDecoder::Utf16LE);
|
||||
QString text = decoder.decode(stream);
|
||||
|
||||
@ -2392,11 +2403,18 @@ QString PDFEncoding::convertSmartFromByteStringToUnicode(const QByteArray& strea
|
||||
{
|
||||
return text;
|
||||
}
|
||||
#else
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-16LE");
|
||||
QString text = codec->toUnicode(stream);
|
||||
// TODO -- how to detect errors?
|
||||
return text;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (hasUTF8LeadMarkings(stream))
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QStringDecoder decoder(QStringDecoder::Utf8);
|
||||
QString text = decoder.decode(stream);
|
||||
|
||||
@ -2404,6 +2422,12 @@ QString PDFEncoding::convertSmartFromByteStringToUnicode(const QByteArray& strea
|
||||
{
|
||||
return text;
|
||||
}
|
||||
#else
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
QString text = codec->toUnicode(stream);
|
||||
// TODO -- how to detect errors?
|
||||
return text;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (canConvertFromEncoding(stream, Encoding::PDFDoc))
|
||||
|
@ -18,9 +18,12 @@
|
||||
#ifndef PDFGLOBAL_H
|
||||
#define PDFGLOBAL_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QtSystemDetection>
|
||||
#include <QtCompilerDetection>
|
||||
#include <QCoreApplication>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
#include <tuple>
|
||||
|
@ -82,7 +82,11 @@ void PDFIconTheme::prepareTheme()
|
||||
{
|
||||
{
|
||||
QTextStream stream(&file);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
stream.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
stream.setCodec("UTF-8");
|
||||
#endif
|
||||
stream.setGenerateByteOrderMark(true);
|
||||
for (const QString& text : infoList)
|
||||
{
|
||||
|
@ -712,7 +712,11 @@ PDFObject PDFParser::getObject()
|
||||
{
|
||||
case PDFLexicalAnalyzer::TokenType::Boolean:
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
Q_ASSERT(m_lookAhead1.data.typeId() == QMetaType::Bool);
|
||||
#else
|
||||
Q_ASSERT(m_lookAhead1.data.type() == QVariant::Bool);
|
||||
#endif
|
||||
const bool value = m_lookAhead1.data.toBool();
|
||||
shift();
|
||||
return PDFObject::createBool(value);
|
||||
@ -720,7 +724,11 @@ PDFObject PDFParser::getObject()
|
||||
|
||||
case PDFLexicalAnalyzer::TokenType::Integer:
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
Q_ASSERT(m_lookAhead1.data.typeId() == QMetaType::LongLong);
|
||||
#else
|
||||
Q_ASSERT(m_lookAhead1.data.type() == QVariant::LongLong);
|
||||
#endif
|
||||
const PDFInteger value = m_lookAhead1.data.toLongLong();
|
||||
shift();
|
||||
|
||||
@ -730,7 +738,11 @@ PDFObject PDFParser::getObject()
|
||||
m_lookAhead2.type == PDFLexicalAnalyzer::TokenType::Command &&
|
||||
m_lookAhead2.data.toByteArray() == PDF_REFERENCE_COMMAND)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
Q_ASSERT(m_lookAhead1.data.typeId() == QMetaType::LongLong);
|
||||
#else
|
||||
Q_ASSERT(m_lookAhead1.data.type() == QVariant::LongLong);
|
||||
#endif
|
||||
const PDFInteger generation = m_lookAhead1.data.toLongLong();
|
||||
shift();
|
||||
shift();
|
||||
@ -745,7 +757,11 @@ PDFObject PDFParser::getObject()
|
||||
|
||||
case PDFLexicalAnalyzer::TokenType::Real:
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
Q_ASSERT(m_lookAhead1.data.typeId() == QMetaType::Double);
|
||||
#else
|
||||
Q_ASSERT(m_lookAhead1.data.type() == QVariant::Double);
|
||||
#endif
|
||||
const PDFReal value = m_lookAhead1.data.toDouble();
|
||||
shift();
|
||||
return PDFObject::createReal(value);
|
||||
@ -753,7 +769,11 @@ PDFObject PDFParser::getObject()
|
||||
|
||||
case PDFLexicalAnalyzer::TokenType::String:
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
Q_ASSERT(m_lookAhead1.data.typeId() == QMetaType::QByteArray);
|
||||
#else
|
||||
Q_ASSERT(m_lookAhead1.data.type() == QVariant::ByteArray);
|
||||
#endif
|
||||
QByteArray array = m_lookAhead1.data.toByteArray();
|
||||
array.shrink_to_fit();
|
||||
shift();
|
||||
@ -762,7 +782,11 @@ PDFObject PDFParser::getObject()
|
||||
|
||||
case PDFLexicalAnalyzer::TokenType::Name:
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
Q_ASSERT(m_lookAhead1.data.typeId() == QMetaType::QByteArray);
|
||||
#else
|
||||
Q_ASSERT(m_lookAhead1.data.type() == QVariant::ByteArray);
|
||||
#endif
|
||||
QByteArray array = m_lookAhead1.data.toByteArray();
|
||||
array.shrink_to_fit();
|
||||
shift();
|
||||
|
@ -45,13 +45,10 @@
|
||||
#pragma clang diagnostic ignored "-Wregister"
|
||||
#endif
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:5033)
|
||||
#ifndef CMS_NO_REGISTER_KEYWORD
|
||||
#define CMS_NO_REGISTER_KEYWORD
|
||||
#endif
|
||||
#include <lcms2.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
#ifdef PDF4QT_COMPILER_CLANG
|
||||
#pragma clang diagnostic pop
|
||||
@ -581,7 +578,7 @@ QColor PDFColorScale::map(PDFReal value) const
|
||||
fractionValue = 1.0;
|
||||
}
|
||||
|
||||
Q_ASSERT(index + 1 < static_cast<int>(m_colorScales.size()));
|
||||
Q_ASSERT(index + 1 < static_cast< int >(m_colorScales.size()));
|
||||
|
||||
const QColor& leftValue = m_colorScales[index];
|
||||
const QColor& rightValue = m_colorScales[index + 1];
|
||||
|
@ -472,10 +472,17 @@ constexpr bool isRectangleVerticallyOverlapped(const QRectF& r1, const QRectF& r
|
||||
|
||||
inline QColor invertColor(QColor color)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
float r = 0.0;
|
||||
float g = 0.0;
|
||||
float b = 0.0;
|
||||
float a = 0.0;
|
||||
#else
|
||||
double r = 0.0;
|
||||
double g = 0.0;
|
||||
double b = 0.0;
|
||||
double a = 0.0;
|
||||
#endif
|
||||
|
||||
color.getRgbF(&r, &g, &b, &a);
|
||||
|
||||
|
@ -12135,19 +12135,35 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui,
|
||||
passwordEdit || signature || textEdit;
|
||||
const bool isDefaultUi = !isNonDefaultUi || defaultUi;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (textEdit || (isDefaultUi && value.value.typeId() == QMetaType::QString))
|
||||
#else
|
||||
if (textEdit || (isDefaultUi && value.value.type() == QVariant::String))
|
||||
#endif
|
||||
{
|
||||
drawUiTextEdit(textEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter);
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
else if (checkButton || (isDefaultUi && value.value.typeId() == QMetaType::Bool))
|
||||
#else
|
||||
else if (checkButton || (isDefaultUi && value.value.type() == QVariant::Bool))
|
||||
#endif
|
||||
{
|
||||
drawUiCheckButton(checkButton, value, nominalExtentArea, painter);
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
else if (imageEdit || (isDefaultUi && value.value.typeId() == QMetaType::QImage))
|
||||
#else
|
||||
else if (imageEdit || (isDefaultUi && value.value.type() == QVariant::Image))
|
||||
#endif
|
||||
{
|
||||
drawUiImageEdit(imageEdit, value, errors, nominalExtentArea, painter);
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
else if (numericEdit || (isDefaultUi && value.value.typeId() == QMetaType::Double))
|
||||
#else
|
||||
else if (numericEdit || (isDefaultUi && value.value.type() == QVariant::Double))
|
||||
#endif
|
||||
{
|
||||
drawUiNumericEdit(numericEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter);
|
||||
}
|
||||
@ -12167,9 +12183,15 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui,
|
||||
{
|
||||
errors << PDFRenderError(RenderErrorType::NotImplemented, PDFTranslationContext::tr("XFA: Buttons not implemented."));
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
else if (dateTimeEdit || (isDefaultUi && (value.value.typeId() == QMetaType::QDateTime ||
|
||||
value.value.typeId() == QMetaType::QDate ||
|
||||
value.value.typeId() == QMetaType::QTime)))
|
||||
#else
|
||||
else if (dateTimeEdit || (isDefaultUi && (value.value.type() == QVariant::DateTime ||
|
||||
value.value.type() == QVariant::Date ||
|
||||
value.value.type() == QVariant::Time)))
|
||||
#endif
|
||||
{
|
||||
drawUiDateTimeEdit(dateTimeEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter);
|
||||
}
|
||||
@ -12392,15 +12414,27 @@ void PDFXFAEngineImpl::drawUiDateTimeEdit(const xfa::XFA_dateTimeEdit* dateTimeE
|
||||
|
||||
QString text;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.value.typeId() == QMetaType::QDateTime)
|
||||
#else
|
||||
if (value.value.type() == QVariant::DateTime)
|
||||
#endif
|
||||
{
|
||||
text = value.value.toDateTime().toString();
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
else if (value.value.typeId() == QMetaType::QTime)
|
||||
#else
|
||||
else if (value.value.type() == QVariant::Time)
|
||||
#endif
|
||||
{
|
||||
text = value.value.toTime().toString();
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
else if (value.value.typeId() == QMetaType::QDate)
|
||||
#else
|
||||
else if (value.value.type() == QVariant::Date)
|
||||
#endif
|
||||
{
|
||||
text = value.value.toDate().toString();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user