aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFValue.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/QPDFValue.cc')
-rw-r--r--libqpdf/QPDFValue.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/libqpdf/QPDFValue.cc b/libqpdf/QPDFValue.cc
index 19679df2..7c5b30a6 100644
--- a/libqpdf/QPDFValue.cc
+++ b/libqpdf/QPDFValue.cc
@@ -13,16 +13,28 @@ QPDFValue::do_create(QPDFValue* object)
std::string
QPDFValue::getDescription()
{
- auto description = object_description ? *object_description : "";
- if (auto pos = description.find("$OG"); pos != std::string::npos) {
- description.replace(pos, 3, og.unparse(' '));
- }
- if (auto pos = description.find("$PO"); pos != std::string::npos) {
- qpdf_offset_t shift = (type_code == ::ot_dictionary) ? 2
- : (type_code == ::ot_array) ? 1
- : 0;
+ if (object_description) {
+ switch (object_description->index()) {
+ case 0:
+ {
+ auto description = std::get<0>(*object_description);
+
+ if (auto pos = description.find("$OG");
+ pos != std::string::npos) {
+ description.replace(pos, 3, og.unparse(' '));
+ }
+ if (auto pos = description.find("$PO");
+ pos != std::string::npos) {
+ qpdf_offset_t shift = (type_code == ::ot_dictionary) ? 2
+ : (type_code == ::ot_array) ? 1
+ : 0;
- description.replace(pos, 3, std::to_string(parsed_offset + shift));
+ description.replace(
+ pos, 3, std::to_string(parsed_offset + shift));
+ }
+ return description;
+ }
+ }
}
- return description;
+ return {};
}