From 0cc77c9ef74f527a6887d9a2e8ebcb6412615f30 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 7 May 2018 22:55:46 +0000 Subject: Add some getters for CPDF_PageObjectHolder. Change-Id: I3fe99ecb17d37f893ce5d0d59219c82ee31fe7ea Reviewed-on: https://pdfium-review.googlesource.com/32110 Commit-Queue: Lei Zhang Reviewed-by: dsinclair --- core/fpdfapi/page/cpdf_pageobjectholder.h | 16 +++++++++++--- core/fpdfapi/render/cpdf_imagerenderer.cpp | 2 +- core/fpdfapi/render/cpdf_pagerendercache.cpp | 4 ++-- core/fpdfapi/render/cpdf_progressiverenderer.cpp | 4 ++-- core/fpdfapi/render/cpdf_rendercontext.cpp | 10 ++++----- core/fpdfapi/render/cpdf_renderstatus.cpp | 28 ++++++++++++------------ core/fpdfdoc/cpdf_annot.cpp | 4 ++-- core/fpdfdoc/cpdf_annotlist.cpp | 6 ++--- 8 files changed, 42 insertions(+), 32 deletions(-) diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h index a65ccc8129..febc53e410 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.h +++ b/core/fpdfapi/page/cpdf_pageobjectholder.h @@ -17,11 +17,11 @@ #include "core/fxcrt/fx_system.h" #include "core/fxcrt/unowned_ptr.h" -class PauseIndicatorIface; +class CPDF_ContentParser; class CPDF_Dictionary; -class CPDF_Stream; class CPDF_Document; -class CPDF_ContentParser; +class CPDF_Stream; +class PauseIndicatorIface; #define PDFTRANS_GROUP 0x0100 #define PDFTRANS_ISOLATED 0x0200 @@ -52,6 +52,14 @@ class CPDF_PageObjectHolder { void ContinueParse(PauseIndicatorIface* pPause); bool IsParsed() const { return m_ParseState == CONTENT_PARSED; } + const CPDF_Document* GetDocument() const { return m_pDocument.Get(); } + CPDF_Document* GetDocument() { return m_pDocument.Get(); } + + // TODO(thestig): Can this return nullptr? If not, audit callers and simplify + // the ones that assume it can. + const CPDF_Dictionary* GetFormDict() const { return m_pFormDict.Get(); } + CPDF_Dictionary* GetFormDict() { return m_pFormDict.Get(); } + const CPDF_PageObjectList* GetPageObjectList() const { return &m_PageObjectList; } @@ -63,7 +71,9 @@ class CPDF_PageObjectHolder { bool ErasePageObjectAtIndex(size_t index); const CFX_Matrix& GetLastCTM() const { return m_LastCTM; } + const CFX_FloatRect& GetBBox() const { return m_BBox; } + int GetTransparency() const { return m_iTransparency; } bool BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } void SetBackgroundAlphaNeeded(bool needed) { m_bBackgroundAlphaNeeded = needed; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 3844f69895..e9e6420632 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -142,7 +142,7 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { CPDF_Page* pPage = nullptr; if (auto* pPageCache = m_pRenderStatus->GetContext()->GetPageCache()) { pPage = pPageCache->GetPage(); - pDocument = pPage->m_pDocument.Get(); + pDocument = pPage->GetDocument(); } else { pDocument = m_pImageObject->GetImage()->GetDocument(); } diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp index a929cb69c7..1358943454 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.cpp +++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp @@ -92,7 +92,7 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap( m_pCurImageCacheEntry = it->second; } else { m_pCurImageCacheEntry = - new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pImage); + new CPDF_ImageCacheEntry(m_pPage->GetDocument(), pImage); } CPDF_DIBSource::LoadState ret = m_pCurImageCacheEntry->StartGetCachedBitmap( pRenderStatus->GetFormResource(), m_pPage->m_pPageResources.Get(), bStdCS, @@ -134,7 +134,7 @@ void CPDF_PageRenderCache::ResetBitmap(const RetainPtr& pImage, if (!pBitmap) return; - pEntry = new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pImage); + pEntry = new CPDF_ImageCacheEntry(m_pPage->GetDocument(), pImage); m_ImageCache[pStream] = pEntry; } else { pEntry = it->second; diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp index b2d16300d4..e388f7fa10 100644 --- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp +++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp @@ -57,8 +57,8 @@ void CPDF_ProgressiveRenderer::Continue(PauseIndicatorIface* pPause) { m_pRenderStatus = pdfium::MakeUnique(); m_pRenderStatus->Initialize( m_pContext.Get(), m_pDevice.Get(), nullptr, nullptr, nullptr, nullptr, - m_pOptions, m_pCurrentLayer->m_pObjectHolder->m_iTransparency, false, - nullptr); + m_pOptions, m_pCurrentLayer->m_pObjectHolder->GetTransparency(), + false, nullptr); m_pDevice->SaveState(); m_ClipRect = m_pCurrentLayer->m_Matrix.GetInverse().TransformRect( CFX_FloatRect(m_pDevice->GetClipBox())); diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp index 73f9a4c3ff..fc756e7a90 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.cpp +++ b/core/fpdfapi/render/cpdf_rendercontext.cpp @@ -21,7 +21,7 @@ #include "core/fxge/fx_dib.h" CPDF_RenderContext::CPDF_RenderContext(CPDF_Page* pPage) - : m_pDocument(pPage->m_pDocument.Get()), + : m_pDocument(pPage->GetDocument()), m_pPageResources(pPage->m_pPageResources.Get()), m_pPageCache(pPage->GetRenderCache()) {} @@ -70,13 +70,13 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, CFX_Matrix FinalMatrix = layer.m_Matrix; FinalMatrix.Concat(*pLastMatrix); status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, - pOptions, layer.m_pObjectHolder->m_iTransparency, false, - nullptr); + pOptions, layer.m_pObjectHolder->GetTransparency(), + false, nullptr); status.RenderObjectList(layer.m_pObjectHolder.Get(), &FinalMatrix); } else { status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, - pOptions, layer.m_pObjectHolder->m_iTransparency, false, - nullptr); + pOptions, layer.m_pObjectHolder->GetTransparency(), + false, nullptr); status.RenderObjectList(layer.m_pObjectHolder.Get(), &layer.m_Matrix); } if (status.GetRenderOptions()->HasFlag(RENDER_LIMITEDIMAGECACHE)) { diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 4df9f18375..f9261570fe 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1241,7 +1241,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, CPDF_Dictionary* pFormResource = nullptr; const CPDF_FormObject* pFormObj = pObj->AsForm(); if (pFormObj) { - const auto& pFormDict = pFormObj->form()->m_pFormDict; + const CPDF_Dictionary* pFormDict = pFormObj->form()->GetFormDict(); if (pFormDict) pFormResource = pFormDict->GetDictFor("Resources"); } @@ -1258,14 +1258,14 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - CPDF_Dictionary* pOC = pFormObj->form()->m_pFormDict->GetDictFor("OC"); + CPDF_Dictionary* pOC = pFormObj->form()->GetFormDict()->GetDictFor("OC"); if (pOC && m_Options.GetOCContext() && !m_Options.GetOCContext()->CheckOCGVisible(pOC)) { return true; } CFX_Matrix matrix = pFormObj->form_matrix(); matrix.Concat(*pObj2Device); - const auto& pFormDict = pFormObj->form()->m_pFormDict; + const CPDF_Dictionary* pFormDict = pFormObj->form()->GetFormDict(); CPDF_Dictionary* pResources = pFormDict ? pFormDict->GetDictFor("Resources") : nullptr; CPDF_RenderStatus status; @@ -1487,9 +1487,9 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, const CPDF_FormObject* pFormObj = pPageObj->AsForm(); if (pFormObj) { group_alpha = pFormObj->m_GeneralState.GetFillAlpha(); - iTransparency = pFormObj->form()->m_iTransparency; + iTransparency = pFormObj->form()->GetTransparency(); bGroupTransparent = !!(iTransparency & PDFTRANS_ISOLATED); - const auto& pFormDict = pFormObj->form()->m_pFormDict; + const CPDF_Dictionary* pFormDict = pFormObj->form()->GetFormDict(); if (pFormDict) pFormResource = pFormDict->GetDictFor("Resources"); } @@ -1505,7 +1505,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, CPDF_Page* pPage = nullptr; if (m_pContext->GetPageCache()) { pPage = m_pContext->GetPageCache()->GetPage(); - pDocument = pPage->m_pDocument.Get(); + pDocument = pPage->GetDocument(); } else { pDocument = pPageObj->AsImage()->GetImage()->GetDocument(); } @@ -1879,15 +1879,15 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, options.SetFlags(option_flags); CPDF_Dictionary* pFormResource = nullptr; - if (pType3Char->form() && pType3Char->form()->m_pFormDict) { + if (pType3Char->form() && pType3Char->form()->GetFormDict()) { pFormResource = - pType3Char->form()->m_pFormDict->GetDictFor("Resources"); + pType3Char->form()->GetFormDict()->GetDictFor("Resources"); } if (fill_alpha == 255) { CPDF_RenderStatus status; status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this, pStates.get(), &options, - pType3Char->form()->m_iTransparency, m_bDropObjects, + pType3Char->form()->GetTransparency(), m_bDropObjects, pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache = m_Type3FontCache; status.m_Type3FontCache.push_back(pType3Font); @@ -1907,7 +1907,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, CPDF_RenderStatus status; status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr, this, pStates.get(), &options, - pType3Char->form()->m_iTransparency, m_bDropObjects, + pType3Char->form()->GetTransparency(), m_bDropObjects, pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache = m_Type3FontCache; status.m_Type3FontCache.push_back(pType3Font); @@ -2247,7 +2247,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, if (!pPattern->colored()) pStates = CloneObjStates(pPageObj, bStroke); - auto& pFormDict = pPattern->form()->m_pFormDict; + const CPDF_Dictionary* pFormDict = pPattern->form()->GetFormDict(); CPDF_Dictionary* pFormResource = pFormDict ? pFormDict->GetDictFor("Resources") : nullptr; for (int col = min_col; col <= max_col; col++) { @@ -2261,7 +2261,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_RenderStatus status; status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this, pStates.get(), &m_Options, - pPattern->form()->m_iTransparency, m_bDropObjects, + pPattern->form()->GetTransparency(), m_bDropObjects, pFormResource); status.RenderObjectList(pPattern->form(), &matrix); } @@ -2611,8 +2611,8 @@ RetainPtr CPDF_RenderStatus::LoadSMask( bitmap.Clear(0); } CPDF_Dictionary* pFormResource = nullptr; - if (form.m_pFormDict) { - pFormResource = form.m_pFormDict->GetDictFor("Resources"); + if (form.GetFormDict()) { + pFormResource = form.GetFormDict()->GetDictFor("Resources"); } CPDF_RenderOptions options; options.SetColorMode(bLuminosity ? CPDF_RenderOptions::kNormal diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index ef803c428d..3b84baf8db 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -53,9 +53,9 @@ CPDF_Form* AnnotGetMatrix(const CPDF_Page* pPage, if (!pForm) return nullptr; - CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix"); + CFX_Matrix form_matrix = pForm->GetFormDict()->GetMatrixFor("Matrix"); CFX_FloatRect form_bbox = - form_matrix.TransformRect(pForm->m_pFormDict->GetRectFor("BBox")); + form_matrix.TransformRect(pForm->GetFormDict()->GetRectFor("BBox")); matrix->MatchRect(pAnnot->GetRect(), form_bbox); matrix->Concat(*pUser2Device); return pForm; diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 6b359f1eb5..77a2d0c2af 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -120,11 +120,11 @@ void GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { } // namespace CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) - : m_pDocument(pPage->m_pDocument.Get()) { - if (!pPage->m_pFormDict) + : m_pDocument(pPage->GetDocument()) { + if (!pPage->GetFormDict()) return; - CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots"); + CPDF_Array* pAnnots = pPage->GetFormDict()->GetArrayFor("Annots"); if (!pAnnots) return; -- cgit v1.2.3