CPDF_ContentParser::CPDF_ContentParser(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, const CFX_Matrix* pParentMatrix, CPDF_Type3Char* pType3Char, std::set<const uint8_t*>* parsedSet) : m_CurrentStage(Stage::kParse), m_pObjectHolder(pForm), m_pType3Char(pType3Char) { ASSERT(pForm); CFX_Matrix form_matrix = pForm->GetDict()->GetMatrixFor("Matrix"); if (pGraphicStates) form_matrix.Concat(pGraphicStates->m_CTM); CPDF_Array* pBBox = pForm->GetDict()->GetArrayFor("BBox"); CFX_FloatRect form_bbox; CPDF_Path ClipPath; if (pBBox) { form_bbox = pBBox->GetRect(); ClipPath.Emplace(); ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, form_bbox.top); ClipPath.Transform(form_matrix); if (pParentMatrix) ClipPath.Transform(*pParentMatrix); form_bbox = form_matrix.TransformRect(form_bbox); if (pParentMatrix) form_bbox = pParentMatrix->TransformRect(form_bbox); } CPDF_Dictionary* pResources = pForm->GetDict()->GetDictFor("Resources"); m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>( pForm->GetDocument(), pForm->m_pPageResources.Get(), pForm->m_pResources.Get(), pParentMatrix, pForm, pResources, form_bbox, pGraphicStates, parsedSet); m_pParser->GetCurStates()->m_CTM = form_matrix; m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; if (ClipPath.HasRef()) { m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, true); } if (pForm->GetTransparency().IsGroup()) { CPDF_GeneralState* pState = &m_pParser->GetCurStates()->m_GeneralState; pState->SetBlendType(BlendMode::kNormal); pState->SetStrokeAlpha(1.0f); pState->SetFillAlpha(1.0f); pState->SetSoftMask(nullptr); } m_pSingleStream = pdfium::MakeRetain<CPDF_StreamAcc>(pForm->GetStream()); m_pSingleStream->LoadAllDataFiltered(); m_pData.Reset(m_pSingleStream->GetData()); m_Size = m_pSingleStream->GetSize(); }
void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, const CFX_Matrix* pParentMatrix, CPDF_Type3Char* pType3Char, int level) { m_pType3Char = pType3Char; m_pObjectHolder = pForm; m_bForm = true; CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix"); if (pGraphicStates) form_matrix.Concat(pGraphicStates->m_CTM); CPDF_Array* pBBox = pForm->m_pFormDict->GetArrayFor("BBox"); CFX_FloatRect form_bbox; CPDF_Path ClipPath; if (pBBox) { form_bbox = pBBox->GetRect(); ClipPath.Emplace(); ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, form_bbox.top); ClipPath.Transform(&form_matrix); if (pParentMatrix) ClipPath.Transform(pParentMatrix); form_bbox.Transform(&form_matrix); if (pParentMatrix) form_bbox.Transform(pParentMatrix); } CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources"); m_pParser.reset(new CPDF_StreamContentParser( pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level)); m_pParser->GetCurStates()->m_CTM = form_matrix; m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; if (ClipPath) { m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, true); } if (pForm->m_Transparency & PDFTRANS_GROUP) { CPDF_GeneralState* pState = &m_pParser->GetCurStates()->m_GeneralState; pState->SetBlendType(FXDIB_BLEND_NORMAL); pState->SetStrokeAlpha(1.0f); pState->SetFillAlpha(1.0f); pState->SetSoftMask(nullptr); } m_nStreams = 0; m_pSingleStream.reset(new CPDF_StreamAcc); m_pSingleStream->LoadAllData(pForm->m_pFormStream, false); m_pData = (uint8_t*)m_pSingleStream->GetData(); m_Size = m_pSingleStream->GetSize(); m_Status = ToBeContinued; m_InternalStage = STAGE_PARSE; m_CurrentOffset = 0; }