From 92f4055d052bf7db1bba3ba6a0b0bd246cd5289a Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Tue, 14 Dec 2021 19:28:38 +0100 Subject: [PATCH] Qbs: fix build clang, mingw --- CodeGenerator/codegenerator.cpp | 2 +- JBIG2_Viewer/mainwindow.cpp | 4 ++-- Pdf4QtLib/Pdf4QtLib.qbs | 9 ++++++--- Pdf4QtLib/sources/pdfalgorithmlcs.cpp | 2 +- Pdf4QtLib/sources/pdfannotation.cpp | 2 +- Pdf4QtLib/sources/pdfcatalog.cpp | 2 +- Pdf4QtLib/sources/pdfcms.cpp | 2 +- Pdf4QtLib/sources/pdfdocument.cpp | 11 ++++++++++ Pdf4QtLib/sources/pdfdocument.h | 12 ----------- Pdf4QtLib/sources/pdfdocumentmanipulator.cpp | 2 +- Pdf4QtLib/sources/pdfdocumentreader.cpp | 10 +++++----- Pdf4QtLib/sources/pdfdocumentreader.h | 2 +- Pdf4QtLib/sources/pdfencoding.cpp | 5 ++++- Pdf4QtLib/sources/pdffont.h | 2 +- Pdf4QtLib/sources/pdfform.cpp | 8 ++++---- Pdf4QtLib/sources/pdfform.h | 2 +- Pdf4QtLib/sources/pdffunction.cpp | 2 +- Pdf4QtLib/sources/pdfitemmodels.cpp | 4 ++-- Pdf4QtLib/sources/pdfnametounicode.cpp | 2 +- Pdf4QtLib/sources/pdfpagecontentprocessor.cpp | 16 ++++++++------- Pdf4QtLib/sources/pdfpainter.cpp | 4 +++- Pdf4QtLib/sources/pdfparser.cpp | 2 ++ Pdf4QtLib/sources/pdfpattern.cpp | 4 ++-- Pdf4QtLib/sources/pdfsignaturehandler.cpp | 4 ++-- Pdf4QtLib/sources/pdfstreamfilters.cpp | 20 ------------------- Pdf4QtLib/sources/pdftransparencyrenderer.cpp | 2 +- Pdf4QtLib/sources/pdfutils.h | 8 +++++++- Pdf4QtLib/sources/pdfxfaengine.cpp | 2 +- .../AudioBookPlugin/audiobookcreator.cpp | 2 +- .../AudioBookPlugin/audiobookplugin.cpp | 4 ++-- .../OutputPreviewPlugin/inkcoveragedialog.cpp | 2 ++ .../outputpreviewwidget.cpp | 2 +- PdfTool/pdftoolaudiobook.cpp | 2 +- PdfTool/pdftoolfetchimages.cpp | 4 ++-- 34 files changed, 81 insertions(+), 82 deletions(-) diff --git a/CodeGenerator/codegenerator.cpp b/CodeGenerator/codegenerator.cpp index 7732d6b..b4f3dcc 100644 --- a/CodeGenerator/codegenerator.cpp +++ b/CodeGenerator/codegenerator.cpp @@ -984,7 +984,7 @@ QStringList GeneratedBase::getFormattedTextWithLayout(QString firstPrefix, QStri int usedLength = indent + qMax(firstPrefix.length(), prefix.length()); int length = 80 - usedLength; QString testText(length, QChar('A')); - int width = fontMetrics.width(testText); + int width = fontMetrics.horizontalAdvance(testText); QTextLayout layout(text, font); layout.setCacheEnabled(false); diff --git a/JBIG2_Viewer/mainwindow.cpp b/JBIG2_Viewer/mainwindow.cpp index a3e5f57..4c4ff9e 100644 --- a/JBIG2_Viewer/mainwindow.cpp +++ b/JBIG2_Viewer/mainwindow.cpp @@ -101,12 +101,12 @@ void MainWindow::on_actionAdd_JBIG2_image_triggered() { QImage image(imageData.getWidth(), imageData.getHeight(), QImage::Format_Mono); const uchar* sourceData = reinterpret_cast(imageData.getData().constData()); - Q_ASSERT(imageData.getData().size() == image.byteCount()); + Q_ASSERT(imageData.getData().size() == image.sizeInBytes()); std::transform(sourceData, sourceData + imageData.getData().size(), image.bits(), [](const uchar value) { return value; }); addImage(file.fileName() + QString(", Decoded in %1 [msec]").arg(time), qMove(image)); } } - catch (pdf::PDFException exception) + catch (const pdf::PDFException& exception) { QMessageBox::critical(this, tr("Error"), exception.getMessage()); } diff --git a/Pdf4QtLib/Pdf4QtLib.qbs b/Pdf4QtLib/Pdf4QtLib.qbs index d40fb25..8bd1b53 100644 --- a/Pdf4QtLib/Pdf4QtLib.qbs +++ b/Pdf4QtLib/Pdf4QtLib.qbs @@ -9,17 +9,20 @@ Pdf4QtLibrary { Depends { name: "openjpeg" } Depends { name: "lcms" } Depends { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("mingw") name: "tbb" } Depends { condition: qbs.hostOS.contains("linux") name: "fontconfig" } + Properties { + condition: qbs.toolchain.contains("msvc") || qbs.toolchain.contains("clang") + cpp.cxxFlags: "/bigobj" + } Properties { condition: qbs.hostOS.contains("windows") cpp.defines: "PDF4QTLIB_LIBRARY" - cpp.cxxFlags: "/bigobj" } files: [ @@ -38,7 +41,7 @@ Pdf4QtLibrary { Depends { name: "openjpeg" } Depends { name: "lcms" } Depends { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("mingw") name: "tbb" } Depends { diff --git a/Pdf4QtLib/sources/pdfalgorithmlcs.cpp b/Pdf4QtLib/sources/pdfalgorithmlcs.cpp index c9eedaa..30e2ff3 100644 --- a/Pdf4QtLib/sources/pdfalgorithmlcs.cpp +++ b/Pdf4QtLib/sources/pdfalgorithmlcs.cpp @@ -164,7 +164,7 @@ PDFAlgorithmLongestCommonSubsequenceBase::SequenceItemRanges PDFAlgorithmLongest PDFAlgorithmLongestCommonSubsequenceBase::SequenceItemFlags PDFAlgorithmLongestCommonSubsequenceBase::collectFlags(const SequenceItemRange& range) { - SequenceItemFlags flags = 0; + SequenceItemFlags flags = SequenceItemFlags(); for (auto it = range.first; it != range.second; ++it) { diff --git a/Pdf4QtLib/sources/pdfannotation.cpp b/Pdf4QtLib/sources/pdfannotation.cpp index ee6ff60..1dd4525 100644 --- a/Pdf4QtLib/sources/pdfannotation.cpp +++ b/Pdf4QtLib/sources/pdfannotation.cpp @@ -1410,7 +1410,7 @@ void PDFAnnotationManager::drawAnnotation(const PageAnnotation& annotation, drawAnnotationUsingAppearanceStream(annotation, appearanceStreamObject, pagePointToDevicePointMatrix, page, cms, painter); } } - catch (PDFException exception) + catch (const PDFException& exception) { errors.push_back(PDFRenderError(RenderErrorType::Error, exception.getMessage())); } diff --git a/Pdf4QtLib/sources/pdfcatalog.cpp b/Pdf4QtLib/sources/pdfcatalog.cpp index 12b0ba2..44a7e04 100644 --- a/Pdf4QtLib/sources/pdfcatalog.cpp +++ b/Pdf4QtLib/sources/pdfcatalog.cpp @@ -684,7 +684,7 @@ PDFDocumentSecurityStore PDFDocumentSecurityStore::parse(const PDFObject& object } } } - catch (PDFException) + catch (const PDFException&) { return PDFDocumentSecurityStore(); } diff --git a/Pdf4QtLib/sources/pdfcms.cpp b/Pdf4QtLib/sources/pdfcms.cpp index 6154a6c..475862d 100644 --- a/Pdf4QtLib/sources/pdfcms.cpp +++ b/Pdf4QtLib/sources/pdfcms.cpp @@ -1491,7 +1491,7 @@ void PDFCMSManager::setDocument(const PDFDocument* document) content = m_document->getDecodedStream(outputProfileObject.getStream()); } } - catch (PDFException) + catch (const PDFException&) { continue; } diff --git a/Pdf4QtLib/sources/pdfdocument.cpp b/Pdf4QtLib/sources/pdfdocument.cpp index eac2037..ca5a87c 100644 --- a/Pdf4QtLib/sources/pdfdocument.cpp +++ b/Pdf4QtLib/sources/pdfdocument.cpp @@ -642,4 +642,15 @@ std::vector PDFDocumentDataLoaderDecorator::readStringArray(const PD return std::vector(); } +const PDFObject& PDFObjectStorage::getObject(const PDFObject& object) const +{ + if (object.isReference()) + { + // Try to dereference the object + return getObject(object.getReference()); + } + + return object; +} + } // namespace pdf diff --git a/Pdf4QtLib/sources/pdfdocument.h b/Pdf4QtLib/sources/pdfdocument.h index da6344e..d476ece 100644 --- a/Pdf4QtLib/sources/pdfdocument.h +++ b/Pdf4QtLib/sources/pdfdocument.h @@ -598,18 +598,6 @@ const PDFObject& PDFDocument::getObjectByReference(PDFObjectReference reference) return m_pdfObjectStorage.getObject(reference); } -inline -const PDFObject& PDFObjectStorage::getObject(const PDFObject& object) const -{ - if (object.isReference()) - { - // Try to dereference the object - return getObject(object.getReference()); - } - - return object; -} - inline const PDFDictionary* PDFObjectStorage::getDictionaryFromObject(const PDFObject& object) const { diff --git a/Pdf4QtLib/sources/pdfdocumentmanipulator.cpp b/Pdf4QtLib/sources/pdfdocumentmanipulator.cpp index 812c022..b484c5a 100644 --- a/Pdf4QtLib/sources/pdfdocumentmanipulator.cpp +++ b/Pdf4QtLib/sources/pdfdocumentmanipulator.cpp @@ -91,7 +91,7 @@ PDFOperationResult PDFDocumentManipulator::assemble(const AssembledPages& pages) // Optimize document - remove unused objects and shrink object storage finalizeDocument(&mergedDocument); } - catch (PDFException exception) + catch (const PDFException& exception) { return exception.getMessage(); } diff --git a/Pdf4QtLib/sources/pdfdocumentreader.cpp b/Pdf4QtLib/sources/pdfdocumentreader.cpp index dfcbe40..4d4aa1e 100644 --- a/Pdf4QtLib/sources/pdfdocumentreader.cpp +++ b/Pdf4QtLib/sources/pdfdocumentreader.cpp @@ -162,7 +162,7 @@ void PDFDocumentReader::checkHeader(const QByteArray& buffer) } } -const PDFInteger PDFDocumentReader::findXrefTableOffset(const QByteArray& buffer) +PDFInteger PDFDocumentReader::findXrefTableOffset(const QByteArray& buffer) { const int startXRefPosition = findFromEnd(PDF_START_OF_XREF_MARK, buffer, PDF_FOOTER_SCAN_LIMIT); if (startXRefPosition == FIND_NOT_FOUND_RESULT) @@ -271,7 +271,7 @@ PDFObject PDFDocumentReader::readDamagedTrailerDictionary() const object = PDFObjectManipulator::merge(object, trailerDictionaryObject, PDFObjectManipulator::RemoveNullObjects); } } - catch (PDFException) + catch (const PDFException&) { // Do nothing... } @@ -299,7 +299,7 @@ PDFDocumentReader::Result PDFDocumentReader::processReferenceTableEntries(PDFXRe QMutexLocker lock(&m_mutex); objects[entry.reference.objectNumber] = PDFObjectStorage::Entry(entry.reference.generation, object); } - catch (PDFException exception) + catch (const PDFException& exception) { QMutexLocker lock(&m_mutex); @@ -518,7 +518,7 @@ void PDFDocumentReader::processObjectStreams(PDFXRefTable* xrefTable, PDFObjectS } } } - catch (PDFException exception) + catch (const PDFException& exception) { QMutexLocker lock(&m_mutex); m_result = Result::Failed; @@ -711,7 +711,7 @@ bool PDFDocumentReader::restoreObjects(std::map& } } } - catch (PDFException) + catch (const PDFException&) { // Do nothing succesfull = false; diff --git a/Pdf4QtLib/sources/pdfdocumentreader.h b/Pdf4QtLib/sources/pdfdocumentreader.h index cee4b44..0b09abf 100644 --- a/Pdf4QtLib/sources/pdfdocumentreader.h +++ b/Pdf4QtLib/sources/pdfdocumentreader.h @@ -98,7 +98,7 @@ private: void checkFooter(const QByteArray& buffer); void checkHeader(const QByteArray& buffer); - const PDFInteger findXrefTableOffset(const QByteArray& buffer); + PDFInteger findXrefTableOffset(const QByteArray& buffer); Result processReferenceTableEntries(PDFXRefTable* xrefTable, const std::vector& occupiedEntries, PDFObjectStorage::PDFObjects& objects); Result processSecurityHandler(const PDFObject& trailerDictionaryObject, const std::vector& occupiedEntries, PDFObjectStorage::PDFObjects& objects); void processObjectStreams(PDFXRefTable* xrefTable, PDFObjectStorage::PDFObjects& objects); diff --git a/Pdf4QtLib/sources/pdfencoding.cpp b/Pdf4QtLib/sources/pdfencoding.cpp index 2df2f4b..ddb1f7f 100644 --- a/Pdf4QtLib/sources/pdfencoding.cpp +++ b/Pdf4QtLib/sources/pdfencoding.cpp @@ -2146,7 +2146,7 @@ QByteArray PDFEncoding::convertToEncoding(const QString& string, Encoding encodi ushort unicode = character.unicode(); unsigned char converted = 0; - for (int i = 0; i < table->size(); ++i) + for (size_t i = 0; i < table->size(); ++i) { if (unicode == (*table)[static_cast(i)]) { @@ -2353,6 +2353,9 @@ const encoding::EncodingTable* PDFEncoding::getTableForEncoding(Encoding encodin case Encoding::MacOsRoman: return &pdf::encoding::MAC_OS_ENCODING_CONVERSION_TABLE; + + default: + break; } // Unknown encoding? diff --git a/Pdf4QtLib/sources/pdffont.h b/Pdf4QtLib/sources/pdffont.h index 83fcec8..9c892b9 100644 --- a/Pdf4QtLib/sources/pdffont.h +++ b/Pdf4QtLib/sources/pdffont.h @@ -315,7 +315,7 @@ public: GlyphIndices glyphIndices); virtual ~PDFSimpleFont() override = default; - const PDFEncoding::Encoding getEncodingType() const { return m_encodingType; } + PDFEncoding::Encoding getEncodingType() const { return m_encodingType; } const encoding::EncodingTable* getEncoding() const { return &m_encoding; } const GlyphIndices* getGlyphIndices() const { return &m_glyphIndices; } diff --git a/Pdf4QtLib/sources/pdfform.cpp b/Pdf4QtLib/sources/pdfform.cpp index 2c20418..f7b7de7 100644 --- a/Pdf4QtLib/sources/pdfform.cpp +++ b/Pdf4QtLib/sources/pdfform.cpp @@ -404,7 +404,7 @@ private: PDFFormField::FieldFlags m_flags; Options m_options; - Qt::Alignment m_textAlignment = 0; + Qt::Alignment m_textAlignment = Qt::Alignment(); int m_topIndex = 0; int m_currentIndex = 0; std::set m_selection; @@ -828,7 +828,7 @@ PDFFormFieldPointer PDFFormField::parse(const PDFObjectStorage* storage, PDFObje { PDFInteger maxLengthDefault = 0; QByteArray defaultAppearance; - Qt::Alignment alignment = 0; + Qt::Alignment alignment = Qt::Alignment(); if (PDFFormFieldText* parentTextField = dynamic_cast(parentField)) { @@ -3776,7 +3776,7 @@ void PDFListBoxPseudowidget::draw(AnnotationDrawParameters& parameters, bool edi QColor highlightColor = getAdjustedColor(palette.color(QPalette::Highlight)); QRectF rect(0, 0, m_widgetRect.width(), m_lineSpacing); - for (int i = m_topIndex; i < m_options.size(); ++i) + for (int i = m_topIndex; i < int(m_options.size()); ++i) { if (m_selection.count(i)) { @@ -3912,7 +3912,7 @@ bool PDFListBoxPseudowidget::hasContinuousSelection() const return false; } - return *m_selection.rbegin() - *m_selection.begin() + 1 == m_selection.size(); + return *m_selection.rbegin() - *m_selection.begin() + 1 == int(m_selection.size()); } int PDFListBoxPseudowidget::getValidIndex(int index) const diff --git a/Pdf4QtLib/sources/pdfform.h b/Pdf4QtLib/sources/pdfform.h index 7e20cd9..0297edb 100644 --- a/Pdf4QtLib/sources/pdfform.h +++ b/Pdf4QtLib/sources/pdfform.h @@ -351,7 +351,7 @@ private: QByteArray m_defaultAppearance; /// Text field alignment - Qt::Alignment m_alignment = 0; + Qt::Alignment m_alignment = Qt::Alignment(); /// Default style QString m_defaultStyle; diff --git a/Pdf4QtLib/sources/pdffunction.cpp b/Pdf4QtLib/sources/pdffunction.cpp index 5e81bf4..b1a0557 100644 --- a/Pdf4QtLib/sources/pdffunction.cpp +++ b/Pdf4QtLib/sources/pdffunction.cpp @@ -1865,7 +1865,7 @@ PDFFunction::FunctionResult PDFPostScriptFunction::apply(const_iterator x_1, con return PDFTranslationContext::tr("Stack contains more values, than output size (%1 remains) (PostScript function).").arg(stack.size()); } } - catch (PDFPostScriptFunction::PDFPostScriptFunctionException exception) + catch (const PDFPostScriptFunction::PDFPostScriptFunctionException& exception) { return exception.getMessage(); } diff --git a/Pdf4QtLib/sources/pdfitemmodels.cpp b/Pdf4QtLib/sources/pdfitemmodels.cpp index 0aa9d03..fd0dcd7 100644 --- a/Pdf4QtLib/sources/pdfitemmodels.cpp +++ b/Pdf4QtLib/sources/pdfitemmodels.cpp @@ -368,8 +368,8 @@ QVariant PDFOutlineTreeItemModel::data(const QModelIndex& index, int role) const case Qt::DisplayRole: return outlineItem->getTitle(); - case Qt::TextColorRole: - return outlineItem->getTextColor(); + case Qt::ForegroundRole: + return QBrush(outlineItem->getTextColor()); case Qt::FontRole: { diff --git a/Pdf4QtLib/sources/pdfnametounicode.cpp b/Pdf4QtLib/sources/pdfnametounicode.cpp index f5004f4..a893bcc 100644 --- a/Pdf4QtLib/sources/pdfnametounicode.cpp +++ b/Pdf4QtLib/sources/pdfnametounicode.cpp @@ -22,7 +22,7 @@ namespace pdf { -static constexpr const std::array glyphNameToUnicode = { +static constexpr const std::array, 4285> glyphNameToUnicode = { std::pair{ QChar(0x0041), "A" }, // Character 'A' Letter, Uppercase std::pair{ QChar(0x00C6), "AE" }, // Character 'Æ' Letter, Uppercase std::pair{ QChar(0x01FC), "AEacute" }, // Character 'Ǽ' Letter, Uppercase diff --git a/Pdf4QtLib/sources/pdfpagecontentprocessor.cpp b/Pdf4QtLib/sources/pdfpagecontentprocessor.cpp index 75a3c06..d580df3 100644 --- a/Pdf4QtLib/sources/pdfpagecontentprocessor.cpp +++ b/Pdf4QtLib/sources/pdfpagecontentprocessor.cpp @@ -278,7 +278,7 @@ void PDFPageContentProcessor::initializeProcessor() m_deviceRGBColorSpace = PDFAbstractColorSpace::createDeviceColorSpaceByName(m_colorSpaceDictionary, m_document, COLOR_SPACE_NAME_DEVICE_RGB); m_deviceCMYKColorSpace = PDFAbstractColorSpace::createDeviceColorSpaceByName(m_colorSpaceDictionary, m_document, COLOR_SPACE_NAME_DEVICE_CMYK); } - catch (PDFException exception) + catch (const PDFException& exception) { m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage())); @@ -687,7 +687,7 @@ void PDFPageContentProcessor::processContent(const QByteArray& content) } } } - catch (PDFException exception) + catch (const PDFException& exception) { // If we get exception when parsing, and parser position is not advanced, // then we must advance it manually, otherwise we get infinite loop. @@ -715,7 +715,7 @@ void PDFPageContentProcessor::processContentStream(const PDFStream* stream) processContent(content); } - catch (PDFException exception) + catch (const PDFException& exception) { m_operands.clear(); m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage())); @@ -904,7 +904,8 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern(); if (!lineDashPattern.isSolid()) { - stroker.setDashPattern(QVector::fromStdVector(lineDashPattern.getDashArray())); + const auto& dashArray = lineDashPattern.getDashArray(); + stroker.setDashPattern(QVector(dashArray.begin(), dashArray.end())); stroker.setDashOffset(lineDashPattern.getDashOffset()); } QPainterPath strokedPath = stroker.createStroke(path); @@ -951,7 +952,8 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern(); if (!lineDashPattern.isSolid()) { - stroker.setDashPattern(QVector::fromStdVector(lineDashPattern.getDashArray())); + const auto& dashArray = lineDashPattern.getDashArray(); + stroker.setDashPattern(QVector(dashArray.begin(), dashArray.end())); stroker.setDashOffset(lineDashPattern.getDashOffset()); } QPainterPath strokedPath = stroker.createStroke(path); @@ -2698,7 +2700,7 @@ void PDFPageContentProcessor::operatorTextSetFontAndFontSize(PDFOperandName font m_graphicState.setTextFontSize(fontSize); updateGraphicState(); } - catch (PDFException) + catch (const PDFException&) { m_graphicState.setTextFont(nullptr); m_graphicState.setTextFontSize(fontSize); @@ -3977,7 +3979,7 @@ PDFPageContentProcessor::PDFSoftMaskDefinition PDFPageContentProcessor::PDFSoftM { result.m_transferFunction = PDFFunction::createFunction(processor->getDocument(), softMask->get("TR")); } - catch (PDFException) + catch (const PDFException&) { processor->reportRenderError(RenderErrorType::Error, PDFTranslationContext::tr("Invalid soft mask transfer function.")); } diff --git a/Pdf4QtLib/sources/pdfpainter.cpp b/Pdf4QtLib/sources/pdfpainter.cpp index 4766416..a871c2f 100644 --- a/Pdf4QtLib/sources/pdfpainter.cpp +++ b/Pdf4QtLib/sources/pdfpainter.cpp @@ -135,7 +135,9 @@ QPen PDFPainterBase::getCurrentPenImpl() const else { pen.setStyle(Qt::CustomDashLine); - pen.setDashPattern(QVector::fromStdVector(lineDashPattern.getDashArray())); + + const auto& dashArray = lineDashPattern.getDashArray(); + pen.setDashPattern(QVector(dashArray.begin(), dashArray.end())); pen.setDashOffset(lineDashPattern.getDashOffset()); } diff --git a/Pdf4QtLib/sources/pdfparser.cpp b/Pdf4QtLib/sources/pdfparser.cpp index 77ea9e2..02d0440 100644 --- a/Pdf4QtLib/sources/pdfparser.cpp +++ b/Pdf4QtLib/sources/pdfparser.cpp @@ -787,6 +787,7 @@ PDFObject PDFParser::getObject() shift(); return PDFObject::createArray(std::move(arraySharedPointer)); } + return PDFObject::createNull(); } case PDFLexicalAnalyzer::TokenType::DictionaryStart: { @@ -902,6 +903,7 @@ PDFObject PDFParser::getObject() shift(); return PDFObject::createDictionary(std::move(dictionarySharedPointer)); } + return PDFObject::createNull(); } case PDFLexicalAnalyzer::TokenType::Null: diff --git a/Pdf4QtLib/sources/pdfpattern.cpp b/Pdf4QtLib/sources/pdfpattern.cpp index 450d548..a0ef9a5 100644 --- a/Pdf4QtLib/sources/pdfpattern.cpp +++ b/Pdf4QtLib/sources/pdfpattern.cpp @@ -1484,7 +1484,7 @@ PDFMesh PDFRadialShading::createMesh(const PDFMeshQualitySettings& settings, con QLineF xAxisLine(p1m.x(), 0, p2m.x(), 0); QPointF intersectionPoint; - if (radiusInterpolationLine.intersect(xAxisLine, &intersectionPoint) != QLineF::NoIntersection) + if (radiusInterpolationLine.intersects(xAxisLine, &intersectionPoint) != QLineF::NoIntersection) { xl = qBound(meshingRectangle.left() - r1, intersectionPoint.x(), xl); } @@ -1509,7 +1509,7 @@ PDFMesh PDFRadialShading::createMesh(const PDFMeshQualitySettings& settings, con QLineF xAxisLine(p1m.x(), 0, p2m.x(), 0); QPointF intersectionPoint; - if (radiusInterpolationLine.intersect(xAxisLine, &intersectionPoint) != QLineF::NoIntersection) + if (radiusInterpolationLine.intersects(xAxisLine, &intersectionPoint) != QLineF::NoIntersection) { xr = qBound(xr, intersectionPoint.x(), meshingRectangle.right() + r2); } diff --git a/Pdf4QtLib/sources/pdfsignaturehandler.cpp b/Pdf4QtLib/sources/pdfsignaturehandler.cpp index b2c0f92..103f74e 100644 --- a/Pdf4QtLib/sources/pdfsignaturehandler.cpp +++ b/Pdf4QtLib/sources/pdfsignaturehandler.cpp @@ -2033,7 +2033,7 @@ void pdf::PDFPublicKeySignatureHandler::addTrustedCertificates(X509_STORE* store #ifdef Q_OS_WIN if (m_parameters.useSystemCertificateStore) { - HCERTSTORE certStore = CertOpenSystemStore(NULL, L"ROOT"); + HCERTSTORE certStore = CertOpenSystemStore(0, L"ROOT"); PCCERT_CONTEXT context = nullptr; if (certStore) { @@ -2059,7 +2059,7 @@ pdf::PDFCertificateStore::CertificateEntries pdf::PDFCertificateStore::getSystem CertificateEntries result; #ifdef Q_OS_WIN - HCERTSTORE certStore = CertOpenSystemStore(NULL, L"ROOT"); + HCERTSTORE certStore = CertOpenSystemStore(0, L"ROOT"); PCCERT_CONTEXT context = nullptr; if (certStore) { diff --git a/Pdf4QtLib/sources/pdfstreamfilters.cpp b/Pdf4QtLib/sources/pdfstreamfilters.cpp index 042f772..1aa4968 100644 --- a/Pdf4QtLib/sources/pdfstreamfilters.cpp +++ b/Pdf4QtLib/sources/pdfstreamfilters.cpp @@ -359,13 +359,6 @@ QByteArray PDFLzwDecodeFilter::apply(const QByteArray& data, { const PDFDictionary* dictionary = dereferencedParameters.getDictionary(); - PDFInteger predictor = 1; - const PDFObject& predictorObject = objectFetcher(dictionary->get("Predictor")); - if (predictorObject.isInt()) - { - predictor = predictorObject.getInteger(); - } - const PDFObject& earlyChangeObject = objectFetcher(dictionary->get("EarlyChange")); if (earlyChangeObject.isInt()) { @@ -385,19 +378,6 @@ QByteArray PDFFlateDecodeFilter::apply(const QByteArray& data, { Q_UNUSED(securityHandler); - const PDFObject& dereferencedParameters = objectFetcher(parameters); - if (dereferencedParameters.isDictionary()) - { - const PDFDictionary* dictionary = dereferencedParameters.getDictionary(); - - PDFInteger predictor = 1; - const PDFObject& predictorObject = objectFetcher(dictionary->get("Predictor")); - if (predictorObject.isInt()) - { - predictor = predictorObject.getInteger(); - } - } - PDFStreamPredictor predictor = PDFStreamPredictor::createPredictor(objectFetcher, parameters); return predictor.apply(uncompress(data)); } diff --git a/Pdf4QtLib/sources/pdftransparencyrenderer.cpp b/Pdf4QtLib/sources/pdftransparencyrenderer.cpp index 65515db..ad6c89c 100644 --- a/Pdf4QtLib/sources/pdftransparencyrenderer.cpp +++ b/Pdf4QtLib/sources/pdftransparencyrenderer.cpp @@ -3229,7 +3229,7 @@ void PDFInkMapper::createSpotColors(bool activate) { colorSpacePointer = PDFAbstractColorSpace::createColorSpace(colorSpaceDictionary, m_document, m_document->getObject(colorSpaceDictionary->getValue(csIndex))); } - catch (PDFException) + catch (const PDFException&) { // Ignore invalid color spaces continue; diff --git a/Pdf4QtLib/sources/pdfutils.h b/Pdf4QtLib/sources/pdfutils.h index f7e55a9..9aaf0fb 100644 --- a/Pdf4QtLib/sources/pdfutils.h +++ b/Pdf4QtLib/sources/pdfutils.h @@ -254,8 +254,14 @@ class PDFIntegerRange public: explicit inline constexpr PDFIntegerRange(T begin, T end) : m_begin(begin), m_end(end) { } - struct Iterator : public std::iterator + struct Iterator { + using iterator_category = std::random_access_iterator_tag; + using difference_type = ptrdiff_t; + using value_type = T; + using pointer = T*; + using reference = T&; + inline Iterator() : value(T(0)) { } inline Iterator(T value) : value(value) { } diff --git a/Pdf4QtLib/sources/pdfxfaengine.cpp b/Pdf4QtLib/sources/pdfxfaengine.cpp index c654ad6..ce93f5f 100644 --- a/Pdf4QtLib/sources/pdfxfaengine.cpp +++ b/Pdf4QtLib/sources/pdfxfaengine.cpp @@ -11466,7 +11466,7 @@ void PDFXFAEngineImpl::setDocument(const PDFModifiedDocument& document, PDFForm* m_template = xfa::XFA_template::parse(document.firstChildElement("template")); } } - catch (PDFException) + catch (const PDFException&) { // Just clear once again - if some errorneous data // were read, we want to clear them. diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookcreator.cpp b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookcreator.cpp index e27b2cd..3247ac9 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookcreator.cpp +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookcreator.cpp @@ -55,7 +55,7 @@ pdf::PDFOperationResult AudioBookCreator::createAudioBook(const Settings& settin QString trimmedText = item.text.trimmed(); if (!trimmedText.isEmpty()) { - textStream << trimmedText << endl; + textStream << trimmedText << Qt::endl; } } diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp index bbbbff6..ba02723 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp @@ -49,9 +49,9 @@ AudioBookPlugin::AudioBookPlugin() : m_actionMoveSelectionUp(nullptr), m_actionMoveSelectionDown(nullptr), m_actionCreateAudioBook(nullptr), + m_actionClear(nullptr), m_audioTextStreamDockWidget(nullptr), - m_audioTextStreamEditorModel(nullptr), - m_actionClear(nullptr) + m_audioTextStreamEditorModel(nullptr) { } diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/inkcoveragedialog.cpp b/Pdf4QtViewerPlugins/OutputPreviewPlugin/inkcoveragedialog.cpp index bb52eb6..a8e65f9 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/inkcoveragedialog.cpp +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/inkcoveragedialog.cpp @@ -308,6 +308,8 @@ QVariant InkCoverageStatisticsModel::data(const QModelIndex& index, int role) co Q_ASSERT(false); break; } + + break; } case Qt::BackgroundColorRole: diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewwidget.cpp b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewwidget.cpp index 4b6f8cc..2d82488 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewwidget.cpp +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewwidget.cpp @@ -355,7 +355,7 @@ void OutputPreviewWidget::paintEvent(QPaintEvent* event) QString textCoverage = QString("%1 %").arg(locale.toString(coverage * 100.0, 'f', 2)); const int textRight = triangleLeft - rowHeight / 4; - const int textWidth = painter.fontMetrics().width(textCoverage); + const int textWidth = painter.fontMetrics().horizontalAdvance(textCoverage); const int textStart = textRight - textWidth; QRect textRect(textStart, yCoordinate - halfHeight, textWidth + 1, rowHeight); diff --git a/PdfTool/pdftoolaudiobook.cpp b/PdfTool/pdftoolaudiobook.cpp index 01d5a17..b58f1d9 100644 --- a/PdfTool/pdftoolaudiobook.cpp +++ b/PdfTool/pdftoolaudiobook.cpp @@ -362,7 +362,7 @@ int PDFToolAudioBook::createAudioBook(const PDFToolOptions& options, pdf::PDFDoc { if (item.flags.testFlag(pdf::PDFDocumentTextFlow::PageStart) && options.textSpeechMarkPageNumbers) { - textStream << QString("").arg(item.text) << endl; + textStream << QString("").arg(item.text) << Qt::endl; } if (!item.text.isEmpty()) diff --git a/PdfTool/pdftoolfetchimages.cpp b/PdfTool/pdftoolfetchimages.cpp index 37f1747..3058434 100644 --- a/PdfTool/pdftoolfetchimages.cpp +++ b/PdfTool/pdftoolfetchimages.cpp @@ -215,7 +215,7 @@ int PDFToolFetchImages::execute(const PDFToolOptions& options) formatter.writeTableColumn("page-no", locale.toString(image.pageIndex + 1), Qt::AlignRight); formatter.writeTableColumn("width", locale.toString(image.image.width()), Qt::AlignRight); formatter.writeTableColumn("height", locale.toString(image.image.height()), Qt::AlignRight); - formatter.writeTableColumn("size", locale.toString(image.image.byteCount()), Qt::AlignRight); + formatter.writeTableColumn("size", locale.toString(image.image.sizeInBytes()), Qt::AlignRight); formatter.writeTableColumn("stored-to", image.fileName); formatter.endTableRow(); @@ -259,7 +259,7 @@ PDFToolAbstractApplication::Options PDFToolFetchImages::getOptionsFlags() const void PDFToolFetchImages::onImageExtracted(pdf::PDFInteger pageIndex, pdf::PDFInteger order, const QImage& image) { QCryptographicHash hasher(QCryptographicHash::Sha512); - hasher.addData(reinterpret_cast(image.bits()), image.byteCount()); + hasher.addData(reinterpret_cast(image.bits()), image.sizeInBytes()); QByteArray hash = hasher.result(); QMutexLocker lock(&m_mutex);