diff options
Diffstat (limited to 'core/fpdfdoc')
47 files changed, 526 insertions, 545 deletions
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp index 4d9e630d97..9d28bc1f82 100644 --- a/core/fpdfdoc/cpdf_action.cpp +++ b/core/fpdfdoc/cpdf_action.cpp @@ -33,7 +33,7 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { if (!m_pDict) return CPDF_Dest(); - CFX_ByteString type = m_pDict->GetStringFor("S"); + ByteString type = m_pDict->GetStringFor("S"); if (type != "GoTo" && type != "GoToR") return CPDF_Dest(); @@ -54,7 +54,7 @@ CPDF_Action::ActionType CPDF_Action::GetType() const { if (!m_pDict) return Unknown; - CFX_ByteString csType = m_pDict->GetStringFor("S"); + ByteString csType = m_pDict->GetStringFor("S"); if (csType.IsEmpty()) return Unknown; @@ -65,11 +65,11 @@ CPDF_Action::ActionType CPDF_Action::GetType() const { return Unknown; } -CFX_WideString CPDF_Action::GetFilePath() const { - CFX_ByteString type = m_pDict->GetStringFor("S"); +WideString CPDF_Action::GetFilePath() const { + ByteString type = m_pDict->GetStringFor("S"); if (type != "GoToR" && type != "Launch" && type != "SubmitForm" && type != "ImportData") { - return CFX_WideString(); + return WideString(); } CPDF_Object* pFile = m_pDict->GetDirectObjectFor("F"); @@ -79,14 +79,14 @@ CFX_WideString CPDF_Action::GetFilePath() const { if (type == "Launch") { CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win"); if (pWinDict) { - return CFX_WideString::FromLocal(pWinDict->GetStringFor("F").AsStringC()); + return WideString::FromLocal(pWinDict->GetStringFor("F").AsStringView()); } } - return CFX_WideString(); + return WideString(); } -CFX_ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const { - CFX_ByteString csURI; +ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const { + ByteString csURI; if (!m_pDict) return csURI; if (m_pDict->GetStringFor("S") != "URI") @@ -103,8 +103,8 @@ CFX_ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const { return csURI; } -CFX_WideString CPDF_Action::GetJavaScript() const { - CFX_WideString csJS; +WideString CPDF_Action::GetJavaScript() const { + WideString csJS; if (!m_pDict) return csJS; diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h index be4d461867..b405f226a5 100644 --- a/core/fpdfdoc/cpdf_action.h +++ b/core/fpdfdoc/cpdf_action.h @@ -45,12 +45,12 @@ class CPDF_Action { CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } ActionType GetType() const; CPDF_Dest GetDest(CPDF_Document* pDoc) const; - CFX_WideString GetFilePath() const; - CFX_ByteString GetURI(const CPDF_Document* pDoc) const; + WideString GetFilePath() const; + ByteString GetURI(const CPDF_Document* pDoc) const; bool GetHideStatus() const { return m_pDict->GetBooleanFor("H", true); } - CFX_ByteString GetNamedAction() const { return m_pDict->GetStringFor("N"); } + ByteString GetNamedAction() const { return m_pDict->GetStringFor("N"); } uint32_t GetFlags() const { return m_pDict->GetIntegerFor("Flags"); } - CFX_WideString GetJavaScript() const; + WideString GetJavaScript() const; size_t GetSubActionsCount() const; CPDF_Action GetSubAction(size_t iIndex) const; diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp index f3c3f5ed25..cee256d3fb 100644 --- a/core/fpdfdoc/cpdf_actionfields.cpp +++ b/core/fpdfdoc/cpdf_actionfields.cpp @@ -23,7 +23,7 @@ size_t CPDF_ActionFields::GetFieldsCount() const { if (!pDict) return 0; - CFX_ByteString csType = pDict->GetStringFor("S"); + ByteString csType = pDict->GetStringFor("S"); CPDF_Object* pFields = nullptr; if (csType == "Hide") pFields = pDict->GetDirectObjectFor("T"); @@ -50,7 +50,7 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const { if (!pDict) return fields; - CFX_ByteString csType = pDict->GetStringFor("S"); + ByteString csType = pDict->GetStringFor("S"); CPDF_Object* pFields; if (csType == "Hide") pFields = pDict->GetDirectObjectFor("T"); @@ -80,7 +80,7 @@ CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const { if (!pDict) return nullptr; - CFX_ByteString csType = pDict->GetStringFor("S"); + ByteString csType = pDict->GetStringFor("S"); CPDF_Object* pFields = nullptr; if (csType == "Hide") pFields = pDict->GetDirectObjectFor("T"); diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index ea15436565..1a8538057c 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -179,12 +179,12 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(const CPDF_Dictionary* pAnnotDict, return pStream; if (CPDF_Dictionary* pDict = psub->AsDictionary()) { - CFX_ByteString as = pAnnotDict->GetStringFor("AS"); + ByteString as = pAnnotDict->GetStringFor("AS"); if (as.IsEmpty()) { - CFX_ByteString value = pAnnotDict->GetStringFor("V"); + ByteString value = pAnnotDict->GetStringFor("V"); if (value.IsEmpty()) { CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent"); - value = pParentDict ? pParentDict->GetStringFor("V") : CFX_ByteString(); + value = pParentDict ? pParentDict->GetStringFor("V") : ByteString(); } if (value.IsEmpty() || !pDict->KeyExist(value)) as = "Off"; @@ -241,7 +241,7 @@ bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) { // Static. CPDF_Annot::Subtype CPDF_Annot::StringToAnnotSubtype( - const CFX_ByteString& sSubtype) { + const ByteString& sSubtype) { if (sSubtype == "Text") return CPDF_Annot::Subtype::TEXT; if (sSubtype == "Link") @@ -300,7 +300,7 @@ CPDF_Annot::Subtype CPDF_Annot::StringToAnnotSubtype( } // Static. -CFX_ByteString CPDF_Annot::AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype) { +ByteString CPDF_Annot::AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype) { if (nSubtype == CPDF_Annot::Subtype::TEXT) return "Text"; if (nSubtype == CPDF_Annot::Subtype::LINK) @@ -456,7 +456,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, width = 1; } } else { - CFX_ByteString style = pBS->GetStringFor("S"); + ByteString style = pBS->GetStringFor("S"); pDashArray = pBS->GetArrayFor("D"); style_char = style[1]; width = pBS->GetNumberFor("W"); diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/cpdf_annot.h index 4ca1941819..cf1b304670 100644 --- a/core/fpdfdoc/cpdf_annot.h +++ b/core/fpdfdoc/cpdf_annot.h @@ -69,9 +69,8 @@ class CPDF_Annot { }; static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict); - static CPDF_Annot::Subtype StringToAnnotSubtype( - const CFX_ByteString& sSubtype); - static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype); + static CPDF_Annot::Subtype StringToAnnotSubtype(const ByteString& sSubtype); + static ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype); static CFX_FloatRect RectFromQuadPoints(CPDF_Dictionary* pAnnotDict); // The second constructor does not take ownership of the dictionary. diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index df3b631626..87e5ba7808 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -35,7 +35,7 @@ std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. // See pdfium:593. - CFX_WideString sContents = pParentDict->GetUnicodeTextFor("Contents"); + WideString sContents = pParentDict->GetUnicodeTextFor("Contents"); if (sContents.IsEmpty()) return nullptr; @@ -92,7 +92,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i)); if (!pDict) continue; - const CFX_ByteString subtype = pDict->GetStringFor("Subtype"); + const ByteString subtype = pDict->GetStringFor("Subtype"); if (subtype == "Popup") { // Skip creating Popup annotations in the PDF document since PDFium // provides its own Popup annotations. diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp index ee205e01dc..0fc9c202cb 100644 --- a/core/fpdfdoc/cpdf_apsettings.cpp +++ b/core/fpdfdoc/cpdf_apsettings.cpp @@ -18,7 +18,7 @@ CPDF_ApSettings::CPDF_ApSettings(const CPDF_ApSettings& that) = default; CPDF_ApSettings::~CPDF_ApSettings() {} -bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const { +bool CPDF_ApSettings::HasMKEntry(const ByteString& csEntry) const { return m_pDict && m_pDict->KeyExist(csEntry); } @@ -27,7 +27,7 @@ int CPDF_ApSettings::GetRotation() const { } FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, - const CFX_ByteString& csEntry) const { + const ByteString& csEntry) const { iColorType = COLORTYPE_TRANSPARENT; if (!m_pDict) return 0; @@ -65,7 +65,7 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, } float CPDF_ApSettings::GetOriginalColor(int index, - const CFX_ByteString& csEntry) const { + const ByteString& csEntry) const { if (!m_pDict) return 0; @@ -75,7 +75,7 @@ float CPDF_ApSettings::GetOriginalColor(int index, void CPDF_ApSettings::GetOriginalColor(int& iColorType, float fc[4], - const CFX_ByteString& csEntry) const { + const ByteString& csEntry) const { iColorType = COLORTYPE_TRANSPARENT; for (int i = 0; i < 4; i++) fc[i] = 0; @@ -105,12 +105,11 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType, } } -CFX_WideString CPDF_ApSettings::GetCaption( - const CFX_ByteString& csEntry) const { - return m_pDict ? m_pDict->GetUnicodeTextFor(csEntry) : CFX_WideString(); +WideString CPDF_ApSettings::GetCaption(const ByteString& csEntry) const { + return m_pDict ? m_pDict->GetUnicodeTextFor(csEntry) : WideString(); } -CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteString& csEntry) const { +CPDF_Stream* CPDF_ApSettings::GetIcon(const ByteString& csEntry) const { return m_pDict ? m_pDict->GetStreamFor(csEntry) : nullptr; } diff --git a/core/fpdfdoc/cpdf_apsettings.h b/core/fpdfdoc/cpdf_apsettings.h index 2f8f9e49d9..a2a1f91a33 100644 --- a/core/fpdfdoc/cpdf_apsettings.h +++ b/core/fpdfdoc/cpdf_apsettings.h @@ -23,7 +23,7 @@ class CPDF_ApSettings { CPDF_ApSettings(const CPDF_ApSettings& that); ~CPDF_ApSettings(); - bool HasMKEntry(const CFX_ByteString& csEntry) const; + bool HasMKEntry(const ByteString& csEntry) const; int GetRotation() const; FX_ARGB GetBorderColor(int& iColorType) const { @@ -50,9 +50,9 @@ class CPDF_ApSettings { GetOriginalColor(iColorType, fc, "BG"); } - CFX_WideString GetNormalCaption() const { return GetCaption("CA"); } - CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); } - CFX_WideString GetDownCaption() const { return GetCaption("AC"); } + WideString GetNormalCaption() const { return GetCaption("CA"); } + WideString GetRolloverCaption() const { return GetCaption("RC"); } + WideString GetDownCaption() const { return GetCaption("AC"); } CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); } CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); } CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); } @@ -62,14 +62,14 @@ class CPDF_ApSettings { private: friend class CPDF_FormControl; - FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const; - float GetOriginalColor(int index, const CFX_ByteString& csEntry) const; + FX_ARGB GetColor(int& iColorType, const ByteString& csEntry) const; + float GetOriginalColor(int index, const ByteString& csEntry) const; void GetOriginalColor(int& iColorType, float fc[4], - const CFX_ByteString& csEntry) const; + const ByteString& csEntry) const; - CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; - CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const; + WideString GetCaption(const ByteString& csEntry) const; + CPDF_Stream* GetIcon(const ByteString& csEntry) const; CFX_UnownedPtr<CPDF_Dictionary> const m_pDict; }; diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp index e84001f846..884c3cb0b8 100644 --- a/core/fpdfdoc/cpdf_bookmark.cpp +++ b/core/fpdfdoc/cpdf_bookmark.cpp @@ -40,25 +40,25 @@ uint32_t CPDF_Bookmark::GetFontStyle() const { return m_pDict ? m_pDict->GetIntegerFor("F") : 0; } -CFX_WideString CPDF_Bookmark::GetTitle() const { +WideString CPDF_Bookmark::GetTitle() const { if (!m_pDict) - return CFX_WideString(); + return WideString(); CPDF_String* pString = ToString(m_pDict->GetDirectObjectFor("Title")); if (!pString) - return CFX_WideString(); + return WideString(); - CFX_WideString title = pString->GetUnicodeText(); + WideString title = pString->GetUnicodeText(); int len = title.GetLength(); if (!len) - return CFX_WideString(); + return WideString(); std::vector<wchar_t> buf(len); for (int i = 0; i < len; i++) { wchar_t w = title[i]; buf[i] = w > 0x20 ? w : 0x20; } - return CFX_WideString(buf.data(), len); + return WideString(buf.data(), len); } CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { diff --git a/core/fpdfdoc/cpdf_bookmark.h b/core/fpdfdoc/cpdf_bookmark.h index b9a1ac650e..88f47a9450 100644 --- a/core/fpdfdoc/cpdf_bookmark.h +++ b/core/fpdfdoc/cpdf_bookmark.h @@ -25,7 +25,7 @@ class CPDF_Bookmark { CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } uint32_t GetColorRef() const; uint32_t GetFontStyle() const; - CFX_WideString GetTitle() const; + WideString GetTitle() const; CPDF_Dest GetDest(CPDF_Document* pDocument) const; CPDF_Action GetAction() const; diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp index 28213aa33b..bd7ea1bc07 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.cpp +++ b/core/fpdfdoc/cpdf_defaultappearance.cpp @@ -16,16 +16,16 @@ bool CPDF_DefaultAppearance::HasFont() { if (m_csDA.IsEmpty()) return false; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); return syntax.FindTagParamFromStart("Tf", 2); } -CFX_ByteString CPDF_DefaultAppearance::GetFontString() { - CFX_ByteString csFont; +ByteString CPDF_DefaultAppearance::GetFontString() { + ByteString csFont; if (m_csDA.IsEmpty()) return csFont; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart("Tf", 2)) { csFont += syntax.GetWord(); csFont += " "; @@ -36,15 +36,15 @@ CFX_ByteString CPDF_DefaultAppearance::GetFontString() { return csFont; } -CFX_ByteString CPDF_DefaultAppearance::GetFont(float* fFontSize) { +ByteString CPDF_DefaultAppearance::GetFont(float* fFontSize) { *fFontSize = 0.0f; if (m_csDA.IsEmpty()) - return CFX_ByteString(); + return ByteString(); - CFX_ByteString csFontNameTag; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + ByteString csFontNameTag; + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart("Tf", 2)) { - csFontNameTag = CFX_ByteString(syntax.GetWord()); + csFontNameTag = ByteString(syntax.GetWord()); csFontNameTag.Delete(0, 1); *fFontSize = FX_atof(syntax.GetWord()); } @@ -55,7 +55,7 @@ bool CPDF_DefaultAppearance::HasColor(PaintOperation nOperation) { if (m_csDA.IsEmpty()) return false; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) { return true; @@ -68,13 +68,12 @@ bool CPDF_DefaultAppearance::HasColor(PaintOperation nOperation) { (nOperation == PaintOperation::STROKE ? "K" : "k"), 4); } -CFX_ByteString CPDF_DefaultAppearance::GetColorString( - PaintOperation nOperation) { - CFX_ByteString csColor; +ByteString CPDF_DefaultAppearance::GetColorString(PaintOperation nOperation) { + ByteString csColor; if (m_csDA.IsEmpty()) return csColor; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) { csColor += syntax.GetWord(); @@ -118,7 +117,7 @@ void CPDF_DefaultAppearance::GetColor(int& iColorType, if (m_csDA.IsEmpty()) return; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) { iColorType = COLORTYPE_GRAY; @@ -151,7 +150,7 @@ void CPDF_DefaultAppearance::GetColor(FX_ARGB& color, if (m_csDA.IsEmpty()) return; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) { iColorType = COLORTYPE_GRAY; @@ -187,16 +186,16 @@ bool CPDF_DefaultAppearance::HasTextMatrix() { if (m_csDA.IsEmpty()) return false; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); return syntax.FindTagParamFromStart("Tm", 6); } -CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() { - CFX_ByteString csTM; +ByteString CPDF_DefaultAppearance::GetTextMatrixString() { + ByteString csTM; if (m_csDA.IsEmpty()) return csTM; - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (syntax.FindTagParamFromStart("Tm", 6)) { for (int i = 0; i < 6; i++) { csTM += syntax.GetWord(); @@ -211,7 +210,7 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() { if (m_csDA.IsEmpty()) return CFX_Matrix(); - CPDF_SimpleParser syntax(m_csDA.AsStringC()); + CPDF_SimpleParser syntax(m_csDA.AsStringView()); if (!syntax.FindTagParamFromStart("Tm", 6)) return CFX_Matrix(); diff --git a/core/fpdfdoc/cpdf_defaultappearance.h b/core/fpdfdoc/cpdf_defaultappearance.h index 3be06e294d..33d4bfdd9d 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.h +++ b/core/fpdfdoc/cpdf_defaultappearance.h @@ -19,21 +19,20 @@ enum class PaintOperation { STROKE, FILL }; class CPDF_DefaultAppearance { public: CPDF_DefaultAppearance() {} - explicit CPDF_DefaultAppearance(const CFX_ByteString& csDA) : m_csDA(csDA) {} + explicit CPDF_DefaultAppearance(const ByteString& csDA) : m_csDA(csDA) {} CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) { m_csDA = cDA.GetStr(); } - CFX_ByteString GetStr() const { return m_csDA; } + ByteString GetStr() const { return m_csDA; } bool HasFont(); - CFX_ByteString GetFontString(); - CFX_ByteString GetFont(float* fFontSize); + ByteString GetFontString(); + ByteString GetFont(float* fFontSize); bool HasColor(PaintOperation nOperation = PaintOperation::FILL); - CFX_ByteString GetColorString( - PaintOperation nOperation = PaintOperation::FILL); + ByteString GetColorString(PaintOperation nOperation = PaintOperation::FILL); void GetColor(int& iColorType, float fc[4], PaintOperation nOperation = PaintOperation::FILL); @@ -42,11 +41,11 @@ class CPDF_DefaultAppearance { PaintOperation nOperation = PaintOperation::FILL); bool HasTextMatrix(); - CFX_ByteString GetTextMatrixString(); + ByteString GetTextMatrixString(); CFX_Matrix GetTextMatrix(); private: - CFX_ByteString m_csDA; + ByteString m_csDA; }; #endif // CORE_FPDFDOC_CPDF_DEFAULTAPPEARANCE_H_ diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp index 3e1988dd5e..ebe3834e91 100644 --- a/core/fpdfdoc/cpdf_dest.cpp +++ b/core/fpdfdoc/cpdf_dest.cpp @@ -65,7 +65,7 @@ int CPDF_Dest::GetZoomMode() { if (!pObj) return 0; - CFX_ByteString mode = pObj->GetString(); + ByteString mode = pObj->GetString(); for (int i = 0; g_sZoomModes[i]; ++i) { if (mode == g_sZoomModes[i]) return i + 1; @@ -126,6 +126,6 @@ float CPDF_Dest::GetParam(int index) { return pArray ? pArray->GetNumberAt(2 + index) : 0; } -CFX_ByteString CPDF_Dest::GetRemoteName() { - return m_pObj ? m_pObj->GetString() : CFX_ByteString(); +ByteString CPDF_Dest::GetRemoteName() { + return m_pObj ? m_pObj->GetString() : ByteString(); } diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h index f029d4c031..23964d7400 100644 --- a/core/fpdfdoc/cpdf_dest.h +++ b/core/fpdfdoc/cpdf_dest.h @@ -22,7 +22,7 @@ class CPDF_Dest { ~CPDF_Dest(); CPDF_Object* GetObject() const { return m_pObj.Get(); } - CFX_ByteString GetRemoteName(); + ByteString GetRemoteName(); int GetPageIndex(CPDF_Document* pDoc); uint32_t GetPageObjNum(); int GetZoomMode(); diff --git a/core/fpdfdoc/cpdf_docjsactions.cpp b/core/fpdfdoc/cpdf_docjsactions.cpp index 669ed7055c..974ca33b8b 100644 --- a/core/fpdfdoc/cpdf_docjsactions.cpp +++ b/core/fpdfdoc/cpdf_docjsactions.cpp @@ -18,9 +18,8 @@ int CPDF_DocJSActions::CountJSActions() const { return name_tree.GetCount(); } -CPDF_Action CPDF_DocJSActions::GetJSActionAndName( - int index, - CFX_WideString* csName) const { +CPDF_Action CPDF_DocJSActions::GetJSActionAndName(int index, + WideString* csName) const { ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); CPDF_Object* pAction = name_tree.LookupValueAndName(index, csName); @@ -28,7 +27,7 @@ CPDF_Action CPDF_DocJSActions::GetJSActionAndName( : CPDF_Action(); } -CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_WideString& csName) const { +CPDF_Action CPDF_DocJSActions::GetJSAction(const WideString& csName) const { ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); CPDF_Object* pAction = name_tree.LookupValue(csName); @@ -36,7 +35,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_WideString& csName) const { : CPDF_Action(); } -int CPDF_DocJSActions::FindJSAction(const CFX_WideString& csName) const { +int CPDF_DocJSActions::FindJSAction(const WideString& csName) const { ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); return name_tree.GetIndex(csName); diff --git a/core/fpdfdoc/cpdf_docjsactions.h b/core/fpdfdoc/cpdf_docjsactions.h index 73c0a1ef1c..c2652d7f6d 100644 --- a/core/fpdfdoc/cpdf_docjsactions.h +++ b/core/fpdfdoc/cpdf_docjsactions.h @@ -19,9 +19,9 @@ class CPDF_DocJSActions { ~CPDF_DocJSActions(); int CountJSActions() const; - CPDF_Action GetJSActionAndName(int index, CFX_WideString* csName) const; - CPDF_Action GetJSAction(const CFX_WideString& csName) const; - int FindJSAction(const CFX_WideString& csName) const; + CPDF_Action GetJSActionAndName(int index, WideString* csName) const; + CPDF_Action GetJSAction(const WideString& csName) const; + int FindJSAction(const WideString& csName) const; CPDF_Document* GetDocument() const { return m_pDocument.Get(); } private: diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp index e34f54e4e1..803c4148c7 100644 --- a/core/fpdfdoc/cpdf_filespec.cpp +++ b/core/fpdfdoc/cpdf_filespec.cpp @@ -20,8 +20,8 @@ namespace { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -CFX_WideString ChangeSlashToPlatform(const wchar_t* str) { - CFX_WideString result; +WideString ChangeSlashToPlatform(const wchar_t* str) { + WideString result; while (*str) { if (*str == '/') { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ @@ -37,8 +37,8 @@ CFX_WideString ChangeSlashToPlatform(const wchar_t* str) { return result; } -CFX_WideString ChangeSlashToPDF(const wchar_t* str) { - CFX_WideString result; +WideString ChangeSlashToPDF(const wchar_t* str) { + WideString result; while (*str) { if (*str == '\\' || *str == ':') result += L'/'; @@ -59,12 +59,12 @@ CPDF_FileSpec::CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) { CPDF_FileSpec::~CPDF_FileSpec() {} -CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) { +WideString CPDF_FileSpec::DecodeFileName(const WideString& filepath) { if (filepath.GetLength() <= 1) - return CFX_WideString(); + return WideString(); #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) + if (filepath.Left(sizeof("/Mac") - 1) == WideStringView(L"/Mac")) return ChangeSlashToPlatform(filepath.c_str() + 1); return ChangeSlashToPlatform(filepath.c_str()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -74,28 +74,28 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) { if (filepath[1] == L'/') return ChangeSlashToPlatform(filepath.c_str() + 1); if (filepath[2] == L'/') { - CFX_WideString result; + WideString result; result += filepath[1]; result += L':'; result += ChangeSlashToPlatform(filepath.c_str() + 2); return result; } - CFX_WideString result; + WideString result; result += L'\\'; result += ChangeSlashToPlatform(filepath.c_str()); return result; #else - return CFX_WideString(filepath); + return WideString(filepath); #endif } -CFX_WideString CPDF_FileSpec::GetFileName() const { - CFX_WideString csFileName; +WideString CPDF_FileSpec::GetFileName() const { + WideString csFileName; if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { csFileName = pDict->GetUnicodeTextFor("UF"); if (csFileName.IsEmpty()) { csFileName = - CFX_WideString::FromLocal(pDict->GetStringFor("F").AsStringC()); + WideString::FromLocal(pDict->GetStringFor("F").AsStringView()); } if (pDict->GetStringFor("FS") == "URL") return csFileName; @@ -105,13 +105,13 @@ CFX_WideString CPDF_FileSpec::GetFileName() const { for (const auto* key : keys) { if (pDict->KeyExist(key)) { csFileName = - CFX_WideString::FromLocal(pDict->GetStringFor(key).AsStringC()); + WideString::FromLocal(pDict->GetStringFor(key).AsStringView()); break; } } } } else if (m_pObj->IsString()) { - csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC()); + csFileName = WideString::FromLocal(m_pObj->GetString().AsStringView()); } return DecodeFileName(csFileName); } @@ -131,7 +131,7 @@ CPDF_Stream* CPDF_FileSpec::GetFileStream() const { constexpr const char* keys[] = {"UF", "F", "DOS", "Mac", "Unix"}; size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : FX_ArraySize(keys); for (size_t i = 0; i < end; ++i) { - const CFX_ByteString& key = keys[i]; + const ByteString& key = keys[i]; if (!pDict->GetUnicodeTextFor(key).IsEmpty()) { CPDF_Stream* pStream = pFiles->GetStreamFor(key); if (pStream) @@ -153,13 +153,13 @@ CPDF_Dictionary* CPDF_FileSpec::GetParamsDict() const { return pDict->GetDictFor("Params"); } -CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideString& filepath) { +WideString CPDF_FileSpec::EncodeFileName(const WideString& filepath) { if (filepath.GetLength() <= 1) - return CFX_WideString(); + return WideString(); #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ if (filepath[1] == L':') { - CFX_WideString result(L'/'); + WideString result(L'/'); result += filepath[0]; if (filepath[2] != L'\\') result += L'/'; @@ -178,17 +178,16 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideString& filepath) { return L'/' + ChangeSlashToPDF(filepath.c_str()); return ChangeSlashToPDF(filepath.c_str()); #else - return CFX_WideString(filepath); + return WideString(filepath); #endif } -void CPDF_FileSpec::SetFileName(const CFX_WideString& wsFileName) { - CFX_WideString wsStr = EncodeFileName(wsFileName); +void CPDF_FileSpec::SetFileName(const WideString& wsFileName) { + WideString wsStr = EncodeFileName(wsFileName); if (m_pObj->IsString()) { - m_pObj->SetString(CFX_ByteString::FromUnicode(wsStr)); + m_pObj->SetString(ByteString::FromUnicode(wsStr)); } else if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { - pDict->SetNewFor<CPDF_String>("F", CFX_ByteString::FromUnicode(wsStr), - false); + pDict->SetNewFor<CPDF_String>("F", ByteString::FromUnicode(wsStr), false); pDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsStr), false); } } diff --git a/core/fpdfdoc/cpdf_filespec.h b/core/fpdfdoc/cpdf_filespec.h index 8640b2e4c6..2cbbc15977 100644 --- a/core/fpdfdoc/cpdf_filespec.h +++ b/core/fpdfdoc/cpdf_filespec.h @@ -22,18 +22,18 @@ class CPDF_FileSpec { ~CPDF_FileSpec(); // Convert a platform dependent file name into pdf format. - static CFX_WideString EncodeFileName(const CFX_WideString& filepath); + static WideString EncodeFileName(const WideString& filepath); // Convert a pdf file name into platform dependent format. - static CFX_WideString DecodeFileName(const CFX_WideString& filepath); + static WideString DecodeFileName(const WideString& filepath); CPDF_Object* GetObj() const { return m_pObj.Get(); } - CFX_WideString GetFileName() const; + WideString GetFileName() const; CPDF_Stream* GetFileStream() const; CPDF_Dictionary* GetParamsDict() const; // Set this file spec to refer to a file name (not a url). - void SetFileName(const CFX_WideString& wsFileName); + void SetFileName(const WideString& wsFileName); private: CFX_UnownedPtr<CPDF_Object> const m_pObj; diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index 555d19660f..62302fe499 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -34,10 +34,10 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, CPDF_FormControl::~CPDF_FormControl() {} -CFX_ByteString CPDF_FormControl::GetOnStateName() const { +ByteString CPDF_FormControl::GetOnStateName() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); - CFX_ByteString csOn; + ByteString csOn; CPDF_Dictionary* pAP = m_pWidgetDict->GetDictFor("AP"); if (!pAP) return csOn; @@ -50,19 +50,19 @@ CFX_ByteString CPDF_FormControl::GetOnStateName() const { if (it.first != "Off") return it.first; } - return CFX_ByteString(); + return ByteString(); } -void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { +void CPDF_FormControl::SetOnStateName(const ByteString& csOn) { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); - CFX_ByteString csValue = csOn; + ByteString csValue = csOn; if (csValue.IsEmpty()) csValue = "Yes"; else if (csValue == "Off") csValue = "Yes"; - CFX_ByteString csAS = m_pWidgetDict->GetStringFor("AS", "Off"); + ByteString csAS = m_pWidgetDict->GetStringFor("AS", "Off"); if (csAS != "Off") m_pWidgetDict->SetNewFor<CPDF_Name>("AS", csValue); @@ -82,7 +82,7 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { auto subdict_it = pSubDict->begin(); while (subdict_it != pSubDict->end()) { - const CFX_ByteString& csKey2 = subdict_it->first; + const ByteString& csKey2 = subdict_it->first; CPDF_Object* pObj2 = subdict_it->second.get(); ++subdict_it; if (!pObj2) @@ -95,10 +95,10 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { } } -CFX_ByteString CPDF_FormControl::GetCheckedAPState() { +ByteString CPDF_FormControl::GetCheckedAPState() { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); - CFX_ByteString csOn = GetOnStateName(); + ByteString csOn = GetOnStateName(); if (GetType() == CPDF_FormField::RadioButton || GetType() == CPDF_FormField::CheckBox) { if (ToArray(FPDF_GetFieldAttr(m_pField->GetDict(), "Opt"))) { @@ -111,10 +111,10 @@ CFX_ByteString CPDF_FormControl::GetCheckedAPState() { return csOn; } -CFX_WideString CPDF_FormControl::GetExportValue() const { +WideString CPDF_FormControl::GetExportValue() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); - CFX_ByteString csOn = GetOnStateName(); + ByteString csOn = GetOnStateName(); if (GetType() == CPDF_FormField::RadioButton || GetType() == CPDF_FormField::CheckBox) { if (CPDF_Array* pArray = @@ -131,8 +131,8 @@ CFX_WideString CPDF_FormControl::GetExportValue() const { bool CPDF_FormControl::IsChecked() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); - CFX_ByteString csOn = GetOnStateName(); - CFX_ByteString csAS = m_pWidgetDict->GetStringFor("AS"); + ByteString csOn = GetOnStateName(); + ByteString csAS = m_pWidgetDict->GetStringFor("AS"); return csAS == csOn; } @@ -143,17 +143,17 @@ bool CPDF_FormControl::IsDefaultChecked() const { if (!pDV) return false; - CFX_ByteString csDV = pDV->GetString(); - CFX_ByteString csOn = GetOnStateName(); + ByteString csDV = pDV->GetString(); + ByteString csOn = GetOnStateName(); return (csDV == csOn); } void CPDF_FormControl::CheckControl(bool bChecked) { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); - CFX_ByteString csOn = GetOnStateName(); - CFX_ByteString csOldAS = m_pWidgetDict->GetStringFor("AS", "Off"); - CFX_ByteString csAS = "Off"; + ByteString csOn = GetOnStateName(); + ByteString csOldAS = m_pWidgetDict->GetStringFor("AS", "Off"); + ByteString csAS = "Off"; if (bChecked) csAS = csOn; if (csOldAS == csAS) @@ -192,7 +192,7 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() { if (!m_pWidgetDict) return Invert; - CFX_ByteString csH = m_pWidgetDict->GetStringFor("H", "I"); + ByteString csH = m_pWidgetDict->GetStringFor("H", "I"); for (size_t i = 0; i < FX_ArraySize(g_sHighlightingMode); ++i) { if (csH == g_sHighlightingMode[i]) return static_cast<HighlightingMode>(i); @@ -205,7 +205,7 @@ CPDF_ApSettings CPDF_FormControl::GetMK() const { : nullptr); } -bool CPDF_FormControl::HasMKEntry(const CFX_ByteString& csEntry) const { +bool CPDF_FormControl::HasMKEntry(const ByteString& csEntry) const { return GetMK().HasMKEntry(csEntry); } @@ -213,27 +213,25 @@ int CPDF_FormControl::GetRotation() { return GetMK().GetRotation(); } -FX_ARGB CPDF_FormControl::GetColor(int& iColorType, - const CFX_ByteString& csEntry) { +FX_ARGB CPDF_FormControl::GetColor(int& iColorType, const ByteString& csEntry) { return GetMK().GetColor(iColorType, csEntry); } -float CPDF_FormControl::GetOriginalColor(int index, - const CFX_ByteString& csEntry) { +float CPDF_FormControl::GetOriginalColor(int index, const ByteString& csEntry) { return GetMK().GetOriginalColor(index, csEntry); } void CPDF_FormControl::GetOriginalColor(int& iColorType, float fc[4], - const CFX_ByteString& csEntry) { + const ByteString& csEntry) { GetMK().GetOriginalColor(iColorType, fc, csEntry); } -CFX_WideString CPDF_FormControl::GetCaption(const CFX_ByteString& csEntry) { +WideString CPDF_FormControl::GetCaption(const ByteString& csEntry) { return GetMK().GetCaption(csEntry); } -CPDF_Stream* CPDF_FormControl::GetIcon(const CFX_ByteString& csEntry) { +CPDF_Stream* CPDF_FormControl::GetIcon(const ByteString& csEntry) { return GetMK().GetIcon(csEntry); } @@ -284,7 +282,7 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { float fFontSize; CPDF_DefaultAppearance cDA = GetDefaultAppearance(); - CFX_ByteString csFontNameTag = cDA.GetFont(&fFontSize); + ByteString csFontNameTag = cDA.GetFont(&fFontSize); if (csFontNameTag.IsEmpty()) return nullptr; diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h index eb63b5b6f0..4f686f44ab 100644 --- a/core/fpdfdoc/cpdf_formcontrol.h +++ b/core/fpdfdoc/cpdf_formcontrol.h @@ -61,14 +61,14 @@ class CPDF_FormControl { CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions = nullptr); - CFX_ByteString GetCheckedAPState(); - CFX_WideString GetExportValue() const; + ByteString GetCheckedAPState(); + WideString GetExportValue() const; bool IsChecked() const; bool IsDefaultChecked() const; HighlightingMode GetHighlightingMode(); - bool HasMKEntry(const CFX_ByteString& csEntry) const; + bool HasMKEntry(const ByteString& csEntry) const; int GetRotation(); FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); } @@ -93,9 +93,9 @@ class CPDF_FormControl { GetOriginalColor(iColorType, fc, "BG"); } - CFX_WideString GetNormalCaption() { return GetCaption("CA"); } - CFX_WideString GetRolloverCaption() { return GetCaption("RC"); } - CFX_WideString GetDownCaption() { return GetCaption("AC"); } + WideString GetNormalCaption() { return GetCaption("CA"); } + WideString GetRolloverCaption() { return GetCaption("RC"); } + WideString GetDownCaption() { return GetCaption("AC"); } CPDF_Stream* GetNormalIcon() { return GetIcon("I"); } CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); } @@ -114,17 +114,17 @@ class CPDF_FormControl { friend class CPDF_InterForm; friend class CPDF_FormField; - CFX_ByteString GetOnStateName() const; - void SetOnStateName(const CFX_ByteString& csOn); + ByteString GetOnStateName() const; + void SetOnStateName(const ByteString& csOn); void CheckControl(bool bChecked); - FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry); - float GetOriginalColor(int index, const CFX_ByteString& csEntry); + FX_ARGB GetColor(int& iColorType, const ByteString& csEntry); + float GetOriginalColor(int index, const ByteString& csEntry); void GetOriginalColor(int& iColorType, float fc[4], - const CFX_ByteString& csEntry); + const ByteString& csEntry); - CFX_WideString GetCaption(const CFX_ByteString& csEntry); - CPDF_Stream* GetIcon(const CFX_ByteString& csEntry); + WideString GetCaption(const ByteString& csEntry); + CPDF_Stream* GetIcon(const ByteString& csEntry); CPDF_ApSettings GetMK() const; CPDF_FormField* const m_pField; diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index acb46a5beb..fec1945956 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -65,13 +65,13 @@ CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict, return FPDF_GetFieldAttr(pParent, name, nLevel + 1); } -CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) { - CFX_WideString full_name; +WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) { + WideString full_name; std::set<CPDF_Dictionary*> visited; CPDF_Dictionary* pLevel = pFieldDict; while (pLevel) { visited.insert(pLevel); - CFX_WideString short_name = pLevel->GetUnicodeTextFor("T"); + WideString short_name = pLevel->GetUnicodeTextFor("T"); if (!short_name.IsEmpty()) { if (full_name.IsEmpty()) full_name = short_name; @@ -98,7 +98,7 @@ CPDF_FormField::~CPDF_FormField() {} void CPDF_FormField::SyncFieldFlags() { CPDF_Object* ft_attr = FPDF_GetFieldAttr(m_pDict.Get(), "FT"); - CFX_ByteString type_name = ft_attr ? ft_attr->GetString() : CFX_ByteString(); + ByteString type_name = ft_attr ? ft_attr->GetString() : ByteString(); CPDF_Object* ff_attr = FPDF_GetFieldAttr(m_pDict.Get(), "Ff"); uint32_t flags = ff_attr ? ff_attr->GetInteger() : 0; m_Flags = 0; @@ -154,7 +154,7 @@ void CPDF_FormField::SyncFieldFlags() { } } -CFX_WideString CPDF_FormField::GetFullName() const { +WideString CPDF_FormField::GetFullName() const { return FPDF_GetFullName(m_pDict.Get()); } @@ -180,7 +180,7 @@ bool CPDF_FormField::ResetField(bool bNotify) { } case CPDF_FormField::ComboBox: case CPDF_FormField::ListBox: { - CFX_WideString csValue; + WideString csValue; ClearSelection(); int iIndex = GetDefaultSelectedItem(); if (iIndex >= 0) @@ -199,12 +199,12 @@ bool CPDF_FormField::ResetField(bool bNotify) { case CPDF_FormField::File: default: { CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict.Get(), "DV"); - CFX_WideString csDValue; + WideString csDValue; if (pDV) csDValue = pDV->GetUnicodeText(); CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict.Get(), "V"); - CFX_WideString csValue; + WideString csValue; if (pV) csValue = pV->GetUnicodeText(); @@ -272,12 +272,12 @@ CPDF_AAction CPDF_FormField::GetAdditionalAction() const { return CPDF_AAction(pObj ? pObj->GetDict() : nullptr); } -CFX_WideString CPDF_FormField::GetAlternateName() const { +WideString CPDF_FormField::GetAlternateName() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "TU"); return pObj ? pObj->GetUnicodeText() : L""; } -CFX_WideString CPDF_FormField::GetMappingName() const { +WideString CPDF_FormField::GetMappingName() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "TM"); return pObj ? pObj->GetUnicodeText() : L""; } @@ -287,17 +287,17 @@ uint32_t CPDF_FormField::GetFieldFlags() const { return pObj ? pObj->GetInteger() : 0; } -CFX_ByteString CPDF_FormField::GetDefaultStyle() const { +ByteString CPDF_FormField::GetDefaultStyle() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DS"); return pObj ? pObj->GetString() : ""; } -CFX_WideString CPDF_FormField::GetRichTextString() const { +WideString CPDF_FormField::GetRichTextString() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "RV"); return pObj ? pObj->GetUnicodeText() : L""; } -CFX_WideString CPDF_FormField::GetValue(bool bDefault) const { +WideString CPDF_FormField::GetValue(bool bDefault) const { if (GetType() == CheckBox || GetType() == RadioButton) return GetCheckValue(bDefault); @@ -310,7 +310,7 @@ CFX_WideString CPDF_FormField::GetValue(bool bDefault) const { pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV"); } if (!pValue) - return CFX_WideString(); + return WideString(); } switch (pValue->GetType()) { @@ -325,18 +325,18 @@ CFX_WideString CPDF_FormField::GetValue(bool bDefault) const { default: break; } - return CFX_WideString(); + return WideString(); } -CFX_WideString CPDF_FormField::GetValue() const { +WideString CPDF_FormField::GetValue() const { return GetValue(false); } -CFX_WideString CPDF_FormField::GetDefaultValue() const { +WideString CPDF_FormField::GetDefaultValue() const { return GetValue(true); } -bool CPDF_FormField::SetValue(const CFX_WideString& value, +bool CPDF_FormField::SetValue(const WideString& value, bool bDefault, bool bNotify) { switch (m_Type) { @@ -349,14 +349,14 @@ bool CPDF_FormField::SetValue(const CFX_WideString& value, case RichText: case Text: case ComboBox: { - CFX_WideString csValue = value; + WideString csValue = value; if (bNotify && !NotifyBeforeValueChange(csValue)) return false; - CFX_ByteString key(bDefault ? "DV" : "V"); + ByteString key(bDefault ? "DV" : "V"); int iIndex = FindOptionValue(csValue); if (iIndex < 0) { - CFX_ByteString bsEncodeText = PDF_EncodeText(csValue); + ByteString bsEncodeText = PDF_EncodeText(csValue); m_pDict->SetNewFor<CPDF_String>(key, bsEncodeText, false); if (m_Type == RichText && !bDefault) m_pDict->SetNewFor<CPDF_String>("RV", bsEncodeText, false); @@ -397,7 +397,7 @@ bool CPDF_FormField::SetValue(const CFX_WideString& value, return true; } -bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bNotify) { +bool CPDF_FormField::SetValue(const WideString& value, bool bNotify) { return SetValue(value, false, bNotify); } @@ -440,7 +440,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const { if (pValue->IsNumber()) return pValue->GetInteger(); - CFX_WideString sel_value; + WideString sel_value; if (pValue->IsString()) { if (index != 0) return -1; @@ -451,12 +451,11 @@ int CPDF_FormField::GetSelectedIndex(int index) const { return -1; CPDF_Object* elementValue = pArray->GetDirectObjectAt(index); - sel_value = - elementValue ? elementValue->GetUnicodeText() : CFX_WideString(); + sel_value = elementValue ? elementValue->GetUnicodeText() : WideString(); } if (index < CountSelectedOptions()) { int iOptIndex = GetSelectedOptionIndex(index); - CFX_WideString csOpt = GetOptionValue(iOptIndex); + WideString csOpt = GetOptionValue(iOptIndex); if (csOpt == sel_value) return iOptIndex; } @@ -469,7 +468,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const { bool CPDF_FormField::ClearSelection(bool bNotify) { if (bNotify && m_pForm->m_pFormNotify) { - CFX_WideString csValue; + WideString csValue; int iIndex = GetSelectedIndex(0); if (iIndex >= 0) csValue = GetOptionLabel(iIndex); @@ -491,7 +490,7 @@ bool CPDF_FormField::IsItemSelected(int index) const { if (IsOptionSelected(index)) return true; - CFX_WideString opt_value = GetOptionValue(index); + WideString opt_value = GetOptionValue(index); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "V"); if (!pValue) { pValue = FPDF_GetFieldAttr(m_pDict.Get(), "I"); @@ -532,7 +531,7 @@ bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) { if (index < 0 || index >= CountOptions()) return false; - CFX_WideString opt_value = GetOptionValue(index); + WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return false; @@ -598,7 +597,7 @@ int CPDF_FormField::GetDefaultSelectedItem() const { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV"); if (!pValue) return -1; - CFX_WideString csDV = pValue->GetUnicodeText(); + WideString csDV = pValue->GetUnicodeText(); if (csDV.IsEmpty()) return -1; for (int i = 0; i < CountOptions(); i++) { @@ -613,30 +612,30 @@ int CPDF_FormField::CountOptions() const { return pArray ? pArray->GetCount() : 0; } -CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) const { +WideString CPDF_FormField::GetOptionText(int index, int sub_index) const { CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict.Get(), "Opt")); if (!pArray) - return CFX_WideString(); + return WideString(); CPDF_Object* pOption = pArray->GetDirectObjectAt(index); if (!pOption) - return CFX_WideString(); + return WideString(); if (CPDF_Array* pOptionArray = pOption->AsArray()) pOption = pOptionArray->GetDirectObjectAt(sub_index); CPDF_String* pString = ToString(pOption); - return pString ? pString->GetUnicodeText() : CFX_WideString(); + return pString ? pString->GetUnicodeText() : WideString(); } -CFX_WideString CPDF_FormField::GetOptionLabel(int index) const { +WideString CPDF_FormField::GetOptionLabel(int index) const { return GetOptionText(index, 1); } -CFX_WideString CPDF_FormField::GetOptionValue(int index) const { +WideString CPDF_FormField::GetOptionValue(int index) const { return GetOptionText(index, 0); } -int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const { +int CPDF_FormField::FindOption(WideString csOptLabel) const { for (int i = 0; i < CountOptions(); i++) { if (GetOptionValue(i) == csOptLabel) return i; @@ -644,7 +643,7 @@ int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const { return -1; } -int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const { +int CPDF_FormField::FindOptionValue(const WideString& csOptValue) const { for (int i = 0; i < CountOptions(); i++) { if (GetOptionValue(i) == csOptValue) return i; @@ -653,7 +652,7 @@ int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const { } #ifdef PDF_ENABLE_XFA -int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, +int CPDF_FormField::InsertOption(WideString csOptLabel, int index, bool bNotify) { if (csOptLabel.IsEmpty()) @@ -662,7 +661,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel)) return -1; - CFX_ByteString csStr = PDF_EncodeText(csOptLabel); + ByteString csStr = PDF_EncodeText(csOptLabel); CPDF_Array* pOpt = ToArray(FPDF_GetFieldAttr(m_pDict.Get(), "Opt")); if (!pOpt) pOpt = m_pDict->SetNewFor<CPDF_Array>("Opt"); @@ -682,7 +681,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, bool CPDF_FormField::ClearOptions(bool bNotify) { if (bNotify && m_pForm->m_pFormNotify) { - CFX_WideString csValue; + WideString csValue; int iIndex = GetSelectedIndex(0); if (iIndex >= 0) csValue = GetOptionLabel(iIndex); @@ -713,14 +712,14 @@ bool CPDF_FormField::CheckControl(int iControlIndex, if (!bChecked && pControl->IsChecked() == bChecked) return false; - CFX_WideString csWExport = pControl->GetExportValue(); - CFX_ByteString csBExport = PDF_EncodeText(csWExport); + WideString csWExport = pControl->GetExportValue(); + ByteString csBExport = PDF_EncodeText(csWExport); int iCount = CountControls(); bool bUnison = IsUnison(this); for (int i = 0; i < iCount; i++) { CPDF_FormControl* pCtrl = GetControl(i); if (bUnison) { - CFX_WideString csEValue = pCtrl->GetExportValue(); + WideString csEValue = pCtrl->GetExportValue(); if (csEValue == csWExport) { if (pCtrl->GetOnStateName() == pControl->GetOnStateName()) pCtrl->CheckControl(bChecked); @@ -742,7 +741,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex, if (bChecked) { m_pDict->SetNewFor<CPDF_Name>("V", csBExport); } else { - CFX_ByteString csV; + ByteString csV; CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict.Get(), "V"); if (pV) csV = pV->GetString(); @@ -750,7 +749,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex, m_pDict->SetNewFor<CPDF_Name>("V", "Off"); } } else if (bChecked) { - CFX_ByteString csIndex; + ByteString csIndex; csIndex.Format("%d", iControlIndex); m_pDict->SetNewFor<CPDF_Name>("V", csIndex); } @@ -759,9 +758,9 @@ bool CPDF_FormField::CheckControl(int iControlIndex, return true; } -CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const { +WideString CPDF_FormField::GetCheckValue(bool bDefault) const { ASSERT(GetType() == CheckBox || GetType() == RadioButton); - CFX_WideString csExport = L"Off"; + WideString csExport = L"Off"; int iCount = CountControls(); for (int i = 0; i < iCount; i++) { CPDF_FormControl* pControl = GetControl(i); @@ -775,14 +774,14 @@ CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const { return csExport; } -bool CPDF_FormField::SetCheckValue(const CFX_WideString& value, +bool CPDF_FormField::SetCheckValue(const WideString& value, bool bDefault, bool bNotify) { ASSERT(GetType() == CheckBox || GetType() == RadioButton); int iCount = CountControls(); for (int i = 0; i < iCount; i++) { CPDF_FormControl* pControl = GetControl(i); - CFX_WideString csExport = pControl->GetExportValue(); + WideString csExport = pControl->GetExportValue(); bool val = csExport == value; if (!bDefault) CheckControl(GetControlIndex(pControl), val); @@ -844,7 +843,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) { return true; if (bNotify && m_pForm->m_pFormNotify) { - CFX_WideString csValue = GetOptionLabel(iOptIndex); + WideString csValue = GetOptionLabel(iOptIndex); if (!NotifyListOrComboBoxBeforeChange(csValue)) return false; } @@ -858,7 +857,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) { continue; if (bNotify && m_pForm->m_pFormNotify) { - CFX_WideString csValue = GetOptionLabel(iOptIndex); + WideString csValue = GetOptionLabel(iOptIndex); if (!NotifyListOrComboBoxBeforeChange(csValue)) return false; } @@ -882,7 +881,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) { bool CPDF_FormField::ClearSelectedOptions(bool bNotify) { if (bNotify && m_pForm->m_pFormNotify) { - CFX_WideString csValue; + WideString csValue; int iIndex = GetSelectedIndex(0); if (iIndex >= 0) csValue = GetOptionLabel(iIndex); @@ -902,7 +901,7 @@ void CPDF_FormField::LoadDA() { if (!pFormDict) return; - CFX_ByteString DA; + ByteString DA; if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DA")) DA = pObj->GetString(); @@ -920,9 +919,9 @@ void CPDF_FormField::LoadDA() { if (!pFont) return; - CPDF_SimpleParser syntax(DA.AsStringC()); + CPDF_SimpleParser syntax(DA.AsStringView()); syntax.FindTagParamFromStart("Tf", 2); - CFX_ByteString font_name(syntax.GetWord()); + ByteString font_name(syntax.GetWord()); CPDF_Dictionary* pFontDict = pFont->GetDictFor(font_name); if (!pFontDict) return; @@ -931,7 +930,7 @@ void CPDF_FormField::LoadDA() { m_FontSize = FX_atof(syntax.GetWord()); } -bool CPDF_FormField::NotifyBeforeSelectionChange(const CFX_WideString& value) { +bool CPDF_FormField::NotifyBeforeSelectionChange(const WideString& value) { if (!m_pForm->m_pFormNotify) return true; return m_pForm->m_pFormNotify->BeforeSelectionChange(this, value) >= 0; @@ -943,7 +942,7 @@ void CPDF_FormField::NotifyAfterSelectionChange() { m_pForm->m_pFormNotify->AfterSelectionChange(this); } -bool CPDF_FormField::NotifyBeforeValueChange(const CFX_WideString& value) { +bool CPDF_FormField::NotifyBeforeValueChange(const WideString& value) { if (!m_pForm->m_pFormNotify) return true; return m_pForm->m_pFormNotify->BeforeValueChange(this, value) >= 0; @@ -955,8 +954,7 @@ void CPDF_FormField::NotifyAfterValueChange() { m_pForm->m_pFormNotify->AfterValueChange(this); } -bool CPDF_FormField::NotifyListOrComboBoxBeforeChange( - const CFX_WideString& value) { +bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(const WideString& value) { switch (GetType()) { case ListBox: return NotifyBeforeSelectionChange(value); diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h index 417f9d189f..6b4b7253e0 100644 --- a/core/fpdfdoc/cpdf_formfield.h +++ b/core/fpdfdoc/cpdf_formfield.h @@ -40,7 +40,7 @@ class CPDF_String; CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict, const char* name, int nLevel = 0); -CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict); +WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict); class CPDF_FormField { public: @@ -60,7 +60,7 @@ class CPDF_FormField { CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); ~CPDF_FormField(); - CFX_WideString GetFullName() const; + WideString GetFullName() const; Type GetType() const { return m_Type; } uint32_t GetFlags() const { return m_Flags; } @@ -82,16 +82,16 @@ class CPDF_FormField { int GetFieldType() const; CPDF_AAction GetAdditionalAction() const; - CFX_WideString GetAlternateName() const; - CFX_WideString GetMappingName() const; + WideString GetAlternateName() const; + WideString GetMappingName() const; uint32_t GetFieldFlags() const; - CFX_ByteString GetDefaultStyle() const; - CFX_WideString GetRichTextString() const; + ByteString GetDefaultStyle() const; + WideString GetRichTextString() const; - CFX_WideString GetValue() const; - CFX_WideString GetDefaultValue() const; - bool SetValue(const CFX_WideString& value, bool bNotify = false); + WideString GetValue() const; + WideString GetDefaultValue() const; + bool SetValue(const WideString& value, bool bNotify = false); int GetMaxLen() const; int CountSelectedItems() const; @@ -106,11 +106,11 @@ class CPDF_FormField { int GetDefaultSelectedItem() const; int CountOptions() const; - CFX_WideString GetOptionLabel(int index) const; - CFX_WideString GetOptionValue(int index) const; + WideString GetOptionLabel(int index) const; + WideString GetOptionValue(int index) const; - int FindOption(CFX_WideString csOptLabel) const; - int FindOptionValue(const CFX_WideString& csOptValue) const; + int FindOption(WideString csOptLabel) const; + int FindOptionValue(const WideString& csOptValue) const; bool CheckControl(int iControlIndex, bool bChecked, bool bNotify = false); @@ -127,9 +127,7 @@ class CPDF_FormField { #ifdef PDF_ENABLE_XFA bool ClearOptions(bool bNotify = false); - int InsertOption(CFX_WideString csOptLabel, - int index = -1, - bool bNotify = false); + int InsertOption(WideString csOptLabel, int index = -1, bool bNotify = false); #endif // PDF_ENABLE_XFA float GetFontSize() const { return m_FontSize; } @@ -138,7 +136,7 @@ class CPDF_FormField { const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } const CPDF_InterForm* GetForm() const { return m_pForm.Get(); } - CFX_WideString GetCheckValue(bool bDefault) const; + WideString GetCheckValue(bool bDefault) const; void AddFormControl(CPDF_FormControl* pFormControl) { m_ControlList.emplace_back(pFormControl); @@ -149,23 +147,23 @@ class CPDF_FormField { } private: - CFX_WideString GetValue(bool bDefault) const; - bool SetValue(const CFX_WideString& value, bool bDefault, bool bNotify); + WideString GetValue(bool bDefault) const; + bool SetValue(const WideString& value, bool bDefault, bool bNotify); void SyncFieldFlags(); int FindListSel(CPDF_String* str); - CFX_WideString GetOptionText(int index, int sub_index) const; + WideString GetOptionText(int index, int sub_index) const; void LoadDA(); - bool SetCheckValue(const CFX_WideString& value, bool bDefault, bool bNotify); + bool SetCheckValue(const WideString& value, bool bDefault, bool bNotify); - bool NotifyBeforeSelectionChange(const CFX_WideString& value); + bool NotifyBeforeSelectionChange(const WideString& value); void NotifyAfterSelectionChange(); - bool NotifyBeforeValueChange(const CFX_WideString& value); + bool NotifyBeforeValueChange(const WideString& value); void NotifyAfterValueChange(); - bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value); + bool NotifyListOrComboBoxBeforeChange(const WideString& value); void NotifyListOrComboBoxAfterChange(); CPDF_FormField::Type m_Type; diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp index 4aeda84c88..af5d15dab3 100644 --- a/core/fpdfdoc/cpdf_formfield_unittest.cpp +++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp @@ -10,7 +10,7 @@ #include "testing/gtest/include/gtest/gtest.h" TEST(cpdf_formfield, FPDF_GetFullName) { - CFX_WideString name = FPDF_GetFullName(nullptr); + WideString name = FPDF_GetFullName(nullptr); EXPECT_TRUE(name.IsEmpty()); CPDF_IndirectObjectHolder obj_holder; diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp index a28f3bc430..20ed963e92 100644 --- a/core/fpdfdoc/cpdf_iconfit.cpp +++ b/core/fpdfdoc/cpdf_iconfit.cpp @@ -20,7 +20,7 @@ CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { if (!m_pDict) return Always; - CFX_ByteString csSW = m_pDict->GetStringFor("SW", "A"); + ByteString csSW = m_pDict->GetStringFor("SW", "A"); if (csSW == "B") return Bigger; if (csSW == "S") diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 7e73f7e5a5..3bbb50b9ec 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -40,24 +40,24 @@ const struct SupportFieldEncoding { {"UHC", 949}, }; -CFX_WideString GetFieldValue(const CPDF_Dictionary& pFieldDict, - const CFX_ByteString& bsEncoding) { - const CFX_ByteString csBValue = pFieldDict.GetStringFor("V"); +WideString GetFieldValue(const CPDF_Dictionary& pFieldDict, + const ByteString& bsEncoding) { + const ByteString csBValue = pFieldDict.GetStringFor("V"); for (const auto& encoding : g_fieldEncoding) { if (bsEncoding == encoding.m_name) - return CFX_WideString::FromCodePage(csBValue.AsStringC(), - encoding.m_codePage); + return WideString::FromCodePage(csBValue.AsStringView(), + encoding.m_codePage); } - CFX_ByteString csTemp = csBValue.Left(2); + ByteString csTemp = csBValue.Left(2); if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") return PDF_DecodeText(csBValue); - return CFX_WideString::FromLocal(csBValue.AsStringC()); + return WideString::FromLocal(csBValue.AsStringView()); } void AddFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont, - CFX_ByteString* csNameTag); + ByteString* csNameTag); void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { if (!pDocument) @@ -69,17 +69,16 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { pFormDict->GetObjNum()); } - CFX_ByteString csDA; + ByteString csDA; if (!pFormDict->KeyExist("DR")) { - CFX_ByteString csBaseName; + ByteString csBaseName; uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); if (pFont) AddFont(pFormDict, pDocument, pFont, &csBaseName); if (charSet != FX_CHARSET_ANSI) { - CFX_ByteString csFontName = - CPDF_InterForm::GetNativeFont(charSet, nullptr); + ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); if (!pFont || csFontName != "Helvetica") { pFont = CPDF_InterForm::AddNativeFont(pDocument); if (pFont) { @@ -101,8 +100,8 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, - const CFX_ByteString& csNameTag) { - CFX_ByteString csAlias = PDF_NameDecode(csNameTag); + const ByteString& csNameTag) { + ByteString csAlias = PDF_NameDecode(csNameTag); if (!pFormDict || csAlias.IsEmpty()) return nullptr; @@ -126,7 +125,7 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, uint8_t charSet, - CFX_ByteString* csNameTag) { + ByteString* csNameTag) { if (!pFormDict) return nullptr; @@ -139,7 +138,7 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, return nullptr; for (const auto& it : *pFonts) { - const CFX_ByteString& csKey = it.first; + const ByteString& csKey = it.first; if (!it.second) continue; @@ -166,7 +165,7 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, bool FindFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont, - CFX_ByteString* csNameTag) { + ByteString* csNameTag) { if (!pFormDict || !pFont) return false; @@ -179,7 +178,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, return false; for (const auto& it : *pFonts) { - const CFX_ByteString& csKey = it.first; + const ByteString& csKey = it.first; if (!it.second) continue; CPDF_Dictionary* pElement = ToDictionary(it.second->GetDirect()); @@ -197,9 +196,9 @@ bool FindFont(CPDF_Dictionary* pFormDict, bool FindFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, - CFX_ByteString csFontName, + ByteString csFontName, CPDF_Font*& pFont, - CFX_ByteString* csNameTag) { + ByteString* csNameTag) { if (!pFormDict) return false; @@ -215,7 +214,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, csFontName.Remove(' '); for (const auto& it : *pFonts) { - const CFX_ByteString& csKey = it.first; + const ByteString& csKey = it.first; if (!it.second) continue; @@ -228,7 +227,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, if (!pFont) continue; - CFX_ByteString csBaseFont; + ByteString csBaseFont; csBaseFont = pFont->GetBaseFont(); csBaseFont.Remove(' '); if (csBaseFont == csFontName) { @@ -242,13 +241,13 @@ bool FindFont(CPDF_Dictionary* pFormDict, void AddFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont, - CFX_ByteString* csNameTag) { + ByteString* csNameTag) { if (!pFont) return; if (!pFormDict) InitDict(pFormDict, pDocument); - CFX_ByteString csTag; + ByteString csTag; if (FindFont(pFormDict, pFont, &csTag)) { *csNameTag = csTag; return; @@ -277,17 +276,17 @@ void AddFont(CPDF_Dictionary*& pFormDict, CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, uint8_t charSet, - CFX_ByteString* csNameTag) { + ByteString* csNameTag) { if (!pFormDict) InitDict(pFormDict, pDocument); - CFX_ByteString csTemp; + ByteString csTemp; CPDF_Font* pFont = GetNativeFont(pFormDict, pDocument, charSet, &csTemp); if (pFont) { *csNameTag = csTemp; return pFont; } - CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); + ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); if (!csFontName.IsEmpty() && FindFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) { return pFont; @@ -301,7 +300,7 @@ CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, class CFieldNameExtractor { public: - explicit CFieldNameExtractor(const CFX_WideString& full_name) + explicit CFieldNameExtractor(const WideString& full_name) : m_FullName(full_name) { m_pCur = m_FullName.c_str(); m_pEnd = m_pCur + m_FullName.GetLength(); @@ -318,7 +317,7 @@ class CFieldNameExtractor { } protected: - CFX_WideString m_FullName; + WideString m_FullName; const wchar_t* m_pCur; const wchar_t* m_pEnd; }; @@ -371,7 +370,7 @@ bool RetrieveSpecificFont(uint8_t charSet, } #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -int CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) { +int CompareFieldName(const WideString& name1, const WideString& name2) { const wchar_t* ptr1 = name1.c_str(); const wchar_t* ptr2 = name2.c_str(); if (name1.GetLength() == name2.GetLength()) @@ -394,7 +393,7 @@ class CFieldTree { class Node { public: Node() : m_pField(nullptr), m_level(0) {} - Node(const CFX_WideString& short_name, int level) + Node(const WideString& short_name, int level) : m_ShortName(short_name), m_level(level) {} ~Node() {} @@ -420,7 +419,7 @@ class CFieldTree { CPDF_FormField* GetField() const { return m_pField.get(); } - const CFX_WideString& GetShortName() const { return m_ShortName; } + const WideString& GetShortName() const { return m_ShortName; } int GetLevel() const { return m_level; } @@ -451,7 +450,7 @@ class CFieldTree { } std::vector<std::unique_ptr<Node>> m_Children; - CFX_WideString m_ShortName; + WideString m_ShortName; std::unique_ptr<CPDF_FormField> m_pField; const int m_level; }; @@ -459,14 +458,14 @@ class CFieldTree { CFieldTree(); ~CFieldTree(); - bool SetField(const CFX_WideString& full_name, + bool SetField(const WideString& full_name, std::unique_ptr<CPDF_FormField> pField); - CPDF_FormField* GetField(const CFX_WideString& full_name); + CPDF_FormField* GetField(const WideString& full_name); - Node* FindNode(const CFX_WideString& full_name); - Node* AddChild(Node* pParent, const CFX_WideString& short_name); + Node* FindNode(const WideString& full_name); + Node* AddChild(Node* pParent, const WideString& short_name); - Node* Lookup(Node* pParent, const CFX_WideString& short_name); + Node* Lookup(Node* pParent, const WideString& short_name); Node m_Root; }; @@ -476,7 +475,7 @@ CFieldTree::CFieldTree() {} CFieldTree::~CFieldTree() {} CFieldTree::Node* CFieldTree::AddChild(Node* pParent, - const CFX_WideString& short_name) { + const WideString& short_name) { if (!pParent) return nullptr; @@ -491,7 +490,7 @@ CFieldTree::Node* CFieldTree::AddChild(Node* pParent, } CFieldTree::Node* CFieldTree::Lookup(Node* pParent, - const CFX_WideString& short_name) { + const WideString& short_name) { if (!pParent) return nullptr; @@ -503,7 +502,7 @@ CFieldTree::Node* CFieldTree::Lookup(Node* pParent, return nullptr; } -bool CFieldTree::SetField(const CFX_WideString& full_name, +bool CFieldTree::SetField(const WideString& full_name, std::unique_ptr<CPDF_FormField> pField) { if (full_name.IsEmpty()) return false; @@ -516,7 +515,7 @@ bool CFieldTree::SetField(const CFX_WideString& full_name, Node* pLast = nullptr; while (nLength > 0) { pLast = pNode; - CFX_WideString name = CFX_WideString(pName, nLength); + WideString name = WideString(pName, nLength); pNode = Lookup(pLast, name); if (!pNode) pNode = AddChild(pLast, name); @@ -532,7 +531,7 @@ bool CFieldTree::SetField(const CFX_WideString& full_name, return true; } -CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) { +CPDF_FormField* CFieldTree::GetField(const WideString& full_name) { if (full_name.IsEmpty()) return nullptr; @@ -544,14 +543,14 @@ CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) { Node* pLast = nullptr; while (nLength > 0 && pNode) { pLast = pNode; - CFX_WideString name = CFX_WideString(pName, nLength); + WideString name = WideString(pName, nLength); pNode = Lookup(pLast, name); name_extractor.GetNext(pName, nLength); } return pNode ? pNode->GetField() : nullptr; } -CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) { +CFieldTree::Node* CFieldTree::FindNode(const WideString& full_name) { if (full_name.IsEmpty()) return nullptr; @@ -563,7 +562,7 @@ CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) { Node* pLast = nullptr; while (nLength > 0 && pNode) { pLast = pNode; - CFX_WideString name = CFX_WideString(pName, nLength); + WideString name = WideString(pName, nLength); pNode = Lookup(pLast, name); name_extractor.GetNext(pName, nLength); } @@ -572,7 +571,7 @@ CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) { CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, - CFX_ByteString* csNameTag) { + ByteString* csNameTag) { uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); return AddNativeFont(pFormDict, pDocument, charSet, csNameTag); } @@ -671,13 +670,13 @@ void CPDF_InterForm::SetUpdateAP(bool bUpdateAP) { s_bUpdateAP = bUpdateAP; } -CFX_ByteString CPDF_InterForm::GenerateNewResourceName( +ByteString CPDF_InterForm::GenerateNewResourceName( const CPDF_Dictionary* pResDict, const char* csType, int iMinLen, const char* csPrefix) { - CFX_ByteString csStr = csPrefix; - CFX_ByteString csBType = csType; + ByteString csStr = csPrefix; + ByteString csBType = csType; if (csStr.IsEmpty()) { if (csBType == "ExtGState") csStr = "GS"; @@ -688,7 +687,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName( else csStr = "Res"; } - CFX_ByteString csTmp = csStr; + ByteString csTmp = csStr; int iCount = csStr.GetLength(); int m = 0; if (iMinLen > 0) { @@ -710,9 +709,9 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName( return csTmp; int num = 0; - CFX_ByteString bsNum; + ByteString bsNum; while (true) { - CFX_ByteString csKey = csTmp + bsNum; + ByteString csKey = csTmp + bsNum; if (!pDict->KeyExist(csKey)) return csKey; if (m < iCount) @@ -726,7 +725,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName( } CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument, - CFX_ByteString csFontName) { + ByteString csFontName) { if (!pDocument || csFontName.IsEmpty()) return nullptr; @@ -737,8 +736,8 @@ CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument, return pDocument->AddStandardFont(csFontName.c_str(), &encoding); } -CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { - CFX_ByteString csFontName; +ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { + ByteString csFontName; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ LOGFONTA lf = {}; if (charSet == FX_CHARSET_ANSI) { @@ -786,7 +785,7 @@ CPDF_Font* CPDF_InterForm::AddNativeFont(uint8_t charSet, #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ LOGFONTA lf; - CFX_ByteString csFontName = GetNativeFont(charSet, &lf); + ByteString csFontName = GetNativeFont(charSet, &lf); if (!csFontName.IsEmpty()) { if (csFontName == "Helvetica") return AddStandardFont(pDocument, csFontName); @@ -801,7 +800,7 @@ CPDF_Font* CPDF_InterForm::AddNativeFont(CPDF_Document* pDocument) { } bool CPDF_InterForm::ValidateFieldName( - CFX_WideString& csNewFieldName, + WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl) const { @@ -810,7 +809,7 @@ bool CPDF_InterForm::ValidateFieldName( int iPos = 0; int iLength = csNewFieldName.GetLength(); - CFX_WideString csSub; + WideString csSub; while (true) { while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName[iPos] == L' ')) { @@ -835,7 +834,7 @@ bool CPDF_InterForm::ValidateFieldName( if (!pExcludedControl || pField->CountControls() < 2) continue; } - CFX_WideString csFullName = pField->GetFullName(); + WideString csFullName = pField->GetFullName(); int iRet = CompareFieldName(csSub, csFullName); if (iRet == 1) { if (pField->GetFieldType() != iType) @@ -858,7 +857,7 @@ bool CPDF_InterForm::ValidateFieldName( return true; } -size_t CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) const { +size_t CPDF_InterForm::CountFields(const WideString& csFieldName) const { if (csFieldName.IsEmpty()) return m_pFieldTree->m_Root.CountFields(); @@ -866,9 +865,8 @@ size_t CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) const { return pNode ? pNode->CountFields() : 0; } -CPDF_FormField* CPDF_InterForm::GetField( - uint32_t index, - const CFX_WideString& csFieldName) const { +CPDF_FormField* CPDF_InterForm::GetField(uint32_t index, + const WideString& csFieldName) const { if (csFieldName.IsEmpty()) return m_pFieldTree->m_Root.GetFieldAtIndex(index); @@ -881,7 +879,7 @@ CPDF_FormField* CPDF_InterForm::GetFieldByDict( if (!pFieldDict) return nullptr; - CFX_WideString csWName = FPDF_GetFullName(pFieldDict); + WideString csWName = FPDF_GetFullName(pFieldDict); return m_pFieldTree->GetField(csWName); } @@ -960,7 +958,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { return -1; } -CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) const { +CPDF_Font* CPDF_InterForm::GetFormFont(ByteString csNameTag) const { return GetFont(m_pFormDict.Get(), m_pDocument.Get(), csNameTag); } @@ -1070,7 +1068,7 @@ void CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { } CPDF_Dictionary* pDict = pFieldDict; - CFX_WideString csWName = FPDF_GetFullName(pFieldDict); + WideString csWName = FPDF_GetFullName(pFieldDict); if (csWName.IsEmpty()) return; @@ -1177,7 +1175,7 @@ bool CPDF_InterForm::CheckRequiredFields( } std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( - const CFX_WideString& pdf_path, + const WideString& pdf_path, bool bSimpleFileSpec) const { std::vector<CPDF_FormField*> fields; size_t nCount = m_pFieldTree->m_Root.CountFields(); @@ -1187,7 +1185,7 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( } std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( - const CFX_WideString& pdf_path, + const WideString& pdf_path, const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude, bool bSimpleFileSpec) const { @@ -1198,9 +1196,9 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictFor("FDF"); if (!pdf_path.IsEmpty()) { if (bSimpleFileSpec) { - CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path); + WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path); pMainDict->SetNewFor<CPDF_String>( - "F", CFX_ByteString::FromUnicode(wsFilePath), false); + "F", ByteString::FromUnicode(wsFilePath), false); pMainDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsFilePath), false); } else { @@ -1230,14 +1228,14 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( continue; } - CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict()); + WideString fullname = FPDF_GetFullName(pField->GetFieldDict()); auto pFieldDict = pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); pFieldDict->SetNewFor<CPDF_String>("T", fullname); if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType() == CPDF_FormField::RadioButton) { - CFX_WideString csExport = pField->GetCheckValue(false); - CFX_ByteString csBExport = PDF_EncodeText(csExport); + WideString csExport = pField->GetCheckValue(false); + ByteString csBExport = PDF_EncodeText(csExport); CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->GetDict(), "Opt"); if (pOpt) pFieldDict->SetNewFor<CPDF_String>("V", csBExport, false); @@ -1255,10 +1253,10 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( } void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, - const CFX_WideString& parent_name, + const WideString& parent_name, bool bNotify, int nLevel) { - CFX_WideString name; + WideString name; if (!parent_name.IsEmpty()) name = parent_name + L"."; @@ -1281,7 +1279,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, if (!pField) return; - CFX_WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding); + WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding); int iType = pField->GetFieldType(); if (bNotify && m_pFormNotify) { if (iType == FIELDTYPE_LISTBOX) { diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h index 9dc0532939..d3796e5752 100644 --- a/core/fpdfdoc/cpdf_interform.h +++ b/core/fpdfdoc/cpdf_interform.h @@ -30,7 +30,7 @@ class IPDF_FormNotify; CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, - CFX_ByteString* csNameTag); + ByteString* csNameTag); class CPDF_InterForm { public: @@ -39,20 +39,19 @@ class CPDF_InterForm { static void SetUpdateAP(bool bUpdateAP); static bool IsUpdateAPEnabled(); - static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, - const char* csType, - int iMinLen, - const char* csPrefix); + static ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, + const char* csType, + int iMinLen, + const char* csPrefix); static CPDF_Font* AddStandardFont(CPDF_Document* pDocument, - CFX_ByteString csFontName); - static CFX_ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont); + ByteString csFontName); + static ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont); static uint8_t GetNativeCharSet(); static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument); static CPDF_Font* AddNativeFont(CPDF_Document* pDocument); - size_t CountFields(const CFX_WideString& csFieldName) const; - CPDF_FormField* GetField(uint32_t index, - const CFX_WideString& csFieldName) const; + size_t CountFields(const WideString& csFieldName) const; + CPDF_FormField* GetField(uint32_t index, const WideString& csFieldName) const; CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, @@ -65,18 +64,18 @@ class CPDF_InterForm { CPDF_FormField* GetFieldInCalculationOrder(int index); int FindFieldInCalculationOrder(const CPDF_FormField* pField); - CPDF_Font* GetFormFont(CFX_ByteString csNameTag) const; + CPDF_Font* GetFormFont(ByteString csNameTag) const; CPDF_DefaultAppearance GetDefaultAppearance() const; int GetFormAlignment() const; bool CheckRequiredFields(const std::vector<CPDF_FormField*>* fields, bool bIncludeOrExclude) const; - std::unique_ptr<CFDF_Document> ExportToFDF(const CFX_WideString& pdf_path, + std::unique_ptr<CFDF_Document> ExportToFDF(const WideString& pdf_path, bool bSimpleFileSpec) const; std::unique_ptr<CFDF_Document> ExportToFDF( - const CFX_WideString& pdf_path, + const WideString& pdf_path, const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude, bool bSimpleFileSpec) const; @@ -99,10 +98,10 @@ class CPDF_InterForm { CPDF_FormControl* AddControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict); void FDF_ImportField(CPDF_Dictionary* pField, - const CFX_WideString& parent_name, + const WideString& parent_name, bool bNotify = false, int nLevel = 0); - bool ValidateFieldName(CFX_WideString& csNewFieldName, + bool ValidateFieldName(WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl) const; @@ -114,7 +113,7 @@ class CPDF_InterForm { std::map<const CPDF_Dictionary*, std::unique_ptr<CPDF_FormControl>> m_ControlMap; std::unique_ptr<CFieldTree> m_pFieldTree; - CFX_ByteString m_bsEncoding; + ByteString m_bsEncoding; CFX_UnownedPtr<IPDF_FormNotify> m_pFormNotify; }; diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp index d225d3f0bf..bdbf8b467e 100644 --- a/core/fpdfdoc/cpdf_nametree.cpp +++ b/core/fpdfdoc/cpdf_nametree.cpp @@ -19,11 +19,10 @@ namespace { const int nMaxRecursion = 32; -std::pair<CFX_WideString, CFX_WideString> GetNodeLimitsMaybeSwap( - CPDF_Array* pLimits) { +std::pair<WideString, WideString> GetNodeLimitsMaybeSwap(CPDF_Array* pLimits) { ASSERT(pLimits); - CFX_WideString csLeft = pLimits->GetUnicodeTextAt(0); - CFX_WideString csRight = pLimits->GetUnicodeTextAt(1); + WideString csLeft = pLimits->GetUnicodeTextAt(0); + WideString csRight = pLimits->GetUnicodeTextAt(1); // If the lower limit is greater than the upper limit, swap them. if (csLeft.Compare(csRight) > 0) { pLimits->SetNewAt<CPDF_String>(0, csRight); @@ -71,14 +70,14 @@ bool GetNodeAncestorsLimits(const CPDF_Dictionary* pNode, // if needed, and any ancestors that are now empty will be removed. bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode, const CPDF_Array* pFind, - const CFX_WideString& csName, + const WideString& csName, int nLevel) { if (nLevel > nMaxRecursion) return false; CPDF_Array* pLimits = pNode->GetArrayFor("Limits"); - CFX_WideString csLeft; - CFX_WideString csRight; + WideString csLeft; + WideString csRight; if (pLimits) std::tie(csLeft, csRight) = GetNodeLimitsMaybeSwap(pLimits); @@ -93,10 +92,10 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode, // Since |csName| defines |pNode|'s limits, we need to loop through the // names to find the new lower and upper limits. - CFX_WideString csNewLeft = csRight; - CFX_WideString csNewRight = csLeft; + WideString csNewLeft = csRight; + WideString csNewRight = csLeft; for (size_t i = 0; i < pNames->GetCount() / 2; ++i) { - CFX_WideString wsName = pNames->GetUnicodeTextAt(i * 2); + WideString wsName = pNames->GetUnicodeTextAt(i * 2); if (wsName.Compare(csNewLeft) < 0) csNewLeft = wsName; if (wsName.Compare(csNewRight) > 0) @@ -131,8 +130,8 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode, // Since |csName| defines |pNode|'s limits, we need to loop through the // kids to find the new lower and upper limits. - CFX_WideString csNewLeft = csRight; - CFX_WideString csNewRight = csLeft; + WideString csNewLeft = csRight; + WideString csNewRight = csLeft; for (size_t j = 0; j < pKids->GetCount(); ++j) { CPDF_Array* pKidLimits = pKids->GetDictAt(j)->GetArrayFor("Limits"); ASSERT(pKidLimits); @@ -155,7 +154,7 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode, // will be the leaf array that |csName| should be added to, and |pFindIndex| // will be the index that it should be added at. CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, - const CFX_WideString& csName, + const WideString& csName, size_t& nIndex, int nLevel, CPDF_Array** ppFind, @@ -166,8 +165,8 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, CPDF_Array* pLimits = pNode->GetArrayFor("Limits"); CPDF_Array* pNames = pNode->GetArrayFor("Names"); if (pLimits) { - CFX_WideString csLeft; - CFX_WideString csRight; + WideString csLeft; + WideString csRight; std::tie(csLeft, csRight) = GetNodeLimitsMaybeSwap(pLimits); // Skip this node if the name to look for is smaller than its lower limit. if (csName.Compare(csLeft) < 0) @@ -189,7 +188,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, if (pNames) { size_t dwCount = pNames->GetCount() / 2; for (size_t i = 0; i < dwCount; i++) { - CFX_WideString csValue = pNames->GetUnicodeTextAt(i * 2); + WideString csValue = pNames->GetUnicodeTextAt(i * 2); int32_t iCompare = csValue.Compare(csName); if (iCompare > 0) break; @@ -233,7 +232,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, size_t nIndex, size_t& nCurIndex, int nLevel, - CFX_WideString* csName, + WideString* csName, CPDF_Array** ppFind, int* pFindIndex) { if (nLevel > nMaxRecursion) @@ -300,7 +299,7 @@ size_t CountNames(CPDF_Dictionary* pNode, int nLevel = 0) { CPDF_NameTree::CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} CPDF_NameTree::CPDF_NameTree(const CPDF_Document* pDoc, - const CFX_ByteString& category) + const ByteString& category) : m_pRoot(nullptr) { const CPDF_Dictionary* pRoot = pDoc->GetRoot(); if (!pRoot) @@ -319,7 +318,7 @@ size_t CPDF_NameTree::GetCount() const { return m_pRoot ? ::CountNames(m_pRoot.Get()) : 0; } -int CPDF_NameTree::GetIndex(const CFX_WideString& csName) const { +int CPDF_NameTree::GetIndex(const WideString& csName) const { if (!m_pRoot) return -1; @@ -330,7 +329,7 @@ int CPDF_NameTree::GetIndex(const CFX_WideString& csName) const { } bool CPDF_NameTree::AddValueAndName(std::unique_ptr<CPDF_Object> pObj, - const CFX_WideString& name) { + const WideString& name) { if (!m_pRoot) return false; @@ -347,7 +346,7 @@ bool CPDF_NameTree::AddValueAndName(std::unique_ptr<CPDF_Object> pObj, // |name| and |pObj|. if (!pFind) { size_t nCurIndex = 0; - CFX_WideString csName; + WideString csName; SearchNameNode(m_pRoot.Get(), 0, nCurIndex, 0, &csName, &pFind, nullptr); } ASSERT(pFind); @@ -381,7 +380,7 @@ bool CPDF_NameTree::DeleteValueAndName(int nIndex) { return false; size_t nCurIndex = 0; - CFX_WideString csName; + WideString csName; CPDF_Array* pFind = nullptr; int nFindIndex = -1; // Fail if the tree does not contain |nIndex|. @@ -400,7 +399,7 @@ bool CPDF_NameTree::DeleteValueAndName(int nIndex) { } CPDF_Object* CPDF_NameTree::LookupValueAndName(int nIndex, - CFX_WideString* csName) const { + WideString* csName) const { csName->clear(); if (!m_pRoot) return nullptr; @@ -410,7 +409,7 @@ CPDF_Object* CPDF_NameTree::LookupValueAndName(int nIndex, nullptr); } -CPDF_Object* CPDF_NameTree::LookupValue(const CFX_WideString& csName) const { +CPDF_Object* CPDF_NameTree::LookupValue(const WideString& csName) const { if (!m_pRoot) return nullptr; @@ -419,7 +418,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(const CFX_WideString& csName) const { } CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, - const CFX_WideString& sName) { + const WideString& sName) { CPDF_Object* pValue = LookupValue(sName); if (!pValue) { CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictFor("Dests"); diff --git a/core/fpdfdoc/cpdf_nametree.h b/core/fpdfdoc/cpdf_nametree.h index 4dc43fc3ac..add62f1767 100644 --- a/core/fpdfdoc/cpdf_nametree.h +++ b/core/fpdfdoc/cpdf_nametree.h @@ -20,18 +20,18 @@ class CPDF_Object; class CPDF_NameTree { public: explicit CPDF_NameTree(CPDF_Dictionary* pRoot); - CPDF_NameTree(const CPDF_Document* pDoc, const CFX_ByteString& category); + CPDF_NameTree(const CPDF_Document* pDoc, const ByteString& category); ~CPDF_NameTree(); bool AddValueAndName(std::unique_ptr<CPDF_Object> pObj, - const CFX_WideString& name); + const WideString& name); bool DeleteValueAndName(int nIndex); - CPDF_Object* LookupValueAndName(int nIndex, CFX_WideString* csName) const; - CPDF_Object* LookupValue(const CFX_WideString& csName) const; - CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_WideString& sName); + CPDF_Object* LookupValueAndName(int nIndex, WideString* csName) const; + CPDF_Object* LookupValue(const WideString& csName) const; + CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const WideString& sName); - int GetIndex(const CFX_WideString& csName) const; + int GetIndex(const WideString& csName) const; size_t GetCount() const; CPDF_Dictionary* GetRoot() const { return m_pRoot.Get(); } diff --git a/core/fpdfdoc/cpdf_nametree_unittest.cpp b/core/fpdfdoc/cpdf_nametree_unittest.cpp index e6e188a72c..38c3140b90 100644 --- a/core/fpdfdoc/cpdf_nametree_unittest.cpp +++ b/core/fpdfdoc/cpdf_nametree_unittest.cpp @@ -84,17 +84,17 @@ TEST(cpdf_nametree, GetUnicodeNameWithBOM) { constexpr char kData[] = "\xFE\xFF\x00\x31"; for (size_t i = 0; i < sizeof(kData); ++i) buf.put(kData[i]); - pNames->AddNew<CPDF_String>(CFX_ByteString(buf), true); + pNames->AddNew<CPDF_String>(ByteString(buf), true); pNames->AddNew<CPDF_Number>(100); // Check that the key is as expected. CPDF_NameTree nameTree(pRootDict.get()); - CFX_WideString storedName; + WideString storedName; nameTree.LookupValueAndName(0, &storedName); EXPECT_STREQ(L"1", storedName.c_str()); // Check that the correct value object can be obtained by looking up "1". - CFX_WideString matchName = L"1"; + WideString matchName = L"1"; CPDF_Object* pObj = nameTree.LookupValue(matchName); ASSERT_TRUE(pObj->IsNumber()); EXPECT_EQ(100, pObj->AsNumber()->GetInteger()); @@ -232,7 +232,7 @@ TEST(cpdf_nametree, DeleteFromKids) { // Delete the name "9.txt", and check that its node gets deleted and its // parent node's limits get updated. - CFX_WideString csName; + WideString csName; ASSERT_TRUE(nameTree.LookupValue(L"9.txt")); EXPECT_EQ(999, nameTree.LookupValue(L"9.txt")->GetInteger()); EXPECT_TRUE(nameTree.LookupValueAndName(4, &csName)); diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp index 7e746e0028..069292c65b 100644 --- a/core/fpdfdoc/cpdf_occontext.cpp +++ b/core/fpdfdoc/cpdf_occontext.cpp @@ -24,13 +24,13 @@ int32_t FindGroup(const CPDF_Array* pArray, const CPDF_Dictionary* pGroupDict) { } bool HasIntent(const CPDF_Dictionary* pDict, - const CFX_ByteStringC& csElement, - const CFX_ByteStringC& csDef) { + const ByteStringView& csElement, + const ByteStringView& csDef) { CPDF_Object* pIntent = pDict->GetDirectObjectFor("Intent"); if (!pIntent) return csElement == csDef; - CFX_ByteString bsIntent; + ByteString bsIntent; if (CPDF_Array* pArray = pIntent->AsArray()) { for (size_t i = 0; i < pArray->GetCount(); i++) { bsIntent = pArray->GetStringAt(i); @@ -70,8 +70,8 @@ CPDF_Dictionary* GetConfig(CPDF_Document* pDoc, return pConfig; } -CFX_ByteString GetUsageTypeString(CPDF_OCContext::UsageType eType) { - CFX_ByteString csState; +ByteString GetUsageTypeString(CPDF_OCContext::UsageType eType) { + ByteString csState; switch (eType) { case CPDF_OCContext::Design: csState = "Design"; @@ -99,7 +99,7 @@ CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType) CPDF_OCContext::~CPDF_OCContext() {} bool CPDF_OCContext::LoadOCGStateFromConfig( - const CFX_ByteString& csConfig, + const ByteString& csConfig, const CPDF_Dictionary* pOCGDict) const { CPDF_Dictionary* pConfig = GetConfig(m_pDocument.Get(), pOCGDict); if (!pConfig) @@ -120,7 +120,7 @@ bool CPDF_OCContext::LoadOCGStateFromConfig( if (!pArray) return bState; - CFX_ByteString csFind = csConfig + "State"; + ByteString csFind = csConfig + "State"; for (size_t i = 0; i < pArray->GetCount(); i++) { CPDF_Dictionary* pUsage = pArray->GetDictAt(i); if (!pUsage) @@ -149,12 +149,12 @@ bool CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const { if (!HasIntent(pOCGDict, "View", "View")) return true; - CFX_ByteString csState = GetUsageTypeString(m_eUsageType); + ByteString csState = GetUsageTypeString(m_eUsageType); CPDF_Dictionary* pUsage = pOCGDict->GetDictFor("Usage"); if (pUsage) { CPDF_Dictionary* pState = pUsage->GetDictFor(csState); if (pState) { - CFX_ByteString csFind = csState + "State"; + ByteString csFind = csState + "State"; if (pState->KeyExist(csFind)) return pState->GetStringFor(csFind) != "OFF"; } @@ -196,7 +196,7 @@ bool CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int nLevel) { if (nLevel > 32 || !pExpression) return false; - CFX_ByteString csOperator = pExpression->GetStringAt(0); + ByteString csOperator = pExpression->GetStringAt(0); if (csOperator == "Not") { CPDF_Object* pOCGObj = pExpression->GetDirectObjectAt(1); if (!pOCGObj) @@ -241,7 +241,7 @@ bool CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict) { if (pVE) return GetOCGVE(pVE, 0); - CFX_ByteString csP = pOCMDDict->GetStringFor("P", "AnyOn"); + ByteString csP = pOCMDDict->GetStringFor("P", "AnyOn"); CPDF_Object* pOCGObj = pOCMDDict->GetDirectObjectFor("OCGs"); if (!pOCGObj) return true; @@ -279,7 +279,7 @@ bool CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary* pOCGDict) { if (!pOCGDict) return true; - CFX_ByteString csType = pOCGDict->GetStringFor("Type", "OCG"); + ByteString csType = pOCGDict->GetStringFor("Type", "OCG"); if (csType == "OCG") return GetOCGVisible(pOCGDict); return LoadOCMDState(pOCGDict); diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h index ea8eea2489..3c93ef1d59 100644 --- a/core/fpdfdoc/cpdf_occontext.h +++ b/core/fpdfdoc/cpdf_occontext.h @@ -31,7 +31,7 @@ class CPDF_OCContext : public CFX_Retainable { CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType); ~CPDF_OCContext() override; - bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig, + bool LoadOCGStateFromConfig(const ByteString& csConfig, const CPDF_Dictionary* pOCGDict) const; bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const; bool GetOCGVisible(const CPDF_Dictionary* pOCGDict); diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp index 7b5e66e585..5efb18ef3d 100644 --- a/core/fpdfdoc/cpdf_pagelabel.cpp +++ b/core/fpdfdoc/cpdf_pagelabel.cpp @@ -13,16 +13,15 @@ namespace { -CFX_WideString MakeRoman(int num) { +WideString MakeRoman(int num) { const int kArabic[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; - const CFX_WideString kRoman[] = {L"m", L"cm", L"d", L"cd", L"c", - L"xc", L"l", L"xl", L"x", L"ix", - L"v", L"iv", L"i"}; + const WideString kRoman[] = {L"m", L"cm", L"d", L"cd", L"c", L"xc", L"l", + L"xl", L"x", L"ix", L"v", L"iv", L"i"}; const int kMaxNum = 1000000; num %= kMaxNum; int i = 0; - CFX_WideString wsRomanNumber; + WideString wsRomanNumber; while (num > 0) { while (num >= kArabic[i]) { num = num - kArabic[i]; @@ -33,11 +32,11 @@ CFX_WideString MakeRoman(int num) { return wsRomanNumber; } -CFX_WideString MakeLetters(int num) { +WideString MakeLetters(int num) { if (num == 0) - return CFX_WideString(); + return WideString(); - CFX_WideString wsLetters; + WideString wsLetters; const int nMaxCount = 1000; const int nLetterCount = 26; --num; @@ -50,8 +49,8 @@ CFX_WideString MakeLetters(int num) { return wsLetters; } -CFX_WideString GetLabelNumPortion(int num, const CFX_ByteString& bsStyle) { - CFX_WideString wsNumPortion; +WideString GetLabelNumPortion(int num, const ByteString& bsStyle) { + WideString wsNumPortion; if (bsStyle.IsEmpty()) return wsNumPortion; if (bsStyle == "D") { @@ -77,7 +76,7 @@ CPDF_PageLabel::CPDF_PageLabel(CPDF_Document* pDocument) CPDF_PageLabel::~CPDF_PageLabel() {} -bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const { +bool CPDF_PageLabel::GetLabel(int nPage, WideString* wsLabel) const { if (!m_pDocument) return false; @@ -108,10 +107,9 @@ bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const { if (pLabel->KeyExist("P")) *wsLabel += pLabel->GetUnicodeTextFor("P"); - CFX_ByteString bsNumberingStyle = pLabel->GetStringFor("S", ""); + ByteString bsNumberingStyle = pLabel->GetStringFor("S", ""); int nLabelNum = nPage - n + pLabel->GetIntegerFor("St", 1); - CFX_WideString wsNumPortion = - GetLabelNumPortion(nLabelNum, bsNumberingStyle); + WideString wsNumPortion = GetLabelNumPortion(nLabelNum, bsNumberingStyle); *wsLabel += wsNumPortion; return true; } @@ -120,7 +118,7 @@ bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const { return true; } -int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { +int32_t CPDF_PageLabel::GetPageByLabel(const ByteStringView& bsLabel) const { if (!m_pDocument) return -1; @@ -130,19 +128,19 @@ int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { int nPages = m_pDocument->GetPageCount(); for (int i = 0; i < nPages; i++) { - CFX_WideString str; + WideString str; if (!GetLabel(i, &str)) continue; if (PDF_EncodeText(str).Compare(bsLabel)) return i; } - int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate. + int nPage = FXSYS_atoi(ByteString(bsLabel).c_str()); // NUL terminate. return nPage > 0 && nPage <= nPages ? nPage : -1; } -int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { +int32_t CPDF_PageLabel::GetPageByLabel(const WideStringView& wsLabel) const { // TODO(tsepez): check usage of c_str() below. return GetPageByLabel( - PDF_EncodeText(wsLabel.unterminated_c_str()).AsStringC()); + PDF_EncodeText(wsLabel.unterminated_c_str()).AsStringView()); } diff --git a/core/fpdfdoc/cpdf_pagelabel.h b/core/fpdfdoc/cpdf_pagelabel.h index 66324f87c6..1b21ca8bdb 100644 --- a/core/fpdfdoc/cpdf_pagelabel.h +++ b/core/fpdfdoc/cpdf_pagelabel.h @@ -16,9 +16,9 @@ class CPDF_PageLabel { explicit CPDF_PageLabel(CPDF_Document* pDocument); ~CPDF_PageLabel(); - bool GetLabel(int nPage, CFX_WideString* wsLabel) const; - int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const; - int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const; + bool GetLabel(int nPage, WideString* wsLabel) const; + int32_t GetPageByLabel(const ByteStringView& bsLabel) const; + int32_t GetPageByLabel(const WideStringView& wsLabel) const; private: CFX_UnownedPtr<CPDF_Document> const m_pDocument; diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp index c5f2b6bd79..0b0b542852 100644 --- a/core/fpdfdoc/cpdf_structelement.cpp +++ b/core/fpdfdoc/cpdf_structelement.cpp @@ -36,7 +36,7 @@ CPDF_StructElement::CPDF_StructElement(CPDF_StructTree* pTree, m_Type(pDict->GetStringFor("S")), m_Title(pDict->GetStringFor("T")) { if (pTree->GetRoleMap()) { - CFX_ByteString mapped = pTree->GetRoleMap()->GetStringFor(m_Type); + ByteString mapped = pTree->GetRoleMap()->GetStringFor(m_Type); if (!mapped.IsEmpty()) m_Type = mapped; } @@ -102,7 +102,7 @@ void CPDF_StructElement::LoadKid(uint32_t PageObjNum, if (CPDF_Reference* pRef = ToReference(pKidDict->GetObjectFor("Pg"))) PageObjNum = pRef->GetRefObjNum(); - CFX_ByteString type = pKidDict->GetStringFor("Type"); + ByteString type = pKidDict->GetStringFor("Type"); if ((type == "MCR" || type == "OBJR") && m_pTree->GetPage() && m_pTree->GetPage()->GetObjNum() != PageObjNum) { return; diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h index 8fe73e51c8..b54487e7f8 100644 --- a/core/fpdfdoc/cpdf_structelement.h +++ b/core/fpdfdoc/cpdf_structelement.h @@ -39,8 +39,8 @@ class CPDF_StructElement : public CFX_Retainable { template <typename T, typename... Args> friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); - const CFX_ByteString& GetType() const { return m_Type; } - const CFX_ByteString& GetTitle() const { return m_Title; } + const ByteString& GetType() const { return m_Type; } + const ByteString& GetTitle() const { return m_Title; } CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } int CountKids() const; @@ -59,8 +59,8 @@ class CPDF_StructElement : public CFX_Retainable { CFX_UnownedPtr<CPDF_StructTree> const m_pTree; CFX_UnownedPtr<CPDF_StructElement> const m_pParent; CFX_UnownedPtr<CPDF_Dictionary> const m_pDict; - CFX_ByteString m_Type; - CFX_ByteString m_Title; + ByteString m_Type; + ByteString m_Title; std::vector<CPDF_StructKid> m_Kids; }; diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 877f8ca01e..d3de6129f1 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -354,7 +354,7 @@ CPVT_WordPlace CPDF_VariableText::InsertSection( CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, const wchar_t* text) { - CFX_WideString swText = text; + WideString swText = text; CPVT_WordPlace wp = place; for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { CPVT_WordPlace oldwp = wp; @@ -412,7 +412,7 @@ CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { return ClearLeftWord(AdjustLineHeader(place, true)); } -void CPDF_VariableText::SetText(const CFX_WideString& swText) { +void CPDF_VariableText::SetText(const WideString& swText) { DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); CPVT_WordPlace wp(0, 0, -1); CPVT_SectionInfo secinfo; diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h index a226350006..704408c5be 100644 --- a/core/fpdfdoc/cpdf_variabletext.h +++ b/core/fpdfdoc/cpdf_variabletext.h @@ -106,7 +106,7 @@ class CPDF_VariableText { void RearrangeAll(); void RearrangePart(const CPVT_WordRange& PlaceRange); void ResetAll(); - void SetText(const CFX_WideString& text); + void SetText(const WideString& text); CPVT_WordPlace InsertWord(const CPVT_WordPlace& place, uint16_t word, int32_t charset, diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp index e25316b6fb..e7fb1416a8 100644 --- a/core/fpdfdoc/cpdf_viewerpreferences.cpp +++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp @@ -34,13 +34,13 @@ CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const { return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr; } -CFX_ByteString CPDF_ViewerPreferences::Duplex() const { +ByteString CPDF_ViewerPreferences::Duplex() const { CPDF_Dictionary* pDict = GetViewerPreferences(); - return pDict ? pDict->GetStringFor("Duplex") : CFX_ByteString("None"); + return pDict ? pDict->GetStringFor("Duplex") : ByteString("None"); } -bool CPDF_ViewerPreferences::GenericName(const CFX_ByteString& bsKey, - CFX_ByteString* bsVal) const { +bool CPDF_ViewerPreferences::GenericName(const ByteString& bsKey, + ByteString* bsVal) const { ASSERT(bsVal); CPDF_Dictionary* pDict = GetViewerPreferences(); if (!pDict) diff --git a/core/fpdfdoc/cpdf_viewerpreferences.h b/core/fpdfdoc/cpdf_viewerpreferences.h index 46428a238c..bbe5d1a512 100644 --- a/core/fpdfdoc/cpdf_viewerpreferences.h +++ b/core/fpdfdoc/cpdf_viewerpreferences.h @@ -24,12 +24,12 @@ class CPDF_ViewerPreferences { bool PrintScaling() const; int32_t NumCopies() const; CPDF_Array* PrintPageRange() const; - CFX_ByteString Duplex() const; + ByteString Duplex() const; // Gets the entry for |bsKey|. If the entry exists and it is of type name, // then this method writes the value into |bsVal| and returns true. Otherwise // returns false and |bsVal| is untouched. |bsVal| must not be NULL. - bool GenericName(const CFX_ByteString& bsKey, CFX_ByteString* bsVal) const; + bool GenericName(const ByteString& bsKey, ByteString* bsVal) const; private: CPDF_Dictionary* GetViewerPreferences() const; diff --git a/core/fpdfdoc/cpvt_color.cpp b/core/fpdfdoc/cpvt_color.cpp index 584a85aaec..914e416dbd 100644 --- a/core/fpdfdoc/cpvt_color.cpp +++ b/core/fpdfdoc/cpvt_color.cpp @@ -9,8 +9,8 @@ #include "core/fpdfapi/parser/cpdf_simple_parser.h" // Static. -CPVT_Color CPVT_Color::ParseColor(const CFX_ByteString& str) { - CPDF_SimpleParser syntax(str.AsStringC()); +CPVT_Color CPVT_Color::ParseColor(const ByteString& str) { + CPDF_SimpleParser syntax(str.AsStringView()); if (syntax.FindTagParamFromStart("g", 1)) return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord())); diff --git a/core/fpdfdoc/cpvt_color.h b/core/fpdfdoc/cpvt_color.h index 2db3b8310e..a7e925bf79 100644 --- a/core/fpdfdoc/cpvt_color.h +++ b/core/fpdfdoc/cpvt_color.h @@ -31,7 +31,7 @@ struct CPVT_Color { float fColor3; float fColor4; - static CPVT_Color ParseColor(const CFX_ByteString& str); + static CPVT_Color ParseColor(const ByteString& str); static CPVT_Color ParseColor(const CPDF_Array& array); }; diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 0edabd1bc3..aaf8661f1e 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -17,7 +17,7 @@ CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, CPDF_Font* pDefFont, - const CFX_ByteString& sDefFontAlias) + const ByteString& sDefFontAlias) : m_pDocument(pDoc), m_pResDict(pResDict), m_pDefFont(pDefFont), @@ -27,7 +27,7 @@ CPVT_FontMap::~CPVT_FontMap() {} CPDF_Font* CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, const CPDF_Dictionary* pResDict, - CFX_ByteString* sSysFontAlias) { + ByteString* sSysFontAlias) { if (!pDoc || !pResDict) return nullptr; @@ -59,7 +59,7 @@ CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { } } -CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { +ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { switch (nFontIndex) { case 0: return m_sDefFontAlias; @@ -70,7 +70,7 @@ CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { } return m_sSysFontAlias; default: - return CFX_ByteString(); + return ByteString(); } } diff --git a/core/fpdfdoc/cpvt_fontmap.h b/core/fpdfdoc/cpvt_fontmap.h index da69463d95..feca454774 100644 --- a/core/fpdfdoc/cpvt_fontmap.h +++ b/core/fpdfdoc/cpvt_fontmap.h @@ -22,12 +22,12 @@ class CPVT_FontMap : public IPVT_FontMap { CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, CPDF_Font* pDefFont, - const CFX_ByteString& sDefFontAlias); + const ByteString& sDefFontAlias); ~CPVT_FontMap() override; // IPVT_FontMap: CPDF_Font* GetPDFFont(int32_t nFontIndex) override; - CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; + ByteString GetPDFFontAlias(int32_t nFontIndex) override; int32_t GetWordFontIndex(uint16_t word, int32_t charset, int32_t nFontIndex) override; @@ -36,15 +36,15 @@ class CPVT_FontMap : public IPVT_FontMap { static CPDF_Font* GetAnnotSysPDFFont(CPDF_Document* pDoc, const CPDF_Dictionary* pResDict, - CFX_ByteString* sSysFontAlias); + ByteString* sSysFontAlias); private: CFX_UnownedPtr<CPDF_Document> const m_pDocument; CFX_UnownedPtr<CPDF_Dictionary> const m_pResDict; CFX_UnownedPtr<CPDF_Font> const m_pDefFont; CFX_UnownedPtr<CPDF_Font> m_pSysFont; - const CFX_ByteString m_sDefFontAlias; - CFX_ByteString m_sSysFontAlias; + const ByteString m_sDefFontAlias; + ByteString m_sSysFontAlias; }; #endif // CORE_FPDFDOC_CPVT_FONTMAP_H_ diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 132e771d47..634864c957 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -42,7 +42,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, if (!pFormDict) return false; - CFX_ByteString DA; + ByteString DA; if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) DA = pDAObj->GetString(); if (DA.IsEmpty()) @@ -50,9 +50,9 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, if (DA.IsEmpty()) return false; - CPDF_SimpleParser syntax(DA.AsStringC()); + CPDF_SimpleParser syntax(DA.AsStringView()); syntax.FindTagParamFromStart("Tf", 2); - CFX_ByteString sFontName(syntax.GetWord()); + ByteString sFontName(syntax.GetWord()); sFontName = PDF_NameDecode(sFontName); if (sFontName.IsEmpty()) return false; @@ -161,14 +161,13 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, crBG = CPVT_Color::ParseColor(*pArray); } std::ostringstream sAppStream; - CFX_ByteString sBG = - CPVT_GenerateAP::GenerateColorAP(crBG, PaintOperation::FILL); + ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, PaintOperation::FILL); if (sBG.GetLength() > 0) { sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" << "Q\n"; } - CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( + ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder); if (sBorderStream.GetLength() > 0) @@ -208,10 +207,10 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, } switch (nWidgetType) { case 0: { - CFX_WideString swValue = + WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V") ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() - : CFX_WideString(); + : WideString(); int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q") ? FPDF_GetFieldAttr(pAnnotDict, "Q")->GetInteger() : 0; @@ -260,7 +259,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, ptOffset = CFX_PointF(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); } - CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP( + ByteString sBody = CPVT_GenerateAP::GenerateEditAP( &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); if (sBody.GetLength() > 0) { sAppStream << "/Tx BMC\n" @@ -279,10 +278,10 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, } } break; case 1: { - CFX_WideString swValue = + WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V") ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() - : CFX_WideString(); + : WideString(); CPVT_FontMap map( pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); @@ -307,8 +306,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, CFX_FloatRect rcContent = vt.GetContentRect(); CFX_PointF ptOffset = CFX_PointF(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); - CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( - &map, vt.GetIterator(), ptOffset, true, 0); + ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), + ptOffset, true, 0); if (sEdit.GetLength() > 0) { sAppStream << "/Tx BMC\n" << "q\n"; @@ -320,7 +319,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, << sEdit << "ET\n" << "Q\nEMC\n"; } - CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( + ByteString sButton = CPVT_GenerateAP::GenerateColorAP( CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f), PaintOperation::FILL); @@ -329,7 +328,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, sAppStream << rcButton.left << " " << rcButton.bottom << " " << rcButton.Width() << " " << rcButton.Height() << " re f\n"; sAppStream << "Q\n"; - CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( + ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), CPVT_Color(CPVT_Color::kGray, 1), CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED, @@ -368,7 +367,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, break; if (CPDF_Object* pOpt = pOpts->GetDirectObjectAt(i)) { - CFX_WideString swItem; + WideString swItem; if (pOpt->IsString()) swItem = pOpt->GetUnicodeText(); else if (CPDF_Array* pArray = pOpt->AsArray()) @@ -461,9 +460,9 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, return true; } -CFX_ByteString GetColorStringWithDefault(CPDF_Array* pColor, - const CPVT_Color& crDefaultColor, - PaintOperation nOperation) { +ByteString GetColorStringWithDefault(CPDF_Array* pColor, + const CPVT_Color& crDefaultColor, + PaintOperation nOperation) { if (pColor) { CPVT_Color color = CPVT_Color::ParseColor(*pColor); return CPVT_GenerateAP::GenerateColorAP(color, nOperation); @@ -500,10 +499,10 @@ CPDF_Array* GetDashArray(const CPDF_Dictionary& pAnnotDict) { return nullptr; } -CFX_ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) { +ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) { CPDF_Array* pDashArray = GetDashArray(pAnnotDict); if (!pDashArray || pDashArray->IsEmpty()) - return CFX_ByteString(); + return ByteString(); // Support maximum of ten elements in the dash array. size_t pDashArrayCount = std::min<size_t>(pDashArray->GetCount(), 10); @@ -514,14 +513,14 @@ CFX_ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) { sDashStream << pDashArray->GetNumberAt(i) << " "; sDashStream << "] 0 d\n"; - return CFX_ByteString(sDashStream); + return ByteString(sDashStream); } -CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc, - const CPDF_Dictionary& pAnnotDict, - CPDF_Font* pDefFont, - const CFX_ByteString& sFontName) { - CFX_WideString swValue(pAnnotDict.GetUnicodeTextFor("T")); +ByteString GetPopupContentsString(CPDF_Document* pDoc, + const CPDF_Dictionary& pAnnotDict, + CPDF_Font* pDefFont, + const ByteString& sFontName) { + WideString swValue(pAnnotDict.GetUnicodeTextFor("T")); swValue += L'\n'; swValue += pAnnotDict.GetUnicodeTextFor("Contents"); CPVT_FontMap map(pDoc, nullptr, pDefFont, sFontName); @@ -538,11 +537,11 @@ CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc, vt.SetText(swValue); vt.RearrangeAll(); CFX_PointF ptOffset(3.0f, -3.0f); - CFX_ByteString sContent = CPVT_GenerateAP::GenerateEditAP( - &map, vt.GetIterator(), ptOffset, false, 0); + ByteString sContent = CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), + ptOffset, false, 0); if (sContent.IsEmpty()) - return CFX_ByteString(); + return ByteString(); std::ostringstream sAppStream; sAppStream << "BT\n" @@ -550,12 +549,12 @@ CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc, CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::FILL) << sContent << "ET\n" << "Q\n"; - return CFX_ByteString(sAppStream); + return ByteString(sAppStream); } std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict( CPDF_Document* pDoc, - const CFX_ByteString& sFontDictName) { + const ByteString& sFontDictName) { CPDF_Dictionary* pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); pFontDict->SetNewFor<CPDF_Name>("Type", "Font"); pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); @@ -569,13 +568,13 @@ std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict( return pResourceFontDict; } -CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { +ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { if (bIsStrokeRect) return bIsFillRect ? "b" : "s"; return bIsFillRect ? "f" : "n"; } -CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { +ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { std::ostringstream sAppStream; sAppStream << CPVT_GenerateAP::GenerateColorAP( CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), PaintOperation::FILL); @@ -622,7 +621,7 @@ CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { } sAppStream << "B*\n"; - return CFX_ByteString(sAppStream); + return ByteString(sAppStream); } } // namespace @@ -635,7 +634,7 @@ bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { if (!pFieldTypeObj) return false; - CFX_ByteString field_type = pFieldTypeObj->GetString(); + ByteString field_type = pFieldTypeObj->GetString(); if (field_type == "Tx") return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); @@ -684,7 +683,7 @@ bool CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC"); @@ -758,7 +757,7 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), @@ -796,7 +795,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, return false; std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), @@ -840,7 +839,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); @@ -863,7 +862,7 @@ bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), @@ -890,7 +889,7 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs\n"; sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), @@ -908,7 +907,7 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " " << rect.Height() << " re b\n"; - CFX_ByteString sFontName = "FONT"; + ByteString sFontName = "FONT"; auto pResourceFontDict = GenerateResourceFontDict(pDoc, sFontName); CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict.get()); if (!pDefFont) @@ -928,7 +927,7 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC"); @@ -976,7 +975,7 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), @@ -1025,7 +1024,7 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { std::ostringstream sAppStream; - CFX_ByteString sExtGSDictName = "GS"; + ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), @@ -1050,7 +1049,7 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, } // Static. -CFX_ByteString CPVT_GenerateAP::GenerateEditAP( +ByteString CPVT_GenerateAP::GenerateEditAP( IPVT_FontMap* pFontMap, CPDF_VariableText::Iterator* pIterator, const CFX_PointF& ptOffset, @@ -1070,7 +1069,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( if (bContinuous) { if (place.LineCmp(oldplace) != 0) { if (sWords.tellp() > 0) { - sLineStream << GetWordRenderString(CFX_ByteString(sWords)); + sLineStream << GetWordRenderString(ByteString(sWords)); sEditStream << sLineStream.str(); sLineStream.str(""); sWords.str(""); @@ -1095,7 +1094,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( if (pIterator->GetWord(word)) { if (word.nFontIndex != nCurFontIndex) { if (sWords.tellp() > 0) { - sLineStream << GetWordRenderString(CFX_ByteString(sWords)); + sLineStream << GetWordRenderString(ByteString(sWords)); sWords.str(""); } sLineStream << GetFontSetString(pFontMap, word.nFontIndex, @@ -1126,24 +1125,23 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } } if (sWords.tellp() > 0) { - sLineStream << GetWordRenderString(CFX_ByteString(sWords)); + sLineStream << GetWordRenderString(ByteString(sWords)); sEditStream << sLineStream.str(); sWords.str(""); } - return CFX_ByteString(sEditStream); + return ByteString(sEditStream); } // Static. -CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( - const CFX_FloatRect& rect, - float fWidth, - const CPVT_Color& color, - const CPVT_Color& crLeftTop, - const CPVT_Color& crRightBottom, - BorderStyle nStyle, - const CPVT_Dash& dash) { +ByteString CPVT_GenerateAP::GenerateBorderAP(const CFX_FloatRect& rect, + float fWidth, + const CPVT_Color& color, + const CPVT_Color& crLeftTop, + const CPVT_Color& crRightBottom, + BorderStyle nStyle, + const CPVT_Dash& dash) { std::ostringstream sAppStream; - CFX_ByteString sColor; + ByteString sColor; float fLeft = rect.left; float fRight = rect.right; float fTop = rect.top; @@ -1238,12 +1236,12 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( break; } } - return CFX_ByteString(sAppStream); + return ByteString(sAppStream); } // Static. -CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, - PaintOperation nOperation) { +ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, + PaintOperation nOperation) { std::ostringstream sColorStream; switch (color.nColorType) { case CPVT_Color::kRGB: @@ -1266,14 +1264,14 @@ CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, case CPVT_Color::kTransparent: break; } - return CFX_ByteString(sColorStream); + return ByteString(sColorStream); } // Static. std::unique_ptr<CPDF_Dictionary> CPVT_GenerateAP::GenerateExtGStateDict( const CPDF_Dictionary& pAnnotDict, - const CFX_ByteString& sExtGSDictName, - const CFX_ByteString& sBlendMode) { + const ByteString& sExtGSDictName, + const ByteString& sBlendMode) { auto pGSDict = pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); pGSDict->SetNewFor<CPDF_String>("Type", "ExtGState", false); @@ -1334,11 +1332,11 @@ void CPVT_GenerateAP::GenerateAndSetAPDict( } // Static. -CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, - int32_t nFontIndex, - uint16_t Word, - uint16_t SubWord) { - CFX_ByteString sWord; +ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, + int32_t nFontIndex, + uint16_t Word, + uint16_t SubWord) { + ByteString sWord; if (SubWord > 0) { sWord.Format("%c", SubWord); return sWord; @@ -1361,22 +1359,21 @@ CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, } // Static. -CFX_ByteString CPVT_GenerateAP::GetWordRenderString( - const CFX_ByteString& strWords) { +ByteString CPVT_GenerateAP::GetWordRenderString(const ByteString& strWords) { if (strWords.GetLength() > 0) return PDF_EncodeString(strWords, false) + " Tj\n"; return ""; } // Static. -CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap, - int32_t nFontIndex, - float fFontSize) { +ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap, + int32_t nFontIndex, + float fFontSize) { std::ostringstream sRet; if (pFontMap) { - CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); + ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); if (sFontAlias.GetLength() > 0 && fFontSize > 0) sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; } - return CFX_ByteString(sRet); + return ByteString(sRet); } diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h index cee96cda50..2812b29a47 100644 --- a/core/fpdfdoc/cpvt_generateap.h +++ b/core/fpdfdoc/cpvt_generateap.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFDOC_CPVT_GENERATEAP_H_ #define CORE_FPDFDOC_CPVT_GENERATEAP_H_ +#include <memory> + #include "core/fpdfdoc/cpdf_defaultappearance.h" #include "core/fpdfdoc/cpdf_variabletext.h" #include "core/fpdfdoc/cpvt_color.h" @@ -46,24 +48,24 @@ class CPVT_GenerateAP { CPDF_Dictionary* pAnnotDict); static bool GenerateUnderlineAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); - static CFX_ByteString GenerateEditAP(IPVT_FontMap* pFontMap, - CPDF_VariableText::Iterator* pIterator, - const CFX_PointF& ptOffset, - bool bContinuous, - uint16_t SubWord); - static CFX_ByteString GenerateBorderAP(const CFX_FloatRect& rect, - float fWidth, - const CPVT_Color& color, - const CPVT_Color& crLeftTop, - const CPVT_Color& crRightBottom, - BorderStyle nStyle, - const CPVT_Dash& dash); - static CFX_ByteString GenerateColorAP(const CPVT_Color& color, - PaintOperation nOperation); + static ByteString GenerateEditAP(IPVT_FontMap* pFontMap, + CPDF_VariableText::Iterator* pIterator, + const CFX_PointF& ptOffset, + bool bContinuous, + uint16_t SubWord); + static ByteString GenerateBorderAP(const CFX_FloatRect& rect, + float fWidth, + const CPVT_Color& color, + const CPVT_Color& crLeftTop, + const CPVT_Color& crRightBottom, + BorderStyle nStyle, + const CPVT_Dash& dash); + static ByteString GenerateColorAP(const CPVT_Color& color, + PaintOperation nOperation); static std::unique_ptr<CPDF_Dictionary> GenerateExtGStateDict( const CPDF_Dictionary& pAnnotDict, - const CFX_ByteString& sExtGSDictName, - const CFX_ByteString& sBlendMode); + const ByteString& sExtGSDictName, + const ByteString& sBlendMode); static std::unique_ptr<CPDF_Dictionary> GenerateResourceDict( CPDF_Document* pDoc, std::unique_ptr<CPDF_Dictionary> pExtGStateDict, @@ -75,14 +77,14 @@ class CPVT_GenerateAP { std::unique_ptr<CPDF_Dictionary> pResourceDict, bool bIsTextMarkupAnnotation); - static CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap, - int32_t nFontIndex, - uint16_t Word, - uint16_t SubWord); - static CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords); - static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap, - int32_t nFontIndex, - float fFontSize); + static ByteString GetPDFWordString(IPVT_FontMap* pFontMap, + int32_t nFontIndex, + uint16_t Word, + uint16_t SubWord); + static ByteString GetWordRenderString(const ByteString& strWords); + static ByteString GetFontSetString(IPVT_FontMap* pFontMap, + int32_t nFontIndex, + float fFontSize); }; #endif // CORE_FPDFDOC_CPVT_GENERATEAP_H_ diff --git a/core/fpdfdoc/ipdf_formnotify.h b/core/fpdfdoc/ipdf_formnotify.h index bf6127dce2..52e5cc96aa 100644 --- a/core/fpdfdoc/ipdf_formnotify.h +++ b/core/fpdfdoc/ipdf_formnotify.h @@ -17,10 +17,10 @@ class IPDF_FormNotify { virtual ~IPDF_FormNotify() {} virtual int BeforeValueChange(CPDF_FormField* pField, - const CFX_WideString& csValue) = 0; + const WideString& csValue) = 0; virtual void AfterValueChange(CPDF_FormField* pField) = 0; virtual int BeforeSelectionChange(CPDF_FormField* pField, - const CFX_WideString& csValue) = 0; + const WideString& csValue) = 0; virtual void AfterSelectionChange(CPDF_FormField* pField) = 0; virtual void AfterCheckedStatusChange(CPDF_FormField* pField) = 0; virtual int BeforeFormReset(CPDF_InterForm* pForm) = 0; diff --git a/core/fpdfdoc/ipvt_fontmap.h b/core/fpdfdoc/ipvt_fontmap.h index 740cb19eb8..31aa73b8a1 100644 --- a/core/fpdfdoc/ipvt_fontmap.h +++ b/core/fpdfdoc/ipvt_fontmap.h @@ -18,7 +18,7 @@ class IPVT_FontMap { virtual ~IPVT_FontMap() {} virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0; - virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0; + virtual ByteString GetPDFFontAlias(int32_t nFontIndex) = 0; virtual int32_t GetWordFontIndex(uint16_t word, int32_t charset, int32_t nFontIndex) = 0; |