Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master_github
Browse files Browse the repository at this point in the history
  • Loading branch information
tsdgeos committed Jul 6, 2024
2 parents 44cfa59 + 35b16a5 commit 439c7b4
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 75 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (ECM_FOUND)
endif()

set(POPPLER_MAJOR_VERSION "24")
set(POPPLER_MINOR_VERSION_STRING "06")
set(POPPLER_MINOR_VERSION_STRING "07")
# We want the string version to have 08 but the integer version can't have a leading 0 since otherwise it's considered octal
# So strip a leading 0 if found in POPPLER_MINOR_VERSION_STRING and store the result in POPPLER_MINOR_VERSION
string(REGEX REPLACE "^0?(.+)$" "\\1" POPPLER_MINOR_VERSION "${POPPLER_MINOR_VERSION_STRING}")
Expand Down Expand Up @@ -614,7 +614,7 @@ ADD_GPERF_FILE(TimesItalicWidths)
ADD_GPERF_FILE(TimesRomanWidths)
ADD_GPERF_FILE(ZapfDingbatsWidths)

set(POPPLER_SOVERSION_NUMBER "138")
set(POPPLER_SOVERSION_NUMBER "139")

set(LINKER_SCRIPT "${CMAKE_BINARY_DIR}/libpoppler.map")
configure_file(
Expand Down
19 changes: 19 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
Release 24.07.0:
core:
* Fix crashes in broken files
* Internal code improvements

qt6:
* Add getters for document additional actions
* Implement reset forms link

qt5:
* Add getters for document additional actions
* Implement reset forms link

utils:
* pdfinfo: Fix crash in broken documents when using -dests

build system:
* Mark glib-mkenums as required

Release 24.06.0:
core:
* Performance improvements in some files
Expand Down
2 changes: 1 addition & 1 deletion cpp/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = "Poppler CPP"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 24.06.0
PROJECT_NUMBER = 24.07.0

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
71 changes: 11 additions & 60 deletions poppler/Catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
// Copyright (C) 2021 RM <rm+git@arcsin.org>
// Copyright (C) 2023 Ilaï Deutel <idtl@google.com>
// Copyright (C) 2024 Hubert Figuiere <hub@figuiere.net>
// Copyright (C) 2024 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
Expand All @@ -52,7 +53,6 @@

#include <cstddef>
#include <cstdlib>
#include "goo/gmem.h"
#include "Object.h"
#include "PDFDoc.h"
#include "XRef.h"
Expand Down Expand Up @@ -640,23 +640,8 @@ Catalog::PageLayout Catalog::getPageLayout()
return pageLayout;
}

NameTree::NameTree()
{
size = 0;
length = 0;
entries = nullptr;
}

NameTree::~NameTree()
{
int i;

for (i = 0; i < length; i++) {
delete entries[i];
}

gfree(entries);
}
NameTree::NameTree() = default;
NameTree::~NameTree() = default;

NameTree::Entry::Entry(Array *array, int index)
{
Expand All @@ -673,36 +658,13 @@ NameTree::Entry::Entry(Array *array, int index)

NameTree::Entry::~Entry() { }

void NameTree::addEntry(Entry *entry)
{
if (length == size) {
if (length == 0) {
size = 8;
} else {
size *= 2;
}
entries = (Entry **)grealloc(entries, sizeof(Entry *) * size);
}

entries[length] = entry;
++length;
}

int NameTree::Entry::cmpEntry(const void *voidEntry, const void *voidOtherEntry)
{
Entry *entry = *(NameTree::Entry **)voidEntry;
Entry *otherEntry = *(NameTree::Entry **)voidOtherEntry;

return entry->name.cmp(&otherEntry->name);
}

void NameTree::init(XRef *xrefA, Object *tree)
{
xref = xrefA;
RefRecursionChecker seen;
parse(tree, seen);
if (entries && length > 0) {
qsort(entries, length, sizeof(Entry *), Entry::cmpEntry);
if (!entries.empty()) {
std::sort(entries.begin(), entries.end(), [](const auto &first, const auto &second) { return first->name.cmp(&second->name) < 0; });
}
}

Expand All @@ -716,10 +678,8 @@ void NameTree::parse(const Object *tree, RefRecursionChecker &seen)
Object names = tree->dictLookup("Names");
if (names.isArray()) {
for (int i = 0; i < names.arrayGetLength(); i += 2) {
NameTree::Entry *entry;

entry = new Entry(names.getArray(), i);
addEntry(entry);
auto entry = std::make_unique<Entry>(names.getArray(), i);
entries.push_back(std::move(entry));
}
}

Expand All @@ -744,20 +704,11 @@ void NameTree::parse(const Object *tree, RefRecursionChecker &seen)
}
}

int NameTree::Entry::cmp(const void *voidKey, const void *voidEntry)
{
GooString *key = (GooString *)voidKey;
Entry *entry = *(NameTree::Entry **)voidEntry;

return key->cmp(&entry->name);
}

