OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium 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 #include "pdf/pdfium/pdfium_page.h" | 5 #include "pdf/pdfium/pdfium_page.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 FPDF_DEST dest = FPDFAction_GetDest(engine_->doc(), action); | 329 FPDF_DEST dest = FPDFAction_GetDest(engine_->doc(), action); |
330 if (dest) | 330 if (dest) |
331 return GetDestinationTarget(dest, target); | 331 return GetDestinationTarget(dest, target); |
332 // TODO(thestig): We don't fully support all types of the in-document | 332 // TODO(thestig): We don't fully support all types of the in-document |
333 // links. Need to implement that. There is a bug to track that: | 333 // links. Need to implement that. There is a bug to track that: |
334 // https://crbug.com/55776 | 334 // https://crbug.com/55776 |
335 return NONSELECTABLE_AREA; | 335 return NONSELECTABLE_AREA; |
336 } | 336 } |
337 case PDFACTION_URI: | 337 case PDFACTION_URI: |
338 return GetURITarget(action, target); | 338 return GetURITarget(action, target); |
| 339 case PDFACTION_LAUNCH: |
| 340 return GetLaunchTarget(action, target); |
339 // TODO(thestig): Support remaining types for https://crbug.com/55776 | 341 // TODO(thestig): Support remaining types for https://crbug.com/55776 |
340 case PDFACTION_LAUNCH: | |
341 case PDFACTION_REMOTEGOTO: | 342 case PDFACTION_REMOTEGOTO: |
342 default: | 343 default: |
343 return NONSELECTABLE_AREA; | 344 return NONSELECTABLE_AREA; |
344 } | 345 } |
345 } | 346 } |
346 | 347 |
347 PDFiumPage::Area PDFiumPage::GetDestinationTarget(FPDF_DEST destination, | 348 PDFiumPage::Area PDFiumPage::GetDestinationTarget(FPDF_DEST destination, |
348 LinkTarget* target) const { | 349 LinkTarget* target) const { |
349 if (target) | 350 if (target) |
350 target->page = FPDFDest_GetPageIndex(engine_->doc(), destination); | 351 target->page = FPDFDest_GetPageIndex(engine_->doc(), destination); |
(...skipping 10 matching lines...) Expand all Loading... |
361 &target->url, buffer_size, true); | 362 &target->url, buffer_size, true); |
362 void* data = api_string_adapter.GetData(); | 363 void* data = api_string_adapter.GetData(); |
363 size_t bytes_written = | 364 size_t bytes_written = |
364 FPDFAction_GetURIPath(engine_->doc(), uri_action, data, buffer_size); | 365 FPDFAction_GetURIPath(engine_->doc(), uri_action, data, buffer_size); |
365 api_string_adapter.Close(bytes_written); | 366 api_string_adapter.Close(bytes_written); |
366 } | 367 } |
367 } | 368 } |
368 return WEBLINK_AREA; | 369 return WEBLINK_AREA; |
369 } | 370 } |
370 | 371 |
| 372 PDFiumPage::Area PDFiumPage::GetLaunchTarget(FPDF_ACTION launch_action, |
| 373 LinkTarget* target) const { |
| 374 if (target) { |
| 375 size_t buffer_size = FPDFAction_GetFilePath(launch_action, nullptr, 0); |
| 376 if (buffer_size > 0) { |
| 377 PDFiumAPIStringBufferAdapter<std::string> api_string_adapter( |
| 378 &target->url, buffer_size, true); |
| 379 void* data = api_string_adapter.GetData(); |
| 380 size_t bytes_written = |
| 381 FPDFAction_GetFilePath(launch_action, data, buffer_size); |
| 382 api_string_adapter.Close(bytes_written); |
| 383 } |
| 384 } |
| 385 return WEBLINK_AREA; |
| 386 } |
| 387 |
371 int PDFiumPage::GetLink(int char_index, LinkTarget* target) { | 388 int PDFiumPage::GetLink(int char_index, LinkTarget* target) { |
372 if (!available_) | 389 if (!available_) |
373 return -1; | 390 return -1; |
374 | 391 |
375 CalculateLinks(); | 392 CalculateLinks(); |
376 | 393 |
377 // Get the bounding box of the rect again, since it might have moved because | 394 // Get the bounding box of the rect again, since it might have moved because |
378 // of the tolerance above. | 395 // of the tolerance above. |
379 double left, right, bottom, top; | 396 double left, right, bottom, top; |
380 FPDFText_GetCharBox(GetTextPage(), char_index, &left, &right, &bottom, &top); | 397 FPDFText_GetCharBox(GetTextPage(), char_index, &left, &right, &bottom, &top); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 page_->loading_count_--; | 553 page_->loading_count_--; |
537 } | 554 } |
538 | 555 |
539 PDFiumPage::Link::Link() = default; | 556 PDFiumPage::Link::Link() = default; |
540 | 557 |
541 PDFiumPage::Link::Link(const Link& that) = default; | 558 PDFiumPage::Link::Link(const Link& that) = default; |
542 | 559 |
543 PDFiumPage::Link::~Link() = default; | 560 PDFiumPage::Link::~Link() = default; |
544 | 561 |
545 } // namespace chrome_pdf | 562 } // namespace chrome_pdf |
OLD | NEW |