Commit a7e269537d8f4b33d1bc8a5a83c53432db9b7560
1 parent
ce8b1ba6
update code to new PointerHolder, and reintroduce change that was accidentally backed out
git-svn-id: svn+q:///qpdf/trunk@1031 71b93d88-0707-0410-a8cf-f5a4172ac649
Showing
10 changed files
with
51 additions
and
45 deletions
examples/pdf-double-page-size.cc
| @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) | @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) | ||
| 66 | 66 | ||
| 67 | // Copy text into a buffer without the null terminator | 67 | // Copy text into a buffer without the null terminator |
| 68 | PointerHolder<Buffer> b = new Buffer(strlen(content)); | 68 | PointerHolder<Buffer> b = new Buffer(strlen(content)); |
| 69 | - unsigned char* bp = b.getPointer()->getBuffer(); | 69 | + unsigned char* bp = b->getBuffer(); |
| 70 | memcpy(bp, (unsigned char*)content, strlen(content)); | 70 | memcpy(bp, (unsigned char*)content, strlen(content)); |
| 71 | 71 | ||
| 72 | try | 72 | try |
examples/pdf-invert-images.cc
| @@ -48,8 +48,8 @@ ImageInverter::provideStreamData(int objid, int generation, | @@ -48,8 +48,8 @@ ImageInverter::provideStreamData(int objid, int generation, | ||
| 48 | // image data. Then invert the image data and write the inverted | 48 | // image data. Then invert the image data and write the inverted |
| 49 | // data to the pipeline. | 49 | // data to the pipeline. |
| 50 | PointerHolder<Buffer> data = this->image_data[objid][generation]; | 50 | PointerHolder<Buffer> data = this->image_data[objid][generation]; |
| 51 | - size_t size = data.getPointer()->getSize(); | ||
| 52 | - unsigned char* buf = data.getPointer()->getBuffer(); | 51 | + size_t size = data->getSize(); |
| 52 | + unsigned char* buf = data->getBuffer(); | ||
| 53 | unsigned char ch; | 53 | unsigned char ch; |
| 54 | for (size_t i = 0; i < size; ++i) | 54 | for (size_t i = 0; i < size; ++i) |
| 55 | { | 55 | { |
| @@ -142,8 +142,7 @@ int main(int argc, char* argv[]) | @@ -142,8 +142,7 @@ int main(int argc, char* argv[]) | ||
| 142 | p, | 142 | p, |
| 143 | QPDFObjectHandle::newNull(), | 143 | QPDFObjectHandle::newNull(), |
| 144 | QPDFObjectHandle::newNull(), | 144 | QPDFObjectHandle::newNull(), |
| 145 | - inv->image_data[objid][gen].getPointer()-> | ||
| 146 | - getSize()); | 145 | + inv->image_data[objid][gen]->getSize()); |
| 147 | } | 146 | } |
| 148 | } | 147 | } |
| 149 | } | 148 | } |
libqpdf/Pl_Buffer.cc
| @@ -51,9 +51,8 @@ Pl_Buffer::getBuffer() | @@ -51,9 +51,8 @@ Pl_Buffer::getBuffer() | ||
| 51 | unsigned char* p = b->getBuffer(); | 51 | unsigned char* p = b->getBuffer(); |
| 52 | while (! this->data.empty()) | 52 | while (! this->data.empty()) |
| 53 | { | 53 | { |
| 54 | - PointerHolder<Buffer> bph = this->data.front(); | 54 | + PointerHolder<Buffer> bp = this->data.front(); |
| 55 | this->data.pop_front(); | 55 | this->data.pop_front(); |
| 56 | - Buffer* bp = bph.getPointer(); | ||
| 57 | size_t bytes = bp->getSize(); | 56 | size_t bytes = bp->getSize(); |
| 58 | memcpy(p, bp->getBuffer(), bytes); | 57 | memcpy(p, bp->getBuffer(), bytes); |
| 59 | p += bytes; | 58 | p += bytes; |
libqpdf/QPDF.cc
| @@ -854,7 +854,7 @@ QPDF::processXRefStream(off_t xref_offset, QPDFObjectHandle& xref_obj) | @@ -854,7 +854,7 @@ QPDF::processXRefStream(off_t xref_offset, QPDFObjectHandle& xref_obj) | ||
| 854 | int expected_size = entry_size * num_entries; | 854 | int expected_size = entry_size * num_entries; |
| 855 | 855 | ||
| 856 | PointerHolder<Buffer> bp = xref_obj.getStreamData(); | 856 | PointerHolder<Buffer> bp = xref_obj.getStreamData(); |
| 857 | - int actual_size = bp.getPointer()->getSize(); | 857 | + int actual_size = bp->getSize(); |
| 858 | 858 | ||
| 859 | if (expected_size != actual_size) | 859 | if (expected_size != actual_size) |
| 860 | { | 860 | { |
| @@ -878,7 +878,7 @@ QPDF::processXRefStream(off_t xref_offset, QPDFObjectHandle& xref_obj) | @@ -878,7 +878,7 @@ QPDF::processXRefStream(off_t xref_offset, QPDFObjectHandle& xref_obj) | ||
| 878 | 878 | ||
| 879 | bool saw_first_compressed_object = false; | 879 | bool saw_first_compressed_object = false; |
| 880 | 880 | ||
| 881 | - unsigned char const* data = bp.getPointer()->getBuffer(); | 881 | + unsigned char const* data = bp->getBuffer(); |
| 882 | for (int i = 0; i < num_entries; ++i) | 882 | for (int i = 0; i < num_entries; ++i) |
| 883 | { | 883 | { |
| 884 | // Read this entry | 884 | // Read this entry |
| @@ -1200,6 +1200,20 @@ QPDF::readObjectInternal(PointerHolder<InputSource> input, | @@ -1200,6 +1200,20 @@ QPDF::readObjectInternal(PointerHolder<InputSource> input, | ||
| 1200 | olist.pop_back(); | 1200 | olist.pop_back(); |
| 1201 | olist.pop_back(); | 1201 | olist.pop_back(); |
| 1202 | } | 1202 | } |
| 1203 | + else if ((value == "endobj") && | ||
| 1204 | + (! (in_array || in_dictionary))) | ||
| 1205 | + { | ||
| 1206 | + // Nothing in the PDF spec appears to allow empty | ||
| 1207 | + // objects, but they have been encountered in | ||
| 1208 | + // actual PDF files and Adobe Reader appears to | ||
| 1209 | + // ignore them. | ||
| 1210 | + warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(), | ||
| 1211 | + this->last_object_description, | ||
| 1212 | + input->getLastOffset(), | ||
| 1213 | + "empty object treated as null")); | ||
| 1214 | + object = QPDFObjectHandle::newNull(); | ||
| 1215 | + input->seek(input->getLastOffset(), SEEK_SET); | ||
| 1216 | + } | ||
| 1203 | else | 1217 | else |
| 1204 | { | 1218 | { |
| 1205 | throw QPDFExc(qpdf_e_damaged_pdf, input->getName(), | 1219 | throw QPDFExc(qpdf_e_damaged_pdf, input->getName(), |
libqpdf/QPDFObjectHandle.cc
| @@ -528,7 +528,7 @@ std::string | @@ -528,7 +528,7 @@ std::string | ||
| 528 | QPDFObjectHandle::unparseResolved() | 528 | QPDFObjectHandle::unparseResolved() |
| 529 | { | 529 | { |
| 530 | dereference(); | 530 | dereference(); |
| 531 | - return this->obj.getPointer()->unparse(); | 531 | + return this->obj->unparse(); |
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | QPDFObjectHandle | 534 | QPDFObjectHandle |
libqpdf/QPDFWriter.cc
| @@ -527,8 +527,7 @@ QPDFWriter::writeString(std::string const& str) | @@ -527,8 +527,7 @@ QPDFWriter::writeString(std::string const& str) | ||
| 527 | void | 527 | void |
| 528 | QPDFWriter::writeBuffer(PointerHolder<Buffer>& b) | 528 | QPDFWriter::writeBuffer(PointerHolder<Buffer>& b) |
| 529 | { | 529 | { |
| 530 | - this->pipeline->write(b.getPointer()->getBuffer(), | ||
| 531 | - b.getPointer()->getSize()); | 530 | + this->pipeline->write(b->getBuffer(), b->getSize()); |
| 532 | } | 531 | } |
| 533 | 532 | ||
| 534 | void | 533 | void |
| @@ -1038,7 +1037,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, | @@ -1038,7 +1037,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, | ||
| 1038 | compress = false; | 1037 | compress = false; |
| 1039 | } | 1038 | } |
| 1040 | 1039 | ||
| 1041 | - this->cur_stream_length = stream_data.getPointer()->getSize(); | 1040 | + this->cur_stream_length = stream_data->getSize(); |
| 1042 | if (is_metadata && this->encrypted && (! this->encrypt_metadata)) | 1041 | if (is_metadata && this->encrypted && (! this->encrypt_metadata)) |
| 1043 | { | 1042 | { |
| 1044 | // Don't encrypt stream data for the metadata stream | 1043 | // Don't encrypt stream data for the metadata stream |
| @@ -1226,7 +1225,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) | @@ -1226,7 +1225,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) | ||
| 1226 | writeStringQDF("\n "); | 1225 | writeStringQDF("\n "); |
| 1227 | writeString(" /Type /ObjStm"); | 1226 | writeString(" /Type /ObjStm"); |
| 1228 | writeStringQDF("\n "); | 1227 | writeStringQDF("\n "); |
| 1229 | - unsigned long length = stream_buffer.getPointer()->getSize(); | 1228 | + unsigned long length = stream_buffer->getSize(); |
| 1230 | adjustAESStreamLength(length); | 1229 | adjustAESStreamLength(length); |
| 1231 | writeString(" /Length " + QUtil::int_to_string(length)); | 1230 | writeString(" /Length " + QUtil::int_to_string(length)); |
| 1232 | writeStringQDF("\n "); | 1231 | writeStringQDF("\n "); |
| @@ -1718,8 +1717,8 @@ QPDFWriter::writeHintStream(int hint_id) | @@ -1718,8 +1717,8 @@ QPDFWriter::writeHintStream(int hint_id) | ||
| 1718 | openObject(hint_id); | 1717 | openObject(hint_id); |
| 1719 | setDataKey(hint_id); | 1718 | setDataKey(hint_id); |
| 1720 | 1719 | ||
| 1721 | - unsigned char* hs = hint_buffer.getPointer()->getBuffer(); | ||
| 1722 | - unsigned long hlen = hint_buffer.getPointer()->getSize(); | 1720 | + unsigned char* hs = hint_buffer->getBuffer(); |
| 1721 | + unsigned long hlen = hint_buffer->getSize(); | ||
| 1723 | 1722 | ||
| 1724 | writeString("<< /Filter /FlateDecode /S "); | 1723 | writeString("<< /Filter /FlateDecode /S "); |
| 1725 | writeString(QUtil::int_to_string(S)); | 1724 | writeString(QUtil::int_to_string(S)); |
| @@ -1888,8 +1887,7 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, int max_offset, | @@ -1888,8 +1887,7 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, int max_offset, | ||
| 1888 | writeStringQDF("\n "); | 1887 | writeStringQDF("\n "); |
| 1889 | writeString(" /Type /XRef"); | 1888 | writeString(" /Type /XRef"); |
| 1890 | writeStringQDF("\n "); | 1889 | writeStringQDF("\n "); |
| 1891 | - writeString(" /Length " + | ||
| 1892 | - QUtil::int_to_string(xref_data.getPointer()->getSize())); | 1890 | + writeString(" /Length " + QUtil::int_to_string(xref_data->getSize())); |
| 1893 | if (compressed) | 1891 | if (compressed) |
| 1894 | { | 1892 | { |
| 1895 | writeStringQDF("\n "); | 1893 | writeStringQDF("\n "); |
| @@ -2251,7 +2249,7 @@ QPDFWriter::writeLinearized() | @@ -2251,7 +2249,7 @@ QPDFWriter::writeLinearized() | ||
| 2251 | activatePipelineStack(); | 2249 | activatePipelineStack(); |
| 2252 | writeHintStream(hint_id); | 2250 | writeHintStream(hint_id); |
| 2253 | popPipelineStack(&hint_buffer); | 2251 | popPipelineStack(&hint_buffer); |
| 2254 | - hint_length = hint_buffer.getPointer()->getSize(); | 2252 | + hint_length = hint_buffer->getSize(); |
| 2255 | 2253 | ||
| 2256 | // Restore hint offset | 2254 | // Restore hint offset |
| 2257 | this->xref[hint_id] = QPDFXRefEntry(1, hint_offset, 0); | 2255 | this->xref[hint_id] = QPDFXRefEntry(1, hint_offset, 0); |
libqpdf/QPDF_Stream.cc
| @@ -370,16 +370,15 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool filter, | @@ -370,16 +370,15 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool filter, | ||
| 370 | if (this->stream_data.getPointer()) | 370 | if (this->stream_data.getPointer()) |
| 371 | { | 371 | { |
| 372 | QTC::TC("qpdf", "QPDF_Stream pipe replaced stream data"); | 372 | QTC::TC("qpdf", "QPDF_Stream pipe replaced stream data"); |
| 373 | - Buffer& b = *(this->stream_data.getPointer()); | ||
| 374 | - pipeline->write(b.getBuffer(), b.getSize()); | 373 | + pipeline->write(this->stream_data->getBuffer(), |
| 374 | + this->stream_data->getSize()); | ||
| 375 | pipeline->finish(); | 375 | pipeline->finish(); |
| 376 | } | 376 | } |
| 377 | else if (this->stream_provider.getPointer()) | 377 | else if (this->stream_provider.getPointer()) |
| 378 | { | 378 | { |
| 379 | - QPDFObjectHandle::StreamDataProvider& p = | ||
| 380 | - (*this->stream_provider.getPointer()); | ||
| 381 | Pl_Count count("stream provider count", pipeline); | 379 | Pl_Count count("stream provider count", pipeline); |
| 382 | - p.provideStreamData(this->objid, this->generation, &count); | 380 | + this->stream_provider->provideStreamData( |
| 381 | + this->objid, this->generation, &count); | ||
| 383 | size_t actual_length = count.getCount(); | 382 | size_t actual_length = count.getCount(); |
| 384 | size_t desired_length = | 383 | size_t desired_length = |
| 385 | this->stream_dict.getKey("/Length").getIntValue(); | 384 | this->stream_dict.getKey("/Length").getIntValue(); |
| @@ -424,7 +423,7 @@ QPDF_Stream::replaceStreamData(PointerHolder<Buffer> data, | @@ -424,7 +423,7 @@ QPDF_Stream::replaceStreamData(PointerHolder<Buffer> data, | ||
| 424 | { | 423 | { |
| 425 | this->stream_data = data; | 424 | this->stream_data = data; |
| 426 | this->stream_provider = 0; | 425 | this->stream_provider = 0; |
| 427 | - replaceFilterData(filter, decode_parms, data.getPointer()->getSize()); | 426 | + replaceFilterData(filter, decode_parms, data->getSize()); |
| 428 | } | 427 | } |
| 429 | 428 | ||
| 430 | void | 429 | void |
libqpdf/QPDF_encryption.cc
| @@ -571,8 +571,7 @@ QPDF::decryptString(std::string& str, int objid, int generation) | @@ -571,8 +571,7 @@ QPDF::decryptString(std::string& str, int objid, int generation) | ||
| 571 | pl.write((unsigned char*)str.c_str(), str.length()); | 571 | pl.write((unsigned char*)str.c_str(), str.length()); |
| 572 | pl.finish(); | 572 | pl.finish(); |
| 573 | PointerHolder<Buffer> buf = bufpl.getBuffer(); | 573 | PointerHolder<Buffer> buf = bufpl.getBuffer(); |
| 574 | - str = std::string((char*)buf.getPointer()->getBuffer(), | ||
| 575 | - (size_t)buf.getPointer()->getSize()); | 574 | + str = std::string((char*)buf->getBuffer(), (size_t)buf->getSize()); |
| 576 | } | 575 | } |
| 577 | else | 576 | else |
| 578 | { | 577 | { |
libqpdf/qpdf-c.cc
| @@ -176,7 +176,7 @@ char const* qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e) | @@ -176,7 +176,7 @@ char const* qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e) | ||
| 176 | { | 176 | { |
| 177 | return ""; | 177 | return ""; |
| 178 | } | 178 | } |
| 179 | - return e->exc.getPointer()->what(); | 179 | + return e->exc->what(); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | enum qpdf_error_code_e qpdf_get_error_code(qpdf_data qpdf, qpdf_error e) | 182 | enum qpdf_error_code_e qpdf_get_error_code(qpdf_data qpdf, qpdf_error e) |
| @@ -185,7 +185,7 @@ enum qpdf_error_code_e qpdf_get_error_code(qpdf_data qpdf, qpdf_error e) | @@ -185,7 +185,7 @@ enum qpdf_error_code_e qpdf_get_error_code(qpdf_data qpdf, qpdf_error e) | ||
| 185 | { | 185 | { |
| 186 | return qpdf_e_success; | 186 | return qpdf_e_success; |
| 187 | } | 187 | } |
| 188 | - return e->exc.getPointer()->getErrorCode(); | 188 | + return e->exc->getErrorCode(); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | char const* qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e) | 191 | char const* qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e) |
| @@ -194,7 +194,7 @@ char const* qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e) | @@ -194,7 +194,7 @@ char const* qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e) | ||
| 194 | { | 194 | { |
| 195 | return ""; | 195 | return ""; |
| 196 | } | 196 | } |
| 197 | - return e->exc.getPointer()->getFilename().c_str(); | 197 | + return e->exc->getFilename().c_str(); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | unsigned long qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e) | 200 | unsigned long qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e) |
| @@ -203,7 +203,7 @@ unsigned long qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e) | @@ -203,7 +203,7 @@ unsigned long qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e) | ||
| 203 | { | 203 | { |
| 204 | return 0; | 204 | return 0; |
| 205 | } | 205 | } |
| 206 | - return e->exc.getPointer()->getFilePosition(); | 206 | + return e->exc->getFilePosition(); |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | char const* qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e) | 209 | char const* qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e) |
| @@ -212,7 +212,7 @@ char const* qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e) | @@ -212,7 +212,7 @@ char const* qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e) | ||
| 212 | { | 212 | { |
| 213 | return ""; | 213 | return ""; |
| 214 | } | 214 | } |
| 215 | - return e->exc.getPointer()->getMessageDetail().c_str(); | 215 | + return e->exc->getMessageDetail().c_str(); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | void qpdf_set_suppress_warnings(qpdf_data qpdf, QPDF_BOOL value) | 218 | void qpdf_set_suppress_warnings(qpdf_data qpdf, QPDF_BOOL value) |
qpdf/test_driver.cc
| @@ -37,8 +37,7 @@ class Provider: public QPDFObjectHandle::StreamDataProvider | @@ -37,8 +37,7 @@ class Provider: public QPDFObjectHandle::StreamDataProvider | ||
| 37 | virtual void provideStreamData(int objid, int generation, | 37 | virtual void provideStreamData(int objid, int generation, |
| 38 | Pipeline* p) | 38 | Pipeline* p) |
| 39 | { | 39 | { |
| 40 | - p->write(b.getPointer()->getBuffer(), | ||
| 41 | - b.getPointer()->getSize()); | 40 | + p->write(b->getBuffer(), b->getSize()); |
| 42 | if (this->bad_length) | 41 | if (this->bad_length) |
| 43 | { | 42 | { |
| 44 | unsigned char ch = ' '; | 43 | unsigned char ch = ' '; |
| @@ -352,7 +351,7 @@ void runtest(int n, char const* filename) | @@ -352,7 +351,7 @@ void runtest(int n, char const* filename) | ||
| 352 | throw std::logic_error("test 7 run on file with no QStream"); | 351 | throw std::logic_error("test 7 run on file with no QStream"); |
| 353 | } | 352 | } |
| 354 | PointerHolder<Buffer> b = new Buffer(20); | 353 | PointerHolder<Buffer> b = new Buffer(20); |
| 355 | - unsigned char* bp = b.getPointer()->getBuffer(); | 354 | + unsigned char* bp = b->getBuffer(); |
| 356 | memcpy(bp, (char*)"new data for stream\n", 20); // no null! | 355 | memcpy(bp, (char*)"new data for stream\n", 20); // no null! |
| 357 | qstream.replaceStreamData( | 356 | qstream.replaceStreamData( |
| 358 | b, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | 357 | b, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); |
| @@ -380,8 +379,7 @@ void runtest(int n, char const* filename) | @@ -380,8 +379,7 @@ void runtest(int n, char const* filename) | ||
| 380 | PointerHolder<QPDFObjectHandle::StreamDataProvider> p = provider; | 379 | PointerHolder<QPDFObjectHandle::StreamDataProvider> p = provider; |
| 381 | qstream.replaceStreamData( | 380 | qstream.replaceStreamData( |
| 382 | p, QPDFObjectHandle::newName("/FlateDecode"), | 381 | p, QPDFObjectHandle::newName("/FlateDecode"), |
| 383 | - QPDFObjectHandle::newNull(), | ||
| 384 | - b.getPointer()->getSize()); | 382 | + QPDFObjectHandle::newNull(), b->getSize()); |
| 385 | provider->badLength(true); | 383 | provider->badLength(true); |
| 386 | try | 384 | try |
| 387 | { | 385 | { |
| @@ -402,7 +400,7 @@ void runtest(int n, char const* filename) | @@ -402,7 +400,7 @@ void runtest(int n, char const* filename) | ||
| 402 | { | 400 | { |
| 403 | QPDFObjectHandle root = pdf.getRoot(); | 401 | QPDFObjectHandle root = pdf.getRoot(); |
| 404 | PointerHolder<Buffer> b1 = new Buffer(20); | 402 | PointerHolder<Buffer> b1 = new Buffer(20); |
| 405 | - unsigned char* bp = b1.getPointer()->getBuffer(); | 403 | + unsigned char* bp = b1->getBuffer(); |
| 406 | memcpy(bp, (char*)"data for new stream\n", 20); // no null! | 404 | memcpy(bp, (char*)"data for new stream\n", 20); // no null! |
| 407 | QPDFObjectHandle qstream = QPDFObjectHandle::newStream(&pdf, b1); | 405 | QPDFObjectHandle qstream = QPDFObjectHandle::newStream(&pdf, b1); |
| 408 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); | 406 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); |
| @@ -416,7 +414,7 @@ void runtest(int n, char const* filename) | @@ -416,7 +414,7 @@ void runtest(int n, char const* filename) | ||
| 416 | std::cout << "exception: " << e.what() << std::endl; | 414 | std::cout << "exception: " << e.what() << std::endl; |
| 417 | } | 415 | } |
| 418 | PointerHolder<Buffer> b2 = new Buffer(22); | 416 | PointerHolder<Buffer> b2 = new Buffer(22); |
| 419 | - bp = b2.getPointer()->getBuffer(); | 417 | + bp = b2->getBuffer(); |
| 420 | memcpy(bp, (char*)"data for other stream\n", 22); // no null! | 418 | memcpy(bp, (char*)"data for other stream\n", 22); // no null! |
| 421 | rstream.replaceStreamData( | 419 | rstream.replaceStreamData( |
| 422 | b2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | 420 | b2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); |
| @@ -430,10 +428,10 @@ void runtest(int n, char const* filename) | @@ -430,10 +428,10 @@ void runtest(int n, char const* filename) | ||
| 430 | else if (n == 10) | 428 | else if (n == 10) |
| 431 | { | 429 | { |
| 432 | PointerHolder<Buffer> b1 = new Buffer(37); | 430 | PointerHolder<Buffer> b1 = new Buffer(37); |
| 433 | - unsigned char* bp = b1.getPointer()->getBuffer(); | 431 | + unsigned char* bp = b1->getBuffer(); |
| 434 | memcpy(bp, (char*)"BT /F1 12 Tf 72 620 Td (Baked) Tj ET\n", 37); | 432 | memcpy(bp, (char*)"BT /F1 12 Tf 72 620 Td (Baked) Tj ET\n", 37); |
| 435 | PointerHolder<Buffer> b2 = new Buffer(38); | 433 | PointerHolder<Buffer> b2 = new Buffer(38); |
| 436 | - bp = b2.getPointer()->getBuffer(); | 434 | + bp = b2->getBuffer(); |
| 437 | memcpy(bp, (char*)"BT /F1 18 Tf 72 520 Td (Mashed) Tj ET\n", 38); | 435 | memcpy(bp, (char*)"BT /F1 18 Tf 72 520 Td (Mashed) Tj ET\n", 38); |
| 438 | 436 | ||
| 439 | std::vector<QPDFObjectHandle> pages = pdf.getAllPages(); | 437 | std::vector<QPDFObjectHandle> pages = pdf.getAllPages(); |
| @@ -451,13 +449,13 @@ void runtest(int n, char const* filename) | @@ -451,13 +449,13 @@ void runtest(int n, char const* filename) | ||
| 451 | QPDFObjectHandle qstream = root.getKey("/QStream"); | 449 | QPDFObjectHandle qstream = root.getKey("/QStream"); |
| 452 | PointerHolder<Buffer> b1 = qstream.getStreamData(); | 450 | PointerHolder<Buffer> b1 = qstream.getStreamData(); |
| 453 | PointerHolder<Buffer> b2 = qstream.getRawStreamData(); | 451 | PointerHolder<Buffer> b2 = qstream.getRawStreamData(); |
| 454 | - if ((b1.getPointer()->getSize() == 7) && | ||
| 455 | - (memcmp(b1.getPointer()->getBuffer(), "potato\n", 7) == 0)) | 452 | + if ((b1->getSize() == 7) && |
| 453 | + (memcmp(b1->getBuffer(), "potato\n", 7) == 0)) | ||
| 456 | { | 454 | { |
| 457 | std::cout << "filtered stream data okay" << std::endl; | 455 | std::cout << "filtered stream data okay" << std::endl; |
| 458 | } | 456 | } |
| 459 | - if ((b2.getPointer()->getSize() == 15) && | ||
| 460 | - (memcmp(b2.getPointer()->getBuffer(), "706F7461746F0A\n", 15) == 0)) | 457 | + if ((b2->getSize() == 15) && |
| 458 | + (memcmp(b2->getBuffer(), "706F7461746F0A\n", 15) == 0)) | ||
| 461 | { | 459 | { |
| 462 | std::cout << "raw stream data okay" << std::endl; | 460 | std::cout << "raw stream data okay" << std::endl; |
| 463 | } | 461 | } |