mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-10 23:20:58 +00:00
Remove deprecated name/number tree constructors
Remove the name/number tree object helper constructors that don't take a QPDF&.
This commit is contained in:
parent
496ca2e4dc
commit
80ed3076a0
4
TODO
4
TODO
@ -481,10 +481,6 @@ Comments appear in the code prefixed by "ABI"
|
|||||||
* Search for ABI to find items not listed here.
|
* Search for ABI to find items not listed here.
|
||||||
* See where anonymous namespaces can be used to keep things private to
|
* See where anonymous namespaces can be used to keep things private to
|
||||||
a source file. Search for `(class|struct)` in **/*.cc.
|
a source file. Search for `(class|struct)` in **/*.cc.
|
||||||
* After removing legacy QPDFNameTreeObjectHelper and
|
|
||||||
QPDFNumberTreeObjectHelper constructors, NNTreeImpl can switch to
|
|
||||||
having a QPDF reference and assume that the reference is always
|
|
||||||
valid.
|
|
||||||
* Having QPDFObjectHandle setters return Class& to allow for
|
* Having QPDFObjectHandle setters return Class& to allow for
|
||||||
use of fluent interfaces. This includes array and dictionary
|
use of fluent interfaces. This includes array and dictionary
|
||||||
mutators.
|
mutators.
|
||||||
|
@ -50,13 +50,6 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
|
|||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
QPDFNameTreeObjectHelper(QPDFObjectHandle, QPDF&, bool auto_repair = true);
|
QPDFNameTreeObjectHelper(QPDFObjectHandle, QPDF&, bool auto_repair = true);
|
||||||
|
|
||||||
// ABI: Legacy Constructor will be removed in QPDF 11. A
|
|
||||||
// QPDFNameTreeObjectHelper constructed in this way can't be
|
|
||||||
// modified or repaired and will silently ignore problems in the
|
|
||||||
// structure.
|
|
||||||
[[deprecated("use constructor that takes QPDF&")]] QPDF_DLL
|
|
||||||
QPDFNameTreeObjectHelper(QPDFObjectHandle);
|
|
||||||
|
|
||||||
// Create an empty name tree
|
// Create an empty name tree
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
static QPDFNameTreeObjectHelper newEmpty(QPDF&, bool auto_repair = true);
|
static QPDFNameTreeObjectHelper newEmpty(QPDF&, bool auto_repair = true);
|
||||||
@ -197,7 +190,7 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
|
|||||||
~Members() = default;
|
~Members() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Members(QPDFObjectHandle& oh, QPDF*, bool auto_repair);
|
Members(QPDFObjectHandle& oh, QPDF&, bool auto_repair);
|
||||||
Members(Members const&) = delete;
|
Members(Members const&) = delete;
|
||||||
|
|
||||||
std::shared_ptr<NNTreeImpl> impl;
|
std::shared_ptr<NNTreeImpl> impl;
|
||||||
|
@ -48,13 +48,6 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
|
|||||||
QPDFNumberTreeObjectHelper(
|
QPDFNumberTreeObjectHelper(
|
||||||
QPDFObjectHandle, QPDF&, bool auto_repair = true);
|
QPDFObjectHandle, QPDF&, bool auto_repair = true);
|
||||||
|
|
||||||
// ABI: Legacy Constructor will be removed in QPDF 11. A
|
|
||||||
// QPDFNumberTreeObjectHelper constructed in this way can't be
|
|
||||||
// modified or repaired and will silently ignore problems in the
|
|
||||||
// structure.
|
|
||||||
[[deprecated("use constructor that takes QPDF&")]] QPDF_DLL
|
|
||||||
QPDFNumberTreeObjectHelper(QPDFObjectHandle);
|
|
||||||
|
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
virtual ~QPDFNumberTreeObjectHelper() = default;
|
virtual ~QPDFNumberTreeObjectHelper() = default;
|
||||||
|
|
||||||
@ -217,7 +210,7 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
|
|||||||
~Members() = default;
|
~Members() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Members(QPDFObjectHandle& oh, QPDF*, bool auto_repair);
|
Members(QPDFObjectHandle& oh, QPDF&, bool auto_repair);
|
||||||
Members(Members const&) = delete;
|
Members(Members const&) = delete;
|
||||||
|
|
||||||
std::shared_ptr<NNTreeImpl> impl;
|
std::shared_ptr<NNTreeImpl> impl;
|
||||||
|
@ -16,37 +16,23 @@ get_description(QPDFObjectHandle& node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
warn(QPDF* qpdf, QPDFObjectHandle& node, std::string const& msg)
|
warn(QPDF& qpdf, QPDFObjectHandle& node, std::string const& msg)
|
||||||
{
|
{
|
||||||
// ABI: in qpdf 11, change to a reference.
|
qpdf.warn(
|
||||||
|
|
||||||
if (qpdf) {
|
|
||||||
qpdf->warn(
|
|
||||||
// line-break
|
// line-break
|
||||||
QPDFExc(
|
QPDFExc(
|
||||||
qpdf_e_damaged_pdf,
|
qpdf_e_damaged_pdf,
|
||||||
qpdf->getFilename(),
|
qpdf.getFilename(),
|
||||||
get_description(node),
|
get_description(node),
|
||||||
0,
|
0,
|
||||||
msg));
|
msg));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
error(QPDF* qpdf, QPDFObjectHandle& node, std::string const& msg)
|
error(QPDF& qpdf, QPDFObjectHandle& node, std::string const& msg)
|
||||||
{
|
{
|
||||||
// ABI: in qpdf 11, change to a reference.
|
|
||||||
|
|
||||||
if (qpdf) {
|
|
||||||
throw QPDFExc(
|
throw QPDFExc(
|
||||||
qpdf_e_damaged_pdf,
|
qpdf_e_damaged_pdf, qpdf.getFilename(), get_description(node), 0, msg);
|
||||||
qpdf->getFilename(),
|
|
||||||
get_description(node),
|
|
||||||
0,
|
|
||||||
msg);
|
|
||||||
} else {
|
|
||||||
throw std::runtime_error(get_description(node) + ": " + msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NNTreeIterator::NNTreeIterator(NNTreeImpl& impl) :
|
NNTreeIterator::NNTreeIterator(NNTreeImpl& impl) :
|
||||||
@ -293,9 +279,6 @@ NNTreeIterator::split(
|
|||||||
// node: A
|
// node: A
|
||||||
// item_number: 0
|
// item_number: 0
|
||||||
|
|
||||||
if (!this->impl.qpdf) {
|
|
||||||
throw std::logic_error("NNTreeIterator::split called with null qpdf");
|
|
||||||
}
|
|
||||||
if (!valid()) {
|
if (!valid()) {
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"NNTreeIterator::split called an invalid iterator");
|
"NNTreeIterator::split called an invalid iterator");
|
||||||
@ -361,7 +344,7 @@ NNTreeIterator::split(
|
|||||||
// same way.
|
// same way.
|
||||||
|
|
||||||
auto first_node =
|
auto first_node =
|
||||||
impl.qpdf->makeIndirectObject(QPDFObjectHandle::newDictionary());
|
impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
|
||||||
first_node.replaceKey(key, first_half);
|
first_node.replaceKey(key, first_half);
|
||||||
QPDFObjectHandle new_kids = QPDFObjectHandle::newArray();
|
QPDFObjectHandle new_kids = QPDFObjectHandle::newArray();
|
||||||
new_kids.appendItem(first_node);
|
new_kids.appendItem(first_node);
|
||||||
@ -397,7 +380,7 @@ NNTreeIterator::split(
|
|||||||
|
|
||||||
// Create a new node to contain the second half
|
// Create a new node to contain the second half
|
||||||
QPDFObjectHandle second_node =
|
QPDFObjectHandle second_node =
|
||||||
impl.qpdf->makeIndirectObject(QPDFObjectHandle::newDictionary());
|
impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
|
||||||
second_node.replaceKey(key, second_half);
|
second_node.replaceKey(key, second_half);
|
||||||
resetLimits(second_node, parent);
|
resetLimits(second_node, parent);
|
||||||
|
|
||||||
@ -705,7 +688,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
|
|||||||
addPathElement(node, kid_number);
|
addPathElement(node, kid_number);
|
||||||
auto next = kids.getArrayItem(kid_number);
|
auto next = kids.getArrayItem(kid_number);
|
||||||
if (!next.isIndirect()) {
|
if (!next.isIndirect()) {
|
||||||
if (impl.qpdf && impl.auto_repair) {
|
if (impl.auto_repair) {
|
||||||
QTC::TC("qpdf", "NNTree fix indirect kid");
|
QTC::TC("qpdf", "NNTree fix indirect kid");
|
||||||
warn(
|
warn(
|
||||||
impl.qpdf,
|
impl.qpdf,
|
||||||
@ -713,7 +696,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
|
|||||||
("converting kid number " +
|
("converting kid number " +
|
||||||
QUtil::int_to_string(kid_number) +
|
QUtil::int_to_string(kid_number) +
|
||||||
" to an indirect object"));
|
" to an indirect object"));
|
||||||
next = impl.qpdf->makeIndirectObject(next);
|
next = impl.qpdf.makeIndirectObject(next);
|
||||||
kids.setArrayItem(kid_number, next);
|
kids.setArrayItem(kid_number, next);
|
||||||
} else {
|
} else {
|
||||||
QTC::TC("qpdf", "NNTree warn indirect kid");
|
QTC::TC("qpdf", "NNTree warn indirect kid");
|
||||||
@ -749,7 +732,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
|
|||||||
|
|
||||||
NNTreeImpl::NNTreeImpl(
|
NNTreeImpl::NNTreeImpl(
|
||||||
NNTreeDetails const& details,
|
NNTreeDetails const& details,
|
||||||
QPDF* qpdf,
|
QPDF& qpdf,
|
||||||
QPDFObjectHandle& oh,
|
QPDFObjectHandle& oh,
|
||||||
bool auto_repair) :
|
bool auto_repair) :
|
||||||
details(details),
|
details(details),
|
||||||
|
@ -32,7 +32,7 @@ class NameTreeDetails: public NNTreeDetails
|
|||||||
static NameTreeDetails name_tree_details;
|
static NameTreeDetails name_tree_details;
|
||||||
|
|
||||||
QPDFNameTreeObjectHelper::Members::Members(
|
QPDFNameTreeObjectHelper::Members::Members(
|
||||||
QPDFObjectHandle& oh, QPDF* q, bool auto_repair) :
|
QPDFObjectHandle& oh, QPDF& q, bool auto_repair) :
|
||||||
impl(std::make_shared<NNTreeImpl>(name_tree_details, q, oh, auto_repair))
|
impl(std::make_shared<NNTreeImpl>(name_tree_details, q, oh, auto_repair))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -40,13 +40,7 @@ QPDFNameTreeObjectHelper::Members::Members(
|
|||||||
QPDFNameTreeObjectHelper::QPDFNameTreeObjectHelper(
|
QPDFNameTreeObjectHelper::QPDFNameTreeObjectHelper(
|
||||||
QPDFObjectHandle oh, QPDF& q, bool auto_repair) :
|
QPDFObjectHandle oh, QPDF& q, bool auto_repair) :
|
||||||
QPDFObjectHelper(oh),
|
QPDFObjectHelper(oh),
|
||||||
m(new Members(oh, &q, auto_repair))
|
m(new Members(oh, q, auto_repair))
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QPDFNameTreeObjectHelper::QPDFNameTreeObjectHelper(QPDFObjectHandle oh) :
|
|
||||||
QPDFObjectHelper(oh),
|
|
||||||
m(new Members(oh, nullptr, false))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class NumberTreeDetails: public NNTreeDetails
|
|||||||
static NumberTreeDetails number_tree_details;
|
static NumberTreeDetails number_tree_details;
|
||||||
|
|
||||||
QPDFNumberTreeObjectHelper::Members::Members(
|
QPDFNumberTreeObjectHelper::Members::Members(
|
||||||
QPDFObjectHandle& oh, QPDF* q, bool auto_repair) :
|
QPDFObjectHandle& oh, QPDF& q, bool auto_repair) :
|
||||||
impl(std::make_shared<NNTreeImpl>(number_tree_details, q, oh, auto_repair))
|
impl(std::make_shared<NNTreeImpl>(number_tree_details, q, oh, auto_repair))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -41,13 +41,7 @@ QPDFNumberTreeObjectHelper::Members::Members(
|
|||||||
QPDFNumberTreeObjectHelper::QPDFNumberTreeObjectHelper(
|
QPDFNumberTreeObjectHelper::QPDFNumberTreeObjectHelper(
|
||||||
QPDFObjectHandle oh, QPDF& q, bool auto_repair) :
|
QPDFObjectHandle oh, QPDF& q, bool auto_repair) :
|
||||||
QPDFObjectHelper(oh),
|
QPDFObjectHelper(oh),
|
||||||
m(new Members(oh, &q, auto_repair))
|
m(new Members(oh, q, auto_repair))
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QPDFNumberTreeObjectHelper::QPDFNumberTreeObjectHelper(QPDFObjectHandle oh) :
|
|
||||||
QPDFObjectHelper(oh),
|
|
||||||
m(new Members(oh, nullptr, false))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,9 @@ class NNTreeImpl
|
|||||||
public:
|
public:
|
||||||
typedef NNTreeIterator iterator;
|
typedef NNTreeIterator iterator;
|
||||||
|
|
||||||
// ABI: for qpdf 11, make qpdf a reference
|
|
||||||
NNTreeImpl(
|
NNTreeImpl(
|
||||||
NNTreeDetails const&,
|
NNTreeDetails const&,
|
||||||
QPDF*,
|
QPDF&,
|
||||||
QPDFObjectHandle&,
|
QPDFObjectHandle&,
|
||||||
bool auto_repair = true);
|
bool auto_repair = true);
|
||||||
iterator begin();
|
iterator begin();
|
||||||
@ -132,7 +131,7 @@ class NNTreeImpl
|
|||||||
int compareKeyKid(QPDFObjectHandle& key, QPDFObjectHandle& items, int idx);
|
int compareKeyKid(QPDFObjectHandle& key, QPDFObjectHandle& items, int idx);
|
||||||
|
|
||||||
NNTreeDetails const& details;
|
NNTreeDetails const& details;
|
||||||
QPDF* qpdf;
|
QPDF& qpdf;
|
||||||
int split_threshold;
|
int split_threshold;
|
||||||
QPDFObjectHandle oh;
|
QPDFObjectHandle oh;
|
||||||
bool auto_repair;
|
bool auto_repair;
|
||||||
|
@ -69,6 +69,10 @@ For a detailed list of changes, please see the file
|
|||||||
method never worked and only did something in qpdf version
|
method never worked and only did something in qpdf version
|
||||||
10.2.x.
|
10.2.x.
|
||||||
|
|
||||||
|
- Remove ``QPDFNameTreeObjectHelper`` and
|
||||||
|
``QPDFNumberTreeObjectHelper`` constructors that don't take a
|
||||||
|
``QPDF&`` argument.
|
||||||
|
|
||||||
- Other changes
|
- Other changes
|
||||||
|
|
||||||
- A new chapter on contributing to qpdf has been added to the
|
- A new chapter on contributing to qpdf has been added to the
|
||||||
|
@ -21,8 +21,6 @@ insertAfter
|
|||||||
4 (4!)
|
4 (4!)
|
||||||
/Empty1
|
/Empty1
|
||||||
/Empty2
|
/Empty2
|
||||||
/Bad1: deprecated API
|
|
||||||
Name/Number tree node (object 16): item at index 2 is not the right type
|
|
||||||
/Bad1 -- wrong key type
|
/Bad1 -- wrong key type
|
||||||
WARNING: name-tree.pdf (Name/Number tree node (object 16)): attempting to repair after error: name-tree.pdf (Name/Number tree node (object 16)): item at index 2 is not the right type
|
WARNING: name-tree.pdf (Name/Number tree node (object 16)): attempting to repair after error: name-tree.pdf (Name/Number tree node (object 16)): item at index 2 is not the right type
|
||||||
WARNING: name-tree.pdf (Name/Number tree node (object 16)): item 2 has the wrong type
|
WARNING: name-tree.pdf (Name/Number tree node (object 16)): item 2 has the wrong type
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
insertAfter
|
insertAfter
|
||||||
3 (3!)
|
3 (3!)
|
||||||
4 (4!)
|
4 (4!)
|
||||||
/Bad1: deprecated API
|
|
||||||
/Bad1
|
/Bad1
|
||||||
WARNING: number-tree.pdf (Name/Number tree node (object 14)): name/number tree node has neither non-empty /Nums nor /Kids
|
WARNING: number-tree.pdf (Name/Number tree node (object 14)): name/number tree node has neither non-empty /Nums nor /Kids
|
||||||
WARNING: number-tree.pdf (Name/Number tree node (object 13)): loop detected while traversing name/number tree
|
WARNING: number-tree.pdf (Name/Number tree node (object 13)): loop detected while traversing name/number tree
|
||||||
|
@ -1733,23 +1733,8 @@ test_46(QPDF& pdf, char const* arg2)
|
|||||||
std::cout << i.first << " " << i.second.unparse() << std::endl;
|
std::cout << i.first << " " << i.second.unparse() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exercise deprecated API until qpdf 11
|
|
||||||
std::cout << "/Bad1: deprecated API" << std::endl;
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(disable : 4996)
|
|
||||||
#endif
|
|
||||||
#if (defined(__GNUC__) || defined(__clang__))
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#endif
|
|
||||||
auto bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"));
|
|
||||||
#if (defined(__GNUC__) || defined(__clang__))
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
assert(bad1.begin() == bad1.end());
|
|
||||||
|
|
||||||
std::cout << "/Bad1" << std::endl;
|
std::cout << "/Bad1" << std::endl;
|
||||||
bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
|
auto bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
|
||||||
assert(bad1.begin() == bad1.end());
|
assert(bad1.begin() == bad1.end());
|
||||||
assert(bad1.last() == bad1.end());
|
assert(bad1.last() == bad1.end());
|
||||||
|
|
||||||
@ -1931,28 +1916,8 @@ test_48(QPDF& pdf, char const* arg2)
|
|||||||
assert(empty.last()->second.getStringValue() == "6");
|
assert(empty.last()->second.getStringValue() == "6");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exercise deprecated API until qpdf 11
|
|
||||||
std::cout << "/Bad1: deprecated API" << std::endl;
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(disable : 4996)
|
|
||||||
#endif
|
|
||||||
#if (defined(__GNUC__) || defined(__clang__))
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#endif
|
|
||||||
auto bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"));
|
|
||||||
#if (defined(__GNUC__) || defined(__clang__))
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
try {
|
|
||||||
bad1.find("G", true);
|
|
||||||
assert(false);
|
|
||||||
} catch (std::runtime_error& e) {
|
|
||||||
std::cout << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "/Bad1 -- wrong key type" << std::endl;
|
std::cout << "/Bad1 -- wrong key type" << std::endl;
|
||||||
bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
|
auto bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
|
||||||
assert(bad1.find("G", true)->first == "A");
|
assert(bad1.find("G", true)->first == "A");
|
||||||
for (auto const& i : bad1) {
|
for (auto const& i : bad1) {
|
||||||
std::cout << i.first << std::endl;
|
std::cout << i.first << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user