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