[poppler] qt5/src qt6/src

2023-06-28 Thread GitLab Mirror
 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 qt6/src

2023-05-25 Thread GitLab Mirror
 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

2023-05-24 Thread GitLab Mirror
 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  : 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 

[poppler] qt5/src qt6/src

2023-05-12 Thread GitLab Mirror
 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

2023-05-12 Thread GitLab Mirror
 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

2023-03-20 Thread GitLab Mirror
 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 
) 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 
) 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

2022-12-03 Thread GitLab Mirror
 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

2022-09-06 Thread GitLab Mirror
 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

2022-03-03 Thread GitLab Mirror
 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

2022-03-03 Thread GitLab Mirror
 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 , QDomDocument 
) 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

2022-03-02 Thread GitLab Mirror
 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 )
 {
 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 )
 {
 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 )
 {
 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 )
 {
 Q_D(TextAnnotation);
+if (color == d->textColor) {
+return;
+}
 d->textColor = color;
 
 d->setDefaultAppearanceToNative();


[poppler] qt5/src qt6/src

2022-03-02 Thread GitLab Mirror
 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 )
 {
 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 );
-/// \since 0.69
+/// Default text color is black \since 0.69
 QColor textColor() const;
 /// \since 0.69
 void setTextColor(const QColor );
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 )
 {
 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 );
+/// Default text color is black
 QColor textColor() const;
 void setTextColor(const QColor );
 


[poppler] qt5/src qt6/src

2022-02-22 Thread GitLab Mirror
 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(),  };
 } 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(), , 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(),  };
 } 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(), , 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

2022-02-22 Thread GitLab Mirror
 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(),  };
 } 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(), , 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(),  };
 } 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(), , 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

2022-02-08 Thread GitLab Mirror
 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

2022-01-12 Thread GitLab Mirror
 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

2022-01-11 Thread GitLab Mirror
 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 )
 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 
 {
 d->documentUserPassword = password;
 }
+
+QString PDFConverter::NewSignatureData::imagePath() const
+{
+return d->imagePath;
+}
+
+void PDFConverter::NewSignatureData::setImagePath(const QString )
+{
+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 );
 
+/**
+ * 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 );
+
 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 )
 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 
 {
 d->documentUserPassword = password;
 }
+
+QString PDFConverter::NewSignatureData::imagePath() const
+{
+return d->imagePath;
+}
+
+void PDFConverter::NewSignatureData::setImagePath(const QString )
+{
+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/poppler-qt6.h
@@ -2087,6 +2087,17 @@ 

[poppler] qt5/src qt6/src

2022-01-05 Thread GitLab Mirror
 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

2022-01-05 Thread GitLab Mirror
 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 )
 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 )
 {
 d->partialName = name;
 }
+
+QByteArray PDFConverter::NewSignatureData::documentOwnerPassword() const
+{
+return d->documentOwnerPassword;
+}
+
+void PDFConverter::NewSignatureData::setDocumentOwnerPassword(const QByteArray 
)
+{
+d->documentOwnerPassword = password;
+}
+
+QByteArray PDFConverter::NewSignatureData::documentUserPassword() const
+{
+return d->documentUserPassword;
+}
+
+void PDFConverter::NewSignatureData::setDocumentUserPassword(const QByteArray 
)
+{
+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 );
 
+/**
+ * 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 );
+
+/**
+ * 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 );
+
 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 )
 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 

[poppler] qt5/src qt6/src

2021-11-24 Thread GitLab Mirror
 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

2021-09-06 Thread GitLab Mirror
 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 ) 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, ,
+m_page->parentDoc->doc->displayPageSlice(_dev, m_page->index + 1, 
72, 72, rotation, false, false, false, -1, -1, -1, -1, 
shouldAbortExtractionCallback ? shouldAbortExtractionInternalCallback : 
nullAbortCallBack, ,
  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 ) 
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, ,
+m_page->parentDoc->doc->displayPageSlice(_dev, m_page->index + 1, 
72, 72, rotation, false, false, false, -1, -1, -1, -1, 
shouldAbortExtractionCallback ? shouldAbortExtractionInternalCallback : 
nullAbortCallBack, ,
  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 qt6/src

2021-07-08 Thread GitLab Mirror
 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

2021-05-07 Thread GitLab Mirror
 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 )
 void XPDFReader::invTransform(const double *M, const QPointF p, double , 
double )
 {
 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 )
 void XPDFReader::invTransform(const double *M, const QPointF p, double , 
double )
 {
 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

2021-04-20 Thread GitLab Mirror
 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 )
 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 )
 {
 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 );
 
+/**
+ * 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 )
 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 )
 {
 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 published by
@@ -1955,7 

[poppler] qt5/src qt6/src

2021-04-20 Thread GitLab Mirror
 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 )
 ::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 )
 
 Object refObj(ref);
 AnnotWidget *signatureAnnot = new AnnotWidget(doc, , , 
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();
 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 )
 ::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 )
 
 Object refObj(ref);
 AnnotWidget *signatureAnnot = new AnnotWidget(doc, , , 
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();
 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 qt6/src

2021-03-21 Thread GitLab Mirror
 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

2021-01-17 Thread GitLab Mirror
 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(, format, ap);
+const size_t bufsize = poppler_vasprintf(, 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(, format, ap);
+const size_t bufsize = poppler_vasprintf(, 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

2021-01-15 Thread GitLab Mirror
 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

2020-12-30 Thread GitLab Mirror
 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(, 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(, 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

2020-12-29 Thread GitLab Mirror
 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  = 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  = 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

2020-12-18 Thread GitLab Mirror
 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

2020-12-18 Thread GitLab Mirror
 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 ) 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 );
 
 /**
   Sets the callback for NSS password requests
 
-  \since 20.12
+  \since 21.01
 */
 void POPPLER_QT5_EXPORT setNSSPasswordCallback(const std::function );
 }
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 );
 
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 ) 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 );
 
 /**
   Sets the callback for NSS password requests
 
-  \since 20.12
+  \since 21.01
 */
 void POPPLER_QT6_EXPORT setNSSPasswordCallback(const std::function );
 }
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 );
 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] qt5/src qt6/src

2020-08-25 Thread GitLab Mirror
 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 qt6/src

2020-08-21 Thread GitLab Mirror
 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 );
 
+// 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 );
 
+// 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