Commit 06a65870 authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid

Use a std::string value in LinkNamed

parent 5d9a9c85
......@@ -416,9 +416,7 @@ static void
build_named (PopplerAction *action,
const LinkNamed *link)
{
const gchar *name;
name = link->getName ()->c_str ();
const gchar* name = link->getName ().c_str ();
if (name != nullptr)
action->named.named_dest = g_strdup (name);
}
......
......@@ -609,15 +609,10 @@ LinkURI::~LinkURI() {
//------------------------------------------------------------------------
LinkNamed::LinkNamed(const Object *nameObj) {
name = nullptr;
hasNameFlag = false;
if (nameObj->isName()) {
name = new GooString(nameObj->getName());
}
}
LinkNamed::~LinkNamed() {
if (name) {
delete name;
name = (nameObj->getName()) ? nameObj->getName() : "";
hasNameFlag = true;
}
}
......
......@@ -278,16 +278,15 @@ public:
// Build a LinkNamed given the action name.
LinkNamed(const Object *nameObj);
~LinkNamed() override;
bool isOk() const override { return name != nullptr; }
bool isOk() const override { return hasNameFlag; }
LinkActionKind getKind() const override { return actionNamed; }
const GooString *getName() const { return name; }
const std::string& getName() const { return name; }
private:
GooString *name;
std::string name;
bool hasNameFlag;
};
......
......@@ -236,30 +236,30 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
case actionNamed:
{
const char * name = ((LinkNamed *)a)->getName()->c_str();
if ( !strcmp( name, "NextPage" ) )
const std::string& name = ((LinkNamed *)a)->getName();
if ( name == "NextPage" )
popplerLink = new LinkAction( linkArea, LinkAction::PageNext );
else if ( !strcmp( name, "PrevPage" ) )
else if ( name == "PrevPage" )
popplerLink = new LinkAction( linkArea, LinkAction::PagePrev );
else if ( !strcmp( name, "FirstPage" ) )
else if ( name == "FirstPage" )
popplerLink = new LinkAction( linkArea, LinkAction::PageFirst );
else if ( !strcmp( name, "LastPage" ) )
else if ( name == "LastPage" )
popplerLink = new LinkAction( linkArea, LinkAction::PageLast );
else if ( !strcmp( name, "GoBack" ) )
else if ( name == "GoBack" )
popplerLink = new LinkAction( linkArea, LinkAction::HistoryBack );
else if ( !strcmp( name, "GoForward" ) )
else if ( name == "GoForward" )
popplerLink = new LinkAction( linkArea, LinkAction::HistoryForward );
else if ( !strcmp( name, "Quit" ) )
else if ( name == "Quit" )
popplerLink = new LinkAction( linkArea, LinkAction::Quit );
else if ( !strcmp( name, "GoToPage" ) )
else if ( name == "GoToPage" )
popplerLink = new LinkAction( linkArea, LinkAction::GoToPage );
else if ( !strcmp( name, "Find" ) )
else if ( name == "Find" )
popplerLink = new LinkAction( linkArea, LinkAction::Find );
else if ( !strcmp( name, "FullScreen" ) )
else if ( name == "FullScreen" )
popplerLink = new LinkAction( linkArea, LinkAction::Presentation );
else if ( !strcmp( name, "Print" ) )
else if ( name == "Print" )
popplerLink = new LinkAction( linkArea, LinkAction::Print );
else if ( !strcmp( name, "Close" ) )
else if ( name == "Close" )
{
// acroread closes the document always, doesnt care whether
// its presentation mode or not
......
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