2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-16 17:45:09 +00:00

QPDFPageObjectHelper: getPageImages -> getImages

This commit is contained in:
Jay Berkenbilt 2020-12-31 13:23:49 -05:00
parent e7a8554563
commit 63ea46193d
9 changed files with 24 additions and 13 deletions

View File

@ -1,5 +1,10 @@
2020-12-31 Jay Berkenbilt <ejb@ql.org> 2020-12-31 Jay Berkenbilt <ejb@ql.org>
* Rename QPDFPageObjectHelper::getPageImages to
QPDFPageObjectHelper::getImages and make it support form XObjects
as well as pages. The old name will be preserved for
compatibility.
* Add QPDFObjectHandle::isFormXObject to test whether an object is * Add QPDFObjectHandle::isFormXObject to test whether an object is
a form XObject. a form XObject.

View File

@ -268,7 +268,7 @@ static void check(char const* filename,
page_iter != pages.end(); ++page_iter) page_iter != pages.end(); ++page_iter)
{ {
QPDFPageObjectHelper& page(*page_iter); QPDFPageObjectHelper& page(*page_iter);
std::map<std::string, QPDFObjectHandle> images = page.getPageImages(); std::map<std::string, QPDFObjectHandle> images = page.getImages();
if (images.size() != 1) if (images.size() != 1)
{ {
throw std::logic_error("incorrect number of images on page"); throw std::logic_error("incorrect number of images on page");

View File

@ -159,7 +159,7 @@ int main(int argc, char* argv[])
QPDFPageObjectHelper& page(*iter); QPDFPageObjectHelper& page(*iter);
// Get all images on the page. // Get all images on the page.
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images =
page.getPageImages(); page.getImages();
for (auto& iter2: images) for (auto& iter2: images)
{ {
QPDFObjectHandle& image = iter2.second; QPDFObjectHandle& image = iter2.second;

View File

@ -143,7 +143,7 @@ FuzzHelper::testPages()
{ {
page.coalesceContentStreams(); page.coalesceContentStreams();
page.parsePageContents(&discard_contents); page.parsePageContents(&discard_contents);
page.getPageImages(); page.getImages();
pldh.getLabelForPage(pageno); pldh.getLabelForPage(pageno);
QPDFObjectHandle page_obj(page.getObjectHandle()); QPDFObjectHandle page_obj(page.getObjectHandle());
page_obj.getJSON(true).unparse(); page_obj.getJSON(true).unparse();

View File

@ -78,6 +78,10 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// name to the image object, which is always a stream. Works with // name to the image object, which is always a stream. Works with
// form XObjects as well as pages. // form XObjects as well as pages.
QPDF_DLL QPDF_DLL
std::map<std::string, QPDFObjectHandle> getImages();
// Old name -- calls getImages()
QPDF_DLL
std::map<std::string, QPDFObjectHandle> getPageImages(); std::map<std::string, QPDFObjectHandle> getPageImages();
// Convert each inline image to an external (normal) image if the // Convert each inline image to an external (normal) image if the

View File

@ -1320,7 +1320,7 @@ QPDFObjectHandle::getGeneration() const
std::map<std::string, QPDFObjectHandle> std::map<std::string, QPDFObjectHandle>
QPDFObjectHandle::getPageImages() QPDFObjectHandle::getPageImages()
{ {
return QPDFPageObjectHelper(*this).getPageImages(); return QPDFPageObjectHelper(*this).getImages();
} }
std::vector<QPDFObjectHandle> std::vector<QPDFObjectHandle>

View File

@ -388,6 +388,12 @@ QPDFPageObjectHelper::getMediaBox(bool copy_if_shared)
std::map<std::string, QPDFObjectHandle> std::map<std::string, QPDFObjectHandle>
QPDFPageObjectHelper::getPageImages() QPDFPageObjectHelper::getPageImages()
{
return getImages();
}
std::map<std::string, QPDFObjectHandle>
QPDFPageObjectHelper::getImages()
{ {
std::map<std::string, QPDFObjectHandle> result; std::map<std::string, QPDFObjectHandle> result;
QPDFObjectHandle resources = getAttribute("/Resources", false); QPDFObjectHandle resources = getAttribute("/Resources", false);

View File

@ -3639,8 +3639,7 @@ static void do_show_pages(QPDF& pdf, Options& o)
<< page.getGeneration() << " R" << std::endl; << page.getGeneration() << " R" << std::endl;
if (o.show_page_images) if (o.show_page_images)
{ {
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images = ph.getImages();
ph.getPageImages();
if (! images.empty()) if (! images.empty())
{ {
std::cout << " images:" << std::endl; std::cout << " images:" << std::endl;
@ -3765,8 +3764,7 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j)
j_page.addDictionaryMember("object", page.getJSON()); j_page.addDictionaryMember("object", page.getJSON());
JSON j_images = j_page.addDictionaryMember( JSON j_images = j_page.addDictionaryMember(
"images", JSON::makeArray()); "images", JSON::makeArray());
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images = ph.getImages();
ph.getPageImages();
for (auto const& iter2: images) for (auto const& iter2: images)
{ {
JSON j_image = j_images.addArrayElement(JSON::makeDictionary()); JSON j_image = j_images.addArrayElement(JSON::makeDictionary());
@ -4785,8 +4783,7 @@ static void handle_transformations(QPDF& pdf, Options& o)
++pageno; ++pageno;
QPDFPageObjectHelper& ph(*iter); QPDFPageObjectHelper& ph(*iter);
QPDFObjectHandle page = ph.getObjectHandle(); QPDFObjectHandle page = ph.getObjectHandle();
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images = ph.getImages();
ph.getPageImages();
for (auto& iter2: images) for (auto& iter2: images)
{ {
std::string name = iter2.first; std::string name = iter2.first;

View File

@ -516,8 +516,7 @@ void runtest(int n, char const* filename1, char const* arg2)
std::cout << "page " << pageno << ":" << std::endl; std::cout << "page " << pageno << ":" << std::endl;
std::cout << " images:" << std::endl; std::cout << " images:" << std::endl;
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images = page.getImages();
page.getPageImages();
for (auto const& iter2: images) for (auto const& iter2: images)
{ {
std::string const& name = iter2.first; std::string const& name = iter2.first;
@ -1488,7 +1487,7 @@ void runtest(int n, char const* filename1, char const* arg2)
{ {
std::cout << "page " << ++pageno << std::endl; std::cout << "page " << ++pageno << std::endl;
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images =
(*p_iter).getPageImages(); (*p_iter).getImages();
for (std::map<std::string, QPDFObjectHandle>::iterator i_iter = for (std::map<std::string, QPDFObjectHandle>::iterator i_iter =
images.begin(); i_iter != images.end(); ++i_iter) images.begin(); i_iter != images.end(); ++i_iter)
{ {