diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-02-16 17:15:32 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-02-16 17:15:32 -0800 |
commit | 32c70815316672091946be88e5941089c359d151 (patch) | |
tree | 5c09a48725bb43b07d09a435f38ead6a933e1712 /fpdfsdk/src | |
parent | 4e44b4049bd4790bcb6c835455632c81c34e78b6 (diff) | |
download | pdfium-32c70815316672091946be88e5941089c359d151.tar.xz |
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 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r-- | fpdfsdk/src/fpdf_flatten.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfeditpage.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/fxedit/fxet_pageobjs.cpp | 33 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/Document.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/src/pdfwindow/PWL_Edit.cpp | 4 |
5 files changed, 32 insertions, 31 deletions
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<CPDF_TextObject*>& 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<CPDF_TextObject*> ObjArray; IFX_Edit::GeneratePageObjects( |