Convert some WideString::Format() calls to FormatInteger()

Avoid mucking with generic format strings and varying sized buffers.

Change-Id: I5c3ac45820a834af7bf69f39800345dae34bfb4c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93031
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp
index 2558ada..6c35f43 100644
--- a/core/fpdfdoc/cpdf_pagelabel.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel.cpp
@@ -53,7 +53,7 @@
   if (bsStyle.IsEmpty())
     return WideString();
   if (bsStyle == "D")
-    return WideString::Format(L"%d", num);
+    return WideString::FormatInteger(num);
   if (bsStyle == "R") {
     WideString wsNumPortion = MakeRoman(num);
     wsNumPortion.MakeUpper();
@@ -103,10 +103,10 @@
     n--;
   }
 
-  WideString label;
   if (pValue) {
     pValue = pValue->GetDirect();
     if (const CPDF_Dictionary* pLabel = pValue->AsDictionary()) {
+      WideString label;
       if (pLabel->KeyExist("P"))
         label += pLabel->GetUnicodeTextFor("P");
 
@@ -117,6 +117,5 @@
       return label;
     }
   }
-  label = WideString::Format(L"%d", nPage + 1);
-  return label;
+  return WideString::FormatInteger(nPage + 1);
 }
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 89c6cfe..b55e26a 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -486,23 +486,23 @@
               sPart += c;
               break;
             case 'm':
-              sPart = WideString::Format(L"%d", nMonth);
+              sPart = WideString::FormatInteger(nMonth);
               break;
             case 'd':
-              sPart = WideString::Format(L"%d", nDay);
+              sPart = WideString::FormatInteger(nDay);
               break;
             case 'H':
-              sPart = WideString::Format(L"%d", nHour);
+              sPart = WideString::FormatInteger(nHour);
               break;
             case 'h':
               sPart =
-                  WideString::Format(L"%d", nHour > 12 ? nHour - 12 : nHour);
+                  WideString::FormatInteger(nHour > 12 ? nHour - 12 : nHour);
               break;
             case 'M':
-              sPart = WideString::Format(L"%d", nMin);
+              sPart = WideString::FormatInteger(nMin);
               break;
             case 's':
-              sPart = WideString::Format(L"%d", nSec);
+              sPart = WideString::FormatInteger(nSec);
               break;
             case 't':
               sPart += nHour > 12 ? 'p' : 'a';
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index fb9fe7d..467d626 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -249,7 +249,7 @@
         continue;
       }
       cFormat.replace(nFound, 1,
-                      WideString::Format(L"%d", cTableAd[i].value).c_str());
+                      WideString::FormatInteger(cTableAd[i].value).c_str());
     }
   }
 
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index ecb4eed..bbd5a25 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -292,7 +292,7 @@
       absl::optional<int32_t> iValue = TryInteger(eAttr, bUseDefault);
       if (!iValue.has_value())
         return absl::nullopt;
-      return WideString::Format(L"%d", iValue.value());
+      return WideString::FormatInteger(iValue.value());
     }
     case XFA_AttributeType::Measure: {
       absl::optional<CXFA_Measurement> value = TryMeasure(eAttr, bUseDefault);
@@ -337,7 +337,7 @@
   CFX_XMLElement* elem = SetValue(eAttr, iValue, bNotify);
   if (elem) {
     elem->SetAttribute(WideString::FromASCII(XFA_AttributeToName(eAttr)),
-                       WideString::Format(L"%d", iValue));
+                       WideString::FormatInteger(iValue));
   }
 }
 
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index b04dac3..cd2cb68 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -333,7 +333,7 @@
   float fDayMaxW = 0.0f;
   float fDayMaxH = 0.0f;
   for (int day = 10; day <= 31; day++) {
-    CFX_SizeF sz = CalcTextSize(WideString::Format(L"%d", day), false);
+    CFX_SizeF sz = CalcTextSize(WideString::FormatInteger(day), false);
     fDayMaxW = (fDayMaxW >= sz.width) ? fDayMaxW : sz.width;
     fDayMaxH = (fDayMaxH >= sz.height) ? fDayMaxH : sz.height;
   }
@@ -478,7 +478,7 @@
     const bool bSelected = pdfium::Contains(m_SelDayArray, i + 1);
     m_DateArray.push_back(
         std::make_unique<DATEINFO>(i + 1, iDayOfWeek, bFlagged, bSelected,
-                                   WideString::Format(L"%d", i + 1)));
+                                   WideString::FormatInteger(i + 1)));
   }
 }