Rename CBA_FontMap to CPDF_BAFontMap.

There are no other CBA_ prefixed objects, and an awkward naming
convention is only valuable if it is rigorously followed.

Bug: pdfium:1675
Change-Id: Ic248aacd6cbdbab4ceb0f400d0821187ef67ca30
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79851
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/BUILD.gn b/core/fpdfdoc/BUILD.gn
index 0e4fa1d95..5e62af9 100644
--- a/core/fpdfdoc/BUILD.gn
+++ b/core/fpdfdoc/BUILD.gn
@@ -7,8 +7,6 @@
 
 source_set("fpdfdoc") {
   sources = [
-    "cba_fontmap.cpp",
-    "cba_fontmap.h",
     "cpdf_aaction.cpp",
     "cpdf_aaction.h",
     "cpdf_action.cpp",
@@ -19,6 +17,8 @@
     "cpdf_annotlist.h",
     "cpdf_apsettings.cpp",
     "cpdf_apsettings.h",
+    "cpdf_bafontmap.cpp",
+    "cpdf_bafontmap.h",
     "cpdf_bookmark.cpp",
     "cpdf_bookmark.h",
     "cpdf_bookmarktree.cpp",
diff --git a/core/fpdfdoc/cba_fontmap.cpp b/core/fpdfdoc/cpdf_bafontmap.cpp
similarity index 82%
rename from core/fpdfdoc/cba_fontmap.cpp
rename to core/fpdfdoc/cpdf_bafontmap.cpp
index 9781a03..e29fe24 100644
--- a/core/fpdfdoc/cba_fontmap.cpp
+++ b/core/fpdfdoc/cpdf_bafontmap.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 
 #include <memory>
 #include <utility>
@@ -64,13 +64,13 @@
 
 }  // namespace
 
-CBA_FontMap::Data::Data() = default;
+CPDF_BAFontMap::Data::Data() = default;
 
-CBA_FontMap::Data::~Data() = default;
+CPDF_BAFontMap::Data::~Data() = default;
 
-CBA_FontMap::CBA_FontMap(CPDF_Document* pDocument,
-                         CPDF_Dictionary* pAnnotDict,
-                         const ByteString& sAPType)
+CPDF_BAFontMap::CPDF_BAFontMap(CPDF_Document* pDocument,
+                               CPDF_Dictionary* pAnnotDict,
+                               const ByteString& sAPType)
     : m_pDocument(pDocument), m_pAnnotDict(pAnnotDict), m_sAPType(sAPType) {
   int32_t nCharset = FX_CHARSET_Default;
   m_pDefaultFont = GetAnnotDefaultFont(&m_sDefaultFontName);
@@ -94,23 +94,23 @@
     GetFontIndex(CFX_Font::kDefaultAnsiFontName, FX_CHARSET_ANSI, false);
 }
 
-CBA_FontMap::~CBA_FontMap() = default;
+CPDF_BAFontMap::~CPDF_BAFontMap() = default;
 
-RetainPtr<CPDF_Font> CBA_FontMap::GetPDFFont(int32_t nFontIndex) {
+RetainPtr<CPDF_Font> CPDF_BAFontMap::GetPDFFont(int32_t nFontIndex) {
   if (pdfium::IndexInBounds(m_Data, nFontIndex))
     return m_Data[nFontIndex]->pFont;
   return nullptr;
 }
 
-ByteString CBA_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
+ByteString CPDF_BAFontMap::GetPDFFontAlias(int32_t nFontIndex) {
   if (pdfium::IndexInBounds(m_Data, nFontIndex))
     return m_Data[nFontIndex]->sFontName;
   return ByteString();
 }
 
-int32_t CBA_FontMap::GetWordFontIndex(uint16_t word,
-                                      int32_t nCharset,
-                                      int32_t nFontIndex) {
+int32_t CPDF_BAFontMap::GetWordFontIndex(uint16_t word,
+                                         int32_t nCharset,
+                                         int32_t nFontIndex) {
   if (nFontIndex > 0) {
     if (KnowWord(nFontIndex, word))
       return nFontIndex;
@@ -140,7 +140,7 @@
   return -1;
 }
 
-int32_t CBA_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) {
+int32_t CPDF_BAFontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) {
   if (!pdfium::IndexInBounds(m_Data, nFontIndex))
     return -1;
 
@@ -154,7 +154,7 @@
   return word < 0xFF ? word : -1;
 }
 
-int32_t CBA_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) {
+int32_t CPDF_BAFontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) {
   // to avoid CJK Font to show ASCII
   if (word < 0x7F)
     return FX_CHARSET_ANSI;
@@ -166,12 +166,12 @@
   return CFX_Font::GetCharSetFromUnicode(word);
 }
 
-int32_t CBA_FontMap::GetNativeCharset() {
+int32_t CPDF_BAFontMap::GetNativeCharset() {
   return FX_GetCharsetFromCodePage(FXSYS_GetACP());
 }
 
-RetainPtr<CPDF_Font> CBA_FontMap::FindFontSameCharset(ByteString* sFontAlias,
-                                                      int32_t nCharset) {
+RetainPtr<CPDF_Font> CPDF_BAFontMap::FindFontSameCharset(ByteString* sFontAlias,
+                                                         int32_t nCharset) {
   if (m_pAnnotDict->GetNameFor(pdfium::annotation::kSubtype) != "Widget")
     return nullptr;
 
@@ -190,7 +190,7 @@
   return FindResFontSameCharset(pDRDict, sFontAlias, nCharset);
 }
 
-RetainPtr<CPDF_Font> CBA_FontMap::FindResFontSameCharset(
+RetainPtr<CPDF_Font> CPDF_BAFontMap::FindResFontSameCharset(
     const CPDF_Dictionary* pResDict,
     ByteString* sFontAlias,
     int32_t nCharset) {
@@ -229,7 +229,7 @@
   return pFind;
 }
 
-RetainPtr<CPDF_Font> CBA_FontMap::GetAnnotDefaultFont(ByteString* sAlias) {
+RetainPtr<CPDF_Font> CPDF_BAFontMap::GetAnnotDefaultFont(ByteString* sAlias) {
   CPDF_Dictionary* pAcroFormDict = nullptr;
   const bool bWidget =
       (m_pAnnotDict->GetNameFor(pdfium::annotation::kSubtype) == "Widget");
@@ -282,8 +282,8 @@
   return CPDF_DocPageData::FromDocument(m_pDocument.Get())->GetFont(pFontDict);
 }
 
-void CBA_FontMap::AddFontToAnnotDict(const RetainPtr<CPDF_Font>& pFont,
-                                     const ByteString& sAlias) {
+void CPDF_BAFontMap::AddFontToAnnotDict(const RetainPtr<CPDF_Font>& pFont,
+                                        const ByteString& sAlias) {
   if (!pFont)
     return;
 
@@ -327,14 +327,14 @@
   }
 }
 
-bool CBA_FontMap::KnowWord(int32_t nFontIndex, uint16_t word) {
+bool CPDF_BAFontMap::KnowWord(int32_t nFontIndex, uint16_t word) {
   return pdfium::IndexInBounds(m_Data, nFontIndex) &&
          CharCodeFromUnicode(nFontIndex, word) >= 0;
 }
 
-int32_t CBA_FontMap::GetFontIndex(const ByteString& sFontName,
-                                  int32_t nCharset,
-                                  bool bFind) {
+int32_t CPDF_BAFontMap::GetFontIndex(const ByteString& sFontName,
+                                     int32_t nCharset,
+                                     bool bFind) {
   int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
   if (nFontIndex >= 0)
     return nFontIndex;
@@ -351,9 +351,9 @@
   return AddFontData(pFont, sAlias, nCharset);
 }
 
-int32_t CBA_FontMap::AddFontData(const RetainPtr<CPDF_Font>& pFont,
-                                 const ByteString& sFontAlias,
-                                 int32_t nCharset) {
+int32_t CPDF_BAFontMap::AddFontData(const RetainPtr<CPDF_Font>& pFont,
+                                    const ByteString& sFontAlias,
+                                    int32_t nCharset) {
   auto pNewData = std::make_unique<Data>();
   pNewData->pFont = pFont;
   pNewData->sFontName = sFontAlias;
@@ -362,18 +362,19 @@
   return pdfium::CollectionSize<int32_t>(m_Data) - 1;
 }
 
-ByteString CBA_FontMap::EncodeFontAlias(const ByteString& sFontName,
-                                        int32_t nCharset) {
+ByteString CPDF_BAFontMap::EncodeFontAlias(const ByteString& sFontName,
+                                           int32_t nCharset) {
   return EncodeFontAlias(sFontName) + ByteString::Format("_%02X", nCharset);
 }
 
-ByteString CBA_FontMap::EncodeFontAlias(const ByteString& sFontName) {
+ByteString CPDF_BAFontMap::EncodeFontAlias(const ByteString& sFontName) {
   ByteString sRet = sFontName;
   sRet.Remove(' ');
   return sRet;
 }
 
-int32_t CBA_FontMap::FindFont(const ByteString& sFontName, int32_t nCharset) {
+int32_t CPDF_BAFontMap::FindFont(const ByteString& sFontName,
+                                 int32_t nCharset) {
   int32_t i = 0;
   for (const auto& pData : m_Data) {
     if ((nCharset == FX_CHARSET_Default || nCharset == pData->nCharset) &&
@@ -385,7 +386,7 @@
   return -1;
 }
 
-ByteString CBA_FontMap::GetNativeFontName(int32_t nCharset) {
+ByteString CPDF_BAFontMap::GetNativeFontName(int32_t nCharset) {
   if (nCharset == FX_CHARSET_Default)
     nCharset = GetNativeCharset();
 
@@ -396,7 +397,7 @@
   return sFontName;
 }
 
-ByteString CBA_FontMap::GetCachedNativeFontName(int32_t nCharset) {
+ByteString CPDF_BAFontMap::GetCachedNativeFontName(int32_t nCharset) {
   for (const auto& pData : m_NativeFont) {
     if (pData && pData->nCharset == nCharset)
       return pData->sFontName;
@@ -413,15 +414,15 @@
   return sNew;
 }
 
-RetainPtr<CPDF_Font> CBA_FontMap::AddFontToDocument(ByteString sFontName,
-                                                    uint8_t nCharset) {
+RetainPtr<CPDF_Font> CPDF_BAFontMap::AddFontToDocument(ByteString sFontName,
+                                                       uint8_t nCharset) {
   if (CFX_FontMapper::IsStandardFontName(sFontName))
     return AddStandardFont(sFontName);
 
   return AddSystemFont(sFontName, nCharset);
 }
 
-RetainPtr<CPDF_Font> CBA_FontMap::AddStandardFont(ByteString sFontName) {
+RetainPtr<CPDF_Font> CPDF_BAFontMap::AddStandardFont(ByteString sFontName) {
   auto* pPageData = CPDF_DocPageData::FromDocument(m_pDocument.Get());
   if (sFontName == "ZapfDingbats")
     return pPageData->AddStandardFont(sFontName, nullptr);
@@ -430,8 +431,8 @@
   return pPageData->AddStandardFont(sFontName, &fe);
 }
 
-RetainPtr<CPDF_Font> CBA_FontMap::AddSystemFont(ByteString sFontName,
-                                                uint8_t nCharset) {
+RetainPtr<CPDF_Font> CPDF_BAFontMap::AddSystemFont(ByteString sFontName,
+                                                   uint8_t nCharset) {
   if (sFontName.IsEmpty())
     sFontName = GetNativeFontName(nCharset);
 
diff --git a/core/fpdfdoc/cba_fontmap.h b/core/fpdfdoc/cpdf_bafontmap.h
similarity index 89%
rename from core/fpdfdoc/cba_fontmap.h
rename to core/fpdfdoc/cpdf_bafontmap.h
index 78390d4..9aa8c43 100644
--- a/core/fpdfdoc/cba_fontmap.h
+++ b/core/fpdfdoc/cpdf_bafontmap.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FPDFDOC_CBA_FONTMAP_H_
-#define CORE_FPDFDOC_CBA_FONTMAP_H_
+#ifndef CORE_FPDFDOC_CPDF_BAFONTMAP_H_
+#define CORE_FPDFDOC_CPDF_BAFONTMAP_H_
 
 #include <memory>
 #include <vector>
@@ -18,14 +18,14 @@
 class CPDF_Dictionary;
 class CPDF_Document;
 
-class CBA_FontMap final : public IPVT_FontMap {
+class CPDF_BAFontMap final : public IPVT_FontMap {
  public:
   static int32_t GetNativeCharset();
 
-  CBA_FontMap(CPDF_Document* pDocument,
-              CPDF_Dictionary* pAnnotDict,
-              const ByteString& sAPType);
-  ~CBA_FontMap() override;
+  CPDF_BAFontMap(CPDF_Document* pDocument,
+                 CPDF_Dictionary* pAnnotDict,
+                 const ByteString& sAPType);
+  ~CPDF_BAFontMap() override;
 
   // IPVT_FontMap
   RetainPtr<CPDF_Font> GetPDFFont(int32_t nFontIndex) override;
@@ -90,4 +90,4 @@
   const ByteString m_sAPType;
 };
 
-#endif  // CORE_FPDFDOC_CBA_FONTMAP_H_
+#endif  // CORE_FPDFDOC_CPDF_BAFONTMAP_H_
diff --git a/fpdfsdk/cpdfsdk_appstream.cpp b/fpdfsdk/cpdfsdk_appstream.cpp
index 443c121..58f03cb 100644
--- a/fpdfsdk/cpdfsdk_appstream.cpp
+++ b/fpdfsdk/cpdfsdk_appstream.cpp
@@ -19,7 +19,7 @@
 #include "core/fpdfapi/parser/cpdf_stream.h"
 #include "core/fpdfapi/parser/cpdf_string.h"
 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 #include "core/fpdfdoc/cpdf_formcontrol.h"
 #include "core/fpdfdoc/cpdf_icon.h"
 #include "core/fpdfdoc/cpvt_word.h"
@@ -1252,8 +1252,8 @@
 
   CPDF_IconFit iconFit = pControl->GetIconFit();
   {
-    CBA_FontMap font_map(widget_->GetPDFPage()->GetDocument(),
-                         widget_->GetPDFAnnot()->GetAnnotDict(), "N");
+    CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
+                            widget_->GetPDFAnnot()->GetAnnotDict(), "N");
     ByteString csAP =
         GetRectFillAppStream(rcWindow, crBackground) +
         GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
@@ -1279,8 +1279,8 @@
     }
   }
   {
-    CBA_FontMap font_map(widget_->GetPDFPage()->GetDocument(),
-                         widget_->GetPDFAnnot()->GetAnnotDict(), "R");
+    CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
+                            widget_->GetPDFAnnot()->GetAnnotDict(), "R");
     ByteString csAP =
         GetRectFillAppStream(rcWindow, crBackground) +
         GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
@@ -1315,8 +1315,8 @@
     }
   }
   {
-    CBA_FontMap font_map(widget_->GetPDFPage()->GetDocument(),
-                         widget_->GetPDFAnnot()->GetAnnotDict(), "D");
+    CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
+                            widget_->GetPDFAnnot()->GetAnnotDict(), "D");
     ByteString csAP =
         GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
         GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
@@ -1566,8 +1566,8 @@
   rcButton.Normalize();
 
   // Font map must outlive |pEdit|.
-  CBA_FontMap font_map(widget_->GetPDFPage()->GetDocument(),
-                       widget_->GetPDFAnnot()->GetAnnotDict(), "N");
+  CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
+                          widget_->GetPDFAnnot()->GetAnnotDict(), "N");
 
   auto pEdit = std::make_unique<CPWL_EditImpl>();
   pEdit->EnableRefresh(false);
@@ -1632,8 +1632,8 @@
   std::ostringstream sBody;
 
   // Font map must outlive |pEdit|.
-  CBA_FontMap font_map(widget_->GetPDFPage()->GetDocument(),
-                       widget_->GetPDFAnnot()->GetAnnotDict(), "N");
+  CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
+                          widget_->GetPDFAnnot()->GetAnnotDict(), "N");
 
   auto pEdit = std::make_unique<CPWL_EditImpl>();
   pEdit->EnableRefresh(false);
@@ -1716,8 +1716,8 @@
   std::ostringstream sLines;
 
   // Font map must outlive |pEdit|.
-  CBA_FontMap font_map(widget_->GetPDFPage()->GetDocument(),
-                       widget_->GetPDFAnnot()->GetAnnotDict(), "N");
+  CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
+                          widget_->GetPDFAnnot()->GetAnnotDict(), "N");
 
   auto pEdit = std::make_unique<CPWL_EditImpl>();
   pEdit->EnableRefresh(false);
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index a3a932b..c29cf14 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -16,7 +16,7 @@
 #include "core/fpdfapi/parser/cpdf_reference.h"
 #include "core/fpdfapi/parser/cpdf_stream.h"
 #include "core/fpdfapi/parser/cpdf_string.h"
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 #include "core/fpdfdoc/cpdf_defaultappearance.h"
 #include "core/fpdfdoc/cpdf_formcontrol.h"
 #include "core/fpdfdoc/cpdf_formfield.h"
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 75aa2f0..3a54ba0 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -9,7 +9,7 @@
 #include <utility>
 
 #include "constants/form_flags.h"
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index f60d571..ef60ab1 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -9,7 +9,7 @@
 #include <utility>
 
 #include "constants/form_flags.h"
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index c2cdca7..2a223d6 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -9,7 +9,7 @@
 #include <utility>
 
 #include "constants/form_flags.h"
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/pwl/cpwl_edit.h"
diff --git a/fpdfsdk/formfiller/cffl_textobject.cpp b/fpdfsdk/formfiller/cffl_textobject.cpp
index a055670..71e6ed9 100644
--- a/fpdfsdk/formfiller/cffl_textobject.cpp
+++ b/fpdfsdk/formfiller/cffl_textobject.cpp
@@ -7,7 +7,7 @@
 #include "fpdfsdk/formfiller/cffl_textobject.h"
 
 #include "core/fpdfapi/page/cpdf_page.h"
-#include "core/fpdfdoc/cba_fontmap.h"
+#include "core/fpdfdoc/cpdf_bafontmap.h"
 
 CPWL_Wnd* CFFL_TextObject::ResetPWLWindow(CPDFSDK_PageView* pPageView,
                                           bool bRestoreValue) {
@@ -33,9 +33,9 @@
   DestroyWindows();
 }
 
-CBA_FontMap* CFFL_TextObject::MaybeCreateFontMap() {
+CPDF_BAFontMap* CFFL_TextObject::MaybeCreateFontMap() {
   if (!m_pFontMap) {
-    m_pFontMap = std::make_unique<CBA_FontMap>(
+    m_pFontMap = std::make_unique<CPDF_BAFontMap>(
         m_pWidget->GetPDFPage()->GetDocument(),
         m_pWidget->GetPDFAnnot()->GetAnnotDict(), "N");
   }
diff --git a/fpdfsdk/formfiller/cffl_textobject.h b/fpdfsdk/formfiller/cffl_textobject.h
index a2381af..050f3ec 100644
--- a/fpdfsdk/formfiller/cffl_textobject.h
+++ b/fpdfsdk/formfiller/cffl_textobject.h
@@ -11,7 +11,7 @@
 
 #include "fpdfsdk/formfiller/cffl_formfiller.h"
 
-class CBA_FontMap;
+class CPDF_BAFontMap;
 
 // Class to implement common functionality for CFFL_FormFiller sub-classes with
 // text fields.
@@ -25,10 +25,10 @@
   CFFL_TextObject(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
   ~CFFL_TextObject() override;
 
-  CBA_FontMap* MaybeCreateFontMap();
+  CPDF_BAFontMap* MaybeCreateFontMap();
 
  private:
-  std::unique_ptr<CBA_FontMap> m_pFontMap;
+  std::unique_ptr<CPDF_BAFontMap> m_pFontMap;
 };
 
 #endif  // FPDFSDK_FORMFILLER_CFFL_TEXTOBJECT_H_