[poppler] glib/poppler-page.cc poppler/Link.h poppler/Page.cc utils/HtmlOutputDev.cc utils/pdfinfo.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 1 14:28:43 UTC 2022
glib/poppler-page.cc | 5 +----
poppler/Link.h | 4 +---
poppler/Page.cc | 4 ++--
utils/HtmlOutputDev.cc | 4 ++--
utils/pdfinfo.cc | 3 +--
5 files changed, 7 insertions(+), 13 deletions(-)
New commits:
commit af3e1e1a3577c4e1c66cbe69ebdc6a632038e299
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Apr 1 16:03:46 2022 +0200
Link: Just return the std::vector instead of two getters
Simpler code to use and solves the int vs size_t mismatch by not having a
type involved at all
diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index d0755024..3fcd4b70 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1119,7 +1119,6 @@ static void poppler_page_init(PopplerPage *page) { }
GList *poppler_page_get_link_mapping(PopplerPage *page)
{
GList *map_list = nullptr;
- gint i;
Links *links;
double width, height;
@@ -1133,13 +1132,11 @@ GList *poppler_page_get_link_mapping(PopplerPage *page)
poppler_page_get_size(page, &width, &height);
- for (i = 0; i < links->getNumLinks(); i++) {
+ for (AnnotLink *link : links->getLinks()) {
PopplerLinkMapping *mapping;
PopplerRectangle rect;
LinkAction *link_action;
- AnnotLink *link;
- link = links->getLink(i);
link_action = link->getAction();
/* Create the mapping */
diff --git a/poppler/Link.h b/poppler/Link.h
index 0c4677ca..204207ba 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -555,9 +555,7 @@ public:
Links(const Links &) = delete;
Links &operator=(const Links &) = delete;
- // Iterate through list of links.
- int getNumLinks() const { return links.size(); }
- AnnotLink *getLink(int i) const { return links[i]; }
+ const std::vector<AnnotLink *> &getLinks() const { return links; }
private:
std::vector<AnnotLink *> links;
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 727dd283..aa23c3e1 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -787,8 +787,8 @@ void Page::makeBox(double hDPI, double vDPI, int rotate, bool useMediaBox, bool
void Page::processLinks(OutputDev *out)
{
std::unique_ptr<Links> links = getLinks();
- for (int i = 0; i < links->getNumLinks(); ++i) {
- out->processLink(links->getLink(i));
+ for (AnnotLink *link : links->getLinks()) {
+ out->processLink(link);
}
}
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index 8a16e008..606d911a 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -1249,8 +1249,8 @@ void HtmlOutputDev::startPage(int pageNumA, GfxState *state, XRef *xref)
void HtmlOutputDev::endPage()
{
std::unique_ptr<Links> linksList = docPage->getLinks();
- for (int i = 0; i < linksList->getNumLinks(); ++i) {
- doProcessLink(linksList->getLink(i));
+ for (AnnotLink *link : linksList->getLinks()) {
+ doProcessLink(link);
}
pages->conv();
diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc
index 7a7fc782..1f4ca791 100644
--- a/utils/pdfinfo.cc
+++ b/utils/pdfinfo.cc
@@ -422,8 +422,7 @@ static void printUrlList(PDFDoc *doc)
Page *page = doc->getPage(pg);
if (page) {
std::unique_ptr<Links> links = page->getLinks();
- for (int i = 0; i < links->getNumLinks(); i++) {
- AnnotLink *annot = links->getLink(i);
+ for (AnnotLink *annot : links->getLinks()) {
LinkAction *action = annot->getAction();
if (action->getKind() == actionURI) {
LinkURI *linkUri = dynamic_cast<LinkURI *>(action);
More information about the poppler
mailing list