diff options
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page.cpp | 48 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 20 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 4 |
4 files changed, 26 insertions, 48 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp index 7e2492fad7..1d18b5343d 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp @@ -666,24 +666,18 @@ void CPDF_FormObject::CalcBoundingBox() { m_Right = form_rect.right; m_Top = form_rect.top; } -CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) +CPDF_PageObjects::CPDF_PageObjects() : m_pFormDict(nullptr), m_pFormStream(nullptr), m_pDocument(nullptr), m_pPageResources(nullptr), m_pResources(nullptr), m_Transparency(0), - m_ObjectList(128), m_bBackgroundAlphaNeeded(FALSE), m_bHasImageMask(FALSE), - m_bReleaseMembers(bReleaseMembers), - m_pParser(nullptr), - m_ParseState(CONTENT_NOT_PARSED) {} + m_ParseState(CONTENT_NOT_PARSED), + m_ObjectList(128) {} CPDF_PageObjects::~CPDF_PageObjects() { - delete m_pParser; - if (!m_bReleaseMembers) { - return; - } FX_POSITION pos = m_ObjectList.GetHeadPosition(); while (pos) { delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); @@ -696,8 +690,7 @@ void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) { m_pParser->Continue(pPause); if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { m_ParseState = CONTENT_PARSED; - delete m_pParser; - m_pParser = NULL; + m_pParser.reset(); } } FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, @@ -774,21 +767,9 @@ void CPDF_PageObjects::LoadTransInfo() { m_Transparency |= PDFTRANS_KNOCKOUT; } } -void CPDF_PageObjects::ClearCacheObjects() { - m_ParseState = CONTENT_NOT_PARSED; - delete m_pParser; - m_pParser = NULL; - if (m_bReleaseMembers) { - FX_POSITION pos = m_ObjectList.GetHeadPosition(); - while (pos) { - delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); - } - } - m_ObjectList.RemoveAll(); -} -CPDF_Page::CPDF_Page() { - m_pPageRender = NULL; -} + +CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {} + void CPDF_Page::Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, FX_BOOL bPageCache) { @@ -858,20 +839,17 @@ void CPDF_Page::Load(CPDF_Document* pDocument, m_Transparency = PDFTRANS_ISOLATED; LoadTransInfo(); } -void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) { - if (bReParse) { - ClearCacheObjects(); - } +void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions) { if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { return; } - m_pParser = new CPDF_ContentParser; + m_pParser.reset(new CPDF_ContentParser); m_pParser->Start(this, pOptions); m_ParseState = CONTENT_PARSING; } -void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) { - StartParse(pOptions, bReParse); - ContinueParse(NULL); +void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions) { + StartParse(pOptions); + ContinueParse(nullptr); } CPDF_Page::~CPDF_Page() { if (m_pPageRender) { @@ -928,7 +906,7 @@ void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { return; } - m_pParser = new CPDF_ContentParser; + m_pParser.reset(new CPDF_ContentParser); m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, level); m_ParseState = CONTENT_PARSING; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp index dd16aa85ce..e9f1747097 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -520,7 +520,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, pGeneralState->SetBlendMode(mode); if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { - pParser->GetObjectList()->m_bBackgroundAlphaNeeded = TRUE; + pParser->GetObjectList()->SetBackgroundAlphaNeeded(TRUE); } break; } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 6ed3d3fc0e..08b10e5500 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -738,8 +738,8 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); m_LastImageName = name; m_pLastImage = pObj->m_pImage; - if (!m_pObjectList->m_bHasImageMask) - m_pObjectList->m_bHasImageMask = m_pLastImage->IsMask(); + if (!m_pObjectList->HasImageMask()) + m_pObjectList->SetHasImageMask(m_pLastImage->IsMask()); } else if (type == "Form") { AddForm(pXObject); } else { @@ -791,13 +791,13 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { status.m_ColorState = m_pCurStates->m_ColorState; status.m_TextState = m_pCurStates->m_TextState; pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1); - if (!m_pObjectList->m_bBackgroundAlphaNeeded && - pFormObj->m_pForm->m_bBackgroundAlphaNeeded) { - m_pObjectList->m_bBackgroundAlphaNeeded = TRUE; + if (!m_pObjectList->BackgroundAlphaNeeded() && + pFormObj->m_pForm->BackgroundAlphaNeeded()) { + m_pObjectList->SetBackgroundAlphaNeeded(TRUE); } pFormObj->CalcBoundingBox(); SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); - m_pObjectList->m_ObjectList.AddTail(pFormObj); + m_pObjectList->AddTail(pFormObj); } CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, @@ -822,7 +822,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), FALSE, FALSE); pImageObj->m_Matrix = ImageMatrix; pImageObj->CalcBoundingBox(); - m_pObjectList->m_ObjectList.AddTail(pImageObj); + m_pObjectList->AddTail(pImageObj); return pImageObj; } @@ -1211,7 +1211,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() { pObj->m_Right = bbox.right; pObj->m_Top = bbox.top; pObj->m_Bottom = bbox.bottom; - m_pObjectList->m_ObjectList.AddTail(pObj); + m_pObjectList->AddTail(pObj); } void CPDF_StreamContentParser::Handle_SetCharSpace() { @@ -1389,7 +1389,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, pCopy->Copy(pText); m_ClipTextList.Add(pCopy); } - m_pObjectList->m_ObjectList.AddTail(pText); + m_pObjectList->AddTail(pText); if (pKerning && pKerning[nsegs - 1] != 0) { if (!pFont->IsVertWriting()) { m_pCurStates->m_TextX -= @@ -1624,7 +1624,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, FX_BOOL bStroke) { pPathObj->m_Matrix = matrix; SetGraphicStates(pPathObj, TRUE, FALSE, TRUE); pPathObj->CalcBoundingBox(); - m_pObjectList->m_ObjectList.AddTail(pPathObj); + m_pObjectList->AddTail(pPathObj); } if (PathClipType) { if (!matrix.IsIdentity()) { 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 9e9b55177b..298f28235f 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -841,10 +841,10 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { m_pType3Char->m_BBox.top = FXSYS_round(m_pParser->GetType3Data()[5] * 1000); } - FX_POSITION pos = m_pObjects->m_ObjectList.GetHeadPosition(); + FX_POSITION pos = m_pObjects->GetFirstObjectPosition(); while (pos) { CPDF_PageObject* pObj = - (CPDF_PageObject*)m_pObjects->m_ObjectList.GetNext(pos); + (CPDF_PageObject*)m_pObjects->GetNextObject(pos); if (pObj->m_ClipPath.IsNull()) { continue; } |