Commit 743a735ee008a4bd70cfac97634f350d9a2d46f1

Authored by m-holger
Committed by Jay Berkenbilt
1 parent f69ed209

Use QPDF::newStream in library

libqpdf/QPDF.cc
@@ -2224,7 +2224,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top) @@ -2224,7 +2224,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
2224 obj_copier.to_copy.push_back(foreign); 2224 obj_copier.to_copy.push_back(foreign);
2225 QPDFObjectHandle reservation; 2225 QPDFObjectHandle reservation;
2226 if (foreign.isStream()) { 2226 if (foreign.isStream()) {
2227 - reservation = QPDFObjectHandle::newStream(this); 2227 + reservation = newStream();
2228 } else { 2228 } else {
2229 reservation = QPDFObjectHandle::newReserved(this); 2229 reservation = QPDFObjectHandle::newReserved(this);
2230 } 2230 }
libqpdf/QPDFEFStreamObjectHelper.cc
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 #include <qpdf/Pl_Discard.hh> 4 #include <qpdf/Pl_Discard.hh>
5 #include <qpdf/Pl_MD5.hh> 5 #include <qpdf/Pl_MD5.hh>
6 #include <qpdf/QIntC.hh> 6 #include <qpdf/QIntC.hh>
  7 +#include <qpdf/QPDF.hh>