Object NameTree::lookup(const GooString *name)
{
Entry **entry;
auto entry = std::lower_bound(entries.begin(), entries.end(), name, [](const auto &element, const GooString *n) { return element->name.cmp(n) < 0; });

entry = (Entry **)bsearch(name, entries, length, sizeof(Entry *), Entry::cmp);
if (entry != nullptr) {
if (entry != entries.end() && (*entry)->name.cmp(name) == 0) {
return (*entry)->value.fetch(xref);
} else {
error(errSyntaxError, -1, "failed to look up ({0:s})", name->c_str());
Expand All @@ -767,7 +718,7 @@ Object NameTree::lookup(const GooString *name)

Object *NameTree::getValue(int index)
{
if (index < length) {
if (size_t(index) < entries.size()) {
return &entries[index]->value;
} else {
return nullptr;
Expand All @@ -776,7 +727,7 @@ Object *NameTree::getValue(int index)

const GooString *NameTree::getName(int index) const
{
if (index < length) {
if (size_t(index) < entries.size()) {
return &entries[index]->name;
} else {
return nullptr;
Expand Down
11 changes: 3 additions & 8 deletions poppler/Catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
// Copyright (C) 2020 Katarina Behrens <Katarina.Behrens@cib.de>
// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden
// Copyright (C) 2021 RM <rm+git@arcsin.org>
// Copyright (C) 2024 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
Expand Down Expand Up @@ -78,7 +79,7 @@ class POPPLER_PRIVATE_EXPORT NameTree

void init(XRef *xref, Object *tree);
Object lookup(const GooString *name);
int numEntries() { return length; };
int numEntries() { return entries.size(); };
// iterator accessor, note it returns a pointer to the internal object, do not free nor delete it
Object *getValue(int i);
const GooString *getName(int i) const;
Expand All @@ -90,18 +91,12 @@ class POPPLER_PRIVATE_EXPORT NameTree
~Entry();
GooString name;
Object value;
static int cmpEntry(const void *voidEntry, const void *voidOtherEntry);
static int cmp(const void *key, const void *entry);
};

void parse(const Object *tree, RefRecursionChecker &seen);
void addEntry(Entry *entry);

XRef *xref;
Entry **entries;
int size, length; // size is the number of entries in
// the array of Entry*
// length is the number of real Entry
std::vector<std::unique_ptr<Entry>> entries;
};

//------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion qt5/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set(poppler_qt5_SRCS
)
add_library(poppler-qt5 ${poppler_qt5_SRCS})
generate_export_header(poppler-qt5 BASE_NAME poppler-qt5 EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/poppler-export.h")
set_target_properties(poppler-qt5 PROPERTIES VERSION 1.34.0 SOVERSION 1)
set_target_properties(poppler-qt5 PROPERTIES VERSION 1.35.0 SOVERSION 1)
if(MINGW AND BUILD_SHARED_LIBS)
get_target_property(POPPLER_QT5_SOVERSION poppler-qt5 SOVERSION)
set_target_properties(poppler-qt5 PROPERTIES SUFFIX "-${POPPLER_QT5_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
Expand Down
2 changes: 1 addition & 1 deletion qt5/src/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = "Poppler Qt5"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 24.06.0
PROJECT_NUMBER = 24.07.0

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
2 changes: 1 addition & 1 deletion qt6/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set(poppler_qt6_SRCS
)
add_library(poppler-qt6 ${poppler_qt6_SRCS})
generate_export_header(poppler-qt6 BASE_NAME poppler-qt6 EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/poppler-export.h")
set_target_properties(poppler-qt6 PROPERTIES VERSION 3.5.0 SOVERSION 3)
set_target_properties(poppler-qt6 PROPERTIES VERSION 3.6.0 SOVERSION 3)
if(MINGW AND BUILD_SHARED_LIBS)
get_target_property(POPPLER_QT6_SOVERSION poppler-qt6 SOVERSION)
set_target_properties(poppler-qt6 PROPERTIES SUFFIX "-${POPPLER_QT6_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
Expand Down
2 changes: 1 addition & 1 deletion qt6/src/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = "Poppler Qt6"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 24.06.0
PROJECT_NUMBER = 24.07.0

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
4 changes: 4 additions & 0 deletions qt6/tests/check_links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ void TestLinks::checkDests_xr02()
dest = doc->linkDestination(QStringLiteral("section.3"));
QVERIFY(!isDestinationValid_pageNumber(dest.get(), doc.get()));
QVERIFY(isDestinationValid_name(dest.get()));
// Better check that a link that should be in the middle of the sorted names does not give one of the neighboring ones
dest = doc->linkDestination(QStringLiteral("section.15"));
QVERIFY(!isDestinationValid_pageNumber(dest.get(), doc.get()));
QVERIFY(isDestinationValid_name(dest.get()));
}

void TestLinks::checkDocumentURILink()
Expand Down

0 comments on commit 439c7b4

Please sign in to comment.