Commit 6346e66499e1efd163393412e4fbac10bca36fef
1 parent
e760931f
Refactor `QPDFAnnotationObjectHelper`: use `operator[]`, `Name`, and `Integer` f…
…or improved clarity and consistency, and remove unused test coverage entries.
Showing
2 changed files
with
7 additions
and
11 deletions
libqpdf/QPDFAnnotationObjectHelper.cc
| 1 | 1 | #include <qpdf/QPDFAnnotationObjectHelper.hh> |
| 2 | 2 | |
| 3 | -#include <qpdf/QPDF.hh> | |
| 4 | 3 | #include <qpdf/QPDFMatrix.hh> |
| 4 | +#include <qpdf/QPDFObjectHandle_private.hh> | |
| 5 | 5 | #include <qpdf/QTC.hh> |
| 6 | 6 | #include <qpdf/QUtil.hh> |
| 7 | 7 | |
| 8 | +using namespace qpdf; | |
| 9 | + | |
| 8 | 10 | QPDFAnnotationObjectHelper::QPDFAnnotationObjectHelper(QPDFObjectHandle oh) : |
| 9 | 11 | QPDFObjectHelper(oh) |
| 10 | 12 | { |
| ... | ... | @@ -31,19 +33,15 @@ QPDFAnnotationObjectHelper::getAppearanceDictionary() |
| 31 | 33 | std::string |
| 32 | 34 | QPDFAnnotationObjectHelper::getAppearanceState() |
| 33 | 35 | { |
| 34 | - if (oh().getKey("/AS").isName()) { | |
| 35 | - QTC::TC("qpdf", "QPDFAnnotationObjectHelper AS present"); | |
| 36 | - return oh().getKey("/AS").getName(); | |
| 37 | - } | |
| 38 | - QTC::TC("qpdf", "QPDFAnnotationObjectHelper AS absent"); | |
| 39 | - return ""; | |
| 36 | + Name AS = (*this)["/AS"]; | |
| 37 | + return AS ? AS.value() : ""; | |
| 40 | 38 | } |
| 41 | 39 | |
| 42 | 40 | int |
| 43 | 41 | QPDFAnnotationObjectHelper::getFlags() |
| 44 | 42 | { |
| 45 | - QPDFObjectHandle flags_obj = oh().getKey("/F"); | |
| 46 | - return flags_obj.isInteger() ? flags_obj.getIntValueAsInt() : 0; | |
| 43 | + Integer flags_obj = (*this)["/F"]; | |
| 44 | + return flags_obj ? flags_obj : 0; | |
| 47 | 45 | } |
| 48 | 46 | |
| 49 | 47 | QPDFObjectHandle | ... | ... |
qpdf/qpdf.testcov
| ... | ... | @@ -292,8 +292,6 @@ QPDFFormFieldObjectHelper TU absent 0 |
| 292 | 292 | QPDFFormFieldObjectHelper TM absent 0 |
| 293 | 293 | QPDFFormFieldObjectHelper Q present 1 |
| 294 | 294 | QPDFFormFieldObjectHelper DA present 1 |
| 295 | -QPDFAnnotationObjectHelper AS present 0 | |
| 296 | -QPDFAnnotationObjectHelper AS absent 0 | |
| 297 | 295 | QPDFAnnotationObjectHelper AP stream 0 |
| 298 | 296 | QPDFAnnotationObjectHelper AP dictionary 0 |
| 299 | 297 | QPDFAnnotationObjectHelper AP sub stream 0 | ... | ... |