OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 need_update = true; | 1181 need_update = true; |
1182 if (IsPageVisible(i)) | 1182 if (IsPageVisible(i)) |
1183 client_->Invalidate(GetPageScreenRect(i)); | 1183 client_->Invalidate(GetPageScreenRect(i)); |
1184 } | 1184 } |
1185 if (need_update) | 1185 if (need_update) |
1186 LoadPageInfo(true); | 1186 LoadPageInfo(true); |
1187 | 1187 |
1188 FinishLoadingDocument(); | 1188 FinishLoadingDocument(); |
1189 } | 1189 } |
1190 | 1190 |
| 1191 unsigned long PDFiumEngine::GetNameDestCount() { |
| 1192 return FPDF_CountNamedDests(doc_); |
| 1193 } |
| 1194 |
| 1195 void PDFiumEngine::GetNameDests(std::vector<std::string>* name_dest) { |
| 1196 unsigned long count = GetNameDestCount(); |
| 1197 for (unsigned long i = 0; i < count; i++) { |
| 1198 wchar_t* name = NULL; |
| 1199 unsigned long len = 0; |
| 1200 FPDF_DEST dest = NULL; |
| 1201 dest = FPDF_GetNamedDest(doc_, i, name, len); |
| 1202 if (dest) { |
| 1203 name = new wchar_t[len]; |
| 1204 FPDF_DEST dest = FPDF_GetNamedDest(doc_, i, name, len); |
| 1205 if (dest) { |
| 1206 name_dest->push_back( |
| 1207 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(name))); |
| 1208 } |
| 1209 delete[] name; |
| 1210 } |
| 1211 } |
| 1212 } |
| 1213 |
1191 void PDFiumEngine::FinishLoadingDocument() { | 1214 void PDFiumEngine::FinishLoadingDocument() { |
1192 DCHECK(doc_loader_.IsDocumentComplete() && doc_); | 1215 DCHECK(doc_loader_.IsDocumentComplete() && doc_); |
1193 if (called_do_document_action_) | 1216 if (called_do_document_action_) |
1194 return; | 1217 return; |
1195 called_do_document_action_ = true; | 1218 called_do_document_action_ = true; |
1196 | 1219 |
1197 // These can only be called now, as the JS might end up needing a page. | 1220 // These can only be called now, as the JS might end up needing a page. |
1198 FORM_DoDocumentJSAction(form_); | 1221 FORM_DoDocumentJSAction(form_); |
1199 FORM_DoDocumentOpenAction(form_); | 1222 FORM_DoDocumentOpenAction(form_); |
1200 if (most_visible_page_ != -1) { | 1223 if (most_visible_page_ != -1) { |
(...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3914 double* height) { | 3937 double* height) { |
3915 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3938 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
3916 if (!doc) | 3939 if (!doc) |
3917 return false; | 3940 return false; |
3918 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3941 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
3919 FPDF_CloseDocument(doc); | 3942 FPDF_CloseDocument(doc); |
3920 return success; | 3943 return success; |
3921 } | 3944 } |
3922 | 3945 |
3923 } // namespace chrome_pdf | 3946 } // namespace chrome_pdf |
OLD | NEW |