From 1638179e85863b5045fcea2282fd3e0622aeac13 Mon Sep 17 00:00:00 2001 From: Ralf Sippl Date: Thu, 12 Apr 2018 21:20:26 +0000 Subject: 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 Reviewed-by: Lei Zhang Reviewed-by: Henrique Nakashima --- samples/pdfium_test_write_helper.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'samples') diff --git a/samples/pdfium_test_write_helper.cc b/samples/pdfium_test_write_helper.cc index 5a2e0f66ce..d061252e07 100644 --- a/samples/pdfium_test_write_helper.cc +++ b/samples/pdfium_test_write_helper.cc @@ -315,15 +315,22 @@ void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) { // Retrieve the annotation's quadpoints if it is a markup annotation. if (FPDFAnnot_HasAttachmentPoints(annot.get())) { - FS_QUADPOINTSF quadpoints; - if (FPDFAnnot_GetAttachmentPoints(annot.get(), &quadpoints)) { - fprintf(fp, - "Quadpoints: (%.3f, %.3f), (%.3f, %.3f), (%.3f, %.3f), (%.3f, " - "%.3f)\n", - quadpoints.x1, quadpoints.y1, quadpoints.x2, quadpoints.y2, - quadpoints.x3, quadpoints.y3, quadpoints.x4, quadpoints.y4); - } else { - fprintf(fp, "Failed to retrieve quadpoints.\n"); + size_t qp_count = FPDFAnnot_CountAttachmentPoints(annot.get()); + fprintf(fp, "Number of quadpoints sets: %zu\n", qp_count); + + // Iterate through all quadpoints of the current annotation + for (size_t j = 0; j < qp_count; ++j) { + FS_QUADPOINTSF quadpoints; + if (FPDFAnnot_GetAttachmentPoints(annot.get(), j, &quadpoints)) { + fprintf(fp, + "Quadpoints set #%zu: (%.3f, %.3f), (%.3f, %.3f), " + "(%.3f, %.3f), (%.3f, %.3f)\n", + j + 1, quadpoints.x1, quadpoints.y1, quadpoints.x2, + quadpoints.y2, quadpoints.x3, quadpoints.y3, quadpoints.x4, + quadpoints.y4); + } else { + fprintf(fp, "Failed to retrieve quadpoints set #%zu.\n", j + 1); + } } } -- cgit v1.2.3