2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-02-03 20:38:25 +00:00

In QPDFJob push the page_heap from QPDFJob down to handlePageSpecs

This commit is contained in:
m-holger 2024-04-16 09:47:27 +01:00
parent e1ca10ccc4
commit 3683938caa
2 changed files with 15 additions and 10 deletions

View File

@ -511,7 +511,7 @@ class QPDFJob
// Transformations
void setQPDFOptions(QPDF& pdf);
void handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap);
bool handlePageSpecs(QPDF& pdf);
bool shouldRemoveUnreferencedResources(QPDF& pdf);
void handleRotations(QPDF& pdf);
std::map<std::pair<int, size_t>, std::vector<int>>

View File

@ -486,9 +486,10 @@ QPDFJob::createQPDF()
pdf.updateFromJSON(m->update_from_json);
}
std::vector<std::unique_ptr<QPDF>> page_heap;
if (!m->page_specs.empty()) {
handlePageSpecs(pdf, page_heap);
if (!handlePageSpecs(pdf)) {
m->warnings = true;
}
}
if (!m->rotations.empty()) {
handleRotations(pdf);
@ -496,11 +497,6 @@ QPDFJob::createQPDF()
handleUnderOverlay(pdf);
handleTransformations(pdf);
for (auto& foreign: page_heap) {
if (foreign->anyWarnings()) {
m->warnings = true;
}
}
return pdf_sp;
}
@ -2381,9 +2377,12 @@ added_page(QPDF& pdf, QPDFPageObjectHelper page)
return added_page(pdf, page.getObjectHandle());
}
void
QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap)
// Handle all page specifications. Return true if it succeeded without warnings.
bool
QPDFJob::handlePageSpecs(QPDF& pdf)
{
std::vector<std::unique_ptr<QPDF>> page_heap;
// Parse all page specifications and translate them into lists of actual pages.
// Handle "." as a shortcut for the input file
@ -2655,6 +2654,12 @@ QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_hea
}
}
}
for (auto& foreign: page_heap) {
if (foreign->anyWarnings()) {
return false;
}
}
return true;
}
void