Commit b4fc9eb700672b35b023e0ff4d43e3c6ba39bf20
Committed by
Jay Berkenbilt
1 parent
720ce9e8
C-API expose new_object as qpdf_oh_new_object
Showing
4 changed files
with
16 additions
and
0 deletions
include/qpdf/qpdf-c.h
| ... | ... | @@ -554,6 +554,10 @@ extern "C" { |
| 554 | 554 | QPDF_DLL |
| 555 | 555 | void qpdf_oh_release_all(qpdf_data data); |
| 556 | 556 | |
| 557 | + /* Clone an object handle */ | |
| 558 | + QPDF_DLL | |
| 559 | + qpdf_oh qpdf_oh_new_object(qpdf_data qpdf, qpdf_oh oh); | |
| 560 | + | |
| 557 | 561 | /* Get trailer and root objects */ |
| 558 | 562 | QPDF_DLL |
| 559 | 563 | qpdf_oh qpdf_get_trailer(qpdf_data data); | ... | ... |
libqpdf/qpdf-c.cc
| ... | ... | @@ -841,6 +841,12 @@ new_object(qpdf_data qpdf, QPDFObjectHandle const& qoh) |
| 841 | 841 | return oh; |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | +qpdf_oh qpdf_oh_new_object(qpdf_data qpdf, qpdf_oh oh) | |
| 845 | +{ | |
| 846 | + QTC::TC("qpdf", "qpdf-c called qpdf_new_object"); | |
| 847 | + return new_object(qpdf, *(qpdf->oh_cache[oh])); | |
| 848 | +} | |
| 849 | + | |
| 844 | 850 | void qpdf_oh_release(qpdf_data qpdf, qpdf_oh oh) |
| 845 | 851 | { |
| 846 | 852 | QTC::TC("qpdf", "qpdf-c called qpdf_oh_release"); | ... | ... |
qpdf/qpdf-ctest.c
| ... | ... | @@ -531,14 +531,19 @@ static void test24(char const* infile, |
| 531 | 531 | assert(qpdf_oh_is_array(qpdf, mediabox)); |
| 532 | 532 | assert(qpdf_oh_get_array_n_items(qpdf, mediabox) == 4); |
| 533 | 533 | qpdf_oh wrapped_mediabox = qpdf_oh_wrap_in_array(qpdf, mediabox); |
| 534 | + qpdf_oh cloned_mediabox = qpdf_oh_new_object(qpdf, mediabox); | |
| 534 | 535 | assert(wrapped_mediabox != mediabox); |
| 536 | + assert(cloned_mediabox != mediabox); | |
| 535 | 537 | assert(qpdf_oh_get_array_n_items(qpdf, wrapped_mediabox) == 4); |
| 536 | 538 | for (int i = 0; i < 4; ++i) |
| 537 | 539 | { |
| 538 | 540 | qpdf_oh item = qpdf_oh_get_array_item(qpdf, mediabox, i); |
| 539 | 541 | qpdf_oh item2 = qpdf_oh_get_array_item(qpdf, wrapped_mediabox, i); |
| 542 | + qpdf_oh item3 = qpdf_oh_get_array_item(qpdf, cloned_mediabox, i); | |
| 540 | 543 | assert(qpdf_oh_get_int_value_as_int(qpdf, item) == |
| 541 | 544 | qpdf_oh_get_int_value_as_int(qpdf, item2)); |
| 545 | + assert(qpdf_oh_get_int_value_as_int(qpdf, item) == | |
| 546 | + qpdf_oh_get_int_value_as_int(qpdf, item3)); | |
| 542 | 547 | printf("item %d: %d %.2f\n", |
| 543 | 548 | i, qpdf_oh_get_int_value_as_int(qpdf, item), |
| 544 | 549 | qpdf_oh_get_numeric_value(qpdf, item)); | ... | ... |
qpdf/qpdf.testcov
| ... | ... | @@ -458,6 +458,7 @@ qpdf pages range omitted with . 0 |
| 458 | 458 | qpdf-c invalid object handle 0 |
| 459 | 459 | qpdf-c called qpdf_oh_release 0 |
| 460 | 460 | qpdf-c called qpdf_oh_release_all 0 |
| 461 | +qpdf-c called qpdf_new_object 0 | |
| 461 | 462 | qpdf-c called qpdf_get_trailer 0 |
| 462 | 463 | qpdf-c called qpdf_get_root 0 |
| 463 | 464 | qpdf-c called qpdf_oh_is_bool 0 | ... | ... |