From 4cb82ee95256f110489f2b503e70729c44419e74 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 22 May 2017 15:15:30 -0700 Subject: Convert more c-style pointers to CFX_UnownedPtr Change-Id: I551b4210c95db0b916e9fe6cddf11e6c3d015c50 Reviewed-on: https://pdfium-review.googlesource.com/5790 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 4 ++-- core/fpdfapi/font/cpdf_type3font.cpp | 3 ++- core/fpdfapi/font/cpdf_type3font.h | 6 +++--- core/fpdfapi/page/cpdf_colorspace.h | 5 +++-- core/fpdfapi/page/cpdf_contentparser.cpp | 13 ++++++++----- core/fpdfapi/page/cpdf_contentparser.h | 5 +++-- core/fpdfapi/page/cpdf_generalstate.cpp | 8 ++++---- core/fpdfapi/page/cpdf_generalstate.h | 11 ++++++----- core/fpdfapi/page/cpdf_page.cpp | 2 +- core/fpdfapi/page/cpdf_pageobjectholder.h | 11 ++++++----- core/fpdfapi/page/cpdf_shadingpattern.cpp | 2 +- core/fpdfapi/page/cpdf_shadingpattern.h | 5 +++-- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 14 +++++++------- core/fpdfapi/page/cpdf_streamcontentparser.h | 16 +++++++++------- core/fpdfapi/render/cpdf_imagerenderer.cpp | 5 +++-- core/fpdfapi/render/cpdf_pagerendercache.cpp | 6 +++--- core/fpdfapi/render/cpdf_rendercontext.cpp | 4 ++-- core/fpdfapi/render/cpdf_renderstatus.cpp | 5 +++-- core/fpdfdoc/cpdf_annot.cpp | 4 ++-- core/fpdfdoc/cpdf_annotlist.cpp | 2 +- core/fpdfdoc/cpdf_interform.cpp | 2 +- fpdfsdk/cpdfsdk_pageview.cpp | 4 ++-- fpdfsdk/cpdfsdk_widgethandler.cpp | 3 +-- fpdfsdk/formfiller/cba_fontmap.cpp | 2 +- fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 3 +-- fpdfsdk/fpdf_flatten.cpp | 4 ++-- fpdfsdk/fpdf_structtree.cpp | 3 ++- fpdfsdk/fpdf_transformpage.cpp | 8 ++++---- fpdfsdk/fpdfdoc.cpp | 2 +- fpdfsdk/fpdfeditpage.cpp | 3 +-- fpdfsdk/fpdfformfill.cpp | 8 ++++---- fpdfsdk/fpdftext.cpp | 2 +- fpdfsdk/fpdfview.cpp | 3 +-- 33 files changed, 94 insertions(+), 84 deletions(-) diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index e431b9bf57..8238414e64 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -49,7 +49,7 @@ bool GetColor(const CPDF_Color* pColor, float* rgb) { } // namespace CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage) - : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument) { + : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument.Get()) { for (const auto& pObj : *pPage->GetPageObjectList()) { if (pObj) m_pageObjects.push_back(pObj.get()); @@ -68,7 +68,7 @@ void CPDF_PageContentGenerator::GenerateContent() { else if (CPDF_TextObject* pTextObj = pPageObj->AsText()) ProcessText(&buf, pTextObj); } - CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; + CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict.Get(); CPDF_Object* pContent = pPageDict ? pPageDict->GetDirectObjectFor("Contents") : nullptr; if (pContent) diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp index 79f6617ce3..1e8c567a7f 100644 --- a/core/fpdfapi/font/cpdf_type3font.cpp +++ b/core/fpdfapi/font/cpdf_type3font.cpp @@ -107,7 +107,8 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) { auto pNewChar = pdfium::MakeUnique(pdfium::MakeUnique( - m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources, + m_pDocument, + m_pFontResources ? m_pFontResources.Get() : m_pPageResources.Get(), pStream, nullptr)); // This can trigger recursion into this method. The content of |m_CacheMap| diff --git a/core/fpdfapi/font/cpdf_type3font.h b/core/fpdfapi/font/cpdf_type3font.h index 0bae192d61..135a19fb7c 100644 --- a/core/fpdfapi/font/cpdf_type3font.h +++ b/core/fpdfapi/font/cpdf_type3font.h @@ -48,9 +48,9 @@ class CPDF_Type3Font : public CPDF_SimpleFont { void LoadGlyphMap() override {} int m_CharWidthL[256]; - CPDF_Dictionary* m_pCharProcs; - CPDF_Dictionary* m_pPageResources; - CPDF_Dictionary* m_pFontResources; + CFX_UnownedPtr m_pCharProcs; + CFX_UnownedPtr m_pPageResources; + CFX_UnownedPtr m_pFontResources; std::map> m_CacheMap; // The depth char loading is in, to avoid recurive calling LoadChar(). int m_CharLoadingDepth; diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h index 76072d1260..15029026c2 100644 --- a/core/fpdfapi/page/cpdf_colorspace.h +++ b/core/fpdfapi/page/cpdf_colorspace.h @@ -9,6 +9,7 @@ #include +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" @@ -61,7 +62,7 @@ class CPDF_ColorSpace { int image_height, bool bTransMask) const; - CPDF_Array*& GetArray() { return m_pArray; } + CPDF_Array* GetArray() const { return m_pArray.Get(); } virtual CPDF_ColorSpace* GetBaseCS() const; virtual void EnableStdConversion(bool bEnabled); @@ -82,7 +83,7 @@ class CPDF_ColorSpace { int m_Family; uint32_t m_nComponents; - CPDF_Array* m_pArray; + CFX_UnownedPtr m_pArray; uint32_t m_dwStdConversion; }; diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index eeac3c17b1..4f4036f078 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -98,8 +98,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources"); m_pParser = pdfium::MakeUnique( - pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, - pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level); + pForm->m_pDocument.Get(), pForm->m_pPageResources.Get(), + pForm->m_pResources.Get(), pParentMatrix, pForm, pResources, &form_bbox, + pGraphicStates, level); m_pParser->GetCurStates()->m_CTM = form_matrix; m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; if (ClipPath.HasRef()) { @@ -114,7 +115,8 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, pState->SetSoftMask(nullptr); } m_nStreams = 0; - m_pSingleStream = pdfium::MakeRetain(pForm->m_pFormStream); + m_pSingleStream = + pdfium::MakeRetain(pForm->m_pFormStream.Get()); m_pSingleStream->LoadAllData(false); m_pData = (uint8_t*)m_pSingleStream->GetData(); m_Size = m_pSingleStream->GetSize(); @@ -167,8 +169,9 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { if (m_InternalStage == STAGE_PARSE) { if (!m_pParser) { m_pParser = pdfium::MakeUnique( - m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources, - nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources, + m_pObjectHolder->m_pDocument.Get(), + m_pObjectHolder->m_pPageResources.Get(), nullptr, nullptr, + m_pObjectHolder.Get(), m_pObjectHolder->m_pResources.Get(), &m_pObjectHolder->m_BBox, nullptr, 0); m_pParser->GetCurStates()->m_ColorState.SetDefault(); } diff --git a/core/fpdfapi/page/cpdf_contentparser.h b/core/fpdfapi/page/cpdf_contentparser.h index 402fd2fdd0..58a977301f 100644 --- a/core/fpdfapi/page/cpdf_contentparser.h +++ b/core/fpdfapi/page/cpdf_contentparser.h @@ -13,6 +13,7 @@ #include "core/fpdfapi/page/cpdf_pageobjectholder.h" #include "core/fpdfapi/page/cpdf_streamcontentparser.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" +#include "core/fxcrt/cfx_unowned_ptr.h" class CPDF_AllStates; class CPDF_Form; @@ -45,9 +46,9 @@ class CPDF_ContentParser { ParseStatus m_Status; InternalStage m_InternalStage; - CPDF_PageObjectHolder* m_pObjectHolder; + CFX_UnownedPtr m_pObjectHolder; bool m_bForm; - CPDF_Type3Char* m_pType3Char; + CFX_UnownedPtr m_pType3Char; uint32_t m_nStreams; CFX_RetainPtr m_pSingleStream; std::vector> m_StreamArray; diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp index 513e5ff7a5..e07a3ca13d 100644 --- a/core/fpdfapi/page/cpdf_generalstate.cpp +++ b/core/fpdfapi/page/cpdf_generalstate.cpp @@ -108,7 +108,7 @@ void CPDF_GeneralState::SetStrokeAlpha(float alpha) { CPDF_Object* CPDF_GeneralState::GetSoftMask() const { const StateData* pData = m_Ref.GetObject(); - return pData ? pData->m_pSoftMask : nullptr; + return pData ? pData->m_pSoftMask.Get() : nullptr; } void CPDF_GeneralState::SetSoftMask(CPDF_Object* pObject) { @@ -117,7 +117,7 @@ void CPDF_GeneralState::SetSoftMask(CPDF_Object* pObject) { CPDF_Object* CPDF_GeneralState::GetTR() const { const StateData* pData = m_Ref.GetObject(); - return pData ? pData->m_pTR : nullptr; + return pData ? pData->m_pTR.Get() : nullptr; } void CPDF_GeneralState::SetTR(CPDF_Object* pObject) { @@ -271,7 +271,7 @@ CPDF_GeneralState::StateData::StateData(const StateData& that) CPDF_DocRenderData* pDocCache = that.m_pTransferFunc->m_pPDFDoc->GetRenderData(); if (pDocCache) - m_pTransferFunc = pDocCache->GetTransferFunc(m_pTR); + m_pTransferFunc = pDocCache->GetTransferFunc(m_pTR.Get()); } } @@ -280,7 +280,7 @@ CPDF_GeneralState::StateData::~StateData() { CPDF_DocRenderData* pDocCache = m_pTransferFunc->m_pPDFDoc->GetRenderData(); if (pDocCache) { m_pTransferFunc.Reset(); // Give up our reference first. - pDocCache->MaybePurgeTransferFunc(m_pTR); + pDocCache->MaybePurgeTransferFunc(m_pTR.Get()); } } } diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h index 9305785256..4ec08ca9c5 100644 --- a/core/fpdfapi/page/cpdf_generalstate.h +++ b/core/fpdfapi/page/cpdf_generalstate.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_PAGE_CPDF_GENERALSTATE_H_ #include "core/fxcrt/cfx_shared_copy_on_write.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxge/fx_dib.h" @@ -83,11 +84,11 @@ class CPDF_GeneralState { CFX_ByteString m_BlendMode; int m_BlendType; - CPDF_Object* m_pSoftMask; + CFX_UnownedPtr m_pSoftMask; CFX_Matrix m_SMaskMatrix; float m_StrokeAlpha; float m_FillAlpha; - CPDF_Object* m_pTR; + CFX_UnownedPtr m_pTR; CFX_RetainPtr m_pTransferFunc; CFX_Matrix m_Matrix; int m_RenderIntent; @@ -97,9 +98,9 @@ class CPDF_GeneralState { bool m_StrokeOP; bool m_FillOP; int m_OPMode; - CPDF_Object* m_pBG; - CPDF_Object* m_pUCR; - CPDF_Object* m_pHT; + CFX_UnownedPtr m_pBG; + CFX_UnownedPtr m_pUCR; + CFX_UnownedPtr m_pHT; float m_Flatness; float m_Smoothness; }; diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp index 5ea575e307..d528d3da0b 100644 --- a/core/fpdfapi/page/cpdf_page.cpp +++ b/core/fpdfapi/page/cpdf_page.cpp @@ -103,7 +103,7 @@ void CPDF_Page::SetRenderContext( } CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const { - CPDF_Dictionary* pPageDict = m_pFormDict; + CPDF_Dictionary* pPageDict = m_pFormDict.Get(); std::set visited; while (1) { visited.insert(pPageDict); diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h index f5b60fff9d..c95ae50520 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.h +++ b/core/fpdfapi/page/cpdf_pageobjectholder.h @@ -11,6 +11,7 @@ #include #include "core/fpdfapi/page/cpdf_pageobjectlist.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" @@ -50,11 +51,11 @@ class CPDF_PageObjectHolder { void Transform(const CFX_Matrix& matrix); CFX_FloatRect CalcBoundingBox() const; - CPDF_Dictionary* m_pFormDict; - CPDF_Stream* m_pFormStream; - CPDF_Document* m_pDocument; - CPDF_Dictionary* m_pPageResources; - CPDF_Dictionary* m_pResources; + CFX_UnownedPtr m_pFormDict; + CFX_UnownedPtr m_pFormStream; + CFX_UnownedPtr m_pDocument; + CFX_UnownedPtr m_pPageResources; + CFX_UnownedPtr m_pResources; CFX_FloatRect m_BBox; int m_Transparency; diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp index dae5ec356c..80eea63f9c 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.cpp +++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp @@ -93,7 +93,7 @@ bool CPDF_ShadingPattern::Load() { m_ShadingType = ToShadingType(pShadingDict->GetIntegerFor("ShadingType")); // We expect to have a stream if our shading type is a mesh. - if (IsMeshShading() && !ToStream(m_pShadingObj)) + if (IsMeshShading() && !ToStream(m_pShadingObj.Get())) return false; return true; diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h index 136153d4a0..c2d55cc3d5 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.h +++ b/core/fpdfapi/page/cpdf_shadingpattern.h @@ -12,6 +12,7 @@ #include "core/fpdfapi/page/cpdf_countedobject.h" #include "core/fpdfapi/page/cpdf_pattern.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" enum ShadingType { @@ -53,7 +54,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern { ShadingType GetShadingType() const { return m_ShadingType; } bool IsShadingObject() const { return m_bShadingObj; } - CPDF_Object* GetShadingObject() const { return m_pShadingObj; } + CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); } CPDF_ColorSpace* GetCS() const { return m_pCS; } const std::vector>& GetFuncs() const { return m_pFunctions; @@ -62,7 +63,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern { private: ShadingType m_ShadingType; bool m_bShadingObj; - CPDF_Object* m_pShadingObj; + CFX_UnownedPtr m_pShadingObj; // Still keep |m_pCS| as some CPDF_ColorSpace (name object) are not managed // as counted objects. Refer to CPDF_DocPageData::GetColorSpace. diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 099ddf6b05..a5af1dbee0 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -633,7 +633,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { if (!key.IsEmpty()) { uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; if (dwObjNum) - pDict->SetNewFor(key, m_pDocument, dwObjNum); + pDict->SetNewFor(key, m_pDocument.Get(), dwObjNum); else pDict->SetFor(key, std::move(pObj)); } @@ -653,7 +653,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } pDict->SetNewFor("Subtype", "Image"); std::unique_ptr pStream = - m_pSyntax->ReadInlineStream(m_pDocument, std::move(pDict), pCSObj); + m_pSyntax->ReadInlineStream(m_pDocument.Get(), std::move(pDict), pCSObj); while (1) { CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); if (type == CPDF_StreamParser::EndOfData) { @@ -771,7 +771,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { auto pFormObj = pdfium::MakeUnique(); pFormObj->m_pForm = pdfium::MakeUnique( - m_pDocument, m_pPageResources, pStream, m_pResources); + m_pDocument.Get(), m_pPageResources.Get(), pStream, m_pResources.Get()); pFormObj->m_FormMatrix = m_pCurStates->m_CTM; pFormObj->m_FormMatrix.Concat(m_mtContentToUser); CPDF_AllStates status; @@ -796,7 +796,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage( auto pImageObj = pdfium::MakeUnique(); pImageObj->SetImage( - pdfium::MakeRetain(m_pDocument, std::move(pStream))); + pdfium::MakeRetain(m_pDocument.Get(), std::move(pStream))); return AddImageObject(std::move(pImageObj)); } @@ -1176,12 +1176,12 @@ CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); if (!pFontDict) { m_bResourceMissing = true; - return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); + return CPDF_Font::GetStockFont(m_pDocument.Get(), "Helvetica"); } CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); if (pFont && pFont->IsType3Font()) { - pFont->AsType3Font()->SetPageResources(m_pResources); + pFont->AsType3Font()->SetPageResources(m_pResources.Get()); pFont->AsType3Font()->CheckType3FontMetrics(); } return pFont; @@ -1255,7 +1255,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, { auto pText = pdfium::MakeUnique(); m_pLastTextObject = pText.get(); - SetGraphicStates(m_pLastTextObject, true, true, true); + SetGraphicStates(m_pLastTextObject.Get(), true, true, true); if (TextRenderingModeIsStrokeMode(text_mode)) { float* pCTM = pText->m_TextState.GetMutableCTM(); pCTM[0] = m_pCurStates->m_CTM.a; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index 50eb0eb63a..5436f8f8c6 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -43,7 +43,9 @@ class CPDF_StreamContentParser { ~CPDF_StreamContentParser(); uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost); - CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } + CPDF_PageObjectHolder* GetPageObjectHolder() const { + return m_pObjectHolder.Get(); + } CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } bool IsColored() const { return m_bColored; } const float* GetType3Data() const { return m_Type3Data; } @@ -186,11 +188,11 @@ class CPDF_StreamContentParser { void Handle_NextLineShowText_Space(); void Handle_Invalid(); - CPDF_Document* const m_pDocument; - CPDF_Dictionary* m_pPageResources; - CPDF_Dictionary* m_pParentResources; - CPDF_Dictionary* m_pResources; - CPDF_PageObjectHolder* m_pObjectHolder; + CFX_UnownedPtr const m_pDocument; + CFX_UnownedPtr m_pPageResources; + CFX_UnownedPtr m_pParentResources; + CFX_UnownedPtr m_pResources; + CFX_UnownedPtr m_pObjectHolder; int m_Level; CFX_Matrix m_mtContentToUser; CFX_FloatRect m_BBox; @@ -201,7 +203,7 @@ class CPDF_StreamContentParser { std::unique_ptr m_pCurStates; CPDF_ContentMark m_CurContentMark; std::vector> m_ClipTextList; - CPDF_TextObject* m_pLastTextObject; + CFX_UnownedPtr m_pLastTextObject; float m_DefFontSize; std::vector m_PathPoints; float m_PathStartX; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 22eb32b4e9..70371d847b 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -138,11 +138,12 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { CPDF_Page* pPage = nullptr; if (auto* pPageCache = m_pRenderStatus->m_pContext->GetPageCache()) { pPage = pPageCache->GetPage(); - pDocument = pPage->m_pDocument; + pDocument = pPage->m_pDocument.Get(); } else { pDocument = m_pImageObject->GetImage()->GetDocument(); } - CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; + CPDF_Dictionary* pPageResources = + pPage ? pPage->m_pPageResources.Get() : nullptr; CPDF_Object* pCSObj = m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor( "ColorSpace"); diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp index fa23355154..cc1f267f14 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.cpp +++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp @@ -88,10 +88,10 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap( m_pCurImageCacheEntry = it->second; } else { m_pCurImageCacheEntry = - new CPDF_ImageCacheEntry(m_pPage->m_pDocument, pStream); + new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pStream); } int ret = m_pCurImageCacheEntry->StartGetCachedBitmap( - pRenderStatus->m_pFormResource, m_pPage->m_pPageResources, bStdCS, + pRenderStatus->m_pFormResource, m_pPage->m_pPageResources.Get(), bStdCS, GroupFamily, bLoadMask, pRenderStatus); if (ret == 2) return true; @@ -129,7 +129,7 @@ void CPDF_PageRenderCache::ResetBitmap( if (!pBitmap) return; - pEntry = new CPDF_ImageCacheEntry(m_pPage->m_pDocument, pStream); + pEntry = new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pStream); m_ImageCache[pStream] = pEntry; } else { pEntry = it->second; diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp index c8626af9ff..2cd59cac18 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.cpp +++ b/core/fpdfapi/render/cpdf_rendercontext.cpp @@ -20,8 +20,8 @@ #include "core/fxge/fx_dib.h" CPDF_RenderContext::CPDF_RenderContext(CPDF_Page* pPage) - : m_pDocument(pPage->m_pDocument), - m_pPageResources(pPage->m_pPageResources), + : m_pDocument(pPage->m_pDocument.Get()), + m_pPageResources(pPage->m_pPageResources.Get()), m_pPageCache(pPage->GetRenderCache()) {} CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc, diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index d485d1dede..e6b01eff3b 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1487,11 +1487,12 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, CPDF_Page* pPage = nullptr; if (m_pContext->GetPageCache()) { pPage = m_pContext->GetPageCache()->GetPage(); - pDocument = pPage->m_pDocument; + pDocument = pPage->m_pDocument.Get(); } else { pDocument = pPageObj->AsImage()->GetImage()->GetDocument(); } - CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; + CPDF_Dictionary* pPageResources = + pPage ? pPage->m_pPageResources.Get() : nullptr; CPDF_Object* pCSObj = pPageObj->AsImage() ->GetImage() ->GetStream() diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index a3ee70ab36..146c863cf3 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -204,8 +204,8 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { if (it != m_APMap.end()) return it->second.get(); - auto pNewForm = - pdfium::MakeUnique(m_pDocument, pPage->m_pResources, pStream); + auto pNewForm = pdfium::MakeUnique( + m_pDocument, pPage->m_pResources.Get(), pStream); pNewForm->ParseContent(nullptr, nullptr, nullptr); CPDF_Form* pResult = pNewForm.get(); diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index ed1b60c287..1427c85616 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -62,7 +62,7 @@ std::unique_ptr CreatePopupAnnot(CPDF_Annot* pAnnot, } // namespace CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) - : m_pDocument(pPage->m_pDocument) { + : m_pDocument(pPage->m_pDocument.Get()) { if (!pPage->m_pFormDict) return; diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 88787d2e5b..21e2244703 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -1048,7 +1048,7 @@ bool CPDF_InterForm::HasXFAForm() const { } void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { - CPDF_Dictionary* pPageDict = pPage->m_pFormDict; + CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get(); if (!pPageDict) return; diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 2dd8e309cf..982eed1b21 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -206,7 +206,7 @@ CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { #ifdef PDF_ENABLE_XFA return m_page->GetContext()->GetPDFDoc(); #else // PDF_ENABLE_XFA - return m_page->m_pDocument; + return m_page->m_pDocument.Get(); #endif // PDF_ENABLE_XFA } return nullptr; @@ -484,7 +484,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { } int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { - CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; + CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict.Get(); CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; } diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index cab210db42..1e63f5ecc6 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -46,8 +46,7 @@ bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { return true; CPDF_Page* pPage = pWidget->GetPDFPage(); - CPDF_Document* pDocument = pPage->m_pDocument; - uint32_t dwPermissions = pDocument->GetUserPermissions(); + uint32_t dwPermissions = pPage->m_pDocument->GetUserPermissions(); return (dwPermissions & FPDFPERM_FILL_FORM) || (dwPermissions & FPDFPERM_ANNOT_FORM); } diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 30f25d49cc..273317401d 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -28,7 +28,7 @@ CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, m_sAPType("N") { CPDF_Page* pPage = pAnnot->GetPDFPage(); - m_pDocument = pPage->m_pDocument; + m_pDocument = pPage->m_pDocument.Get(); m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict(); Initialize(); } diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index bd08c67b2c..5a35852005 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -461,8 +461,7 @@ bool CFFL_InteractiveFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) { return false; CPDF_Page* pPage = pWidget->GetPDFPage(); - CPDF_Document* pDocument = pPage->m_pDocument; - uint32_t dwPermissions = pDocument->GetUserPermissions(); + uint32_t dwPermissions = pPage->m_pDocument->GetUserPermissions(); return (dwPermissions & FPDFPERM_FILL_FORM) || (dwPermissions & FPDFPERM_ANNOT_FORM) || (dwPermissions & FPDFPERM_MODIFY); diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index 31b838cd94..0477d6fea5 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -246,8 +246,8 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { if (!page) return FLATTEN_FAIL; - CPDF_Document* pDocument = pPage->m_pDocument; - CPDF_Dictionary* pPageDict = pPage->m_pFormDict; + CPDF_Document* pDocument = pPage->m_pDocument.Get(); + CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get(); if (!pDocument || !pPageDict) return FLATTEN_FAIL; diff --git a/fpdfsdk/fpdf_structtree.cpp b/fpdfsdk/fpdf_structtree.cpp index 0c1cc0f6b8..bd6641f7cb 100644 --- a/fpdfsdk/fpdf_structtree.cpp +++ b/fpdfsdk/fpdf_structtree.cpp @@ -41,7 +41,8 @@ DLLEXPORT FPDF_STRUCTTREE STDCALL FPDF_StructTree_GetForPage(FPDF_PAGE page) { CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage) return nullptr; - return CPDF_StructTree::LoadPage(pPage->m_pDocument, pPage->m_pFormDict) + return CPDF_StructTree::LoadPage(pPage->m_pDocument.Get(), + pPage->m_pFormDict.Get()) .release(); } diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index cc5239b802..9cf5a0b729 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -119,7 +119,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, matrix->d, matrix->e, matrix->f); textBuf << bsMatix; - CPDF_Dictionary* pPageDic = pPage->m_pFormDict; + CPDF_Dictionary* pPageDic = pPage->m_pFormDict.Get(); CPDF_Object* pContentObj = pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; if (!pContentObj) @@ -127,7 +127,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, if (!pContentObj) return false; - CPDF_Document* pDoc = pPage->m_pDocument; + CPDF_Document* pDoc = pPage->m_pDocument.Get(); if (!pDoc) return false; @@ -276,7 +276,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, if (!pPage) return; - CPDF_Dictionary* pPageDic = pPage->m_pFormDict; + CPDF_Dictionary* pPageDic = pPage->m_pFormDict.Get(); CPDF_Object* pContentObj = pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; if (!pContentObj) @@ -301,7 +301,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, strClip << "W* n\n"; } } - CPDF_Document* pDoc = pPage->m_pDocument; + CPDF_Document* pDoc = pPage->m_pDocument.Get(); if (!pDoc) return; diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp index 70a27a5011..1c445e6f14 100644 --- a/fpdfsdk/fpdfdoc.cpp +++ b/fpdfsdk/fpdfdoc.cpp @@ -53,7 +53,7 @@ CPDF_LinkList* GetLinkList(CPDF_Page* page) { if (!page) return nullptr; - CPDF_Document* pDoc = page->m_pDocument; + CPDF_Document* pDoc = page->m_pDocument.Get(); std::unique_ptr* pHolder = pDoc->LinksContext(); if (!pHolder->get()) *pHolder = pdfium::MakeUnique(); diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp index 431adcaa95..95ae66685d 100644 --- a/fpdfsdk/fpdfeditpage.cpp +++ b/fpdfsdk/fpdfeditpage.cpp @@ -300,7 +300,6 @@ DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { if (!IsPageObject(pPage)) return; - CPDF_Dictionary* pDict = pPage->m_pFormDict; rotate %= 4; - pDict->SetNewFor("Rotate", rotate * 90); + pPage->m_pFormDict->SetNewFor("Rotate", rotate * 90); } diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 121e1a9c8e..fb12967bde 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -141,7 +141,7 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); #else // PDF_ENABLE_XFA options.m_pOCContext = pdfium::MakeRetain( - pPage->m_pDocument, CPDF_OCContext::View); + pPage->m_pDocument.Get(), CPDF_OCContext::View); if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); #endif // PDF_ENABLE_XFA @@ -162,7 +162,7 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, return -1; CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (pPage) { - CPDF_InterForm interform(pPage->m_pDocument); + CPDF_InterForm interform(pPage->m_pDocument.Get()); CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( pPage, CFX_PointF(static_cast(page_x), static_cast(page_y)), @@ -232,7 +232,7 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage) return -1; - CPDF_InterForm interform(pPage->m_pDocument); + CPDF_InterForm interform(pPage->m_pDocument.Get()); int z_order = -1; (void)interform.GetControlAtPoint( pPage, CFX_PointF(static_cast(page_x), static_cast(page_y)), @@ -741,7 +741,7 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, return; CPDFSDK_ActionHandler* pActionHandler = pFormFillEnv->GetActionHander(); - CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict; + CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict.Get(); CPDF_AAction aa(pPageDict->GetDictFor("AA")); if (FPDFPAGE_AACTION_OPEN == aaType) { if (aa.ActionExist(CPDF_AAction::OpenPage)) { diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp index 5abd232b53..916233c56e 100644 --- a/fpdfsdk/fpdftext.cpp +++ b/fpdfsdk/fpdftext.cpp @@ -53,7 +53,7 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) { CPDFXFA_Context* pContext = pPage->GetContext(); CPDF_ViewerPreferences viewRef(pContext->GetPDFDoc()); #else // PDF_ENABLE_XFA - CPDF_ViewerPreferences viewRef(pPDFPage->m_pDocument); + CPDF_ViewerPreferences viewRef(pPDFPage->m_pDocument.Get()); #endif // PDF_ENABLE_XFA CPDF_TextPage* textpage = new CPDF_TextPage( diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 76913cee4f..f20e8ab9f4 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -98,11 +98,10 @@ void RenderPageImpl(CPDF_PageRenderContext* pContext, (flags & FPDF_PRINTING) ? CPDF_OCContext::Print : CPDF_OCContext::View; pContext->m_pOptions->m_AddFlags = flags >> 8; pContext->m_pOptions->m_pOCContext = - pdfium::MakeRetain(pPage->m_pDocument, usage); + pdfium::MakeRetain(pPage->m_pDocument.Get(), usage); pContext->m_pDevice->SaveState(); pContext->m_pDevice->SetClip_Rect(clipping_rect); - pContext->m_pContext = pdfium::MakeUnique(pPage); pContext->m_pContext->AppendLayer(pPage, &matrix); -- cgit v1.2.3