Convert ByteString::{Format|FormatV} to static methods

This CL moves the Format and FormatV methods of ByteString to be static.

Bug: pdfium:934
Change-Id: I9c30455a789aff9f619b9d5bf89c0712644f2d9a
Reviewed-on: https://pdfium-review.googlesource.com/18650
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_datetime.cpp b/fpdfsdk/cpdfsdk_datetime.cpp
index ce22cae..332ae8e 100644
--- a/fpdfsdk/cpdfsdk_datetime.cpp
+++ b/fpdfsdk/cpdfsdk_datetime.cpp
@@ -264,16 +264,11 @@
 }
 
 ByteString CPDFSDK_DateTime::ToCommonDateTimeString() {
-  ByteString str1;
-  str1.Format("%04d-%02u-%02u %02u:%02u:%02u ", m_year, m_month, m_day, m_hour,
-              m_minute, m_second);
-  if (m_tzHour < 0)
-    str1 += "-";
-  else
-    str1 += "+";
-  ByteString str2;
-  str2.Format("%02d:%02u", std::abs(static_cast<int>(m_tzHour)), m_tzMinute);
-  return str1 + str2;
+  return ByteString::Format("%04d-%02u-%02u %02u:%02u:%02u ", m_year, m_month,
+                            m_day, m_hour, m_minute, m_second) +
+         (m_tzHour < 0 ? "-" : "+") +
+         ByteString::Format("%02d:%02u", std::abs(static_cast<int>(m_tzHour)),
+                            m_tzMinute);
 }
 
 ByteString CPDFSDK_DateTime::ToPDFDateTimeString() {
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index 35d3617..07fbd7c 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -173,8 +173,8 @@
   CPDF_Stream* pNewContents = pDocument->NewIndirect<CPDF_Stream>(
       nullptr, 0,
       pdfium::MakeUnique<CPDF_Dictionary>(pDocument->GetByteStringPool()));
-  ByteString sStream;
-  sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
+  ByteString sStream =
+      ByteString::Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
   pNewContents->SetData(sStream.raw_str(), sStream.GetLength());
   return pNewContents->GetObjNum();
 }
@@ -301,10 +301,9 @@
   ByteString key;
   int nStreams = pdfium::CollectionSize<int>(ObjectArray);
   if (nStreams > 0) {
-    ByteString sKey;
     int i = 0;
     while (i < INT_MAX) {
-      sKey.Format("FFT%d", i);
+      ByteString sKey = ByteString::Format("FFT%d", i);
       if (!pPageXObject->KeyExist(sKey)) {
         key = sKey;
         break;
@@ -391,8 +390,7 @@
     if (!pXObject)
       pXObject = pNewXORes->SetNewFor<CPDF_Dictionary>("XObject");
 
-    ByteString sFormName;
-    sFormName.Format("F%d", i);
+    ByteString sFormName = ByteString::Format("F%d", i);
     pXObject->SetNewFor<CPDF_Reference>(sFormName, pDocument,
                                         pObj->GetObjNum());
 
@@ -401,10 +399,8 @@
     ByteString sStream(pAcc->GetData(), pAcc->GetSize());
     CFX_Matrix matrix = pAPDic->GetMatrixFor("Matrix");
     CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix);
-    ByteString sTemp;
-    sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f,
-                 sFormName.c_str());
-    sStream += sTemp;
+    sStream += ByteString::Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d,
+                                  m.e, m.f, sFormName.c_str());
     pNewXObject->SetDataAndRemoveFilter(sStream.raw_str(), sStream.GetLength());
   }
   pPageDict->RemoveFor("Annots");
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index dcf19f2..b607dff 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -114,15 +114,11 @@
   textBuf << "q ";
   CFX_FloatRect rect = CFXFloatRectFromFSRECTF(*clipRect);
   rect.Normalize();
-  ByteString bsClipping;
-  bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
-                    rect.Width(), rect.Height());
-  textBuf << bsClipping;
 
-  ByteString bsMatix;
-  bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c,
-                 matrix->d, matrix->e, matrix->f);
-  textBuf << bsMatix;
+  textBuf << ByteString::Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
+                                rect.Width(), rect.Height());
+  textBuf << ByteString::Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,
+                                matrix->c, matrix->d, matrix->e, matrix->f);
 
   CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get();
   CPDF_Object* pContentObj = GetPageContent(pPageDict);
diff --git a/fpdfsdk/fpdfattachment.cpp b/fpdfsdk/fpdfattachment.cpp
index 7402114..8b3c8fe 100644
--- a/fpdfsdk/fpdfattachment.cpp
+++ b/fpdfsdk/fpdfattachment.cpp
@@ -232,11 +232,13 @@
   // Set the creation date of the new attachment in the dictionary.
   CFX_DateTime dateTime;
   dateTime.Now();
-  ByteString bsDateTime;
-  bsDateTime.Format("D:%d%02d%02d%02d%02d%02d", dateTime.GetYear(),
-                    dateTime.GetMonth(), dateTime.GetDay(), dateTime.GetHour(),
-                    dateTime.GetMinute(), dateTime.GetSecond());
-  pParamsDict->SetNewFor<CPDF_String>("CreationDate", bsDateTime, false);
+  pParamsDict->SetNewFor<CPDF_String>(
+      "CreationDate",
+      ByteString::Format("D:%d%02d%02d%02d%02d%02d", dateTime.GetYear(),
+                         dateTime.GetMonth(), dateTime.GetDay(),
+                         dateTime.GetHour(), dateTime.GetMinute(),
+                         dateTime.GetSecond()),
+      false);
 
   // Set the checksum of the new attachment in the dictionary.
   pParamsDict->SetNewFor<CPDF_String>(
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index db726b7..a032bf6 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -105,9 +105,9 @@
     if (time(&currentTime) != -1) {
       tm* pTM = localtime(&currentTime);
       if (pTM) {
-        DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900,
-                       pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min,
-                       pTM->tm_sec);
+        DateStr = ByteString::Format(
+            "D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900, pTM->tm_mon + 1,
+            pTM->tm_mday, pTM->tm_hour, pTM->tm_min, pTM->tm_sec);
       }
     }
   }
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 374fe56..bc6c7db 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -434,9 +434,8 @@
     return;
 
   RetainPtr<IFX_SeekableStream> fileWrite = MakeSeekableStream(pFileHandler);
-  ByteString content;
   if (fileType == FXFA_SAVEAS_XML) {
-    content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+    ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
     fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
                           content.GetLength());
     CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
@@ -492,7 +491,7 @@
         ByteString bPath = wPath.UTF8Encode();
         const char* szFormat =
             "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
-        content.Format(szFormat, bPath.c_str());
+        ByteString content = ByteString::Format(szFormat, bPath.c_str());
         fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
                               content.GetLength());
       }
diff --git a/fpdfsdk/pwl/cpwl_font_map.cpp b/fpdfsdk/pwl/cpwl_font_map.cpp
index 522b6ef..4a2ac4b 100644
--- a/fpdfsdk/pwl/cpwl_font_map.cpp
+++ b/fpdfsdk/pwl/cpwl_font_map.cpp
@@ -260,9 +260,7 @@
 
 ByteString CPWL_FontMap::EncodeFontAlias(const ByteString& sFontName,
                                          int32_t nCharset) {
-  ByteString sPostfix;
-  sPostfix.Format("_%02X", nCharset);
-  return EncodeFontAlias(sFontName) + sPostfix;
+  return EncodeFontAlias(sFontName) + ByteString::Format("_%02X", nCharset);
 }
 
 ByteString CPWL_FontMap::EncodeFontAlias(const ByteString& sFontName) {