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 --- 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 +-- 12 files changed, 21 insertions(+), 24 deletions(-) (limited to 'fpdfsdk') 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