diff options
author | Jane Liu <janeliulwq@google.com> | 2017-08-16 13:24:58 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-16 17:47:33 +0000 |
commit | b370e5a8f8df8cd6827ddb99b958d6a00642035e (patch) | |
tree | aa22efaece1304a928e9d0f6765334f9cf4ff3cb /fpdfsdk/fpdfannot.cpp | |
parent | 816d7e4a0dccc049a1defe8a17e1b05c211665e1 (diff) | |
download | pdfium-b370e5a8f8df8cd6827ddb99b958d6a00642035e.tar.xz |
Fixed the return values of FPDFAnnot_Get{Rect|AttachmentPoints}
Currently, FPDFAnnot_Get{Rect|AttachmentPoints} would return BBox if the
annotation's appearance stream is defined, which does not make much
sense to the user since BBox is defined in the form space; upon
rendering, the annotation's position in the device space is solely
defined by its rectangle.
This CL removes references to BBox in FPDFAnnot_Get{Rect|
AttachmentPoints}; instead, they will only return rectangle or
quadpoints as requested. The embedder test is also modified to reflect
this change, and also to demonstrate that an annotation's position is
changed only if its rectangle is changed.
Bug=pdfium:861
Change-Id: I489876511aa5d93131dd695170d46bbc49d16574
Reviewed-on: https://pdfium-review.googlesource.com/11050
Commit-Queue: Jane Liu <janeliulwq@google.com>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfannot.cpp')
-rw-r--r-- | fpdfsdk/fpdfannot.cpp | 66 |
1 files changed, 13 insertions, 53 deletions
diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index fee99c844b..5c4aae2075 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -601,45 +601,18 @@ FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, if (!pAnnotDict) 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 - // "BBox" entry comes from annotation dictionary's "QuadPoints" entry, but - // takes priority over "QuadPoints" when rendering. Otherwise, retrieve - // the "Quadpoints" entry from the annotation dictionary. - CPDF_Array* pArray; - CPDF_Stream* pStream = - FPDFDOC_GetAnnotAP(pAnnotDict, CPDF_Annot::AppearanceMode::Normal); - if (pStream) { - pArray = pStream->GetDict()->GetArrayFor("BBox"); - if (!pArray) - 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); - } else { - pArray = pAnnotDict->GetArrayFor("QuadPoints"); - if (!pArray) - 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); - } + CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); + if (!pArray) + 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 true; } @@ -683,20 +656,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, if (!pAnnotDict) 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 - // by the "BBox" entry in the AP dictionary, since its "BBox" entry comes - // from annotation dictionary's "Rect" entry, but takes priority over "Rect" - // when rendering. Otherwise, retrieve the "Rect" entry from the annotation - // dictionary. - CFX_FloatRect rt; - CPDF_Stream* pStream = - FPDFDOC_GetAnnotAP(pAnnotDict, CPDF_Annot::AppearanceMode::Normal); - if (!pStream || FPDFAnnot_HasAttachmentPoints(annot)) - rt = pAnnotDict->GetRectFor("Rect"); - else - rt = pStream->GetDict()->GetRectFor("BBox"); - + CFX_FloatRect rt = pAnnotDict->GetRectFor("Rect"); rect->left = rt.left; rect->bottom = rt.bottom; rect->right = rt.right; |