diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-03 17:19:53 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-03 17:19:53 +0000 |
commit | 525147a1f6d6cd736a407d1e189ac25d2f4726e8 (patch) | |
tree | bdc818c52d902a5a4e8ce8a4f0ba29bd11007b05 /fpdfsdk/fpdf_editpage.cpp | |
parent | ccd9421589922b8f35ee5330d7fdac7edea081db (diff) | |
download | pdfium-525147a1f6d6cd736a407d1e189ac25d2f4726e8.tar.xz |
Use strict types in FPDF API, try #3
Rather than messing with actual inheritence, add type-checking wrappers
and just blatantly cast to incomplete types. Along the way, this points
out places where we would downcast without checking, which I fix.
Change-Id: Ieb303eb46ad8522dfe082454f1f10f247ffd52d5
Reviewed-on: https://pdfium-review.googlesource.com/32030
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_editpage.cpp')
-rw-r--r-- | fpdfsdk/fpdf_editpage.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 944dbdc576..0647dc537f 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -54,11 +54,6 @@ static_assert(FPDF_PAGEOBJ_SHADING == CPDF_PageObject::SHADING, static_assert(FPDF_PAGEOBJ_FORM == CPDF_PageObject::FORM, "FPDF_PAGEOBJ_FORM/CPDF_PageObject::FORM mismatch"); -const CPDF_ContentMarkItem* CPDFContentMarkItemFromFPDFPageObjectMark( - FPDF_PAGEOBJECTMARK mark) { - return static_cast<const CPDF_ContentMarkItem*>(mark); -} - bool IsPageObject(CPDF_Page* pPage) { if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")) return false; @@ -251,7 +246,7 @@ FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page, if (!IsPageObject(pPage)) return nullptr; - return pPage->GetPageObjectByIndex(index); + return FPDFPageObjectFromCPDFPageObject(pPage->GetPageObjectByIndex(index)); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page) { @@ -278,15 +273,14 @@ FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, unsigned long index) { if (!page_object) return nullptr; - const auto& mark = - CPDFPageObjectFromFPDFPageObject(page_object)->m_ContentMark; - if (!mark.HasRef()) + auto* mark = &CPDFPageObjectFromFPDFPageObject(page_object)->m_ContentMark; + if (!mark->HasRef()) return nullptr; - if (index >= mark.CountItems()) + if (index >= mark->CountItems()) return nullptr; - return static_cast<FPDF_PAGEOBJECTMARK>(&mark.GetItem(index)); + return FPDFPageObjectMarkFromCPDFContentMarkItem(&mark->GetItem(index)); } FPDF_EXPORT unsigned long FPDF_CALLCONV |