summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2020-01-25 20:44:56 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-02-23 16:46:59 +0000
commit42eebb9bade006ceb602805c474bc9df5ef630b9 (patch)
tree89fc2d230cf72ffb5011bbfded5b673b0c681314
parent887d35751979d3441a18db00b99cfc5b6b8d958f (diff)
Use a std::string value in LinkRendition
-rw-r--r--poppler/Link.cc11
-rw-r--r--poppler/Link.h4
-rw-r--r--utils/JSInfo.cc12
3 files changed, 11 insertions, 16 deletions
diff --git a/poppler/Link.cc b/poppler/Link.cc
index 9433fd9f..0aca017a 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -714,7 +714,6 @@ LinkSound::LinkSound(const Object *soundObj) {
LinkRendition::LinkRendition(const Object *obj) {
operation = NoRendition;
media = nullptr;
- js = nullptr;
int operationCode = -1;
screenRef = Ref::INVALID();
@@ -723,11 +722,10 @@ LinkRendition::LinkRendition(const Object *obj) {
Object tmp = obj->dictLookup("JS");
if (!tmp.isNull()) {
if (tmp.isString()) {
- js = new GooString(tmp.getString());
+ js = tmp.getString()->toStr();
} else if (tmp.isStream()) {
Stream *stream = tmp.getStream();
- js = new GooString();
- stream->fillGooString(js);
+ stream->fillString(js);
} else {
error(errSyntaxWarning, -1, "Invalid Rendition Action: JS not string or stream");
}
@@ -736,7 +734,7 @@ LinkRendition::LinkRendition(const Object *obj) {
tmp = obj->dictLookup("OP");
if (tmp.isInt()) {
operationCode = tmp.getInt();
- if (!js && (operationCode < 0 || operationCode > 4)) {
+ if (js.empty() && (operationCode < 0 || operationCode > 4)) {
error(errSyntaxWarning, -1, "Invalid Rendition Action: unrecognized operation valued: {0:d}", operationCode);
} else {
// retrieve rendition object
@@ -773,14 +771,13 @@ LinkRendition::LinkRendition(const Object *obj) {
operation = PlayRendition;
break;
}
- } else if (!js) {
+ } else if (js=="") {
error(errSyntaxWarning, -1, "Invalid Rendition action: no OP or JS field defined");
}
}
}
LinkRendition::~LinkRendition() {
- delete js;
delete media;
}
diff --git a/poppler/Link.h b/poppler/Link.h
index 053cbb85..f3b2d787 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -365,7 +365,7 @@ public:
const MediaRendition* getMedia() const { return media; }
- const GooString *getScript() const { return js; }
+ const std::string& getScript() const { return js; }
private:
@@ -375,7 +375,7 @@ private:
MediaRendition* media;
- GooString *js;
+ std::string js;
};
//------------------------------------------------------------------------
diff --git a/utils/JSInfo.cc b/utils/JSInfo.cc
index ba082904..aa9402d5 100644
--- a/utils/JSInfo.cc
+++ b/utils/JSInfo.cc
@@ -71,15 +71,13 @@ void JSInfo::scanLinkAction(LinkAction *link, const char *action, bool deleteLin
if (link->getKind() == actionRendition) {
LinkRendition *linkr = static_cast<LinkRendition *>(link);
- if (linkr->getScript()) {
+ if (!linkr->getScript().empty()) {
hasJS = true;
if (print) {
- const GooString *s = linkr->getScript();
- if (s && s->c_str()) {
- fprintf(file, "%s (Rendition):\n", action);
- printJS(s);
- fputs("\n\n", file);
- }
+ fprintf(file, "%s (Rendition):\n", action);
+ const GooString s(linkr->getScript());
+ printJS(&s);
+ fputs("\n\n", file);
}
}
}