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 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "ppapi/cpp/rect.h" | 12 #include "ppapi/cpp/rect.h" |
13 #include "third_party/pdfium/public/fpdf_doc.h" | 13 #include "third_party/pdfium/public/fpdf_doc.h" |
14 #include "third_party/pdfium/public/fpdf_formfill.h" | 14 #include "third_party/pdfium/public/fpdf_formfill.h" |
15 #include "third_party/pdfium/public/fpdf_text.h" | 15 #include "third_party/pdfium/public/fpdf_text.h" |
16 | 16 |
17 namespace chrome_pdf { | 17 namespace chrome_pdf { |
18 | 18 |
19 class PDFiumEngine; | 19 class PDFiumEngine; |
20 | 20 |
21 // Wrapper around a page from the document. | 21 // Wrapper around a page from the document. |
22 class PDFiumPage { | 22 class PDFiumPage { |
23 public: | 23 public: |
24 PDFiumPage(PDFiumEngine* engine, | 24 PDFiumPage(PDFiumEngine* engine, int i, const pp::Rect& r, bool available); |
25 int i, | |
26 const pp::Rect& r, | |
27 bool available); | |
28 PDFiumPage(const PDFiumPage& that); | 25 PDFiumPage(const PDFiumPage& that); |
29 ~PDFiumPage(); | 26 ~PDFiumPage(); |
30 | 27 |
31 // Unloads the PDFium data for this page from memory. | 28 // Unloads the PDFium data for this page from memory. |
32 void Unload(); | 29 void Unload(); |
33 // Gets the FPDF_PAGE for this page, loading and parsing it if necessary. | 30 // Gets the FPDF_PAGE for this page, loading and parsing it if necessary. |
34 FPDF_PAGE GetPage(); | 31 FPDF_PAGE GetPage(); |
35 // Get the FPDF_PAGE for printing. | 32 // Get the FPDF_PAGE for printing. |
36 FPDF_PAGE GetPrintPage(); | 33 FPDF_PAGE GetPrintPage(); |
37 // Close the printing page. | 34 // Close the printing page. |
(...skipping 25 matching lines...) Expand all Loading... |
63 // We are using std::string here which have a copy contructor. | 60 // We are using std::string here which have a copy contructor. |
64 // That prevents us from using union here. | 61 // That prevents us from using union here. |
65 std::string url; // Valid for WEBLINK_AREA only. | 62 std::string url; // Valid for WEBLINK_AREA only. |
66 int page; // Valid for DOCLINK_AREA only. | 63 int page; // Valid for DOCLINK_AREA only. |
67 }; | 64 }; |
68 | 65 |
69 // Given a point in the document that's in this page, returns its character | 66 // Given a point in the document that's in this page, returns its character |
70 // index if it's near a character, and also the type of text. | 67 // index if it's near a character, and also the type of text. |
71 // Target is optional. It will be filled in for WEBLINK_AREA or | 68 // Target is optional. It will be filled in for WEBLINK_AREA or |
72 // DOCLINK_AREA only. | 69 // DOCLINK_AREA only. |
73 Area GetCharIndex(const pp::Point& point, int rotation, int* char_index, | 70 Area GetCharIndex(const pp::Point& point, |
74 int* form_type, LinkTarget* target); | 71 int rotation, |
| 72 int* char_index, |
| 73 int* form_type, |
| 74 LinkTarget* target); |
75 | 75 |
76 // Gets the character at the given index. | 76 // Gets the character at the given index. |
77 base::char16 GetCharAtIndex(int index); | 77 base::char16 GetCharAtIndex(int index); |
78 | 78 |
79 // Gets the number of characters in the page. | 79 // Gets the number of characters in the page. |
80 int GetCharCount(); | 80 int GetCharCount(); |
81 | 81 |
82 // Converts from page coordinates to screen coordinates. | 82 // Converts from page coordinates to screen coordinates. |
83 pp::Rect PageToScreen(const pp::Point& offset, | 83 pp::Rect PageToScreen(const pp::Point& offset, |
84 double zoom, | 84 double zoom, |
85 double left, | 85 double left, |
86 double top, | 86 double top, |
87 double right, | 87 double right, |
88 double bottom, | 88 double bottom, |
89 int rotation) const; | 89 int rotation) const; |
90 | 90 |
91 int index() const { return index_; } | 91 int index() const { return index_; } |
92 pp::Rect rect() const { return rect_; } | 92 pp::Rect rect() const { return rect_; } |
93 void set_rect(const pp::Rect& r) { rect_ = r; } | 93 void set_rect(const pp::Rect& r) { rect_ = r; } |
94 bool available() const { return available_; } | 94 bool available() const { return available_; } |
95 void set_available(bool available) { available_ = available; } | 95 void set_available(bool available) { available_ = available; } |
96 void set_calculated_links(bool calculated_links) { | 96 void set_calculated_links(bool calculated_links) { |
97 calculated_links_ = calculated_links; | 97 calculated_links_ = calculated_links; |
98 } | 98 } |
99 | 99 |
100 private: | 100 private: |
101 // Returns a link index if the given character index is over a link, or -1 | 101 // Returns a link index if the given character index is over a link, or -1 |
102 // otherwise. | 102 // otherwise. |
103 int GetLink(int char_index, LinkTarget* target); | 103 int GetLink(int char_index, LinkTarget* target); |
104 // Returns the link indices if the given rect intersects a link rect, or an | 104 // Returns the link indices if the given rect intersects a link rect, or an |
105 // empty vector otherwise. | 105 // empty vector otherwise. |
106 std::vector<int> GetLinks(pp::Rect text_area, | 106 std::vector<int> GetLinks(pp::Rect text_area, |
107 std::vector<LinkTarget>* targets); | 107 std::vector<LinkTarget>* targets); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 int loading_count_; | 139 int loading_count_; |
140 pp::Rect rect_; | 140 pp::Rect rect_; |
141 bool calculated_links_; | 141 bool calculated_links_; |
142 std::vector<Link> links_; | 142 std::vector<Link> links_; |
143 bool available_; | 143 bool available_; |
144 }; | 144 }; |
145 | 145 |
146 } // namespace chrome_pdf | 146 } // namespace chrome_pdf |
147 | 147 |
148 #endif // PDF_PDFIUM_PDFIUM_PAGE_H_ | 148 #endif // PDF_PDFIUM_PDFIUM_PAGE_H_ |
OLD | NEW |