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_text.h" | 7 #include "public/fpdf_text.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
10 #include "core/fpdfdoc/include/fpdf_doc.h" | 10 #include "core/fpdfdoc/include/fpdf_doc.h" |
11 #include "core/fpdftext/include/cpdf_linkextract.h" | 11 #include "core/fpdftext/include/cpdf_linkextract.h" |
12 #include "core/fpdftext/include/cpdf_textpage.h" | 12 #include "core/fpdftext/include/cpdf_textpage.h" |
13 #include "core/fpdftext/include/cpdf_textpagefind.h" | 13 #include "core/fpdftext/include/cpdf_textpagefind.h" |
14 #include "fpdfsdk/include/fsdk_define.h" | 14 #include "fpdfsdk/include/fsdk_define.h" |
15 #include "third_party/base/numerics/safe_conversions.h" | 15 #include "third_party/base/numerics/safe_conversions.h" |
| 16 #include "third_party/base/stl_util.h" |
16 | 17 |
17 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
18 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 19 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
19 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" | 20 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
20 #endif // PDF_ENABLE_XFA | 21 #endif // PDF_ENABLE_XFA |
21 | 22 |
22 #ifdef _WIN32 | 23 #ifdef _WIN32 |
23 #include <tchar.h> | 24 #include <tchar.h> |
24 #endif | 25 #endif |
25 | 26 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 FXSYS_memcpy(buffer, cbUTF16URL.GetBuffer(buf_size), buf_size); | 309 FXSYS_memcpy(buffer, cbUTF16URL.GetBuffer(buf_size), buf_size); |
309 } | 310 } |
310 return size; | 311 return size; |
311 } | 312 } |
312 | 313 |
313 DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, | 314 DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, |
314 int link_index) { | 315 int link_index) { |
315 if (!link_page || link_index < 0) | 316 if (!link_page || link_index < 0) |
316 return 0; | 317 return 0; |
317 | 318 |
318 CFX_RectArray rects; | |
319 CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page); | 319 CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page); |
320 pageLink->GetRects(link_index, &rects); | 320 return pdfium::CollectionSize<int>(pageLink->GetRects(link_index)); |
321 return rects.GetSize(); | |
322 } | 321 } |
323 | 322 |
324 DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, | 323 DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, |
325 int link_index, | 324 int link_index, |
326 int rect_index, | 325 int rect_index, |
327 double* left, | 326 double* left, |
328 double* top, | 327 double* top, |
329 double* right, | 328 double* right, |
330 double* bottom) { | 329 double* bottom) { |
331 if (!link_page || link_index < 0 || rect_index < 0) | 330 if (!link_page || link_index < 0 || rect_index < 0) |
332 return; | 331 return; |
333 | 332 |
334 CFX_RectArray rectArray; | |
335 CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page); | 333 CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page); |
336 pageLink->GetRects(link_index, &rectArray); | 334 std::vector<CFX_FloatRect> rectArray = pageLink->GetRects(link_index); |
337 if (rect_index >= rectArray.GetSize()) | 335 if (rect_index >= pdfium::CollectionSize<int>(rectArray)) |
338 return; | 336 return; |
339 | 337 |
340 CFX_FloatRect rect = rectArray.GetAt(rect_index); | 338 *left = rectArray[rect_index].left; |
341 *left = rect.left; | 339 *right = rectArray[rect_index].right; |
342 *right = rect.right; | 340 *top = rectArray[rect_index].top; |
343 *top = rect.top; | 341 *bottom = rectArray[rect_index].bottom; |
344 *bottom = rect.bottom; | |
345 } | 342 } |
346 | 343 |
347 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) { | 344 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) { |
348 delete CPDFLinkExtractFromFPDFPageLink(link_page); | 345 delete CPDFLinkExtractFromFPDFPageLink(link_page); |
349 } | 346 } |
OLD | NEW |