diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-06-11 13:21:32 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-06-11 13:31:01 +0300 |
commit | 3cd4e0aa7961889eb06374885ed648f5b9bd85bc (patch) | |
tree | 6a089aedea155b1f1a74b553f4d1b57c70554a8f /src/pdf | |
parent | 6d029165d1593c514db08c34d6b08a00a4435d5e (diff) | |
parent | 38063a6332b9f948a0381763271e9a9ac7af0999 (diff) |
Merge tag 'v6.2.9-lts' into tqtc/lts-6.2-opensource6.2.9
Qt 6.2.9-lts release
Conflicts solved:
dependencies.yaml
examples/webenginewidgets/push-notifications/CMakeLists.txt
Change-Id: I0127c2575369f6939df89f3301659470d481b9bf
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/CMakeLists.txt | 37 | ||||
-rw-r--r-- | src/pdf/configure.cmake | 3 | ||||
-rw-r--r-- | src/pdf/configure/BUILD.root.gn.in | 8 | ||||
-rw-r--r-- | src/pdf/doc/about_credits.tmpl | 1 | ||||
-rw-r--r-- | src/pdf/doc/about_credits_entry.tmpl | 13 | ||||
-rw-r--r-- | src/pdf/doc/images/pdfviewer.png | bin | 0 -> 264348 bytes | |||
-rw-r--r-- | src/pdf/doc/src/qtpdf-index.qdoc | 8 | ||||
-rw-r--r-- | src/pdf/doc/src/qtpdf-licensing.qdoc | 18 | ||||
-rw-r--r-- | src/pdf/plugins/imageformats/pdf/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/pdf/qpdfdocument.cpp | 17 | ||||
-rw-r--r-- | src/pdf/qpdfdocument_p.h | 25 | ||||
-rw-r--r-- | src/pdf/qpdflink.cpp | 11 | ||||
-rw-r--r-- | src/pdf/qpdflinkmodel.cpp | 6 | ||||
-rw-r--r-- | src/pdf/qpdfsearchmodel.cpp | 14 | ||||
-rw-r--r-- | src/pdf/qpdfsearchmodel.h | 1 | ||||
-rw-r--r-- | src/pdf/qpdfsearchmodel_p.h | 2 |
16 files changed, 140 insertions, 27 deletions
diff --git a/src/pdf/CMakeLists.txt b/src/pdf/CMakeLists.txt index ed2da1032..e79bbd85e 100644 --- a/src/pdf/CMakeLists.txt +++ b/src/pdf/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.19) find_package(Ninja 1.7.2 REQUIRED) find_package(Nodejs 12 REQUIRED) @@ -40,6 +43,10 @@ qt_internal_add_module(Pdf add_subdirectory(plugins/imageformats/pdf) +get_install_config(config) +get_architectures(archs) +list(GET archs 0 arch) + ## # PDF DOCS ## @@ -48,6 +55,16 @@ qt_internal_add_docs(Pdf doc/qtpdf.qdocconf ) +add_code_attributions_target( + TARGET generate_pdf_attributions + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pdf_attributions.qdoc + GN_TARGET :QtPdf + FILE_TEMPLATE doc/about_credits.tmpl + ENTRY_TEMPLATE doc/about_credits_entry.tmpl + BUILDDIR ${buildDir}/${config}/${arch} +) +add_dependencies(generate_pdf_attributions run_pdf_GnDone) +add_dependencies(docs generate_pdf_attributions) ## # TOOLCHAIN SETUP @@ -111,15 +128,21 @@ foreach(arch ${archs}) strip_absolute_paths_from_debug_symbols=false ) - if(LINUX) + if(LINUX OR ANDROID) list(APPEND gnArgArg is_cfi=false ozone_auto_platforms=false - use_gnome_keyring=false) + use_gnome_keyring=false + enable_vr=false + ) extend_gn_list(gnArgArg ARGS use_system_icu CONDITION QT_FEATURE_webengine_system_icu ) + extend_gn_list(gnArgArg + ARGS use_system_libopenjpeg2 + CONDITION QT_FEATURE_webengine_system_libopenjpeg2 + ) endif() if(MACOS) list(APPEND gnArgArg angle_enable_vulkan=false) @@ -166,6 +189,14 @@ foreach(arch ${archs}) CONDITION QT_FEATURE_pdf_xfa_tiff ) extend_gn_list(gnArgArg + ARGS pdfium_use_system_zlib + CONDITION QT_FEATURE_webengine_system_zlib + ) + extend_gn_list(gnArgArg + ARGS pdfium_use_system_libpng use_system_libpng + CONDITION QT_FEATURE_webengine_system_libpng + ) + extend_gn_list(gnArgArg ARGS pdfium_use_qt_libpng CONDITION QT_FEATURE_webengine_qt_libpng ) @@ -186,7 +217,7 @@ foreach(arch ${archs}) CMAKE_TARGET Pdf NINJA_TARGETS QtPdf GN_TARGET ${buildGn} - GN_ARGS "${gnArgArg}" + GN_ARGS ${gnArgArg} BUILDDIR ${buildDir}/${config}/${arch} MODULE pdf ) diff --git a/src/pdf/configure.cmake b/src/pdf/configure.cmake index 8d1a07183..ac4e4e25f 100644 --- a/src/pdf/configure.cmake +++ b/src/pdf/configure.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_feature("pdf-v8" PRIVATE LABEL "Support V8" PURPOSE "Enables javascript support." diff --git a/src/pdf/configure/BUILD.root.gn.in b/src/pdf/configure/BUILD.root.gn.in index 5420e8581..3918c1e9f 100644 --- a/src/pdf/configure/BUILD.root.gn.in +++ b/src/pdf/configure/BUILD.root.gn.in @@ -51,7 +51,7 @@ config("cpp17_config") { static_library("QtPdf") { complete_static_lib = true - rsp_types = [ "objects", "archives", "libs" ] + rsp_types = [ "objects", "archives", "libs", "lflags" ] configs += [ ":cpp17_config", ":QtPdf_config" @@ -59,4 +59,10 @@ static_library("QtPdf") { deps = [ "//third_party/pdfium" ] + if (is_win) { + libs = [ + "dloadhelper.lib", + "winmm.lib", + ] + } } diff --git a/src/pdf/doc/about_credits.tmpl b/src/pdf/doc/about_credits.tmpl new file mode 100644 index 000000000..57fae9e78 --- /dev/null +++ b/src/pdf/doc/about_credits.tmpl @@ -0,0 +1 @@ +{{entries}} diff --git a/src/pdf/doc/about_credits_entry.tmpl b/src/pdf/doc/about_credits_entry.tmpl new file mode 100644 index 000000000..294198709 --- /dev/null +++ b/src/pdf/doc/about_credits_entry.tmpl @@ -0,0 +1,13 @@ +/*! +\page qtpdf-3rdparty-{{name-sanitized}}.html +\attribution +\ingroup qtpdf-licensing +\brief {{license-type}} +\title {{name}} + +\l{{{url}}}{Project Homepage} + +\badcode +{{license}} +\endcode +*/ diff --git a/src/pdf/doc/images/pdfviewer.png b/src/pdf/doc/images/pdfviewer.png Binary files differnew file mode 100644 index 000000000..ac8a31ac0 --- /dev/null +++ b/src/pdf/doc/images/pdfviewer.png diff --git a/src/pdf/doc/src/qtpdf-index.qdoc b/src/pdf/doc/src/qtpdf-index.qdoc index 07c151f47..fb44eb5fa 100644 --- a/src/pdf/doc/src/qtpdf-index.qdoc +++ b/src/pdf/doc/src/qtpdf-index.qdoc @@ -64,4 +64,12 @@ \li \l{Qt PDF C++ Classes} \li \l{Qt Quick PDF QML Types} \endlist + + \section1 Licenses and Attributions + + Qt PDF is available under commercial licenses from \l{The Qt Company}. + In addition, it is available under the + \l{GNU Lesser General Public License, version 3}, or + the \l{GNU General Public License, version 2}. + See \l{Qt PDF Licensing} for further details about this module. */ diff --git a/src/pdf/doc/src/qtpdf-licensing.qdoc b/src/pdf/doc/src/qtpdf-licensing.qdoc new file mode 100644 index 000000000..190ee8331 --- /dev/null +++ b/src/pdf/doc/src/qtpdf-licensing.qdoc @@ -0,0 +1,18 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \group qtpdf-licensing + \title Qt PDF Licensing + + Qt PDF is available under commercial licenses from \l{The Qt Company}. + In addition, it is available under the + \l{GNU Lesser General Public License, version 3}, or + the \l{GNU General Public License, version 2}. + See \l{Qt Licensing} for further details. + + The module includes a snapshot of PDFium. As such, users need to respect + the licenses of PDFium and third-party code included in it. + + Third party licenses included in the sources are: +*/ diff --git a/src/pdf/plugins/imageformats/pdf/CMakeLists.txt b/src/pdf/plugins/imageformats/pdf/CMakeLists.txt index 517d152c7..73a0b3144 100644 --- a/src/pdf/plugins/imageformats/pdf/CMakeLists.txt +++ b/src/pdf/plugins/imageformats/pdf/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_internal_add_plugin(QPdfPlugin OUTPUT_NAME qpdf PLUGIN_TYPE imageformats diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp index a3e412c5c..268389f4a 100644 --- a/src/pdf/qpdfdocument.cpp +++ b/src/pdf/qpdfdocument.cpp @@ -824,22 +824,6 @@ QImage QPdfDocument::render(int page, QSize imageSize, QPdfDocumentRenderOptions result.fill(Qt::transparent); FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(result.width(), result.height(), FPDFBitmap_BGRA, result.bits(), result.bytesPerLine()); - int rotation = 0; - switch (renderOptions.rotation()) { - case QPdfDocumentRenderOptions::Rotation::None: - rotation = 0; - break; - case QPdfDocumentRenderOptions::Rotation::Clockwise90: - rotation = 1; - break; - case QPdfDocumentRenderOptions::Rotation::Clockwise180: - rotation = 2; - break; - case QPdfDocumentRenderOptions::Rotation::Clockwise270: - rotation = 3; - break; - } - const QPdfDocumentRenderOptions::RenderFlags renderFlags = renderOptions.renderFlags(); int flags = 0; if (renderFlags & QPdfDocumentRenderOptions::RenderFlag::Annotations) @@ -885,6 +869,7 @@ QImage QPdfDocument::render(int page, QSize imageSize, QPdfDocumentRenderOptions qCDebug(qLcDoc) << "page" << page << "region" << renderOptions.scaledClipRect() << "size" << imageSize << "took" << timer.elapsed() << "ms"; } else { + const auto rotation = QPdfDocumentPrivate::toFPDFRotation(renderOptions.rotation()); FPDF_RenderPageBitmap(bitmap, pdfPage, 0, 0, result.width(), result.height(), rotation, flags); qCDebug(qLcDoc) << "page" << page << "size" << imageSize << "took" << timer.elapsed() << "ms"; } diff --git a/src/pdf/qpdfdocument_p.h b/src/pdf/qpdfdocument_p.h index 973dc1d4a..d52aabe4b 100644 --- a/src/pdf/qpdfdocument_p.h +++ b/src/pdf/qpdfdocument_p.h @@ -81,6 +81,31 @@ public: QPointF getCharPosition(FPDF_TEXTPAGE textPage, double pageHeight, int charIndex); QRectF getCharBox(FPDF_TEXTPAGE textPage, double pageHeight, int charIndex); + // FPDF takes the rotation parameter as an int. + // This enum is mapping the int values defined in fpdfview.h:956. + // (not using enum class to ensure int convertability) + enum QFPDFRotation { + Normal = 0, + ClockWise90 = 1, + ClockWise180 = 2, + CounterClockWise90 = 3 + }; + + static constexpr QFPDFRotation toFPDFRotation(QPdfDocumentRenderOptions::Rotation rotation) + { + switch (rotation) { + case QPdfDocumentRenderOptions::Rotation::None: + return QFPDFRotation::Normal; + case QPdfDocumentRenderOptions::Rotation::Clockwise90: + return QFPDFRotation::ClockWise90; + case QPdfDocumentRenderOptions::Rotation::Clockwise180: + return QFPDFRotation::ClockWise180; + case QPdfDocumentRenderOptions::Rotation::Clockwise270: + return QFPDFRotation::CounterClockWise90; + } + Q_UNREACHABLE(); + } + struct TextPosition { QPointF position; qreal height = 0; diff --git a/src/pdf/qpdflink.cpp b/src/pdf/qpdflink.cpp index d1f5bdfdc..0c2867086 100644 --- a/src/pdf/qpdflink.cpp +++ b/src/pdf/qpdflink.cpp @@ -152,12 +152,11 @@ QList<QRectF> QPdfLink::rectangles() const */ QString QPdfLink::toString() const { - static const QString format = QPdfLinkModel::tr("page %1 location %2,%3 zoom %4"); - return d->page > 0 ? format.arg(QString::number(d->page), - QString::number(d->location.x()), - QString::number(d->location.y()), - QString::number(d->zoom)) - : d->url.toString(); + if (d->page <= 0) + return d->url.toString(); + return QPdfLinkModel::tr("Page %1 location %2, %3 zoom %4") + .arg(d->page).arg(d->location.x(), 0, 'f', 1).arg(d->location.y(), 0, 'f', 1) + .arg(d->zoom, 0, 'f', 0); } /*! diff --git a/src/pdf/qpdflinkmodel.cpp b/src/pdf/qpdflinkmodel.cpp index a8e98926a..c98a8723e 100644 --- a/src/pdf/qpdflinkmodel.cpp +++ b/src/pdf/qpdflinkmodel.cpp @@ -180,6 +180,12 @@ void QPdfLinkModelPrivate::update() qCWarning(qLcLink) << "skipping link with invalid bounding box"; continue; // while enumerating links } + // In case horizontal/vertical coordinates are flipped, swap them. + if (rect.right < rect.left) + std::swap(rect.right, rect.left); + if (rect.bottom > rect.top) + std::swap(rect.bottom, rect.top); + QPdfLink linkData; linkData.d->rects << QRectF(rect.left, pageHeight - rect.top, rect.right - rect.left, rect.top - rect.bottom); diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp index a8946ccfe..3109430f0 100644 --- a/src/pdf/qpdfsearchmodel.cpp +++ b/src/pdf/qpdfsearchmodel.cpp @@ -20,7 +20,6 @@ Q_LOGGING_CATEGORY(qLcS, "qt.pdf.search") static const int UpdateTimerInterval = 100; static const int ContextChars = 64; -static const double CharacterHitTolerance = 6.0; /*! \class QPdfSearchModel @@ -195,11 +194,23 @@ void QPdfSearchModel::setDocument(QPdfDocument *document) if (d->document == document) return; + disconnect(d->documentConnection); + d->documentConnection = connect(document, &QPdfDocument::pageCountChanged, this, + &QPdfSearchModel::onDocumentPageCountChanged); + d->document = document; d->clearResults(); emit documentChanged(); } +void QPdfSearchModel::onDocumentPageCountChanged(int count) +{ + Q_UNUSED(count); + + Q_D(QPdfSearchModel); + d->clearResults(); +} + void QPdfSearchModel::timerEvent(QTimerEvent *event) { Q_D(QPdfSearchModel); @@ -257,6 +268,7 @@ bool QPdfSearchModelPrivate::doSearch(int page) } FPDF_SCHHANDLE sh = FPDFText_FindStart(textPage, searchString.utf16(), 0, 0); QList<QPdfLink> newSearchResults; + constexpr double CharacterHitTolerance = 6.0; while (FPDFText_FindNext(sh)) { int idx = FPDFText_GetSchResultIndex(sh); int count = FPDFText_GetSchCount(sh); diff --git a/src/pdf/qpdfsearchmodel.h b/src/pdf/qpdfsearchmodel.h index c1e4e64ec..b1094b67b 100644 --- a/src/pdf/qpdfsearchmodel.h +++ b/src/pdf/qpdfsearchmodel.h @@ -55,6 +55,7 @@ Q_SIGNALS: protected: void updatePage(int page); void timerEvent(QTimerEvent *event) override; + void onDocumentPageCountChanged(int count); private: QHash<int, QByteArray> m_roleNames; diff --git a/src/pdf/qpdfsearchmodel_p.h b/src/pdf/qpdfsearchmodel_p.h index 4922c81e9..5ffa08f5d 100644 --- a/src/pdf/qpdfsearchmodel_p.h +++ b/src/pdf/qpdfsearchmodel_p.h @@ -45,6 +45,8 @@ public: int rowCountSoFar = 0; int updateTimerId = -1; int nextPageToUpdate = 0; + + QMetaObject::Connection documentConnection; }; QT_END_NAMESPACE |