summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-18 17:05:11 -0800
committerLei Zhang <thestig@chromium.org>2015-12-18 17:05:11 -0800
commit4880d1a168729d42be736293fb93b514802e4f12 (patch)
tree9cfe5aa73113301487dce8bcef5139fb7295536a /core/src/fpdfapi/fpdf_page
parentaedd4555ec1a80121f176586cb72180337e4ccd8 (diff)
downloadpdfium-4880d1a168729d42be736293fb93b514802e4f12.tar.xz
Merge to XFA: Get rid of a few CPDF_Object Create() methods and just use new instead.
R=ochang@chromium.org Review URL: https://codereview.chromium.org/1540693002 . (cherry picked from commit d866ab0b44a571c884fdd8ba5a5319adaf607559) Review URL: https://codereview.chromium.org/1541563002 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp50
2 files changed, 29 insertions, 33 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index e90c53c956..865c6b7116 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -114,7 +114,7 @@ void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
if (len > 32) {
m_ParamBuf1[index].m_Type = 0;
m_ParamBuf1[index].m_pObject =
- CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(name, len)));
+ new CPDF_Name(PDF_NameDecode(CFX_ByteStringC(name, len)));
} else {
m_ParamBuf1[index].m_Type = PDFOBJ_NAME;
if (!FXSYS_memchr(name, '#', len)) {
@@ -165,15 +165,15 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(FX_DWORD index) {
_ContentParam& param = m_ParamBuf1[real_index];
if (param.m_Type == PDFOBJ_NUMBER) {
CPDF_Number* pNumber = param.m_Number.m_bInteger
- ? CPDF_Number::Create(param.m_Number.m_Integer)
- : CPDF_Number::Create(param.m_Number.m_Float);
+ ? new CPDF_Number(param.m_Number.m_Integer)
+ : new CPDF_Number(param.m_Number.m_Float);
param.m_Type = 0;
param.m_pObject = pNumber;
return pNumber;
}
if (param.m_Type == PDFOBJ_NAME) {
- CPDF_Name* pName = CPDF_Name::Create(
+ CPDF_Name* pName = new CPDF_Name(
CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len));
param.m_Type = 0;
param.m_pObject = pName;
@@ -524,7 +524,7 @@ void _PDF_ReplaceAbbr(CPDF_Object* pObj) {
_PDF_InlineValueAbbr,
sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
if (!fullname.IsEmpty()) {
- pArray->SetAt(i, CPDF_Name::Create(fullname));
+ pArray->SetAt(i, new CPDF_Name(fullname));
}
} else {
_PDF_ReplaceAbbr(pElement);
@@ -587,7 +587,7 @@ void _PDF_ReplaceFull(CPDF_Object* pObj) {
_PDF_InlineValueAbbr,
sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
if (!abbrName.IsEmpty()) {
- pArray->SetAt(i, CPDF_Name::Create(abbrName));
+ pArray->SetAt(i, new CPDF_Name(abbrName));
}
} else {
_PDF_ReplaceFull(pElement);
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 2f68d78808..02ac27ac0f 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -75,7 +75,7 @@ FX_DWORD CPDF_StreamContentParser::Parse(const uint8_t* pData,
void _PDF_ReplaceAbbr(CPDF_Object* pObj);
void CPDF_StreamContentParser::Handle_BeginImage() {
FX_FILESIZE savePos = m_pSyntax->GetPos();
- CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
+ CPDF_Dictionary* pDict = new CPDF_Dictionary;
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::Keyword) {
@@ -516,16 +516,16 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
if (m_WordSize == 4) {
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) {
- m_pLastObj = CPDF_Boolean::Create(TRUE);
+ m_pLastObj = new CPDF_Boolean(TRUE);
return Others;
}
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) {
- m_pLastObj = CPDF_Null::Create();
+ m_pLastObj = new CPDF_Null;
return Others;
}
} else if (m_WordSize == 5) {
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') {
- m_pLastObj = CPDF_Boolean::Create(FALSE);
+ m_pLastObj = new CPDF_Boolean(FALSE);
return Others;
}
}
@@ -603,42 +603,40 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray,
}
if (bIsNumber) {
m_WordBuffer[m_WordSize] = 0;
- return CPDF_Number::Create(CFX_ByteStringC(m_WordBuffer, m_WordSize));
+ return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize));
}
int first_char = m_WordBuffer[0];
if (first_char == '/') {
- return CPDF_Name::Create(
+ return new CPDF_Name(
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
}
if (first_char == '(') {
- return CPDF_String::Create(ReadString());
+ return new CPDF_String(ReadString(), FALSE);
}
if (first_char == '<') {
if (m_WordSize == 1) {
- return CPDF_String::Create(ReadHexString(), TRUE);
+ return new CPDF_String(ReadHexString(), TRUE);
}
- CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
+ CPDF_Dictionary* pDict = new CPDF_Dictionary;
while (1) {
GetNextWord(bIsNumber);
if (m_WordSize == 0) {
pDict->Release();
- return NULL;
+ return nullptr;
}
if (m_WordSize == 2 && m_WordBuffer[0] == '>') {
break;
}
if (m_WordBuffer[0] != '/') {
pDict->Release();
- return NULL;
+ return nullptr;
}
CFX_ByteString key =
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
CPDF_Object* pObj = ReadNextObject(TRUE);
if (!pObj) {
- if (pDict) {
- pDict->Release();
- }
- return NULL;
+ pDict->Release();
+ return nullptr;
}
if (!key.IsEmpty()) {
pDict->SetAt(key, pObj);
@@ -652,31 +650,29 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray,
if (!bAllowNestedArray && bInArray) {
return NULL;
}
- CPDF_Array* pArray = CPDF_Array::Create();
+ CPDF_Array* pArray = new CPDF_Array;
while (1) {
CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, TRUE);
- if (!pObj) {
- if (m_WordSize == 0 || m_WordBuffer[0] == ']') {
- return pArray;
- }
- if (m_WordBuffer[0] == '[') {
- continue;
- }
- } else {
+ if (pObj) {
pArray->Add(pObj);
+ continue;
}
+
+ if (m_WordSize == 0 || m_WordBuffer[0] == ']')
+ break;
}
+ return pArray;
}
if (m_WordSize == 4) {
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) {
- return CPDF_Boolean::Create(TRUE);
+ return new CPDF_Boolean(TRUE);
}
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) {
- return CPDF_Null::Create();
+ return new CPDF_Null;
}
} else if (m_WordSize == 5) {
if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') {
- return CPDF_Boolean::Create(FALSE);
+ return new CPDF_Boolean(FALSE);
}
}
return NULL;