7 #include <qpdf/QUtil.hh> 8 #include <qpdf/QUtil.hh>
8 9
9 QPDFEFStreamObjectHelper::QPDFEFStreamObjectHelper(QPDFObjectHandle oh) : 10 QPDFEFStreamObjectHelper::QPDFEFStreamObjectHelper(QPDFObjectHandle oh) :
@@ -91,20 +92,20 @@ QPDFEFStreamObjectHelper @@ -91,20 +92,20 @@ QPDFEFStreamObjectHelper
91 QPDFEFStreamObjectHelper::createEFStream( 92 QPDFEFStreamObjectHelper::createEFStream(
92 QPDF& qpdf, std::shared_ptr<Buffer> data) 93 QPDF& qpdf, std::shared_ptr<Buffer> data)
93 { 94 {
94 - return newFromStream(QPDFObjectHandle::newStream(&qpdf, data)); 95 + return newFromStream(qpdf.newStream(data));
95 } 96 }
96 97
97 QPDFEFStreamObjectHelper 98 QPDFEFStreamObjectHelper
98 QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::string const& data) 99 QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::string const& data)
99 { 100 {
100 - return newFromStream(QPDFObjectHandle::newStream(&qpdf, data)); 101 + return newFromStream(qpdf.newStream(data));
101 } 102 }
102 103
103 QPDFEFStreamObjectHelper 104 QPDFEFStreamObjectHelper
104 QPDFEFStreamObjectHelper::createEFStream( 105 QPDFEFStreamObjectHelper::createEFStream(
105 QPDF& qpdf, std::function<void(Pipeline*)> provider) 106 QPDF& qpdf, std::function<void(Pipeline*)> provider)
106 { 107 {
107 - auto stream = QPDFObjectHandle::newStream(&qpdf); 108 + auto stream = qpdf.newStream();
108 stream.replaceStreamData( 109 stream.replaceStreamData(
109 provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 110 provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
110 return newFromStream(stream); 111 return newFromStream(stream);
libqpdf/QPDFJob.cc
@@ -2242,13 +2242,10 @@ QPDFJob::doUnderOverlayForPage( @@ -2242,13 +2242,10 @@ QPDFJob::doUnderOverlayForPage(
2242 } 2242 }
2243 if (!content.empty()) { 2243 if (!content.empty()) {
2244 if (before) { 2244 if (before) {
2245 - dest_page.addPageContents(  
2246 - QPDFObjectHandle::newStream(&pdf, content), true); 2245 + dest_page.addPageContents(pdf.newStream(content), true);
2247 } else { 2246 } else {
2248 - dest_page.addPageContents(  
2249 - QPDFObjectHandle::newStream(&pdf, "q\n"), true);  
2250 - dest_page.addPageContents(  
2251 - QPDFObjectHandle::newStream(&pdf, "\nQ\n" + content), false); 2247 + dest_page.addPageContents(pdf.newStream("q\n"), true);
  2248 + dest_page.addPageContents(pdf.newStream("\nQ\n" + content), false);
2252 } 2249 }
2253 } 2250 }
2254 } 2251 }
@@ -2473,8 +2470,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf) @@ -2473,8 +2470,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2473 if (io->evaluate( 2470 if (io->evaluate(
2474 "image " + name + " on page " + 2471 "image " + name + " on page " +
2475 std::to_string(pageno))) { 2472 std::to_string(pageno))) {
2476 - QPDFObjectHandle new_image =  
2477 - QPDFObjectHandle::newStream(&pdf); 2473 + QPDFObjectHandle new_image = pdf.newStream();
2478 new_image.replaceDict(image.getDict().shallowCopy()); 2474 new_image.replaceDict(image.getDict().shallowCopy());
2479 new_image.replaceStreamData( 2475 new_image.replaceStreamData(
2480 sdp, 2476 sdp,
libqpdf/QPDFPageDocumentHelper.cc
@@ -163,8 +163,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( @@ -163,8 +163,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
163 page_oh.replaceKey("/Annots", new_annots_oh); 163 page_oh.replaceKey("/Annots", new_annots_oh);
164 } 164 }
165 } 165 }
166 - page.addPageContents(QPDFObjectHandle::newStream(&qpdf, "q\n"), true);  
167 - page.addPageContents(  
168 - QPDFObjectHandle::newStream(&qpdf, "\nQ\n" + new_content), false); 166 + page.addPageContents(qpdf.newStream("q\n"), true);
  167 + page.addPageContents(qpdf.newStream("\nQ\n" + new_content), false);
169 } 168 }
170 } 169 }
libqpdf/QPDFPageObjectHelper.cc
@@ -785,10 +785,10 @@ QPDFPageObjectHelper::getMatrixForTransformations(bool invert) @@ -785,10 +785,10 @@ QPDFPageObjectHelper::getMatrixForTransformations(bool invert)
785 QPDFObjectHandle 785 QPDFObjectHandle
786 QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations) 786 QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
787 { 787 {
788 - QPDF& qpdf = this->oh.getQPDF(  
789 - "QPDFPageObjectHelper::getFormXObjectForPage called with a direct "  
790 - "object");  
791 - QPDFObjectHandle result = QPDFObjectHandle::newStream(&qpdf); 788 + auto result = this->oh
  789 + .getQPDF("QPDFPageObjectHelper::getFormXObjectForPage "
  790 + "called with a direct object")
  791 + .newStream();
792 QPDFObjectHandle newdict = result.getDict(); 792 QPDFObjectHandle newdict = result.getDict();
793 newdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject")); 793 newdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));
794 newdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form")); 794 newdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"));
@@ -1062,8 +1062,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh) @@ -1062,8 +1062,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
1062 } 1062 }
1063 std::string cm_str = std::string("q\n") + cm.unparse() + " cm\n"; 1063 std::string cm_str = std::string("q\n") + cm.unparse() + " cm\n";
1064 this->oh.addPageContents(QPDFObjectHandle::newStream(&qpdf, cm_str), true); 1064 this->oh.addPageContents(QPDFObjectHandle::newStream(&qpdf, cm_str), true);
1065 - this->oh.addPageContents(  
1066 - QPDFObjectHandle::newStream(&qpdf, "\nQ\n"), false); 1065 + this->oh.addPageContents(qpdf.newStream("\nQ\n"), false);
1067 this->oh.removeKey("/Rotate"); 1066 this->oh.removeKey("/Rotate");
1068 QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false); 1067 QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
1069 if (!rotate_obj.isNull()) { 1068 if (!rotate_obj.isNull()) {
libqpdf/qpdf-c.cc
@@ -1696,7 +1696,7 @@ qpdf_oh @@ -1696,7 +1696,7 @@ qpdf_oh
1696 qpdf_oh_new_stream(qpdf_data qpdf) 1696 qpdf_oh_new_stream(qpdf_data qpdf)
1697 { 1697 {
1698 QTC::TC("qpdf", "qpdf-c called qpdf_oh_new_stream"); 1698 QTC::TC("qpdf", "qpdf-c called qpdf_oh_new_stream");
1699 - return new_object(qpdf, QPDFObjectHandle::newStream(qpdf->qpdf.get())); 1699 + return new_object(qpdf, qpdf->qpdf->newStream());
1700 } 1700 }
1701 1701
1702 void 1702 void