[poppler] poppler/Link.cc poppler/Link.h utils/HtmlOutputDev.cc

2022-02-10 Thread GitLab Mirror
 poppler/Link.cc|   21 +
 poppler/Link.h |7 +--
 utils/HtmlOutputDev.cc |8 
 3 files changed, 6 insertions(+), 30 deletions(-)

New commits:
commit 7a429c3cf9fba67ee736a52aa4f12e0c177f1405
Author: Albert Astals Cid 
Date:   Thu Feb 10 14:44:13 2022 +0100

Remove LinkDest::copy

The class is perfectly copyable by the default compiler provided copy
constructor

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 11ef879b..69b83995 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -16,7 +16,7 @@
 // Copyright (C) 2006, 2008 Pino Toscano 
 // Copyright (C) 2007, 2010, 2011 Carlos Garcia Campos 
 // Copyright (C) 2008 Hugo Mercier 
-// Copyright (C) 2008-2010, 2012-2014, 2016-2021 Albert Astals Cid 

+// Copyright (C) 2008-2010, 2012-2014, 2016-2022 Albert Astals Cid 

 // Copyright (C) 2009 Kovid Goyal 
 // Copyright (C) 2009 Ilya Gorenbein 
 // Copyright (C) 2012 Tobias Koening 
@@ -408,25 +408,6 @@ LinkDest::LinkDest(const Array *a)
 ok = true;
 }
 
-LinkDest::LinkDest(const LinkDest *dest)
-{
-kind = dest->kind;
-pageIsRef = dest->pageIsRef;
-if (pageIsRef)
-pageRef = dest->pageRef;
-else
-pageNum = dest->pageNum;
-left = dest->left;
-bottom = dest->bottom;
-right = dest->right;
-top = dest->top;
-zoom = dest->zoom;
-changeLeft = dest->changeLeft;
-changeTop = dest->changeTop;
-changeZoom = dest->changeZoom;
-ok = true;
-}
-
 //
 // LinkGoTo
 //
diff --git a/poppler/Link.h b/poppler/Link.h
index c058eb7f..3cd78e33 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2008 Hugo Mercier 
 // Copyright (C) 2010, 2011 Carlos Garcia Campos 
 // Copyright (C) 2012 Tobias Koening 
-// Copyright (C) 2018-2021 Albert Astals Cid 
+// Copyright (C) 2018-2022 Albert Astals Cid 
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Intevation GmbH 
 // Copyright (C) 2019, 2020 Oliver Sander 
@@ -119,9 +119,6 @@ public:
 // Build a LinkDest from the array.
 explicit LinkDest(const Array *a);
 
-// Copy a LinkDest.
-LinkDest *copy() const { return new LinkDest(this); }
-
 // Was the LinkDest created successfully?
 bool isOk() const { return ok; }
 
@@ -154,8 +151,6 @@ private:
  //   destFitH/BH use changeTop;
  //   destFitV/BV use changeLeft
 bool ok; // set if created successfully
-
-explicit LinkDest(const LinkDest *dest);
 };
 
 //
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index 7564b3e4..5d697a58 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -17,7 +17,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2005-2013, 2016-2021 Albert Astals Cid 
+// Copyright (C) 2005-2013, 2016-2022 Albert Astals Cid 
 // Copyright (C) 2008 Kjartan Maraas 
 // Copyright (C) 2008 Boris Toloknov 
 // Copyright (C) 2008 Haruyuki Kawabe 
@@ -1507,7 +1507,7 @@ GooString *HtmlOutputDev::getLinkDest(AnnotLink *link)
 LinkGoTo *ha = (LinkGoTo *)link->getAction();
 std::unique_ptr dest;
 if (ha->getDest() != nullptr)
-dest = std::unique_ptr(ha->getDest()->copy());
+dest = std::make_unique(*ha->getDest());
 else if (ha->getNamedDest() != nullptr)
 dest = catalog->findDest(ha->getNamedDest());
 
@@ -1556,7 +1556,7 @@ GooString *HtmlOutputDev::getLinkDest(AnnotLink *link)
 file = new GooString(ha->getFileName()->c_str());
 }
 if (ha->getDest() != nullptr)
