Cleanup: Get rid of CPDF_Reference::Create().
authorLei Zhang <thestig@chromium.org>
Mon, 22 Jun 2015 22:16:15 +0000 (15:16 -0700)
committerLei Zhang <thestig@chromium.org>
Mon, 22 Jun 2015 22:16:15 +0000 (15:16 -0700)
Just call new CPDF_Reference instead.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/1194343002.

core/include/fpdfapi/fpdf_objects.h
core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
core/src/fpdfdoc/doc_annot.cpp

index 570dc41..45b7cc6 100644 (file)
@@ -675,12 +675,6 @@ public:
 class CPDF_Reference : public CPDF_Object
 {
 public:
-
-    static CPDF_Reference*     Create(CPDF_IndirectObjects* pDoc, int objnum)
-    {
-        return new CPDF_Reference(pDoc, objnum);
-    }
-
     CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum)
         : CPDF_Object(PDFOBJ_REFERENCE), m_pObjList(pDoc), m_RefObjNum(objnum) {
     }
index 2db8d60..c37e92d 100644 (file)
@@ -1063,7 +1063,8 @@ static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages,
         if (pKid->GetString("Type") == FX_BSTRC("Page")) {
             if (nPagesToGo == 0) {
                 if (bInsert) {
-                    pKidList->InsertAt(i, CPDF_Reference::Create(pDoc, pPage->GetObjNum()));
+                    pKidList->InsertAt(
+                        i, new CPDF_Reference(pDoc, pPage->GetObjNum()));
                     pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum());
                 } else {
                     pKidList->RemoveAt(i);
index 3f9f4cc..a3e409d 100644 (file)
@@ -506,7 +506,7 @@ void CPDF_Array::SetAt(FX_DWORD i, CPDF_Object* pObj, CPDF_IndirectObjects* pObj
         pOld->Release();
     if (pObj->GetObjNum()) {
         ASSERT(pObjs != NULL);
-        pObj = CPDF_Reference::Create(pObjs, pObj->GetObjNum());
+        pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
     }
     m_Objects.SetAt(i, pObj);
 }
@@ -515,7 +515,7 @@ void CPDF_Array::InsertAt(FX_DWORD index, CPDF_Object* pObj, CPDF_IndirectObject
     ASSERT(pObj != NULL);
     if (pObj->GetObjNum()) {
         ASSERT(pObjs != NULL);
-        pObj = CPDF_Reference::Create(pObjs, pObj->GetObjNum());
+        pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
     }
     m_Objects.InsertAt(index, pObj);
 }
@@ -524,7 +524,7 @@ void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs)
     ASSERT(pObj != NULL);
     if (pObj->GetObjNum()) {
         ASSERT(pObjs != NULL);
-        pObj = CPDF_Reference::Create(pObjs, pObj->GetObjNum());
+        pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
     }
     m_Objects.Add(pObj);
 }
@@ -752,7 +752,7 @@ void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj, CPDF_
     if (pObj) {
         if (pObj->GetObjNum()) {
             ASSERT(pObjs != NULL);
-            pObj = CPDF_Reference::Create(pObjs, pObj->GetObjNum());
+            pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
         }
         m_Map.SetAt(key, pObj);
     } else {
index 685ee04..f7174f7 100644 (file)
@@ -2062,7 +2062,6 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
     FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY);
     FX_BOOL bIsNumber;
     CFX_ByteString word = GetNextWord(bIsNumber);
-    CPDF_Object* pRet = NULL;
     if (word.GetLength() == 0) {
         if (bTypeOnly) {
             return (CPDF_Object*)PDFOBJ_INVALID;
@@ -2079,38 +2078,33 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
                 if (bTypeOnly) {
                     return (CPDF_Object*)PDFOBJ_REFERENCE;
                 }
-                pRet = CPDF_Reference::Create(pObjList, objnum);
-                return pRet;
+                return new CPDF_Reference(pObjList, objnum);
             } else {
                 m_Pos = SavedPos;
                 if (bTypeOnly) {
                     return (CPDF_Object*)PDFOBJ_NUMBER;
                 }
-                pRet = CPDF_Number::Create(word);
-                return pRet;
+                return CPDF_Number::Create(word);
             }
         } else {
             m_Pos = SavedPos;
             if (bTypeOnly) {
                 return (CPDF_Object*)PDFOBJ_NUMBER;
             }
-            pRet = CPDF_Number::Create(word);
-            return pRet;
+            return CPDF_Number::Create(word);
         }
     }
     if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) {
         if (bTypeOnly) {
             return (CPDF_Object*)PDFOBJ_BOOLEAN;
         }
-        pRet = CPDF_Boolean::Create(word == FX_BSTRC("true"));
-        return pRet;
+        return CPDF_Boolean::Create(word == FX_BSTRC("true"));
     }
     if (word == FX_BSTRC("null")) {
         if (bTypeOnly) {
             return (CPDF_Object*)PDFOBJ_NULL;
         }
-        pRet = CPDF_Null::Create();
-        return pRet;
+        return CPDF_Null::Create();
     }
     if (word == FX_BSTRC("(")) {
         if (bTypeOnly) {
@@ -2120,8 +2114,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
         if (m_pCryptoHandler && bDecrypt) {
             m_pCryptoHandler->Decrypt(objnum, gennum, str);
         }
-        pRet = CPDF_String::Create(str, FALSE);
-        return pRet;
+        return CPDF_String::Create(str, FALSE);
     }
     if (word == FX_BSTRC("<")) {
         if (bTypeOnly) {
@@ -2131,8 +2124,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
         if (m_pCryptoHandler && bDecrypt) {
             m_pCryptoHandler->Decrypt(objnum, gennum, str);
         }
-        pRet = CPDF_String::Create(str, TRUE);
-        return pRet;
+        return CPDF_String::Create(str, TRUE);
     }
     if (word == FX_BSTRC("[")) {
         if (bTypeOnly) {
@@ -2151,8 +2143,8 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
         if (bTypeOnly) {
             return (CPDF_Object*)PDFOBJ_NAME;
         }
-        pRet = CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
-        return pRet;
+        return CPDF_Name::Create(
+            PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
     }
     if (word == FX_BSTRC("<<")) {
         if (bTypeOnly) {
@@ -2264,7 +2256,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList
                 if (bTypeOnly) {
                     return (CPDF_Object*)PDFOBJ_REFERENCE;
                 }
-                return CPDF_Reference::Create(pObjList, objnum);
+                return new CPDF_Reference(pObjList, objnum);
             } else {
                 m_Pos = SavedPos;
                 if (bTypeOnly) {
index 98cd01b..0a74619 100644 (file)
@@ -31,10 +31,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
         FX_DWORD dwObjNum = pDict->GetObjNum();
         if (dwObjNum == 0) {
             dwObjNum = m_pDocument->AddIndirectObject(pDict);
-            CPDF_Reference* pAction = CPDF_Reference::Create(m_pDocument, dwObjNum);
-            if (pAction == NULL) {
-                break;
-            }
+            CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum);
             pAnnots->InsertAt(i, pAction);
             pAnnots->RemoveAt(i + 1);
             pDict = pAnnots->GetDict(i);