Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Unified Diff: core/src/fpdfdoc/doc_link.cpp

Issue 958423005: Handle overlapping links and widgets. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_form.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfdoc/doc_link.cpp
diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp
index 964b84e549e4992bf5852289a4d76cfe0d4d2def..0fe3c69124c7c2fc405efa74dbd9af158796f0cb 100644
--- a/core/src/fpdfdoc/doc_link.cpp
+++ b/core/src/fpdfdoc/doc_link.cpp
@@ -7,6 +7,9 @@
#include "../../include/fpdfdoc/fpdf_doc.h"
#include "../../src/fxcrt/fx_safe_types.h"
+CPDF_LinkList::CPDF_LinkList()
+{
+}
CPDF_LinkList::~CPDF_LinkList()
{
FX_POSITION pos = m_PageMap.GetStartPosition();
@@ -33,21 +36,17 @@ CFX_PtrArray* CPDF_LinkList::GetPageLinks(CPDF_Page* pPage)
}
return pPageLinkList;
}
-int CPDF_LinkList::CountLinks(CPDF_Page* pPage)
+FX_BOOL CPDF_LinkList::IsLink(CPDF_Dictionary* pAnnot)
{
- CFX_PtrArray* pPageLinkList = GetPageLinks(pPage);
- if (pPageLinkList == NULL) {
- return 0;
- }
- return pPageLinkList->GetSize();
+ return pAnnot->GetString("Subtype") == "Link";
}
-CPDF_Link CPDF_LinkList::GetLink(CPDF_Page* pPage, int index)
+FX_BOOL CPDF_LinkList::IsWidget(CPDF_Dictionary* pAnnot)
{
- CFX_PtrArray* pPageLinkList = GetPageLinks(pPage);
- if (pPageLinkList == NULL) {
- return NULL;
- }
- return (CPDF_Dictionary*)pPageLinkList->GetAt(index);
+ return pAnnot->GetString("Subtype") == "Widget";
+}
+CPDF_Rect CPDF_LinkList::GetWidgetRect(CPDF_Dictionary* pWidget)
+{
+ return pWidget->GetRect("Rect");
}
CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y)
{
@@ -57,10 +56,18 @@ CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLO
}
int size = pPageLinkList->GetSize();
for (int i = size - 1; i >= 0; --i) {
- CPDF_Link Link = (CPDF_Dictionary*)pPageLinkList->GetAt(i);
- CPDF_Rect rect = Link.GetRect();
- if (rect.Contains(pdf_x, pdf_y)) {
- return Link;
+ CPDF_Dictionary* pAnnot = (CPDF_Dictionary*)pPageLinkList->GetAt(i);
+ if (IsLink(pAnnot)) {
+ CPDF_Link link(pAnnot);
+ CPDF_Rect rect = link.GetRect();
+ if (rect.Contains(pdf_x, pdf_y)) {
+ return link;
+ }
+ } else if (IsWidget(pAnnot)) {
+ CPDF_Rect rect = GetWidgetRect(pAnnot);
+ if (rect.Contains(pdf_x, pdf_y)) {
+ return NULL;
+ }
}
}
return NULL;
@@ -76,10 +83,9 @@ void CPDF_LinkList::LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList)
if (pAnnot == NULL) {
continue;
}
- if (pAnnot->GetString("Subtype") != "Link") {
- continue;
+ if (IsLink(pAnnot) || IsWidget(pAnnot)) {
+ pList->Add(pAnnot);
}
- pList->Add(pAnnot);
}
}
CPDF_Rect CPDF_Link::GetRect()
« no previous file with comments | « core/src/fpdfdoc/doc_form.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698