diff options
author | Jane Liu <janeliulwq@google.com> | 2017-08-15 10:50:22 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-16 17:15:02 +0000 |
commit | 0c6b07d3fdbbabda8753e6457f4323237fc5be30 (patch) | |
tree | 8b1b62186095a8a2191c60e234dfd8a63b8d30db /fpdfsdk/fpdfannot.cpp | |
parent | ca89829775fec2968b51fe5abad86bad1b6a277b (diff) | |
download | pdfium-0c6b07d3fdbbabda8753e6457f4323237fc5be30.tar.xz |
Changed the return type of FPDFAnnot_Get{Rect|AttachmentPoints}()
Instead of returning structs, changed FPDFAnnot_GetRect() and
FPDFAnnot_GetAttachmentPoints() to return a bool and take a struct
as an out parameter.
Change-Id: I380e76eb1566b2488150fb31e9dad564a3ee10d4
Reviewed-on: https://pdfium-review.googlesource.com/10470
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Jane Liu <janeliulwq@google.com>
Diffstat (limited to 'fpdfsdk/fpdfannot.cpp')
-rw-r--r-- | fpdfsdk/fpdfannot.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index 9213877b0b..fee99c844b 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -590,15 +590,16 @@ FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, return true; } -FPDF_EXPORT FS_QUADPOINTSF FPDF_CALLCONV -FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot) { - if (!annot || !FPDFAnnot_HasAttachmentPoints(annot)) - return FS_QUADPOINTSF(); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, + FS_QUADPOINTSF* quadPoints) { + if (!annot || !FPDFAnnot_HasAttachmentPoints(annot) || !quadPoints) + return false; CPDF_Dictionary* pAnnotDict = CPDFAnnotContextFromFPDFAnnotation(annot)->GetAnnotDict(); if (!pAnnotDict) - return FS_QUADPOINTSF(); + return false; // If the annotation's appearance stream is defined, then retrieve the // quadpoints defined by the "BBox" entry in the AP dictionary, since its @@ -606,41 +607,40 @@ FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot) { // takes priority over "QuadPoints" when rendering. Otherwise, retrieve // the "Quadpoints" entry from the annotation dictionary. CPDF_Array* pArray; - FS_QUADPOINTSF quadPoints; CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(pAnnotDict, CPDF_Annot::AppearanceMode::Normal); if (pStream) { pArray = pStream->GetDict()->GetArrayFor("BBox"); if (!pArray) - return FS_QUADPOINTSF(); + return false; // Convert the BBox array into quadpoint coordinates. BBox array follows the // order of a rectangle array: (left, bottom, right, up); and quadpoints // follows the following order: (top-left vertex, top-right vertex, bottom- // left vertex, bottom-right vertex). - quadPoints.x1 = pArray->GetNumberAt(0); - quadPoints.y1 = pArray->GetNumberAt(3); - quadPoints.x2 = pArray->GetNumberAt(2); - quadPoints.y2 = pArray->GetNumberAt(3); - quadPoints.x3 = pArray->GetNumberAt(0); - quadPoints.y3 = pArray->GetNumberAt(1); - quadPoints.x4 = pArray->GetNumberAt(2); - quadPoints.y4 = pArray->GetNumberAt(1); + quadPoints->x1 = pArray->GetNumberAt(0); + quadPoints->y1 = pArray->GetNumberAt(3); + quadPoints->x2 = pArray->GetNumberAt(2); + quadPoints->y2 = pArray->GetNumberAt(3); + quadPoints->x3 = pArray->GetNumberAt(0); + quadPoints->y3 = pArray->GetNumberAt(1); + quadPoints->x4 = pArray->GetNumberAt(2); + quadPoints->y4 = pArray->GetNumberAt(1); } else { pArray = pAnnotDict->GetArrayFor("QuadPoints"); if (!pArray) - return FS_QUADPOINTSF(); - - quadPoints.x1 = pArray->GetNumberAt(0); - quadPoints.y1 = pArray->GetNumberAt(1); - quadPoints.x2 = pArray->GetNumberAt(2); - quadPoints.y2 = pArray->GetNumberAt(3); - quadPoints.x3 = pArray->GetNumberAt(4); - quadPoints.y3 = pArray->GetNumberAt(5); - quadPoints.x4 = pArray->GetNumberAt(6); - quadPoints.y4 = pArray->GetNumberAt(7); + return false; + + quadPoints->x1 = pArray->GetNumberAt(0); + quadPoints->y1 = pArray->GetNumberAt(1); + quadPoints->x2 = pArray->GetNumberAt(2); + quadPoints->y2 = pArray->GetNumberAt(3); + quadPoints->x3 = pArray->GetNumberAt(4); + quadPoints->y3 = pArray->GetNumberAt(5); + quadPoints->x4 = pArray->GetNumberAt(6); + quadPoints->y4 = pArray->GetNumberAt(7); } - return quadPoints; + return true; } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot, @@ -673,14 +673,15 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot, return true; } -FPDF_EXPORT FS_RECTF FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot) { - if (!annot) - return FS_RECTF(); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, + FS_RECTF* rect) { + if (!annot || !rect) + return false; CPDF_Dictionary* pAnnotDict = CPDFAnnotContextFromFPDFAnnotation(annot)->GetAnnotDict(); if (!pAnnotDict) - return FS_RECTF(); + return false; // If the annotation's appearance stream is defined and the annotation is of // a type that does not have quadpoints, then retrieve the rectangle defined @@ -696,12 +697,11 @@ FPDF_EXPORT FS_RECTF FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot) { else rt = pStream->GetDict()->GetRectFor("BBox"); - FS_RECTF rect; - rect.left = rt.left; - rect.bottom = rt.bottom; - rect.right = rt.right; - rect.top = rt.top; - return rect; + rect->left = rt.left; + rect->bottom = rt.bottom; + rect->right = rt.right; + rect->top = rt.top; + return true; } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, |