summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-16 22:08:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-16 22:08:07 +0000
commit1c4735aed9442a8e442214a23a3df94bd8fc99b5 (patch)
tree37264efcc3a1d90e3a9f05384d283923c828242f /fpdfsdk
parent3f1c832dda209cf6682bb75316c07d71332fe6c3 (diff)
downloadpdfium-1c4735aed9442a8e442214a23a3df94bd8fc99b5.tar.xz
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>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_datetime.cpp15
-rw-r--r--fpdfsdk/fpdf_flatten.cpp16
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp14
-rw-r--r--fpdfsdk/fpdfattachment.cpp12
-rw-r--r--fpdfsdk/fpdfeditpage.cpp6
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp5
-rw-r--r--fpdfsdk/pwl/cpwl_font_map.cpp4
7 files changed, 29 insertions, 43 deletions
diff --git a/fpdfsdk/cpdfsdk_datetime.cpp b/fpdfsdk/cpdfsdk_datetime.cpp
index ce22cae12f..332ae8e62e 100644
--- a/fpdfsdk/cpdfsdk_datetime.cpp
+++ b/fpdfsdk/cpdfsdk_datetime.cpp
@@ -264,16 +264,11 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
}
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 35d3617627..07fbd7cd9e 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -173,8 +173,8 @@ uint32_t NewIndirectContentsStream(const ByteString& key,
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 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
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 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
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 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
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 dcf19f2be7..b607dffc4e 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -114,15 +114,11 @@ FPDFPage_TransFormWithClip(FPDF_PAGE page,
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 7402114756..8b3c8fe20a 100644
--- a/fpdfsdk/fpdfattachment.cpp
+++ b/fpdfsdk/fpdfattachment.cpp
@@ -232,11 +232,13 @@ FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment,
// 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 db726b74f0..a032bf6607 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -105,9 +105,9 @@ FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument() {
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 374fe566fc..bc6c7dbe13 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -434,9 +434,8 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
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 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
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 522b6ef67f..4a2ac4bcb8 100644
--- a/fpdfsdk/pwl/cpwl_font_map.cpp
+++ b/fpdfsdk/pwl/cpwl_font_map.cpp
@@ -260,9 +260,7 @@ CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc,
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) {