diff options
author | Lei Zhang <thestig@chromium.org> | 2015-12-14 16:58:33 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-12-14 16:58:33 -0800 |
commit | d983b09c3ae29a97cba8e9ec9c6351545f6087ee (patch) | |
tree | 5641a4bc6eddaa8069904c29c3e3897043411646 /core/src/fpdfdoc/doc_ocg.cpp | |
parent | f86d3f946e2f1977c7eaea01dcb9d7ecb3064cd1 (diff) | |
download | pdfium-d983b09c3ae29a97cba8e9ec9c6351545f6087ee.tar.xz |
Merge to XFA: Remove FX_BSTRC.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1521563002 .
(cherry picked from commit 1956a174020686f91cd3b34294e91f4560fe45aa)
Review URL: https://codereview.chromium.org/1526823002 .
Diffstat (limited to 'core/src/fpdfdoc/doc_ocg.cpp')
-rw-r--r-- | core/src/fpdfdoc/doc_ocg.cpp | 90 |
1 files changed, 42 insertions, 48 deletions
diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp index 7f9c6774df..4e0e1c5a31 100644 --- a/core/src/fpdfdoc/doc_ocg.cpp +++ b/core/src/fpdfdoc/doc_ocg.cpp @@ -21,12 +21,11 @@ static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject, } return pObject->GetDict() == pGroupDict ? 0 : -1; } -static FX_BOOL FPDFDOC_OCG_HasIntent( - const CPDF_Dictionary* pDict, - const CFX_ByteStringC& csElement, - const CFX_ByteStringC& csDef = FX_BSTRC("")) { +static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict, + const CFX_ByteStringC& csElement, + const CFX_ByteStringC& csDef = "") { FXSYS_assert(pDict != NULL); - CPDF_Object* pIntent = pDict->GetElementValue(FX_BSTRC("Intent")); + CPDF_Object* pIntent = pDict->GetElementValue("Intent"); if (pIntent == NULL) { return csElement == csDef; } @@ -35,32 +34,31 @@ static FX_BOOL FPDFDOC_OCG_HasIntent( FX_DWORD dwCount = pArray->GetCount(); for (FX_DWORD i = 0; i < dwCount; i++) { bsIntent = pArray->GetString(i); - if (bsIntent == FX_BSTRC("All") || bsIntent == csElement) + if (bsIntent == "All" || bsIntent == csElement) return TRUE; } return FALSE; } bsIntent = pIntent->GetString(); - return bsIntent == FX_BSTRC("All") || bsIntent == csElement; + return bsIntent == "All" || bsIntent == csElement; } static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc, const CPDF_Dictionary* pOCGDict, const CFX_ByteStringC& bsState) { FXSYS_assert(pDoc && pOCGDict); - CPDF_Dictionary* pOCProperties = - pDoc->GetRoot()->GetDict(FX_BSTRC("OCProperties")); + CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDict("OCProperties"); if (!pOCProperties) { return NULL; } - CPDF_Array* pOCGs = pOCProperties->GetArray(FX_BSTRC("OCGs")); + CPDF_Array* pOCGs = pOCProperties->GetArray("OCGs"); if (!pOCGs) { return NULL; } if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) { return NULL; } - CPDF_Dictionary* pConfig = pOCProperties->GetDict(FX_BSTRC("D")); - CPDF_Array* pConfigs = pOCProperties->GetArray(FX_BSTRC("Configs")); + CPDF_Dictionary* pConfig = pOCProperties->GetDict("D"); + CPDF_Array* pConfigs = pOCProperties->GetArray("Configs"); if (pConfigs) { CPDF_Dictionary* pFind; int32_t iCount = pConfigs->GetCount(); @@ -69,7 +67,7 @@ static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc, if (!pFind) { continue; } - if (!FPDFDOC_OCG_HasIntent(pFind, FX_BSTRC("View"), FX_BSTRC("View"))) { + if (!FPDFDOC_OCG_HasIntent(pFind, "View", "View")) { continue; } pConfig = pFind; @@ -80,13 +78,13 @@ static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc, } static CFX_ByteString FPDFDOC_OCG_GetUsageTypeString( CPDF_OCContext::UsageType eType) { - CFX_ByteString csState = FX_BSTRC("View"); + CFX_ByteString csState = "View"; if (eType == CPDF_OCContext::Design) { - csState = FX_BSTRC("Design"); + csState = "Design"; } else if (eType == CPDF_OCContext::Print) { - csState = FX_BSTRC("Print"); + csState = "Print"; } else if (eType == CPDF_OCContext::Export) { - csState = FX_BSTRC("Export"); + csState = "Export"; } return csState; } @@ -107,33 +105,32 @@ FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, return TRUE; } bValidConfig = TRUE; - FX_BOOL bState = pConfig->GetString(FX_BSTRC("BaseState"), FX_BSTRC("ON")) != - FX_BSTRC("OFF"); - CPDF_Array* pArray = pConfig->GetArray(FX_BSTRC("ON")); + FX_BOOL bState = pConfig->GetString("BaseState", "ON") != "OFF"; + CPDF_Array* pArray = pConfig->GetArray("ON"); if (pArray) { if (FPDFDOC_OCG_FindGroup(pArray, pOCGDict) >= 0) { bState = TRUE; } } - pArray = pConfig->GetArray(FX_BSTRC("OFF")); + pArray = pConfig->GetArray("OFF"); if (pArray) { if (FPDFDOC_OCG_FindGroup(pArray, pOCGDict) >= 0) { bState = FALSE; } } - pArray = pConfig->GetArray(FX_BSTRC("AS")); + pArray = pConfig->GetArray("AS"); if (pArray) { - CFX_ByteString csFind = csConfig + FX_BSTRC("State"); + CFX_ByteString csFind = csConfig + "State"; int32_t iCount = pArray->GetCount(); for (int32_t i = 0; i < iCount; i++) { CPDF_Dictionary* pUsage = pArray->GetDict(i); if (!pUsage) { continue; } - if (pUsage->GetString(FX_BSTRC("Event"), FX_BSTRC("View")) != csConfig) { + if (pUsage->GetString("Event", "View") != csConfig) { continue; } - CPDF_Array* pOCGs = pUsage->GetArray(FX_BSTRC("OCGs")); + CPDF_Array* pOCGs = pUsage->GetArray("OCGs"); if (!pOCGs) { continue; } @@ -144,29 +141,29 @@ FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, if (!pState) { continue; } - bState = pState->GetString(csFind) != FX_BSTRC("OFF"); + bState = pState->GetString(csFind) != "OFF"; } } return bState; } FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const { - if (!FPDFDOC_OCG_HasIntent(pOCGDict, FX_BSTRC("View"), FX_BSTRC("View"))) { + if (!FPDFDOC_OCG_HasIntent(pOCGDict, "View", "View")) { return TRUE; } CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType); - CPDF_Dictionary* pUsage = pOCGDict->GetDict(FX_BSTRC("Usage")); + CPDF_Dictionary* pUsage = pOCGDict->GetDict("Usage"); if (pUsage) { CPDF_Dictionary* pState = pUsage->GetDict(csState); if (pState) { - CFX_ByteString csFind = csState + FX_BSTRC("State"); + CFX_ByteString csFind = csState + "State"; if (pState->KeyExist(csFind)) { - return pState->GetString(csFind) != FX_BSTRC("OFF"); + return pState->GetString(csFind) != "OFF"; } } - if (csState != FX_BSTRC("View")) { - pState = pUsage->GetDict(FX_BSTRC("View")); - if (pState && pState->KeyExist(FX_BSTRC("ViewState"))) { - return pState->GetString(FX_BSTRC("ViewState")) != FX_BSTRC("OFF"); + if (csState != "View") { + pState = pUsage->GetDict("View"); + if (pState && pState->KeyExist("ViewState")) { + return pState->GetString("ViewState") != "OFF"; } } } @@ -199,7 +196,7 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int32_t iCount = pExpression->GetCount(); CPDF_Object* pOCGObj; CFX_ByteString csOperator = pExpression->GetString(0); - if (csOperator == FX_BSTRC("Not")) { + if (csOperator == "Not") { pOCGObj = pExpression->GetElementValue(1); if (!pOCGObj) return FALSE; @@ -209,7 +206,7 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, return !GetOCGVE(pArray, bFromConfig, nLevel + 1); return FALSE; } - if (csOperator == FX_BSTRC("Or") || csOperator == FX_BSTRC("And")) { + if (csOperator == "Or" || csOperator == "And") { FX_BOOL bValue = FALSE; for (int32_t i = 1; i < iCount; i++) { pOCGObj = pExpression->GetElementValue(1); @@ -225,7 +222,7 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, if (i == 1) { bValue = bItem; } else { - if (csOperator == FX_BSTRC("Or")) { + if (csOperator == "Or") { bValue = bValue || bItem; } else { bValue = bValue && bItem; @@ -239,12 +236,12 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, FX_BOOL bFromConfig) { FXSYS_assert(pOCMDDict != NULL); - CPDF_Array* pVE = pOCMDDict->GetArray(FX_BSTRC("VE")); + CPDF_Array* pVE = pOCMDDict->GetArray("VE"); if (pVE != NULL) { return GetOCGVE(pVE, bFromConfig); } - CFX_ByteString csP = pOCMDDict->GetString(FX_BSTRC("P"), FX_BSTRC("AnyOn")); - CPDF_Object* pOCGObj = pOCMDDict->GetElementValue(FX_BSTRC("OCGs")); + CFX_ByteString csP = pOCMDDict->GetString("P", "AnyOn"); + CPDF_Object* pOCGObj = pOCMDDict->GetElementValue("OCGs"); if (!pOCGObj) return TRUE; if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) @@ -255,7 +252,7 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, return TRUE; FX_BOOL bState = FALSE; - if (csP == FX_BSTRC("AllOn") || csP == FX_BSTRC("AllOff")) { + if (csP == "AllOn" || csP == "AllOff") { bState = TRUE; } int32_t iCount = pArray->GetCount(); @@ -265,11 +262,9 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, if (pItemDict) bItem = bFromConfig ? LoadOCGState(pItemDict) : GetOCGVisible(pItemDict); - if ((csP == FX_BSTRC("AnyOn") && bItem) || - (csP == FX_BSTRC("AnyOff") && !bItem)) + if ((csP == "AnyOn" && bItem) || (csP == "AnyOff" && !bItem)) return TRUE; - if ((csP == FX_BSTRC("AllOn") && !bItem) || - (csP == FX_BSTRC("AllOff") && bItem)) + if ((csP == "AllOn" && !bItem) || (csP == "AllOff" && bItem)) return FALSE; } return bState; @@ -278,9 +273,8 @@ FX_BOOL CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary* pOCGDict) { if (!pOCGDict) { return TRUE; } - CFX_ByteString csType = - pOCGDict->GetString(FX_BSTRC("Type"), FX_BSTRC("OCG")); - if (csType == FX_BSTRC("OCG")) { + CFX_ByteString csType = pOCGDict->GetString("Type", "OCG"); + if (csType == "OCG") { return GetOCGVisible(pOCGDict); } return LoadOCMDState(pOCGDict, FALSE); |