112 lines
3.1 KiB
Diff
112 lines
3.1 KiB
Diff
From 435cd4bddd69f742467114cc0f9331e48f30cabc Mon Sep 17 00:00:00 2001
|
|
From: Jakub Wilk <jwilk@jwilk.net>
|
|
Date: Sat, 2 Sep 2017 15:58:25 +0200
|
|
Subject: [PATCH] Fix compatibility with Poppler 0.58.
|
|
|
|
http://cgit.freedesktop.org/poppler/poppler/commit/?id=3c29ded4bee5eadb829ed46af2ec92be57b0077b
|
|
http://cgit.freedesktop.org/poppler/poppler/commit/?id=9773c1534668d84b8267c3e5c9d612076fa231a5
|
|
---
|
|
pdf-backend.cc | 14 ++++++++++++--
|
|
pdf-backend.hh | 12 ++++++++++++
|
|
pdf2djvu.cc | 5 ++++-
|
|
3 files changed, 28 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/pdf-backend.cc b/pdf-backend.cc
|
|
index 2499402..554c5c0 100644
|
|
--- a/pdf-backend.cc
|
|
+++ b/pdf-backend.cc
|
|
@@ -402,7 +402,7 @@ pdf::Metadata::Metadata(pdf::Document &document)
|
|
date_fields.push_back(std::make_pair("ModDate", &this->mod_date));
|
|
|
|
pdf::OwnedObject info;
|
|
- document.getDocInfo(&info);
|
|
+ document.get_doc_info(info);
|
|
if (!info.isDict())
|
|
return;
|
|
pdf::Dict *info_dict = info.getDict();
|
|
@@ -591,17 +591,27 @@ double pdf::get_path_area(splash::Path &path)
|
|
|
|
pdf::Object *pdf::dict_lookup(pdf::Object &dict, const char *key, pdf::Object *object)
|
|
{
|
|
+#if POPPLER_VERSION < 5800
|
|
return dict.dictLookup(const_cast<char*>(key), object);
|
|
+#else
|
|
+ *object = dict.dictLookup(const_cast<char*>(key));
|
|
+ return object;
|
|
+#endif
|
|
}
|
|
|
|
pdf::Object *pdf::dict_lookup(pdf::Object *dict, const char *key, pdf::Object *object)
|
|
{
|
|
- return dict->dictLookup(const_cast<char*>(key), object);
|
|
+ return pdf::dict_lookup(*dict, key, object);
|
|
}
|
|
|
|
pdf::Object *pdf::dict_lookup(pdf::Dict *dict, const char *key, pdf::Object *object)
|
|
{
|
|
+#if POPPLER_VERSION < 5800
|
|
return dict->lookup(const_cast<char*>(key), object);
|
|
+#else
|
|
+ *object = dict->lookup(const_cast<char*>(key));
|
|
+ return object;
|
|
+#endif
|
|
}
|
|
|
|
|
|
diff --git a/pdf-backend.hh b/pdf-backend.hh
|
|
index 6a430c7..f50269e 100644
|
|
--- a/pdf-backend.hh
|
|
+++ b/pdf-backend.hh
|
|
@@ -274,6 +274,7 @@ namespace pdf
|
|
* ====================================
|
|
*/
|
|
|
|
+#if POPPLER_VERSION < 5800
|
|
class OwnedObject : public Object
|
|
{
|
|
public:
|
|
@@ -282,6 +283,9 @@ namespace pdf
|
|
this->free();
|
|
}
|
|
};
|
|
+#else
|
|
+ typedef ::Object OwnedObject;
|
|
+#endif
|
|
|
|
|
|
/* class pdf::Environment
|
|
@@ -315,6 +319,14 @@ namespace pdf
|
|
void display_page(Renderer *renderer, int npage, double hdpi, double vdpi, bool crop, bool do_links);
|
|
void get_page_size(int n, bool crop, double &width, double &height);
|
|
const std::string get_xmp();
|
|
+ void get_doc_info(pdf::OwnedObject &info)
|
|
+ {
|
|
+#if POPPLER_VERSION < 5800
|
|
+ this->getDocInfo(&info);
|
|
+#else
|
|
+ info = this->getDocInfo();
|
|
+#endif
|
|
+ }
|
|
class LoadError : public std::runtime_error
|
|
{
|
|
public:
|
|
diff --git a/pdf2djvu.cc b/pdf2djvu.cc
|
|
index ea3f7b0..9c16be7 100644
|
|
--- a/pdf2djvu.cc
|
|
+++ b/pdf2djvu.cc
|
|
@@ -716,10 +716,13 @@ void pdf_outline_to_djvu_outline(pdf::Object *node, pdf::Catalog *catalog,
|
|
}
|
|
|
|
pdf::dict_lookup(current, "Next", &next);
|
|
+#if POPPLER_VERSION < 5800
|
|
current.free();
|
|
current = next;
|
|
+#else
|
|
+ current = std::move(next);
|
|
+#endif
|
|
}
|
|
- current.free();
|
|
}
|
|
|
|
static void pdf_outline_to_djvu_outline(pdf::Document &doc, djvu::Outline &djvu_outline,
|