Move GetNativeCharSet() into an anonymous namespace.
Move CPDF_InteractiveForm::GetNativeCharSet() into an anonymous
namespace. Also remove one of the two variants of AddNativeFont(),
which is just a wrapper around the other, and remove a now redundant
GetNativeCharSet() call.
Change-Id: I5882948667b9e6d1982dda0d64ffd2e637fa2de9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73118
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp
index 27fa31c..ee5670b 100644
--- a/core/fpdfdoc/cpdf_interactiveform.cpp
+++ b/core/fpdfdoc/cpdf_interactiveform.cpp
@@ -148,6 +148,10 @@
return csTmp;
}
+uint8_t GetNativeCharSet() {
+ return FX_GetCharsetFromCodePage(FXSYS_GetACP());
+}
+
void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
if (!pDocument)
return;
@@ -161,7 +165,7 @@
ByteString csDA;
if (!pFormDict->KeyExist("DR")) {
ByteString csBaseName;
- uint8_t charSet = CPDF_InteractiveForm::GetNativeCharSet();
+ uint8_t charSet = GetNativeCharSet();
RetainPtr<CPDF_Font> pFont = CPDF_InteractiveForm::AddStandardFont(
pDocument, CFX_Font::kDefaultAnsiFontName);
if (pFont)
@@ -170,7 +174,7 @@
if (charSet != FX_CHARSET_ANSI) {
ByteString csFontName = GetNativeFontName(charSet, nullptr);
if (!pFont || csFontName != CFX_Font::kDefaultAnsiFontName) {
- pFont = CPDF_InteractiveForm::AddNativeFont(pDocument);
+ pFont = CPDF_InteractiveForm::AddNativeFont(charSet, pDocument);
if (pFont) {
csBaseName.clear();
AddFont(pFormDict, pDocument, pFont, &csBaseName);
@@ -542,7 +546,7 @@
if (!pFormDict)
InitDict(pFormDict, pDocument);
- uint8_t charSet = CPDF_InteractiveForm::GetNativeCharSet();
+ uint8_t charSet = GetNativeCharSet();
ByteString csTemp;
RetainPtr<CPDF_Font> pFont =
GetNativeFont(pFormDict, pDocument, charSet, &csTemp);
@@ -563,11 +567,6 @@
return pFont;
}
-// static
-uint8_t CPDF_InteractiveForm::GetNativeCharSet() {
- return FX_GetCharsetFromCodePage(FXSYS_GetACP());
-}
-
CPDF_InteractiveForm::CPDF_InteractiveForm(CPDF_Document* pDocument)
: m_pDocument(pDocument), m_pFieldTree(std::make_unique<CFieldTree>()) {
CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
@@ -630,11 +629,6 @@
return nullptr;
}
-RetainPtr<CPDF_Font> CPDF_InteractiveForm::AddNativeFont(
- CPDF_Document* pDocument) {
- return pDocument ? AddNativeFont(GetNativeCharSet(), pDocument) : nullptr;
-}
-
size_t CPDF_InteractiveForm::CountFields(const WideString& csFieldName) const {
if (csFieldName.IsEmpty())
return m_pFieldTree->m_Root.CountFields();
diff --git a/core/fpdfdoc/cpdf_interactiveform.h b/core/fpdfdoc/cpdf_interactiveform.h
index e76f419..e4e8f42 100644
--- a/core/fpdfdoc/cpdf_interactiveform.h
+++ b/core/fpdfdoc/cpdf_interactiveform.h
@@ -49,12 +49,10 @@
static void SetUpdateAP(bool bUpdateAP);
static bool IsUpdateAPEnabled();
- static uint8_t GetNativeCharSet();
static RetainPtr<CPDF_Font> AddStandardFont(CPDF_Document* pDocument,
ByteString csFontName);
static RetainPtr<CPDF_Font> AddNativeFont(uint8_t iCharSet,
CPDF_Document* pDocument);
- static RetainPtr<CPDF_Font> AddNativeFont(CPDF_Document* pDocument);
static RetainPtr<CPDF_Font> AddNativeInteractiveFormFont(
CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,