Commit 42eebb9b authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid

Use a std::string value in LinkRendition

parent 887d3575
......@@ -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;
}
......
......@@ -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;
};
//------------------------------------------------------------------------
......
......@@ -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);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment