| 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 | 9 |
| 10 namespace chrome_pdf { | 10 namespace chrome_pdf { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 count *= -1; | 64 count *= -1; |
| 65 index -= count - 1; | 65 index -= count - 1; |
| 66 } | 66 } |
| 67 | 67 |
| 68 if (count > 0) { | 68 if (count > 0) { |
| 69 unsigned short* data = | 69 unsigned short* data = |
| 70 reinterpret_cast<unsigned short*>(WriteInto(&rv, count + 1)); | 70 reinterpret_cast<unsigned short*>(WriteInto(&rv, count + 1)); |
| 71 // |written| includes the trailing terminator, so get rid of the trailing | 71 // |written| includes the trailing terminator, so get rid of the trailing |
| 72 // NUL character by calling resize(). | 72 // NUL character by calling resize(). |
| 73 int written = FPDFText_GetText(page_->GetTextPage(), index, count, data); | 73 int written = FPDFText_GetText(page_->GetTextPage(), index, count, data); |
| 74 if (written < 1) | 74 if (written > 0) { |
| 75 rv.resize(0); | 75 DCHECK_EQ(L'\0', rv[written - 1]); |
| 76 else | |
| 77 rv.resize(written - 1); | 76 rv.resize(written - 1); |
| 77 } else { |
| 78 rv.clear(); |
| 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 return rv; | 82 return rv; |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace chrome_pdf | 85 } // namespace chrome_pdf |
| OLD | NEW |