Rename CFGAS_FormatString to CFGAS_StringFormatter.

Because it is an object that can format strings, not a string
that contains format directives. Longstanding irritation.

Change-Id: Iae3849593ed64b0c0eed41b35a56027fa34207e8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51770
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fgas/BUILD.gn b/xfa/fgas/BUILD.gn
index 76db6a1..04b4a92 100644
--- a/xfa/fgas/BUILD.gn
+++ b/xfa/fgas/BUILD.gn
@@ -12,8 +12,8 @@
   sources = [
     "crt/cfgas_decimal.cpp",
     "crt/cfgas_decimal.h",
-    "crt/cfgas_formatstring.cpp",
-    "crt/cfgas_formatstring.h",
+    "crt/cfgas_stringformatter.cpp",
+    "crt/cfgas_stringformatter.h",
     "crt/locale_iface.h",
     "crt/locale_mgr_iface.h",
     "font/cfgas_defaultfontmanager.cpp",
@@ -50,7 +50,7 @@
 pdfium_unittest_source_set("unittests") {
   sources = [
     "crt/cfgas_decimal_unittest.cpp",
-    "crt/cfgas_formatstring_unittest.cpp",
+    "crt/cfgas_stringformatter_unittest.cpp",
   ]
   deps = [
     ":fgas",
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_stringformatter.cpp
similarity index 96%
rename from xfa/fgas/crt/cfgas_formatstring.cpp
rename to xfa/fgas/crt/cfgas_stringformatter.cpp
index 7dccda0..96f6fbc 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_stringformatter.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "xfa/fgas/crt/cfgas_formatstring.h"
+#include "xfa/fgas/crt/cfgas_stringformatter.h"
 
 #include <algorithm>
 #include <utility>
@@ -824,12 +824,12 @@
   return true;
 }
 
-CFGAS_FormatString::CFGAS_FormatString(LocaleMgrIface* pLocaleMgr)
+CFGAS_StringFormatter::CFGAS_StringFormatter(LocaleMgrIface* pLocaleMgr)
     : m_pLocaleMgr(pLocaleMgr) {}
 
-CFGAS_FormatString::~CFGAS_FormatString() {}
+CFGAS_StringFormatter::~CFGAS_StringFormatter() {}
 
-void CFGAS_FormatString::SplitFormatString(
+void CFGAS_StringFormatter::SplitFormatString(
     const WideString& wsFormatString,
     std::vector<WideString>* wsPatterns) const {
   int32_t iStrLen = wsFormatString.GetLength();
@@ -852,7 +852,7 @@
   }
 }
 
-FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(
+FX_LOCALECATEGORY CFGAS_StringFormatter::GetCategory(
     const WideString& wsPattern) const {
   FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown;
   pdfium::span<const wchar_t> spPattern = wsPattern.AsSpan();
@@ -906,8 +906,9 @@
   return eCategory;
 }
 
-WideString CFGAS_FormatString::GetTextFormat(const WideString& wsPattern,
-                                             WideStringView wsCategory) const {
+WideString CFGAS_StringFormatter::GetTextFormat(
+    const WideString& wsPattern,
+    WideStringView wsCategory) const {
   size_t ccf = 0;
   pdfium::span<const wchar_t> spPattern = wsPattern.AsSpan();
   bool bBrackOpen = false;
@@ -953,7 +954,7 @@
   return wsPurgePattern;
 }
 
-LocaleIface* CFGAS_FormatString::GetNumericFormat(
+LocaleIface* CFGAS_StringFormatter::GetNumericFormat(
     const WideString& wsPattern,
     size_t* iDotIndex,
     uint32_t* dwStyle,
@@ -1058,9 +1059,9 @@
   return pLocale;
 }
 
-bool CFGAS_FormatString::ParseText(const WideString& wsSrcText,
-                                   const WideString& wsPattern,
-                                   WideString* wsValue) const {
+bool CFGAS_StringFormatter::ParseText(const WideString& wsSrcText,
+                                      const WideString& wsPattern,
+                                      WideString* wsValue) const {
   wsValue->clear();
   if (wsSrcText.IsEmpty() || wsPattern.IsEmpty())
     return false;
@@ -1130,9 +1131,9 @@
   return iPattern == spTextFormat.size() && iText == spSrcText.size();
 }
 
-bool CFGAS_FormatString::ParseNum(const WideString& wsSrcNum,
-                                  const WideString& wsPattern,
-                                  WideString* wsValue) const {
+bool CFGAS_StringFormatter::ParseNum(const WideString& wsSrcNum,
+                                     const WideString& wsPattern,
+                                     WideString* wsValue) const {
   wsValue->clear();
   if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty())
     return false;
@@ -1544,7 +1545,7 @@
   return true;
 }
 
-FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat(
+FX_DATETIMETYPE CFGAS_StringFormatter::GetDateTimeFormat(
     const WideString& wsPattern,
     LocaleIface** pLocale,
     WideString* wsDatePattern,
@@ -1681,10 +1682,10 @@
   return (FX_DATETIMETYPE)iFindCategory;
 }
 
-bool CFGAS_FormatString::ParseDateTime(const WideString& wsSrcDateTime,
-                                       const WideString& wsPattern,
-                                       FX_DATETIMETYPE eDateTimeType,
-                                       CFX_DateTime* dtValue) const {
+bool CFGAS_StringFormatter::ParseDateTime(const WideString& wsSrcDateTime,
+                                          const WideString& wsPattern,
+                                          FX_DATETIMETYPE eDateTimeType,
+                                          CFX_DateTime* dtValue) const {
   dtValue->Reset();
   if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty())
     return false;
@@ -1726,8 +1727,8 @@
   return true;
 }
 
-bool CFGAS_FormatString::ParseZero(const WideString& wsSrcText,
-                                   const WideString& wsPattern) const {
+bool CFGAS_StringFormatter::ParseZero(const WideString& wsSrcText,
+                                      const WideString& wsPattern) const {
   WideString wsTextFormat = GetTextFormat(wsPattern, L"zero");
   pdfium::span<const wchar_t> spSrcText = wsSrcText.AsSpan();
   pdfium::span<const wchar_t> spTextFormat = wsTextFormat.AsSpan();
@@ -1755,8 +1756,8 @@
   return iPattern == spTextFormat.size() && iText == spSrcText.size();
 }
 
-bool CFGAS_FormatString::ParseNull(const WideString& wsSrcText,
-                                   const WideString& wsPattern) const {
+bool CFGAS_StringFormatter::ParseNull(const WideString& wsSrcText,
+                                      const WideString& wsPattern) const {
   WideString wsTextFormat = GetTextFormat(wsPattern, L"null");
   pdfium::span<const wchar_t> spSrcText = wsSrcText.AsSpan();
   pdfium::span<const wchar_t> spTextFormat = wsTextFormat.AsSpan();
@@ -1784,9 +1785,9 @@
   return iPattern == spTextFormat.size() && iText == spSrcText.size();
 }
 
-bool CFGAS_FormatString::FormatText(const WideString& wsSrcText,
-                                    const WideString& wsPattern,
-                                    WideString* wsOutput) const {
+bool CFGAS_StringFormatter::FormatText(const WideString& wsSrcText,
+                                       const WideString& wsPattern,
+                                       WideString* wsOutput) const {
   if (wsPattern.IsEmpty() || wsSrcText.IsEmpty())
     return false;
 
@@ -1843,9 +1844,9 @@
   return iText == spSrcText.size();
 }
 
-bool CFGAS_FormatString::FormatNum(const WideString& wsInputNum,
-                                   const WideString& wsPattern,
-                                   WideString* wsOutput) const {
+bool CFGAS_StringFormatter::FormatNum(const WideString& wsInputNum,
+                                      const WideString& wsPattern,
+                                      WideString* wsOutput) const {
   if (wsInputNum.IsEmpty() || wsPattern.IsEmpty())
     return false;
 
@@ -2189,10 +2190,10 @@
   return true;
 }
 
-bool CFGAS_FormatString::FormatDateTime(const WideString& wsSrcDateTime,
-                                        const WideString& wsPattern,
-                                        FX_DATETIMETYPE eDateTimeType,
-                                        WideString* wsOutput) const {
+bool CFGAS_StringFormatter::FormatDateTime(const WideString& wsSrcDateTime,
+                                           const WideString& wsPattern,
+                                           FX_DATETIMETYPE eDateTimeType,
+                                           WideString* wsOutput) const {
   if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty())
     return false;
 
@@ -2247,8 +2248,8 @@
   return false;
 }
 
-bool CFGAS_FormatString::FormatZero(const WideString& wsPattern,
-                                    WideString* wsOutput) const {
+bool CFGAS_StringFormatter::FormatZero(const WideString& wsPattern,
+                                       WideString* wsOutput) const {
   if (wsPattern.IsEmpty())
     return false;
 
@@ -2264,8 +2265,8 @@
   return true;
 }
 
-bool CFGAS_FormatString::FormatNull(const WideString& wsPattern,
-                                    WideString* wsOutput) const {
+bool CFGAS_StringFormatter::FormatNull(const WideString& wsPattern,
+                                       WideString* wsOutput) const {
   if (wsPattern.IsEmpty())
     return false;
 
diff --git a/xfa/fgas/crt/cfgas_formatstring.h b/xfa/fgas/crt/cfgas_stringformatter.h
similarity index 91%
rename from xfa/fgas/crt/cfgas_formatstring.h
rename to xfa/fgas/crt/cfgas_stringformatter.h
index aed49e0..906508f 100644
--- a/xfa/fgas/crt/cfgas_formatstring.h
+++ b/xfa/fgas/crt/cfgas_stringformatter.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef XFA_FGAS_CRT_CFGAS_FORMATSTRING_H_
-#define XFA_FGAS_CRT_CFGAS_FORMATSTRING_H_
+#ifndef XFA_FGAS_CRT_CFGAS_STRINGFORMATTER_H_
+#define XFA_FGAS_CRT_CFGAS_STRINGFORMATTER_H_
 
 #include <vector>
 
@@ -20,10 +20,10 @@
                           pdfium::span<const wchar_t> wsTime,
                           CFX_DateTime* datetime);
 
-class CFGAS_FormatString {
+class CFGAS_StringFormatter {
  public:
-  explicit CFGAS_FormatString(LocaleMgrIface* pLocaleMgr);
-  ~CFGAS_FormatString();
+  explicit CFGAS_StringFormatter(LocaleMgrIface* pLocaleMgr);
+  ~CFGAS_StringFormatter();
 
   void SplitFormatString(const WideString& wsFormatString,
                          std::vector<WideString>* wsPatterns) const;
@@ -72,4 +72,4 @@
   UnownedPtr<LocaleMgrIface> const m_pLocaleMgr;
 };
 
-#endif  // XFA_FGAS_CRT_CFGAS_FORMATSTRING_H_
+#endif  // XFA_FGAS_CRT_CFGAS_STRINGFORMATTER_H_
diff --git a/xfa/fgas/crt/cfgas_formatstring_unittest.cpp b/xfa/fgas/crt/cfgas_stringformatter_unittest.cpp
similarity index 95%
rename from xfa/fgas/crt/cfgas_formatstring_unittest.cpp
rename to xfa/fgas/crt/cfgas_stringformatter_unittest.cpp
index 50877e1..478f053 100644
--- a/xfa/fgas/crt/cfgas_formatstring_unittest.cpp
+++ b/xfa/fgas/crt/cfgas_stringformatter_unittest.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "xfa/fgas/crt/cfgas_formatstring.h"
+#include "xfa/fgas/crt/cfgas_stringformatter.h"
 
 #include <time.h>
 
@@ -16,14 +16,14 @@
 #include "third_party/base/ptr_util.h"
 #include "xfa/fxfa/parser/cxfa_localemgr.h"
 
-class CFGAS_FormatStringTest : public testing::Test {
+class CFGAS_StringFormatterTest : public testing::Test {
  public:
-  CFGAS_FormatStringTest() {
+  CFGAS_StringFormatterTest() {
     SetTZ("UTC");
     CPDF_ModuleMgr::Get()->Init();
   }
 
-  ~CFGAS_FormatStringTest() override { CPDF_ModuleMgr::Get()->Destroy(); }
+  ~CFGAS_StringFormatterTest() override { CPDF_ModuleMgr::Get()->Destroy(); }
 
   void TearDown() override {
     fmt_.reset();
@@ -42,21 +42,21 @@
 
   // Note, this re-creates the fmt on each call. If you need to multiple
   // times store it locally.
-  CFGAS_FormatString* fmt(const WideString& locale) {
+  CFGAS_StringFormatter* fmt(const WideString& locale) {
     fmt_.reset();  // Can't outlive |mgr_|.
     mgr_ = pdfium::MakeUnique<CXFA_LocaleMgr>(nullptr, locale);
-    fmt_ = pdfium::MakeUnique<CFGAS_FormatString>(mgr_.get());
+    fmt_ = pdfium::MakeUnique<CFGAS_StringFormatter>(mgr_.get());
     return fmt_.get();
   }
 
  protected:
   std::unique_ptr<CXFA_LocaleMgr> mgr_;
-  std::unique_ptr<CFGAS_FormatString> fmt_;
+  std::unique_ptr<CFGAS_StringFormatter> fmt_;
 };
 
 // TODO(dsinclair): Looks like the formatter/parser does not handle the various
 // 'g' flags.
-TEST_F(CFGAS_FormatStringTest, DateFormat) {
+TEST_F(CFGAS_StringFormatterTest, DateFormat) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -120,7 +120,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, TimeFormat) {
+TEST_F(CFGAS_StringFormatterTest, TimeFormat) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -171,7 +171,7 @@
   SetTZ("UTC");
 }
 
-TEST_F(CFGAS_FormatStringTest, DateTimeFormat) {
+TEST_F(CFGAS_StringFormatterTest, DateTimeFormat) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -199,7 +199,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, DateParse) {
+TEST_F(CFGAS_StringFormatterTest, DateParse) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -262,7 +262,7 @@
 
 // TODO(dsinclair): GetDateTimeFormat is broken and doesn't allow just returning
 // a parsed Time. It will assume it's a Date. The method needs to be re-written.
-// TEST_F(CFGAS_FormatStringTest, TimeParse) {
+// TEST_F(CFGAS_StringFormatterTest, TimeParse) {
 //   struct {
 //     const wchar_t* locale;
 //     const wchar_t* input;
@@ -287,7 +287,7 @@
 //   }
 // }
 
-TEST_F(CFGAS_FormatStringTest, SplitFormatString) {
+TEST_F(CFGAS_StringFormatterTest, SplitFormatString) {
   std::vector<WideString> results;
   fmt(L"en")->SplitFormatString(
       L"null{'No data'} | null{} | text{999*9999} | text{999*999*9999}",
@@ -302,7 +302,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, NumParse) {
+TEST_F(CFGAS_StringFormatterTest, NumParse) {
   struct TestCase {
     const wchar_t* locale;
     const wchar_t* input;
@@ -443,7 +443,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, NumFormat) {
+TEST_F(CFGAS_StringFormatterTest, NumFormat) {
   struct TestCase {
     const wchar_t* locale;
     const wchar_t* input;
@@ -559,7 +559,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, TextParse) {
+TEST_F(CFGAS_StringFormatterTest, TextParse) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -584,13 +584,13 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, InvalidTextParse) {
+TEST_F(CFGAS_StringFormatterTest, InvalidTextParse) {
   // Input does not match mask.
   WideString result;
   EXPECT_FALSE(fmt(L"en")->ParseText(L"123-4567-8", L"AAA-9999-X", &result));
 }
 
-TEST_F(CFGAS_FormatStringTest, TextFormat) {
+TEST_F(CFGAS_StringFormatterTest, TextFormat) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -614,13 +614,14 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, NullParse) {
+TEST_F(CFGAS_StringFormatterTest, NullParse) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
     const wchar_t* pattern;
   } tests[] = {
-      {L"en", L"", L"null{}"}, {L"en", L"No data", L"null{'No data'}"},
+      {L"en", L"", L"null{}"},
+      {L"en", L"No data", L"null{'No data'}"},
   };
 
   for (size_t i = 0; i < FX_ArraySize(tests); ++i) {
@@ -630,7 +631,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, NullFormat) {
+TEST_F(CFGAS_StringFormatterTest, NullFormat) {
   struct {
     const wchar_t* locale;
     const wchar_t* pattern;
@@ -644,7 +645,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, ZeroParse) {
+TEST_F(CFGAS_StringFormatterTest, ZeroParse) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -660,7 +661,7 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, ZeroFormat) {
+TEST_F(CFGAS_StringFormatterTest, ZeroFormat) {
   struct {
     const wchar_t* locale;
     const wchar_t* input;
@@ -682,8 +683,8 @@
   }
 }
 
-TEST_F(CFGAS_FormatStringTest, GetCategory) {
-  CFGAS_FormatString* f = fmt(L"en");
+TEST_F(CFGAS_StringFormatterTest, GetCategory) {
+  CFGAS_StringFormatter* f = fmt(L"en");
 
   EXPECT_EQ(FX_LOCALECATEGORY_Unknown, f->GetCategory(L"'just text'"));
   EXPECT_EQ(FX_LOCALECATEGORY_Null, f->GetCategory(L"null{}"));
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 23b9a9a..0b9ce1f 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -14,7 +14,7 @@
 #include "third_party/base/ptr_util.h"
 #include "third_party/base/span.h"
 #include "third_party/base/stl_util.h"
-#include "xfa/fgas/crt/cfgas_formatstring.h"
+#include "xfa/fgas/crt/cfgas_stringformatter.h"
 #include "xfa/fxfa/parser/cxfa_document.h"
 #include "xfa/fxfa/parser/cxfa_localemgr.h"
 #include "xfa/fxfa/parser/xfa_utils.h"
@@ -130,7 +130,7 @@
   WideString wsOutput;
   ScopedLocale scoped_locale(m_pLocaleMgr.Get(), pLocale);
 
-  auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
+  auto pFormat = pdfium::MakeUnique<CFGAS_StringFormatter>(m_pLocaleMgr.Get());
   std::vector<WideString> wsPatterns;
   pFormat->SplitFormatString(wsPattern, &wsPatterns);
 
@@ -262,7 +262,7 @@
                                       const WideString& wsFormat,
                                       LocaleIface* pLocale,
                                       XFA_VALUEPICTURE eValueType) const {
-  auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
+  auto pFormat = pdfium::MakeUnique<CFGAS_StringFormatter>(m_pLocaleMgr.Get());
   std::vector<WideString> wsPatterns;
   pFormat->SplitFormatString(wsFormat, &wsPatterns);
   wsResult.clear();
@@ -284,7 +284,7 @@
 
   wsResult.clear();
   bool bRet = false;
-  auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
+  auto pFormat = pdfium::MakeUnique<CFGAS_StringFormatter>(m_pLocaleMgr.Get());
   FX_LOCALECATEGORY eCategory =
       ValueCategory(pFormat->GetCategory(wsFormat), m_dwType);
   switch (eCategory) {
@@ -548,7 +548,7 @@
 
   ScopedLocale scoped_locale(m_pLocaleMgr.Get(), pLocale);
 
-  auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
+  auto pFormat = pdfium::MakeUnique<CFGAS_StringFormatter>(m_pLocaleMgr.Get());
   std::vector<WideString> wsPatterns;
   pFormat->SplitFormatString(wsPattern, &wsPatterns);
   bool bRet = false;