Reorder cpdf_tounicodemap.cpp to better match header.
Change-Id: Ia4e32528e84b185172af6da7e008ca60e2ef444a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59258
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp
index aca7feb..ce503b5 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp
@@ -16,6 +16,32 @@
#include "core/fxcrt/fx_safe_types.h"
#include "third_party/base/numerics/safe_conversions.h"
+namespace {
+
+WideString StringDataAdd(WideString str) {
+ WideString ret;
+ int len = str.GetLength();
+ wchar_t value = 1;
+ for (int i = len - 1; i >= 0; --i) {
+ wchar_t ch = str[i] + value;
+ if (ch < str[i]) {
+ ret.InsertAtFront(0);
+ } else {
+ ret.InsertAtFront(ch);
+ value = 0;
+ }
+ }
+ if (value)
+ ret.InsertAtFront(value);
+ return ret;
+}
+
+} // namespace
+
+CPDF_ToUnicodeMap::CPDF_ToUnicodeMap() : m_pBaseMap(nullptr) {}
+
+CPDF_ToUnicodeMap::~CPDF_ToUnicodeMap() {}
+
WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
auto it = m_Map.find(charcode);
if (it != m_Map.end()) {
@@ -72,24 +98,6 @@
return result;
}
-static WideString StringDataAdd(WideString str) {
- WideString ret;
- int len = str.GetLength();
- wchar_t value = 1;
- for (int i = len - 1; i >= 0; --i) {
- wchar_t ch = str[i] + value;
- if (ch < str[i]) {
- ret.InsertAtFront(0);
- } else {
- ret.InsertAtFront(ch);
- value = 0;
- }
- }
- if (value)
- ret.InsertAtFront(value);
- return ret;
-}
-
// Static.
WideString CPDF_ToUnicodeMap::StringToWideString(ByteStringView str) {
int len = str.GetLength();
@@ -114,16 +122,6 @@
return result;
}
-CPDF_ToUnicodeMap::CPDF_ToUnicodeMap() : m_pBaseMap(nullptr) {}
-
-CPDF_ToUnicodeMap::~CPDF_ToUnicodeMap() {}
-
-uint32_t CPDF_ToUnicodeMap::GetUnicode() {
- FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength();
- uni = uni * 0x10000 + 0xffff;
- return uni.ValueOrDefault(0);
-}
-
void CPDF_ToUnicodeMap::Load(const CPDF_Stream* pStream) {
CIDSet cid_set = CIDSET_UNKNOWN;
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
@@ -230,3 +228,9 @@
m_pBaseMap = nullptr;
}
}
+
+uint32_t CPDF_ToUnicodeMap::GetUnicode() {
+ FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength();
+ uni = uni * 0x10000 + 0xffff;
+ return uni.ValueOrDefault(0);
+}