aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-02 14:12:17 +0200
committerm-holger <m-holger@kubitscheck.org>2022-08-31 23:46:09 +0200
commit7248cab71b69efe1e5efa3f1400d4d3970271a77 (patch)
treee5099c59aef6a19a91425310d73aa4472b31c0bd
parentbd300be08d94add92657aef1d46afd100459302b (diff)
downloadqpdf-7248cab71b69efe1e5efa3f1400d4d3970271a77.tar.zst
Add class QPDF_Unresolved
Allow QPDFObjectHandle::obj to be set prior resolving object. ot_unresolved has been appended to the list object types in order to preserve the output of existing test cases.
-rw-r--r--include/qpdf/Constants.h2
-rw-r--r--include/qpdf/QPDFObject.hh1
-rw-r--r--libqpdf/CMakeLists.txt1
-rw-r--r--libqpdf/QPDF_Unresolved.cc41
-rw-r--r--libqpdf/qpdf/QPDF_Unresolved.hh21
5 files changed, 66 insertions, 0 deletions
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index 5d2113bd..cf6bdaef 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -82,6 +82,8 @@ enum qpdf_object_type_e {
/* Additional object types that can occur in content streams */
ot_operator,
ot_inlineimage,
+ /* Object types internal to qpdf */
+ ot_unresolved,
/* NOTE: if adding to this list, update QPDFObject.hh */
};
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh
index eb7c4b90..8b6f7403 100644
--- a/include/qpdf/QPDFObject.hh
+++ b/include/qpdf/QPDFObject.hh
@@ -61,6 +61,7 @@ class QPDFObject
static constexpr object_type_e ot_stream = ::ot_stream;
static constexpr object_type_e ot_operator = ::ot_operator;
static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
+ static constexpr object_type_e ot_unresolved = ::ot_unresolved;
virtual ~QPDFObject() = default;
virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;
diff --git a/libqpdf/CMakeLists.txt b/libqpdf/CMakeLists.txt
index 51f7476d..7a4ef333 100644
--- a/libqpdf/CMakeLists.txt
+++ b/libqpdf/CMakeLists.txt
@@ -99,6 +99,7 @@ set(libqpdf_SOURCES
QPDF_Reserved.cc
QPDF_Stream.cc
QPDF_String.cc
+ QPDF_Unresolved.cc
QPDF_encryption.cc
QPDF_json.cc
QPDF_linearization.cc
diff --git a/libqpdf/QPDF_Unresolved.cc b/libqpdf/QPDF_Unresolved.cc
new file mode 100644
index 00000000..f348ec36
--- /dev/null
+++ b/libqpdf/QPDF_Unresolved.cc
@@ -0,0 +1,41 @@
+#include <qpdf/QPDF_Unresolved.hh>
+
+#include <stdexcept>
+
+std::shared_ptr<QPDFObject>
+QPDF_Unresolved::create()
+{
+ return do_create(new QPDF_Unresolved());
+}
+
+std::shared_ptr<QPDFObject>
+QPDF_Unresolved::shallowCopy()
+{
+ return create();
+}
+
+std::string
+QPDF_Unresolved::unparse()
+{
+ throw std::logic_error(
+ "attempted to unparse an unresolveded QPDFObjectHandle");
+ return "";
+}
+
+JSON
+QPDF_Unresolved::getJSON(int json_version)
+{
+ return JSON::makeNull();
+}
+
+QPDFObject::object_type_e
+QPDF_Unresolved::getTypeCode() const
+{
+ return QPDFObject::ot_unresolved;
+}
+
+char const*
+QPDF_Unresolved::getTypeName() const
+{
+ return "unresolved";
+}
diff --git a/libqpdf/qpdf/QPDF_Unresolved.hh b/libqpdf/qpdf/QPDF_Unresolved.hh
new file mode 100644
index 00000000..4f1c5238
--- /dev/null
+++ b/libqpdf/qpdf/QPDF_Unresolved.hh
@@ -0,0 +1,21 @@
+#ifndef QPDF_UNRESOLVED_HH
+#define QPDF_UNRESOLVED_HH
+
+#include <qpdf/QPDFObject.hh>
+
+class QPDF_Unresolved: public QPDFObject
+{
+ public:
+ virtual ~QPDF_Unresolved() = default;
+ static std::shared_ptr<QPDFObject> create();
+ virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::string unparse();
+ virtual JSON getJSON(int json_version);
+ virtual QPDFObject::object_type_e getTypeCode() const;
+ virtual char const* getTypeName() const;
+
+ private:
+ QPDF_Unresolved() = default;
+};
+
+#endif // QPDF_UNRESOLVED_HH