summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFObjectHandle.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-07-11 21:29:41 +0200
committerJay Berkenbilt <ejb@ql.org>2012-07-11 21:54:33 +0200
commite7b8f297ba92f4cadf88efcb394830dc24d54738 (patch)
tree4bc25b3928545d81c4b8029fab389af8bccfdbc5 /libqpdf/QPDFObjectHandle.cc
parent8a217eb3a26931453b4f003c6c18ad8569230cf1 (diff)
downloadqpdf-e7b8f297ba92f4cadf88efcb394830dc24d54738.tar.zst
Support copying objects from another QPDF object
This includes QPDF::copyForeignObject and supporting foreign objects as arguments to addPage*.
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r--libqpdf/QPDFObjectHandle.cc36
1 files changed, 34 insertions, 2 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index 25298bee..4f43aa89 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -355,6 +355,14 @@ QPDFObjectHandle::isOrHasName(std::string const& value)
return false;
}
+// Indirect object accessors
+QPDF*
+QPDFObjectHandle::getOwningQPDF()
+{
+ // Will be null for direct objects
+ return this->qpdf;
+}
+
// Dictionary mutators
void
@@ -784,6 +792,7 @@ QPDFObjectHandle::makeDirectInternal(std::set<int>& visited)
}
dereference();
+ this->qpdf = 0;
this->objid = 0;
this->generation = 0;
@@ -946,6 +955,16 @@ QPDFObjectHandle::assertReserved()
}
void
+QPDFObjectHandle::assertIndirect()
+{
+ if (! isIndirect())
+ {
+ throw std::logic_error(
+ "operation for indirect object attempted on direct object");
+ }
+}
+
+void
QPDFObjectHandle::assertScalar()
{
assertType("Scalar", isScalar());
@@ -957,11 +976,24 @@ QPDFObjectHandle::assertNumber()
assertType("Number", isNumber());
}
+bool
+QPDFObjectHandle::isPageObject()
+{
+ return (this->isDictionary() && this->hasKey("/Type") &&
+ (this->getKey("/Type").getName() == "/Page"));
+}
+
+bool
+QPDFObjectHandle::isPagesObject()
+{
+ return (this->isDictionary() && this->hasKey("/Type") &&
+ (this->getKey("/Type").getName() == "/Pages"));
+}
+
void
QPDFObjectHandle::assertPageObject()
{
- if (! (this->isDictionary() && this->hasKey("/Type") &&
- (this->getKey("/Type").getName() == "/Page")))
+ if (! isPageObject())
{
throw std::logic_error("page operation called on non-Page object");
}