summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2020-01-25 09:46:10 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-02-23 16:46:59 +0000
commite9278387cbff75ce75a87a92bc297b53256bd3fc (patch)
treee045eca01a553b6959e11d8ec8fbd3ea0a944c76
parent9c8d05116e8d4fc26c5a9cd5a41aadb1f39b7f9f (diff)
Use a std::string value in LinkHide
-rw-r--r--poppler/Link.cc9
-rw-r--r--poppler/Link.h12
2 files changed, 9 insertions, 12 deletions
diff --git a/poppler/Link.cc b/poppler/Link.cc
index 74b16d7f..f9d4edf9 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -872,13 +872,14 @@ LinkOCGState::LinkOCGState(const Object *obj)
//------------------------------------------------------------------------
LinkHide::LinkHide(const Object *hideObj) {
- targetName = nullptr;
+ hasTargetNameFlag = false;
show = false; // Default
if (hideObj->isDict()) {
const Object targetObj = hideObj->dictLookup("T");
if (targetObj.isString()) {
- targetName = targetObj.getString()->copy();
+ targetName = targetObj.getString()->toStr();
+ hasTargetNameFlag = true;
}
const Object shouldHide = hideObj->dictLookup("H");
if (shouldHide.isBool()) {
@@ -887,10 +888,6 @@ LinkHide::LinkHide(const Object *hideObj) {
}
}
-LinkHide::~LinkHide() {
- delete targetName;
-}
-
//------------------------------------------------------------------------
// LinkUnknown
//------------------------------------------------------------------------
diff --git a/poppler/Link.h b/poppler/Link.h
index 532eac74..48a7a91e 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -470,9 +470,7 @@ class LinkHide: public LinkAction {
public:
LinkHide(const Object *hideObj);
- ~LinkHide() override;
-
- bool isOk() const override { return targetName != nullptr; }
+ bool isOk() const override { return hasTargetNameFlag; }
LinkActionKind getKind() const override { return actionHide; }
// According to spec the target can be either:
@@ -484,14 +482,16 @@ public:
// While b / c appear to be very uncommon and can't easily be
// created with Adobe Acrobat DC. So only support hide
// actions with named targets (yet).
- bool hasTargetName() const { return targetName != nullptr; }
- const GooString *getTargetName() const { return targetName; }
+ bool hasTargetName() const { return hasTargetNameFlag; }
+ const std::string& getTargetName() const { return targetName; }
// Should this action show or hide.
bool isShowAction() const { return show; }
private:
- GooString *targetName;
+
+ bool hasTargetNameFlag;
+ std::string targetName;
bool show;
};