Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1806)

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 801913002: Simplify PDFium by removing code that's not used in the open source repo. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 7d8bd4842aeaadf3a3f9d78f30c59af219ea510f..879c2f3c0e0c02fc2331750fe83bb4415fd521b8 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -29,33 +29,9 @@ CPDF_StreamContentParser::CPDF_StreamContentParser()
m_pLastImage = NULL;
m_bReleaseLastDict = TRUE;
m_pParentResources = NULL;
-#ifdef _FPDFAPI_MINI_
- m_pObjectState = NULL;
- m_pObjectStack = NULL;
- m_pWordBuf = NULL;
- m_pDictName = NULL;
- m_pStreamBuf = NULL;
- m_WordState = 0;
- m_ObjectSize = 0;
-#endif
}
FX_BOOL CPDF_StreamContentParser::Initialize()
{
-#ifdef _FPDFAPI_MINI_
- m_pObjectState = FX_Alloc(FX_BOOL, _FPDF_MAX_OBJECT_STACK_SIZE_);
- FXSYS_memset32(m_pObjectState, 0, _FPDF_MAX_OBJECT_STACK_SIZE_ * sizeof(FX_BOOL));
- m_pObjectStack = FX_Alloc(CPDF_Object*, _FPDF_MAX_OBJECT_STACK_SIZE_);
- FXSYS_memset32(m_pObjectStack, 0, _FPDF_MAX_OBJECT_STACK_SIZE_ * sizeof(CPDF_Object*));
- m_pWordBuf = FX_Alloc(FX_BYTE, 256);
- FXSYS_memset32(m_pWordBuf, 0, 256 * sizeof(FX_BYTE));
- m_pDictName = FX_Alloc(FX_BYTE, 256);
- FXSYS_memset32(m_pDictName, 0, 256 * sizeof(FX_BYTE));
- m_pStreamBuf = FX_Alloc(FX_BYTE, STREAM_PARSE_BUFSIZE);
- FXSYS_memset32(m_pStreamBuf, 0, STREAM_PARSE_BUFSIZE * sizeof(FX_BYTE));
- m_StringBuf.EstimateSize(1024);
- m_ObjectSize = 0;
- m_ImageSrcBuf.EstimateSize(STREAM_PARSE_BUFSIZE);
-#endif
return TRUE;
}
CPDF_StreamContentParser::~CPDF_StreamContentParser()
@@ -77,18 +53,6 @@ CPDF_StreamContentParser::~CPDF_StreamContentParser()
if (m_pLastCloneImageDict) {
m_pLastCloneImageDict->Release();
}
-#ifdef _FPDFAPI_MINI_
- for (i = 0; i < (int)m_ObjectSize; ++i) {
- if (!m_pObjectState[i]) {
- m_pObjectStack[i]->Release();
- }
- }
- FX_Free(m_pObjectStack);
- FX_Free(m_pObjectState);
- FX_Free(m_pStreamBuf);
- FX_Free(m_pWordBuf);
- FX_Free(m_pDictName);
-#endif
}
void CPDF_StreamContentParser::PrepareParse(CPDF_Document* pDocument,
CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources, CFX_AffineMatrix* pmtContentToUser, CPDF_PageObjects* pObjList,
@@ -128,9 +92,6 @@ void CPDF_StreamContentParser::PrepareParse(CPDF_Document* pDocument,
m_pCurStates->m_TextState.New();
m_pCurStates->m_ColorState.New();
}
-#ifdef _FPDFAPI_MINI_
- FXSYS_memset32(m_pObjectState, 0, _FPDF_MAX_OBJECT_STACK_SIZE_ * sizeof(FX_BOOL));
-#endif
}
int CPDF_StreamContentParser::GetNextParamPos()
{
@@ -676,11 +637,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject()
{
CFX_ByteString name = GetString(0);
if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && m_pLastImage->GetStream()->GetObjNum()) {
-#if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_)
- AddDuplicateImage();
-#else
AddImage(NULL, m_pLastImage, FALSE);
-#endif
return;
}
if (m_Options.m_bTextOnly) {
@@ -744,7 +701,6 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject()
}
void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream)
{
-#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_)
if (!m_Options.m_bSeparateForm) {
CPDF_Dictionary* pResources = pStream->GetDict()->GetDict(FX_BSTRC("Resources"));
CFX_AffineMatrix form_matrix = pStream->GetDict()->GetMatrix(FX_BSTRC("Matrix"));
@@ -772,15 +728,9 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream)
if (stream.GetSize() == 0) {
return;
}
-#ifdef _FPDFAPI_MINI_
- parser.InputData(stream.GetData(), stream.GetSize());
- parser.Finish();
-#else
parser.Parse(stream.GetData(), stream.GetSize(), 0);
-#endif
return;
}
-#endif
CPDF_FormObject* pFormObj = FX_NEW CPDF_FormObject;
pFormObj->m_pForm = FX_NEW CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources);
pFormObj->m_FormMatrix = m_pCurStates->m_CTM;
@@ -798,44 +748,6 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream)
SetGraphicStates(pFormObj, TRUE, TRUE, TRUE);
m_pObjectList->m_ObjectList.AddTail(pFormObj);
}
-#if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_)
-void CPDF_StreamContentParser::AddDuplicateImage()
-{
- FX_POSITION tailpos = m_pObjectList->m_ObjectList.GetTailPosition();
- CPDF_PageObject* pLastObj = (CPDF_PageObject*)m_pObjectList->m_ObjectList.GetAt(tailpos);
- if (pLastObj == NULL || (pLastObj->m_Type != PDFPAGE_INLINES && pLastObj->m_Type != PDFPAGE_IMAGE)) {
- AddImage(NULL, m_pLastImage, FALSE);
- return;
- }
- if (pLastObj->m_GeneralState != m_pCurStates->m_GeneralState ||
- pLastObj->m_ClipPath != m_pCurStates->m_ClipPath ||
- pLastObj->m_ColorState != m_pCurStates->m_ColorState) {
- AddImage(NULL, m_pLastImage, FALSE);
- return;
- }
- CFX_AffineMatrix ImageMatrix;
- ImageMatrix.Copy(m_pCurStates->m_CTM);
- ImageMatrix.Concat(m_mtContentToUser);
- if (pLastObj->m_Type == PDFPAGE_INLINES) {
- CPDF_InlineImages* pInlines = (CPDF_InlineImages*)pLastObj;
- if (pInlines->m_pStream != m_pLastImage->GetStream()) {
- AddImage(NULL, m_pLastImage, FALSE);
- return;
- }
- pInlines->AddMatrix(ImageMatrix);
- } else {
- CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pLastObj;
- CPDF_InlineImages* pInlines = FX_NEW CPDF_InlineImages;
- pInlines->m_pStream = m_pLastImage->GetStream();
- SetGraphicStates(pInlines, !pInlines->m_pStream->GetDict()->KeyExist(FX_BSTRC("ColorSpace")), FALSE, FALSE);
- pInlines->AddMatrix(pImageObj->m_Matrix);
- pInlines->AddMatrix(ImageMatrix);
- m_pObjectList->m_ObjectList.RemoveAt(tailpos);
- m_pObjectList->m_ObjectList.AddTail(pInlines);
- pLastObj->Release();
- }
-}
-#endif
CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline)
{
if (pStream == NULL && pImage == NULL) {
@@ -963,9 +875,7 @@ void CPDF_StreamContentParser::Handle_ClosePath()
}
void CPDF_StreamContentParser::Handle_SetFlat()
{
-#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_)
m_pCurStates->m_GeneralState.GetModify()->m_Flatness = GetNumber(0);
-#endif
}
void CPDF_StreamContentParser::Handle_BeginImageData()
{
@@ -1010,15 +920,11 @@ void CPDF_StreamContentParser::Handle_MoveTo()
{
REQUIRE_PARAMS(2);
if (m_Options.m_bTextOnly) {
-#ifndef _FPDFAPI_MINI_
m_pSyntax->SkipPathObject();
-#endif
return;
}
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO);
-#ifndef _FPDFAPI_MINI_
ParsePathObject();
-#endif
}
void CPDF_StreamContentParser::Handle_SetMiterLimit()
{

Powered by Google App Engine
This is Rietveld 408576698