summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfdoc.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-08-14 19:24:08 -0700
committerLei Zhang <thestig@chromium.org>2015-08-14 19:24:08 -0700
commitbdf72c353af5b8a34ef5efdeddfff36d2089a158 (patch)
tree34258c3019152b41bbfd8f3332683dbc25c0c9da /fpdfsdk/src/fpdfdoc.cpp
parent88f0bafb4163d297b51055124d4d35b769905216 (diff)
downloadpdfium-bdf72c353af5b8a34ef5efdeddfff36d2089a158.tar.xz
Merge to XFA: Add new public APIs to find the z-order for links and widgets.
- Implement FPDFLink_GetLinkZOrderAtPoint(). - Implement FPDFPage_FormFieldZOrderAtPoint(). - Mark FPDPage_HasFormFieldAtPoint() as deprecated. - Modify CPDF_LinkList and CPDF_InterForm to support new APIs. - Clean up dead code in CPDF_LinkList and CPDF_InterForm. BUG=chromium:515837 R=jun_fang@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/1278053004 . (cherry picked from commit 24fbf134d43a7ec4226de3db601f0a617bbe428b) Review URL: https://codereview.chromium.org/1295893005 .
Diffstat (limited to 'fpdfsdk/src/fpdfdoc.cpp')
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp73
1 files changed, 52 insertions, 21 deletions
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index 0006094f1a..47225dd2b1 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -9,11 +9,13 @@
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
-static int THISMODULE = 0;
+namespace {
-static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
- CPDF_Bookmark bookmark,
- const CFX_WideString& title) {
+int THISMODULE = 0;
+
+CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
+ CPDF_Bookmark bookmark,
+ const CFX_WideString& title) {
if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
// First check this item
return bookmark;
@@ -30,6 +32,26 @@ static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
return CPDF_Bookmark();
}
+void ReleaseLinkList(void* data) {
+ delete (CPDF_LinkList*)data;
+}
+
+CPDF_LinkList* GetLinkList(CPDF_Page* page) {
+ if (!page)
+ return nullptr;
+
+ // Link list is stored with the document
+ CPDF_Document* pDoc = page->m_pDocument;
+ CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
+ if (!pLinkList) {
+ pLinkList = new CPDF_LinkList;
+ pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
+ }
+ return pLinkList;
+}
+
+} // namespace
+
DLLEXPORT FPDF_BOOKMARK STDCALL
FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
if (!document || !pDict)
@@ -163,26 +185,35 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
return dest.GetPageIndex(pDoc);
}
-static void ReleaseLinkList(void* data) {
- delete (CPDF_LinkList*)data;
+DLLEXPORT FPDF_LINK STDCALL
+FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) {
+ CPDFXFA_Page* pXFAPage = (CPDFXFA_Page*)page;
+ CPDF_Page* pPage = pXFAPage->GetPDFPage();
+ if (!pPage)
+ return nullptr;
+
+ CPDF_LinkList* pLinkList = GetLinkList(pPage);
+ if (!pLinkList)
+ return nullptr;
+
+ return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr)
+ .GetDict();
}
-DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
- double x,
- double y) {
- if (!page)
- return NULL;
- CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+DLLEXPORT int STDCALL
+FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) {
+ CPDFXFA_Page* pXFAPage = (CPDFXFA_Page*)page;
+ CPDF_Page* pPage = pXFAPage->GetPDFPage();
if (!pPage)
- return NULL;
- // Link list is stored with the document
- CPDF_Document* pDoc = pPage->m_pDocument;
- CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
- if (!pLinkList) {
- pLinkList = new CPDF_LinkList(pDoc);
- pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
- }
- return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict();
+ return -1;
+
+ CPDF_LinkList* pLinkList = GetLinkList(pPage);
+ if (!pLinkList)
+ return -1;
+
+ int z_order = -1;
+ pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order);
+ return z_order;
}
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,