-dest = ha->getDest()->copy();
+dest = new LinkDest(*ha->getDest());
 if (dest && file) {
 if (!(dest->isPageRef()))
 destPage = dest->getPageNum();
@@ -1774,7 +1774,7 @@ int HtmlOutputDev::getOutlinePageNum(OutlineItem *item)
 return pagenum;
 
 if (link->getDest())
-linkdest = std::unique_ptr(link->getDest()->copy());
+linkdest = std::make_unique(*link->getDest());
 else if (link->getNamedDest())
 linkdest = catalog->findDest(link->getNamedDest());
 


[poppler] poppler/Link.cc poppler/Link.h

2020-03-18 Thread GitLab Mirror
 poppler/Link.cc |   20 
 poppler/Link.h  |   20 +++-
 2 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 81a86064c14a7fc25047b6040d65464e732cf501
Author: Adam Reichold 
Date:   Wed Mar 18 11:39:50 2020 +0100

Fix vague linkage of Link* class vtables

Due to falling back to the implicitly inline destructors,
some of the Link* classes had all their overridden methods
defined inline with made the linkage of their vtables vague.

This change moves their destructors into a defined translation
unit thereby anchoring their vtables in the libpoppler DSO which
fixes issues using dynamic_cast when builing Poppler using Clang.

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 790c41ab..cc3ebf2a 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -444,6 +444,8 @@ LinkGoTo::LinkGoTo(const Object *destObj) {
   }
 }
 
+LinkGoTo::~LinkGoTo() = default;
+
 //
 // LinkGoToR
 //
@@ -474,6 +476,8 @@ LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) {
   }
 }
 
+LinkGoToR::~LinkGoToR() = default;
+
 //
 // LinkLaunch
 //
@@ -552,6 +556,8 @@ LinkURI::LinkURI(const Object *uriObj, const GooString 
*baseURI) {
   }
 }
 
+LinkURI::~LinkURI() = default;
+
 //
 // LinkNamed
 //
@@ -564,6 +570,8 @@ LinkNamed::LinkNamed(const Object *nameObj) {
   }
 }
 
+LinkNamed::~LinkNamed() = default;
+
 //
 // LinkMovie
 //
@@ -607,6 +615,8 @@ LinkMovie::LinkMovie(const Object *obj) {
   }
 }
 
+LinkMovie::~LinkMovie() = default;
+
 //
 // LinkSound
 //
@@ -645,6 +655,8 @@ LinkSound::LinkSound(const Object *soundObj) {
   }
 }
 
+LinkSound::~LinkSound() = default;
+
 //
 // LinkRendition
 //
@@ -738,6 +750,8 @@ LinkJavaScript::LinkJavaScript(Object *jsObj) {
   }
 }
 
+LinkJavaScript::~LinkJavaScript() = default;
+
 Object LinkJavaScript::createObject(XRef *xref, const GooString )
 {
   Dict *linkDict = new Dict(xref);
@@ -793,6 +807,8 @@ LinkOCGState::LinkOCGState(const Object *obj)
   preserveRB = obj->dictLookup("PreserveRB").getBoolWithDefaultValue(true);
 }
 
+LinkOCGState::~LinkOCGState() = default;
+
 //
 // LinkHide
 //
@@ -814,6 +830,8 @@ LinkHide::LinkHide(const Object *hideObj) {
   }
 }
 
+LinkHide::~LinkHide() = default;
+
 //
 // LinkUnknown
 //
@@ -822,6 +840,8 @@ LinkUnknown::LinkUnknown(const char *actionA) {
   action = std::string(actionA ? actionA : "");
 }
 
+LinkUnknown::~LinkUnknown() = default;
+
 //
 // Links
 //
diff --git a/poppler/Link.h b/poppler/Link.h
index 3aa5e0a8..57c169ea 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -164,6 +164,8 @@ public:
   // Build a LinkGoTo from a destination (dictionary, name, or string).
   LinkGoTo(const Object *destObj);
 
+  ~LinkGoTo() override;
+
   // Was the LinkGoTo created successfully?
   bool isOk() const override { return dest || namedDest; }
 
@@ -191,6 +193,8 @@ public:
   // (dictionary, name, or string).
   LinkGoToR(Object *fileSpecObj, Object *destObj);
 
+  ~LinkGoToR() override;
+
   // Was the LinkGoToR created successfully?
   bool isOk() const override { return fileName && (dest || namedDest); }
 
@@ -243,6 +247,8 @@ public:
   // Build a LinkURI given the URI (string) and base URI.
   LinkURI(const Object *uriObj, const GooString *baseURI);
 
+  ~LinkURI() override;
+
   // Was the LinkURI created successfully?
   bool isOk() const override { return hasURIFlag; }
 
@@ -266,6 +272,8 @@ public:
   // Build a LinkNamed given the action name.
   LinkNamed(const Object *nameObj);
 
