[poppler] qt5/src qt5/tests qt6/src qt6/tests
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 14 20:33:14 UTC 2021
qt5/src/poppler-document.cc | 5 +++++
qt5/src/poppler-qt5.h | 20 +++++++++++++++++++-
qt5/tests/check_metadata.cpp | 7 +++----
qt5/tests/stress-poppler-dir.cpp | 7 +++++--
qt5/tests/stress-poppler-qt5.cpp | 4 ++--
qt5/tests/test-password-qt5.cpp | 5 ++---
qt5/tests/test-poppler-qt5.cpp | 5 ++---
qt6/src/poppler-document.cc | 7 ++-----
qt6/src/poppler-qt6.h | 14 +++++++++-----
qt6/tests/check_metadata.cpp | 7 +++----
qt6/tests/stress-poppler-dir.cpp | 4 ++--
qt6/tests/stress-poppler-qt6.cpp | 4 ++--
qt6/tests/test-password-qt6.cpp | 5 ++---
qt6/tests/test-poppler-qt6.cpp | 5 ++---
14 files changed, 60 insertions(+), 39 deletions(-)
New commits:
commit 13c95f251bf47068a3c083bf038cab86fea7f570
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date: Fri Jul 9 11:55:24 2021 +0200
Make getPdfVersion return a dedicated version object
That's a bit more modern than the old way where pointers to two
integers had to be passed to the method.
With the new method you can write
auto pdfVersion = doc->getPdfVersion();
// access numbers as pdfVersion.major and pdfVersion.minor
instead of
int major, minor;
doc->getPdfVersion(&major, &minor);
With C++17 you can even write
auto [major, minor] = doc->getPdfVersion();
The new method is put alongside the old one in the Qt5 interface.
It replaces the old one in the Qt6 interface.
diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc
index 6118ccdd..25835f35 100644
--- a/qt5/src/poppler-document.cc
+++ b/qt5/src/poppler-document.cc
@@ -556,6 +556,11 @@ void Document::getPdfVersion(int *major, int *minor) const
*minor = m_doc->doc->getPDFMinorVersion();
}
+Document::PdfVersion Document::getPdfVersion() const
+{
+ return PdfVersion { m_doc->doc->getPDFMajorVersion(), m_doc->doc->getPDFMinorVersion() };
+}
+
Page *Document::page(const QString &label) const
{
GooString label_g(label.toLatin1().data());
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index d6dbd461..dacda011 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -1648,9 +1648,27 @@ QString subject = m_doc->info("Subject");
\param minor an optional pointer to a variable where store the
"minor" number of the version
+ \deprecated Will be removed in the Qt6 interface. Use the method
+ returning a PdfVersion object instead!
+
\since 0.12
*/
- void getPdfVersion(int *major, int *minor) const;
+ Q_DECL_DEPRECATED void getPdfVersion(int *major, int *minor) const;
+
+ /** \brief The version specification of a pdf file */
+ struct PdfVersion
+ {
+ int major;
+ int minor;
+ };
+
+ /**
+ The version of the PDF specification that the document
+ conforms to
+
+ \since 21.08
+ */
+ PdfVersion getPdfVersion() const;
/**
The fonts within the PDF document.
diff --git a/qt5/tests/check_metadata.cpp b/qt5/tests/check_metadata.cpp
index 6167d9c3..90ebba04 100644
--- a/qt5/tests/check_metadata.cpp
+++ b/qt5/tests/check_metadata.cpp
@@ -226,10 +226,9 @@ void TestMetaData::checkVersion()
doc = Poppler::Document::load(TESTDATADIR "/unittestcases/doublepage.pdf");
QVERIFY(doc);
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
- QCOMPARE(major, 1);
- QCOMPARE(minor, 6);
+ auto pdfVersion = doc->getPdfVersion();
+ QCOMPARE(pdfVersion.major, 1);
+ QCOMPARE(pdfVersion.minor, 6);
delete doc;
}
diff --git a/qt5/tests/stress-poppler-dir.cpp b/qt5/tests/stress-poppler-dir.cpp
index 6db57129..8cac185b 100644
--- a/qt5/tests/stress-poppler-dir.cpp
+++ b/qt5/tests/stress-poppler-dir.cpp
@@ -28,8 +28,11 @@ int main(int argc, char **argv)
delete doc;
}
} else {
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
+ auto pdfVersion = doc->getPdfVersion();
+ if (pdfVersion.major != 1) {
+ qWarning() << "pdf major version is not '1'";
+ }
+
doc->info(QStringLiteral("Title"));
doc->info(QStringLiteral("Subject"));
doc->info(QStringLiteral("Author"));
diff --git a/qt5/tests/stress-poppler-qt5.cpp b/qt5/tests/stress-poppler-qt5.cpp
index 07f8cdf2..31795f96 100644
--- a/qt5/tests/stress-poppler-qt5.cpp
+++ b/qt5/tests/stress-poppler-qt5.cpp
@@ -36,8 +36,8 @@ int main(int argc, char **argv)
if (!doc) {
qWarning() << "doc not loaded";
} else {
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
+ auto pdfVersion = doc->getPdfVersion();
+ Q_UNUSED(pdfVersion);
doc->info(QStringLiteral("Title"));
doc->info(QStringLiteral("Subject"));
doc->info(QStringLiteral("Author"));
diff --git a/qt5/tests/test-password-qt5.cpp b/qt5/tests/test-password-qt5.cpp
index a85ecb21..530b3ac2 100644
--- a/qt5/tests/test-password-qt5.cpp
+++ b/qt5/tests/test-password-qt5.cpp
@@ -95,9 +95,8 @@ int main(int argc, char **argv)
}
// output some meta-data
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
- qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(major).arg(minor));
+ auto pdfVersion = doc->getPdfVersion();
+ qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(pdfVersion.major).arg(pdfVersion.minor));
qDebug() << " Title: " << doc->info(QStringLiteral("Title"));
qDebug() << " Subject: " << doc->info(QStringLiteral("Subject"));
qDebug() << " Author: " << doc->info(QStringLiteral("Author"));
diff --git a/qt5/tests/test-poppler-qt5.cpp b/qt5/tests/test-poppler-qt5.cpp
index 182e5eae..3ccc83f2 100644
--- a/qt5/tests/test-poppler-qt5.cpp
+++ b/qt5/tests/test-poppler-qt5.cpp
@@ -150,9 +150,8 @@ int main(int argc, char **argv)
}
// output some meta-data
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
- qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(major).arg(minor));
+ Poppler::Document::PdfVersion pdfVersion = doc->getPdfVersion();
+ qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(pdfVersion.major).arg(pdfVersion.minor));
qDebug() << " Title: " << doc->info(QStringLiteral("Title"));
qDebug() << " Subject: " << doc->info(QStringLiteral("Subject"));
qDebug() << " Author: " << doc->info(QStringLiteral("Author"));
diff --git a/qt6/src/poppler-document.cc b/qt6/src/poppler-document.cc
index a84dd7e7..4725c1b7 100644
--- a/qt6/src/poppler-document.cc
+++ b/qt6/src/poppler-document.cc
@@ -548,12 +548,9 @@ bool Document::okToAssemble() const
return m_doc->doc->okToAssemble();
}
-void Document::getPdfVersion(int *major, int *minor) const
+Document::PdfVersion Document::getPdfVersion() const
{
- if (major)
- *major = m_doc->doc->getPDFMajorVersion();
- if (minor)
- *minor = m_doc->doc->getPDFMinorVersion();
+ return PdfVersion { m_doc->doc->getPDFMajorVersion(), m_doc->doc->getPDFMinorVersion() };
}
std::unique_ptr<Page> Document::page(const QString &label) const
diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h
index 2ab7097d..9650b97e 100644
--- a/qt6/src/poppler-qt6.h
+++ b/qt6/src/poppler-qt6.h
@@ -1514,16 +1514,20 @@ QString subject = m_doc->info("Subject");
*/
bool okToAssemble() const;
+ /** \brief The version specification of a pdf file */
+ struct PdfVersion
+ {
+ int major;
+ int minor;
+ };
+
/**
The version of the PDF specification that the document
conforms to
- \param major an optional pointer to a variable where store the
- "major" number of the version
- \param minor an optional pointer to a variable where store the
- "minor" number of the version
+ \since 21.08
*/
- void getPdfVersion(int *major, int *minor) const;
+ PdfVersion getPdfVersion() const;
/**
The fonts within the PDF document.
diff --git a/qt6/tests/check_metadata.cpp b/qt6/tests/check_metadata.cpp
index 2a456bed..9c5c722c 100644
--- a/qt6/tests/check_metadata.cpp
+++ b/qt6/tests/check_metadata.cpp
@@ -181,10 +181,9 @@ void TestMetaData::checkVersion()
std::unique_ptr<Poppler::Document> doc = Poppler::Document::load(TESTDATADIR "/unittestcases/doublepage.pdf");
QVERIFY(doc);
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
- QCOMPARE(major, 1);
- QCOMPARE(minor, 6);
+ auto pdfVersion = doc->getPdfVersion();
+ QCOMPARE(pdfVersion.major, 1);
+ QCOMPARE(pdfVersion.minor, 6);
}
void TestMetaData::checkPdfId()
diff --git a/qt6/tests/stress-poppler-dir.cpp b/qt6/tests/stress-poppler-dir.cpp
index 9a30fc93..3f05444a 100644
--- a/qt6/tests/stress-poppler-dir.cpp
+++ b/qt6/tests/stress-poppler-dir.cpp
@@ -27,8 +27,8 @@ int main(int argc, char **argv)
qWarning() << "couldn't unlock document";
}
} else {
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
+ auto pdfVersion = doc->getPdfVersion();
+ Q_UNUSED(pdfVersion);
doc->info(QStringLiteral("Title"));
doc->info(QStringLiteral("Subject"));
doc->info(QStringLiteral("Author"));
diff --git a/qt6/tests/stress-poppler-qt6.cpp b/qt6/tests/stress-poppler-qt6.cpp
index 2f6c9026..f613b827 100644
--- a/qt6/tests/stress-poppler-qt6.cpp
+++ b/qt6/tests/stress-poppler-qt6.cpp
@@ -36,8 +36,8 @@ int main(int argc, char **argv)
if (!doc) {
qWarning() << "doc not loaded";
} else {
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
+ auto pdfVersion = doc->getPdfVersion();
+ Q_UNUSED(pdfVersion);
doc->info(QStringLiteral("Title"));
doc->info(QStringLiteral("Subject"));
doc->info(QStringLiteral("Author"));
diff --git a/qt6/tests/test-password-qt6.cpp b/qt6/tests/test-password-qt6.cpp
index befcbdfb..e4a247cd 100644
--- a/qt6/tests/test-password-qt6.cpp
+++ b/qt6/tests/test-password-qt6.cpp
@@ -91,9 +91,8 @@ int main(int argc, char **argv)
}
// output some meta-data
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
- qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(major).arg(minor));
+ auto pdfVersion = doc->getPdfVersion();
+ qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(pdfVersion.major).arg(pdfVersion.minor));
qDebug() << " Title: " << doc->info(QStringLiteral("Title"));
qDebug() << " Subject: " << doc->info(QStringLiteral("Subject"));
qDebug() << " Author: " << doc->info(QStringLiteral("Author"));
diff --git a/qt6/tests/test-poppler-qt6.cpp b/qt6/tests/test-poppler-qt6.cpp
index 3c90232f..5a0742db 100644
--- a/qt6/tests/test-poppler-qt6.cpp
+++ b/qt6/tests/test-poppler-qt6.cpp
@@ -144,9 +144,8 @@ int main(int argc, char **argv)
}
// output some meta-data
- int major = 0, minor = 0;
- doc->getPdfVersion(&major, &minor);
- qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(major).arg(minor));
+ auto pdfVersion = doc->getPdfVersion();
+ qDebug() << " PDF Version: " << qPrintable(QStringLiteral("%1.%2").arg(pdfVersion.major).arg(pdfVersion.minor));
qDebug() << " Title: " << doc->info(QStringLiteral("Title"));
qDebug() << " Subject: " << doc->info(QStringLiteral("Subject"));
qDebug() << " Author: " << doc->info(QStringLiteral("Author"));
More information about the poppler
mailing list