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 | 9 |
10 namespace { | 10 namespace { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return 0; | 194 return 0; |
195 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 195 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
196 if (!pDoc) | 196 if (!pDoc) |
197 return 0; | 197 return 0; |
198 CPDF_Dest dest((CPDF_Array*)pDict); | 198 CPDF_Dest dest((CPDF_Array*)pDict); |
199 return dest.GetPageIndex(pDoc); | 199 return dest.GetPageIndex(pDoc); |
200 } | 200 } |
201 | 201 |
202 DLLEXPORT FPDF_LINK STDCALL | 202 DLLEXPORT FPDF_LINK STDCALL |
203 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { | 203 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { |
204 CPDF_Page* pPage = (CPDF_Page*)page; | 204 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 205 if (!pPage) |
| 206 return nullptr; |
| 207 |
205 CPDF_LinkList* pLinkList = GetLinkList(pPage); | 208 CPDF_LinkList* pLinkList = GetLinkList(pPage); |
206 if (!pLinkList) | 209 if (!pLinkList) |
207 return nullptr; | 210 return nullptr; |
208 | 211 |
209 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr) | 212 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr) |
210 .GetDict(); | 213 .GetDict(); |
211 } | 214 } |
212 | 215 |
213 DLLEXPORT int STDCALL | 216 DLLEXPORT int STDCALL |
214 FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) { | 217 FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) { |
215 CPDF_Page* pPage = (CPDF_Page*)page; | 218 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 219 if (!pPage) |
| 220 return -1; |
| 221 |
216 CPDF_LinkList* pLinkList = GetLinkList(pPage); | 222 CPDF_LinkList* pLinkList = GetLinkList(pPage); |
217 if (!pLinkList) | 223 if (!pLinkList) |
218 return -1; | 224 return -1; |
219 | 225 |
220 int z_order = -1; | 226 int z_order = -1; |
221 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); | 227 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); |
222 return z_order; | 228 return z_order; |
223 } | 229 } |
224 | 230 |
225 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, | 231 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, |
(...skipping 18 matching lines...) Expand all Loading... |
244 if (!pDict) | 250 if (!pDict) |
245 return nullptr; | 251 return nullptr; |
246 | 252 |
247 CPDF_Link link((CPDF_Dictionary*)pDict); | 253 CPDF_Link link((CPDF_Dictionary*)pDict); |
248 return link.GetAction().GetDict(); | 254 return link.GetAction().GetDict(); |
249 } | 255 } |
250 | 256 |
251 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, | 257 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, |
252 int* startPos, | 258 int* startPos, |
253 FPDF_LINK* linkAnnot) { | 259 FPDF_LINK* linkAnnot) { |
254 if (!page || !startPos || !linkAnnot) | 260 if (!startPos || !linkAnnot) |
255 return FALSE; | 261 return FALSE; |
256 CPDF_Page* pPage = (CPDF_Page*)page; | 262 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
257 if (!pPage->m_pFormDict) | 263 if (!pPage || !pPage->m_pFormDict) |
258 return FALSE; | 264 return FALSE; |
259 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); | 265 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); |
260 if (!pAnnots) | 266 if (!pAnnots) |
261 return FALSE; | 267 return FALSE; |
262 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { | 268 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { |
263 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); | 269 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); |
264 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) | 270 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) |
265 continue; | 271 continue; |
266 if (pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) { | 272 if (pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) { |
267 *startPos = i + 1; | 273 *startPos = i + 1; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 return 0; | 339 return 0; |
334 CFX_WideString text = pInfo->GetUnicodeText(tag); | 340 CFX_WideString text = pInfo->GetUnicodeText(tag); |
335 // Use UTF-16LE encoding | 341 // Use UTF-16LE encoding |
336 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 342 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
337 unsigned long len = encodedText.GetLength(); | 343 unsigned long len = encodedText.GetLength(); |
338 if (buffer && buflen >= len) { | 344 if (buffer && buflen >= len) { |
339 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 345 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
340 } | 346 } |
341 return len; | 347 return len; |
342 } | 348 } |
OLD | NEW |