From 32c70815316672091946be88e5941089c359d151 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 16 Feb 2016 17:15:32 -0800 Subject: Split CPDF_PageObjectHolder off from CPDF_PageObjectList Eventually, we're going to expose an iterator over CPDF_PageObjectList that we don't want to be inherited by the CPDF_PageObjectHolder sub-classes: page and form. Also, the operations that the object holder performs dealing with inquiring about masks and such seem beyond the scope of what a list would provide. Hence the "Holder" name. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1701073002 . --- core/include/fpdfapi/fpdf_module.h | 1 - core/include/fpdfapi/fpdf_page.h | 52 ++++++++++---------- core/include/fpdfapi/fpdf_render.h | 4 +- core/include/fpdftext/fpdf_text.h | 3 +- core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp | 4 +- core/src/fpdfapi/fpdf_font/fpdf_font.cpp | 2 +- core/src/fpdfapi/fpdf_page/fpdf_page.cpp | 56 +++++++++------------- .../fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 2 +- core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 29 +++++------ .../src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 4 +- core/src/fpdfapi/fpdf_page/pageint.h | 8 ++-- core/src/fpdfapi/fpdf_render/fpdf_render.cpp | 42 ++++++++-------- core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp | 6 +-- core/src/fpdfapi/fpdf_render/render_int.h | 2 +- core/src/fpdftext/fpdf_text_int.cpp | 41 ++++++---------- core/src/fpdftext/text_int.h | 4 +- fpdfsdk/include/fxedit/fx_edit.h | 8 ++-- fpdfsdk/include/pdfwindow/PWL_Edit.h | 4 +- fpdfsdk/src/fpdf_flatten.cpp | 5 +- fpdfsdk/src/fpdfeditpage.cpp | 8 ++-- fpdfsdk/src/fxedit/fxet_pageobjs.cpp | 33 ++++++------- fpdfsdk/src/javascript/Document.cpp | 13 +++-- fpdfsdk/src/pdfwindow/PWL_Edit.cpp | 4 +- 23 files changed, 157 insertions(+), 178 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(GetNext(pos)); } CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const { - return (CPDF_PageObject*)m_ObjectList.GetPrev(pos); + return static_cast(GetPrev(pos)); } CPDF_PageObject* GetObjectAt(FX_POSITION pos) const { - return (CPDF_PageObject*)m_ObjectList.GetAt(pos); + return static_cast(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 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(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(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(m_pPage->GetPageWidth()); + const int32_t nPageHeight = static_cast(m_pPage->GetPageHeight()); std::vector nHorizontalMask(nPageWidth); std::vector 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 m_CharIndex; - const CPDF_PageObjectList* const m_pPage; std::deque m_CharList; std::deque m_TempCharList; CFX_WideTextBuf m_TextBuf; diff --git a/fpdfsdk/include/fxedit/fx_edit.h b/fpdfsdk/include/fxedit/fx_edit.h index 59ac2b13ba..359f7d85e1 100644 --- a/fpdfsdk/include/fxedit/fx_edit.h +++ b/fpdfsdk/include/fxedit/fx_edit.h @@ -14,7 +14,7 @@ class CFX_RenderDevice; class CPDF_Font; class CFX_Matrix; -class CPDF_PageObjectList; +class CPDF_PageObjectHolder; class CPDF_Point; class CPDF_TextObject; class IFX_Edit; @@ -458,19 +458,19 @@ class IFX_Edit { const CPDF_Point& ptOffset, const CPVT_WordRange* pRange); static void GeneratePageObjects( - CPDF_PageObjectList* pPageObjects, + CPDF_PageObjectHolder* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTemplate& ObjArray); static void GenerateRichPageObjects( - CPDF_PageObjectList* pPageObjects, + CPDF_PageObjectHolder* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, CFX_ArrayTemplate& ObjArray); - static void GenerateUnderlineObjects(CPDF_PageObjectList* pPageObjects, + static void GenerateUnderlineObjects(CPDF_PageObjectHolder* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, diff --git a/fpdfsdk/include/pdfwindow/PWL_Edit.h b/fpdfsdk/include/pdfwindow/PWL_Edit.h index 7885331bc7..4b3411b772 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/include/pdfwindow/PWL_Edit.h @@ -110,10 +110,10 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { m_pFillerNotify = pNotify; } - void GeneratePageObjects(CPDF_PageObjectList* pPageObjects, + void GeneratePageObjects(CPDF_PageObjectHolder* pPageObjects, const CPDF_Point& ptOffset, CFX_ArrayTemplate& ObjArray); - void GeneratePageObjects(CPDF_PageObjectList* pPageObjects, + void GeneratePageObjects(CPDF_PageObjectHolder* pPageObjects, const CPDF_Point& ptOffset); protected: diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp index 413b391eee..36b8319dca 100644 --- a/fpdfsdk/src/fpdf_flatten.cpp +++ b/fpdfsdk/src/fpdf_flatten.cpp @@ -42,9 +42,10 @@ FX_BOOL GetContentsRect(CPDF_Document* pDoc, pPDFPage->Load(pDoc, pDict, FALSE); pPDFPage->ParseContent(nullptr); - FX_POSITION pos = pPDFPage->GetFirstObjectPosition(); + FX_POSITION pos = pPDFPage->GetPageObjectList()->GetHeadPosition(); while (pos) { - CPDF_PageObject* pPageObject = pPDFPage->GetNextObject(pos); + CPDF_PageObject* pPageObject = + pPDFPage->GetPageObjectList()->GetNextObject(pos); if (!pPageObject) continue; diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp index f964172d10..6d39cb100f 100644 --- a/fpdfsdk/src/fpdfeditpage.cpp +++ b/fpdfsdk/src/fpdfeditpage.cpp @@ -135,9 +135,9 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; if (!pPageObj) return; - FX_POSITION LastPersition = pPage->GetLastObjectPosition(); + FX_POSITION LastPersition = pPage->GetPageObjectList()->GetTailPosition(); - pPage->InsertObject(LastPersition, pPageObj); + pPage->GetPageObjectList()->InsertObject(LastPersition, pPageObj); switch (pPageObj->m_Type) { case FPDF_PAGEOBJ_PATH: { CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; @@ -177,7 +177,7 @@ DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) { "Page")) { return -1; } - return pPage->CountObjects(); + return pPage->GetPageObjectList()->GetCount(); } DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, @@ -188,7 +188,7 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, "Page")) { return NULL; } - return pPage->GetObjectByIndex(index); + return pPage->GetPageObjectList()->GetObjectByIndex(index); } DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) { diff --git a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp index 6cdcc84991..d54e4649db 100644 --- a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp +++ b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp @@ -409,7 +409,7 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, pDevice->RestoreState(); } -static void AddRectToPageObjects(CPDF_PageObjectList* pPageObjs, +static void AddRectToPageObjects(CPDF_PageObjectHolder* pPageObjs, FX_COLORREF crFill, const CPDF_Rect& rcFill) { CPDF_PathObject* pPathObj = new CPDF_PathObject; @@ -425,18 +425,19 @@ static void AddRectToPageObjects(CPDF_PageObjectList* pPageObjs, pPathObj->m_FillType = FXFILL_ALTERNATE; pPathObj->m_bStroke = FALSE; - - pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pPathObj); + pPageObjs->GetPageObjectList()->InsertObject( + pPageObjs->GetPageObjectList()->GetTailPosition(), pPathObj); } -static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectList* pPageObjs, - FX_COLORREF crText, - CPDF_Font* pFont, - FX_FLOAT fFontSize, - FX_FLOAT fCharSpace, - int32_t nHorzScale, - const CPDF_Point& point, - const CFX_ByteString& text) { +static CPDF_TextObject* AddTextObjToPageObjects( + CPDF_PageObjectHolder* pPageObjs, + FX_COLORREF crText, + CPDF_Font* pFont, + FX_FLOAT fFontSize, + FX_FLOAT fCharSpace, + int32_t nHorzScale, + const CPDF_Point& point, + const CFX_ByteString& text) { CPDF_TextObject* pTxtObj = new CPDF_TextObject; CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); @@ -461,14 +462,14 @@ static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectList* pPageObjs, pTxtObj->SetPosition(point.x, point.y); pTxtObj->SetText(text); - - pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pTxtObj); + pPageObjs->GetPageObjectList()->InsertObject( + pPageObjs->GetPageObjectList()->GetTailPosition(), pTxtObj); return pTxtObj; } void IFX_Edit::GeneratePageObjects( - CPDF_PageObjectList* pPageObjects, + CPDF_PageObjectHolder* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, @@ -532,7 +533,7 @@ void IFX_Edit::GeneratePageObjects( } void IFX_Edit::GenerateRichPageObjects( - CPDF_PageObjectList* pPageObjects, + CPDF_PageObjectHolder* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, @@ -624,7 +625,7 @@ void IFX_Edit::GenerateRichPageObjects( } } -void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectList* pPageObjects, +void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pPageObjects, IFX_Edit* pEdit, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 0bd754af76..e869e72310 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -1380,14 +1380,12 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc, page.Load(pDocument, pPageDict); page.ParseContent(nullptr); - FX_POSITION pos = page.GetFirstObjectPosition(); - int nWords = 0; - CFX_WideString swRet; - + FX_POSITION pos = page.GetPageObjectList()->GetHeadPosition(); while (pos) { - if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) { + if (CPDF_PageObject* pPageObj = + page.GetPageObjectList()->GetNextObject(pos)) { if (pPageObj->m_Type == CPDF_PageObject::TEXT) { int nObjWords = CountWords((CPDF_TextObject*)pPageObj); @@ -1444,9 +1442,10 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc, page.ParseContent(nullptr); int nWords = 0; - FX_POSITION pos = page.GetFirstObjectPosition(); + FX_POSITION pos = page.GetPageObjectList()->GetHeadPosition(); while (pos) { - if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) { + if (CPDF_PageObject* pPageObj = + page.GetPageObjectList()->GetNextObject(pos)) { if (pPageObj->m_Type == CPDF_PageObject::TEXT) { CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj; nWords += CountWords(pTextObj); diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp index cbef23cc19..057cb4191e 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp @@ -1168,7 +1168,7 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place, } void CPWL_Edit::GeneratePageObjects( - CPDF_PageObjectList* pPageObjects, + CPDF_PageObjectHolder* pPageObjects, const CPDF_Point& ptOffset, CFX_ArrayTemplate& ObjArray) { IFX_Edit::GeneratePageObjects( @@ -1177,7 +1177,7 @@ void CPWL_Edit::GeneratePageObjects( ObjArray); } -void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectList* pPageObjects, +void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pPageObjects, const CPDF_Point& ptOffset) { CFX_ArrayTemplate ObjArray; IFX_Edit::GeneratePageObjects( -- cgit v1.2.3