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_range.h" | 5 #include "pdf/pdfium/pdfium_range.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" | 9 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 for (int i = 0; i < count; ++i) { | 50 for (int i = 0; i < count; ++i) { |
51 double left, top, right, bottom; | 51 double left, top, right, bottom; |
52 FPDFText_GetRect(page_->GetTextPage(), i, &left, &top, &right, &bottom); | 52 FPDFText_GetRect(page_->GetTextPage(), i, &left, &top, &right, &bottom); |
53 cached_screen_rects_.push_back( | 53 cached_screen_rects_.push_back( |
54 page_->PageToScreen(offset, zoom, left, top, right, bottom, rotation)); | 54 page_->PageToScreen(offset, zoom, left, top, right, bottom, rotation)); |
55 } | 55 } |
56 | 56 |
57 return cached_screen_rects_; | 57 return cached_screen_rects_; |
58 } | 58 } |
59 | 59 |
60 base::string16 PDFiumRange::GetText() { | 60 base::string16 PDFiumRange::GetText() const { |
61 int index = char_index_; | 61 int index = char_index_; |
62 int count = char_count_; | 62 int count = char_count_; |
63 base::string16 rv; | 63 base::string16 rv; |
64 if (count < 0) { | 64 if (count < 0) { |
65 count *= -1; | 65 count *= -1; |
66 index -= count - 1; | 66 index -= count - 1; |
67 } | 67 } |
68 | 68 |
69 if (count > 0) { | 69 if (count > 0) { |
70 PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&rv, | 70 PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&rv, |
71 count, | 71 count, |
72 false); | 72 false); |
73 unsigned short* data = | 73 unsigned short* data = |
74 reinterpret_cast<unsigned short*>(api_string_adapter.GetData()); | 74 reinterpret_cast<unsigned short*>(api_string_adapter.GetData()); |
75 int written = FPDFText_GetText(page_->GetTextPage(), index, count, data); | 75 int written = FPDFText_GetText(page_->GetTextPage(), index, count, data); |
76 api_string_adapter.Close(written); | 76 api_string_adapter.Close(written); |
77 } | 77 } |
78 | 78 |
79 return rv; | 79 return rv; |
80 } | 80 } |
81 | 81 |
82 } // namespace chrome_pdf | 82 } // namespace chrome_pdf |
OLD | NEW |