| 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 #ifndef PDF_PDFIUM_PDFIUM_PAGE_H_ | 5 #ifndef PDF_PDFIUM_PDFIUM_PAGE_H_ |
| 6 #define PDF_PDFIUM_PDFIUM_PAGE_H_ | 6 #define PDF_PDFIUM_PDFIUM_PAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class PDFiumEngine; | 23 class PDFiumEngine; |
| 24 | 24 |
| 25 // Wrapper around a page from the document. | 25 // Wrapper around a page from the document. |
| 26 class PDFiumPage { | 26 class PDFiumPage { |
| 27 public: | 27 public: |
| 28 PDFiumPage(PDFiumEngine* engine, | 28 PDFiumPage(PDFiumEngine* engine, |
| 29 int i, | 29 int i, |
| 30 const pp::Rect& r, | 30 const pp::Rect& r, |
| 31 bool available); | 31 bool available); |
| 32 ~PDFiumPage(); | 32 ~PDFiumPage(); |
| 33 |
| 33 // Unloads the PDFium data for this page from memory. | 34 // Unloads the PDFium data for this page from memory. |
| 34 void Unload(); | 35 void Unload(); |
| 35 // Gets the FPDF_PAGE for this page, loading and parsing it if necessary. | 36 // Gets the FPDF_PAGE for this page, loading and parsing it if necessary. |
| 36 FPDF_PAGE GetPage(); | 37 FPDF_PAGE GetPage(); |
| 37 // Get the FPDF_PAGE for printing. | 38 // Get the FPDF_PAGE for printing. |
| 38 FPDF_PAGE GetPrintPage(); | 39 FPDF_PAGE GetPrintPage(); |
| 39 // Close the printing page. | 40 // Close the printing page. |
| 40 void ClosePrintPage(); | 41 void ClosePrintPage(); |
| 41 | 42 |
| 42 // Returns FPDF_TEXTPAGE for the page, loading and parsing it if necessary. | 43 // Returns FPDF_TEXTPAGE for the page, loading and parsing it if necessary. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 // Gets the number of characters in the page. | 73 // Gets the number of characters in the page. |
| 73 int GetCharCount(); | 74 int GetCharCount(); |
| 74 | 75 |
| 75 // Converts from page coordinates to screen coordinates. | 76 // Converts from page coordinates to screen coordinates. |
| 76 pp::Rect PageToScreen(const pp::Point& offset, | 77 pp::Rect PageToScreen(const pp::Point& offset, |
| 77 double zoom, | 78 double zoom, |
| 78 double left, | 79 double left, |
| 79 double top, | 80 double top, |
| 80 double right, | 81 double right, |
| 81 double bottom, | 82 double bottom, |
| 82 int rotation); | 83 int rotation) const; |
| 83 | 84 |
| 84 int index() const { return index_; } | 85 int index() const { return index_; } |
| 85 pp::Rect rect() const { return rect_; } | 86 pp::Rect rect() const { return rect_; } |
| 86 void set_rect(const pp::Rect& r) { rect_ = r; } | 87 void set_rect(const pp::Rect& r) { rect_ = r; } |
| 87 bool available() const { return available_; } | 88 bool available() const { return available_; } |
| 88 void set_available(bool available) { available_ = available; } | 89 void set_available(bool available) { available_ = available; } |
| 89 void set_calculated_links(bool calculated_links) { | 90 void set_calculated_links(bool calculated_links) { |
| 90 calculated_links_ = calculated_links; | 91 calculated_links_ = calculated_links; |
| 91 } | 92 } |
| 92 | 93 |
| 93 private: | 94 private: |
| 94 // Returns a link index if the given character index is over a link, or -1 | 95 // Returns a link index if the given character index is over a link, or -1 |
| 95 // otherwise. | 96 // otherwise. |
| 96 int GetLink(int char_index, LinkTarget* target); | 97 int GetLink(int char_index, LinkTarget* target); |
| 97 // Returns the link indices if the given rect intersects a link rect, or an | 98 // Returns the link indices if the given rect intersects a link rect, or an |
| 98 // empty vector otherwise. | 99 // empty vector otherwise. |
| 99 std::vector<int> GetLinks(pp::Rect text_area, | 100 std::vector<int> GetLinks(pp::Rect text_area, |
| 100 std::vector<LinkTarget>* targets); | 101 std::vector<LinkTarget>* targets); |
| 101 // Calculate the locations of any links on the page. | 102 // Calculate the locations of any links on the page. |
| 102 void CalculateLinks(); | 103 void CalculateLinks(); |
| 103 // Returns link type and target associated with a link. Returns | 104 // Returns link type and target associated with a link. Returns |
| 104 // NONSELECTABLE_AREA if link detection failed. | 105 // NONSELECTABLE_AREA if link detection failed. |
| 105 Area GetLinkTarget(FPDF_LINK link, LinkTarget* target); | 106 Area GetLinkTarget(FPDF_LINK link, LinkTarget* target) const; |
| 106 // Returns target associated with a destination. | 107 // Returns target associated with a destination. |
| 107 Area GetDestinationTarget(FPDF_DEST destination, LinkTarget* target); | 108 Area GetDestinationTarget(FPDF_DEST destination, LinkTarget* target) const; |
| 108 // Returns the text in the supplied box as a Value Node | 109 // Returns the text in the supplied box as a Value Node |
| 109 base::Value* GetTextBoxAsValue(double page_height, double left, double top, | 110 base::Value* GetTextBoxAsValue(double page_height, double left, double top, |
| 110 double right, double bottom, int rotation); | 111 double right, double bottom, int rotation); |
| 111 // Helper functions for JSON generation | 112 // Helper functions for JSON generation |
| 112 base::Value* CreateTextNode(const std::string& text); | 113 base::Value* CreateTextNode(const std::string& text); |
| 113 base::Value* CreateURLNode(const std::string& text, const std::string& url); | 114 base::Value* CreateURLNode(const std::string& text, const std::string& url); |
| 114 | 115 |
| 115 class ScopedLoadCounter { | 116 class ScopedLoadCounter { |
| 116 public: | 117 public: |
| 117 explicit ScopedLoadCounter(PDFiumPage* page); | 118 explicit ScopedLoadCounter(PDFiumPage* page); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 137 int loading_count_; | 138 int loading_count_; |
| 138 pp::Rect rect_; | 139 pp::Rect rect_; |
| 139 bool calculated_links_; | 140 bool calculated_links_; |
| 140 std::vector<Link> links_; | 141 std::vector<Link> links_; |
| 141 bool available_; | 142 bool available_; |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 } // namespace chrome_pdf | 145 } // namespace chrome_pdf |
| 145 | 146 |
| 146 #endif // PDF_PDFIUM_PDFIUM_PAGE_H_ | 147 #endif // PDF_PDFIUM_PDFIUM_PAGE_H_ |
| OLD | NEW |