aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFAnnotationObjectHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-03 17:51:58 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-03 17:59:55 +0100
commitca94ac68d9cdb317328398c770c9c755f0004535 (patch)
tree1654a22747dcf94151efa61ce62eda7ff7e967d0 /libqpdf/QPDFAnnotationObjectHelper.cc
parent06d6438ddf7f817d9cc1698c9b4b5e4b8f53e151 (diff)
downloadqpdf-ca94ac68d9cdb317328398c770c9c755f0004535.tar.zst
Honor flags when flattening annotations
Diffstat (limited to 'libqpdf/QPDFAnnotationObjectHelper.cc')
-rw-r--r--libqpdf/QPDFAnnotationObjectHelper.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/libqpdf/QPDFAnnotationObjectHelper.cc b/libqpdf/QPDFAnnotationObjectHelper.cc
index ca4af907..3295fd3a 100644
--- a/libqpdf/QPDFAnnotationObjectHelper.cc
+++ b/libqpdf/QPDFAnnotationObjectHelper.cc
@@ -81,7 +81,8 @@ QPDFAnnotationObjectHelper::getAppearanceStream(
std::string
QPDFAnnotationObjectHelper::getPageContentForAppearance(
- std::string const& name, int rotate)
+ std::string const& name, int rotate,
+ int required_flags, int forbidden_flags)
{
if (! getAppearanceStream("/N").isStream())
{
@@ -168,11 +169,24 @@ QPDFAnnotationObjectHelper::getPageContentForAppearance(
// appearance matrix.
QPDFObjectHandle rect_obj = this->oh.getKey("/Rect");
- QPDFObjectHandle flags = this->oh.getKey("/F");
+ QPDFObjectHandle flags_obj = this->oh.getKey("/F");
QPDFObjectHandle as = getAppearanceStream("/N").getDict();
QPDFObjectHandle bbox_obj = as.getKey("/BBox");
QPDFObjectHandle matrix_obj = as.getKey("/Matrix");
+ int flags = flags_obj.isInteger() ? flags_obj.getIntValue() : 0;
+
+ if (flags & forbidden_flags)
+ {
+ QTC::TC("qpdf", "QPDFAnnotationObjectHelper forbidden flags");
+ return "";
+ }
+ if ((flags & required_flags) != required_flags)
+ {
+ QTC::TC("qpdf", "QPDFAnnotationObjectHelper missing required flags");
+ return "";
+ }
+
if (! (bbox_obj.isRectangle() && rect_obj.isRectangle()))
{
return "";
@@ -188,8 +202,7 @@ QPDFAnnotationObjectHelper::getPageContentForAppearance(
QTC::TC("qpdf", "QPDFAnnotationObjectHelper default matrix");
}
QPDFObjectHandle::Rectangle rect = rect_obj.getArrayAsRectangle();
- bool do_rotate = (rotate && flags.isInteger() &&
- (flags.getIntValue() & 16));
+ bool do_rotate = (rotate && (flags & an_no_rotate));
if (do_rotate)
{
// If the the annotation flags include the NoRotate bit and