From 275e260a6cd4a8e506ba974feb85ebcd926c1739 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 18 Sep 2017 14:23:18 -0400 Subject: Convert string class names Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez Commit-Queue: Ryan Harrison --- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 48 +++++++------- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 40 +++++------ fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 103 ++++++++++++++--------------- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h | 28 ++++---- 4 files changed, 108 insertions(+), 111 deletions(-) (limited to 'fpdfsdk/fpdfxfa') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 1032d49edc..8779c44186 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -219,19 +219,19 @@ v8::Isolate* CPDFXFA_Context::GetJSERuntime() const { return runtime->GetIsolate(); } -CFX_WideString CPDFXFA_Context::GetAppTitle() const { +WideString CPDFXFA_Context::GetAppTitle() const { return L"PDFium"; } -CFX_WideString CPDFXFA_Context::GetAppName() { +WideString CPDFXFA_Context::GetAppName() { return m_pFormFillEnv ? m_pFormFillEnv->FFI_GetAppName() : L""; } -CFX_WideString CPDFXFA_Context::GetLanguage() { +WideString CPDFXFA_Context::GetLanguage() { return m_pFormFillEnv ? m_pFormFillEnv->GetLanguage() : L""; } -CFX_WideString CPDFXFA_Context::GetPlatform() { +WideString CPDFXFA_Context::GetPlatform() { return m_pFormFillEnv ? m_pFormFillEnv->GetPlatform() : L""; } @@ -240,8 +240,8 @@ void CPDFXFA_Context::Beep(uint32_t dwType) { m_pFormFillEnv->JS_appBeep(dwType); } -int32_t CPDFXFA_Context::MsgBox(const CFX_WideString& wsMessage, - const CFX_WideString& wsTitle, +int32_t CPDFXFA_Context::MsgBox(const WideString& wsMessage, + const WideString& wsTitle, uint32_t dwIconType, uint32_t dwButtonType) { if (!m_pFormFillEnv) @@ -292,12 +292,12 @@ int32_t CPDFXFA_Context::MsgBox(const CFX_WideString& wsMessage, return XFA_IDYes; } -CFX_WideString CPDFXFA_Context::Response(const CFX_WideString& wsQuestion, - const CFX_WideString& wsTitle, - const CFX_WideString& wsDefaultAnswer, - bool bMark) { +WideString CPDFXFA_Context::Response(const WideString& wsQuestion, + const WideString& wsTitle, + const WideString& wsDefaultAnswer, + bool bMark) { if (!m_pFormFillEnv) - return CFX_WideString(); + return WideString(); int nLength = 2048; std::vector pBuff(nLength); @@ -305,27 +305,27 @@ CFX_WideString CPDFXFA_Context::Response(const CFX_WideString& wsQuestion, wsDefaultAnswer.c_str(), nullptr, bMark, pBuff.data(), nLength); if (nLength <= 0) - return CFX_WideString(); + return WideString(); nLength = std::min(2046, nLength); pBuff[nLength] = 0; pBuff[nLength + 1] = 0; - return CFX_WideString::FromUTF16LE(reinterpret_cast(pBuff.data()), - nLength / sizeof(uint16_t)); + return WideString::FromUTF16LE(reinterpret_cast(pBuff.data()), + nLength / sizeof(uint16_t)); } CFX_RetainPtr CPDFXFA_Context::DownloadURL( - const CFX_WideString& wsURL) { + const WideString& wsURL) { return m_pFormFillEnv ? m_pFormFillEnv->DownloadFromURL(wsURL.c_str()) : nullptr; } -bool CPDFXFA_Context::PostRequestURL(const CFX_WideString& wsURL, - const CFX_WideString& wsData, - const CFX_WideString& wsContentType, - const CFX_WideString& wsEncode, - const CFX_WideString& wsHeader, - CFX_WideString& wsResponse) { +bool CPDFXFA_Context::PostRequestURL(const WideString& wsURL, + const WideString& wsData, + const WideString& wsContentType, + const WideString& wsEncode, + const WideString& wsHeader, + WideString& wsResponse) { if (!m_pFormFillEnv) return false; @@ -335,9 +335,9 @@ bool CPDFXFA_Context::PostRequestURL(const CFX_WideString& wsURL, return true; } -bool CPDFXFA_Context::PutRequestURL(const CFX_WideString& wsURL, - const CFX_WideString& wsData, - const CFX_WideString& wsEncode) { +bool CPDFXFA_Context::PutRequestURL(const WideString& wsURL, + const WideString& wsData, + const WideString& wsEncode) { return m_pFormFillEnv && m_pFormFillEnv->PutRequestURL(wsURL.c_str(), wsData.c_str(), wsEncode.c_str()); diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index 586e12d5be..a0f90ab37b 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -56,31 +56,31 @@ class CPDFXFA_Context : public IXFA_AppProvider { void ClearChangeMark(); // IFXA_AppProvider: - CFX_WideString GetLanguage() override; - CFX_WideString GetPlatform() override; - CFX_WideString GetAppName() override; - CFX_WideString GetAppTitle() const override; + WideString GetLanguage() override; + WideString GetPlatform() override; + WideString GetAppName() override; + WideString GetAppTitle() const override; void Beep(uint32_t dwType) override; - int32_t MsgBox(const CFX_WideString& wsMessage, - const CFX_WideString& wsTitle, + int32_t MsgBox(const WideString& wsMessage, + const WideString& wsTitle, uint32_t dwIconType, uint32_t dwButtonType) override; - CFX_WideString Response(const CFX_WideString& wsQuestion, - const CFX_WideString& wsTitle, - const CFX_WideString& wsDefaultAnswer, - bool bMark) override; + WideString Response(const WideString& wsQuestion, + const WideString& wsTitle, + const WideString& wsDefaultAnswer, + bool bMark) override; CFX_RetainPtr DownloadURL( - const CFX_WideString& wsURL) override; - bool PostRequestURL(const CFX_WideString& wsURL, - const CFX_WideString& wsData, - const CFX_WideString& wsContentType, - const CFX_WideString& wsEncode, - const CFX_WideString& wsHeader, - CFX_WideString& wsResponse) override; - bool PutRequestURL(const CFX_WideString& wsURL, - const CFX_WideString& wsData, - const CFX_WideString& wsEncode) override; + const WideString& wsURL) override; + bool PostRequestURL(const WideString& wsURL, + const WideString& wsData, + const WideString& wsContentType, + const WideString& wsEncode, + const WideString& wsHeader, + WideString& wsResponse) override; + bool PutRequestURL(const WideString& wsURL, + const WideString& wsData, + const WideString& wsEncode) override; IFWL_AdapterTimerMgr* GetTimerMgr() override; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 65379254f0..b4dc3f1ed0 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -379,8 +379,7 @@ void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, } } -void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, - CFX_WideString& wsTitle) { +void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) { if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetPDFDoc()) return; @@ -388,13 +387,13 @@ void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, if (!pInfoDict) return; - CFX_ByteString csTitle = pInfoDict->GetStringFor("Title"); + ByteString csTitle = pInfoDict->GetStringFor("Title"); wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); csTitle.ReleaseBuffer(csTitle.GetLength()); } void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, - const CFX_WideString& wsTitle) { + const WideString& wsTitle) { if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetPDFDoc()) return; @@ -404,7 +403,7 @@ void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, } void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, - const CFX_WideString& wsFilePath, + const WideString& wsFilePath, bool bXDP) { if (hDoc != m_pContext->GetXFADoc()) return; @@ -419,14 +418,14 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, return; int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; - CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); + ByteString bs = wsFilePath.UTF16LE_Encode(); if (wsFilePath.IsEmpty()) { if (!pFormFillEnv->GetFormFillInfo() || !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) { return; } - CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse(); + WideString filepath = pFormFillEnv->JS_fieldBrowse(); bs = filepath.UTF16LE_Encode(); } int len = bs.GetLength(); @@ -439,7 +438,7 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, CFX_RetainPtr fileWrite = MakeSeekableStream(pFileHandler); - CFX_ByteString content; + ByteString content; if (fileType == FXFA_SAVEAS_XML) { content = "\r\n"; fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(), @@ -485,10 +484,10 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, continue; } if (i == size - 1) { - CFX_WideString wPath = CFX_WideString::FromUTF16LE( + WideString wPath = WideString::FromUTF16LE( reinterpret_cast(bs.c_str()), bs.GetLength() / sizeof(unsigned short)); - CFX_ByteString bPath = wPath.UTF8Encode(); + ByteString bPath = wPath.UTF8Encode(); const char* szFormat = "\n"; content.Format(szFormat, bPath.c_str()); @@ -505,7 +504,7 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, } void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideString& bsURL) { + const WideString& bsURL) { if (hDoc != m_pContext->GetXFADoc()) return; @@ -516,7 +515,7 @@ void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, if (!pFormFillEnv) return; - CFX_WideStringC str(bsURL.c_str()); + WideStringView str(bsURL.c_str()); pFormFillEnv->GotoURL(m_pContext.Get(), str); } @@ -644,9 +643,9 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { if (!pFormFillEnv) return false; - CFX_WideString ws; + WideString ws; ws.FromLocal(IDS_XFA_Validate_Input); - CFX_ByteString bs = ws.UTF16LE_Encode(); + ByteString bs = ws.UTF16LE_Encode(); int len = bs.GetLength(); pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 1); @@ -700,12 +699,12 @@ bool CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { CFX_RetainPtr CPDFXFA_DocEnvironment::OpenLinkedFile( CXFA_FFDoc* hDoc, - const CFX_WideString& wsLink) { + const WideString& wsLink) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); if (!pFormFillEnv) return nullptr; - CFX_ByteString bs = wsLink.UTF16LE_Encode(); + ByteString bs = wsLink.UTF16LE_Encode(); int len = bs.GetLength(); FPDF_FILEHANDLER* pFileHandler = pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); @@ -723,7 +722,7 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, if (!m_pContext->GetXFADocView()) return false; - CFX_ByteString content; + ByteString content; CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); if (!pFormFillEnv) return false; @@ -808,7 +807,7 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, return true; } -void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent, +void CPDFXFA_DocEnvironment::ToXFAContentFlags(WideString csSrcContent, FPDF_DWORD& flag) { if (csSrcContent.Contains(L" config ")) flag |= FXFA_CONFIG; @@ -830,19 +829,19 @@ void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent, } } -bool CPDFXFA_DocEnvironment::MailToInfo(CFX_WideString& csURL, - CFX_WideString& csToAddress, - CFX_WideString& csCCAddress, - CFX_WideString& csBCCAddress, - CFX_WideString& csSubject, - CFX_WideString& csMsg) { - CFX_WideString srcURL = csURL; +bool CPDFXFA_DocEnvironment::MailToInfo(WideString& csURL, + WideString& csToAddress, + WideString& csCCAddress, + WideString& csBCCAddress, + WideString& csSubject, + WideString& csMsg) { + WideString srcURL = csURL; srcURL.TrimLeft(); if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0) return false; auto pos = srcURL.Find(L'?'); - CFX_WideString tmp; + WideString tmp; if (!pos.has_value()) { pos = srcURL.Find(L'@'); if (!pos.has_value()) @@ -903,13 +902,13 @@ bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, if (!pFormFillEnv) return false; - CFX_WideStringC csURLC; + WideStringView csURLC; submit.GetSubmitTarget(csURLC); - CFX_WideString csURL(csURLC); + WideString csURL(csURLC); if (csURL.IsEmpty()) { - CFX_WideString ws; + WideString ws; ws.FromLocal("Submit cancelled."); - CFX_ByteString bs = ws.UTF16LE_Encode(); + ByteString bs = ws.UTF16LE_Encode(); int len = bs.GetLength(); pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 4); @@ -921,13 +920,13 @@ bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, int fileFlag = -1; switch (submit.GetSubmitFormat()) { case XFA_ATTRIBUTEENUM_Xdp: { - CFX_WideStringC csContentC; + WideStringView csContentC; submit.GetSubmitXDPContent(csContentC); - CFX_WideString csContent; + WideString csContent; csContent = csContentC; csContent.TrimLeft(); csContent.TrimRight(); - CFX_WideString space; + WideString space; space.FromLocal(" "); csContent = space + csContent + space; FPDF_DWORD flag = 0; @@ -958,20 +957,20 @@ bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, if (!pFileHandler) return false; if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { - CFX_WideString csToAddress; - CFX_WideString csCCAddress; - CFX_WideString csBCCAddress; - CFX_WideString csSubject; - CFX_WideString csMsg; + WideString csToAddress; + WideString csCCAddress; + WideString csBCCAddress; + WideString csSubject; + WideString csMsg; if (!MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, csMsg)) { return false; } - CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); - CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); - CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); - CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); - CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); + ByteString bsTo = WideString(csToAddress).UTF16LE_Encode(); + ByteString bsCC = WideString(csCCAddress).UTF16LE_Encode(); + ByteString bsBcc = WideString(csBCCAddress).UTF16LE_Encode(); + ByteString bsSubject = WideString(csSubject).UTF16LE_Encode(); + ByteString bsMsg = WideString(csMsg).UTF16LE_Encode(); FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); @@ -986,8 +985,8 @@ bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, bsMsg.ReleaseBuffer(bsMsg.GetStringLength()); } else { // HTTP or FTP - CFX_WideString ws; - CFX_ByteString bs = csURL.UTF16LE_Encode(); + WideString ws; + ByteString bs = csURL.UTF16LE_Encode(); int len = bs.GetLength(); pFormFillEnv->UploadTo(pFileHandler, fileFlag, (FPDF_WIDESTRING)bs.GetBuffer(len)); @@ -996,10 +995,9 @@ bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, return true; } -bool CPDFXFA_DocEnvironment::SetGlobalProperty( - CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, - CFXJSE_Value* pValue) { +bool CPDFXFA_DocEnvironment::SetGlobalProperty(CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) { if (hDoc != m_pContext->GetXFADoc()) return false; if (!m_pContext->GetFormFillEnv() || @@ -1013,10 +1011,9 @@ bool CPDFXFA_DocEnvironment::SetGlobalProperty( return bRet; } -bool CPDFXFA_DocEnvironment::GetGlobalProperty( - CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, - CFXJSE_Value* pValue) { +bool CPDFXFA_DocEnvironment::GetGlobalProperty(CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) { if (hDoc != m_pContext->GetXFADoc()) return false; if (!m_pContext->GetFormFillEnv() || diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h index 90bc6dea04..e6a0f926af 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h @@ -49,12 +49,12 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override; bool IsCalculationsEnabled(CXFA_FFDoc* hDoc) override; void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override; - void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) override; - void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) override; + void GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) override; + void SetTitle(CXFA_FFDoc* hDoc, const WideString& wsTitle) override; void ExportData(CXFA_FFDoc* hDoc, - const CFX_WideString& wsFilePath, + const WideString& wsFilePath, bool bXDP) override; - void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL) override; + void GotoURL(CXFA_FFDoc* hDoc, const WideString& bsURL) override; bool IsValidationsEnabled(CXFA_FFDoc* hDoc) override; void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override; void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; @@ -79,32 +79,32 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { bool SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override; bool GetGlobalProperty(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, + const ByteStringView& szPropName, CFXJSE_Value* pValue) override; bool SetGlobalProperty(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, + const ByteStringView& szPropName, CFXJSE_Value* pValue) override; CFX_RetainPtr OpenLinkedFile( CXFA_FFDoc* hDoc, - const CFX_WideString& wsLink) override; + const WideString& wsLink) override; private: bool OnBeforeNotifySubmit(); void OnAfterNotifySubmit(); bool NotifySubmit(bool bPrevOrPost); bool SubmitDataInternal(CXFA_FFDoc* hDoc, CXFA_Submit submit); - bool MailToInfo(CFX_WideString& csURL, - CFX_WideString& csToAddress, - CFX_WideString& csCCAddress, - CFX_WideString& csBCCAddress, - CFX_WideString& csSubject, - CFX_WideString& csMsg); + bool MailToInfo(WideString& csURL, + WideString& csToAddress, + WideString& csCCAddress, + WideString& csBCCAddress, + WideString& csSubject, + WideString& csMsg); bool ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, int fileType, FPDF_DWORD encodeType, FPDF_DWORD flag); - void ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag); + void ToXFAContentFlags(WideString csSrcContent, FPDF_DWORD& flag); CFX_UnownedPtr const m_pContext; }; -- cgit v1.2.3