Use QPDF::newStream in library

This commit is contained in:
m-holger 2022-09-26 20:11:27 +01:00 committed by Jay Berkenbilt
parent f69ed209d0
commit 743a735ee0
6 changed files with 17 additions and 22 deletions

View File

@ -2224,7 +2224,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
obj_copier.to_copy.push_back(foreign);
QPDFObjectHandle reservation;
if (foreign.isStream()) {
reservation = QPDFObjectHandle::newStream(this);
reservation = newStream();
} else {
reservation = QPDFObjectHandle::newReserved(this);
}

View File

@ -4,6 +4,7 @@
#include <qpdf/Pl_Discard.hh>
#include <qpdf/Pl_MD5.hh>
#include <qpdf/QIntC.hh>
#include <qpdf/QPDF.hh>
#include <qpdf/QUtil.hh>
QPDFEFStreamObjectHelper::QPDFEFStreamObjectHelper(QPDFObjectHandle oh) :
@ -91,20 +92,20 @@ QPDFEFStreamObjectHelper
QPDFEFStreamObjectHelper::createEFStream(
QPDF& qpdf, std::shared_ptr<Buffer> data)
{
return newFromStream(QPDFObjectHandle::newStream(&qpdf, data));
return newFromStream(qpdf.newStream(data));
}
QPDFEFStreamObjectHelper
QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::string const& data)
{
return newFromStream(QPDFObjectHandle::newStream(&qpdf, data));
return newFromStream(qpdf.newStream(data));
}
QPDFEFStreamObjectHelper
QPDFEFStreamObjectHelper::createEFStream(
QPDF& qpdf, std::function<void(Pipeline*)> provider)
{
auto stream = QPDFObjectHandle::newStream(&qpdf);
auto stream = qpdf.newStream();
stream.replaceStreamData(
provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
return newFromStream(stream);

View File

@ -2242,13 +2242,10 @@ QPDFJob::doUnderOverlayForPage(
}
if (!content.empty()) {
if (before) {
dest_page.addPageContents(
QPDFObjectHandle::newStream(&pdf, content), true);
dest_page.addPageContents(pdf.newStream(content), true);
} else {
dest_page.addPageContents(
QPDFObjectHandle::newStream(&pdf, "q\n"), true);
dest_page.addPageContents(
QPDFObjectHandle::newStream(&pdf, "\nQ\n" + content), false);
dest_page.addPageContents(pdf.newStream("q\n"), true);
dest_page.addPageContents(pdf.newStream("\nQ\n" + content), false);
}
}
}
@ -2473,8 +2470,7 @@ QPDFJob::handleTransformations(QPDF& pdf)
if (io->evaluate(
"image " + name + " on page " +
std::to_string(pageno))) {
QPDFObjectHandle new_image =
QPDFObjectHandle::newStream(&pdf);
QPDFObjectHandle new_image = pdf.newStream();
new_image.replaceDict(image.getDict().shallowCopy());
new_image.replaceStreamData(
sdp,

View File

@ -163,8 +163,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
page_oh.replaceKey("/Annots", new_annots_oh);
}
}
page.addPageContents(QPDFObjectHandle::newStream(&qpdf, "q\n"), true);
page.addPageContents(
QPDFObjectHandle::newStream(&qpdf, "\nQ\n" + new_content), false);
page.addPageContents(qpdf.newStream("q\n"), true);
page.addPageContents(qpdf.newStream("\nQ\n" + new_content), false);
}
}

View File

@ -785,10 +785,10 @@ QPDFPageObjectHelper::getMatrixForTransformations(bool invert)
QPDFObjectHandle
QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
{
QPDF& qpdf = this->oh.getQPDF(
"QPDFPageObjectHelper::getFormXObjectForPage called with a direct "
"object");
QPDFObjectHandle result = QPDFObjectHandle::newStream(&qpdf);
auto result = this->oh
.getQPDF("QPDFPageObjectHelper::getFormXObjectForPage "
"called with a direct object")
.newStream();
QPDFObjectHandle newdict = result.getDict();
newdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));
newdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"));
@ -1062,8 +1062,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
}
std::string cm_str = std::string("q\n") + cm.unparse() + " cm\n";
this->oh.addPageContents(QPDFObjectHandle::newStream(&qpdf, cm_str), true);
this->oh.addPageContents(
QPDFObjectHandle::newStream(&qpdf, "\nQ\n"), false);
this->oh.addPageContents(qpdf.newStream("\nQ\n"), false);
this->oh.removeKey("/Rotate");
QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
if (!rotate_obj.isNull()) {

View File

@ -1696,7 +1696,7 @@ qpdf_oh
qpdf_oh_new_stream(qpdf_data qpdf)
{
QTC::TC("qpdf", "qpdf-c called qpdf_oh_new_stream");
return new_object(qpdf, QPDFObjectHandle::newStream(qpdf->qpdf.get()));
return new_object(qpdf, qpdf->qpdf->newStream());
}
void