+  ~LinkNamed() override;
+
   bool isOk() const override { return hasNameFlag; }
 
   LinkActionKind getKind() const override { return actionNamed; }
@@ -294,6 +302,8 @@ public:
 
   LinkMovie(const 

[poppler] poppler/Link.cc poppler/Link.h

2020-02-29 Thread GitLab Mirror
 poppler/Link.cc |   60 +++-
 poppler/Link.h  |   37 +-
 2 files changed, 26 insertions(+), 71 deletions(-)

New commits:
commit b3cfbbf2679618d0c32670090717a6e2f70faf9c
Author: Oliver Sander 
Date:   Tue Feb 11 22:34:10 2020 +0100

Use std::unique_ptr for LinkGoto data members

This makes it clear that these pointers are owning.
It makes the code slightly shorter, too.

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 0bf57b3e..c9945ce8 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -425,21 +425,17 @@ LinkDest::LinkDest(const LinkDest *dest) {
 //
 
 LinkGoTo::LinkGoTo(const Object *destObj) {
-  dest = nullptr;
-  namedDest = nullptr;
-
   // named destination
   if (destObj->isName()) {
-namedDest = new GooString(destObj->getName());
+namedDest = std::make_unique(destObj->getName());
   } else if (destObj->isString()) {
-namedDest = destObj->getString()->copy();
+namedDest = std::unique_ptr(destObj->getString()->copy());
 
   // destination dictionary
   } else if (destObj->isArray()) {
-dest = new LinkDest(destObj->getArray());
+dest = std::make_unique(destObj->getArray());
 if (!dest->isOk()) {
-  delete dest;
-  dest = nullptr;
+  dest.reset();
 }
 
   // error
@@ -448,40 +444,28 @@ LinkGoTo::LinkGoTo(const Object *destObj) {
   }
 }
 
-LinkGoTo::~LinkGoTo() {
-  if (dest)
-delete dest;
-  if (namedDest)
-delete namedDest;
-}
-
 //
 // LinkGoToR
 //
 
 LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) {
-  fileName = nullptr;
-  dest = nullptr;
-  namedDest = nullptr;
-
   // get file name
   Object obj1 = getFileSpecNameForPlatform (fileSpecObj);
   if (obj1.isString()) {
-fileName = obj1.getString()->copy();
+fileName = std::unique_ptr(obj1.getString()->copy());
   }
 
   // named destination
   if (destObj->isName()) {
-namedDest = new GooString(destObj->getName());
+namedDest = std::make_unique(destObj->getName());
   } else if (destObj->isString()) {
-namedDest = destObj->getString()->copy();
+namedDest = std::unique_ptr(destObj->getString()->copy());
 
   // destination dictionary
   } else if (destObj->isArray()) {
-dest = new LinkDest(destObj->getArray());
+dest = std::make_unique(destObj->getArray());
 if (!dest->isOk()) {
-  delete dest;
-  dest = nullptr;
+  dest.reset();
 }
 
   // error
@@ -490,31 +474,18 @@ LinkGoToR::LinkGoToR(Object *fileSpecObj, Object 
*destObj) {
   }
 }
 
-LinkGoToR::~LinkGoToR() {
-  if (fileName)
-delete fileName;
-  if (dest)
-delete dest;
-  if (namedDest)
-delete namedDest;
-}
-
-
 //
 // LinkLaunch
 //
 
 LinkLaunch::LinkLaunch(const Object *actionObj) {
 
-  fileName = nullptr;
-  params = nullptr;
-
   if (actionObj->isDict()) {
 Object obj1 = actionObj->dictLookup("F");
 if (!obj1.isNull()) {
   Object obj3 = getFileSpecNameForPlatform ();
   if (obj3.isString()) {
-   fileName = obj3.getString()->copy();
+   fileName = std::unique_ptr(obj3.getString()->copy());
   }
 } else {
 #ifdef _WIN32
@@ -528,11 +499,11 @@ LinkLaunch::LinkLaunch(const Object *actionObj) {
Object obj2 = obj1.dictLookup("F");
Object obj3 = getFileSpecNameForPlatform ();
if (obj3.isString()) {
- fileName = obj3.getString()->copy();
+ fileName = std::unique_ptr(obj3.getString()->copy());
}
obj2 = obj1.dictLookup("P");
if (obj2.isString()) {
- params = obj2.getString()->copy();
+ params = std::unique_ptr(obj2.getString()->copy());
}
   } else {
error(errSyntaxWarning, -1, "Bad launch-type link action");
@@ -541,13 +512,6 @@ LinkLaunch::LinkLaunch(const Object *actionObj) {
   }
 }
 
-LinkLaunch::~LinkLaunch() {
-  if (fileName)
-delete fileName;
-  if (params)
-delete params;
-}
-
 //
 // LinkURI
 //
diff --git a/poppler/Link.h b/poppler/Link.h
index b996f560..3aa5e0a8 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -164,22 +164,19 @@ public:
   // Build a LinkGoTo from a destination (dictionary, name, or string).
   LinkGoTo(const Object *destObj);
 
-  // Destructor.
-  ~LinkGoTo() override;
-
   // Was the LinkGoTo created successfully?
   bool isOk() const override { return dest || namedDest; }
 
   // Accessors.
   LinkActionKind getKind() const override { return actionGoTo; }
-  const LinkDest *getDest() const { 

[poppler] poppler/Link.cc poppler/Link.h qt5/src

2020-01-04 Thread GitLab Mirror
 poppler/Link.cc|2 +-
 poppler/Link.h |1 +
 qt5/src/poppler-link-private.h |1 +
 qt5/src/poppler-link.h |1 +
 qt5/src/poppler-optcontent.cc  |2 +-
 5 files changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 04debcf2a044d358aa8cd3694739db7d5471da0e
Author: Albert Astals Cid 
Date:   Sat Jan 4 11:37:01 2020 +0100

Update (C) of previous commits

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 888a0f1b..c9af4033 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -22,7 +22,7 @@
 // Copyright (C) 2012 Tobias Koening 
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Intevation GmbH 
-// Copyright (C) 2018 Adam Reichold 
+// Copyright (C) 2018, 2020 Adam Reichold 
 // Copyright (C) 2019, 2020 Oliver Sander 
 //
 // To see a description of the changes please see the Changelog file that
diff --git a/poppler/Link.h b/poppler/Link.h
index 22f43d9f..4d10f2dd 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -21,6 +21,7 @@
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Intevation GmbH 
 // Copyright (C) 2019, 2020 Oliver Sander 
+// Copyright (C) 2020 Adam Reichold 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/qt5/src/poppler-link-private.h b/qt5/src/poppler-link-private.h
index ed12f70b..58139377 100644
--- a/qt5/src/poppler-link-private.h
+++ b/qt5/src/poppler-link-private.h
@@ -1,6 +1,7 @@
 /* poppler-link-private.h: qt interface to poppler
  * Copyright (C) 2016, 2018, Albert Astals Cid 
  * Copyright (C) 2018 Intevation GmbH 
+ * Copyright (C) 2020 Oliver Sander 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/qt5/src/poppler-link.h b/qt5/src/poppler-link.h
index 24dd24c4..393d09b8 100644
--- a/qt5/src/poppler-link.h
+++ b/qt5/src/poppler-link.h
@@ -5,6 +5,7 @@
  * Copyright (C) 2012, Tobias Koenig 
  * Copyright (C) 2013, Anthony Granger 
  * Copyright (C) 2018 Intevation GmbH 
+ * Copyright (C) 2020 Oliver Sander 
  * Adapting code from
  *   Copyright (C) 2004 by Enrico Ros 
  *
diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc
index 5b71be80..7abac60f 100644
--- a/qt5/src/poppler-optcontent.cc
+++ b/qt5/src/poppler-optcontent.cc
@@ -7,7 +7,7 @@
  * Copyright (C) 2017, Hubert Figuière 
  * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
  * Copyright (C) 2018 Adam Reichold 
- * Copyright (C) 2019 Oliver Sander 
+ * Copyright (C) 2019, 2020 Oliver Sander 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Link.cc poppler/Link.h

2020-01-04 Thread GitLab Mirror
 poppler/Link.cc |6 +-
 poppler/Link.h  |3 ---
 2 files changed, 1 insertion(+), 8 deletions(-)

New commits:
commit 21a7a98ad926b2e0aa3646d0c07ff13df8777f8b
Author: Adam Reichold 
Date:   Sat Jan 4 09:31:03 2020 +0100

Remove LinkAction::setNextActions as this setter should not be used outside 
of the ::parseAction method.

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 74904acd..888a0f1b 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -199,7 +199,7 @@ LinkAction *LinkAction::parseAction(const Object *obj, 
const GooString *baseURI,
 }
   }
 
-  action->setNextActions(std::move(actionList));
+  action->nextActionList = std::move(actionList);
 
   return action;
 }
@@ -208,10 +208,6 @@ const std::vector& LinkAction::nextActions() 
const {
   return nextActionList;
 }
 
-void LinkAction::setNextActions(std::vector&& actions) {
-  nextActionList = std::move(actions);
-}
-
 //
 // LinkDest
 //
diff --git a/poppler/Link.h b/poppler/Link.h
index b6fb9fb4..22f43d9f 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -87,9 +87,6 @@ public:
   // The list contains pointer to LinkAction objects.
   const std::vector& nextActions() const;
 
-  // Sets the next action list.
-  void setNextActions(std::vector&& actions);
-
 private:
   static LinkAction *parseAction(const Object *obj, const GooString *baseURI, 
std::set *seenNextActions);
 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Link.cc poppler/Link.h

2019-11-29 Thread GitLab Mirror
 poppler/Link.cc |   17 -
 poppler/Link.h  |7 ---
 2 files changed, 24 deletions(-)

New commits:
commit 6e60cd8ef9696c12e4f33eb671013315b2b07790
Author: Albert Astals Cid 
Date:   Sat Nov 30 02:04:22 2019 +0100

Links: Remove two unused functions

Note: If you're one of the people using the internal API against our
wishes, you can still roll out these functions yourself

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 4db8fe3d..35ddfb92 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -969,20 +969,3 @@ Links::~Links() {
   for (AnnotLink *link : links)
 link->decRefCnt();
 }
-
-LinkAction *Links::find(double x, double y) const {
-  for (int i = getNumLinks() - 1; i >= 0; --i) {
-if (links[i]->inRect(x, y)) {
-  return links[i]->getAction();
-}
-  }
-  return nullptr;
-}
-
-bool Links::onLink(double x, double y) const {
-  for (AnnotLink *link : links) {
-if (link->inRect(x, y))
-  return true;
-  }
-  return false;
-}
diff --git a/poppler/Link.h b/poppler/Link.h
index 59c1ae0b..59ecd4e4 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -543,13 +543,6 @@ public:
   int getNumLinks() const { return links.size(); }
   AnnotLink *getLink(int i) const { return links[i]; }
 
-  // If point , is in a link, return the associated action;
-  // else return nullptr.
-  LinkAction *find(double x, double y) const;
-
-  // Return true if , is in a link.
-  bool onLink(double x, double y) const;
-
 private:
 
   std::vector links;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] poppler/Link.cc poppler/Link.h

2019-11-29 Thread GitLab Mirror
 poppler/Link.cc |   33 +++--
 poppler/Link.h  |5 ++---
 2 files changed, 9 insertions(+), 29 deletions(-)

New commits:
commit 82dc60155a015e5798db6f78a5f165dc7dd376c9
Author: Albert Astals Cid 
Date:   Fri Nov 29 14:54:27 2019 +0100

Turn Links::links into a std::vector instead of **

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 64dc7041..4db8fe3d 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -951,44 +951,27 @@ LinkUnknown::~LinkUnknown() {
 //
 
 Links::Links(Annots *annots) {
-  int size;
-  int i;
-
-  links = nullptr;
-  size = 0;
-  numLinks = 0;
-
   if (!annots)
 return;
 
-  for (i = 0; i < annots->getNumAnnots(); ++i) {
+  for (int i = 0; i < annots->getNumAnnots(); ++i) {
 Annot *annot = annots->getAnnot(i);
 
 if (annot->getType() != Annot::typeLink)
   continue;
 
-if (numLinks >= size) {
-  size += 16;
-  links = (AnnotLink **)greallocn(links, size, sizeof(AnnotLink *));
-}
 annot->incRefCnt();
-links[numLinks++] = static_cast(annot);
+links.push_back(static_cast(annot));
   }
 }
 
 Links::~Links() {
-  int i;
-
-  for (i = 0; i < numLinks; ++i)
-links[i]->decRefCnt();
-
-  gfree(links);
+  for (AnnotLink *link : links)
+link->decRefCnt();
 }
 
 LinkAction *Links::find(double x, double y) const {
-  int i;
-
-  for (i = numLinks - 1; i >= 0; --i) {
+  for (int i = getNumLinks() - 1; i >= 0; --i) {
 if (links[i]->inRect(x, y)) {
   return links[i]->getAction();
 }
@@ -997,10 +980,8 @@ LinkAction *Links::find(double x, double y) const {
 }
 
 bool Links::onLink(double x, double y) const {
-  int i;
-
-  for (i = 0; i < numLinks; ++i) {
-if (links[i]->inRect(x, y))
+  for (AnnotLink *link : links) {
+if (link->inRect(x, y))
   return true;
   }
   return false;
diff --git a/poppler/Link.h b/poppler/Link.h
index d610fad0..59c1ae0b 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -540,7 +540,7 @@ public:
   Links& operator=(const Links &) = delete;
 
   // Iterate through list of links.
-  int getNumLinks() const { return numLinks; }
+  int getNumLinks() const { return links.size(); }
   AnnotLink *getLink(int i) const { return links[i]; }
 
   // If point , is in a link, return the associated action;
@@ -552,8 +552,7 @@ public:
 
 private:
 
-  AnnotLink **links;
-  int numLinks;
+  std::vector links;
 };
 
 #endif
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] poppler/Link.cc poppler/Link.h

2018-04-16 Thread Albert Astals Cid
 poppler/Link.cc |   22 +++---
 poppler/Link.h  |5 +++--
 2 files changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 444d9d8de5d4f8d627084405e1583b6d6d3900c7
Author: Albert Astals Cid 
Date:   Mon Apr 16 22:28:18 2018 +0200

Simplify LinkAction::parseAction a bit

After the discussion on the mailing list, also using unique_ptr was
wrong

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 42bdaf1b..9ebf33ef 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -70,8 +70,14 @@ LinkAction *LinkAction::parseDest(const Object *obj) {
   return action;
 }
 
+LinkAction *LinkAction::parseAction(const Object *obj, const GooString 
*baseURI)
+{
+std::set seenNextActions;
+return parseAction(obj, baseURI, );
+}
+
 LinkAction *LinkAction::parseAction(const Object *obj, const GooString 
*baseURI,
-std::unique_ptr 
seenNextActions) {
+std::set *seenNextActions) {
   LinkAction *action;
 
   if (!obj->isDict()) {
@@ -160,19 +166,16 @@ LinkAction *LinkAction::parseAction(const Object *obj, 
const GooString *baseURI,
 // Prevent circles in the tree by checking the ref against used refs in
 // our current tree branch.
 const Object nextRefObj = obj->dictLookupNF("Next");
-if (!seenNextActions)
-seenNextActions.reset(new std::set);
 if (nextRefObj.isRef()) {
 const Ref ref = nextRefObj.getRef();
-if (seenNextActions->find(ref.num) != seenNextActions->end()) {
+if (!seenNextActions->insert(ref.num).second) {
 error(errSyntaxWarning, -1, "parseAction: Circular next actions 
detected.");
 return action;
 }
-seenNextActions->insert(ref.num);
 }
 
 actionList = new GooList(1);
-actionList->append(parseAction(, nullptr, 
std::move(seenNextActions)));
+actionList->append(parseAction(, nullptr, seenNextActions));
   } else if (nextObj.isArray()) {
 const Array *a = nextObj.getArray();
 const int n = a->getLength();
@@ -185,19 +188,16 @@ LinkAction *LinkAction::parseAction(const Object *obj, 
const GooString *baseURI,
   }
 
   // Similar circle check as above.
-  if (!seenNextActions)
-seenNextActions.reset(new std::set);
   const Object obj3Ref = a->getNF(i);
   if (obj3Ref.isRef()) {
   const Ref ref = obj3Ref.getRef();
-  if (seenNextActions->find(ref.num) != seenNextActions->end()) {
+  if (!seenNextActions->insert(ref.num).second) {
   error(errSyntaxWarning, -1, "parseAction: Circular next actions 
detected in array.");
   return action;
   }
-  seenNextActions->insert(ref.num);
   }
 
-  actionList->append(parseAction(, nullptr, 
std::move(seenNextActions)));
+  actionList->append(parseAction(, nullptr, seenNextActions));
 }
   }
 
diff --git a/poppler/Link.h b/poppler/Link.h
index 77d224d9..4388523c 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -85,8 +85,9 @@ public:
   static LinkAction *parseDest(const Object *obj);
 
   // Parse an action dictionary.
-  static LinkAction *parseAction(const Object *obj, const GooString *baseURI = 
nullptr,
- std::unique_ptr 
seenNextActions = nullptr);
+  static LinkAction *parseAction(const Object *obj, const GooString *baseURI = 
nullptr);
+  static LinkAction *parseAction(const Object *obj, const GooString *baseURI,
+ std::set *seenNextActions);
 
   // A List of the next actions to execute in order.
   // The list contains pointer to LinkAction objects.
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler