summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_helpers.cpp
diff options
context:
space:
mode:
authorRalf Sippl <ralf.sippl@gmail.com>2018-04-12 21:20:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-12 21:20:26 +0000
commit1638179e85863b5045fcea2282fd3e0622aeac13 (patch)
treee21cc4c409ed04ccb4496f17c4edcc0d8f586cdc /fpdfsdk/cpdfsdk_helpers.cpp
parentc9f4f0dbcaaf9e86ef2b64c844b094bd2f6b1a92 (diff)
downloadpdfium-1638179e85863b5045fcea2282fd3e0622aeac13.tar.xz
Add index parameter to quadpoints getter and setter.
This is needed for working with multiline text markup annotations. Based on https://pdfium-review.googlesource.com/12012. Bug: pdfium:1045 Change-Id: Ifb105996b8b950bb2d5fceaf754b4f571155aef4 Reviewed-on: https://pdfium-review.googlesource.com/29150 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_helpers.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_helpers.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp
index 45c2674a4d..19252f7c5b 100644
--- a/fpdfsdk/cpdfsdk_helpers.cpp
+++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -19,6 +19,8 @@
namespace {
+constexpr char kQuadPoints[] = "QuadPoints";
+
FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) {
return static_cast<FPDF_DOCUMENT>(doc);
}
@@ -429,10 +431,41 @@ CFX_FloatRect CFXFloatRectFromFSRECTF(const FS_RECTF& rect) {
return CFX_FloatRect(rect.left, rect.bottom, rect.right, rect.top);
}
-const CPDF_Array* GetQuadPointsArrayFromDictionary(CPDF_Dictionary* dict) {
+CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict) {
return dict ? dict->GetArrayFor("QuadPoints") : nullptr;
}
+CPDF_Array* AddQuadPointsArrayToDictionary(CPDF_Dictionary* dict) {
+ if (!dict)
+ return nullptr;
+ return dict->SetNewFor<CPDF_Array>(kQuadPoints);
+}
+
+bool IsValidQuadPointsIndex(const CPDF_Array* array, size_t index) {
+ return array && index < array->GetCount() / 8;
+}
+
+bool GetQuadPointsAtIndex(const CPDF_Array* array,
+ size_t quad_index,
+ FS_QUADPOINTSF* quad_points) {
+ ASSERT(quad_points);
+ ASSERT(array);
+
+ if (!IsValidQuadPointsIndex(array, quad_index))
+ return false;
+
+ quad_index *= 8;
+ quad_points->x1 = array->GetNumberAt(quad_index);
+ quad_points->y1 = array->GetNumberAt(quad_index + 1);
+ quad_points->x2 = array->GetNumberAt(quad_index + 2);
+ quad_points->y2 = array->GetNumberAt(quad_index + 3);
+ quad_points->x3 = array->GetNumberAt(quad_index + 4);
+ quad_points->y3 = array->GetNumberAt(quad_index + 5);
+ quad_points->x4 = array->GetNumberAt(quad_index + 6);
+ quad_points->y4 = array->GetNumberAt(quad_index + 7);
+ return true;
+}
+
bool GetQuadPointsFromDictionary(CPDF_Dictionary* dict,
size_t quad_index,
FS_QUADPOINTSF* quad_points) {