From aaed698534284ca45a986ae7344246cffbc6faa9 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 22 Mar 2018 18:39:05 +0000 Subject: Consolidate QuadPoints reading code in fpdfsdk. Also fix nits in QuadPoints code in cpdf_annot.cpp. Change-Id: I7852b673d3dca906e6d250cb3cfa305f8ea7e742 Reviewed-on: https://pdfium-review.googlesource.com/28893 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fpdfdoc/cpdf_annot.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'core/fpdfdoc/cpdf_annot.cpp') diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 91cdb12d9f..42bda6e319 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -205,9 +205,12 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { return pResult; } -// Static. +// static CFX_FloatRect CPDF_Annot::RectFromQuadPointsArray(const CPDF_Array* pArray, size_t nIndex) { + ASSERT(pArray); + ASSERT(nIndex < pArray->GetCount() / 8); + // QuadPoints are defined with 4 pairs of numbers // ([ pair0, pair1, pair2, pair3 ]), where // pair0 = top_left @@ -224,7 +227,7 @@ CFX_FloatRect CPDF_Annot::RectFromQuadPointsArray(const CPDF_Array* pArray, pArray->GetNumberAt(2 + nIndex * 8), pArray->GetNumberAt(3 + nIndex * 8)); } -// Static. +// static CFX_FloatRect CPDF_Annot::BoundingRectFromQuadPoints( CPDF_Dictionary* pAnnotDict) { CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); @@ -240,23 +243,21 @@ CFX_FloatRect CPDF_Annot::BoundingRectFromQuadPoints( return ret; } -// Static. +// static CFX_FloatRect CPDF_Annot::RectFromQuadPoints(CPDF_Dictionary* pAnnotDict, size_t nIndex) { CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); - if (!pArray) return CFX_FloatRect(); - return RectFromQuadPointsArray(pArray, nIndex); } -// Static. +// static bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) { return !!(pAnnotDict->GetIntegerFor("F") & ANNOTFLAG_HIDDEN); } -// Static. +// static CPDF_Annot::Subtype CPDF_Annot::StringToAnnotSubtype( const ByteString& sSubtype) { if (sSubtype == "Text") @@ -316,7 +317,7 @@ CPDF_Annot::Subtype CPDF_Annot::StringToAnnotSubtype( return CPDF_Annot::Subtype::UNKNOWN; } -// Static. +// static ByteString CPDF_Annot::AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype) { if (nSubtype == CPDF_Annot::Subtype::TEXT) return "Text"; @@ -375,7 +376,7 @@ ByteString CPDF_Annot::AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype) { return ""; } -// Static. +// static size_t CPDF_Annot::QuadPointCount(const CPDF_Array* pArray) { return pArray->GetCount() / 8; } -- cgit v1.2.3