summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_module.h1
-rw-r--r--core/include/fpdfapi/fpdf_page.h52
-rw-r--r--core/include/fpdfapi/fpdf_render.h4
-rw-r--r--core/include/fpdftext/fpdf_text.h3
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp56
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp29
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_page/pageint.h8
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp42
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_render/render_int.h2
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp41
-rw-r--r--core/src/fpdftext/text_int.h4
16 files changed, 119 insertions, 141 deletions
diff --git a/core/include/fpdfapi/fpdf_module.h b/core/include/fpdfapi/fpdf_module.h
index 6888e81000..4856184932 100644
--- a/core/include/fpdfapi/fpdf_module.h
+++ b/core/include/fpdfapi/fpdf_module.h
@@ -24,7 +24,6 @@ class CPDF_Document;
class CPDF_FontGlobals;
class CPDF_Image;
class CPDF_Page;
-class CPDF_PageObjectList;
class CPDF_PageRenderCache;
class CPDF_RenderOptions;
class CPDF_Stream;
diff --git a/core/include/fpdfapi/fpdf_page.h b/core/include/fpdfapi/fpdf_page.h
index 20030e7dea..fb951280a2 100644
--- a/core/include/fpdfapi/fpdf_page.h
+++ b/core/include/fpdfapi/fpdf_page.h
@@ -22,50 +22,46 @@ class CPDF_StreamFilter;
class CPDF_AllStates;
class CPDF_ContentParser;
class CPDF_StreamContentParser;
+
#define PDFTRANS_GROUP 0x0100
#define PDFTRANS_ISOLATED 0x0200
#define PDFTRANS_KNOCKOUT 0x0400
-class CPDF_PageObjectList {
+class CPDF_PageObjectList : public CFX_PtrList {
public:
- CPDF_PageObjectList();
- ~CPDF_PageObjectList();
-
- void ContinueParse(IFX_Pause* pPause);
-
- FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; }
-
- FX_POSITION GetFirstObjectPosition() const {
- return m_ObjectList.GetHeadPosition();
- }
-
- FX_POSITION GetLastObjectPosition() const {
- return m_ObjectList.GetTailPosition();
- }
+ explicit CPDF_PageObjectList(int nBlockSize) : CFX_PtrList(nBlockSize) {}
CPDF_PageObject* GetNextObject(FX_POSITION& pos) const {
- return (CPDF_PageObject*)m_ObjectList.GetNext(pos);
+ return static_cast<CPDF_PageObject*>(GetNext(pos));
}
CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const {
- return (CPDF_PageObject*)m_ObjectList.GetPrev(pos);
+ return static_cast<CPDF_PageObject*>(GetPrev(pos));
}
CPDF_PageObject* GetObjectAt(FX_POSITION pos) const {
- return (CPDF_PageObject*)m_ObjectList.GetAt(pos);
+ return static_cast<CPDF_PageObject*>(GetAt(pos));
}
- void AddTail(CPDF_PageObject* obj) { m_ObjectList.AddTail(obj); }
- FX_DWORD CountObjects() const { return m_ObjectList.GetCount(); }
-
- int GetObjectIndex(CPDF_PageObject* pObj) const;
-
+ // Linear complexity, to be avoided except as needed by public APIs.
CPDF_PageObject* GetObjectByIndex(int index) const;
FX_POSITION InsertObject(FX_POSITION posInsertAfter,
CPDF_PageObject* pNewObject);
+};
- void Transform(const CFX_Matrix& matrix);
+class CPDF_PageObjectHolder {
+ public:
+ CPDF_PageObjectHolder();
+ ~CPDF_PageObjectHolder();
+
+ void ContinueParse(IFX_Pause* pPause);
+ FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; }
+
+ CPDF_PageObjectList* GetPageObjectList() { return &m_PageObjectList; }
+ const CPDF_PageObjectList* GetPageObjectList() const {
+ return &m_PageObjectList;
+ }
FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; }
void SetBackgroundAlphaNeeded(FX_BOOL needed) {
@@ -74,6 +70,8 @@ class CPDF_PageObjectList {
FX_BOOL HasImageMask() const { return m_bHasImageMask; }
void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; }
+
+ void Transform(const CFX_Matrix& matrix);
CFX_FloatRect CalcBoundingBox() const;
CPDF_Dictionary* m_pFormDict;
@@ -93,10 +91,10 @@ class CPDF_PageObjectList {
FX_BOOL m_bHasImageMask;
ParseState m_ParseState;
std::unique_ptr<CPDF_ContentParser> m_pParser;
- CFX_PtrList m_ObjectList;
+ CPDF_PageObjectList m_PageObjectList;
};
-class CPDF_Page : public CPDF_PageObjectList, public CFX_PrivateData {
+class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData {
public:
CPDF_Page();
~CPDF_Page();
@@ -142,7 +140,7 @@ class CPDF_ParseOptions {
FX_BOOL m_bDecodeInlineImage;
};
-class CPDF_Form : public CPDF_PageObjectList {
+class CPDF_Form : public CPDF_PageObjectHolder {
public:
CPDF_Form(CPDF_Document* pDocument,
CPDF_Dictionary* pPageResources,
diff --git a/core/include/fpdfapi/fpdf_render.h b/core/include/fpdfapi/fpdf_render.h
index ec5d151914..fc0f68afe8 100644
--- a/core/include/fpdfapi/fpdf_render.h
+++ b/core/include/fpdfapi/fpdf_render.h
@@ -74,7 +74,7 @@ class CPDF_RenderContext {
public:
class Layer {
public:
- CPDF_PageObjectList* m_pObjectList;
+ CPDF_PageObjectHolder* m_pObjectHolder;
CFX_Matrix m_Matrix;
};
@@ -82,7 +82,7 @@ class CPDF_RenderContext {
CPDF_RenderContext(CPDF_Document* pDoc, CPDF_PageRenderCache* pPageCache);
~CPDF_RenderContext();
- void AppendLayer(CPDF_PageObjectList* pObjectList,
+ void AppendLayer(CPDF_PageObjectHolder* pObjectHolder,
const CFX_Matrix* pObject2Device);
void Render(CFX_RenderDevice* pDevice,
diff --git a/core/include/fpdftext/fpdf_text.h b/core/include/fpdftext/fpdf_text.h
index 140fe90bf7..498b6235c3 100644
--- a/core/include/fpdftext/fpdf_text.h
+++ b/core/include/fpdftext/fpdf_text.h
@@ -10,7 +10,6 @@
#include "core/include/fpdfapi/fpdf_parser.h"
class CPDF_Page;
-class CPDF_PageObjectList;
class CPDF_TextObject;
class IPDF_LinkExtract;
class IPDF_ReflowedPage;
@@ -50,7 +49,7 @@ class IPDF_TextPage {
static IPDF_TextPage* CreateReflowTextPage(IPDF_ReflowedPage* pRefPage);
virtual ~IPDF_TextPage() {}
- virtual FX_BOOL ParseTextPage() = 0;
+ virtual void ParseTextPage() = 0;
virtual bool IsParsed() const = 0;
virtual int CharIndexFromTextIndex(int TextIndex) const = 0;
virtual int TextIndexFromCharIndex(int CharIndex) const = 0;
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
index 555de449fa..82ab370564 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
@@ -20,9 +20,9 @@ CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage)
if (m_pPage) {
m_pDocument = m_pPage->m_pDocument;
}
- FX_POSITION pos = pPage->GetFirstObjectPosition();
+ FX_POSITION pos = pPage->GetPageObjectList()->GetHeadPosition();
while (pos) {
- InsertPageObject(pPage->GetNextObject(pos));
+ InsertPageObject(pPage->GetPageObjectList()->GetNextObject(pos));
}
}
CPDF_PageContentGenerator::~CPDF_PageContentGenerator() {}
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index e3d75076d7..ec86a60d6f 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -1706,7 +1706,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) {
ASSERT(!pdfium::ContainsKey(m_CacheMap, charcode));
CPDF_Type3Char* pCachedChar = pNewChar.release();
m_CacheMap[charcode] = pCachedChar;
- if (pCachedChar->m_pForm->CountObjects() == 0) {
+ if (pCachedChar->m_pForm->GetPageObjectList()->GetCount() == 0) {
delete pCachedChar->m_pForm;
pCachedChar->m_pForm = nullptr;
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index c4a26e9921..1a81e1b901 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -670,7 +670,7 @@ void CPDF_FormObject::CalcBoundingBox() {
m_Right = form_rect.right;
m_Top = form_rect.top;
}
-CPDF_PageObjectList::CPDF_PageObjectList()
+CPDF_PageObjectHolder::CPDF_PageObjectHolder()
: m_pFormDict(nullptr),
m_pFormStream(nullptr),
m_pDocument(nullptr),
@@ -680,14 +680,15 @@ CPDF_PageObjectList::CPDF_PageObjectList()
m_bBackgroundAlphaNeeded(FALSE),
m_bHasImageMask(FALSE),
m_ParseState(CONTENT_NOT_PARSED),
- m_ObjectList(128) {}
-CPDF_PageObjectList::~CPDF_PageObjectList() {
- FX_POSITION pos = m_ObjectList.GetHeadPosition();
+ m_PageObjectList(128) {}
+
+CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {
+ FX_POSITION pos = m_PageObjectList.GetHeadPosition();
while (pos) {
- delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
+ delete m_PageObjectList.GetNextObject(pos);
}
}
-void CPDF_PageObjectList::ContinueParse(IFX_Pause* pPause) {
+void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) {
if (!m_pParser) {
return;
}
@@ -700,43 +701,30 @@ void CPDF_PageObjectList::ContinueParse(IFX_Pause* pPause) {
FX_POSITION CPDF_PageObjectList::InsertObject(FX_POSITION posInsertAfter,
CPDF_PageObject* pNewObject) {
if (!posInsertAfter) {
- return m_ObjectList.AddHead(pNewObject);
- }
- return m_ObjectList.InsertAfter(posInsertAfter, pNewObject);
-}
-int CPDF_PageObjectList::GetObjectIndex(CPDF_PageObject* pObj) const {
- int index = 0;
- FX_POSITION pos = m_ObjectList.GetHeadPosition();
- while (pos) {
- CPDF_PageObject* pThisObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
- if (pThisObj == pObj) {
- return index;
- }
- index++;
+ return AddHead(pNewObject);
}
- return -1;
+ return InsertAfter(posInsertAfter, pNewObject);
}
CPDF_PageObject* CPDF_PageObjectList::GetObjectByIndex(int index) const {
- FX_POSITION pos = m_ObjectList.FindIndex(index);
- return pos ? static_cast<CPDF_PageObject*>(m_ObjectList.GetAt(pos)) : nullptr;
+ FX_POSITION pos = FindIndex(index);
+ return pos ? GetObjectAt(pos) : nullptr;
}
-void CPDF_PageObjectList::Transform(const CFX_Matrix& matrix) {
- FX_POSITION pos = m_ObjectList.GetHeadPosition();
+void CPDF_PageObjectHolder::Transform(const CFX_Matrix& matrix) {
+ FX_POSITION pos = m_PageObjectList.GetHeadPosition();
while (pos) {
- CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
- pObj->Transform(matrix);
+ m_PageObjectList.GetNextObject(pos)->Transform(matrix);
}
}
-CFX_FloatRect CPDF_PageObjectList::CalcBoundingBox() const {
- if (m_ObjectList.GetCount() == 0) {
+CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const {
+ if (m_PageObjectList.GetCount() == 0) {
return CFX_FloatRect(0, 0, 0, 0);
}
FX_FLOAT left, right, top, bottom;
left = bottom = 1000000 * 1.0f;
right = top = -1000000 * 1.0f;
- FX_POSITION pos = m_ObjectList.GetHeadPosition();
+ FX_POSITION pos = m_PageObjectList.GetHeadPosition();
while (pos) {
- CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
+ CPDF_PageObject* pObj = (CPDF_PageObject*)m_PageObjectList.GetNext(pos);
if (left > pObj->m_Left) {
left = pObj->m_Left;
}
@@ -752,7 +740,7 @@ CFX_FloatRect CPDF_PageObjectList::CalcBoundingBox() const {
}
return CFX_FloatRect(left, bottom, right, top);
}
-void CPDF_PageObjectList::LoadTransInfo() {
+void CPDF_PageObjectHolder::LoadTransInfo() {
if (!m_pFormDict) {
return;
}
@@ -926,10 +914,10 @@ void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates,
CPDF_Form* CPDF_Form::Clone() const {
CPDF_Form* pClone =
new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources);
- FX_POSITION pos = m_ObjectList.GetHeadPosition();
+ FX_POSITION pos = m_PageObjectList.GetHeadPosition();
while (pos) {
- CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
- pClone->m_ObjectList.AddTail(pObj->Clone());
+ CPDF_PageObject* pObj = (CPDF_PageObject*)m_PageObjectList.GetNext(pos);
+ pClone->m_PageObjectList.AddTail(pObj->Clone());
}
return pClone;
}
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 20345138b4..a003d2047f 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()->SetBackgroundAlphaNeeded(TRUE);
+ pParser->GetPageObjectHolder()->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 7f242fdb0e..6e02cb11b4 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 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
CPDF_Dictionary* pPageResources,
CPDF_Dictionary* pParentResources,
CFX_Matrix* pmtContentToUser,
- CPDF_PageObjectList* pObjList,
+ CPDF_PageObjectHolder* pObjHolder,
CPDF_Dictionary* pResources,
CPDF_Rect* pBBox,
CPDF_ParseOptions* pOptions,
@@ -124,7 +124,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
m_pPageResources(pPageResources),
m_pParentResources(pParentResources),
m_pResources(pResources),
- m_pObjectList(pObjList),
+ m_pObjectHolder(pObjHolder),
m_Level(level),
m_ParamStartPos(0),
m_ParamCount(0),
@@ -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->HasImageMask())
- m_pObjectList->SetHasImageMask(m_pLastImage->IsMask());
+ if (!m_pObjectHolder->HasImageMask())
+ m_pObjectHolder->SetHasImageMask(m_pLastImage->IsMask());
} else if (type == "Form") {
AddForm(pXObject);
} else {
@@ -764,7 +764,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
form_bbox.Transform(&form_matrix);
}
CPDF_StreamContentParser parser(m_pDocument, m_pPageResources, m_pResources,
- &m_mtContentToUser, m_pObjectList,
+ &m_mtContentToUser, m_pObjectHolder,
pResources, &form_bbox, &m_Options,
m_pCurStates.get(), m_Level + 1);
parser.m_pCurStates->m_CTM = form_matrix;
@@ -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->BackgroundAlphaNeeded() &&
+ if (!m_pObjectHolder->BackgroundAlphaNeeded() &&
pFormObj->m_pForm->BackgroundAlphaNeeded()) {
- m_pObjectList->SetBackgroundAlphaNeeded(TRUE);
+ m_pObjectHolder->SetBackgroundAlphaNeeded(TRUE);
}
pFormObj->CalcBoundingBox();
SetGraphicStates(pFormObj, TRUE, TRUE, TRUE);
- m_pObjectList->AddTail(pFormObj);
+ m_pObjectHolder->GetPageObjectList()->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->AddTail(pImageObj);
+ m_pObjectHolder->GetPageObjectList()->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->AddTail(pObj);
+ m_pObjectHolder->GetPageObjectList()->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->AddTail(pText);
+ m_pObjectHolder->GetPageObjectList()->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->AddTail(pPathObj);
+ m_pObjectHolder->GetPageObjectList()->AddTail(pPathObj);
}
if (PathClipType) {
if (!matrix.IsIdentity()) {
@@ -1641,12 +1641,13 @@ FX_DWORD CPDF_StreamContentParser::Parse(const uint8_t* pData,
if (m_Level > _FPDF_MAX_FORM_LEVEL_) {
return dwSize;
}
- FX_DWORD InitObjCount = m_pObjectList->CountObjects();
+ FX_DWORD InitObjCount = m_pObjectHolder->GetPageObjectList()->GetCount();
CPDF_StreamParser syntax(pData, dwSize);
CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax);
m_CompatCount = 0;
while (1) {
- FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount;
+ FX_DWORD cost =
+ m_pObjectHolder->GetPageObjectList()->GetCount() - InitObjCount;
if (max_cost && cost >= max_cost) {
break;
}
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 022c170bf0..7fa3286e11 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->GetFirstObjectPosition();
+ FX_POSITION pos = m_pObjects->GetPageObjectList()->GetHeadPosition();
while (pos) {
CPDF_PageObject* pObj =
- (CPDF_PageObject*)m_pObjects->GetNextObject(pos);
+ m_pObjects->GetPageObjectList()->GetNextObject(pos);
if (pObj->m_ClipPath.IsNull()) {
continue;
}
diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h
index 9c8946b721..4df8d6aa9f 100644
--- a/core/src/fpdfapi/fpdf_page/pageint.h
+++ b/core/src/fpdfapi/fpdf_page/pageint.h
@@ -94,7 +94,7 @@ class CPDF_StreamContentParser {
CPDF_Dictionary* pPageResources,
CPDF_Dictionary* pParentResources,
CFX_Matrix* pmtContentToUser,
- CPDF_PageObjectList* pObjList,
+ CPDF_PageObjectHolder* pObjHolder,
CPDF_Dictionary* pResources,
CFX_FloatRect* pBBox,
CPDF_ParseOptions* pOptions,
@@ -102,7 +102,7 @@ class CPDF_StreamContentParser {
int level);
~CPDF_StreamContentParser();
- CPDF_PageObjectList* GetObjectList() const { return m_pObjectList; }
+ CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; }
CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); }
FX_BOOL IsColored() const { return m_bColored; }
const FX_FLOAT* GetType3Data() const { return m_Type3Data; }
@@ -236,7 +236,7 @@ class CPDF_StreamContentParser {
CPDF_Dictionary* m_pPageResources;
CPDF_Dictionary* m_pParentResources;
CPDF_Dictionary* m_pResources;
- CPDF_PageObjectList* m_pObjectList;
+ CPDF_PageObjectHolder* m_pObjectHolder;
int m_Level;
CFX_Matrix m_mtContentToUser;
CFX_FloatRect m_BBox;
@@ -298,7 +298,7 @@ class CPDF_ContentParser {
ParseStatus m_Status;
InternalStage m_InternalStage;
- CPDF_PageObjectList* m_pObjects;
+ CPDF_PageObjectHolder* m_pObjects;
FX_BOOL m_bForm;
CPDF_ParseOptions m_Options;
CPDF_Type3Char* m_pType3Char;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 0ea941a1e6..0023ee92de 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -237,17 +237,19 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
m_Transparency = transparency;
return TRUE;
}
-void CPDF_RenderStatus::RenderObjectList(const CPDF_PageObjectList* pObjs,
- const CFX_Matrix* pObj2Device) {
+void CPDF_RenderStatus::RenderObjectList(
+ const CPDF_PageObjectHolder* pObjectHolder,
+ const CFX_Matrix* pObj2Device) {
CFX_FloatRect clip_rect = m_pDevice->GetClipBox();
CFX_Matrix device2object;
device2object.SetReverse(*pObj2Device);
device2object.TransformRect(clip_rect);
int index = 0;
- FX_POSITION pos = pObjs->GetFirstObjectPosition();
+ FX_POSITION pos = pObjectHolder->GetPageObjectList()->GetHeadPosition();
while (pos) {
index++;
- CPDF_PageObject* pCurObj = pObjs->GetNextObject(pos);
+ CPDF_PageObject* pCurObj =
+ pObjectHolder->GetPageObjectList()->GetNextObject(pos);
if (pCurObj == m_pStopObj) {
m_bStopped = TRUE;
return;
@@ -971,10 +973,10 @@ CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc,
CPDF_RenderContext::~CPDF_RenderContext() {}
-void CPDF_RenderContext::AppendLayer(CPDF_PageObjectList* pObjs,
+void CPDF_RenderContext::AppendLayer(CPDF_PageObjectHolder* pObjectHolder,
const CFX_Matrix* pObject2Device) {
Layer* pLayer = m_Layers.AddSpace();
- pLayer->m_pObjectList = pObjs;
+ pLayer->m_pObjectHolder = pObjectHolder;
if (pObject2Device) {
pLayer->m_Matrix = *pObject2Device;
} else {
@@ -999,9 +1001,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
FinalMatrix.Concat(*pLastMatrix);
CPDF_RenderStatus status;
status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL,
- pOptions, pLayer->m_pObjectList->m_Transparency, FALSE,
- NULL);
- status.RenderObjectList(pLayer->m_pObjectList, &FinalMatrix);
+ pOptions, pLayer->m_pObjectHolder->m_Transparency,
+ FALSE, NULL);
+ status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix);
if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
}
@@ -1012,8 +1014,8 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
} else {
CPDF_RenderStatus status;
status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions,
- pLayer->m_pObjectList->m_Transparency, FALSE, NULL);
- status.RenderObjectList(pLayer->m_pObjectList, &pLayer->m_Matrix);
+ pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL);
+ status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix);
if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
}
@@ -1064,7 +1066,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
m_pRenderStatus.reset(new CPDF_RenderStatus());
m_pRenderStatus->Initialize(
m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions,
- m_pCurrentLayer->m_pObjectList->m_Transparency, FALSE, NULL);
+ m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL);
m_pDevice->SaveState();
m_ClipRect = m_pDevice->GetClipBox();
CFX_Matrix device2object;
@@ -1074,14 +1076,16 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
FX_POSITION pos;
if (m_LastObjectRendered) {
pos = m_LastObjectRendered;
- m_pCurrentLayer->m_pObjectList->GetNextObject(pos);
+ m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetNextObject(pos);
} else {
- pos = m_pCurrentLayer->m_pObjectList->GetFirstObjectPosition();
+ pos = m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()
+ ->GetHeadPosition();
}
int nObjsToGo = kStepLimit;
while (pos) {
CPDF_PageObject* pCurObj =
- m_pCurrentLayer->m_pObjectList->GetObjectAt(pos);
+ m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetObjectAt(
+ pos);
if (pCurObj && pCurObj->m_Left <= m_ClipRect.right &&
pCurObj->m_Right >= m_ClipRect.left &&
pCurObj->m_Bottom <= m_ClipRect.top &&
@@ -1108,9 +1112,9 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
return;
nObjsToGo = kStepLimit;
}
- m_pCurrentLayer->m_pObjectList->GetNextObject(pos);
+ m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetNextObject(pos);
}
- if (m_pCurrentLayer->m_pObjectList->IsParsed()) {
+ if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) {
m_pRenderStatus.reset();
m_pDevice->RestoreState();
m_pCurrentLayer = nullptr;
@@ -1120,8 +1124,8 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
return;
}
} else {
- m_pCurrentLayer->m_pObjectList->ContinueParse(pPause);
- if (!m_pCurrentLayer->m_pObjectList->IsParsed())
+ m_pCurrentLayer->m_pObjectHolder->ContinueParse(pPause);
+ if (!m_pCurrentLayer->m_pObjectHolder->IsParsed())
return;
}
}
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
index d0427f68fa..7e2c0bd0fd 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -316,9 +316,9 @@ FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) {
if (m_pBitmap || !m_pForm) {
return TRUE;
}
- if (m_pForm->CountObjects() == 1 && !m_bColored) {
- CPDF_PageObject* pPageObj =
- m_pForm->GetObjectAt(m_pForm->GetFirstObjectPosition());
+ if (m_pForm->GetPageObjectList()->GetCount() == 1 && !m_bColored) {
+ CPDF_PageObject* pPageObj = m_pForm->GetPageObjectList()->GetObjectAt(
+ m_pForm->GetPageObjectList()->GetHeadPosition());
if (pPageObj->m_Type == CPDF_PageObject::IMAGE) {
CPDF_ImageObject* pImage = (CPDF_ImageObject*)pPageObj;
m_ImageMatrix = pImage->m_Matrix;
diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h
index 165e6800fb..9a262ea6fc 100644
--- a/core/src/fpdfapi/fpdf_render/render_int.h
+++ b/core/src/fpdfapi/fpdf_render/render_int.h
@@ -124,7 +124,7 @@ class CPDF_RenderStatus {
FX_ARGB fill_color = 0,
FX_DWORD GroupFamily = 0,
FX_BOOL bLoadMask = FALSE);
- void RenderObjectList(const CPDF_PageObjectList* pObjs,
+ void RenderObjectList(const CPDF_PageObjectHolder* pObjectHolder,
const CFX_Matrix* pObj2Device);
void RenderSingleObject(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device);
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index a0f0c64822..b6e39de004 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -135,15 +135,13 @@ bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo) {
}
}
-FX_BOOL CPDF_TextPage::ParseTextPage() {
+void CPDF_TextPage::ParseTextPage() {
m_bIsParsed = false;
- if (!m_pPage)
- return FALSE;
-
m_TextBuf.Clear();
m_CharList.clear();
m_pPreTextObj = NULL;
ProcessObject();
+
m_bIsParsed = true;
m_CharIndex.clear();
int nCount = pdfium::CollectionSize<int>(m_CharList);
@@ -185,7 +183,6 @@ FX_BOOL CPDF_TextPage::ParseTextPage() {
if (indexSize % 2) {
m_CharIndex.erase(m_CharIndex.begin() + indexSize - 1);
}
- return TRUE;
}
int CPDF_TextPage::CountChars() const {
@@ -756,11 +753,8 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const {
}
int32_t CPDF_TextPage::FindTextlineFlowDirection() {
- if (!m_pPage) {
- return -1;
- }
- const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth();
- const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight();
+ const int32_t nPageWidth = static_cast<int32_t>(m_pPage->GetPageWidth());
+ const int32_t nPageHeight = static_cast<int32_t>(m_pPage->GetPageHeight());
std::vector<uint8_t> nHorizontalMask(nPageWidth);
std::vector<uint8_t> nVerticalMask(nPageHeight);
uint8_t* pDataH = nHorizontalMask.data();
@@ -769,13 +763,13 @@ int32_t CPDF_TextPage::FindTextlineFlowDirection() {
FX_FLOAT fLineHeight = 0.0f;
CPDF_PageObject* pPageObj = NULL;
FX_POSITION pos = NULL;
- pos = m_pPage->GetFirstObjectPosition();
+ pos = m_pPage->GetPageObjectList()->GetHeadPosition();
if (!pos) {
return -1;
}
while (pos) {
- pPageObj = m_pPage->GetNextObject(pos);
- if (NULL == pPageObj) {
+ pPageObj = m_pPage->GetPageObjectList()->GetNextObject(pos);
+ if (!pPageObj) {
continue;
}
if (CPDF_PageObject::TEXT != pPageObj->m_Type) {
@@ -854,19 +848,15 @@ int32_t CPDF_TextPage::FindTextlineFlowDirection() {
}
void CPDF_TextPage::ProcessObject() {
- CPDF_PageObject* pPageObj = NULL;
- if (!m_pPage) {
- return;
- }
- FX_POSITION pos;
- pos = m_pPage->GetFirstObjectPosition();
+ FX_POSITION pos = m_pPage->GetPageObjectList()->GetHeadPosition();
if (!pos) {
return;
}
m_TextlineDir = FindTextlineFlowDirection();
int nCount = 0;
while (pos) {
- pPageObj = m_pPage->GetNextObject(pos);
+ CPDF_PageObject* pPageObj =
+ m_pPage->GetPageObjectList()->GetNextObject(pos);
if (pPageObj) {
if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
CFX_Matrix matrix;
@@ -877,7 +867,6 @@ void CPDF_TextPage::ProcessObject() {
ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix);
}
}
- pPageObj = NULL;
}
int count = m_LineObj.GetSize();
for (int i = 0; i < count; i++) {
@@ -894,7 +883,7 @@ void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj,
if (!pFormObj) {
return;
}
- pos = pFormObj->m_pForm->GetFirstObjectPosition();
+ pos = pFormObj->m_pForm->GetPageObjectList()->GetHeadPosition();
if (!pos) {
return;
}
@@ -902,7 +891,7 @@ void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj,
curFormMatrix.Copy(pFormObj->m_FormMatrix);
curFormMatrix.Concat(formMatrix);
while (pos) {
- pPageObj = pFormObj->m_pForm->GetNextObject(pos);
+ pPageObj = pFormObj->m_pForm->GetPageObjectList()->GetNextObject(pos);
if (pPageObj) {
if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
ProcessTextObject((CPDF_TextObject*)pPageObj, curFormMatrix, pos);
@@ -1851,11 +1840,11 @@ FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(CPDF_TextObject* pTextObj,
}
int i = 0;
if (!ObjPos) {
- ObjPos = m_pPage->GetLastObjectPosition();
+ ObjPos = m_pPage->GetPageObjectList()->GetTailPosition();
}
- CPDF_PageObject* pObj = m_pPage->GetPrevObject(ObjPos);
+ CPDF_PageObject* pObj = m_pPage->GetPageObjectList()->GetPrevObject(ObjPos);
while (i < 5 && ObjPos) {
- pObj = m_pPage->GetPrevObject(ObjPos);
+ pObj = m_pPage->GetPageObjectList()->GetPrevObject(ObjPos);
if (pObj == pTextObj) {
continue;
}
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index 9131cdb321..edde651ddb 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -57,7 +57,7 @@ class CPDF_TextPage : public IPDF_TextPage {
~CPDF_TextPage() override {}
// IPDF_TextPage:
- FX_BOOL ParseTextPage() override;
+ void ParseTextPage() override;
bool IsParsed() const override { return m_bIsParsed; }
int CharIndexFromTextIndex(int TextIndex) const override;
int TextIndexFromCharIndex(int CharIndex) const override;
@@ -131,8 +131,8 @@ class CPDF_TextPage : public IPDF_TextPage {
const CPDF_Font* pFont,
int nItems) const;
+ const CPDF_Page* const m_pPage;
std::vector<FX_WORD> m_CharIndex;
- const CPDF_PageObjectList* const m_pPage;
std::deque<PAGECHAR_INFO> m_CharList;
std::deque<PAGECHAR_INFO> m_TempCharList;
CFX_WideTextBuf m_TextBuf;