Make ContentStreamParser members private, fix constructor
[pdfium.git] / core / src / fpdfapi / fpdf_page / fpdf_page_parser_old.cpp
index d829acb..ebd4d83 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "../../../include/fpdfapi/fpdf_page.h"
@@ -154,7 +154,7 @@ void CPDF_StreamContentParser::Handle_BeginImage()
 }
 void CPDF_StreamContentParser::ParsePathObject()
 {
-    FX_FLOAT params[6] = {0};
+    FX_FLOAT params[6] = {};
     int nParams = 0;
     int last_pos = m_pSyntax->GetPos();
     while (1) {
@@ -918,17 +918,11 @@ CPDF_ContentParser::~CPDF_ContentParser()
 }
 void CPDF_ContentParser::Clear()
 {
-    if (m_pParser) {
-        delete m_pParser;
-    }
-    if (m_pSingleStream) {
-        delete m_pSingleStream;
-    }
+    delete m_pParser;
+    delete m_pSingleStream;
     if (m_pStreamArray) {
         for (FX_DWORD i = 0; i < m_nStreams; i ++)
-            if (m_pStreamArray[i]) {
-                delete m_pStreamArray[i];
-            }
+            delete m_pStreamArray[i];
         FX_Free(m_pStreamArray);
     }
     if (m_pData && m_pSingleStream == NULL) {
@@ -1003,17 +997,18 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates,
         }
     }
     CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDict(FX_BSTRC("Resources"));
-    m_pParser = new CPDF_StreamContentParser;
-    m_pParser->Initialize();
-    m_pParser->PrepareParse(pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, pParentMatrix, pForm,
-                            pResources, &form_bbox, pOptions, pGraphicStates, level);
-    m_pParser->m_pCurStates->m_CTM = form_matrix;
-    m_pParser->m_pCurStates->m_ParentMatrix = form_matrix;
+    m_pParser = new CPDF_StreamContentParser(
+        pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
+        pParentMatrix, pForm, pResources, &form_bbox, pOptions, pGraphicStates,
+        level);
+    
+    m_pParser->GetCurStates()->m_CTM = form_matrix;
+    m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
     if (ClipPath.NotNull()) {
-        m_pParser->m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, TRUE);
+        m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, TRUE);
     }
     if (pForm->m_Transparency & PDFTRANS_GROUP) {
-        CPDF_GeneralStateData* pData = m_pParser->m_pCurStates->m_GeneralState.GetModify();
+        CPDF_GeneralStateData* pData = m_pParser->GetCurStates()->m_GeneralState.GetModify();
         pData->m_BlendType = FXDIB_BLEND_NORMAL;
         pData->m_StrokeAlpha = 1.0f;
         pData->m_FillAlpha = 1.0f;
@@ -1074,18 +1069,18 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause)
             }
         }
         if (m_InternalStage == PAGEPARSE_STAGE_PARSE) {
-            if (m_pParser == NULL) {
-                m_pParser = new CPDF_StreamContentParser;
-                m_pParser->Initialize();
-                m_pParser->PrepareParse(m_pObjects->m_pDocument, m_pObjects->m_pPageResources, NULL, NULL, m_pObjects,
-                                        m_pObjects->m_pResources, &m_pObjects->m_BBox, &m_Options, NULL, 0);
-                m_pParser->m_pCurStates->m_ColorState.GetModify()->Default();
+            if (!m_pParser) {
+                m_pParser = new CPDF_StreamContentParser(
+                    m_pObjects->m_pDocument, m_pObjects->m_pPageResources,
+                    nullptr, nullptr, m_pObjects, m_pObjects->m_pResources,
+                    &m_pObjects->m_BBox, &m_Options, nullptr, 0);
+                m_pParser->GetCurStates()->m_ColorState.GetModify()->Default();
             }
             if (m_CurrentOffset >= m_Size) {
                 m_InternalStage = PAGEPARSE_STAGE_CHECKCLIP;
             } else {
                 m_CurrentOffset += m_pParser->Parse(m_pData + m_CurrentOffset, m_Size - m_CurrentOffset, PARSE_STEP_LIMIT);
-                if (m_pParser->m_bAbort) {
+                if (m_pParser->ShouldAbort()) {
                     m_InternalStage = PAGEPARSE_STAGE_CHECKCLIP;
                     continue;
                 }
@@ -1093,12 +1088,12 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause)
         }
         if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) {
             if (m_pType3Char) {
-                m_pType3Char->m_bColored = m_pParser->m_bColored;
-                m_pType3Char->m_Width = FXSYS_round(m_pParser->m_Type3Data[0] * 1000);
-                m_pType3Char->m_BBox.left = FXSYS_round(m_pParser->m_Type3Data[2] * 1000);
-                m_pType3Char->m_BBox.bottom = FXSYS_round(m_pParser->m_Type3Data[3] * 1000);
-                m_pType3Char->m_BBox.right = FXSYS_round(m_pParser->m_Type3Data[4] * 1000);
-                m_pType3Char->m_BBox.top = FXSYS_round(m_pParser->m_Type3Data[5] * 1000);
+                m_pType3Char->m_bColored = m_pParser->IsColored();
+                m_pType3Char->m_Width = FXSYS_round(m_pParser->GetType3Data()[0] * 1000);
+                m_pType3Char->m_BBox.left = FXSYS_round(m_pParser->GetType3Data()[2] * 1000);
+                m_pType3Char->m_BBox.bottom = FXSYS_round(m_pParser->GetType3Data()[3] * 1000);
+                m_pType3Char->m_BBox.right = FXSYS_round(m_pParser->GetType3Data()[4] * 1000);
+                m_pType3Char->m_BBox.top = FXSYS_round(m_pParser->GetType3Data()[5] * 1000);
             }
             FX_POSITION pos = m_pObjects->m_ObjectList.GetHeadPosition();
             while (pos) {