mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Refactor overlay/underlay in preparation for change
This commit is contained in:
parent
e65bb2c5c2
commit
48bacbf2e6
@ -526,15 +526,14 @@ class QPDFJob
|
||||
void
|
||||
getUOPagenos(UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos);
|
||||
void handleUnderOverlay(QPDF& pdf);
|
||||
void doUnderOverlayForPage(
|
||||
std::string doUnderOverlayForPage(
|
||||
QPDF& pdf,
|
||||
UnderOverlay& uo,
|
||||
std::map<int, std::vector<int>>& pagenos,
|
||||
size_t page_idx,
|
||||
std::map<int, QPDFObjectHandle>& fo,
|
||||
std::vector<QPDFPageObjectHelper>& pages,
|
||||
QPDFPageObjectHelper& dest_page,
|
||||
bool before);
|
||||
QPDFPageObjectHelper& dest_page);
|
||||
void validateUnderOverlay(QPDF& pdf, UnderOverlay* uo);
|
||||
void handleTransformations(QPDF& pdf);
|
||||
void addAttachments(QPDF& pdf);
|
||||
|
@ -2056,7 +2056,7 @@ get_afdh_for_qpdf(
|
||||
return afdh_map[uid].get();
|
||||
}
|
||||
|
||||
void
|
||||
std::string
|
||||
QPDFJob::doUnderOverlayForPage(
|
||||
QPDF& pdf,
|
||||
UnderOverlay& uo,
|
||||
@ -2064,12 +2064,11 @@ QPDFJob::doUnderOverlayForPage(
|
||||
size_t page_idx,
|
||||
std::map<int, QPDFObjectHandle>& fo,
|
||||
std::vector<QPDFPageObjectHelper>& pages,
|
||||
QPDFPageObjectHelper& dest_page,
|
||||
bool before)
|
||||
QPDFPageObjectHelper& dest_page)
|
||||
{
|
||||
int pageno = 1 + QIntC::to_int(page_idx);
|
||||
if (!pagenos.count(pageno)) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>
|
||||
@ -2121,14 +2120,7 @@ QPDFJob::doUnderOverlayForPage(
|
||||
content += new_content;
|
||||
}
|
||||
}
|
||||
if (!content.empty()) {
|
||||
if (before) {
|
||||
dest_page.addPageContents(pdf.newStream(content), true);
|
||||
} else {
|
||||
dest_page.addPageContents(pdf.newStream("q\n"), true);
|
||||
dest_page.addPageContents(pdf.newStream("\nQ\n" + content), false);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2182,24 +2174,29 @@ QPDFJob::handleUnderOverlay(QPDF& pdf)
|
||||
doIfVerbose([&](Pipeline& v, std::string const& prefix) {
|
||||
v << " page " << 1 + i << "\n";
|
||||
});
|
||||
doUnderOverlayForPage(
|
||||
auto pageno = QIntC::to_int(i) + 1;
|
||||
if (!(underlay_pagenos.count(pageno) ||
|
||||
overlay_pagenos.count(pageno))) {
|
||||
continue;
|
||||
}
|
||||
auto& dest_page = main_pages.at(i);
|
||||
auto content = doUnderOverlayForPage(
|
||||
pdf,
|
||||
m->underlay,
|
||||
underlay_pagenos,
|
||||
i,
|
||||
underlay_fo,
|
||||
upages,
|
||||
main_pages.at(i),
|
||||
true);
|
||||
doUnderOverlayForPage(
|
||||
pdf,
|
||||
m->overlay,
|
||||
overlay_pagenos,
|
||||
i,
|
||||
overlay_fo,
|
||||
opages,
|
||||
main_pages.at(i),
|
||||
false);
|
||||
dest_page);
|
||||
if (!content.empty()) {
|
||||
dest_page.addPageContents(pdf.newStream(content), true);
|
||||
}
|
||||
content = doUnderOverlayForPage(
|
||||
pdf, m->overlay, overlay_pagenos, i, overlay_fo, opages, dest_page);
|
||||
if (!content.empty()) {
|
||||
dest_page.addPageContents(pdf.newStream("q\n"), true);
|
||||
dest_page.addPageContents(pdf.newStream("\nQ\n" + content), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user