| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../public/fpdf_doc.h" | 7 #include "../../public/fpdf_doc.h" |
| 8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_page.h" | 10 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return 0; | 196 return 0; |
| 197 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 197 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 198 if (!pDoc) | 198 if (!pDoc) |
| 199 return 0; | 199 return 0; |
| 200 CPDF_Dest dest((CPDF_Array*)pDict); | 200 CPDF_Dest dest((CPDF_Array*)pDict); |
| 201 return dest.GetPageIndex(pDoc); | 201 return dest.GetPageIndex(pDoc); |
| 202 } | 202 } |
| 203 | 203 |
| 204 DLLEXPORT FPDF_LINK STDCALL | 204 DLLEXPORT FPDF_LINK STDCALL |
| 205 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { | 205 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { |
| 206 CPDFXFA_Page* pXFAPage = (CPDFXFA_Page*)page; | 206 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 207 CPDF_Page* pPage = pXFAPage->GetPDFPage(); | |
| 208 if (!pPage) | 207 if (!pPage) |
| 209 return nullptr; | 208 return nullptr; |
| 210 | 209 |
| 211 CPDF_LinkList* pLinkList = GetLinkList(pPage); | 210 CPDF_LinkList* pLinkList = GetLinkList(pPage); |
| 212 if (!pLinkList) | 211 if (!pLinkList) |
| 213 return nullptr; | 212 return nullptr; |
| 214 | 213 |
| 215 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr) | 214 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr) |
| 216 .GetDict(); | 215 .GetDict(); |
| 217 } | 216 } |
| 218 | 217 |
| 219 DLLEXPORT int STDCALL | 218 DLLEXPORT int STDCALL |
| 220 FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) { | 219 FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) { |
| 221 CPDFXFA_Page* pXFAPage = (CPDFXFA_Page*)page; | 220 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 222 CPDF_Page* pPage = pXFAPage->GetPDFPage(); | |
| 223 if (!pPage) | 221 if (!pPage) |
| 224 return -1; | 222 return -1; |
| 225 | 223 |
| 226 CPDF_LinkList* pLinkList = GetLinkList(pPage); | 224 CPDF_LinkList* pLinkList = GetLinkList(pPage); |
| 227 if (!pLinkList) | 225 if (!pLinkList) |
| 228 return -1; | 226 return -1; |
| 229 | 227 |
| 230 int z_order = -1; | 228 int z_order = -1; |
| 231 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); | 229 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); |
| 232 return z_order; | 230 return z_order; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 254 if (!pDict) | 252 if (!pDict) |
| 255 return nullptr; | 253 return nullptr; |
| 256 | 254 |
| 257 CPDF_Link link((CPDF_Dictionary*)pDict); | 255 CPDF_Link link((CPDF_Dictionary*)pDict); |
| 258 return link.GetAction().GetDict(); | 256 return link.GetAction().GetDict(); |
| 259 } | 257 } |
| 260 | 258 |
| 261 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, | 259 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, |
| 262 int* startPos, | 260 int* startPos, |
| 263 FPDF_LINK* linkAnnot) { | 261 FPDF_LINK* linkAnnot) { |
| 264 if (!page || !startPos || !linkAnnot) | 262 if (!startPos || !linkAnnot) |
| 265 return FALSE; | 263 return FALSE; |
| 266 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | 264 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 267 if (!pPage->m_pFormDict) | 265 if (!pPage || !pPage->m_pFormDict) |
| 268 return FALSE; | 266 return FALSE; |
| 269 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); | 267 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); |
| 270 if (!pAnnots) | 268 if (!pAnnots) |
| 271 return FALSE; | 269 return FALSE; |
| 272 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { | 270 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { |
| 273 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); | 271 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); |
| 274 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) | 272 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) |
| 275 continue; | 273 continue; |
| 276 if (pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) { | 274 if (pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) { |
| 277 *startPos = i + 1; | 275 *startPos = i + 1; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 return 0; | 341 return 0; |
| 344 CFX_WideString text = pInfo->GetUnicodeText(tag); | 342 CFX_WideString text = pInfo->GetUnicodeText(tag); |
| 345 // Use UTF-16LE encoding | 343 // Use UTF-16LE encoding |
| 346 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 344 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
| 347 unsigned long len = encodedText.GetLength(); | 345 unsigned long len = encodedText.GetLength(); |
| 348 if (buffer && buflen >= len) { | 346 if (buffer && buflen >= len) { |
| 349 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 347 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
| 350 } | 348 } |
| 351 return len; | 349 return len; |
| 352 } | 350 } |
| OLD | NEW |