aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-06-19 17:00:15 +0200
committerJay Berkenbilt <ejb@ql.org>2018-06-21 21:57:13 +0200
commit4cded10821e3bd523cf96eb628d7364820a07b84 (patch)
treeb3509d6b845450f2712a0e4a09331f1f91849159 /include
parent078cf9bf90ec22ba141ebf379e6993b491c2995d (diff)
downloadqpdf-4cded10821e3bd523cf96eb628d7364820a07b84.tar.zst
Add QPDFObjectHandle::Rectangle type
Provide a convenient way of accessing rectangles.
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFObjectHandle.hh47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 6f78e9a9..4f5cde37 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -172,6 +172,31 @@ class QPDFObjectHandle
void terminateParsing();
};
+ // Convenience object for rectangles
+ class Rectangle
+ {
+ public:
+ Rectangle() :
+ llx(0.0),
+ lly(0.0),
+ urx(0.0),
+ ury(0.0)
+ {
+ }
+ Rectangle(double llx, double lly,
+ double urx, double ury) :
+ llx(llx),
+ lly(lly),
+ urx(urx),
+ ury(ury)
+ {
+ }
+
+ double llx;
+ double lly;
+ double urx;
+ double ury;
+ };
QPDF_DLL
QPDFObjectHandle();
@@ -344,11 +369,18 @@ class QPDFObjectHandle
static QPDFObjectHandle newArray(
std::vector<QPDFObjectHandle> const& items);
QPDF_DLL
+ static QPDFObjectHandle newArray(Rectangle const&);
+ QPDF_DLL
static QPDFObjectHandle newDictionary();
QPDF_DLL
static QPDFObjectHandle newDictionary(
std::map<std::string, QPDFObjectHandle> const& items);
+ // Create an array from a rectangle. Equivalent to the rectangle
+ // form of newArray.
+ QPDF_DLL
+ static QPDFObjectHandle newFromRectangle(Rectangle const&);
+
// Create a new stream and associate it with the given qpdf
// object. A subsequent call must be made to replaceStreamData()
// to provide data for the stream. The stream's dictionary may be
@@ -465,6 +497,12 @@ class QPDFObjectHandle
QPDFObjectHandle getArrayItem(int n);
QPDF_DLL
std::vector<QPDFObjectHandle> getArrayAsVector();
+ QPDF_DLL
+ bool isRectangle();
+ // If the array an array of four numeric values, return as a
+ // rectangle. Otherwise, return the rectangle [0, 0, 0, 0]
+ QPDF_DLL
+ Rectangle getArrayAsRectangle();
// Methods for dictionary objects
QPDF_DLL
@@ -739,6 +777,15 @@ class QPDFObjectHandle
QPDF_DLL
void coalesceContentStreams();
+ // Issue a warning about this object if possible. If the object
+ // has a description, a warning will be issued. Otherwise, if
+ // throw_if_no_description is true, throw an exception. Otherwise
+ // do nothing. Objects read normally from the file have
+ // descriptions. See comments on setObjectDescription for
+ // additional details.
+ void warnIfPossible(std::string const& warning,
+ bool throw_if_no_description = false);
+
// Initializers for objects. This Factory class gives the QPDF
// class specific permission to call factory methods without
// making it a friend of the whole QPDFObjectHandle class.