Index: core/src/fpdfdoc/doc_form.cpp |
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp |
index 460a44a7dffea28731e6dad33d3796e7f7429e46..915f14ffab2609fcb89a1bffe975270e1bf9d93a 100644 |
--- a/core/src/fpdfdoc/doc_form.cpp |
+++ b/core/src/fpdfdoc/doc_form.cpp |
@@ -8,8 +8,45 @@ |
#include "core/src/fpdfdoc/doc_utils.h" |
#include "third_party/base/stl_util.h" |
+namespace { |
+ |
const int nMaxRecursion = 32; |
+const struct SupportFieldEncoding { |
+ const FX_CHAR* m_name; |
+ FX_WORD m_codePage; |
+} g_fieldEncoding[] = { |
+ {"BigFive", 950}, |
+ {"GBK", 936}, |
+ {"Shift-JIS", 932}, |
+ {"UHC", 949}, |
+}; |
+ |
+static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary* pFieldDict, |
Tom Sepez
2016/02/19 17:02:47
Nit: need not be static now that namespace'd anon.
Lei Zhang
2016/02/19 18:48:34
Done.
|
+ CFX_WideString& csValue, |
+ CFX_ByteString& bsEncoding) { |
+ CFX_ByteString csBValue = pFieldDict->GetStringBy("V"); |
+ const size_t iCount = FX_ArraySize(g_fieldEncoding); |
+ size_t i = 0; |
Tom Sepez
2016/02/19 17:02:47
Nit: maybe range-based for-loop.
Lei Zhang
2016/02/19 18:48:34
Done, and more.
|
+ for (; i < iCount; ++i) |
+ if (bsEncoding == g_fieldEncoding[i].m_name) { |
+ break; |
Tom Sepez
2016/02/19 17:02:47
Nit: maybe do line 36 here and return rather than
Lei Zhang
2016/02/19 18:48:34
Done.
|
+ } |
+ if (i < iCount) { |
+ csValue = |
+ CFX_WideString::FromCodePage(csBValue, g_fieldEncoding[i].m_codePage); |
+ return; |
+ } |
+ CFX_ByteString csTemp = csBValue.Left(2); |
+ if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") { |
+ csValue = PDF_DecodeText(csBValue); |
+ } else { |
+ csValue = CFX_WideString::FromLocal(csBValue); |
+ } |
+} |
+ |
+} // namespace |
+ |
class CFieldNameExtractor { |
public: |
explicit CFieldNameExtractor(const CFX_WideString& full_name) { |
@@ -1088,39 +1125,7 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( |
} |
return pDoc; |
} |
-const struct _SupportFieldEncoding { |
- const FX_CHAR* m_name; |
- int32_t m_codePage; |
-} g_fieldEncoding[] = { |
- {"BigFive", 950}, |
- {"GBK", 936}, |
- {"Shift-JIS", 932}, |
- {"UHC", 949}, |
-}; |
-static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary* pFieldDict, |
- CFX_WideString& csValue, |
- CFX_ByteString& bsEncoding) { |
- CFX_ByteString csBValue = pFieldDict->GetStringBy("V"); |
- int32_t iCount = sizeof(g_fieldEncoding) / sizeof(g_fieldEncoding[0]); |
- int32_t i = 0; |
- for (; i < iCount; ++i) |
- if (bsEncoding == g_fieldEncoding[i].m_name) { |
- break; |
- } |
- if (i < iCount) { |
- CFX_CharMap* pCharMap = |
- CFX_CharMap::GetDefaultMapper(g_fieldEncoding[i].m_codePage); |
- FXSYS_assert(pCharMap); |
- csValue.ConvertFrom(csBValue, pCharMap); |
- return; |
- } |
- CFX_ByteString csTemp = csBValue.Left(2); |
- if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") { |
- csValue = PDF_DecodeText(csBValue); |
- } else { |
- csValue = CFX_WideString::FromLocal(csBValue); |
- } |
-} |
+ |
void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, |
const CFX_WideString& parent_name, |
FX_BOOL bNotify, |