| 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 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 | 2222 |
| 2223 void PDFiumEngine::InvalidateAllPages() { | 2223 void PDFiumEngine::InvalidateAllPages() { |
| 2224 CancelPaints(); | 2224 CancelPaints(); |
| 2225 StopFind(); | 2225 StopFind(); |
| 2226 LoadPageInfo(true); | 2226 LoadPageInfo(true); |
| 2227 client_->Invalidate(pp::Rect(plugin_size_)); | 2227 client_->Invalidate(pp::Rect(plugin_size_)); |
| 2228 } | 2228 } |
| 2229 | 2229 |
| 2230 std::string PDFiumEngine::GetSelectedText() { | 2230 std::string PDFiumEngine::GetSelectedText() { |
| 2231 base::string16 result; | 2231 base::string16 result; |
| 2232 base::string16 new_line_char = base::UTF8ToUTF16("\n"); |
| 2232 for (size_t i = 0; i < selection_.size(); ++i) { | 2233 for (size_t i = 0; i < selection_.size(); ++i) { |
| 2233 if (i > 0 && | 2234 if (i > 0 && |
| 2234 selection_[i - 1].page_index() > selection_[i].page_index()) { | 2235 selection_[i - 1].page_index() > selection_[i].page_index()) { |
| 2235 result = selection_[i].GetText() + result; | 2236 result = selection_[i].GetText() + new_line_char + result; |
| 2236 } else { | 2237 } else { |
| 2238 if (i > 0) |
| 2239 result.append(new_line_char); |
| 2237 result.append(selection_[i].GetText()); | 2240 result.append(selection_[i].GetText()); |
| 2238 } | 2241 } |
| 2239 } | 2242 } |
| 2240 | 2243 |
| 2241 FormatStringWithHyphens(&result); | 2244 FormatStringWithHyphens(&result); |
| 2242 FormatStringForOS(&result); | 2245 FormatStringForOS(&result); |
| 2243 return base::UTF16ToUTF8(result); | 2246 return base::UTF16ToUTF8(result); |
| 2244 } | 2247 } |
| 2245 | 2248 |
| 2246 std::string PDFiumEngine::GetLinkAtPosition(const pp::Point& point) { | 2249 std::string PDFiumEngine::GetLinkAtPosition(const pp::Point& point) { |
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3889 double* height) { | 3892 double* height) { |
| 3890 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3893 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3891 if (!doc) | 3894 if (!doc) |
| 3892 return false; | 3895 return false; |
| 3893 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3896 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3894 FPDF_CloseDocument(doc); | 3897 FPDF_CloseDocument(doc); |
| 3895 return success; | 3898 return success; |
| 3896 } | 3899 } |
| 3897 | 3900 |
| 3898 } // namespace chrome_pdf | 3901 } // namespace chrome_pdf |
| OLD | NEW |