diff options
Diffstat (limited to 'external/pdfium/AnnotationLineStartAndEnd.patch.1')
-rw-r--r-- | external/pdfium/AnnotationLineStartAndEnd.patch.1 | 107 |
1 files changed, 81 insertions, 26 deletions
diff --git a/external/pdfium/AnnotationLineStartAndEnd.patch.1 b/external/pdfium/AnnotationLineStartAndEnd.patch.1 index 00ebb6d20ed1..0a40905abada 100644 --- a/external/pdfium/AnnotationLineStartAndEnd.patch.1 +++ b/external/pdfium/AnnotationLineStartAndEnd.patch.1 @@ -1,48 +1,103 @@ +From 30f45a6f043fc1bbd19eb4820261c45ad68cf1cc Mon Sep 17 00:00:00 2001 +From: Miklos Vajna <vmiklos@collabora.co.uk> +Date: Fri, 4 Dec 2020 19:12:31 +0000 +Subject: [PATCH] Add FPDFAnnot_GetLine() API + +This is similar to FPDFAnnot_GetVertices() for polygon/polyline +annotations, but this one is for line annotations and the point list has +a fixed size of 2. + +Change-Id: If910caaef8c41a9965f2ba47f87c34ea33355f99 +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/76730 +Commit-Queue: Tom Sepez <tsepez@chromium.org> +Reviewed-by: Tom Sepez <tsepez@chromium.org> +--- + constants/annotation_common.h | 3 ++ + fpdfsdk/fpdf_annot.cpp | 26 +++++++++++++ + fpdfsdk/fpdf_annot_embeddertest.cpp | 45 ++++++++++++++++++++++ + fpdfsdk/fpdf_view_c_api_test.c | 1 + + public/fpdf_annot.h | 13 +++++++ + testing/resources/line_annot.in | 48 +++++++++++++++++++++++ + testing/resources/line_annot.pdf | 60 +++++++++++++++++++++++++++++ + 7 files changed, 196 insertions(+) + create mode 100644 testing/resources/line_annot.in + create mode 100644 testing/resources/line_annot.pdf + +diff --git a/constants/annotation_common.h b/constants/annotation_common.h +index be6420651..656842bb5 100644 +--- a/constants/annotation_common.h ++++ b/constants/annotation_common.h +@@ -32,6 +32,9 @@ constexpr char kVertices[] = "Vertices"; + // Entries for ink annotations + constexpr char kInkList[] = "InkList"; + ++// Entries for line annotations ++constexpr char kL[] = "L"; ++ + } // namespace annotation + } // namespace pdfium + diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp -index 229651d82..b43f378bc 100644 +index 51b4332c2..85f86e547 100644 --- a/fpdfsdk/fpdf_annot.cpp +++ b/fpdfsdk/fpdf_annot.cpp -@@ -552,6 +552,25 @@ FPDFAnnot_GetInkStrokePoints(FPDF_ANNOTATION annot, int index, - return true; +@@ -887,6 +887,32 @@ FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot, + return points_len; } - + +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot, + FS_POINTF* start, + FS_POINTF* end) { -+ CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot); -+ if (!pAnnotDict || !start || !end) ++ if (!start || !end) ++ return false; ++ ++ FPDF_ANNOTATION_SUBTYPE subtype = FPDFAnnot_GetSubtype(annot); ++ if (subtype != FPDF_ANNOT_LINE) ++ return false; ++ ++ CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot); ++ if (!annot_dict) + return false; + -+ CPDF_Array* pLineArray = pAnnotDict->GetArrayFor("L"); -+ if (!pLineArray || pLineArray->size() < 4) ++ CPDF_Array* line = annot_dict->GetArrayFor(pdfium::annotation::kL); ++ if (!line || line->size() < 4) + return false; + -+ start->x = pLineArray->GetNumberAt(0); -+ start->y = pLineArray->GetNumberAt(1); -+ end->x = pLineArray->GetNumberAt(2); -+ end->y = pLineArray->GetNumberAt(3); ++ start->x = line->GetNumberAt(0); ++ start->y = line->GetNumberAt(1); ++ end->x = line->GetNumberAt(2); ++ end->y = line->GetNumberAt(3); + + return true; +} + - FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV - FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) { - CPDF_AnnotContext* pAnnot = CPDFAnnotContextFromFPDFAnnotation(annot); + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, + FPDF_BYTESTRING key) { + CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot); diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h -index ce033cde3..c4b0f71b3 100644 +index d121344f7..6c8a237e7 100644 --- a/public/fpdf_annot.h +++ b/public/fpdf_annot.h -@@ -232,6 +232,10 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV - FPDFAnnot_GetInkStrokePoints(FPDF_ANNOTATION annot, int index, - FS_POINTF* points); - -+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV -+FPDFAnnot_GetLine(FPDF_ANNOTATION annot, FS_POINTF* start, -+ FS_POINTF* end); +@@ -439,6 +439,19 @@ FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot, + FS_POINTF* buffer, + unsigned long length); + ++// Experimental API. ++// Get the starting and ending coordinates of a line annotation. ++// ++// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot() ++// start - starting point ++// end - ending point ++// ++// Returns true if the annotation is of type line, |start| and |end| are not ++// NULL, false otherwise. ++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot, ++ FS_POINTF* start, ++ FS_POINTF* end); + // Experimental API. - // Add |obj| to |annot|. |obj| must have been created by - // FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and --- + // Check if |annot|'s dictionary has |key| as a key. + // +-- 2.26.2 |