[poppler] qt5/src qt6/src
qt5/src/poppler-page.cc |1 + qt6/src/poppler-page.cc |1 + 2 files changed, 2 insertions(+) New commits: commit d1e86894cbb617c64b84fe18cae7294b1cb45eed Author: Albert Astals Cid Date: Thu Jun 29 00:35:56 2023 +0200 Update (C) diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 43c7d9fd..853ee3b9 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -27,6 +27,7 @@ * Copyright (C) 2020 Philipp Knechtges * Copyright (C) 2021 Hubert Figuiere * Copyright (C) 2021 Thomas Huxhorn + * Copyright (C) 2023 Kevin Ottens . Work sponsored by De Bortoli Wines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt6/src/poppler-page.cc b/qt6/src/poppler-page.cc index 40062e81..ce4d18d9 100644 --- a/qt6/src/poppler-page.cc +++ b/qt6/src/poppler-page.cc @@ -26,6 +26,7 @@ * Copyright (C) 2020 Philipp Knechtges * Copyright (C) 2021 Hubert Figuiere * Copyright (C) 2021 Thomas Huxhorn + * Copyright (C) 2023 Kevin Ottens . Work sponsored by De Bortoli Wines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
[poppler] qt5/src qt5/tests qt6/src qt6/tests
qt5/src/poppler-page.cc |8 qt5/tests/CMakeLists.txt |1 + qt5/tests/check_overprint.cpp | 41 + qt6/src/poppler-page.cc |8 qt6/tests/CMakeLists.txt |1 + qt6/tests/check_overprint.cpp | 38 ++ 6 files changed, 89 insertions(+), 8 deletions(-) New commits: commit 6ebe45e8dceae11d02c74df47c34f4490a45a15e Author: Kevin Ottens Date: Wed Jun 21 15:10:48 2023 +0200 Don't crash when overprint preview is enabled with the Qt bindings When overprint preview is enabled, the image data row size changes during conversion to XBGR. The Qt bindings were assuming this row size was constant which led to badly broken QImages at conversion time (generating garbage if displayed or even crashing). This commit simply add regression tests for the case and gets the row size after bitmap conversion. diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index b2cea93b..43c7d9fd 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -129,10 +129,6 @@ public: { SplashBitmap *b = getBitmap(); -const int bw = b->getWidth(); -const int bh = b->getHeight(); -const int brs = b->getRowSize(); - // If we use DeviceN8, convert to XBGR8. // If requested, also transfer Splash's internal alpha channel. const SplashBitmap::ConversionMode mode = ignorePaperColor ? SplashBitmap::conversionAlphaPremultiplied : SplashBitmap::conversionOpaque; @@ -140,6 +136,10 @@ public: const QImage::Format format = ignorePaperColor ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; if (b->convertToXBGR(mode)) { +const int bw = b->getWidth(); +const int bh = b->getHeight(); +const int brs = b->getRowSize(); + SplashColorPtr data = takeImageData ? b->takeData() : b->getDataPtr(); if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { diff --git a/qt5/tests/CMakeLists.txt b/qt5/tests/CMakeLists.txt index 9de870ee..e610413a 100644 --- a/qt5/tests/CMakeLists.txt +++ b/qt5/tests/CMakeLists.txt @@ -74,6 +74,7 @@ qt5_add_qtest(check_qt5_signature_basics check_signature_basics.cpp) qt5_add_qtest(check_qt5_utf8document check_utf8document.cpp) qt5_add_qtest(check_qt5_distinguished_name_parser check_distinguished_name_parser.cpp) qt5_add_qtest(check_qt5_cidfontswidthsbuilder check_cidfontswidthsbuilder.cpp) +qt5_add_qtest(check_qt5_overprint check_overprint.cpp) if (NOT WIN32) qt5_add_qtest(check_qt5_pagelabelinfo check_pagelabelinfo.cpp) qt5_add_qtest(check_qt5_strings check_strings.cpp) diff --git a/qt5/tests/check_overprint.cpp b/qt5/tests/check_overprint.cpp new file mode 100644 index ..3035c652 --- /dev/null +++ b/qt5/tests/check_overprint.cpp @@ -0,0 +1,41 @@ +#include + +#include + +#include + +class TestOverprint : public QObject +{ +Q_OBJECT +public: +explicit TestOverprint(QObject *parent = nullptr) : QObject(parent) { } +private slots: +void checkOverprintImageRendering(); +}; + +void TestOverprint::checkOverprintImageRendering() +{ +Poppler::Document *doc = Poppler::Document::load(TESTDATADIR "/tests/mask-seams.pdf"); +QVERIFY(doc); + +doc->setRenderHint(Poppler::Document::OverprintPreview, true); + +Poppler::Page *page = doc->page(0); +QVERIFY(page); + +constexpr int width = 600; +constexpr int height = 400; + +QImage img = page->renderToImage(300.0, 300.0, 0, 0, width, height); +QCOMPARE(img.format(), QImage::Format_RGB32); +QCOMPARE(img.width(), width); +QCOMPARE(img.height(), height); +QCOMPARE(img.bytesPerLine(), width * 4); +QCOMPARE(img.sizeInBytes(), width * height * 4); + +delete page; +delete doc; +} + +QTEST_GUILESS_MAIN(TestOverprint) +#include "check_overprint.moc" diff --git a/qt6/src/poppler-page.cc b/qt6/src/poppler-page.cc index dd1cb0e5..40062e81 100644 --- a/qt6/src/poppler-page.cc +++ b/qt6/src/poppler-page.cc @@ -128,10 +128,6 @@ public: { SplashBitmap *b = getBitmap(); -const int bw = b->getWidth(); -const int bh = b->getHeight(); -const int brs = b->getRowSize(); - // If we use DeviceN8, convert to XBGR8. // If requested, also transfer Splash's internal alpha channel. const SplashBitmap::ConversionMode mode = ignorePaperColor ? SplashBitmap::conversionAlphaPremultiplied : SplashBitmap::conversionOpaque; @@ -139,6 +135,10 @@ public: const QImage::Format format = ignorePaperColor ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; if (b->convertToXBGR(mode)) { +const int bw = b->getWidth(); +const int bh = b->getHeight(); +const int brs = b->getRowSize(); + SplashColorPtr data = takeImageData ? b->takeData() : b->getDataPtr(); if
[poppler] qt5/src qt6/src
qt5/src/poppler-form.h |1 + qt6/src/poppler-form.h |1 + 2 files changed, 2 insertions(+) New commits: commit 82fc01784dcfc3e22ee0053e4ecfa9b500119b19 Author: Albert Astals Cid Date: Thu May 25 12:25:57 2023 +0200 Update (C) diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index 55b07093..ae572ea3 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -13,6 +13,7 @@ * Copyright (C) 2020, Thorsten Behrens * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden * Copyright (C) 2021, Theofilos Intzoglou + * Copyright (C) 2023, g10 Code GmbH, Author: Sune Stolborg Vuorela * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt6/src/poppler-form.h b/qt6/src/poppler-form.h index b64a6e02..3de8b72c 100644 --- a/qt6/src/poppler-form.h +++ b/qt6/src/poppler-form.h @@ -13,6 +13,7 @@ * Copyright (C) 2020, Thorsten Behrens * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden * Copyright (C) 2021, Theofilos Intzoglou + * Copyright (C) 2023, g10 Code GmbH, Author: Sune Stolborg Vuorela * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
[poppler] qt5/src qt6/src
qt5/src/poppler-form.cc | 88 +++ qt5/src/poppler-form.h | 55 + qt6/src/poppler-form.cc | 89 qt6/src/poppler-form.h | 54 - 4 files changed, 284 insertions(+), 2 deletions(-) New commits: commit 83630a0ecf3db671c820b80f584e45ab9927c3fe Author: Sune Vuorela Date: Wed May 24 23:04:24 2023 + Qt frontend code for selecting cryptosign backend diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 05852bb4..770afd57 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -1147,6 +1147,94 @@ QVector getAvailableSigningCertificates() return vReturnCerts; } +static std::optional convertToFrontend(std::optional type) +{ +if (!type) { +return std::nullopt; +} +switch (type.value()) { +case CryptoSign::Backend::Type::NSS3: +return CryptoSignBackend::NSS; +case CryptoSign::Backend::Type::GPGME: +return CryptoSignBackend::GPG; +} +return std::nullopt; +} + +static std::optional convertToBackend(std::optional backend) +{ +if (!backend) { +return std::nullopt; +} +switch (backend.value()) { +case CryptoSignBackend::NSS: +return CryptoSign::Backend::Type::NSS3; +case CryptoSignBackend::GPG: +return CryptoSign::Backend::Type::GPGME; +} +return std::nullopt; +} + +QVector availableCryptoSignBackends() +{ +QVector backends; +for (auto &backend : CryptoSign::Factory::getAvailable()) { +auto converted = convertToFrontend(backend); +if (converted) { +backends.push_back(converted.value()); +} +} +return backends; +} + +std::optional activeCryptoSignBackend() +{ +return convertToFrontend(CryptoSign::Factory::getActive()); +} + +bool setActiveCryptoSignBackend(CryptoSignBackend backend) +{ +auto available = availableCryptoSignBackends(); +if (!available.contains(backend)) { +return false; +} +auto converted = convertToBackend(backend); +if (!converted) { +return false; +} +CryptoSign::Factory::setPreferredBackend(converted.value()); +return activeCryptoSignBackend() == backend; +} + +static bool hasNSSBackendFeature(CryptoSignBackendFeature feature) +{ +switch (feature) { +case CryptoSignBackendFeature::BackendAsksPassphrase: +return false; +} +return false; +} + +static bool hasGPGBackendFeature(CryptoSignBackendFeature feature) +{ +switch (feature) { +case CryptoSignBackendFeature::BackendAsksPassphrase: +return true; +} +return false; +} + +bool hasCryptoSignBackendFeature(CryptoSignBackend backend, CryptoSignBackendFeature feature) +{ +switch (backend) { +case CryptoSignBackend::NSS: +return hasNSSBackendFeature(feature); +case CryptoSignBackend::GPG: +return hasGPGBackendFeature(feature); +} +return false; +} + QString POPPLER_QT5_EXPORT getNSSDir() { #ifdef ENABLE_NSS3 diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index 0e64f2ee..55b07093 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -846,12 +847,64 @@ private: Q_DISABLE_COPY(FormFieldSignature) }; +/** + * Possible compiled in backends for signature handling + * + * \since 23.06 + */ +enum class CryptoSignBackend +{ +NSS, +GPG +}; + +/** + * The available compiled-in backends + * + * \since 23.06 + */ +QVector POPPLER_QT5_EXPORT availableCryptoSignBackends(); + +/** + * Returns current active backend or nullopt if none is active + * + * \note there will always be an active backend if there is available backends + * + * \since 23.06 + */ +std::optional POPPLER_QT5_EXPORT activeCryptoSignBackend(); + +/** + * Sets active backend + * + * \return true on success + * + * \since 23.06 + */ +bool POPPLER_QT5_EXPORT setActiveCryptoSignBackend(CryptoSignBackend backend); + +enum class CryptoSignBackendFeature +{ +/// If the backend itself out of band requests passwords +/// or if the host applicaion somehow must do it +BackendAsksPassphrase +}; + +/** + * Queries if a backend supports or not supports a given feature. + * + * \since 23.06 + */ +bool POPPLER_QT5_EXPORT hasCryptoSignBackendFeature(CryptoSignBackend, CryptoSignBackendFeature); + /** Returns is poppler was compiled with NSS support + \deprecated Use availableBackends instead + \since 21.01 */ -bool POPPLER_QT5_EXPORT hasNSSSupport(); +bool POPPLER_QT5_DEPRECATED POPPLER_QT5_EXPORT hasNSSSupport(); /** Return vector of suitable signing certificates diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc index 83dc79d7..01655a81 100644 --- a/qt6/src/poppler-form.cc +++ b/qt6/src/poppler-form.cc @@ -1147,6 +1147,95 @@ QVector getAvailableSig
[poppler] qt5/src qt6/src
qt5/src/poppler-embeddedfile.cc |1 + qt6/src/poppler-embeddedfile.cc |1 + 2 files changed, 2 insertions(+) New commits: commit 6fd2c2e6f50b6b8f47c554c8e7e3076cd81a7554 Author: Albert Astals Cid Date: Fri May 12 16:22:24 2023 +0200 Update (C) diff --git a/qt5/src/poppler-embeddedfile.cc b/qt5/src/poppler-embeddedfile.cc index 9fe62c77..ed105f75 100644 --- a/qt5/src/poppler-embeddedfile.cc +++ b/qt5/src/poppler-embeddedfile.cc @@ -3,6 +3,7 @@ * Copyright (C) 2005, Brad Hards * Copyright (C) 2008, 2011, Pino Toscano * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich + * Copyright (C) 2023 g10 Code GmbH, Author: Sune Stolborg Vuorela * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt6/src/poppler-embeddedfile.cc b/qt6/src/poppler-embeddedfile.cc index 42bfc6a4..2fa3dc39 100644 --- a/qt6/src/poppler-embeddedfile.cc +++ b/qt6/src/poppler-embeddedfile.cc @@ -3,6 +3,7 @@ * Copyright (C) 2005, Brad Hards * Copyright (C) 2008, 2011, Pino Toscano * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich + * Copyright (C) 2023 g10 Code GmbH, Author: Sune Stolborg Vuorela * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
[poppler] qt5/src qt6/src
qt5/src/poppler-embeddedfile.cc | 11 ++- qt6/src/poppler-embeddedfile.cc | 14 ++ 2 files changed, 4 insertions(+), 21 deletions(-) New commits: commit aefd09f9eb69b91ae2cae0351280aaa66742dd84 Author: Sune Vuorela Date: Thu May 11 16:43:41 2023 +0200 Convert embedded files to bytearray a bit smarter The current behavior also triggers a runtime warning per byte: "Using QByteRef with an index pointing outside the valid range of a QByteArray. The corresponding behavior is deprecated, and will be changed in a future version of Qt." This will keep an extra copy of the data around during convertion, but that's probably okay. diff --git a/qt5/src/poppler-embeddedfile.cc b/qt5/src/poppler-embeddedfile.cc index bab8d73f..9fe62c77 100644 --- a/qt5/src/poppler-embeddedfile.cc +++ b/qt5/src/poppler-embeddedfile.cc @@ -104,15 +104,8 @@ QByteArray EmbeddedFile::data() } stream->reset(); -int dataLen = 0; -QByteArray fileArray; -int i; -while ((i = stream->getChar()) != EOF) { -fileArray[dataLen] = (char)i; -++dataLen; -} -fileArray.resize(dataLen); -return fileArray; +auto data = stream->toUnsignedChars(); +return QByteArray(reinterpret_cast(data.data()), data.size()); } bool EmbeddedFile::isValid() const diff --git a/qt6/src/poppler-embeddedfile.cc b/qt6/src/poppler-embeddedfile.cc index 1b8a7a1c..42bfc6a4 100644 --- a/qt6/src/poppler-embeddedfile.cc +++ b/qt6/src/poppler-embeddedfile.cc @@ -104,18 +104,8 @@ QByteArray EmbeddedFile::data() } stream->reset(); -int dataLen = 0; -QByteArray fileArray; -int i; -while ((i = stream->getChar()) != EOF) { -if (dataLen >= fileArray.size()) { -fileArray.resize(dataLen + 32768); -} -fileArray[dataLen] = (char)i; -++dataLen; -} -fileArray.resize(dataLen); -return fileArray; +auto data = stream->toUnsignedChars(); +return QByteArray(reinterpret_cast(data.data()), data.size()); } bool EmbeddedFile::isValid() const
[poppler] qt5/src qt6/src utils/pdfsig.cc
qt5/src/poppler-form.cc |4 ++-- qt6/src/poppler-form.cc |2 +- utils/pdfsig.cc |3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) New commits: commit 2b53d5a8ccb7350c00ef135ab40ca3562099265c Author: Sune Vuorela Date: Mon Mar 20 11:48:42 2023 +0100 Fixup for 8787103a43 Some codepaths was overlooked; might lead to crashes in pdfsig. Also clean up the Qt checkpassword functions; they aren't crashers though. diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index b56e73d0..1bead08b 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -781,11 +781,11 @@ bool CertificateInfo::checkPassword(const QString &password) const { #ifdef ENABLE_NSS3 Q_D(const CertificateInfo); -SignatureHandler sigHandler(d->nick_name.toUtf8().constData(), HashAlgorithm::Sha256); +SignatureHandler sigHandler(d->nick_name.toStdString(), HashAlgorithm::Sha256); unsigned char buffer[5]; memcpy(buffer, "test", 5); sigHandler.updateHash(buffer, 5); -std::unique_ptr tmpSignature = sigHandler.signDetached(password.toUtf8().constData()); +std::unique_ptr tmpSignature = sigHandler.signDetached(password.toStdString()); return tmpSignature.get() != nullptr; #else return false; diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc index 05d183cb..ac138261 100644 --- a/qt6/src/poppler-form.cc +++ b/qt6/src/poppler-form.cc @@ -785,7 +785,7 @@ bool CertificateInfo::checkPassword(const QString &password) const unsigned char buffer[5]; memcpy(buffer, "test", 5); sigHandler.updateHash(buffer, 5); -std::unique_ptr tmpSignature = sigHandler.signDetached(password.toUtf8().constData()); +std::unique_ptr tmpSignature = sigHandler.signDetached(password.toStdString()); return tmpSignature.get() != nullptr; #else return false; diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc index c090f1dc..c494de3c 100644 --- a/utils/pdfsig.cc +++ b/utils/pdfsig.cc @@ -439,14 +439,13 @@ int main(int argc, char *argv[]) if (etsiCAdESdetached) { ffs->setSignatureType(ETSI_CAdES_detached); } -const char *pw = (strlen(password) == 0) ? nullptr : password; const auto rs = std::unique_ptr(reason.toStr().empty() ? nullptr : utf8ToUtf16WithBom(reason.toStr())); if (ffs->getNumWidgets() != 1) { printf("Unexpected number of widgets for the signature: %d\n", ffs->getNumWidgets()); return 2; } FormWidgetSignature *fws = static_cast(ffs->getWidget(0)); -const bool success = fws->signDocument(argv[2], certNickname, pw, rs.get()); +const bool success = fws->signDocument(std::string { argv[2] }, std::string { certNickname }, std::string { password }, rs.get()); return success ? 0 : 3; }
[poppler] qt5/src qt6/src utils/CMakeLists.txt
qt5/src/CMakeLists.txt |1 + qt6/src/CMakeLists.txt |1 + utils/CMakeLists.txt |3 +++ 3 files changed, 5 insertions(+) New commits: commit 821784a6f08adfbb5211d665389acc275e035e84 Author: Albert Astals Cid Date: Sun Dec 4 03:02:30 2022 +0100 cmake: Add missing LCMS2_INCLUDE_DIR diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt index 638505e6..5db3a6c5 100644 --- a/qt5/src/CMakeLists.txt +++ b/qt5/src/CMakeLists.txt @@ -49,6 +49,7 @@ if (ENABLE_NSS3) endif() if(USE_CMS) target_link_libraries(poppler-qt5 poppler ${LCMS2_LIBRARIES}) +target_include_directories(poppler-qt5 SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) endif() install(TARGETS poppler-qt5 RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/qt6/src/CMakeLists.txt b/qt6/src/CMakeLists.txt index 7104924f..cd919753 100644 --- a/qt6/src/CMakeLists.txt +++ b/qt6/src/CMakeLists.txt @@ -49,6 +49,7 @@ if (ENABLE_NSS3) endif() if(USE_CMS) target_link_libraries(poppler-qt6 poppler ${LCMS2_LIBRARIES}) +target_include_directories(poppler-qt6 SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) endif() install(TARGETS poppler-qt6 RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 747fb1e5..34696e93 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -16,6 +16,7 @@ add_executable(pdftoppm ${pdftoppm_SOURCES}) target_link_libraries(pdftoppm ${common_libs}) if(LCMS2_FOUND) target_link_libraries(pdftoppm ${LCMS2_LIBRARIES}) + target_include_directories(pdftoppm SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) endif() install(TARGETS pdftoppm DESTINATION bin) install(FILES pdftoppm.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) @@ -40,6 +41,7 @@ if (HAVE_CAIRO) target_link_libraries(pdftocairo ${CAIRO_LIBRARIES} Freetype::Freetype ${common_libs}) if(LCMS2_FOUND) target_link_libraries(pdftocairo ${LCMS2_LIBRARIES}) +target_include_directories(pdftocairo SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) endif() install(TARGETS pdftocairo DESTINATION bin) install(FILES pdftocairo.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) @@ -113,6 +115,7 @@ add_executable(pdftops ${pdftops_SOURCES}) target_link_libraries(pdftops ${common_libs}) if(LCMS2_FOUND) target_link_libraries(pdftops ${LCMS2_LIBRARIES}) + target_include_directories(pdftops SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) endif() install(TARGETS pdftops DESTINATION bin) install(FILES pdftops.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
[poppler] qt5/src qt6/src
qt5/src/poppler-form.cc | 10 +- qt6/src/poppler-form.cc | 10 +- 2 files changed, 18 insertions(+), 2 deletions(-) New commits: commit d06eb33d1668ca3a08055bd033d8f5ea725e5be7 Author: Albert Astals Cid Date: Fri Aug 12 23:29:01 2022 +0200 qt: Also take into account flagNoView when getting/setting the visible status KDE bug #456313 diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index a6d40910..a4111511 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -194,7 +194,14 @@ void FormField::setReadOnly(bool value) bool FormField::isVisible() const { -return !(m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagHidden); +const unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags(); +if (flags & Annot::flagHidden) { +return false; +} +if (flags & Annot::flagNoView) { +return false; +} +return true; } void FormField::setVisible(bool value) @@ -202,6 +209,7 @@ void FormField::setVisible(bool value) unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags(); if (value) { flags &= ~Annot::flagHidden; +flags &= ~Annot::flagNoView; } else { flags |= Annot::flagHidden; } diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc index c06eb9ae..6f264bd0 100644 --- a/qt6/src/poppler-form.cc +++ b/qt6/src/poppler-form.cc @@ -194,7 +194,14 @@ void FormField::setReadOnly(bool value) bool FormField::isVisible() const { -return !(m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagHidden); +const unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags(); +if (flags & Annot::flagHidden) { +return false; +} +if (flags & Annot::flagNoView) { +return false; +} +return true; } void FormField::setVisible(bool value) @@ -202,6 +209,7 @@ void FormField::setVisible(bool value) unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags(); if (value) { flags &= ~Annot::flagHidden; +flags &= ~Annot::flagNoView; } else { flags |= Annot::flagHidden; }
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc |2 ++ qt6/src/poppler-annotation.cc |2 ++ 2 files changed, 4 insertions(+) New commits: commit 1c1553142de667a10949ac17d9f9f609f1a23832 Author: Albert Astals Cid Date: Thu Mar 3 17:30:15 2022 +0100 qt: Add qWarnings for non supported scenarios diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index c7607b88..5f563ca4 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -2032,6 +2032,7 @@ void TextAnnotation::setTextType(TextAnnotation::TextType type) } // Type cannot be changed if annotation is already tied +qWarning() << "You can't change the type of a TextAnnotation that is already in a page"; } QString TextAnnotation::textIcon() const @@ -2453,6 +2454,7 @@ void LineAnnotation::setLineType(LineAnnotation::LineType type) } // Type cannot be changed if annotation is already tied +qWarning() << "You can't change the type of a LineAnnotation that is already in a page"; } QLinkedList LineAnnotation::linePoints() const diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc index 3ee4a83c..1b9aa344 100644 --- a/qt6/src/poppler-annotation.cc +++ b/qt6/src/poppler-annotation.cc @@ -1603,6 +1603,7 @@ void TextAnnotation::setTextType(TextAnnotation::TextType type) } // Type cannot be changed if annotation is already tied +qWarning() << "You can't change the type of a TextAnnotation that is already in a page"; } QString TextAnnotation::textIcon() const @@ -1953,6 +1954,7 @@ void LineAnnotation::setLineType(LineAnnotation::LineType type) } // Type cannot be changed if annotation is already tied +qWarning() << "You can't change the type of a LineAnnotation that is already in a page"; } QVector LineAnnotation::linePoints() const
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc |3 +++ qt5/src/poppler-link.h|5 +++-- qt5/src/poppler-page.cc |7 +-- qt6/src/poppler-link.h|5 +++-- qt6/src/poppler-page.cc |7 +-- 5 files changed, 19 insertions(+), 8 deletions(-) New commits: commit 26f56c073bdcccb5780e8cc3226ff2a2df6fe97d Author: Albert Astals Cid Date: Tue Mar 1 23:28:47 2022 +0100 qt: Handle SaveAs named action diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index d25b3a00..c7607b88 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -3848,6 +3848,9 @@ void LinkAnnotation::store(QDomNode &node, QDomDocument &document) const case Poppler::LinkAction::Print: hyperlinkElement.setAttribute(QStringLiteral("action"), QStringLiteral("Print")); break; +case Poppler::LinkAction::SaveAs: +hyperlinkElement.setAttribute(QStringLiteral("action"), QStringLiteral("SaveAs")); +break; } break; } diff --git a/qt5/src/poppler-link.h b/qt5/src/poppler-link.h index e83e2f8f..5de35429 100644 --- a/qt5/src/poppler-link.h +++ b/qt5/src/poppler-link.h @@ -1,5 +1,5 @@ /* poppler-link.h: qt interface to poppler - * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, Albert Astals Cid + * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, 2022, Albert Astals Cid * Copyright (C) 2007-2008, 2010, Pino Toscano * Copyright (C) 2010, 2012, Guillermo Amaral * Copyright (C) 2012, Tobias Koenig @@ -385,7 +385,8 @@ public: Find = 10, GoToPage = 11, Close = 12, -Print = 13 ///< \since 0.16 +Print = 13, ///< \since 0.16 +SaveAs = 14 ///< \since 22.04 }; /** diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index eedc580f..1e808f7a 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -1,7 +1,7 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Brad Hards - * Copyright (C) 2005-2021, Albert Astals Cid + * Copyright (C) 2005-2022, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2008 Carlos Garcia Campos @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -256,8 +257,10 @@ Link *PageData::convertLinkActionToLink(::LinkAction *a, DocumentData *parentDoc // its presentation mode or not // popplerLink = new LinkAction( linkArea, LinkAction::EndPresentation ); popplerLink = new LinkAction(linkArea, LinkAction::Close); +} else if (name == "SaveAs") { +popplerLink = new LinkAction(linkArea, LinkAction::SaveAs); } else { -// TODO +qWarning() << "Unhandled action name" << name.c_str(); } } break; diff --git a/qt6/src/poppler-link.h b/qt6/src/poppler-link.h index 7cadd218..52065a2e 100644 --- a/qt6/src/poppler-link.h +++ b/qt6/src/poppler-link.h @@ -1,5 +1,5 @@ /* poppler-link.h: qt interface to poppler - * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, Albert Astals Cid + * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, 2022, Albert Astals Cid * Copyright (C) 2007-2008, 2010, Pino Toscano * Copyright (C) 2010, 2012, Guillermo Amaral * Copyright (C) 2012, Tobias Koenig @@ -382,7 +382,8 @@ public: Find = 10, GoToPage = 11, Close = 12, -Print = 13 +Print = 13, +SaveAs = 14 ///< \since 22.04 }; /** diff --git a/qt6/src/poppler-page.cc b/qt6/src/poppler-page.cc index afdbf692..84786d33 100644 --- a/qt6/src/poppler-page.cc +++ b/qt6/src/poppler-page.cc @@ -1,7 +1,7 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Brad Hards - * Copyright (C) 2005-2021, Albert Astals Cid + * Copyright (C) 2005-2022, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2008 Carlos Garcia Campos @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -255,8 +256,10 @@ std::unique_ptr PageData::convertLinkActionToLink(::LinkAction *a, Documen // its presentation mode or not // popplerLink = std::make_unique(linkArea, LinkAction::EndPresentation); popplerLink = std::make_unique(linkArea, LinkAction::Close); +} else if (name == "SaveAs") { +popplerLink = std::make_unique(linkArea, LinkAction::SaveAs); } else { -// TODO +qWarning() << "Unhandled action name" << name.c_str(); } } break;
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc |6 ++ qt6/src/poppler-annotation.cc |6 ++ 2 files changed, 12 insertions(+) New commits: commit 4e8d336cc5b7bc848afd50bbe8211e5837f298a4 Author: Albert Astals Cid Date: Wed Mar 2 16:53:33 2022 +0100 qt: Add a few "don't do anything if you're setting the same value we already have" diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index ddb773d8..d25b3a00 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -2089,6 +2089,9 @@ QFont TextAnnotation::textFont() const void TextAnnotation::setTextFont(const QFont &font) { Q_D(TextAnnotation); +if (font == d->textFont) { +return; +} d->textFont = font; d->setDefaultAppearanceToNative(); @@ -2111,6 +2114,9 @@ QColor TextAnnotation::textColor() const void TextAnnotation::setTextColor(const QColor &color) { Q_D(TextAnnotation); +if (color == d->textColor) { +return; +} d->textColor = color; d->setDefaultAppearanceToNative(); diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc index c1c61259..3ee4a83c 100644 --- a/qt6/src/poppler-annotation.cc +++ b/qt6/src/poppler-annotation.cc @@ -1660,6 +1660,9 @@ QFont TextAnnotation::textFont() const void TextAnnotation::setTextFont(const QFont &font) { Q_D(TextAnnotation); +if (font == d->textFont) { +return; +} d->textFont = font; d->setDefaultAppearanceToNative(); @@ -1682,6 +1685,9 @@ QColor TextAnnotation::textColor() const void TextAnnotation::setTextColor(const QColor &color) { Q_D(TextAnnotation); +if (color == d->textColor) { +return; +} d->textColor = color; d->setDefaultAppearanceToNative();
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc |3 +-- qt5/src/poppler-annotation.h |4 ++-- qt6/src/poppler-annotation.cc |3 +-- qt6/src/poppler-annotation.h |3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) New commits: commit ca724daf21a60900e6bb3d44e7b88c64990e4a21 Author: Albert Astals Cid Date: Wed Mar 2 16:44:56 2022 +0100 qt: Annotations, don't change the text color when changing the font diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index cca9737b..ddb773d8 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -1832,7 +1832,7 @@ public: TextAnnotation::TextType textType; QString textIcon; std::optional textFont; -QColor textColor; +QColor textColor = Qt::black; int inplaceAlign; // 0:left, 1:center, 2:right QVector inplaceCallout; TextAnnotation::InplaceIntent inplaceIntent; @@ -2090,7 +2090,6 @@ void TextAnnotation::setTextFont(const QFont &font) { Q_D(TextAnnotation); d->textFont = font; -d->textColor = Qt::black; d->setDefaultAppearanceToNative(); } diff --git a/qt5/src/poppler-annotation.h b/qt5/src/poppler-annotation.h index c8c4c6ac..00460f74 100644 --- a/qt5/src/poppler-annotation.h +++ b/qt5/src/poppler-annotation.h @@ -1,5 +1,5 @@ /* poppler-annotation.h: qt interface to poppler - * Copyright (C) 2006-2008, 2012, 2013, 2018-2021 Albert Astals Cid + * Copyright (C) 2006-2008, 2012, 2013, 2018-2022 Albert Astals Cid * Copyright (C) 2006, 2008 Pino Toscano * Copyright (C) 2007, Brad Hards * Copyright (C) 2010, Philip Lorenz @@ -562,7 +562,7 @@ public: QFont textFont() const; void setTextFont(const QFont &font); -/// \since 0.69 +/// Default text color is black \since 0.69 QColor textColor() const; /// \since 0.69 void setTextColor(const QColor &color); diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc index 43408bf3..c1c61259 100644 --- a/qt6/src/poppler-annotation.cc +++ b/qt6/src/poppler-annotation.cc @@ -1497,7 +1497,7 @@ public: TextAnnotation::TextType textType; QString textIcon; std::optional textFont; -QColor textColor; +QColor textColor = Qt::black; TextAnnotation::InplaceAlignPosition inplaceAlign; QVector inplaceCallout; TextAnnotation::InplaceIntent inplaceIntent; @@ -1661,7 +1661,6 @@ void TextAnnotation::setTextFont(const QFont &font) { Q_D(TextAnnotation); d->textFont = font; -d->textColor = Qt::black; d->setDefaultAppearanceToNative(); } diff --git a/qt6/src/poppler-annotation.h b/qt6/src/poppler-annotation.h index 644c9167..16f2eda5 100644 --- a/qt6/src/poppler-annotation.h +++ b/qt6/src/poppler-annotation.h @@ -1,5 +1,5 @@ /* poppler-annotation.h: qt interface to poppler - * Copyright (C) 2006-2008, 2012, 2013, 2018-2021 Albert Astals Cid + * Copyright (C) 2006-2008, 2012, 2013, 2018-2022 Albert Astals Cid * Copyright (C) 2006, 2008 Pino Toscano * Copyright (C) 2007, Brad Hards * Copyright (C) 2010, Philip Lorenz @@ -518,6 +518,7 @@ public: QFont textFont() const; void setTextFont(const QFont &font); +/// Default text color is black QColor textColor() const; void setTextColor(const QColor &color);
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc | 18 +- qt6/src/poppler-annotation.cc | 18 +- 2 files changed, 26 insertions(+), 10 deletions(-) New commits: commit 5b2a4b46f642acc0db97910045475d340be57466 Author: Albert Astals Cid Date: Tue Feb 22 16:07:50 2022 +0100 qt: Store QFont as an optional This way we can know whether the font has been set externally or not diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index 4e0caeae..20a4a534 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -1835,7 +1835,7 @@ public: // data fields TextAnnotation::TextType textType; QString textIcon; -QFont textFont; +std::optional textFont; QColor textColor; int inplaceAlign; // 0:left, 1:center, 2:right QVector inplaceCallout; @@ -1863,7 +1863,11 @@ Annot *TextAnnotationPrivate::createNativeAnnot(::Page *destPage, DocumentData * if (textType == TextAnnotation::Linked) { pdfAnnot = new AnnotText { destPage->getDoc(), &rect }; } else { -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; +const double pointSize = textFont ? textFont->pointSizeF() : AnnotFreeText::undefinedFontPtSize; +if (pointSize < 0) { +qWarning() << "TextAnnotationPrivate::createNativeAnnot: font pointSize < 0"; +} +DefaultAppearance da { { objName, "Invalid_font" }, pointSize, convertQColor(textColor) }; pdfAnnot = new AnnotFreeText { destPage->getDoc(), &rect, da }; } @@ -1885,7 +1889,11 @@ void TextAnnotationPrivate::setDefaultAppearanceToNative() { if (pdfAnnot && pdfAnnot->getType() == Annot::typeFreeText) { AnnotFreeText *ftextann = static_cast(pdfAnnot); -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; +const double pointSize = textFont ? textFont->pointSizeF() : AnnotFreeText::undefinedFontPtSize; +if (pointSize < 0) { +qWarning() << "TextAnnotationPrivate::createNativeAnnot: font pointSize < 0"; +} +DefaultAppearance da { { objName, "Invalid_font" }, pointSize, convertQColor(textColor) }; ftextann->setDefaultAppearance(da); } } @@ -2066,8 +2074,8 @@ QFont TextAnnotation::textFont() const { Q_D(const TextAnnotation); -if (!d->pdfAnnot) -return d->textFont; +if (d->textFont) +return *d->textFont; double fontSize { AnnotFreeText::undefinedFontPtSize }; if (d->pdfAnnot->getType() == Annot::typeFreeText) { diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc index 60a9b9be..748749cd 100644 --- a/qt6/src/poppler-annotation.cc +++ b/qt6/src/poppler-annotation.cc @@ -1500,7 +1500,7 @@ public: // data fields TextAnnotation::TextType textType; QString textIcon; -QFont textFont; +std::optional textFont; QColor textColor; TextAnnotation::InplaceAlignPosition inplaceAlign; QVector inplaceCallout; @@ -1528,7 +1528,11 @@ Annot *TextAnnotationPrivate::createNativeAnnot(::Page *destPage, DocumentData * if (textType == TextAnnotation::Linked) { pdfAnnot = new AnnotText { destPage->getDoc(), &rect }; } else { -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; +const double pointSize = textFont ? textFont->pointSizeF() : AnnotFreeText::undefinedFontPtSize; +if (pointSize < 0) { +qWarning() << "TextAnnotationPrivate::createNativeAnnot: font pointSize < 0"; +} +DefaultAppearance da { { objName, "Invalid_font" }, pointSize, convertQColor(textColor) }; pdfAnnot = new AnnotFreeText { destPage->getDoc(), &rect, da }; } @@ -1550,7 +1554,11 @@ void TextAnnotationPrivate::setDefaultAppearanceToNative() { if (pdfAnnot && pdfAnnot->getType() == Annot::typeFreeText) { AnnotFreeText *ftextann = static_cast(pdfAnnot); -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; +const double pointSize = textFont ? textFont->pointSizeF() : AnnotFreeText::undefinedFontPtSize; +if (pointSize < 0) { +qWarning() << "TextAnnotationPrivate::createNativeAnnot: font pointSize < 0"; +} +DefaultAppearance da { { objName, "Invalid_font" }, pointSize, convertQColor(textColor) }; ftextann->setDefaultAppearance(da); } } @@ -1637,8 +1645,8 @@ QFont TextAnnotation::textFont() const { Q_D(const TextAnnotation); -if (!d->pdfAnnot) -return d->textFont; +if (d->textFont) +return *d->textFont; double fontSize { AnnotFreeText::undefinedFontPtSize }; if (d->pdfAnnot->getType() == Annot::typeFreeText) {
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc |4 ++-- qt6/src/poppler-annotation.cc |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit ad96231cca9390713183cf899d5a62b81d1767eb Author: Albert Astals Cid Date: Tue Feb 22 15:07:11 2022 +0100 qt: Remove unneeded unique_ptr constructor convertQColor already returns an unique_ptr diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index eb569c41..4e0caeae 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -1863,7 +1863,7 @@ Annot *TextAnnotationPrivate::createNativeAnnot(::Page *destPage, DocumentData * if (textType == TextAnnotation::Linked) { pdfAnnot = new AnnotText { destPage->getDoc(), &rect }; } else { -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), std::unique_ptr { convertQColor(textColor) } }; +DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; pdfAnnot = new AnnotFreeText { destPage->getDoc(), &rect, da }; } @@ -1885,7 +1885,7 @@ void TextAnnotationPrivate::setDefaultAppearanceToNative() { if (pdfAnnot && pdfAnnot->getType() == Annot::typeFreeText) { AnnotFreeText *ftextann = static_cast(pdfAnnot); -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), std::unique_ptr { convertQColor(textColor) } }; +DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; ftextann->setDefaultAppearance(da); } } diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc index a77332ca..60a9b9be 100644 --- a/qt6/src/poppler-annotation.cc +++ b/qt6/src/poppler-annotation.cc @@ -1528,7 +1528,7 @@ Annot *TextAnnotationPrivate::createNativeAnnot(::Page *destPage, DocumentData * if (textType == TextAnnotation::Linked) { pdfAnnot = new AnnotText { destPage->getDoc(), &rect }; } else { -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), std::unique_ptr { convertQColor(textColor) } }; +DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; pdfAnnot = new AnnotFreeText { destPage->getDoc(), &rect, da }; } @@ -1550,7 +1550,7 @@ void TextAnnotationPrivate::setDefaultAppearanceToNative() { if (pdfAnnot && pdfAnnot->getType() == Annot::typeFreeText) { AnnotFreeText *ftextann = static_cast(pdfAnnot); -DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), std::unique_ptr { convertQColor(textColor) } }; +DefaultAppearance da { { objName, "Invalid_font" }, static_cast(textFont.pointSize()), convertQColor(textColor) }; ftextann->setDefaultAppearance(da); } }
[poppler] qt5/src qt6/src
qt5/src/poppler-qt5.h |8 qt6/src/poppler-qt6.h |8 2 files changed, 8 insertions(+), 8 deletions(-) New commits: commit 85fc5394a8fd785486a7c73630d320f459a7a281 Author: Albert Astals Cid Date: Tue Feb 8 14:54:01 2022 +0100 qt: Change typedefs to using Much easier to understand diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index bab846f8..abeb4fdb 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -94,7 +94,7 @@ struct OutlineItemData; \since 0.16 */ -typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/); +using PopplerDebugFunc = void (*)(const QString & /*message*/, const QVariant & /*closure*/); /** Set a new debug/error output function. @@ -537,7 +537,7 @@ public: \since 0.62 */ -typedef void (*RenderToImagePartialUpdateFunc)(const QImage & /*image*/, const QVariant & /*closure*/); +using RenderToImagePartialUpdateFunc = void (*)(const QImage & /*image*/, const QVariant & /*closure*/); /** Partial Update query renderToImage callback. @@ -547,7 +547,7 @@ public: \since 0.62 */ -typedef bool (*ShouldRenderToImagePartialQueryFunc)(const QVariant & /*closure*/); +using ShouldRenderToImagePartialQueryFunc = bool (*)(const QVariant & /*closure*/); /** Render the page to a QImage using the current @@ -608,7 +608,7 @@ public: \since 0.63 */ -typedef bool (*ShouldAbortQueryFunc)(const QVariant & /*closure*/); +using ShouldAbortQueryFunc = bool (*)(const QVariant & /*closure*/); /** Render the page to a QImage using the current diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index 779e64dc..da27d866 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -94,7 +94,7 @@ struct OutlineItemData; the first parameter is the actual message, the second is the unaltered closure argument which was passed to the setDebugErrorFunction call. */ -typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/); +using PopplerDebugFunc = void (*)(const QString & /*message*/, const QVariant & /*closure*/); /** Set a new debug/error output function. @@ -519,7 +519,7 @@ public: the first parameter is the image as rendered up to now, the second is the unaltered closure argument which was passed to the renderToImage call. */ -typedef void (*RenderToImagePartialUpdateFunc)(const QImage & /*image*/, const QVariant & /*closure*/); +using RenderToImagePartialUpdateFunc = void (*)(const QImage & /*image*/, const QVariant & /*closure*/); /** Partial Update query renderToImage callback. @@ -527,7 +527,7 @@ public: This function type is used for query if the partial rendering update should happen; the parameter is the unaltered closure argument which was passed to the renderToImage call. */ -typedef bool (*ShouldRenderToImagePartialQueryFunc)(const QVariant & /*closure*/); +using ShouldRenderToImagePartialQueryFunc = bool (*)(const QVariant & /*closure*/); /** Render the page to a QImage using the current @@ -584,7 +584,7 @@ public: This function type is used for query if the current rendering/text extraction should be cancelled. */ -typedef bool (*ShouldAbortQueryFunc)(const QVariant & /*closure*/); +using ShouldAbortQueryFunc = bool (*)(const QVariant & /*closure*/); /** Render the page to a QImage using the current
[poppler] qt5/src qt6/src
qt5/src/poppler-pdf-converter.cc |1 + qt5/src/poppler-qt5.h|1 + qt6/src/poppler-pdf-converter.cc |1 + qt6/src/poppler-qt6.h|1 + 4 files changed, 4 insertions(+) New commits: commit 6a869a8115c0fc914f91317b2dcd7fdf0b839611 Author: Albert Astals Cid Date: Wed Jan 12 19:41:32 2022 +0100 Update (C) diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index bd3d8006..e070d51b 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -6,6 +6,7 @@ * Copyright (C) 2021, Klarälvdalens Datakonsult AB, a KDAB Group company, . * Copyright (C) 2021, Zachary Travis * Copyright (C) 2021, Georgiy Sgibnev . Work sponsored by lab50.net. + * Copyright (C) 2022, Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 4b1af1e5..bab846f8 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -28,6 +28,7 @@ * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, . * Copyright (C) 2021 Mahmoud Khalil * Copyright (C) 2021 Georgiy Sgibnev . Work sponsored by lab50.net. + * Copyright (C) 2022 Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt6/src/poppler-pdf-converter.cc b/qt6/src/poppler-pdf-converter.cc index 5a75f1e8..09b8debf 100644 --- a/qt6/src/poppler-pdf-converter.cc +++ b/qt6/src/poppler-pdf-converter.cc @@ -6,6 +6,7 @@ * Copyright (C) 2021, Klarälvdalens Datakonsult AB, a KDAB Group company, . * Copyright (C) 2021, Zachary Travis * Copyright (C) 2021, Georgiy Sgibnev . Work sponsored by lab50.net. + * Copyright (C) 2022, Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index f4ec26a0..779e64dc 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -28,6 +28,7 @@ * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, . * Copyright (C) 2021 Mahmoud Khalil * Copyright (C) 2021 Georgiy Sgibnev . Work sponsored by lab50.net. + * Copyright (C) 2022 Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
[poppler] qt5/src qt6/src
qt5/src/poppler-pdf-converter.cc | 14 +- qt5/src/poppler-qt5.h| 11 +++ qt6/src/poppler-pdf-converter.cc | 14 +- qt6/src/poppler-qt6.h| 11 +++ 4 files changed, 48 insertions(+), 2 deletions(-) New commits: commit 327cd87e489fd2be39bdb5bad394ce33be247dde Author: Martin Date: Wed Jan 12 00:21:13 2022 + [qt] Add PDFConverter::NewSignatureData::imagePath diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index 1a21c591..bd3d8006 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -138,7 +138,7 @@ bool PDFConverter::sign(const NewSignatureData &data) const auto userPwd = std::make_unique(data.documentUserPassword().constData()); return doc->sign(d->outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), data.password().toUtf8().constData(), QStringToGooString(data.fieldPartialName()), data.page() + 1, boundaryToPdfRectangle(destPage, data.boundingRectangle(), Annotation::FixedRotation), *gSignatureText, *gSignatureLeftText, data.fontSize(), convertQColor(data.fontColor()), data.borderWidth(), - convertQColor(data.borderColor()), convertQColor(data.backgroundColor()), reason.get(), location.get(), "" /*imagepath*/, ownerPwd.get(), userPwd.get()); + convertQColor(data.borderColor()), convertQColor(data.backgroundColor()), reason.get(), location.get(), data.imagePath().toStdString(), ownerPwd.get(), userPwd.get()); } struct PDFConverter::NewSignatureData::NewSignatureDataPrivate @@ -164,6 +164,8 @@ struct PDFConverter::NewSignatureData::NewSignatureDataPrivate QByteArray documentOwnerPassword; QByteArray documentUserPassword; + +QString imagePath; }; PDFConverter::NewSignatureData::NewSignatureData() : d(new NewSignatureDataPrivate()) { } @@ -342,4 +344,14 @@ void PDFConverter::NewSignatureData::setDocumentUserPassword(const QByteArray &p { d->documentUserPassword = password; } + +QString PDFConverter::NewSignatureData::imagePath() const +{ +return d->imagePath; +} + +void PDFConverter::NewSignatureData::setImagePath(const QString &path) +{ +d->imagePath = path; +} } diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 8fa0a51e..4b1af1e5 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -2311,6 +2311,17 @@ public: QByteArray documentUserPassword() const; void setDocumentUserPassword(const QByteArray &password); +/** + * Filesystem path to an image file to be used as background + * image for the signature annotation widget. + * + * Default: empty + * + * \since 22.02 + */ +QString imagePath() const; +void setImagePath(const QString &path); + private: struct NewSignatureDataPrivate; NewSignatureDataPrivate *const d; diff --git a/qt6/src/poppler-pdf-converter.cc b/qt6/src/poppler-pdf-converter.cc index 687d0e52..5a75f1e8 100644 --- a/qt6/src/poppler-pdf-converter.cc +++ b/qt6/src/poppler-pdf-converter.cc @@ -138,7 +138,7 @@ bool PDFConverter::sign(const NewSignatureData &data) const auto userPwd = std::make_unique(data.documentUserPassword().constData()); return doc->sign(d->outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), data.password().toUtf8().constData(), QStringToGooString(data.fieldPartialName()), data.page() + 1, boundaryToPdfRectangle(destPage, data.boundingRectangle(), Annotation::FixedRotation), *gSignatureText, *gSignatureLeftText, data.fontSize(), convertQColor(data.fontColor()), data.borderWidth(), - convertQColor(data.borderColor()), convertQColor(data.backgroundColor()), reason.get(), location.get(), "" /*imagepath*/, ownerPwd.get(), userPwd.get()); + convertQColor(data.borderColor()), convertQColor(data.backgroundColor()), reason.get(), location.get(), data.imagePath().toStdString(), ownerPwd.get(), userPwd.get()); } struct PDFConverter::NewSignatureData::NewSignatureDataPrivate @@ -164,6 +164,8 @@ struct PDFConverter::NewSignatureData::NewSignatureDataPrivate QByteArray documentOwnerPassword; QByteArray documentUserPassword; + +QString imagePath; }; PDFConverter::NewSignatureData::NewSignatureData() : d(new NewSignatureDataPrivate()) { } @@ -342,4 +344,14 @@ void PDFConverter::NewSignatureData::setDocumentUserPassword(const QByteArray &p { d->documentUserPassword = password; } + +QString PDFConverter::NewSignatureData::imagePath() const +{ +return d->imagePath; +} + +void PDFConverter::NewSignatureData::setImagePath(const QString &path) +{ +d->imagePath = path; +} } diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index 1c8948e9..f4ec26a0 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/popp
[poppler] qt5/src qt6/src
qt5/src/poppler-pdf-converter.cc |2 +- qt5/src/poppler-qt5.h|2 +- qt6/src/poppler-pdf-converter.cc |2 +- qt6/src/poppler-qt6.h|2 +- 4 files changed, 4 insertions(+), 4 deletions(-) New commits: commit bdcde37d2ca87b2b193d269b63cd9eff6b047286 Author: Albert Astals Cid Date: Wed Jan 5 23:58:01 2022 +0100 Update (C) of commit-1 diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index 28256dc7..1a21c591 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -1,6 +1,6 @@ /* poppler-pdf-converter.cc: qt interface to poppler * Copyright (C) 2008, Pino Toscano - * Copyright (C) 2008, 2009, 2020, 2021, Albert Astals Cid + * Copyright (C) 2008, 2009, 2020-2022, Albert Astals Cid * Copyright (C) 2020, Thorsten Behrens * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden * Copyright (C) 2021, Klarälvdalens Datakonsult AB, a KDAB Group company, . diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 19d30cac..8fa0a51e 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -1,7 +1,7 @@ /* poppler-qt.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2007, Brad Hards - * Copyright (C) 2005-2015, 2017-2021, Albert Astals Cid + * Copyright (C) 2005-2015, 2017-2022, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2009 Shawn Rutledge diff --git a/qt6/src/poppler-pdf-converter.cc b/qt6/src/poppler-pdf-converter.cc index 2d6c90a1..687d0e52 100644 --- a/qt6/src/poppler-pdf-converter.cc +++ b/qt6/src/poppler-pdf-converter.cc @@ -1,6 +1,6 @@ /* poppler-pdf-converter.cc: qt interface to poppler * Copyright (C) 2008, Pino Toscano - * Copyright (C) 2008, 2009, 2020, 2021, Albert Astals Cid + * Copyright (C) 2008, 2009, 2020-2022, Albert Astals Cid * Copyright (C) 2020, Thorsten Behrens * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden * Copyright (C) 2021, Klarälvdalens Datakonsult AB, a KDAB Group company, . diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index 2ae36ab8..1c8948e9 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -1,7 +1,7 @@ /* poppler-qt.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2007, Brad Hards - * Copyright (C) 2005-2015, 2017-2021, Albert Astals Cid + * Copyright (C) 2005-2015, 2017-2022, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2009 Shawn Rutledge
[poppler] qt5/src qt6/src
qt5/src/poppler-pdf-converter.cc | 27 ++- qt5/src/poppler-qt5.h| 20 qt6/src/poppler-pdf-converter.cc | 27 ++- qt6/src/poppler-qt6.h| 20 4 files changed, 92 insertions(+), 2 deletions(-) New commits: commit 902ef7b20b7b7b6d434e45b3f06d2ac8b3e8ba54 Author: Albert Astals Cid Date: Wed Dec 29 19:26:15 2021 +0100 qt: Allow passing the document password when signing We need it since in the middle of the signing process we need to reopen the document we just created to do some final modifications diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index 5b2e7c03..28256dc7 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -134,9 +134,11 @@ bool PDFConverter::sign(const NewSignatureData &data) std::unique_ptr gSignatureLeftText = std::unique_ptr(QStringToUnicodeGooString(data.signatureLeftText())); const auto reason = std::unique_ptr(data.reason().isEmpty() ? nullptr : QStringToUnicodeGooString(data.reason())); const auto location = std::unique_ptr(data.location().isEmpty() ? nullptr : QStringToUnicodeGooString(data.location())); +const auto ownerPwd = std::make_unique(data.documentOwnerPassword().constData()); +const auto userPwd = std::make_unique(data.documentUserPassword().constData()); return doc->sign(d->outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), data.password().toUtf8().constData(), QStringToGooString(data.fieldPartialName()), data.page() + 1, boundaryToPdfRectangle(destPage, data.boundingRectangle(), Annotation::FixedRotation), *gSignatureText, *gSignatureLeftText, data.fontSize(), convertQColor(data.fontColor()), data.borderWidth(), - convertQColor(data.borderColor()), convertQColor(data.backgroundColor()), reason.get(), location.get()); + convertQColor(data.borderColor()), convertQColor(data.backgroundColor()), reason.get(), location.get(), "" /*imagepath*/, ownerPwd.get(), userPwd.get()); } struct PDFConverter::NewSignatureData::NewSignatureDataPrivate @@ -159,6 +161,9 @@ struct PDFConverter::NewSignatureData::NewSignatureDataPrivate QColor backgroundColor = QColor(240, 240, 240); QString partialName = QUuid::createUuid().toString(); + +QByteArray documentOwnerPassword; +QByteArray documentUserPassword; }; PDFConverter::NewSignatureData::NewSignatureData() : d(new NewSignatureDataPrivate()) { } @@ -317,4 +322,24 @@ void PDFConverter::NewSignatureData::setFieldPartialName(const QString &name) { d->partialName = name; } + +QByteArray PDFConverter::NewSignatureData::documentOwnerPassword() const +{ +return d->documentOwnerPassword; +} + +void PDFConverter::NewSignatureData::setDocumentOwnerPassword(const QByteArray &password) +{ +d->documentOwnerPassword = password; +} + +QByteArray PDFConverter::NewSignatureData::documentUserPassword() const +{ +return d->documentUserPassword; +} + +void PDFConverter::NewSignatureData::setDocumentUserPassword(const QByteArray &password) +{ +d->documentUserPassword = password; +} } diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index f307a26e..19d30cac 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -2291,6 +2291,26 @@ public: QString fieldPartialName() const; void setFieldPartialName(const QString &name); +/** + * Document owner password (needed if the document that is being signed is password protected) + * + * Default: no password + * + * \since 22.02 + */ +QByteArray documentOwnerPassword() const; +void setDocumentOwnerPassword(const QByteArray &password); + +/** + * Document user password (needed if the document that is being signed is password protected) + * + * Default: no password + * + * \since 22.02 + */ +QByteArray documentUserPassword() const; +void setDocumentUserPassword(const QByteArray &password); + private: struct NewSignatureDataPrivate; NewSignatureDataPrivate *const d; diff --git a/qt6/src/poppler-pdf-converter.cc b/qt6/src/poppler-pdf-converter.cc index 1c77146d..2d6c90a1 100644 --- a/qt6/src/poppler-pdf-converter.cc +++ b/qt6/src/poppler-pdf-converter.cc @@ -134,9 +134,11 @@ bool PDFConverter::sign(const NewSignatureData &data) std::unique_ptr gSignatureLeftText = std::unique_ptr(QStringToUnicodeGooString(data.signatureLeftText())); const auto reason = std::unique_ptr(data.reason().isEmpty() ? nullptr : QStringToUnicodeGooString(data.reason())); const auto location = std::unique_ptr(data.location().isEmpty() ? nullptr : QStringToUnicodeGooString(data.location())); +const auto ownerPwd = std::make_unique(data.d
[poppler] qt5/src qt6/src
qt5/src/poppler-qiodeviceoutstream-private.h |2 +- qt5/src/poppler-qiodeviceoutstream.cc|2 ++ qt6/src/poppler-qiodeviceoutstream-private.h |2 +- qt6/src/poppler-qiodeviceoutstream.cc|2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) New commits: commit 70980eaf611c21a5f12a7edbe332e223f3b874f1 Author: Even Rouault Date: Wed Nov 24 16:53:29 2021 +0100 poppler-qiodeviceoutstream: add printf format attribute for GCC Solves ``` /home/even/poppler/qt5/src/poppler-qiodeviceoutstream.cc: In function ‘int Poppler::poppler_vasprintf(char**, const char*, __va_list_tag*)’: /home/even/poppler/qt5/src/poppler-qiodeviceoutstream.cc:49:62: warning: function ‘int Poppler::poppler_vasprintf(char**, const char*, __va_list_tag*)’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] 49 | const size_t size = vsnprintf(nullptr, 0, format, ap_copy) + 1; | ^ ``` diff --git a/qt5/src/poppler-qiodeviceoutstream-private.h b/qt5/src/poppler-qiodeviceoutstream-private.h index b1b5101a..bc8dd02a 100644 --- a/qt5/src/poppler-qiodeviceoutstream-private.h +++ b/qt5/src/poppler-qiodeviceoutstream-private.h @@ -37,7 +37,7 @@ public: void close() override; Goffset getPos() override; void put(char c) override; -void printf(const char *format, ...) override; +void printf(const char *format, ...) override GCC_PRINTF_FORMAT(2, 3); private: QIODevice *m_device; diff --git a/qt5/src/poppler-qiodeviceoutstream.cc b/qt5/src/poppler-qiodeviceoutstream.cc index 13941914..4c7e8eff 100644 --- a/qt5/src/poppler-qiodeviceoutstream.cc +++ b/qt5/src/poppler-qiodeviceoutstream.cc @@ -42,6 +42,8 @@ void QIODeviceOutStream::put(char c) m_device->putChar(c); } +static int poppler_vasprintf(char **buf_ptr, const char *format, va_list ap) GCC_PRINTF_FORMAT(2, 0); + static int poppler_vasprintf(char **buf_ptr, const char *format, va_list ap) { va_list ap_copy; diff --git a/qt6/src/poppler-qiodeviceoutstream-private.h b/qt6/src/poppler-qiodeviceoutstream-private.h index 9f407d17..4f7b0f85 100644 --- a/qt6/src/poppler-qiodeviceoutstream-private.h +++ b/qt6/src/poppler-qiodeviceoutstream-private.h @@ -37,7 +37,7 @@ public: void close() override; Goffset getPos() override; void put(char c) override; -void printf(const char *format, ...) override; +void printf(const char *format, ...) override GCC_PRINTF_FORMAT(2, 3); private: QIODevice *m_device; diff --git a/qt6/src/poppler-qiodeviceoutstream.cc b/qt6/src/poppler-qiodeviceoutstream.cc index 171f7399..75d36128 100644 --- a/qt6/src/poppler-qiodeviceoutstream.cc +++ b/qt6/src/poppler-qiodeviceoutstream.cc @@ -42,6 +42,8 @@ void QIODeviceOutStream::put(char c) m_device->putChar(c); } +static int poppler_vasprintf(char **buf_ptr, const char *format, va_list ap) GCC_PRINTF_FORMAT(2, 0); + static int poppler_vasprintf(char **buf_ptr, const char *format, va_list ap) { va_list ap_copy;
[poppler] qt5/src qt6/src
qt5/src/poppler-page.cc | 11 --- qt6/src/poppler-page.cc | 11 --- 2 files changed, 8 insertions(+), 14 deletions(-) New commits: commit 736337fdab52ba77e1877347adff595136f74d73 Author: Thomas Huxhorn Date: Sun Aug 29 12:18:57 2021 +0200 save the trouble of remembering to delete the pointer diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 65f39bb3..b35894cf 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -26,6 +26,7 @@ * Copyright (C) 2020 Oliver Sander * Copyright (C) 2020 Philipp Knechtges * Copyright (C) 2021 Hubert Figuiere + * Copyright (C) 2021 Thomas Huxhorn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -723,23 +724,20 @@ QList Page::textList(Rotation rotate) const QList Page::textList(Rotation rotate, ShouldAbortQueryFunc shouldAbortExtractionCallback, const QVariant &closure) const { -TextOutputDev *output_dev; - QList output_list; -output_dev = new TextOutputDev(nullptr, false, 0, false, false); +TextOutputDev output_dev(nullptr, false, 0, false, false); int rotation = (int)rotate * 90; TextExtractionAbortHelper abortHelper(shouldAbortExtractionCallback, closure); -m_page->parentDoc->doc->displayPageSlice(output_dev, m_page->index + 1, 72, 72, rotation, false, false, false, -1, -1, -1, -1, shouldAbortExtractionCallback ? shouldAbortExtractionInternalCallback : nullAbortCallBack, &abortHelper, +m_page->parentDoc->doc->displayPageSlice(&output_dev, m_page->index + 1, 72, 72, rotation, false, false, false, -1, -1, -1, -1, shouldAbortExtractionCallback ? shouldAbortExtractionInternalCallback : nullAbortCallBack, &abortHelper, nullptr, nullptr, true); -TextWordList *word_list = output_dev->makeWordList(); +TextWordList *word_list = output_dev.makeWordList(); if (!word_list || (shouldAbortExtractionCallback && shouldAbortExtractionCallback(closure))) { delete word_list; -delete output_dev; return output_list; } @@ -774,7 +772,6 @@ QList Page::textList(Rotation rotate, ShouldAbortQueryFunc shouldAbor } delete word_list; -delete output_dev; return output_list; } diff --git a/qt6/src/poppler-page.cc b/qt6/src/poppler-page.cc index a8d00db1..11a60410 100644 --- a/qt6/src/poppler-page.cc +++ b/qt6/src/poppler-page.cc @@ -25,6 +25,7 @@ * Copyright (C) 2018, 2021 Nelson Benítez León * Copyright (C) 2020 Philipp Knechtges * Copyright (C) 2021 Hubert Figuiere + * Copyright (C) 2021 Thomas Huxhorn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -694,23 +695,20 @@ std::vector> Page::textList(Rotation rotate) const std::vector> Page::textList(Rotation rotate, ShouldAbortQueryFunc shouldAbortExtractionCallback, const QVariant &closure) const { -TextOutputDev *output_dev; - std::vector> output_list; -output_dev = new TextOutputDev(nullptr, false, 0, false, false); +TextOutputDev output_dev(nullptr, false, 0, false, false); int rotation = (int)rotate * 90; TextExtractionAbortHelper abortHelper(shouldAbortExtractionCallback, closure); -m_page->parentDoc->doc->displayPageSlice(output_dev, m_page->index + 1, 72, 72, rotation, false, false, false, -1, -1, -1, -1, shouldAbortExtractionCallback ? shouldAbortExtractionInternalCallback : nullAbortCallBack, &abortHelper, +m_page->parentDoc->doc->displayPageSlice(&output_dev, m_page->index + 1, 72, 72, rotation, false, false, false, -1, -1, -1, -1, shouldAbortExtractionCallback ? shouldAbortExtractionInternalCallback : nullAbortCallBack, &abortHelper, nullptr, nullptr, true); -TextWordList *word_list = output_dev->makeWordList(); +TextWordList *word_list = output_dev.makeWordList(); if (!word_list || (shouldAbortExtractionCallback && shouldAbortExtractionCallback(closure))) { delete word_list; -delete output_dev; return output_list; } @@ -745,7 +743,6 @@ std::vector> Page::textList(Rotation rotate, ShouldAbor } delete word_list; -delete output_dev; return output_list; }
[poppler] qt5/src
qt5/src/poppler-document.cc |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 3d49757055dbcd2876c0b26ee00a7bd780541938 Author: Albert Astals Cid Date: Thu Jul 15 22:19:30 2021 +0200 Update (C) diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 25835f35..3460cf53 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -13,7 +13,7 @@ * Copyright (C) 2017 Adrian Johnson * Copyright (C) 2017 Suzuki Toshiya * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich - * Copyright (C) 2019, 2020 Oliver Sander + * Copyright (C) 2019-2021 Oliver Sander * Copyright (C) 2019 Alexander Volkov * Copyright (C) 2020 Philipp Knechtges * Copyright (C) 2020 Katarina Behrens ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests qt6/src qt6/tests
qt5/src/poppler-document.cc |5 + qt5/src/poppler-qt5.h| 20 +++- qt5/tests/check_metadata.cpp |7 +++ qt5/tests/stress-poppler-dir.cpp |7 +-- qt5/tests/stress-poppler-qt5.cpp |4 ++-- qt5/tests/test-password-qt5.cpp |5 ++--- qt5/tests/test-poppler-qt5.cpp |5 ++--- qt6/src/poppler-document.cc |7 ++- qt6/src/poppler-qt6.h| 14 +- qt6/tests/check_metadata.cpp |7 +++ qt6/tests/stress-poppler-dir.cpp |4 ++-- qt6/tests/stress-poppler-qt6.cpp |4 ++-- qt6/tests/test-password-qt6.cpp |5 ++--- qt6/tests/test-poppler-qt6.cpp |5 ++--- 14 files changed, 60 insertions(+), 39 deletions(-) New commits: commit 13c95f251bf47068a3c083bf038cab86fea7f570 Author: Oliver Sander Date: Fri Jul 9 11:55:24 2021 +0200 Make getPdfVersion return a dedicated version object That's a bit more modern than the old way where pointers to two integers had to be passed to the method. With the new method you can write auto pdfVersion = doc->getPdfVersion(); // access numbers as pdfVersion.major and pdfVersion.minor instead of int major, minor; doc->getPdfVersion(&major, &minor); With C++17 you can even write auto [major, minor] = doc->getPdfVersion(); The new method is put alongside the old one in the Qt5 interface. It replaces the old one in the Qt6 interface. diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 6118ccdd..25835f35 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -556,6 +556,11 @@ void Document::getPdfVersion(int *major, int *minor) const *minor = m_doc->doc->getPDFMinorVersion(); } +Document::PdfVersion Document::getPdfVersion() const +{ +return PdfVersion { m_doc->doc->getPDFMajorVersion(), m_doc->doc->getPDFMinorVersion() }; +} + Page *Document::page(const QString &label) const { GooString label_g(label.toLatin1().data()); diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index d6dbd461..dacda011 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -1648,9 +1648,27 @@ QString subject = m_doc->info("Subject"); \param minor an optional pointer to a variable where store the "minor" number of the version + \deprecated Will be removed in the Qt6 interface. Use the method + returning a PdfVersion object instead! + \since 0.12 */ -void getPdfVersion(int *major, int *minor) const; +Q_DECL_DEPRECATED void getPdfVersion(int *major, int *minor) const; + +/** \brief The version specification of a pdf file */ +struct PdfVersion +{ +int major; +int minor; +}; + +/** + The version of the PDF specification that the document + conforms to + + \since 21.08 +*/ +PdfVersion getPdfVersion() const; /** The fonts within the PDF document. diff --git a/qt5/tests/check_metadata.cpp b/qt5/tests/check_metadata.cpp index 6167d9c3..90ebba04 100644 --- a/qt5/tests/check_metadata.cpp +++ b/qt5/tests/check_metadata.cpp @@ -226,10 +226,9 @@ void TestMetaData::checkVersion() doc = Poppler::Document::load(TESTDATADIR "/unittestcases/doublepage.pdf"); QVERIFY(doc); -int major = 0, minor = 0; -doc->getPdfVersion(&major, &minor); -QCOMPARE(major, 1); -QCOMPARE(minor, 6); +auto pdfVersion = doc->getPdfVersion(); +QCOMPARE(pdfVersion.major, 1); +QCOMPARE(pdfVersion.minor, 6); delete doc; } diff --git a/qt5/tests/stress-poppler-dir.cpp b/qt5/tests/stress-poppler-dir.cpp index 6db57129..8cac185b 100644 --- a/qt5/tests/stress-poppler-dir.cpp +++ b/qt5/tests/stress-poppler-dir.cpp @@ -28,8 +28,11 @@ int main(int argc, char **argv) delete doc; } } else { -int major = 0, minor = 0; -doc->getPdfVersion(&major, &minor); +auto pdfVersion = doc->getPdfVersion(); +if (pdfVersion.major != 1) { +qWarning() << "pdf major version is not '1'"; +} + doc->info(QStringLiteral("Title")); doc->info(QStringLiteral("Subject")); doc->info(QStringLiteral("Author")); diff --git a/qt5/tests/stress-poppler-qt5.cpp b/qt5/tests/stress-poppler-qt5.cpp index 07f8cdf2..31795f96 100644 --- a/qt5/tests/stress-poppler-qt5.cpp +++ b/qt5/tests/stress-poppler-qt5.cpp @@ -36,8 +36,8 @@ int main(int argc, char **argv) if (!doc) { qWarning() << "doc not loaded"; } else { -int major = 0, minor = 0; -doc->getPdfVersion(&major, &minor); +auto pdfVersion = doc->getPdfVersion(); +Q_UNUSED(pdfVersion); doc->info(QStringLiteral("Title")); doc->i
[poppler] qt5/src
qt5/src/poppler-qt5.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 5977890bb79798ec3ad48b9806d760a1d2746990 Author: Albert Astals Cid Date: Thu Jul 8 23:07:07 2021 +0200 Update (C) diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 75f51e7c..d6dbd461 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -16,7 +16,7 @@ * Copyright (C) 2012, 2013 Thomas Freitag * Copyright (C) 2013 Anthony Granger * Copyright (C) 2016 Jakub Alba - * Copyright (C) 2017, 2020 Oliver Sander + * Copyright (C) 2017, 2020, 2021 Oliver Sander * Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich * Copyright (C) 2018, 2021 Nelson Benítez León * Copyright (C) 2019 Jan Grulich ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-qt5.h |5 + qt6/src/poppler-qt6.h |5 + 2 files changed, 10 insertions(+) New commits: commit ab409a6ec85dc7511dbe8ea6b2e4d7897f36670b Author: Oliver Sander Date: Thu Jul 8 20:56:49 2021 +0200 Document that a document has to outlive its pages Because the Page objects handed out by Document objects store a pointer to the document. If the Document object is deleted before a Page object it handed out, that Page object will have a stale pointer. diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index a55fb9a4..75f51e7c 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -1339,6 +1339,11 @@ public: This function can return nullptr if for some reason the page can't be properly parsed. \param index the page number index + + \warning The Page object returned by this method internally stores a pointer + to the document that it was created from. This pointer will go stale if you + delete the Document object. Therefore the Document object needs to be kept alive + as long as you want to use the Page object. */ Page *page(int index) const; diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index bad34bc5..2ab7097d 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -1216,6 +1216,11 @@ public: This function can return empty unique pointer if for some reason the page can't be properly parsed. \param index the page number index + + \warning The Page object returned by this method internally stores a pointer + to the document that it was created from. This pointer will go stale if you + delete the Document object. Therefore the Document object needs to be kept alive + as long as you want to use the Page object. */ std::unique_ptr page(int index) const; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation-helper.h |9 +++-- qt6/src/poppler-annotation-helper.h |9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) New commits: commit 4ef3535bffedd217707ea16f2ba415dbcdc1ed41 Author: Albert Astals Cid Date: Sat May 8 01:11:57 2021 +0200 qt: Don't assert when trying to invert singular matrices oss-fuzz/33611 diff --git a/qt5/src/poppler-annotation-helper.h b/qt5/src/poppler-annotation-helper.h index c96b7dfc..b294a084 100644 --- a/qt5/src/poppler-annotation-helper.h +++ b/qt5/src/poppler-annotation-helper.h @@ -1,5 +1,5 @@ /* poppler-annotation-helper.h: qt interface to poppler - * Copyright (C) 2006, 2008, 2017-2019, Albert Astals Cid + * Copyright (C) 2006, 2008, 2017-2019, 2021, Albert Astals Cid * Copyright (C) 2008, Pino Toscano * Copyright (C) 2012, Fabio D'Urso * Copyright (C) 2018, Dileep Sankhla @@ -55,7 +55,12 @@ void XPDFReader::transform(double *M, double x, double y, QPointF &res) void XPDFReader::invTransform(const double *M, const QPointF p, double &x, double &y) { const double det = M[0] * M[3] - M[1] * M[2]; -Q_ASSERT(det != 0); +if (det == 0) { +qWarning("Tried to invert singular matrix, something won't work"); +x = 0; +y = 0; +return; +} const double invM[4] = { M[3] / det, -M[1] / det, -M[2] / det, M[0] / det }; const double xt = p.x() - M[4]; diff --git a/qt6/src/poppler-annotation-helper.h b/qt6/src/poppler-annotation-helper.h index c96b7dfc..b294a084 100644 --- a/qt6/src/poppler-annotation-helper.h +++ b/qt6/src/poppler-annotation-helper.h @@ -1,5 +1,5 @@ /* poppler-annotation-helper.h: qt interface to poppler - * Copyright (C) 2006, 2008, 2017-2019, Albert Astals Cid + * Copyright (C) 2006, 2008, 2017-2019, 2021, Albert Astals Cid * Copyright (C) 2008, Pino Toscano * Copyright (C) 2012, Fabio D'Urso * Copyright (C) 2018, Dileep Sankhla @@ -55,7 +55,12 @@ void XPDFReader::transform(double *M, double x, double y, QPointF &res) void XPDFReader::invTransform(const double *M, const QPointF p, double &x, double &y) { const double det = M[0] * M[3] - M[1] * M[2]; -Q_ASSERT(det != 0); +if (det == 0) { +qWarning("Tried to invert singular matrix, something won't work"); +x = 0; +y = 0; +return; +} const double invM[4] = { M[3] / det, -M[1] / det, -M[2] / det, M[0] / det }; const double xt = p.x() - M[4]; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-pdf-converter.cc | 13 - qt5/src/poppler-qt5.h| 14 +- qt6/src/poppler-pdf-converter.cc | 13 - qt6/src/poppler-qt6.h| 14 +- 4 files changed, 50 insertions(+), 4 deletions(-) New commits: commit e43a3d9cff01c7d2b6374b3aa340882528da9c85 Author: Albert Astals Cid Date: Tue Apr 13 16:06:48 2021 +0200 qt: Allow to pass the border width when signing diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index 32910725..d1355764 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -176,7 +176,7 @@ bool PDFConverter::sign(const NewSignatureData &data) destPage->addAnnot(signatureAnnot); std::unique_ptr border(new AnnotBorderArray()); -border->setWidth(1.5); +border->setWidth(data.borderWidth()); signatureAnnot->setBorder(std::move(border)); FormWidgetSignature *fws = dynamic_cast(formWidget); @@ -211,6 +211,7 @@ struct PDFConverter::NewSignatureData::NewSignatureDataPrivate double fontSize = 10.0; QColor fontColor = Qt::red; QColor borderColor = Qt::red; +double borderWidth = 1.5; QColor backgroundColor = QColor(240, 240, 240); QString partialName = QUuid::createUuid().toString(); @@ -308,6 +309,16 @@ QColor PDFConverter::NewSignatureData::backgroundColor() const return d->backgroundColor; } +double PDFConverter::NewSignatureData::borderWidth() const +{ +return d->borderWidth; +} + +void PDFConverter::NewSignatureData::setBorderWidth(double width) +{ +d->borderWidth = width; +} + void PDFConverter::NewSignatureData::setBackgroundColor(const QColor &color) { d->backgroundColor = color; diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 2d879f78..70d2566a 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -25,6 +25,7 @@ * Copyright (C) 2020 Katarina Behrens * Copyright (C) 2020 Thorsten Behrens * Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden + * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2137,7 +2138,8 @@ public: * - rect for the signature annotation * - text that will be shown inside the rect * - font size and color - * - border and background color + * - border width and color + * - background color * \since 21.01 */ class POPPLER_QT5_EXPORT NewSignatureData @@ -2181,6 +2183,16 @@ public: QColor borderColor() const; void setBorderColor(const QColor &color); +/** + * border width in points + * + * Default: 1.5 + * + * \since 21.05 + */ +double borderWidth() const; +void setBorderWidth(double width); + /** * Default: QColor(240, 240, 240) */ diff --git a/qt6/src/poppler-pdf-converter.cc b/qt6/src/poppler-pdf-converter.cc index 3783e9ed..62e6d535 100644 --- a/qt6/src/poppler-pdf-converter.cc +++ b/qt6/src/poppler-pdf-converter.cc @@ -176,7 +176,7 @@ bool PDFConverter::sign(const NewSignatureData &data) destPage->addAnnot(signatureAnnot); std::unique_ptr border(new AnnotBorderArray()); -border->setWidth(1.5); +border->setWidth(data.borderWidth()); signatureAnnot->setBorder(std::move(border)); FormWidgetSignature *fws = dynamic_cast(formWidget); @@ -211,6 +211,7 @@ struct PDFConverter::NewSignatureData::NewSignatureDataPrivate double fontSize = 10.0; QColor fontColor = Qt::red; QColor borderColor = Qt::red; +double borderWidth = 1.5; QColor backgroundColor = QColor(240, 240, 240); QString partialName = QUuid::createUuid().toString(); @@ -308,6 +309,16 @@ QColor PDFConverter::NewSignatureData::backgroundColor() const return d->backgroundColor; } +double PDFConverter::NewSignatureData::borderWidth() const +{ +return d->borderWidth; +} + +void PDFConverter::NewSignatureData::setBorderWidth(double width) +{ +d->borderWidth = width; +} + void PDFConverter::NewSignatureData::setBackgroundColor(const QColor &color) { d->backgroundColor = color; diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index 5e34dcce..5d38fbdd 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -25,6 +25,7 @@ * Copyright (C) 2020 Katarina Behrens * Copyright (C) 2020 Thorsten Behrens * Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden + * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as
[poppler] qt5/src qt6/src
qt5/src/poppler-pdf-converter.cc |5 +++-- qt6/src/poppler-pdf-converter.cc |5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) New commits: commit d672fbe5c1f22c69e30824d7cb896e6b8fb560eb Author: Albert Astals Cid Date: Tue Apr 13 13:59:47 2021 +0200 qt: Make sure new signatures are always properly oriented With the old code if it the page we were adding a signature was landscape and then rotated 90 degrees to look like portrait (relatively common on scanned documents) the text would appear wrongly oriented diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index fa3f797d..32910725 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -3,6 +3,7 @@ * Copyright (C) 2008, 2009, 2020, Albert Astals Cid * Copyright (C) 2020, Thorsten Behrens * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden + * Copyright (C) 2021, Klarälvdalens Datakonsult AB, a KDAB Group company, . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -129,7 +130,7 @@ bool PDFConverter::sign(const NewSignatureData &data) ::Page *destPage = doc->getPage(data.page() + 1); const DefaultAppearance da { { objName, "SigFont" }, data.fontSize(), std::unique_ptr { convertQColor(data.fontColor()) } }; -const PDFRectangle rect = boundaryToPdfRectangle(destPage, data.boundingRectangle(), 0 /* no flags */); +const PDFRectangle rect = boundaryToPdfRectangle(destPage, data.boundingRectangle(), Annotation::FixedRotation); Object annotObj = Object(new Dict(doc->getXRef())); annotObj.dictSet("Type", Object(objName, "Annot")); @@ -157,7 +158,7 @@ bool PDFConverter::sign(const NewSignatureData &data) Object refObj(ref); AnnotWidget *signatureAnnot = new AnnotWidget(doc, &annotObj, &refObj, field.get()); -signatureAnnot->setFlags(signatureAnnot->getFlags() | Annot::flagPrint | Annot::flagLocked); +signatureAnnot->setFlags(signatureAnnot->getFlags() | Annot::flagPrint | Annot::flagLocked | Annot::flagNoRotate); Dict dummy(doc->getXRef()); auto appearCharacs = std::make_unique(&dummy); appearCharacs->setBorderColor(std::unique_ptr { convertQColor(data.borderColor()) }); diff --git a/qt6/src/poppler-pdf-converter.cc b/qt6/src/poppler-pdf-converter.cc index 91705f6e..3783e9ed 100644 --- a/qt6/src/poppler-pdf-converter.cc +++ b/qt6/src/poppler-pdf-converter.cc @@ -3,6 +3,7 @@ * Copyright (C) 2008, 2009, 2020, Albert Astals Cid * Copyright (C) 2020, Thorsten Behrens * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden + * Copyright (C) 2021, Klarälvdalens Datakonsult AB, a KDAB Group company, . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -129,7 +130,7 @@ bool PDFConverter::sign(const NewSignatureData &data) ::Page *destPage = doc->getPage(data.page() + 1); const DefaultAppearance da { { objName, "SigFont" }, data.fontSize(), std::unique_ptr { convertQColor(data.fontColor()) } }; -const PDFRectangle rect = boundaryToPdfRectangle(destPage, data.boundingRectangle(), 0 /* no flags */); +const PDFRectangle rect = boundaryToPdfRectangle(destPage, data.boundingRectangle(), Annotation::FixedRotation); Object annotObj = Object(new Dict(doc->getXRef())); annotObj.dictSet("Type", Object(objName, "Annot")); @@ -157,7 +158,7 @@ bool PDFConverter::sign(const NewSignatureData &data) Object refObj(ref); AnnotWidget *signatureAnnot = new AnnotWidget(doc, &annotObj, &refObj, field.get()); -signatureAnnot->setFlags(signatureAnnot->getFlags() | Annot::flagPrint | Annot::flagLocked); +signatureAnnot->setFlags(signatureAnnot->getFlags() | Annot::flagPrint | Annot::flagLocked | Annot::flagNoRotate); Dict dummy(doc->getXRef()); auto appearCharacs = std::make_unique(&dummy); appearCharacs->setBorderColor(std::unique_ptr { convertQColor(data.borderColor()) }); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests qt6/src qt6/tests
qt5/src/poppler-private.cc |4 qt5/tests/check_strings.cpp | 12 +--- qt6/src/poppler-private.cc |4 qt6/tests/check_strings.cpp | 12 +--- 4 files changed, 26 insertions(+), 6 deletions(-) New commits: commit b770a55a47278f4104fc410034577cc4ea0434a6 Author: Albert Astals Cid Date: Tue Apr 13 17:59:34 2021 +0200 qt: QStringToUnicodeGooString don't produce a "fake empty" string if the input string is empty, just return an empty GooString, not a GooString with only the unicode marker diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index 5b30f19c..695b9b8c 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -9,6 +9,7 @@ * Copyright (C) 2018-2020 Adam Reichold * Copyright (C) 2019, 2020 Oliver Sander * Copyright (C) 2019 João Netto + * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, * Inspired on code by * Copyright (C) 2004 by Albert Astals Cid * Copyright (C) 2004 by Enrico Ros @@ -115,6 +116,9 @@ QString UnicodeParsedString(const std::string &s1) GooString *QStringToUnicodeGooString(const QString &s) { +if (s.isEmpty()) { +return new GooString(); +} int len = s.length() * 2 + 2; char *cstring = (char *)gmallocn(len, sizeof(char)); cstring[0] = (char)0xfe; diff --git a/qt5/tests/check_strings.cpp b/qt5/tests/check_strings.cpp index 4c996c4f..14d22740 100644 --- a/qt5/tests/check_strings.cpp +++ b/qt5/tests/check_strings.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010, 2011, Pino Toscano + * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -189,9 +190,14 @@ void TestStrings::check_QStringToUnicodeGooString() QFETCH(QByteArray, result); GooString *goo = Poppler::QStringToUnicodeGooString(string); -QVERIFY(goo->hasUnicodeMarker()); -QCOMPARE(goo->getLength(), string.length() * 2 + 2); -QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, goo->getLength() - 2)); +if (string.isEmpty()) { +QVERIFY(goo->toStr().empty()); +QCOMPARE(goo->getLength(), 0); +} else { +QVERIFY(goo->hasUnicodeMarker()); +QCOMPARE(goo->getLength(), string.length() * 2 + 2); +QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, goo->getLength() - 2)); +} delete goo; } diff --git a/qt6/src/poppler-private.cc b/qt6/src/poppler-private.cc index c60876da..a2971adc 100644 --- a/qt6/src/poppler-private.cc +++ b/qt6/src/poppler-private.cc @@ -9,6 +9,7 @@ * Copyright (C) 2018-2020 Adam Reichold * Copyright (C) 2019, 2020 Oliver Sander * Copyright (C) 2019 João Netto + * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, * Inspired on code by * Copyright (C) 2004 by Albert Astals Cid * Copyright (C) 2004 by Enrico Ros @@ -115,6 +116,9 @@ QString UnicodeParsedString(const std::string &s1) GooString *QStringToUnicodeGooString(const QString &s) { +if (s.isEmpty()) { +return new GooString(); +} int len = s.length() * 2 + 2; char *cstring = (char *)gmallocn(len, sizeof(char)); cstring[0] = (char)0xfe; diff --git a/qt6/tests/check_strings.cpp b/qt6/tests/check_strings.cpp index c887105c..fdd2f703 100644 --- a/qt6/tests/check_strings.cpp +++ b/qt6/tests/check_strings.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010, 2011, Pino Toscano + * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -189,9 +190,14 @@ void TestStrings::check_QStringToUnicodeGooString() QFETCH(QByteArray, result); GooString *goo = Poppler::QStringToUnicodeGooString(string); -QVERIFY(goo->hasUnicodeMarker()); -QCOMPARE(goo->getLength(), string.length() * 2 + 2); -QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, goo->getLength() - 2)); +if (string.isEmpty()) { +QVERIFY(goo->toStr().empty()); +QCOMPARE(goo->getLength(), 0); +} else { +QVERIFY(goo->hasUnicodeMarker()); +QCOMPARE(goo->getLength(), string.length() * 2 + 2); +QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, goo->getLength() - 2)); +} delete goo; } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-page.cc |8 ++-- qt6/src/poppler-page.cc |8 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) New commits: commit 42dde686bf5a674401850b2d3fdd2bc7467e9a66 Author: Albert Astals Cid Date: Mon Mar 22 00:03:59 2021 +0100 qt: Fix memory leak when QImage constructor "fails" diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 9f681722..c433ada4 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -1,7 +1,7 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Brad Hards - * Copyright (C) 2005-2020, Albert Astals Cid + * Copyright (C) 2005-2021, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2008 Carlos Garcia Campos @@ -154,7 +154,11 @@ public: if (takeImageData) { // Construct a Qt image holding (and also owning) the raw bitmap data. -return QImage(data, bw, bh, brs, format, gfree, data); +QImage i(data, bw, bh, brs, format, gfree, data); +if (i.isNull()) { +gfree(data); +} +return i; } else { return QImage(data, bw, bh, brs, format).copy(); } diff --git a/qt6/src/poppler-page.cc b/qt6/src/poppler-page.cc index 0ad6c013..f1f4116c 100644 --- a/qt6/src/poppler-page.cc +++ b/qt6/src/poppler-page.cc @@ -1,7 +1,7 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Brad Hards - * Copyright (C) 2005-2020, Albert Astals Cid + * Copyright (C) 2005-2021, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2008 Carlos Garcia Campos @@ -154,7 +154,11 @@ public: if (takeImageData) { // Construct a Qt image holding (and also owning) the raw bitmap data. -return QImage(data, bw, bh, brs, format, gfree, data); +QImage i(data, bw, bh, brs, format, gfree, data); +if (i.isNull()) { +gfree(data); +} +return i; } else { return QImage(data, bw, bh, brs, format).copy(); } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-qiodeviceoutstream.cc |8 qt6/src/poppler-qiodeviceoutstream.cc |8 2 files changed, 8 insertions(+), 8 deletions(-) New commits: commit 222f96edc379d94661f5cab4c22c8cc9122d6e21 Author: Albert Astals Cid Date: Mon Jan 18 00:33:49 2021 +0100 qt: Fix regression in QIODeviceOutStream + MSVC vsnprintf actually works fine than qvsnprintf on MSVC nowadays so use that diff --git a/qt5/src/poppler-qiodeviceoutstream.cc b/qt5/src/poppler-qiodeviceoutstream.cc index d6ee0cdb..13941914 100644 --- a/qt5/src/poppler-qiodeviceoutstream.cc +++ b/qt5/src/poppler-qiodeviceoutstream.cc @@ -1,7 +1,7 @@ /* poppler-qiodevicestream.cc: Qt5 interface to poppler * Copyright (C) 2008, Pino Toscano * Copyright (C) 2013 Adrian Johnson - * Copyright (C) 2020 Albert Astals Cid + * Copyright (C) 2020, 2021 Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,11 +42,11 @@ void QIODeviceOutStream::put(char c) m_device->putChar(c); } -static int poppler_qvasprintf(char **buf_ptr, const char *format, va_list ap) +static int poppler_vasprintf(char **buf_ptr, const char *format, va_list ap) { va_list ap_copy; va_copy(ap_copy, ap); -const size_t size = qvsnprintf(nullptr, 0, format, ap_copy) + 1; +const size_t size = vsnprintf(nullptr, 0, format, ap_copy) + 1; va_end(ap_copy); *buf_ptr = new char[size]; @@ -58,7 +58,7 @@ void QIODeviceOutStream::printf(const char *format, ...) va_list ap; va_start(ap, format); char *buf; -const size_t bufsize = poppler_qvasprintf(&buf, format, ap); +const size_t bufsize = poppler_vasprintf(&buf, format, ap); va_end(ap); m_device->write(buf, bufsize); delete[] buf; diff --git a/qt6/src/poppler-qiodeviceoutstream.cc b/qt6/src/poppler-qiodeviceoutstream.cc index c9c61e33..171f7399 100644 --- a/qt6/src/poppler-qiodeviceoutstream.cc +++ b/qt6/src/poppler-qiodeviceoutstream.cc @@ -1,7 +1,7 @@ /* poppler-qiodevicestream.cc: Qt6 interface to poppler * Copyright (C) 2008, Pino Toscano * Copyright (C) 2013 Adrian Johnson - * Copyright (C) 2020 Albert Astals Cid + * Copyright (C) 2020, 2021 Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,11 +42,11 @@ void QIODeviceOutStream::put(char c) m_device->putChar(c); } -static int poppler_qvasprintf(char **buf_ptr, const char *format, va_list ap) +static int poppler_vasprintf(char **buf_ptr, const char *format, va_list ap) { va_list ap_copy; va_copy(ap_copy, ap); -const size_t size = qvsnprintf(nullptr, 0, format, ap_copy) + 1; +const size_t size = vsnprintf(nullptr, 0, format, ap_copy) + 1; va_end(ap_copy); *buf_ptr = new char[size]; @@ -58,7 +58,7 @@ void QIODeviceOutStream::printf(const char *format, ...) va_list ap; va_start(ap, format); char *buf; -const size_t bufsize = poppler_qvasprintf(&buf, format, ap); +const size_t bufsize = poppler_vasprintf(&buf, format, ap); va_end(ap); m_device->write(buf, bufsize); delete[] buf; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-qt5.h |4 ++-- qt6/src/poppler-qt6.h |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit 051cae3b34226953aa0381f850e8e6eaa0b564bd Author: Albert Astals Cid Date: Sat Jan 16 00:11:37 2021 +0100 qt: Properly export NewSignatureData diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index f1b64a9e..2d879f78 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -1,7 +1,7 @@ /* poppler-qt.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2007, Brad Hards - * Copyright (C) 2005-2015, 2017-2020, Albert Astals Cid + * Copyright (C) 2005-2015, 2017-2021, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2009 Shawn Rutledge @@ -2140,7 +2140,7 @@ public: * - border and background color * \since 21.01 */ -class NewSignatureData +class POPPLER_QT5_EXPORT NewSignatureData { public: NewSignatureData(); diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index 42b3cb1a..5e34dcce 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -1,7 +1,7 @@ /* poppler-qt.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2007, Brad Hards - * Copyright (C) 2005-2015, 2017-2020, Albert Astals Cid + * Copyright (C) 2005-2015, 2017-2021, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2009 Shawn Rutledge @@ -1958,7 +1958,7 @@ public: * - border and background color * \since 21.01 */ -class NewSignatureData +class POPPLER_QT6_EXPORT NewSignatureData { public: NewSignatureData(); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-qiodeviceoutstream.cc | 20 +++- qt6/src/poppler-qiodeviceoutstream.cc | 20 +++- 2 files changed, 30 insertions(+), 10 deletions(-) New commits: commit 8846eb5d2e1466cf0aaa1f38d5452b60c47bd9dc Author: Albert Astals Cid Date: Wed Dec 30 17:37:41 2020 +0100 QIODeviceOutStream: allocate memory dynamically Instead of using a fixed size array. I've only seen this being problematic in oss-fuzz created files, but I don't see why an actual file wouldn't create issues here too, so even if this is a bit slower, be on the safe side. diff --git a/qt5/src/poppler-qiodeviceoutstream.cc b/qt5/src/poppler-qiodeviceoutstream.cc index 002bdb00..d6ee0cdb 100644 --- a/qt5/src/poppler-qiodeviceoutstream.cc +++ b/qt5/src/poppler-qiodeviceoutstream.cc @@ -1,6 +1,7 @@ /* poppler-qiodevicestream.cc: Qt5 interface to poppler * Copyright (C) 2008, Pino Toscano * Copyright (C) 2013 Adrian Johnson + * Copyright (C) 2020 Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,8 +24,6 @@ #include -#define QIODeviceOutStreamBufSize 8192 - namespace Poppler { QIODeviceOutStream::QIODeviceOutStream(QIODevice *device) : m_device(device) { } @@ -43,15 +42,26 @@ void QIODeviceOutStream::put(char c) m_device->putChar(c); } +static int poppler_qvasprintf(char **buf_ptr, const char *format, va_list ap) +{ +va_list ap_copy; +va_copy(ap_copy, ap); +const size_t size = qvsnprintf(nullptr, 0, format, ap_copy) + 1; +va_end(ap_copy); +*buf_ptr = new char[size]; + +return qvsnprintf(*buf_ptr, size, format, ap); +} + void QIODeviceOutStream::printf(const char *format, ...) { va_list ap; va_start(ap, format); -char buf[QIODeviceOutStreamBufSize]; -size_t bufsize = 0; -bufsize = qvsnprintf(buf, QIODeviceOutStreamBufSize - 1, format, ap); +char *buf; +const size_t bufsize = poppler_qvasprintf(&buf, format, ap); va_end(ap); m_device->write(buf, bufsize); +delete[] buf; } } diff --git a/qt6/src/poppler-qiodeviceoutstream.cc b/qt6/src/poppler-qiodeviceoutstream.cc index e300fe0d..c9c61e33 100644 --- a/qt6/src/poppler-qiodeviceoutstream.cc +++ b/qt6/src/poppler-qiodeviceoutstream.cc @@ -1,6 +1,7 @@ /* poppler-qiodevicestream.cc: Qt6 interface to poppler * Copyright (C) 2008, Pino Toscano * Copyright (C) 2013 Adrian Johnson + * Copyright (C) 2020 Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,8 +24,6 @@ #include -#define QIODeviceOutStreamBufSize 8192 - namespace Poppler { QIODeviceOutStream::QIODeviceOutStream(QIODevice *device) : m_device(device) { } @@ -43,15 +42,26 @@ void QIODeviceOutStream::put(char c) m_device->putChar(c); } +static int poppler_qvasprintf(char **buf_ptr, const char *format, va_list ap) +{ +va_list ap_copy; +va_copy(ap_copy, ap); +const size_t size = qvsnprintf(nullptr, 0, format, ap_copy) + 1; +va_end(ap_copy); +*buf_ptr = new char[size]; + +return qvsnprintf(*buf_ptr, size, format, ap); +} + void QIODeviceOutStream::printf(const char *format, ...) { va_list ap; va_start(ap, format); -char buf[QIODeviceOutStreamBufSize]; -size_t bufsize = 0; -bufsize = qvsnprintf(buf, QIODeviceOutStreamBufSize - 1, format, ap); +char *buf; +const size_t bufsize = poppler_qvasprintf(&buf, format, ap); va_end(ap); m_device->write(buf, bufsize); +delete[] buf; } } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-document.cc |7 +-- qt6/src/poppler-document.cc |7 +-- 2 files changed, 10 insertions(+), 4 deletions(-) New commits: commit 72827b0c11dc18a7eb6fce89c0e9877a8f3fc820 Author: Albert Astals Cid Date: Tue Dec 29 23:50:05 2020 +0100 qt: Account for catalog potentially lacking AcroForm diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index b6c7624a..0a2a6ce4 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -801,9 +801,12 @@ Document::FormType Document::formType() const QVector Document::formCalculateOrder() const { -QVector result; - Form *form = m_doc->doc->getCatalog()->getForm(); +if (!form) { +return {}; +} + +QVector result; const std::vector &calculateOrder = form->getCalculateOrder(); for (Ref r : calculateOrder) { FormWidget *w = form->findWidgetByRef(r); diff --git a/qt6/src/poppler-document.cc b/qt6/src/poppler-document.cc index 9b5edc62..1a13d46d 100644 --- a/qt6/src/poppler-document.cc +++ b/qt6/src/poppler-document.cc @@ -783,9 +783,12 @@ Document::FormType Document::formType() const QVector Document::formCalculateOrder() const { -QVector result; - Form *form = m_doc->doc->getCatalog()->getForm(); +if (!form) { +return {}; +} + +QVector result; const std::vector &calculateOrder = form->getCalculateOrder(); for (Ref r : calculateOrder) { FormWidget *w = form->findWidgetByRef(r); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.cc |2 +- qt6/src/poppler-annotation.cc |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit c71de2436a390f6d6db4f8d0f29887bfa574df78 Author: Albert Astals Cid Date: Fri Dec 18 14:04:11 2020 +0100 qt: Mark file internal function as static diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index e3e6f9f8..58b06c8f 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -200,7 +200,7 @@ void AnnotationPrivate::flushBaseAnnotationProperties() // Returns matrix to convert from user space coords (oriented according to the // specified rotation) to normalized coords -void fillNormalizationMTX(::Page *pdfPage, double MTX[6], int pageRotation) +static void fillNormalizationMTX(::Page *pdfPage, double MTX[6], int pageRotation) { Q_ASSERT(pdfPage); diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc index 609130b6..4b31cece 100644 --- a/qt6/src/poppler-annotation.cc +++ b/qt6/src/poppler-annotation.cc @@ -136,7 +136,7 @@ void AnnotationPrivate::flushBaseAnnotationProperties() // Returns matrix to convert from user space coords (oriented according to the // specified rotation) to normalized coords -void fillNormalizationMTX(::Page *pdfPage, double MTX[6], int pageRotation) +static void fillNormalizationMTX(::Page *pdfPage, double MTX[6], int pageRotation) { Q_ASSERT(pdfPage); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-form.h | 14 +++--- qt5/src/poppler-qt5.h |4 ++-- qt6/src/poppler-form.h | 14 +++--- qt6/src/poppler-qt6.h |4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) New commits: commit 6133bc0f3a2cb3b2c185c81367cbac9d72f11bbd Author: Albert Astals Cid Date: Fri Dec 18 13:53:46 2020 +0100 qt: The signing code will be in 21.01 not 20.12 diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index 0d1b23cb..05231931 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -563,7 +563,7 @@ public: /** The certificate internal database nickname - \since 20.12 + \since 21.01 */ QString nickName() const; @@ -610,7 +610,7 @@ public: /** Checks if the given password is the correct one for this certificate - \since 20.12 + \since 21.01 */ bool checkPassword(const QString &password) const; @@ -825,35 +825,35 @@ private: /** Returns is poppler was compiled with NSS support - \since 20.12 + \since 21.01 */ bool POPPLER_QT5_EXPORT hasNSSSupport(); /** Return vector of suitable signing certificates - \since 20.12 + \since 21.01 */ QVector POPPLER_QT5_EXPORT getAvailableSigningCertificates(); /** Gets the current NSS CertDB directory - \since 20.12 + \since 21.01 */ QString POPPLER_QT5_EXPORT getNSSDir(); /** Set a custom NSS CertDB directory. Needs to be called before doing any other signature operation - \since 20.12 + \since 21.01 */ void POPPLER_QT5_EXPORT setNSSDir(const QString &pathURL); /** Sets the callback for NSS password requests - \since 20.12 + \since 21.01 */ void POPPLER_QT5_EXPORT setNSSPasswordCallback(const std::function &f); } diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 21ae1657..f1b64a9e 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -2138,7 +2138,7 @@ public: * - text that will be shown inside the rect * - font size and color * - border and background color - * \since 20.12 + * \since 21.01 */ class NewSignatureData { @@ -2205,7 +2205,7 @@ public: \return whether the signing succeeded -\since 20.12 +\since 21.01 */ bool sign(const NewSignatureData &data); diff --git a/qt6/src/poppler-form.h b/qt6/src/poppler-form.h index dfc8142a..9dbc6699 100644 --- a/qt6/src/poppler-form.h +++ b/qt6/src/poppler-form.h @@ -529,7 +529,7 @@ public: /** The certificate internal database nickname - \since 20.12 + \since 21.01 */ QString nickName() const; @@ -576,7 +576,7 @@ public: /** Checks if the given password is the correct one for this certificate - \since 20.12 + \since 21.01 */ bool checkPassword(const QString &password) const; @@ -774,35 +774,35 @@ private: /** Returns is poppler was compiled with NSS support - \since 20.12 + \since 21.01 */ bool POPPLER_QT6_EXPORT hasNSSSupport(); /** Return vector of suitable signing certificates - \since 20.12 + \since 21.01 */ QVector POPPLER_QT6_EXPORT getAvailableSigningCertificates(); /** Gets the current NSS CertDB directory - \since 20.12 + \since 21.01 */ QString POPPLER_QT6_EXPORT getNSSDir(); /** Set a custom NSS CertDB directory. Needs to be called before doing any other signature operation - \since 20.12 + \since 21.01 */ void POPPLER_QT6_EXPORT setNSSDir(const QString &pathURL); /** Sets the callback for NSS password requests - \since 20.12 + \since 21.01 */ void POPPLER_QT6_EXPORT setNSSPasswordCallback(const std::function &f); } diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index 229f6c93..42b3cb1a 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -1956,7 +1956,7 @@ public: * - text that will be shown inside the rect * - font size and color * - border and background color - * \since 20.12 + * \since 21.01 */ class NewSignatureData { @@ -2023,7 +2023,7 @@ public: \return whether the signing succeeded -\since 20.12 +\since 21.01 */ bool sign(const NewSignatureData &data); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation.cc |8 1 file changed, 8 insertions(+) New commits: commit c48f469cd6755fb9fea7870d6b64aaf891cb2012 Author: Albert Astals Cid Date: Sat Nov 28 00:55:49 2020 +0100 qt5: Fix division by 0 in broken files oss-fuzz/27983 diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index f30e4d55..43ded2b8 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -298,6 +298,14 @@ PDFRectangle AnnotationPrivate::boundaryToPdfRectangle(const QRectF &r, int rFla { Q_ASSERT(pdfPage); +const double w = pdfPage->getCropWidth(); +const double h = pdfPage->getCropHeight(); + +if (w == 0 || h == 0) { +// page is broken, there's nothing to transform +return {}; +} + const int pageRotate = pdfPage->getRotate(); double MTX[6]; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-private.cc |2 +- qt6/src/poppler-private.cc |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit c09f01b1be772b39b3d160ebdd6d09eac06e375d Author: Albert Astals Cid Date: Tue Aug 25 23:13:32 2020 +0200 Update (C) diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index 84cc8c56..5b30f19c 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -1,6 +1,6 @@ /* poppler-private.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2006, 2011, 2015, 2017-2019 by Albert Astals Cid + * Copyright (C) 2006, 2011, 2015, 2017-2020 by Albert Astals Cid * Copyright (C) 2008, 2010, 2011, 2014 by Pino Toscano * Copyright (C) 2013 by Thomas Freitag * Copyright (C) 2013 Adrian Johnson diff --git a/qt6/src/poppler-private.cc b/qt6/src/poppler-private.cc index e7566500..c60876da 100644 --- a/qt6/src/poppler-private.cc +++ b/qt6/src/poppler-private.cc @@ -1,6 +1,6 @@ /* poppler-private.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2006, 2011, 2015, 2017-2019 by Albert Astals Cid + * Copyright (C) 2006, 2011, 2015, 2017-2020 by Albert Astals Cid * Copyright (C) 2008, 2010, 2011, 2014 by Pino Toscano * Copyright (C) 2013 by Thomas Freitag * Copyright (C) 2013 Adrian Johnson ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests qt6/src qt6/tests
qt5/src/poppler-private.cc |4 ++-- qt5/tests/check_strings.cpp |9 + qt6/src/poppler-private.cc |4 ++-- qt6/tests/check_strings.cpp |9 + 4 files changed, 22 insertions(+), 4 deletions(-) New commits: commit 2b8692a5a52a8cd997e70f7912ad7cedeb34891b Author: Albert Astals Cid Date: Tue Aug 25 23:05:51 2020 +0200 qt: Clean as many null characters from the end as possible Not only one Fixes KDE bug #425791 diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index 827a6345..84cc8c56 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -77,8 +77,8 @@ QString unicodeToQString(const Unicode *u, int len) { const UnicodeMap *utf8Map = globalParams->getUtf8Map(); -// ignore the last character if it is 0x0 -if ((len > 0) && (u[len - 1] == 0)) { +// ignore the last characters if they are 0x0 +while ((len > 0) && (u[len - 1] == 0)) { --len; } diff --git a/qt5/tests/check_strings.cpp b/qt5/tests/check_strings.cpp index 948171f6..4c996c4f 100644 --- a/qt5/tests/check_strings.cpp +++ b/qt5/tests/check_strings.cpp @@ -114,6 +114,15 @@ void TestStrings::check_unicodeToQString_data() u[2] = 0x0; QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + 0") << u << l << QStringLiteral("封面"); } +{ +const int l = 4; +Unicode *u = new Unicode[l]; +u[0] = 0x5c01; +u[1] = 0x9762; +u[2] = 0x0; +u[3] = 0x0; +QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + two 0") << u << l << QStringLiteral("封面"); +} } void TestStrings::check_unicodeToQString() diff --git a/qt6/src/poppler-private.cc b/qt6/src/poppler-private.cc index 44a9a6dc..e7566500 100644 --- a/qt6/src/poppler-private.cc +++ b/qt6/src/poppler-private.cc @@ -77,8 +77,8 @@ QString unicodeToQString(const Unicode *u, int len) { const UnicodeMap *utf8Map = globalParams->getUtf8Map(); -// ignore the last character if it is 0x0 -if ((len > 0) && (u[len - 1] == 0)) { +// ignore the last characters if they are 0x0 +while ((len > 0) && (u[len - 1] == 0)) { --len; } diff --git a/qt6/tests/check_strings.cpp b/qt6/tests/check_strings.cpp index fa7c6bab..c887105c 100644 --- a/qt6/tests/check_strings.cpp +++ b/qt6/tests/check_strings.cpp @@ -114,6 +114,15 @@ void TestStrings::check_unicodeToQString_data() u[2] = 0x0; QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + 0") << u << l << QStringLiteral("封面"); } +{ +const int l = 4; +Unicode *u = new Unicode[l]; +u[0] = 0x5c01; +u[1] = 0x9762; +u[2] = 0x0; +u[3] = 0x0; +QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + two 0") << u << l << QStringLiteral("封面"); +} } void TestStrings::check_unicodeToQString() ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt6/src
qt5/src/poppler-annotation.h |1 + qt6/src/poppler-annotation.h |3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) New commits: commit 150e6efa0e9495ffceffbdfbff795bc9ccdf45f7 Author: Albert Astals Cid Date: Fri Aug 21 15:32:23 2020 +0200 qt: Document TextAnnotation::inplaceAlign diff --git a/qt5/src/poppler-annotation.h b/qt5/src/poppler-annotation.h index 58088199..f85c9a0d 100644 --- a/qt5/src/poppler-annotation.h +++ b/qt5/src/poppler-annotation.h @@ -522,6 +522,7 @@ public: /// \since 0.69 void setTextColor(const QColor &color); +// 0:left, 1:center, 2:right int inplaceAlign() const; void setInplaceAlign(int align); diff --git a/qt6/src/poppler-annotation.h b/qt6/src/poppler-annotation.h index 15f94e1b..701d6d3b 100644 --- a/qt6/src/poppler-annotation.h +++ b/qt6/src/poppler-annotation.h @@ -1,5 +1,5 @@ /* poppler-annotation.h: qt interface to poppler - * Copyright (C) 2006-2008, 2012, 2013, 2018, 2019 Albert Astals Cid + * Copyright (C) 2006-2008, 2012, 2013, 2018-2020 Albert Astals Cid * Copyright (C) 2006, 2008 Pino Toscano * Copyright (C) 2007, Brad Hards * Copyright (C) 2010, Philip Lorenz @@ -472,6 +472,7 @@ public: QColor textColor() const; void setTextColor(const QColor &color); +// 0:left, 1:center, 2:right int inplaceAlign() const; void setInplaceAlign(int align); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation.h |8 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit 3a6c77bc21e4982619ade995564466fbc543d3ac Author: Albert Astals Cid Date: Mon Jul 13 22:16:36 2020 +0200 qt5: Mark AnnotationUtils as deprecated, it's gone in qt6 diff --git a/qt5/src/poppler-annotation.h b/qt5/src/poppler-annotation.h index 1ad9f7c7..58088199 100644 --- a/qt5/src/poppler-annotation.h +++ b/qt5/src/poppler-annotation.h @@ -1,5 +1,5 @@ /* poppler-annotation.h: qt interface to poppler - * Copyright (C) 2006-2008, 2012, 2013, 2018, 2019 Albert Astals Cid + * Copyright (C) 2006-2008, 2012, 2013, 2018-2020 Albert Astals Cid * Copyright (C) 2006, 2008 Pino Toscano * Copyright (C) 2007, Brad Hards * Copyright (C) 2010, Philip Lorenz @@ -80,19 +80,19 @@ public: * \returns a pointer to the complete Annotation or 0 if element is * invalid. */ -static Annotation *createAnnotation(const QDomElement &annElement); +Q_DECL_DEPRECATED static Annotation *createAnnotation(const QDomElement &annElement); /** * Save the Annotation \p ann as a child of \p annElement taking * care of saving all revisions if \p ann has any. */ -static void storeAnnotation(const Annotation *ann, QDomElement &annElement, QDomDocument &document); +Q_DECL_DEPRECATED static void storeAnnotation(const Annotation *ann, QDomElement &annElement, QDomDocument &document); /** * Returns an element called \p name from the direct children of * \p parentNode or a null element if not found. */ -static QDomElement findChildElement(const QDomNode &parentNode, const QString &name); +Q_DECL_DEPRECATED static QDomElement findChildElement(const QDomNode &parentNode, const QString &name); }; /** ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-document.cc | 16 +++ qt5/src/poppler-form.cc | 46 ++-- qt5/src/poppler-private.h |2 - qt5/src/poppler-qt5.h | 11 ++ 4 files changed, 52 insertions(+), 23 deletions(-) New commits: commit 12eeb475fbf3ee0bb43b96ea79d46a426ba809e7 Author: Albert Astals Cid Date: Fri Apr 10 00:31:40 2020 +0200 qt5: Add Document::signatures Returns all the signatures of a given document, this is better than iterating over all the pages getting the form fields that are of signature type since there's documents with signatures not associated to a given page Fixes part of #895 diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index e1b8d05b..cba9da39 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -48,6 +48,7 @@ #include #include +#include "poppler-form.h" #include "poppler-private.h" #include "poppler-page-private.h" #include "poppler-outline-private.h" @@ -829,6 +830,21 @@ namespace Poppler { return result; } +QVector Document::signatures() const +{ +QVector result; + +const std::vector<::FormFieldSignature*> pSignatures = m_doc->doc->getSignatureFields(); + +for (::FormFieldSignature *pSignature : pSignatures) { +::FormWidget *fw = pSignature->getWidget(0); +::Page *p = m_doc->doc->getPage(fw->getWidgetAnnotation()->getPageNum()); +result.append(new FormFieldSignature(m_doc, p, static_cast(fw))); +} + +return result; +} + QDateTime convertDate( const char *dateString ) { int year, mon, day, hour, min, sec, tzHours, tzMins; diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 1ed419c8..19adbd7b 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -105,29 +105,31 @@ FormFieldIcon::~FormFieldIcon() FormField::FormField(std::unique_ptr dd) : m_formData(std::move(dd)) { - const int rotation = m_formData->page->getRotate(); - // reading the coords - double left, top, right, bottom; - m_formData->fm->getRect(&left, &bottom, &right, &top); - // build a normalized transform matrix for this page at 100% scale - GfxState gfxState( 72.0, 72.0, m_formData->page->getCropBox(), rotation, true ); - const double * gfxCTM = gfxState.getCTM(); - double MTX[6]; - double pageWidth = m_formData->page->getCropWidth(); - double pageHeight = m_formData->page->getCropHeight(); - // landscape and seascape page rotation: be sure to use the correct (== rotated) page size - if (((rotation / 90) % 2) == 1) -qSwap(pageWidth, pageHeight); - for ( int i = 0; i < 6; i+=2 ) - { -MTX[i] = gfxCTM[i] / pageWidth; -MTX[i+1] = gfxCTM[i+1] / pageHeight; + if (m_formData->page) { +const int rotation = m_formData->page->getRotate(); +// reading the coords +double left, top, right, bottom; +m_formData->fm->getRect(&left, &bottom, &right, &top); +// build a normalized transform matrix for this page at 100% scale +GfxState gfxState( 72.0, 72.0, m_formData->page->getCropBox(), rotation, true ); +const double * gfxCTM = gfxState.getCTM(); +double MTX[6]; +double pageWidth = m_formData->page->getCropWidth(); +double pageHeight = m_formData->page->getCropHeight(); +// landscape and seascape page rotation: be sure to use the correct (== rotated) page size +if (((rotation / 90) % 2) == 1) + qSwap(pageWidth, pageHeight); +for ( int i = 0; i < 6; i+=2 ) +{ + MTX[i] = gfxCTM[i] / pageWidth; + MTX[i+1] = gfxCTM[i+1] / pageHeight; +} +QPointF topLeft; +XPDFReader::transform( MTX, qMin( left, right ), qMax( top, bottom ), topLeft ); +QPointF bottomRight; +XPDFReader::transform( MTX, qMax( left, right ), qMin( top, bottom ), bottomRight ); +m_formData->box = QRectF(topLeft, QSizeF(bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y())); } - QPointF topLeft; - XPDFReader::transform( MTX, qMin( left, right ), qMax( top, bottom ), topLeft ); - QPointF bottomRight; - XPDFReader::transform( MTX, qMax( left, right ), qMin( top, bottom ), bottomRight ); - m_formData->box = QRectF(topLeft, QSizeF(bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y())); } FormField::~FormField() = default; diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index 03312daa..7e612ba1 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -256,7 +256,7 @@ namespace Poppler { } DocumentData *doc; - ::Page *page; + ::Page *page; // Note for some signatures it can be null since there's signatures that don't belong to a given page ::FormWidget *fm; QRectF box; static POPPLER_QT5_EXPORT ::FormWidget *getFormWidget( const FormField *f ); diff --git a/qt5/src/popp
[poppler] qt5/src qt5/tests
qt5/src/ArthurOutputDev.cc |5 +- qt5/tests/CMakeLists.txt |1 qt5/tests/check_stroke_opacity.cpp | 73 + 3 files changed, 77 insertions(+), 2 deletions(-) New commits: commit 5ccc03f13b22c11d38f349b95c6d50dcfbaedb4b Author: Oliver Sander Date: Wed Apr 15 15:40:38 2020 +0200 [arthur] Set the opacity when filling with axial gradients diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 9469f82e..d535a8fa 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -767,6 +767,7 @@ bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, // Number of color space components auto nComps = shading->getColorSpace()->getNComps(); + auto opacity = state->getFillOpacity(); // Helper function to test two color objects for 'almost-equality' auto isSameGfxColor = [&nComps,&colorDelta](const GfxColor &colorA, const GfxColor &colorB) @@ -807,7 +808,7 @@ bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, GfxRGB rgb; shading->getColorSpace()->getRGB(&color0, &rgb); - QColor qColor(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b)); + QColor qColor(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b), dblToByte(opacity)); gradient.setColorAt(0,qColor); // Look for more relevant parameter values by bisection @@ -847,7 +848,7 @@ bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, // set the color shading->getColorSpace()->getRGB(&color1, &rgb); -qColor.setRgb(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b)); +qColor.setRgb(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b), dblToByte(opacity)); gradient.setColorAt((ta[j] - tMin)/(tMax - tMin), qColor); // Move to the next parameter region diff --git a/qt5/tests/CMakeLists.txt b/qt5/tests/CMakeLists.txt index 5abcbc45..b01d0835 100644 --- a/qt5/tests/CMakeLists.txt +++ b/qt5/tests/CMakeLists.txt @@ -72,6 +72,7 @@ qt5_add_qtest(check_qt5_actualtext check_actualtext.cpp) qt5_add_qtest(check_qt5_lexer check_lexer.cpp) qt5_add_qtest(check_qt5_goostring check_goostring.cpp) qt5_add_qtest(check_qt5_object check_object.cpp) +qt5_add_qtest(check_qt5_stroke_opacity check_stroke_opacity.cpp) qt5_add_qtest(check_qt5_utf_conversion check_utf_conversion.cpp) qt5_add_qtest(check_qt5_outline check_outline.cpp) if (NOT WIN32) diff --git a/qt5/tests/check_stroke_opacity.cpp b/qt5/tests/check_stroke_opacity.cpp new file mode 100644 index ..e278c16e --- /dev/null +++ b/qt5/tests/check_stroke_opacity.cpp @@ -0,0 +1,73 @@ +#include + +#include +#include +#include + +#include + +// Unit tests for rendering axial shadings without full opacity +class TestStrokeOpacity : public QObject +{ +Q_OBJECT +public: +TestStrokeOpacity(QObject *parent = nullptr) : QObject(parent) { } +private slots: +void checkStrokeOpacity_data(); +void checkStrokeOpacity(); +}; + +void TestStrokeOpacity::checkStrokeOpacity_data() +{ +QTest::addColumn("backendType"); + +QTest::newRow("splash") << (int)Poppler::Document::SplashBackend; +QTest::newRow("qpainter") << (int)Poppler::Document::ArthurBackend; +} + +void TestStrokeOpacity::checkStrokeOpacity() +{ +QFETCH(int, backendType); + +auto doc = std::unique_ptr(Poppler::Document::load(TESTDATADIR "/unittestcases/stroke-alpha-pattern.pdf")); +QVERIFY(doc!=nullptr); + +doc->setRenderBackend((Poppler::Document::RenderBackend)backendType); + +// BUG: For some reason splash gets the opacity wrong when antialiasing is switched off +if (backendType== (int)Poppler::Document::SplashBackend) { +doc->setRenderHint(Poppler::Document::Antialiasing, true); +} + +const auto page = std::unique_ptr(doc->page(0)); +QVERIFY(page!=nullptr); + +// Render (at low resolution and with cropped marging) +QImage image = page->renderToImage(36,36,40,50,200,230); + +// The actual tests start here + +// Splash and QPainter backends implement shadings slightly differently, +// hence we cannot expect to get precisely the same colors. +// Allow a tolerance up to '3' per channel. +int tolerance = 3; +auto approximatelyEqual = [&tolerance](QRgb c0, const QColor& c1) +{ + return std::abs(qAlpha(c0) - c1.alpha() ) < tolerance + && std::abs(qRed(c0) - c1.red() ) < tolerance + && std::abs(qGreen(c0) - c1.green() ) < tolerance + && std::abs(qBlue(c0) - c1.blue() ) < tolerance; +}; + +// At the lower left of the test document is a square with an axial shading, +// which should be rendered with opacity 0.25. +// Check that with a sample pixel +auto pixel = image.pixel(70,160); + +QVERIFY(approximatelyEqual(pixel, QColor(253,233,196,255))); +} + +QTEST_GUILESS_MAIN(TestStrokeOpacity) + +#include "check_stroke_opacity.moc" + __
[poppler] qt5/src
qt5/src/ArthurOutputDev.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 9cf9356d334c6a1fa8bc3f1466778541b8f9c276 Author: Albert Astals Cid Date: Sat Apr 11 00:04:02 2020 +0200 Update (C) of last commit diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index b380cb5d..046f51dd 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -20,7 +20,7 @@ // Copyright (C) 2011 Andreas Hartmetz // Copyright (C) 2013 Thomas Freitag // Copyright (C) 2013 Mihai Niculescu -// Copyright (C) 2017, 2018 Oliver Sander +// Copyright (C) 2017, 2018, 2020 Oliver Sander // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |6 +++--- qt5/src/ArthurOutputDev.h | 14 ++ qt5/src/poppler-page.cc| 19 +++ 3 files changed, 24 insertions(+), 15 deletions(-) New commits: commit 162fdf21717a92428f4fc0c1bf7e86610b9ea703 Author: Oliver Sander Date: Fri Apr 10 22:01:00 2020 + [arthur] Fix font hinting Previously, the ArthurOutputDev would always use the Qt default value for the QFont hinting preference. At the same time, it contained a custom enum type with various hinting levels that didn't do anything at all. This patch removes the custom enum, uses QFont::HintingPreference instead, and actually passes the chosen value to the font renderer. diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 3d84e75a..9469f82e 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -150,7 +150,7 @@ const QPicture& ArthurType3Font::getGlyph(int gid) const ArthurOutputDev::ArthurOutputDev(QPainter *painter): m_lastTransparencyGroupPicture(nullptr), - m_fontHinting(NoHinting) + m_hintingPreference(QFont::PreferDefaultHinting) { m_painter.push(painter); m_currentBrush = QBrush(Qt::SolidPattern); @@ -481,7 +481,7 @@ void ArthurOutputDev::updateFont(GfxState *state) int fontDataLen; const char* fontData = gfxFont->readEmbFontFile(xref, &fontDataLen); -m_rawFont = new QRawFont(QByteArray(fontData, fontDataLen), fontSize); +m_rawFont = new QRawFont(QByteArray(fontData, fontDataLen), fontSize, m_hintingPreference); m_rawFontCache.insert(std::make_pair(fontID,std::unique_ptr(m_rawFont))); // Free the font data, it was copied in the QByteArray constructor @@ -490,7 +490,7 @@ void ArthurOutputDev::updateFont(GfxState *state) } case gfxFontLocExternal:{ // font is in an external font file QString fontFile(fontLoc->path->c_str()); -m_rawFont = new QRawFont(fontFile, fontSize); +m_rawFont = new QRawFont(fontFile, fontSize, m_hintingPreference); m_rawFontCache.insert(std::make_pair(fontID,std::unique_ptr(m_rawFont))); break; } diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index b6285775..b380cb5d 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -55,23 +55,13 @@ class ArthurType3Font; class ArthurOutputDev: public OutputDev { public: - /** - * Describes how fonts are distorted (aka hinted) to fit the pixel grid. - * More hinting means sharper edges and less adherence to the true letter shapes. - */ - enum FontHinting { -NoHinting = 0, ///< Font shapes are left unchanged -SlightHinting, ///< Font shapes are distorted vertically only -FullHinting ///< Font shapes are distorted horizontally and vertically - }; - // Constructor. ArthurOutputDev(QPainter *painter ); // Destructor. ~ArthurOutputDev() override; - void setFontHinting(FontHinting hinting) { m_fontHinting = hinting; } + void setHintingPreference(QFont::HintingPreference hintingPreference) { m_hintingPreference = hintingPreference; } //- get info about output device @@ -195,7 +185,7 @@ private: // it here for later use in paintTransparencyGroup. QPicture* m_lastTransparencyGroupPicture; - FontHinting m_fontHinting; + QFont::HintingPreference m_hintingPreference; QPen m_currentPen; // The various stacks are used to implement the 'saveState' and 'restoreState' methods diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 30e03509..35bec6c9 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -511,6 +511,19 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, return renderToImage(xres, yres, x, y, w, h, rotate, partialUpdateCallback, shouldDoPartialUpdateCallback, nullptr, payload); } +// Translate the text hinting settings from poppler-speak to Qt-speak +static QFont::HintingPreference QFontHintingFromPopplerHinting(int renderHints) +{ + QFont::HintingPreference result = QFont::PreferNoHinting; + + if (renderHints & Document::TextHinting) + { +result = (renderHints & Document::TextSlightHinting) ? QFont::PreferVerticalHinting : QFont::PreferFullHinting; + } + + return result; +} + QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, ShouldAbortQueryFunc shouldAbortRenderCallback, const QVariant &payload) const { int rotation = (int)rotate * 90; @@ -604,6 +617,9 @@ QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w, QPainter painter(&tmpimg); QImageDumpingArthurOutputDev arthur_output(&painter, &tmpimg); + + arthur_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f19d6723313c0db1b63b8a04c0d2475422b875fb Author: Albert Astals Cid Date: Thu Mar 26 22:50:34 2020 +0100 Update (C) diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 3afe908a..3d84e75a 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -23,7 +23,7 @@ // Copyright (C) 2013 Thomas Freitag // Copyright (C) 2013 Dominik Haumann // Copyright (C) 2013 Mihai Niculescu -// Copyright (C) 2017, 2018 Oliver Sander +// Copyright (C) 2017, 2018, 2020 Oliver Sander // Copyright (C) 2017 Adrian Johnson // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich // Copyright (C) 2018 Adam Reichold ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |9 - 1 file changed, 8 insertions(+), 1 deletion(-) New commits: commit 5e1a83dbdc065504291528554cb11ab8fabeb5f6 Author: Oliver Sander Date: Wed Mar 25 21:14:34 2020 +0100 Avoid division by zero in updateLineDash Qt measures dash patterns in terms of line width. This means that you have to divide by the width, which doesn't work if the line width is 'cosmetic', i.e., zero. The Qt documentation states that this case should be treated as if the line width was 1 pixel. BUG: 695 diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 3ec78e06..3afe908a 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -268,10 +268,17 @@ void ArthurOutputDev::updateLineDash(GfxState *state) } QVector pattern(dashLength); + double scaling = state->getLineWidth(); + + // Negative line widths are not allowed, width 0 counts as 'one pixel width'. + if (scaling <= 0) { +scaling = 1.0; + } + for (int i = 0; i < dashLength; ++i) { // pdf measures the dash pattern in dots, but Qt uses the // line width as the unit. -pattern[i] = dashPattern[i] / state->getLineWidth(); +pattern[i] = dashPattern[i] / scaling; } m_currentPen.setDashPattern(pattern); m_currentPen.setDashOffset(dashStart); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-document.cc |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 8ed4623c3aad7899114ddb9754e303c97ce64e50 Author: Albert Astals Cid Date: Wed Feb 5 21:25:46 2020 +0100 Update (C) diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 8015eb09..e1b8d05b 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -1,7 +1,7 @@ /* poppler-document.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2008, Brad Hards - * Copyright (C) 2005-2010, 2012, 2013, 2015, 2017-2019, Albert Astals Cid + * Copyright (C) 2005-2010, 2012, 2013, 2015, 2017-2020, Albert Astals Cid * Copyright (C) 2006-2010, Pino Toscano * Copyright (C) 2010, 2011 Hib Eris * Copyright (C) 2012 Koji Otani ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-document.cc |1 + 1 file changed, 1 insertion(+) New commits: commit 0bdf0d31d99a7becb1e36b5503213fe777673acb Author: Albert Astals Cid Date: Thu Jan 30 22:27:55 2020 +0100 qt5: Fix loading from iodevice diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index bff01205..8015eb09 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -152,6 +152,7 @@ namespace Poppler { new GooString(ownerPassword.data()), new GooString(userPassword.data())); } + else { doc2 = new DocumentData(m_doc->m_filePath, new GooString(ownerPassword.data()), ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-page.cc |7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) New commits: commit 2816a3597f4accadcfe982673b501264e8bdee21 Author: Albert Astals Cid Date: Tue Jan 28 23:42:31 2020 +0100 qt5: fix search for "complex" characters poppler internals want ucs4 not unicode based on a patch by Alex Henrie diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index f40b00e6..9e08134a 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -1,7 +1,7 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Brad Hards - * Copyright (C) 2005-2019, Albert Astals Cid + * Copyright (C) 2005-2020, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2008 Carlos Garcia Campos @@ -373,10 +373,7 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo inline TextPage *PageData::prepareTextSearch(const QString &text, Page::Rotation rotate, QVector *u) { - const QChar * str = text.unicode(); - const int len = text.length(); - u->resize(len); - for (int i = 0; i < len; ++i) (*u)[i] = str[i].unicode(); + *u = text.toUcs4(); const int rotation = (int)rotate * 90; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests
qt5/src/poppler-form.cc |2 +- qt5/tests/check_forms.cpp | 18 ++ 2 files changed, 19 insertions(+), 1 deletion(-) New commits: commit dd0ea681efc1e0a476803be1260f7a7691c26534 Author: David García Garzón Date: Sun Jan 5 23:35:51 2020 + qt5: Fix FormField::name encoding Also add a test for it diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 26b583ba..cab25af6 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -147,7 +147,7 @@ QString FormField::name() const QString name; if (const GooString *goo = m_formData->fm->getPartialName()) { -name = QString::fromLatin1(goo->c_str()); +name = UnicodeParsedString(goo); } return name; } diff --git a/qt5/tests/check_forms.cpp b/qt5/tests/check_forms.cpp index ac60fdc4..fb7c3baf 100644 --- a/qt5/tests/check_forms.cpp +++ b/qt5/tests/check_forms.cpp @@ -16,6 +16,7 @@ private slots: void testSetIcon();// Test that setIcon will always be valid. void testSetPrintable(); void testSetAppearanceText(); +void testUnicodeFieldAttributes(); }; void TestForms::testCheckbox() @@ -208,5 +209,22 @@ void TestForms::testSetAppearanceText() QCOMPARE( nTextForms, 5 ); } +void TestForms::testUnicodeFieldAttributes() +{ +QScopedPointer< Poppler::Document > document(Poppler::Document::load(TESTDATADIR "/unittestcases/fieldWithUtf16Names.pdf")); +QVERIFY( document ); + +QScopedPointer< Poppler::Page > page(document->page(0)); +QVERIFY( page ); + +QList forms = page->formFields(); + + Poppler::FormField * field = forms.first(); + + QCOMPARE(field->name(), QStringLiteral("Tex")); + QCOMPARE(field->uiName(), QStringLiteral("Texto de ayuda")); +} + + QTEST_GUILESS_MAIN(TestForms) #include "check_forms.moc" ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-form.cc |1 + 1 file changed, 1 insertion(+) New commits: commit bc8250504b14655eb25d11336899bdcc032df18d Author: Albert Astals Cid Date: Sun Jan 5 22:32:55 2020 +0100 Update (C) diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 2f6948d4..26b583ba 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -10,6 +10,7 @@ * Copyright (C) 2018 Chinmoy Ranjan Pradhan * Copyright (C) 2018 Oliver Sander * Copyright (C) 2019 João Netto + * Copyright (C) 2020 David García Garzón * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-form.cc |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit a9ef3cb7dd991ab935ad08f75ae4fc85bb594c78 Author: David García Garzón Date: Sun Jan 5 19:53:04 2020 +0100 Accepting UTF-16 uiNames for form fields diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 5917e0a7..2f6948d4 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -173,7 +173,7 @@ QString FormField::uiName() const QString name; if (const GooString *goo = m_formData->fm->getAlternateUiName()) { -name = QString::fromLatin1(goo->c_str()); +name = UnicodeParsedString(goo); } return name; } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-link-private.h | 14 +++--- qt5/src/poppler-link.h |4 ++-- qt5/src/poppler-optcontent.cc | 10 +- qt5/src/poppler-page.cc|2 +- 4 files changed, 19 insertions(+), 11 deletions(-) New commits: commit 0053b82841d37077b9b22ea393bb807fbe53eb64 Author: Oliver Sander Date: Fri Jan 3 17:54:17 2020 +0100 Deep-copy the LinkOCGAction object The convertLinkActionToLink method deep-copies every poppler LinkAction object into a Link object as used by the Qt5 frontend. With one exception: LinkOCGState objects are not deep-copied, but pointers to them are stored instead. This makes for a memory management that is inconsistent, difficult to understand, and prone to memory errors. The present patch introduces deep-copying for LinkOCGState objects as well. diff --git a/qt5/src/poppler-link-private.h b/qt5/src/poppler-link-private.h index 766f1899..ed12f70b 100644 --- a/qt5/src/poppler-link-private.h +++ b/qt5/src/poppler-link-private.h @@ -20,6 +20,10 @@ #ifndef _POPPLER_LINK_PRIVATE_H_ #define _POPPLER_LINK_PRIVATE_H_ +#include + +#include "Link.h" + class LinkOCGState; namespace Poppler { @@ -56,13 +60,17 @@ public: class LinkOCGStatePrivate : public LinkPrivate { public: -LinkOCGStatePrivate( const QRectF &area, ::LinkOCGState *plocg ) +LinkOCGStatePrivate( const QRectF &area, + const std::vector<::LinkOCGState::StateList>& sList, + bool pRB ) : LinkPrivate( area ) -, popplerLinkOCGState( plocg ) +, stateList( sList ) +, preserveRB( pRB ) { } -::LinkOCGState *popplerLinkOCGState; +std::vector<::LinkOCGState::StateList> stateList; +bool preserveRB; }; diff --git a/qt5/src/poppler-link.h b/qt5/src/poppler-link.h index 93221846..24dd24c4 100644 --- a/qt5/src/poppler-link.h +++ b/qt5/src/poppler-link.h @@ -177,8 +177,6 @@ class POPPLER_QT5_EXPORT LinkDestination */ class POPPLER_QT5_EXPORT Link { - friend class OptContentModel; - public: /// \cond PRIVATE Link( const QRectF &linkArea ); @@ -624,6 +622,8 @@ class POPPLER_QT5_EXPORT LinkMovie : public Link */ class POPPLER_QT5_EXPORT LinkOCGState : public Link { + friend class OptContentModel; + public: /** * Create a new OCGState link. This is only used by Poppler::Page. diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc index ad959db8..5b71be80 100644 --- a/qt5/src/poppler-optcontent.cc +++ b/qt5/src/poppler-optcontent.cc @@ -397,23 +397,23 @@ namespace Poppler void OptContentModel::applyLink( LinkOCGState *link ) { -::LinkOCGState *popplerLinkOCGState = static_cast(link->d_ptr)->popplerLinkOCGState; +LinkOCGStatePrivate *linkPrivate = link->d_func(); QSet changedItems; -const std::vector<::LinkOCGState::StateList>& statesList = popplerLinkOCGState->getStateList(); +const std::vector<::LinkOCGState::StateList>& statesList = linkPrivate->stateList; for (const ::LinkOCGState::StateList& stateList : statesList) { const std::vector& refsList = stateList.list; for (const Ref& ref : refsList) { OptContentItem *item = d->itemFromRef(QString::number(ref.num)); if (stateList.st == ::LinkOCGState::On) { - item->setState(OptContentItem::On, popplerLinkOCGState->getPreserveRB(), changedItems); + item->setState(OptContentItem::On, linkPrivate->preserveRB, changedItems); } else if (stateList.st == ::LinkOCGState::Off) { - item->setState(OptContentItem::Off, popplerLinkOCGState->getPreserveRB(), changedItems); + item->setState(OptContentItem::Off, linkPrivate->preserveRB, changedItems); } else { OptContentItem::ItemState newState = item->state() == OptContentItem::On ? OptContentItem::Off : OptContentItem::On; - item->setState(newState, popplerLinkOCGState->getPreserveRB(), changedItems); + item->setState(newState, linkPrivate->preserveRB, changedItems); } } } diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 29394d20..f40b00e6 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -340,7 +340,7 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo { ::LinkOCGState *plocg = (::LinkOCGState *)a; - LinkOCGStatePrivate *locgp = new LinkOCGStatePrivate( linkArea, plocg ); + LinkOCGStatePrivate *locgp = new LinkOCGStatePrivate( linkArea, plocg->getStateList(), plocg->getPreserveRB() ); popplerLink = new LinkOCGState( locgp ); } break; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-form.cc | 18 +++--- qt5/src/poppler-form.h |5 +++-- 2 files changed, 10 insertions(+), 13 deletions(-) New commits: commit 165bfbe220cd395a829deede92f3a0d4648d5ba6 Author: Oliver Sander Date: Mon Nov 25 10:14:24 2019 +0100 Use std::unique_ptr for m_formData To make it clear that it is an owning pointer. diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index a3a5fd5a..5917e0a7 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -101,8 +101,8 @@ FormFieldIcon::~FormFieldIcon() delete d_ptr; } -FormField::FormField(FormFieldData &dd) - : m_formData(&dd) +FormField::FormField(std::unique_ptr dd) + : m_formData(std::move(dd)) { const int rotation = m_formData->page->getRotate(); // reading the coords @@ -129,11 +129,7 @@ FormField::FormField(FormFieldData &dd) m_formData->box = QRectF(topLeft, QSizeF(bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y())); } -FormField::~FormField() -{ - delete m_formData; - m_formData = nullptr; -} +FormField::~FormField() = default; QRectF FormField::rect() const { @@ -273,7 +269,7 @@ Link *FormField::additionalAction(Annotation::AdditionalActionType type) const } FormFieldButton::FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w) - : FormField(*new FormFieldData(doc, p, w)) + : FormField(std::make_unique(doc, p, w)) { } @@ -394,7 +390,7 @@ QList FormFieldButton::siblings() const FormFieldText::FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w) - : FormField(*new FormFieldData(doc, p, w)) + : FormField(std::make_unique(doc, p, w)) { } @@ -482,7 +478,7 @@ void FormFieldText::setFontSize(int fontSize) } FormFieldChoice::FormFieldChoice(DocumentData *doc, ::Page *p, ::FormWidgetChoice *w) - : FormField(*new FormFieldData(doc, p, w)) + : FormField(std::make_unique(doc, p, w)) { } @@ -910,7 +906,7 @@ SignatureValidationInfo &SignatureValidationInfo::operator=(const SignatureValid } FormFieldSignature::FormFieldSignature(DocumentData *doc, ::Page *p, ::FormWidgetSignature *w) - : FormField(*new FormFieldData(doc, p, w)) + : FormField(std::make_unique(doc, p, w)) { } diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index 836ada37..3918fc7d 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -28,6 +28,7 @@ #ifndef _POPPLER_QT5_FORM_H_ #define _POPPLER_QT5_FORM_H_ +#include #include #include #include @@ -205,9 +206,9 @@ namespace Poppler { protected: /// \cond PRIVATE - FormField(FormFieldData &dd); + FormField(std::unique_ptr dd); - FormFieldData *m_formData; + std::unique_ptr m_formData; /// \endcond private: ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation-helper.h | 118 1 file changed, 118 deletions(-) New commits: commit 4c42f03f26dc9ceb31bcd8bf7c290f3bc87fd862 Author: Albert Astals Cid Date: Wed Oct 30 23:01:40 2019 +0100 qt5: remove a bunch of unused internal functions diff --git a/qt5/src/poppler-annotation-helper.h b/qt5/src/poppler-annotation-helper.h index b1f61bb0..d1d222c6 100644 --- a/qt5/src/poppler-annotation-helper.h +++ b/qt5/src/poppler-annotation-helper.h @@ -41,129 +41,11 @@ namespace Poppler { class XPDFReader { public: -// find named symbol and parse it -static inline void lookupName( Dict *, char *, QString & dest ); -static inline void lookupString( Dict *, char *, QString & dest ); -static inline void lookupBool( Dict *, char *, bool & dest ); -static inline void lookupInt( Dict *, char *, int & dest ); -static inline void lookupNum( Dict *, char *, double & dest ); -static inline int lookupNumArray( Dict *, char *, double * dest, int len ); -static inline void lookupColor( Dict *, char *, QColor & color ); -static inline void lookupIntRef( Dict *, char *, int & dest ); -static inline void lookupDate( Dict *, char *, QDateTime & dest ); // transform from user coords to normalized ones using the matrix M static inline void transform( double * M, double x, double y, QPointF &res ); static inline void invTransform( const double * M, const QPointF p, double &x, double &y ); }; -void XPDFReader::lookupName( Dict * dict, char * type, QString & dest ) -{ -Object nameObj = dict->lookup( type ); -if ( nameObj.isNull() ) -return; -if ( nameObj.isName() ) -dest = nameObj.getName(); -else -qDebug() << type << " is not Name." << endl; -} - -void XPDFReader::lookupString( Dict * dict, char * type, QString & dest ) -{ -Object stringObj = dict->lookup( type ); -if ( stringObj.isNull() ) -return; -if ( stringObj.isString() ) -dest = stringObj.getString()->c_str(); -else -qDebug() << type << " is not String." << endl; -} - -void XPDFReader::lookupBool( Dict * dict, char * type, bool & dest ) -{ -Object boolObj = dict->lookup( type ); -if ( boolObj.isNull() ) -return; -if ( boolObj.isBool() ) -dest = boolObj.getBool() == true; -else -qDebug() << type << " is not Bool." << endl; -} - -void XPDFReader::lookupInt( Dict * dict, char * type, int & dest ) -{ -Object intObj = dict->lookup( type ); -if ( intObj.isNull() ) -return; -if ( intObj.isInt() ) -dest = intObj.getInt(); -else -qDebug() << type << " is not Int." << endl; -} - -void XPDFReader::lookupNum( Dict * dict, char * type, double & dest ) -{ -Object numObj = dict->lookup( type ); -if ( numObj.isNull() ) -return; -if ( numObj.isNum() ) -dest = numObj.getNum(); -else -qDebug() << type << " is not Num." << endl; -} - -int XPDFReader::lookupNumArray( Dict * dict, char * type, double * dest, int len ) -{ -Object arrObj = dict->lookup( type ); -if ( arrObj.isNull() ) -return 0; -if ( arrObj.isArray() ) -{ -len = qMin( len, arrObj.arrayGetLength() ); -for ( int i = 0; i < len; i++ ) -{ -Object numObj = arrObj.arrayGet( i ); -dest[i] = numObj.getNum(); -} -} -else -{ -len = 0; -qDebug() << type << "is not Array." << endl; -} -return len; -} - -void XPDFReader::lookupColor( Dict * dict, char * type, QColor & dest ) -{ -double c[3]; -if ( XPDFReader::lookupNumArray( dict, type, c, 3 ) == 3 ) -dest = QColor( (int)(c[0]*255.0), (int)(c[1]*255.0), (int)(c[2]*255.0)); -} - -void XPDFReader::lookupIntRef( Dict * dict, char * type, int & dest ) -{ -const Object &refObj = dict->lookupNF( type ); -if ( refObj.isNull() ) -return; -if ( refObj.isRef() ) -dest = refObj.getRefNum(); -else -qDebug() << type << " is not Ref." << endl; -} - -void XPDFReader::lookupDate( Dict * dict, char * type, QDateTime & dest ) -{ -Object dateObj = dict->lookup( type ); -if ( dateObj.isNull() ) -return; -if ( dateObj.isString() ) -{ -dest = convertDate( dateObj.getString()->c_str() ); -} -else -qDebug() << type << " is not Date" << endl; -} - void XPDFReader::transform( double * M, double x, double y, QPointF &res ) { res.setX( M[0] * x + M[2] * y + M[4] ); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-fontinfo.cc |1 + qt5/src/poppler-private.h |1 + qt5/src/poppler-qt5.h |1 + 3 files changed, 3 insertions(+) New commits: commit b7d1374c1eedc32669c1608f6213bea2d7e5fb7b Author: Albert Astals Cid Date: Thu Aug 8 19:27:09 2019 +0200 Update (C) of last commit diff --git a/qt5/src/poppler-fontinfo.cc b/qt5/src/poppler-fontinfo.cc index 609a83f2..3948a298 100644 --- a/qt5/src/poppler-fontinfo.cc +++ b/qt5/src/poppler-fontinfo.cc @@ -6,6 +6,7 @@ * Copyright (C) 2008, 2009, Pino Toscano * Copyright (C) 2018, Adam Reichold * Copyright (C) 2019, Oliver Sander + * Copyright (C) 2019, Jan Grulich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index 93195550..28b5ca30 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -15,6 +15,7 @@ * Copyright (C) 2018 Adam Reichold * Copyright (C) 2019 Oliver Sander * Copyright (C) 2019 João Netto + * Copyright (C) 2019 Jan Grulich * Inspired on code by * Copyright (C) 2004 by Albert Astals Cid * Copyright (C) 2004 by Enrico Ros diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 6102aa20..847671ea 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -19,6 +19,7 @@ * Copyright (C) 2017 Oliver Sander * Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich * Copyright (C) 2018 Nelson Benítez León + * Copyright (C) 2019 Jan Grulich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-fontinfo.cc |5 + qt5/src/poppler-private.h |2 ++ qt5/src/poppler-qt5.h |6 ++ 3 files changed, 13 insertions(+) New commits: commit 623983346bb2075d572aa2d8c1757bff5b807126 Author: Jan Grulich Date: Wed Aug 7 07:46:29 2019 +0200 Add subsitute-font information to Qt bindings diff --git a/qt5/src/poppler-fontinfo.cc b/qt5/src/poppler-fontinfo.cc index b563461e..609a83f2 100644 --- a/qt5/src/poppler-fontinfo.cc +++ b/qt5/src/poppler-fontinfo.cc @@ -52,6 +52,11 @@ QString FontInfo::name() const return m_data->fontName; } +QString FontInfo::substituteName() const +{ + return m_data->fontSubstituteName; +} + QString FontInfo::file() const { return m_data->fontFile; diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index 80f6581e..93195550 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -175,6 +175,7 @@ namespace Poppler { { if (fi->getName()) fontName = fi->getName()->c_str(); if (fi->getFile()) fontFile = fi->getFile()->c_str(); + if (fi->getSubstituteName()) fontSubstituteName = fi->getSubstituteName()->c_str(); isEmbedded = fi->getEmbedded(); isSubset = fi->getSubset(); type = (Poppler::FontInfo::Type)fi->getType(); @@ -185,6 +186,7 @@ namespace Poppler { FontInfoData& operator=(const FontInfoData &) = default; QString fontName; + QString fontSubstituteName; QString fontFile; bool isEmbedded : 1; bool isSubset : 1; diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index ebbc456a..6102aa20 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -210,6 +210,12 @@ namespace Poppler { QString name() const; /** + The name of the substitute font. Can be a null QString if the font has no substitute font + @since 0.80 + */ + QString substituteName() const; + + /** The path of the font file used to represent this font on this system, or a null string is the font is embedded */ ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-form.h |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 3348f4d3cdd625b47c3a63b86f9329df3363e29f Author: João Netto Date: Sat Jul 20 14:50:56 2019 -0300 These changes were implemented in 0.79 diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index 4e356b8e..d252ff8a 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -55,7 +55,7 @@ namespace Poppler { /** The class containing the appearance information -\since 0.78 +\since 0.79 */ class POPPLER_QT5_EXPORT FormFieldIcon { @@ -249,7 +249,7 @@ namespace Poppler { /** * Gets the icon used by the button * -* \since 0.78 +* \since 0.79 */ FormFieldIcon icon() const; @@ -257,7 +257,7 @@ namespace Poppler { * Sets a new icon for the button, it has to be a icon * returned by FormFieldButton::icon. * -* \since 0.78 +* \since 0.79 */ void setIcon(const FormFieldIcon &icon); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-private.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 9bbecdecc8d75a59f270ea6d7af2f22fb201c29f Author: Albert Astals Cid Date: Fri Jul 19 00:57:07 2019 +0200 Update (C) of previous commit diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index e6ed08d5..227972dc 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -1,7 +1,7 @@ /* poppler-private.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2008, Brad Hards - * Copyright (C) 2006-2009, 2011, 2012, 2017, 2018 by Albert Astals Cid + * Copyright (C) 2006-2009, 2011, 2012, 2017-2019 by Albert Astals Cid * Copyright (C) 2007-2009, 2011, 2014 by Pino Toscano * Copyright (C) 2011 Andreas Hartmetz * Copyright (C) 2011 Hib Eris ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-private.cc |4 ++-- qt5/src/poppler-private.h |2 +- 2 files changed, 3 insertions(+), 3 deletions(-) New commits: commit ff01f747788e5dfee6a30153a88999e76c7f770b Author: Albert Astals Cid Date: Fri Jul 19 00:42:27 2019 +0200 qt5: Fix MSVC build (hopefully) diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index a3fbec36..8735b699 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -304,9 +304,9 @@ namespace Debug { } } -FormFieldIconData POPPLER_QT5_EXPORT *FormFieldIconData::getData( const FormFieldIcon &f ) +FormFieldIconData *FormFieldIconData::getData( const FormFieldIcon &f ) { return f.d_ptr; } -} \ No newline at end of file +} diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index de5ec041..e6ed08d5 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -243,7 +243,7 @@ namespace Poppler { class FormFieldIconData { public: - static FormFieldIconData *getData( const FormFieldIcon &f ); + static POPPLER_QT5_EXPORT FormFieldIconData *getData( const FormFieldIcon &f ); Dict *icon; }; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation.cc |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) New commits: commit 8ac28200d29c84076fe8845ffacfcf8aa1d1a0f7 Author: Albert Astals Cid Date: Wed Jul 17 17:43:30 2019 +0200 qt5: Simplify code that creates an invalid Ref diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index c2798408..5f23782d 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -769,8 +769,7 @@ Ref AnnotationPrivate::pdfObjectReference() const { if (pdfAnnot == nullptr) { -const Ref invalid_ref = { -1, -1 }; -return invalid_ref; +return Ref::INVALID(); } return pdfAnnot->getRef(); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-page.cc |1 + 1 file changed, 1 insertion(+) New commits: commit 15c89ce277bddab535e5ea17081f2a87b1bcbe8a Author: Albert Astals Cid Date: Wed Jul 17 00:46:05 2019 +0200 qt5: Page::textList: Fix leak when aborting extraction diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index bf1f8889..c4d00a6b 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -783,6 +783,7 @@ QList Page::textList(Rotation rotate, ShouldAbortQueryFunc shouldAbort TextWordList *word_list = output_dev->makeWordList(); if (!word_list || (shouldAbortExtractionCallback && shouldAbortExtractionCallback(closure))) { +delete word_list; delete output_dev; return output_list; } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests
qt5/src/poppler-form.cc | 16 qt5/src/poppler-form.h| 12 qt5/tests/check_forms.cpp | 20 3 files changed, 48 insertions(+) New commits: commit 04e8309d18fa2f90ed93930e7eb689e523c7eb44 Author: João Netto Date: Mon Jul 8 20:43:19 2019 -0300 Added option to set the form available to print diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index fa9c3312..111d5b09 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -207,6 +207,22 @@ void FormField::setVisible(bool value) m_formData->fm->getWidgetAnnotation()->setFlags(flags); } +bool FormField::isPrintable() const +{ + return (m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagPrint); +} + +void FormField::setPrintable(bool value) +{ + unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags(); + if (value) { +flags |= Annot::flagPrint; + } else { +flags &= ~Annot::flagPrint; + } + m_formData->fm->getWidgetAnnotation()->setFlags(flags); +} + Link* FormField::activationAction() const { Link* action = nullptr; diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index f4c64589..ac00da26 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -155,6 +155,18 @@ namespace Poppler { void setVisible(bool value); /** + Whether this field is printable. + \since 0.79 +*/ + bool isPrintable() const; + + /** + Set whether this field is printable. + \since 0.79 +*/ + void setPrintable(bool value); + + /** The activation action of this form field. \note It may be null. diff --git a/qt5/tests/check_forms.cpp b/qt5/tests/check_forms.cpp index ec48ce91..f139ed1f 100644 --- a/qt5/tests/check_forms.cpp +++ b/qt5/tests/check_forms.cpp @@ -14,6 +14,7 @@ private slots: void testCheckbox();// Test for issue #655 void testCheckboxIssue159();// Test for issue #159 void testSetIcon();// Test that setIcon will always be valid. +void testSetPrintable(); }; void TestForms::testCheckbox() @@ -148,5 +149,24 @@ void TestForms::testSetIcon() QVERIFY( Poppler::FormFieldIconData::getData( anmIcon )->icon ); } +void TestForms::testSetPrintable() +{ +QScopedPointer< Poppler::Document > document(Poppler::Document::load(TESTDATADIR "/unittestcases/form_set_icon.pdf")); +QVERIFY( document ); + +QScopedPointer< Poppler::Page > page(document->page(0)); +QVERIFY( page ); + +QList forms = page->formFields(); + +Q_FOREACH (Poppler::FormField *field, forms) { +field->setPrintable( true ); +QCOMPARE( field->isPrintable(), true ); + +field->setPrintable( false ); +QCOMPARE( field->isPrintable(), false ); +} +} + QTEST_GUILESS_MAIN(TestForms) #include "check_forms.moc" ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-optcontent.cc |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit a8dd0a5909c8902881fc382fa52eda462905979d Author: Albert Astals Cid Date: Wed Jul 3 14:10:13 2019 +0200 qt5: replace deprecated qStableSort with std::stable_sort diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc index 49acd4a4..56abf871 100644 --- a/qt5/src/poppler-optcontent.cc +++ b/qt5/src/poppler-optcontent.cc @@ -367,7 +367,7 @@ namespace Poppler Q_FOREACH (OptContentItem *item, changedItems) { indexes.append(d->indexFromItem(item, 0)); } - qStableSort(indexes); + std::stable_sort(indexes.begin(), indexes.end()); Q_FOREACH (const QModelIndex &changedIndex, indexes) { emit dataChanged(changedIndex, changedIndex); } @@ -431,7 +431,7 @@ namespace Poppler Q_FOREACH (OptContentItem *item, changedItems) { indexes.append(d->indexFromItem(item, 0)); } - qStableSort(indexes); + std::stable_sort(indexes.begin(), indexes.end()); Q_FOREACH (const QModelIndex &changedIndex, indexes) { emit dataChanged(changedIndex, changedIndex); } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-page.cc |2 +- qt5/src/poppler-qt5.h |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) New commits: commit cf629d6f829d1371b86fc654891ca83533b0542e Author: Albert Astals Cid Date: Wed Jul 3 14:06:09 2019 +0200 QString::null is deprecated, use QString() diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 4676dcd8..bf1f8889 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -211,7 +211,7 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo LinkGoTo * g = (LinkGoTo *) a; const LinkDestinationData ldd( g->getDest(), g->getNamedDest(), parentDoc, false ); // create link: no ext file, namedDest, object pointer - popplerLink = new LinkGoto( linkArea, QString::null, LinkDestination( ldd ) ); + popplerLink = new LinkGoto( linkArea, QString(), LinkDestination( ldd ) ); } break; diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index c03fec15..ebbc456a 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -1,7 +1,7 @@ /* poppler-qt.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2007, Brad Hards - * Copyright (C) 2005-2015, 2017, 2018, Albert Astals Cid + * Copyright (C) 2005-2015, 2017-2019, Albert Astals Cid * Copyright (C) 2005, Stefan Kebekus * Copyright (C) 2006-2011, Pino Toscano * Copyright (C) 2009 Shawn Rutledge @@ -205,7 +205,7 @@ namespace Poppler { ~FontInfo(); /** - The name of the font. Can be QString::null if the font has no name + The name of the font. Can be a null QString if the font has no name */ QString name() const; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests
qt5/src/poppler-annotation.cc |2 +- qt5/tests/check_annotations.cpp | 18 ++ 2 files changed, 19 insertions(+), 1 deletion(-) New commits: commit 0d0630cd6f10d0586172b740290056620fe56b21 Author: Albert Astals Cid Date: Sun Apr 28 19:25:08 2019 +0200 qt5: Fix regression in annotation handling diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index 207d6ca4..c2798408 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -412,7 +412,7 @@ QList AnnotationPrivate::findAnnotations(::Page *pdfPage, DocumentD if (!markupann) { // Assume it's a root annotation, and skip if user didn't request it -if (parentID != 0) +if (parentID != -1) continue; } else if (markupann->getInReplyToID() != parentID) diff --git a/qt5/tests/check_annotations.cpp b/qt5/tests/check_annotations.cpp index 1145ceec..20b33f21 100644 --- a/qt5/tests/check_annotations.cpp +++ b/qt5/tests/check_annotations.cpp @@ -20,6 +20,7 @@ private slots: void checkFontSizeAndColor(); void checkHighlightFromAndToQuads(); void checkUTF16LEAnnot(); + void checkNonMarkupAnnotations(); }; /* Is .5f sufficient for 16 bit color channel roundtrip trough save and load on all architectures? */ @@ -155,6 +156,23 @@ void TestAnnotations::checkUTF16LEAnnot() QCOMPARE(annot->contents(), QString::fromUtf8("Únîcödé豰")); //clazy:exclude=qstring-allocations } +void TestAnnotations::checkNonMarkupAnnotations() +{ +std::unique_ptr doc{ + Poppler::Document::load(TESTDATADIR "/unittestcases/checkbox_issue_159.pdf") +}; +QVERIFY(doc.get()); + +std::unique_ptr page{ + doc->page(0) +}; +QVERIFY(page.get()); + +auto annots = page->annotations(); +QCOMPARE(annots.size(), 17); +} + + QTEST_GUILESS_MAIN(TestAnnotations) #include "check_annotations.moc" ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation-private.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit ea34108538742ebddf95052319d2f3cbd29b5986 Author: Albert Astals Cid Date: Fri Apr 5 16:06:22 2019 +0200 Update (C) of previous commit diff --git a/qt5/src/poppler-annotation-private.h b/qt5/src/poppler-annotation-private.h index 937edad4..c63a86dd 100644 --- a/qt5/src/poppler-annotation-private.h +++ b/qt5/src/poppler-annotation-private.h @@ -2,7 +2,7 @@ * Copyright (C) 2007, Pino Toscano * Copyright (C) 2012, Tobias Koenig * Copyright (C) 2012, 2013 Fabio D'Urso - * Copyright (C) 2012, 2014, 2018, Albert Astals Cid + * Copyright (C) 2012, 2014, 2018, 2019, Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-private.cc |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit b0f11e3c8696cbb334b765789a548419669fa4ea Author: Albert Astals Cid Date: Sun Mar 31 00:39:09 2019 +0100 Update (C) of previous commit diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index 5a86bafb..e847ed5e 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -6,7 +6,7 @@ * Copyright (C) 2013 Adrian Johnson * Copyright (C) 2016 Jakub Alba * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich - * Copyright (C) 2018 Adam Reichold + * Copyright (C) 2018, 2019 Adam Reichold * Copyright (C) 2019 Oliver Sander * Inspired on code by * Copyright (C) 2004 by Albert Astals Cid ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-private.cc |1 + 1 file changed, 1 insertion(+) New commits: commit 3c12c660748ccdd0b7c08b8f4a2891ad1368e437 Author: Albert Astals Cid Date: Thu Mar 28 12:58:41 2019 +0100 qt5: small optimization to UnicodeParsedString by using QString::reserve it should be faster and use less memory diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index b284a744..719ccffc 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -129,6 +129,7 @@ namespace Debug { } QString result; +result.reserve(stringLength / 2); // i = 2 to skip the unicode marker for ( int i = 2; i < stringLength; i += 2 ) { ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src qt5/tests
qt5/src/poppler-private.cc | 15 --- qt5/tests/check_strings.cpp |2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) New commits: commit 623d073030259042921d34034cdcf701dae7c96b Author: Albert Astals Cid Date: Thu Mar 28 12:47:22 2019 +0100 qt: UnicodeParsedString support UTF16-LE strings They are not part of the standard but Adobe seems to support them and there's files out there like that so better to support them than not diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index 5f673973..b284a744 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -1,6 +1,6 @@ /* poppler-private.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2006, 2011, 2015, 2017, 2018 by Albert Astals Cid + * Copyright (C) 2006, 2011, 2015, 2017-2019 by Albert Astals Cid * Copyright (C) 2008, 2010, 2011, 2014 by Pino Toscano * Copyright (C) 2013 by Thomas Freitag * Copyright (C) 2013 Adrian Johnson @@ -108,12 +108,20 @@ namespace Debug { const char *cString; int stringLength; bool deleteCString; -if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getLength() > 1 && ( s1->getChar(1) & 0xff ) == 0xff ) ) +bool isLE = false; +if ( s1->hasUnicodeMarker() ) { cString = s1->c_str(); stringLength = s1->getLength(); deleteCString = false; } +else if ( s1->hasUnicodeMarkerLE() ) +{ +isLE = true; +cString = s1->c_str(); +stringLength = s1->getLength(); +deleteCString = false; +} else { cString = pdfDocEncodingToUTF16(s1, &stringLength); @@ -124,7 +132,8 @@ namespace Debug { // i = 2 to skip the unicode marker for ( int i = 2; i < stringLength; i += 2 ) { -const Unicode u = ( ( cString[i] & 0xff ) << 8 ) | ( cString[i+1] & 0xff ); +const Unicode u = isLE ? ( ( cString[i+1] & 0xff ) << 8 ) | ( cString[i] & 0xff ) + : ( ( cString[i] & 0xff ) << 8 ) | ( cString[i+1] & 0xff ); result += QChar( u ); } if (deleteCString) diff --git a/qt5/tests/check_strings.cpp b/qt5/tests/check_strings.cpp index 583617aa..e7b3f990 100644 --- a/qt5/tests/check_strings.cpp +++ b/qt5/tests/check_strings.cpp @@ -163,6 +163,8 @@ void TestStrings::check_UnicodeParsedString_data() << QStringLiteral("ša"); QTest::newRow("test string") << newGooString("\xFE\xFF\0t\0e\0s\0t\0 \0s\0t\0r\0i\0n\0g", 24) << QStringLiteral("test string"); +QTest::newRow("UTF16-LE") << newGooString("\xFF\xFE\xDA\x00\x6E\x00\xEE\x00\x63\x00\xF6\x00\x64\x00\xE9\x00\x51\x75", 18) + << QStringLiteral("Únîcödé畑"); } void TestStrings::check_UnicodeParsedString() ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-version.h.in |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) New commits: commit 01e963c4f89f47a883c27c597cdf7bf361e8f1ce Author: Albert Astals Cid Date: Sat Jan 5 18:12:42 2019 +0100 qt5: undefine major and minor since old glibc defined them diff --git a/qt5/src/poppler-version.h.in b/qt5/src/poppler-version.h.in index 9dd3c1e1..35645fe8 100644 --- a/qt5/src/poppler-version.h.in +++ b/qt5/src/poppler-version.h.in @@ -1,6 +1,6 @@ /* * Copyright (C) 2009, Pino Toscano - * Copyright (C) 2018, Albert Astals Cid + * Copyright (C) 2018, 2019, Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,12 @@ #include +// glibc < 2.28 used to include sys/sysmacros.h +// from sys/types.h and sysmacros.h defines minor and major so +// undefine them. You may need to undefine them in your code too. +#undef minor +#undef major + #define POPPLER_VERSION "@POPPLER_VERSION@" #define POPPLER_VERSION_MAJOR @POPPLER_MAJOR_VERSION@ #define POPPLER_VERSION_MINOR @POPPLER_MINOR_VERSION@ ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/CMakeLists.txt |4 ++ qt5/src/poppler-version.cpp | 40 ++ qt5/src/poppler-version.h.in | 66 +++ 3 files changed, 110 insertions(+) New commits: commit e676558a8b2d71906f1bf77407318a4fef6a60c2 Author: Albert Astals Cid Date: Sun Dec 16 23:40:02 2018 +0100 qt5: Add the possibility of getting version We provide both the build and runtime version, so if an app was built against poppler 0.65 but running against 0.72, the app can say somewhere in it's about/config dialogs Running poppler 0.72 (built against 0.65) This way we can explain to users while some features are not available even if they should be, because the runtime and build time differences sometimes matter diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt index de565b23..5269d620 100644 --- a/qt5/src/CMakeLists.txt +++ b/qt5/src/CMakeLists.txt @@ -12,6 +12,8 @@ set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +configure_file(poppler-version.h.in ${CMAKE_CURRENT_BINARY_DIR}/poppler-version.h @ONLY) + set(poppler_qt5_SRCS poppler-annotation.cc poppler-document.cc @@ -33,6 +35,7 @@ set(poppler_qt5_SRCS poppler-page-transition.cc poppler-media.cc ArthurOutputDev.cc + poppler-version.cpp ) add_library(poppler-qt5 ${poppler_qt5_SRCS}) set_target_properties(poppler-qt5 PROPERTIES VERSION 1.17.0 SOVERSION 1) @@ -55,5 +58,6 @@ install(FILES poppler-export.h poppler-page-transition.h poppler-media.h + ${CMAKE_CURRENT_BINARY_DIR}/poppler-version.h DESTINATION include/poppler/qt5) diff --git a/qt5/src/poppler-version.cpp b/qt5/src/poppler-version.cpp new file mode 100644 index ..015267c1 --- /dev/null +++ b/qt5/src/poppler-version.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009-2010, Pino Toscano + * Copyright (C) 2018, Albert Astals Cid + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "poppler-version.h" + +QString Poppler::Version::string() +{ +return QStringLiteral(POPPLER_VERSION); +} + +unsigned int Poppler::Version::major() +{ +return POPPLER_VERSION_MAJOR; +} + +unsigned int Poppler::Version::minor() +{ +return POPPLER_VERSION_MINOR; +} + +unsigned int Poppler::Version::micro() +{ +return POPPLER_VERSION_MICRO; +} diff --git a/qt5/src/poppler-version.h.in b/qt5/src/poppler-version.h.in new file mode 100644 index ..9dd3c1e1 --- /dev/null +++ b/qt5/src/poppler-version.h.in @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2009, Pino Toscano + * Copyright (C) 2018, Albert Astals Cid + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef POPPLER_VERSION_H +#define POPPLER_VERSION_H + +#include "poppler-export.h" + +#include + +#define POPPLER_VERSION "@POPPLER_VERSION@" +#define POPPLER_VERSION_MAJOR @POPPLER_MAJOR_VERSION@ +#define POPPLER_VERSION_MINOR @POPPLER_MINOR_VERSION@ +#define POPPLER_VERSION_MICRO @POPPLER_MICRO_VERSION@ + +namespace Poppler +{ + +namespace Version +{ + +/** + \since 0.73 + \returns the version string of the current poppler-qt5 library + */ +POPPLER_QT5_EXPORT QString string(); + +/** + \since 0.73 + \returns the "major" number of the version of the current poppler-qt5 library + */ +POPPLER_QT5_EXPORT unsigned int major(); + +/** + \since 0.73 + \returns the "minor" number of the version of the current poppler-qt5 library + */ +POPPLER_QT5_EXPORT unsigned int minor(); + +/** + \since 0.73 + \returns the "micro" number of the version of the current poppler-qt5 library + */ +POPPLER_QT5_EXPORT unsigned i
[poppler] qt5/src
qt5/src/CMakeLists.txt |1 + 1 file changed, 1 insertion(+) New commits: commit 54d003599920276710e7532b2250b302b459e2a4 Author: Albert Astals Cid Date: Thu Nov 8 23:12:15 2018 +0100 qt5: Add -DQT_NO_SIGNALS_SLOTS_KEYWORDS We don't have any signals or slots at the moment but add the keyword so if we ever add them it's using the Q_SIGNAL/Q_SLOT variant so we don't get collisions with other people that use signal/slot diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt index 6f34054e..de565b23 100644 --- a/qt5/src/CMakeLists.txt +++ b/qt5/src/CMakeLists.txt @@ -1,5 +1,6 @@ add_definitions(${QT5_DEFINITIONS}) add_definitions(${Qt5Core_DEFINITIONS}) +add_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/CMakeLists.txt|4 qt5/src/poppler-private.h |8 2 files changed, 8 insertions(+), 4 deletions(-) New commits: commit 5993cc0afdd6f1ebb4e6738536309245e53be18f Author: Albert Astals Cid Date: Fri Oct 26 17:41:43 2018 +0200 qt5: Default to hidden symbols diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt index ffa16fa8..6f34054e 100644 --- a/qt5/src/CMakeLists.txt +++ b/qt5/src/CMakeLists.txt @@ -7,6 +7,10 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + set(poppler_qt5_SRCS poppler-annotation.cc poppler-document.cc diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index 9b261d36..a83b49a5 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -58,13 +58,13 @@ class FormWidget; namespace Poppler { /* borrowed from kpdf */ -QString unicodeToQString(const Unicode* u, int len); +POPPLER_QT5_EXPORT QString unicodeToQString(const Unicode* u, int len); -QString UnicodeParsedString(const GooString *s1); +POPPLER_QT5_EXPORT QString UnicodeParsedString(const GooString *s1); -GooString *QStringToUnicodeGooString(const QString &s); +POPPLER_QT5_EXPORT GooString *QStringToUnicodeGooString(const QString &s); -GooString *QStringToGooString(const QString &s); +POPPLER_QT5_EXPORT GooString *QStringToGooString(const QString &s); GooString *QDateTimeToUnicodeGooString(const QDateTime &dt); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-page.cc |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) New commits: commit 5b9f42db983e1d5e915373cf554a50ce4e9b7ef0 Author: Tobias Deiminger Date: Mon Oct 15 08:25:14 2018 +0200 Make Page::renderToImage with Arthur more thread safe An application using ArthurBackend can be subject to multi threading. So better use a copy of XRef during rendering, just the same as it's already done when using SplashBackend. diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 8d5995dd..ed4ef36d 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -500,7 +500,8 @@ static bool renderToArthur(QImageDumpingArthurOutputDev *arthur_output, QPainter h, abortHelper->shouldAbortRenderCallback ? shouldAbortRenderInternalCallback : nullAbortCallBack, abortHelper, - (hideAnnotations) ? annotDisplayDecideCbk : nullAnnotCallBack); + (hideAnnotations) ? annotDisplayDecideCbk : nullAnnotCallBack, + nullptr, gTrue); if (savePainter) painter->restore(); return true; ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-qt5.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit de999b24ffefb397ff716123ea66137fc48f7daf Author: Albert Astals Cid Date: Sat Sep 22 22:47:59 2018 +0200 Fix copypasta mistake diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 2998180e..ed189701 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -961,7 +961,7 @@ delete it; QString label() const; /** - Returns the index of the page, or a null string is the page has no label. + Returns the index of the page. \since 0.70 **/ ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-document.cc |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) New commits: commit b2c2433b4dc8bb11fcd6206dc8e24373a66ba521 Author: Albert Astals Cid Date: Sat Sep 22 20:09:40 2018 +0200 qt5: Be more stubborn getting the page from a label string If using the "plain" label string didn't work, try with an unicode encoded one, this is a bit better since the label->cmpN comparison in PageLabelInfo::labelToIndex now succeeds but unfortunately the strtol used there still gets confused and fails to return the proper page index diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 102bd820..c7b90ca9 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -567,8 +567,12 @@ namespace Poppler { GooString label_g(label.toLatin1().data()); int index; - if (!m_doc->doc->getCatalog()->labelToIndex (&label_g, &index)) - return nullptr; + if (!m_doc->doc->getCatalog()->labelToIndex (&label_g, &index)) { + std::unique_ptr label_ug(QStringToUnicodeGooString(label)); + if (!m_doc->doc->getCatalog()->labelToIndex (label_ug.get(), &index)) { + return nullptr; + } + } return page(index); } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |2 ++ 1 file changed, 2 insertions(+) New commits: commit a613cd32bcaabe67649536886637ad022685c402 Author: Albert Astals Cid Date: Thu Apr 19 17:10:23 2018 +0200 Fix compilation with libc++ diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 17da8f29..f4f6b141 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -41,6 +41,8 @@ #include #include +#include + #include "goo/gfile.h" #include "GlobalParams.h" #include "Error.h" ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-link.h |1 - 1 file changed, 1 deletion(-) New commits: commit 1dcf335a8e212fdfd18bad1f56a743504f653cf5 Author: Albert Astals Cid Date: Tue Apr 17 16:21:33 2018 +0200 qt5: Don't need this friend declaration diff --git a/qt5/src/poppler-link.h b/qt5/src/poppler-link.h index 0ce4c0d1..938f8b13 100644 --- a/qt5/src/poppler-link.h +++ b/qt5/src/poppler-link.h @@ -178,7 +178,6 @@ class POPPLER_QT5_EXPORT LinkDestination class POPPLER_QT5_EXPORT Link { friend class OptContentModel; - friend class LinkPrivate; public: /// \cond PRIVATE ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc | 91 ++--- qt5/src/ArthurOutputDev.h |2 2 files changed, 30 insertions(+), 63 deletions(-) New commits: commit 8c8c0034ae88c06616ace5e5ead71318f04311cf Author: Oliver Sander Date: Sat Apr 7 23:45:50 2018 +0200 Implement ArthurOutputDev::drawImageMask Bug #105531 Also temporarily disable type3 fonts since it seems they're not properly supported diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 640634d0..67485a2e 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -836,6 +836,11 @@ void ArthurOutputDev::drawChar(GfxState *state, double x, double y, return; } + // Don't do anything for type3 fonts -- they are not yet supported + if (state->getFont()->getType() == fontType3) { +return; + } + if (!(render & 1)) { quint32 glyphIndex = (m_codeToGID) ? m_codeToGID[code] : code; @@ -924,76 +929,38 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool interpolate, GBool inlineImg) { - qDebug() << "drawImageMask"; -#if 0 - unsigned char *buffer; - unsigned char *dest; - cairo_surface_t *image; - cairo_pattern_t *pattern; - int x, y; - ImageStream *imgStr; - Guchar *pix; - double *ctm; - cairo_matrix_t matrix; - int invert_bit; - int row_stride; - - row_stride = (width + 3) & ~3; - buffer = (unsigned char *) malloc (height * row_stride); - if (buffer == nullptr) { -error(-1, "Unable to allocate memory for image."); -return; - } - - /* TODO: Do we want to cache these? */ - imgStr = new ImageStream(str, width, 1, 1); + std::unique_ptr imgStr(new ImageStream(str, width, + 1,// numPixelComps + 1)); // getBits imgStr->reset(); - invert_bit = invert ? 1 : 0; + // TODO: Would using QImage::Format_Mono be more efficient here? + QImage image(width, height, QImage::Format_ARGB32); + unsigned int *data = (unsigned int *)image.bits(); + int stride = image.bytesPerLine()/4; - for (y = 0; y < height; y++) { -pix = imgStr->getLine(); -dest = buffer + y * row_stride; -for (x = 0; x < width; x++) { + QRgb fillColor = m_currentBrush.color().rgb(); + + for (int y = 0; y < height; y++) { + +Guchar *pix = imgStr->getLine(); + +// Invert the vertical coordinate: y is increasing from top to bottom +// on the page, but y is increasing bottom to top in the picture. +unsigned int* dest = data + (height-1-y) * stride; + +for (int x = 0; x < width; x++) { + + bool opaque = ((bool)pix[x]) == invert; + dest[x] = (opaque) ? fillColor : 0; - if (pix[x] ^ invert_bit) - *dest++ = 0; - else - *dest++ = 255; } } - image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8, - width, height, row_stride); - if (image == nullptr) -return; - pattern = cairo_pattern_create_for_surface (image); - if (pattern == nullptr) -return; - - ctm = state->getCTM(); - LOG (printf ("drawImageMask %dx%d, matrix: %f, %f, %f, %f, %f, %f\n", - width, height, ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); - matrix.xx = ctm[0] / width; - matrix.xy = -ctm[2] / height; - matrix.yx = ctm[1] / width; - matrix.yy = -ctm[3] / height; - matrix.x0 = ctm[2] + ctm[4]; - matrix.y0 = ctm[3] + ctm[5]; - cairo_matrix_invert (&matrix); - cairo_pattern_set_matrix (pattern, &matrix); - - cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST); - /* FIXME: Doesn't the image mask support any colorspace? */ - cairo_set_source_rgb (cairo, fill_color.r, fill_color.g, fill_color.b); - cairo_mask (cairo, pattern); - - cairo_pattern_destroy (pattern); - cairo_surface_destroy (image); - free (buffer); + // At this point, the QPainter coordinate transformation (CTM) is such + // that QRect(0,0,1,1) is exactly the area of the image. + m_painter.top()->drawImage( QRect(0,0,1,1), image ); imgStr->close (); - delete imgStr; -#endif } //TODO: lots more work here. diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index 701a883a..0e68ac99 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -91,7 +91,7 @@ public: // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - GBool interpretType3Chars() override { return gTrue; } + GBool interpretType3Chars() override { return gFalse; } //- initialization and control ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-form.cc | 11 +++ qt5/src/poppler-form.h |6 ++ 2 files changed, 17 insertions(+) New commits: commit 3e0408966ccdd713de7795ce7992888b3896b49c Author: Andre Heinecke Date: Thu Mar 22 14:53:19 2018 +0100 Qt5: Allow setting of visibility Extends Qt5 API to allow setting visibility flags diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index ff737bdc..7396b596 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -163,6 +163,17 @@ bool FormField::isVisible() const return !(m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagHidden); } +void FormField::setVisible(bool value) +{ + Guint flags = m_formData->fm->getWidgetAnnotation()->getFlags(); + if (value) { +flags &= ~Annot::flagHidden; + } else { +flags |= Annot::flagHidden; + } + m_formData->fm->getWidgetAnnotation()->setFlags(flags); +} + Link* FormField::activationAction() const { Link* action = nullptr; diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h index d52f7e4b..e83deca3 100644 --- a/qt5/src/poppler-form.h +++ b/qt5/src/poppler-form.h @@ -122,6 +122,12 @@ namespace Poppler { bool isVisible() const; /** + Set whether this form field is visible. + \since 0.64 +*/ + void setVisible(bool value); + + /** The activation action of this form field. \note It may be null. ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc | 128 - qt5/src/ArthurOutputDev.h |9 ++- 2 files changed, 135 insertions(+), 2 deletions(-) New commits: commit 7a708ffd374cd18e9e4bfe8a8e95c02184a074ba Author: Oliver Sander Date: Wed Mar 28 00:00:35 2018 +0200 Implement ArthurOutputDev::axialShadedFill diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 34fde569..9af32ae5 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -23,7 +23,7 @@ // Copyright (C) 2013 Thomas Freitag // Copyright (C) 2013 Dominik Haumann // Copyright (C) 2013 Mihai Niculescu -// Copyright (C) 2017 Oliver Sander +// Copyright (C) 2017, 2018 Oliver Sander // Copyright (C) 2017 Adrian Johnson // // To see a description of the changes please see the Changelog file that @@ -687,6 +687,132 @@ void ArthurOutputDev::eoFill(GfxState *state) m_painter.top()->fillPath( convertPath( state, state->getPath(), Qt::OddEvenFill ), m_currentBrush ); } +GBool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) +{ + double x0, y0, x1, y1; + shading->getCoords(&x0, &y0, &x1, &y1); + + // get the clip region bbox + double xMin, yMin, xMax, yMax; + state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); + + // get the function domain + double t0 = shading->getDomain0(); + double t1 = shading->getDomain1(); + + // Max number of splits along the t axis + constexpr int maxSplits = 256; + + // Max delta allowed in any color component + const double colorDelta = (dblToCol(1 / 256.0)); + + // Number of color space components + auto nComps = shading->getColorSpace()->getNComps(); + + // Helper function to test two color objects for 'almost-equality' + auto isSameGfxColor = [&nComps,&colorDelta](const GfxColor &colorA, const GfxColor &colorB) +{ + for (int k = 0; k < nComps; ++k) { +if (abs(colorA.c[k] - colorB.c[k]) > colorDelta) { + return false; +} + } + return true; +}; + + // Helper function: project a number into an interval + // With C++17 this is part of the standard library + auto clamp = [](double v, double lo, double hi) + { return std::min(std::max(v,lo), hi); }; + + // ta stores all parameter values where we evaluate the input shading function. + // In between, QLinearGradient will interpolate linearly. + // We set up the array with three values. + std::array ta; + ta[0] = tMin; + std::array next; + next[0] = maxSplits / 2; + ta[maxSplits / 2] = 0.5 * (tMin + tMax); + next[maxSplits / 2] = maxSplits; + ta[maxSplits] = tMax; + + // compute the color at t = tMin + double tt = clamp(t0 + (t1 - t0) * tMin, t0, t1); + + GfxColor color0, color1; + shading->getColor(tt, &color0); + + // Construct a gradient object and set its color at one parameter end + QLinearGradient gradient(QPointF(x0 + tMin * (x1 - x0), y0 + tMin * (y1 - y0)), + QPointF(x0 + tMax * (x1 - x0), y0 + tMax * (y1 - y0))); + + GfxRGB rgb; + shading->getColorSpace()->getRGB(&color0, &rgb); + QColor qColor(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b)); + gradient.setColorAt(0,qColor); + + // Look for more relevant parameter values by bisection + int i = 0; + while (i < maxSplits) { + +int j = next[i]; +while (j > i + 1) { + + // Next parameter value to try + tt = clamp(t0 + (t1 - t0) * ta[j], t0, t1); + shading->getColor(tt, &color1); + + // j is a good next color stop if the input shading can be approximated well + // on the interval (ta[i], ta[j]) by a linear interpolation. + // We test this by comparing the real color in the middle between ta[i] and ta[j] + // with the linear interpolant there. + auto midPoint = 0.5 * (ta[i] + ta[j]); + GfxColor colorAtMidPoint; + shading->getColor(midPoint, &colorAtMidPoint); + + GfxColor linearlyInterpolatedColor; + for (int ii=0; iigetColorSpace()->getRGB(&color1, &rgb); +qColor.setRgb(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b)); +gradient.setColorAt((ta[j] - tMin)/(tMax - tMin), qColor); + +// Move to the next parameter region +color0 = color1; +i = next[i]; + } + + state->moveTo(xMin, yMin); + state->lineTo(xMin, yMax); + state->lineTo(xMax, yMax); + state->lineTo(xMax, yMin); + state->closePath(); + + // Actually paint the shaded region + QBrush newBrush(gradient); + m_painter.top()->fillPath( convertPath( state, state->getPath(), Qt::WindingFill ), newBrush ); + + state->clearPath(); + + // True means: The shaded region has been painted + return gTrue; +} + void ArthurOutputDev::clip(GfxState *state) { m_painter.top()->setClipPath(convertPath( state, state->getPath(), Qt::WindingFil
[poppler] qt5/src
qt5/src/poppler-page.cc | 148 qt5/src/poppler-qt5.h | 98 +++ 2 files changed, 185 insertions(+), 61 deletions(-) New commits: commit b1016f574ac63fa269ca5125827895220e1df883 Author: Albert Astals Cid Date: Thu Feb 1 22:46:33 2018 +0100 Qt5: Add cancellation support to renderToImage and textList diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 174d5857..f4c88de3 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -19,7 +19,7 @@ * Copyright (C) 2016, Hanno Meyer-Thurow * Copyright (C) 2017, Oliver Sander * Copyright (C) 2017 Adrian Johnson - * Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich + * Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,27 +70,48 @@ namespace Poppler { -class Qt5SplashOutputDev : public SplashOutputDev +class TextExtractionAbortHelper { public: - Qt5SplashOutputDev(SplashColorMode colorMode, int bitmapRowPad, - GBool reverseVideo, bool ignorePaperColorA, SplashColorPtr paperColor, - GBool bitmapTopDown, SplashThinLineMode thinLineMode, - GBool overprintPreview) -: SplashOutputDev(colorMode, bitmapRowPad, reverseVideo, paperColor, bitmapTopDown, thinLineMode, overprintPreview) -, partialUpdateCallback(nullptr) -, shouldDoPartialUpdateCallback(nullptr) -, ignorePaperColor(ignorePaperColorA) + TextExtractionAbortHelper(Page::ShouldAbortQueryFunc shouldAbortCallback, const QVariant &payloadA) { +shouldAbortExtractionCallback = shouldAbortCallback; +payload = payloadA; } - void setPartialUpdateCallbackData(Page::RenderToImagePartialUpdateFunc callback, Page::ShouldRenderToImagePartialQueryFunc shouldDoCallback, const QVariant &payloadA) + Page::ShouldAbortQueryFunc shouldAbortExtractionCallback = nullptr; + QVariant payload; +}; + +class OutputDevCallbackHelper +{ +public: + void setCallbacks(Page::RenderToImagePartialUpdateFunc callback, Page::ShouldRenderToImagePartialQueryFunc shouldDoCallback, Page::ShouldAbortQueryFunc shouldAbortCallback, const QVariant &payloadA) { partialUpdateCallback = callback; shouldDoPartialUpdateCallback = shouldDoCallback; +shouldAbortRenderCallback = shouldAbortCallback; payload = payloadA; } + Page::RenderToImagePartialUpdateFunc partialUpdateCallback = nullptr; + Page::ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback = nullptr; + Page::ShouldAbortQueryFunc shouldAbortRenderCallback = nullptr; + QVariant payload; +}; + +class Qt5SplashOutputDev : public SplashOutputDev, public OutputDevCallbackHelper +{ +public: + Qt5SplashOutputDev(SplashColorMode colorMode, int bitmapRowPad, + GBool reverseVideo, bool ignorePaperColorA, SplashColorPtr paperColor, + GBool bitmapTopDown, SplashThinLineMode thinLineMode, + GBool overprintPreview) +: SplashOutputDev(colorMode, bitmapRowPad, reverseVideo, paperColor, bitmapTopDown, thinLineMode, overprintPreview) +, ignorePaperColor(ignorePaperColorA) + { + } + void dump() override { if (partialUpdateCallback && shouldDoPartialUpdateCallback && shouldDoPartialUpdateCallback(payload)) { @@ -143,31 +164,19 @@ public: } private: - Page::RenderToImagePartialUpdateFunc partialUpdateCallback; - Page::ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback; - QVariant payload; bool ignorePaperColor; }; -class QImageDumpingArthurOutputDev : public ArthurOutputDev +class QImageDumpingArthurOutputDev : public ArthurOutputDev, public OutputDevCallbackHelper { public: QImageDumpingArthurOutputDev(QPainter *painter, QImage *i) : ArthurOutputDev(painter) -, partialUpdateCallback(nullptr) -, shouldDoPartialUpdateCallback(nullptr) , image(i) { } - void setPartialUpdateCallbackData(Page::RenderToImagePartialUpdateFunc callback, Page::ShouldRenderToImagePartialQueryFunc shouldDoCallback, const QVariant &payloadA) - { -partialUpdateCallback = callback; -shouldDoPartialUpdateCallback = shouldDoCallback; -payload = payloadA; - } - void dump() override { if (partialUpdateCallback && shouldDoPartialUpdateCallback && shouldDoPartialUpdateCallback(payload)) { @@ -176,9 +185,6 @@ public: } private: - Page::RenderToImagePartialUpdateFunc partialUpdateCallback; - Page::ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback; - QVariant payload; QImage *image; }; @@ -412,7 +418,34 @@ Page::~Page() delete m_page; } -static bool
Re: [poppler] qt5/src
El dimecres, 10 de gener de 2018, a les 20:39:22 CET, Adam Reichold va escriure: > Hello again, > > If you mind the smart pointer templates, then what about > > auto* const newData = new PageTransitionData(*other.data); > auto* const oldData = data; > data = newData; > delete oldData; > > As this is a library which does not know what kind of programs will make > use of it, exception safety is quite important IMHO. Honestly poppler is full of things more important than this operator (that is unused by anyone since it would be crashing if someone had been using it :D) that would have problems like this, if you have memory problems that can't have this new done, something else will fail for sure. Cheers, Albert > > Best regards, Adam. > > Am 10.01.2018 um 19:57 schrieb Albert Astals Cid: > > El dimecres, 10 de gener de 2018, a les 8:57:05 CET, Adam Reichold va > > > > escriure: > >> Hello, > >> > >> Am 09.01.2018 um 23:41 schrieb Albert Astals Cid: > >>> +PageTransition& PageTransition::operator=(const PageTransition &other) > >>> +{ > >>> + if ( this != &other ) { > >>> +delete data; > >>> +data = new PageTransitionData(*other.data); > >>> + } > >>> + > >>> + return *this; > >>> +} > >>> + > >> > >> In view of exception safety, I think it would be better to first create > >> the new data and then destroy the old one, i.e.: > >> > >> std::unique_ptr newData{new > >> PageTransitionData(*other.data)}; > >> data.swap(newData); > > > > I'd really much prefer code i can read over safety exception :D > > > > Cheers, > > > > Albert > >> > >> (assuming PageTransition::data becomes a unique_ptr) > >> > >> Regards, Adam. > >> ___ > >> poppler mailing list > >> poppler@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/poppler > > > > ___ > > poppler mailing list > > poppler@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/poppler > > ___ > poppler mailing list > poppler@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/poppler ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
Re: [poppler] qt5/src
Hello again, If you mind the smart pointer templates, then what about auto* const newData = new PageTransitionData(*other.data); auto* const oldData = data; data = newData; delete oldData; As this is a library which does not know what kind of programs will make use of it, exception safety is quite important IMHO. Best regards, Adam. Am 10.01.2018 um 19:57 schrieb Albert Astals Cid: > El dimecres, 10 de gener de 2018, a les 8:57:05 CET, Adam Reichold va > escriure: >> Hello, >> >> Am 09.01.2018 um 23:41 schrieb Albert Astals Cid: >>> +PageTransition& PageTransition::operator=(const PageTransition &other) >>> +{ >>> + if ( this != &other ) { >>> +delete data; >>> +data = new PageTransitionData(*other.data); >>> + } >>> + >>> + return *this; >>> +} >>> + >> >> In view of exception safety, I think it would be better to first create >> the new data and then destroy the old one, i.e.: >> >> std::unique_ptr newData{new >> PageTransitionData(*other.data)}; >> data.swap(newData); > > I'd really much prefer code i can read over safety exception :D > > Cheers, > Albert > >> >> (assuming PageTransition::data becomes a unique_ptr) >> >> Regards, Adam. >> ___ >> poppler mailing list >> poppler@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/poppler > > > ___ > poppler mailing list > poppler@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/poppler > ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
Re: [poppler] qt5/src
El dimecres, 10 de gener de 2018, a les 8:57:05 CET, Adam Reichold va escriure: > Hello, > > Am 09.01.2018 um 23:41 schrieb Albert Astals Cid: > > +PageTransition& PageTransition::operator=(const PageTransition &other) > > +{ > > + if ( this != &other ) { > > +delete data; > > +data = new PageTransitionData(*other.data); > > + } > > + > > + return *this; > > +} > > + > > In view of exception safety, I think it would be better to first create > the new data and then destroy the old one, i.e.: > > std::unique_ptr newData{new > PageTransitionData(*other.data)}; > data.swap(newData); I'd really much prefer code i can read over safety exception :D Cheers, Albert > > (assuming PageTransition::data becomes a unique_ptr) > > Regards, Adam. > ___ > poppler mailing list > poppler@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/poppler ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
Re: [poppler] qt5/src
Hello, Am 09.01.2018 um 23:41 schrieb Albert Astals Cid: > +PageTransition& PageTransition::operator=(const PageTransition &other) > +{ > + if ( this != &other ) { > +delete data; > +data = new PageTransitionData(*other.data); > + } > + > + return *this; > +} > + In view of exception safety, I think it would be better to first create the new data and then destroy the old one, i.e.: std::unique_ptr newData{new PageTransitionData(*other.data)}; data.swap(newData); (assuming PageTransition::data becomes a unique_ptr) Regards, Adam. ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-page-transition.cc | 10 ++ qt5/src/poppler-page-transition.h |5 - 2 files changed, 14 insertions(+), 1 deletion(-) New commits: commit 43ad7071aa126d3b6754421b544e114d87fdd82a Author: Albert Astals Cid Date: Tue Jan 9 23:41:01 2018 +0100 qt5: Implement operator= for PageTransition diff --git a/qt5/src/poppler-page-transition.cc b/qt5/src/poppler-page-transition.cc index 759592e9..2c4a7ef9 100644 --- a/qt5/src/poppler-page-transition.cc +++ b/qt5/src/poppler-page-transition.cc @@ -62,6 +62,16 @@ PageTransition::~PageTransition() delete data; } +PageTransition& PageTransition::operator=(const PageTransition &other) +{ + if ( this != &other ) { +delete data; +data = new PageTransitionData(*other.data); + } + + return *this; +} + PageTransition::Type PageTransition::type() const { return (Poppler::PageTransition::Type)data->pt->getType(); diff --git a/qt5/src/poppler-page-transition.h b/qt5/src/poppler-page-transition.h index c53ddf28..f7cd4c54 100644 --- a/qt5/src/poppler-page-transition.h +++ b/qt5/src/poppler-page-transition.h @@ -101,7 +101,10 @@ class POPPLER_QT5_EXPORT PageTransition { /** \brief copy constructor */ PageTransition(const PageTransition &pt); - + + /** \brief assignment operator \since 0.63 */ + PageTransition& operator=(const PageTransition &other); + /** Destructor */ ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation.cc |9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) New commits: commit e70990c5b2d95a9099b8f4a1c69ca9e5b2a559a4 Author: Albert Astals Cid Date: Wed Jan 3 00:46:42 2018 +0100 qt5: make the check for rendition a bit earlier diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index dbe336dc..4da4cf20 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -544,18 +544,15 @@ QList AnnotationPrivate::findAnnotations(::Page *pdfPage, DocumentD if (!wantScreenAnnotations) continue; AnnotScreen * screenann = static_cast< AnnotScreen * >( ann ); -if (!screenann->getAction()) +// TODO Support other link types than Link::Rendition in ScreenAnnotation +if (!screenann->getAction() || screenann->getAction()->getKind() != actionRendition) continue; ScreenAnnotation * s = new ScreenAnnotation(); annotation = s; // -> screen Link * popplerLink = PageData::convertLinkActionToLink( screenann->getAction(), doc, QRectF() ); -// TODO Support other link types than Link::Rendition in ScreenAnnotation -if (popplerLink->linkType() == Link::Rendition) -s->setAction( static_cast(popplerLink) ); -else -delete popplerLink; +s->setAction( static_cast(popplerLink) ); // -> screenTitle GooString * screentitle = screenann->getTitle(); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-annotation.cc |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) New commits: commit 9f08b62ea283ea66b35cfc6dab3e7f45bc4170b9 Author: Albert Astals Cid Date: Wed Jan 3 00:32:23 2018 +0100 qt5: Do not assume all Screen annotation actions are Renditions Fixes KDE bug #388175 diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index dfd56906..dbe336dc 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -551,7 +551,11 @@ QList AnnotationPrivate::findAnnotations(::Page *pdfPage, DocumentD // -> screen Link * popplerLink = PageData::convertLinkActionToLink( screenann->getAction(), doc, QRectF() ); -s->setAction( static_cast(popplerLink) ); +// TODO Support other link types than Link::Rendition in ScreenAnnotation +if (popplerLink->linkType() == Link::Rendition) +s->setAction( static_cast(popplerLink) ); +else +delete popplerLink; // -> screenTitle GooString * screentitle = screenann->getTitle(); ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit c138ec620b5084348dc892bf9fd8228ed098970a Author: Oliver Sander Date: Tue Nov 28 16:40:40 2017 +0100 Arthur: 'clip' should intersect new and old clipping path Previously, the 'clip' method of the ArthurOutputDev class replaced the current clipping path with the one given in the GfxState variable. However, the expected behavior is to intersect the new path with the old one, and use the result as the new clipping path. diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 0ec029f2..8053396f 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -635,12 +635,12 @@ void ArthurOutputDev::eoFill(GfxState *state) void ArthurOutputDev::clip(GfxState *state) { - m_painter->setClipPath(convertPath( state, state->getPath(), Qt::WindingFill ) ); + m_painter->setClipPath(convertPath( state, state->getPath(), Qt::WindingFill ), Qt::IntersectClip ); } void ArthurOutputDev::eoClip(GfxState *state) { - m_painter->setClipPath(convertPath( state, state->getPath(), Qt::OddEvenFill ) ); + m_painter->setClipPath(convertPath( state, state->getPath(), Qt::OddEvenFill ), Qt::IntersectClip ); } void ArthurOutputDev::drawChar(GfxState *state, double x, double y, ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/poppler-page.cc | 254 +--- qt5/src/poppler-qt5.h | 78 ++ 2 files changed, 254 insertions(+), 78 deletions(-) New commits: commit e0302537ec0919d9f3dbf180ebbc6e2653b1049b Author: Albert Astals Cid Date: Wed Nov 15 10:44:14 2017 +0100 qt5: Add API to let the rendering process callback to get a partial rendering Bug #103372 diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 9dcdaad9..3341f54c 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -19,6 +19,7 @@ * Copyright (C) 2016, Hanno Meyer-Thurow * Copyright (C) 2017, Oliver Sander * Copyright (C) 2017 Adrian Johnson + * Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by the LiMux project of the city of Munich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,6 +70,120 @@ namespace Poppler { +class Qt5SplashOutputDev : public SplashOutputDev +{ +public: + Qt5SplashOutputDev(SplashColorMode colorMode, int bitmapRowPad, + GBool reverseVideo, bool ignorePaperColorA, SplashColorPtr paperColor, + GBool bitmapTopDown, SplashThinLineMode thinLineMode, + GBool overprintPreview) +: SplashOutputDev(colorMode, bitmapRowPad, reverseVideo, paperColor, bitmapTopDown, thinLineMode, overprintPreview) +, partialUpdateCallback(nullptr) +, shouldDoPartialUpdateCallback(nullptr) +, ignorePaperColor(ignorePaperColorA) + { + } + + void setPartialUpdateCallbackData(Page::RenderToImagePartialUpdateFunc callback, Page::ShouldRenderToImagePartialQueryFunc shouldDoCallback, const QVariant &payloadA) + { +partialUpdateCallback = callback; +shouldDoPartialUpdateCallback = shouldDoCallback; +payload = payloadA; + } + + void dump() override + { +if (partialUpdateCallback && shouldDoPartialUpdateCallback && shouldDoPartialUpdateCallback(payload)) { + partialUpdateCallback(getXBGRImage( false /* takeImageData */), payload); +} + } + + QImage getXBGRImage(bool takeImageData) + { +SplashBitmap *bitmap = getBitmap(); + +const int bw = bitmap->getWidth(); +const int bh = bitmap->getHeight(); +const int brs = bitmap->getRowSize(); + +// If we use DeviceN8, convert to XBGR8. +// If requested, also transfer Splash's internal alpha channel. +const SplashBitmap::ConversionMode mode = ignorePaperColor +? SplashBitmap::conversionAlphaPremultiplied +: SplashBitmap::conversionOpaque; + +const QImage::Format format = ignorePaperColor +? QImage::Format_ARGB32_Premultiplied +: QImage::Format_RGB32; + +if (bitmap->convertToXBGR(mode)) { + SplashColorPtr data = takeImageData ? bitmap->takeData() : bitmap->getDataPtr(); + + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { +// Convert byte order from RGBX to XBGR. +for (int i = 0; i < bh; ++i) { + for (int j = 0; j < bw; ++j) { +SplashColorPtr pixel = &data[i * brs + j]; + +qSwap(pixel[0], pixel[3]); +qSwap(pixel[1], pixel[2]); + } +} + } + + if (takeImageData) { +// Construct a Qt image holding (and also owning) the raw bitmap data. +return QImage(data, bw, bh, brs, format, gfree, data); + } else { +return QImage(data, bw, bh, brs, format).copy(); + } +} + +return QImage(); + } + +private: + Page::RenderToImagePartialUpdateFunc partialUpdateCallback; + Page::ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback; + QVariant payload; + bool ignorePaperColor; +}; + + +class QImageDumpingArthurOutputDev : public ArthurOutputDev +{ +public: + QImageDumpingArthurOutputDev(QPainter *painter, QImage *i) +: ArthurOutputDev(painter) +, partialUpdateCallback(nullptr) +, shouldDoPartialUpdateCallback(nullptr) +, image(i) + { + } + + void setPartialUpdateCallbackData(Page::RenderToImagePartialUpdateFunc callback, Page::ShouldRenderToImagePartialQueryFunc shouldDoCallback, const QVariant &payloadA) + { +partialUpdateCallback = callback; +shouldDoPartialUpdateCallback = shouldDoCallback; +payload = payloadA; + } + + void dump() override + { +if (partialUpdateCallback && shouldDoPartialUpdateCallback && shouldDoPartialUpdateCallback(payload)) { + partialUpdateCallback(*image, payload); +} + } + +private: + Page::RenderToImagePartialUpdateFunc partialUpdateCallback; + Page::ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback; + QVariant payload; + QImage *image; +}; + + + Link* PageData::convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea) { return convertLinkActionToLink(a, parentDoc, linkArea); @@ -297,8 +412,59 @@ Page::~Page() delete m_
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |3 +++ 1 file changed, 3 insertions(+) New commits: commit 4d109589e5d2ac989d4fd7ac318ddf976f3106ed Author: Oliver Sander Date: Sun Oct 29 20:28:52 2017 +0100 Fix leak in ArthurOutputDev::updateFont Bug #103508 diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 3be12672..8d3c801e 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -341,6 +341,9 @@ void ArthurOutputDev::updateFont(GfxState *state) m_rawFont = new QRawFont(QByteArray(fontData, fontDataLen), fontSize); m_rawFontCache.insert(std::make_pair(fontID,std::unique_ptr(m_rawFont))); + +// Free the font data, it was copied in the QByteArray constructor +free((char*)fontData); break; } case gfxFontLocExternal:{ // font is in an external font file ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc | 14 ++ qt5/src/ArthurOutputDev.h |9 + 2 files changed, 23 insertions(+) New commits: commit e0926ca8a94bafa6d5bfd694064c5e30da2b79db Author: Oliver Sander Date: Thu Oct 5 18:32:40 2017 +0200 Properly implement saveState / restoreState Not all of the internal state was actually saved/restored in those methods, which lead to inconsistencies between the ArthurOutputDev state and the GfxState object. Bug #103118 diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index f199e656..3be12672 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -137,12 +137,26 @@ void ArthurOutputDev::endPage() { void ArthurOutputDev::saveState(GfxState *state) { + m_currentPenStack.push(m_currentPen); + m_currentBrushStack.push(m_currentBrush); + m_rawFontStack.push(m_rawFont); + m_codeToGIDStack.push(m_codeToGID); + m_painter->save(); } void ArthurOutputDev::restoreState(GfxState *state) { m_painter->restore(); + + m_codeToGID = m_codeToGIDStack.top(); + m_codeToGIDStack.pop(); + m_rawFont = m_rawFontStack.top(); + m_rawFontStack.pop(); + m_currentBrush = m_currentBrushStack.top(); + m_currentBrushStack.pop(); + m_currentPen = m_currentPenStack.top(); + m_currentPenStack.pop(); } void ArthurOutputDev::updateAll(GfxState *state) diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index 496f5a72..480c7827 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -36,6 +36,7 @@ #include #include +#include #include "goo/gtypes.h" #include "OutputDev.h" @@ -172,14 +173,21 @@ public: private: QPainter *m_painter; FontHinting m_fontHinting; + QPen m_currentPen; + // The various stacks are used to implement the 'saveState' and 'restoreState' methods + std::stack m_currentPenStack; + QBrush m_currentBrush; + std::stack m_currentBrushStack; + GBool m_needFontUpdate; // set when the font needs to be updated SplashFontEngine *m_fontEngine; XRef *xref; // xref table for current document // The current font in use QRawFont* m_rawFont; + std::stack m_rawFontStack; // Identify a font by its 'Ref' and its font size struct ArthurFontID @@ -199,6 +207,7 @@ private: // The table that maps character codes to glyph indexes int* m_codeToGID; + std::stack m_codeToGIDStack; }; #endif ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc | 48 - qt5/src/ArthurOutputDev.h |4 --- 2 files changed, 18 insertions(+), 34 deletions(-) New commits: commit ebf6d1ca736fecad49fbf543875c794770bd4d57 Author: Oliver Sander Date: Fri Sep 15 11:18:58 2017 +0200 Clean up the remaining Splash code in Arthur backend - remove some goto-style error handling - use nullptr - use std::unique_ptr (fixes a leak) - remove unused data member m_currentFont - remove some unused forward declarations Bug #103117 diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index f31e6a5f..f199e656 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -296,14 +296,14 @@ void ArthurOutputDev::updateStrokeOpacity(GfxState *state) void ArthurOutputDev::updateFont(GfxState *state) { - GfxFont *font = state->getFont(); - if (!font) + GfxFont *gfxFont = state->getFont(); + if (!gfxFont) { return; } // is the font in the cache? - ArthurFontID fontID = {*font->getID(), state->getFontSize()}; + ArthurFontID fontID = {*gfxFont->getID(), state->getFontSize()}; auto cacheEntry = m_rawFontCache.find(fontID); if (cacheEntry!=m_rawFontCache.end()) { @@ -316,14 +316,14 @@ void ArthurOutputDev::updateFont(GfxState *state) // New font: load it into the cache float fontSize = state->getFontSize(); -GfxFontLoc* fontLoc = font->locateFont(xref, nullptr); +std::unique_ptr fontLoc(gfxFont->locateFont(xref, nullptr)); if (fontLoc) { // load the font from respective location switch (fontLoc->locType) { case gfxFontLocEmbedded: {// if there is an embedded font, read it to memory int fontDataLen; -const char* fontData = font->readEmbFontFile(xref, &fontDataLen); +const char* fontData = gfxFont->readEmbFontFile(xref, &fontDataLen); m_rawFont = new QRawFont(QByteArray(fontData, fontDataLen), fontSize); m_rawFontCache.insert(std::make_pair(fontID,std::unique_ptr(m_rawFont))); @@ -362,12 +362,9 @@ void ArthurOutputDev::updateFont(GfxState *state) // * #ifdef HAVE_SPLASH - GfxFont *gfxFont; - GfxFontLoc *fontLoc; GfxFontType fontType; - SplashOutFontFileID *id; SplashFontFile *fontFile; - SplashFontSrc *fontsrc = NULL; + SplashFontSrc *fontsrc = nullptr; FoFiTrueType *ff; Object refObj, strObj; GooString *fileName; @@ -381,29 +378,26 @@ void ArthurOutputDev::updateFont(GfxState *state) SplashFTFontFile* ftFontFile; m_needFontUpdate = false; - fileName = NULL; - tmpBuf = NULL; - fontLoc = NULL; + fileName = nullptr; + tmpBuf = nullptr; - if (!(gfxFont = state->getFont())) { -goto err1; - } fontType = gfxFont->getType(); if (fontType == fontType3) { -goto err1; +return; } // Default: no codeToGID table m_codeToGID = nullptr; // check the font file cache - id = new SplashOutFontFileID(gfxFont->getID()); + SplashOutFontFileID *id = new SplashOutFontFileID(gfxFont->getID()); if ((fontFile = m_fontEngine->getFontFile(id))) { delete id; } else { -if (!(fontLoc = gfxFont->locateFont(xref, NULL))) { +std::unique_ptr fontLoc(gfxFont->locateFont(xref, nullptr)); +if (!fontLoc) { error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); @@ -475,7 +469,7 @@ void ArthurOutputDev::updateFont(GfxState *state) n = 256; delete ff; } else { - codeToGID = NULL; + codeToGID = nullptr; n = 0; } if (!(fontFile = m_fontEngine->loadTrueTypeFont( @@ -506,7 +500,7 @@ void ArthurOutputDev::updateFont(GfxState *state) memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), n * sizeof(int)); } else { - codeToGID = NULL; + codeToGID = nullptr; n = 0; } if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont( @@ -521,7 +515,7 @@ void ArthurOutputDev::updateFont(GfxState *state) break; case fontCIDType2: case fontCIDType2OT: - codeToGID = NULL; + codeToGID = nullptr; n = 0; if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); @@ -566,18 +560,12 @@ void ArthurOutputDev::updateFont(GfxState *state) // font in the Splash font cache. Otherwise we'd load it again and again. m_fontEngine->getFont(fontFile, mat, matrix); - delete fontLoc; if (fontsrc && !fontsrc->isFile) fontsrc->unref(); return; err2: delete id; - delete fontLoc; - err1: - if (fontsrc && !fontsrc->isFile) - fontsrc->unref(); - return; #endif } @@ -753,7 +741,7 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc |2 ++ 1 file changed, 2 insertions(+) New commits: commit f538b74a38acb53b877e000a64647ce8043133ac Author: Oliver Sander Date: Tue Oct 3 00:04:17 2017 +0200 qt5: ArthurOutputDev: Add missing 'return' in error paths diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 14c79813..61c5990b 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -884,6 +884,7 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream * { qDebug() << "Soft mask size does not match image size!"; drawImage(state, ref, str, width, height, colorMap, interpolate, nullptr, gFalse); +return; } // Bail out if the mask isn't a single channel. I don't know @@ -892,6 +893,7 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream * { qDebug() << "Soft mask is not a single 8-bit channel!"; drawImage(state, ref, str, width, height, colorMap, interpolate, nullptr, gFalse); +return; } /* TODO: Do we want to cache these? */ ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) New commits: commit f871b82edfd632f79ec7bdd0b4d560cd348d8b1a Author: Oliver Sander Date: Fri Sep 8 23:27:45 2017 +0200 qt5: ArthurOutputDev: Fix several small bugs related to dash pattern handling diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 9810de97..14c79813 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -185,9 +185,23 @@ void ArthurOutputDev::updateLineDash(GfxState *state) int dashLength; double dashStart; state->getLineDash(&dashPattern, &dashLength, &dashStart); + + // Special handling for zero-length patterns, i.e., solid lines. + // Simply calling QPen::setDashPattern with an empty pattern does *not* + // result in a solid line. Rather, the current pattern is unchanged. + // See the implementation of the setDashPattern method in the file qpen.cpp. + if (dashLength==0) + { +m_currentPen.setStyle(Qt::SolidLine); +m_painter->setPen(m_currentPen); +return; + } + QVector pattern(dashLength); for (int i = 0; i < dashLength; ++i) { -pattern[i] = dashPattern[i]; +// pdf measures the dash pattern in dots, but Qt uses the +// line width as the unit. +pattern[i] = dashPattern[i] / state->getLineWidth(); } m_currentPen.setDashPattern(pattern); m_currentPen.setDashOffset(dashStart); @@ -244,6 +258,11 @@ void ArthurOutputDev::updateLineWidth(GfxState *state) { m_currentPen.setWidthF(state->getLineWidth()); m_painter->setPen(m_currentPen); + // The updateLineDash method needs to know the line width, but it is sometimes + // called before the updateLineWidth method. To make sure that the last call + // to updateLineDash before a drawing operation is always with the correct line + // width, we call it here, right after a change to the line width. + updateLineDash(state); } void ArthurOutputDev::updateFillColor(GfxState *state) ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler
[poppler] qt5/src
qt5/src/ArthurOutputDev.cc | 67 + qt5/src/ArthurOutputDev.h |9 ++ 2 files changed, 76 insertions(+) New commits: commit 3ec5e86ca000653525650a99755c85e512a04bdc Author: Oliver Sander Date: Fri Sep 29 21:24:23 2017 +0200 qt5: ArthurOutputDev: Implement the drawSoftMaskedImage method diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index ca0e0b27..9810de97 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -849,3 +849,70 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, delete imgStr; } + +void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GfxImageColorMap *maskColorMap, + GBool maskInterpolate) +{ + // Bail out if the image size doesn't match the mask size. I don't know + // what to do in this case. + if (width!=maskWidth || height!=maskHeight) + { +qDebug() << "Soft mask size does not match image size!"; +drawImage(state, ref, str, width, height, colorMap, interpolate, nullptr, gFalse); + } + + // Bail out if the mask isn't a single channel. I don't know + // what to do in this case. + if (maskColorMap->getColorSpace()->getNComps() != 1) + { +qDebug() << "Soft mask is not a single 8-bit channel!"; +drawImage(state, ref, str, width, height, colorMap, interpolate, nullptr, gFalse); + } + + /* TODO: Do we want to cache these? */ + std::unique_ptr imgStr(new ImageStream(str, width, + colorMap->getNumPixelComps(), + colorMap->getBits())); + imgStr->reset(); + + std::unique_ptr maskImageStr(new ImageStream(maskStr, maskWidth, + maskColorMap->getNumPixelComps(), + maskColorMap->getBits())); + maskImageStr->reset(); + + QImage image(width, height, QImage::Format_ARGB32); + unsigned int *data = (unsigned int *)image.bits(); + int stride = image.bytesPerLine()/4; + + std::vector maskLine(maskWidth); + + for (int y = 0; y < height; y++) { + +Guchar *pix = imgStr->getLine(); +Guchar *maskPix = maskImageStr->getLine(); + +// Invert the vertical coordinate: y is increasing from top to bottom +// on the page, but y is increasing bottom to top in the picture. +unsigned int* line = data+(height-1-y)*stride; +colorMap->getRGBLine(pix, line, width); + +// Apply the mask values to the image alpha channel +maskColorMap->getGrayLine(maskPix, maskLine.data(), width); +for (int x = 0; x < width; x++) +{ + *line = *line | (maskLine[x]<<24); + line++; +} + } + + // At this point, the QPainter coordinate transformation (CTM) is such + // that QRect(0,0,1,1) is exactly the area of the image. + m_painter->drawImage( QRect(0,0,1,1), image ); +} + diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index dc8b547c..9ebdcec1 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -151,6 +151,15 @@ public: int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg) override; + void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GfxImageColorMap *maskColorMap, + GBool maskInterpolate) override; + //- Type 3 font operators void type3D0(GfxState *state, double wx, double wy) override; void type3D1(GfxState *state, double wx, double wy, ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler