aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_optimization.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-08-22 03:33:44 +0200
committerJay Berkenbilt <ejb@ql.org>2017-08-22 03:35:11 +0200
commita8c93bd324d0362a26c1e6591eead5c52f865c0d (patch)
treeb3eda018bb384479c109640f442c94bc3d84ac0b /libqpdf/QPDF_optimization.cc
parent8288a4eb3a326acced6f07b0caf75f6ada53150d (diff)
downloadqpdf-a8c93bd324d0362a26c1e6591eead5c52f865c0d.tar.zst
Push QPDF member variables into a nested class
Pushing member variables into a nested class enables addition of new member variables without breaking binary compatibility.
Diffstat (limited to 'libqpdf/QPDF_optimization.cc')
-rw-r--r--libqpdf/QPDF_optimization.cc62
1 files changed, 31 insertions, 31 deletions
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc
index fad710d0..1e42865c 100644
--- a/libqpdf/QPDF_optimization.cc
+++ b/libqpdf/QPDF_optimization.cc
@@ -62,7 +62,7 @@ void
QPDF::optimize(std::map<int, int> const& object_stream_data,
bool allow_changes)
{
- if (! this->obj_user_to_objects.empty())
+ if (! this->m->obj_user_to_objects.empty())
{
// already optimized
return;
@@ -83,19 +83,19 @@ QPDF::optimize(std::map<int, int> const& object_stream_data,
}
// Traverse pages tree pushing all inherited resources down to the
- // page level. This also initializes this->all_pages.
+ // page level. This also initializes this->m->all_pages.
pushInheritedAttributesToPage(allow_changes, false);
// Traverse pages
- int n = this->all_pages.size();
+ int n = this->m->all_pages.size();
for (int pageno = 0; pageno < n; ++pageno)
{
updateObjectMaps(ObjUser(ObjUser::ou_page, pageno),
- this->all_pages.at(pageno));
+ this->m->all_pages.at(pageno));
}
// Traverse document-level items
- std::set<std::string> keys = this->trailer.getKeys();
+ std::set<std::string> keys = this->m->trailer.getKeys();
for (std::set<std::string>::iterator iter = keys.begin();
iter != keys.end(); ++iter)
{
@@ -107,7 +107,7 @@ QPDF::optimize(std::map<int, int> const& object_stream_data,
else
{
updateObjectMaps(ObjUser(ObjUser::ou_trailer_key, key),
- this->trailer.getKey(key));
+ this->m->trailer.getKey(key));
}
}
@@ -129,8 +129,8 @@ QPDF::optimize(std::map<int, int> const& object_stream_data,
ObjUser root_ou = ObjUser(ObjUser::ou_root);
QPDFObjGen root_og = QPDFObjGen(root.getObjGen());
- obj_user_to_objects[root_ou].insert(root_og);
- object_to_obj_users[root_og].insert(root_ou);
+ this->m->obj_user_to_objects[root_ou].insert(root_og);
+ this->m->object_to_obj_users[root_og].insert(root_ou);
filterCompressedObjects(object_stream_data);
}
@@ -151,7 +151,7 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys)
// The record of whether we've done this is cleared by
// updateAllPagesCache(). If we're warning for skipped keys,
// re-traverse unconditionally.
- if (this->pushed_inherited_attributes_to_pages && (! warn_skipped_keys))
+ if (this->m->pushed_inherited_attributes_to_pages && (! warn_skipped_keys))
{
return;
}
@@ -159,12 +159,12 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys)
// key_ancestors is a mapping of page attribute keys to a stack of
// Pages nodes that contain values for them.
std::map<std::string, std::vector<QPDFObjectHandle> > key_ancestors;
- this->all_pages.clear();
+ this->m->all_pages.clear();
pushInheritedAttributesToPageInternal(
- this->trailer.getKey("/Root").getKey("/Pages"),
- key_ancestors, this->all_pages, allow_changes, warn_skipped_keys);
+ this->m->trailer.getKey("/Root").getKey("/Pages"),
+ key_ancestors, this->m->all_pages, allow_changes, warn_skipped_keys);
assert(key_ancestors.empty());
- this->pushed_inherited_attributes_to_pages = true;
+ this->m->pushed_inherited_attributes_to_pages = true;
}
void
@@ -192,8 +192,8 @@ QPDF::pushInheritedAttributesToPageInternal2(
if (visited.count(this_og) > 0)
{
throw QPDFExc(
- qpdf_e_pages, this->file->getName(),
- this->last_object_description, 0,
+ qpdf_e_pages, this->m->file->getName(),
+ this->m->last_object_description, 0,
"Loop detected in /Pages structure (inherited attributes)");
}
visited.insert(this_og);
@@ -219,9 +219,9 @@ QPDF::pushInheritedAttributesToPageInternal2(
{
if (! allow_changes)
{
- throw QPDFExc(qpdf_e_internal, this->file->getName(),
- this->last_object_description,
- this->file->getLastOffset(),
+ throw QPDFExc(qpdf_e_internal, this->m->file->getName(),
+ this->m->last_object_description,
+ this->m->file->getLastOffset(),
"optimize detected an "
"inheritable attribute when called "
"in no-change mode");
@@ -269,8 +269,8 @@ QPDF::pushInheritedAttributesToPageInternal2(
setLastObjectDescription("Pages object",
cur_pages.getObjectID(),
cur_pages.getGeneration());
- warn(QPDFExc(qpdf_e_pages, this->file->getName(),
- this->last_object_description, 0,
+ warn(QPDFExc(qpdf_e_pages, this->m->file->getName(),
+ this->m->last_object_description, 0,
"Unknown key " + key + " in /Pages object"
" is being discarded as a result of"
" flattening the /Pages tree"));
@@ -337,9 +337,9 @@ QPDF::pushInheritedAttributesToPageInternal2(
}
else
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
- this->last_object_description,
- this->file->getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(),
+ this->m->last_object_description,
+ this->m->file->getLastOffset(),
"invalid Type " + type + " in page tree");
}
visited.erase(this_og);
@@ -382,8 +382,8 @@ QPDF::updateObjectMapsInternal(ObjUser const& ou, QPDFObjectHandle oh,
QTC::TC("qpdf", "QPDF opt loop detected");
return;
}
- this->obj_user_to_objects[ou].insert(og);
- this->object_to_obj_users[og].insert(ou);
+ this->m->obj_user_to_objects[ou].insert(og);
+ this->m->object_to_obj_users[og].insert(ou);
visited.insert(og);
}
@@ -445,8 +445,8 @@ QPDF::filterCompressedObjects(std::map<int, int> const& object_stream_data)
std::map<QPDFObjGen, std::set<ObjUser> > t_object_to_obj_users;
for (std::map<ObjUser, std::set<QPDFObjGen> >::iterator i1 =
- this->obj_user_to_objects.begin();
- i1 != this->obj_user_to_objects.end(); ++i1)
+ this->m->obj_user_to_objects.begin();
+ i1 != this->m->obj_user_to_objects.end(); ++i1)
{
ObjUser const& ou = (*i1).first;
std::set<QPDFObjGen> const& objects = (*i1).second;
@@ -468,8 +468,8 @@ QPDF::filterCompressedObjects(std::map<int, int> const& object_stream_data)
}
for (std::map<QPDFObjGen, std::set<ObjUser> >::iterator i1 =
- this->object_to_obj_users.begin();
- i1 != this->object_to_obj_users.end(); ++i1)
+ this->m->object_to_obj_users.begin();
+ i1 != this->m->object_to_obj_users.end(); ++i1)
{
QPDFObjGen const& og = (*i1).first;
std::set<ObjUser> const& objusers = (*i1).second;
@@ -490,6 +490,6 @@ QPDF::filterCompressedObjects(std::map<int, int> const& object_stream_data)
}
}
- this->obj_user_to_objects = t_obj_user_to_objects;
- this->object_to_obj_users = t_object_to_obj_users;
+ this->m->obj_user_to_objects = t_obj_user_to_objects;
+ this->m->object_to_obj_users = t_object_to_obj_users;
}