[Libreoffice-commits] core.git: external/pdfium vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 22 10:27:43 UTC 2020


 external/pdfium/AnnotationBorderProperties.patch.1 |  107 ++++--
 external/pdfium/AnnotationInkAndVertices.patch.1   |  327 +++++++++++++--------
 external/pdfium/AnnotationLineStartAndEnd.patch.1  |  107 +++++-
 external/pdfium/UnpackedTarball_pdfium.mk          |    6 
 vcl/source/pdf/PDFiumLibrary.cxx                   |   10 
 5 files changed, 375 insertions(+), 182 deletions(-)

New commits:
commit 4b9bf3d999b637ff35515a7b38aeb05e95ee882a
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Dec 22 09:12:48 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Dec 22 11:26:54 2020 +0100

    pdfium: replace 3 patches with backports
    
    So that vcl/ already uses the upstreamed API and the patches can be just
    dropped on the next pdfium upgrade.
    
    Change-Id: I58f6a4cca37677788d9a2e4e31c2e89d074ad5ae
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108140
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/external/pdfium/AnnotationBorderProperties.patch.1 b/external/pdfium/AnnotationBorderProperties.patch.1
index 87f8f48beed9..0dc42e1f95f5 100644
--- a/external/pdfium/AnnotationBorderProperties.patch.1
+++ b/external/pdfium/AnnotationBorderProperties.patch.1
@@ -1,60 +1,89 @@
+From 305d2ed186c9e1e7c3d0f914235e926e27b35a9f Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Tue, 15 Dec 2020 17:28:49 +0000
+Subject: [PATCH] Add FPDFAnnot_GetBorder() API
+
+This is similar to FPDFAnnot_GetLine(), but a /Border key is valid for
+all annotation types.
+
+The array can have an optional 4th element, but that itself doesn't have
+a fixed size, so it's not exposed by this API -- could be done by a
+separate function.
+
+Change-Id: I796c2ea17be1f039a6c6129dbde0b0a22276e19a
+Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/77010
+Commit-Queue: Tom Sepez <tsepez at chromium.org>
+Reviewed-by: Tom Sepez <tsepez at chromium.org>
+---
+ fpdfsdk/fpdf_annot.cpp              | 23 +++++++++++++++++
+ fpdfsdk/fpdf_annot_embeddertest.cpp | 40 +++++++++++++++++++++++++++++
+ fpdfsdk/fpdf_view_c_api_test.c      |  1 +
+ public/fpdf_annot.h                 | 16 ++++++++++++
+ testing/resources/line_annot.in     |  2 ++
+ testing/resources/line_annot.pdf    |  6 +++--
+ 6 files changed, 86 insertions(+), 2 deletions(-)
+
 diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
-index c1471220b..229651d82 100644
+index 85f86e547..eee3567d4 100644
 --- a/fpdfsdk/fpdf_annot.cpp
 +++ b/fpdfsdk/fpdf_annot.cpp
-@@ -756,6 +756,35 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot,
+@@ -913,6 +913,29 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot,
    return true;
  }
-
-+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetBorder(FPDF_ANNOTATION annot,
-+                                                        float* hor_radius,
-+                                                        float* vert_radius,
-+                                                        float* width) {
-+  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
-+  if (!pAnnotDict || !hor_radius || !vert_radius || !width)
+ 
++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
++FPDFAnnot_GetBorder(FPDF_ANNOTATION annot,
++                    float* horizontal_radius,
++                    float* vertical_radius,
++                    float* border_width) {
++  if (!horizontal_radius || !vertical_radius || !border_width)
 +    return false;
 +
-+  // If BA entry exists, then Border is ignored
-+  if (pAnnotDict->KeyExist("BA"))
++  CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
++  if (!annot_dict)
 +    return false;
 +
-+  CPDF_Array* pBorderArray = pAnnotDict->GetArrayFor("Border");
-+  if (!pBorderArray) {
-+    *hor_radius = 0.0f;
-+    *vert_radius = 0.0f;
-+    *width = 1.0f;
-+    return true;
-+  }
-+  if (pBorderArray->size() < 3)
++  CPDF_Array* border = annot_dict->GetArrayFor(pdfium::annotation::kBorder);
++  if (!border || border->size() < 3)
 +    return false;
 +
-+  *hor_radius = pBorderArray->GetNumberAt(0);
-+  *vert_radius = pBorderArray->GetNumberAt(1);
-+  *width = pBorderArray->GetNumberAt(2);
++  *horizontal_radius = border->GetNumberAt(0);
++  *vertical_radius = border->GetNumberAt(1);
++  *border_width = border->GetNumberAt(2);
 +
 +  return true;
 +}
 +
- FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
- FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot) {
-   if (!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 2176450c8..ce033cde3 100644
+index 6c8a237e7..2b708af13 100644
 --- a/public/fpdf_annot.h
 +++ b/public/fpdf_annot.h
-@@ -313,6 +313,12 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot,
-                                                        unsigned int* A);
-
- // Experimental API.
-+// TODO
-+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetBorder(FPDF_ANNOTATION annot,
-+                                                        float* hor_radius,
-+                                                        float* vert_radius,
-+                                                        float* width);
+@@ -452,6 +452,22 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot,
+                                                       FS_POINTF* start,
+                                                       FS_POINTF* end);
+ 
 +// Experimental API.
- // Check if the annotation is of a type that has attachment points
- // (i.e. quadpoints). Quadpoints are the vertices of the rectangle that
- // encompasses the texts affected by the annotation. They provide the
---
++// Get the characteristics of the annotation's border (rounded rectangle).
++//
++//   annot  - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
++//   horizontal_radius - horizontal corner radius, in default user space units
++//   vertical_radius - vertical corner radius, in default user space units
++//   border_width - border width, in default user space units
++//
++// Returns true if |horizontal_radius|, |vertical_radius| and |border_width| are
++// not NULL, false otherwise.
++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
++FPDFAnnot_GetBorder(FPDF_ANNOTATION annot,
++                    float* horizontal_radius,
++                    float* vertical_radius,
++                    float* border_width);
++
+ // Experimental API.
+ // Check if |annot|'s dictionary has |key| as a key.
+ //
+-- 
 2.26.2
 
diff --git a/external/pdfium/AnnotationInkAndVertices.patch.1 b/external/pdfium/AnnotationInkAndVertices.patch.1
index a7fa04ddef05..d7cce4f27df2 100644
--- a/external/pdfium/AnnotationInkAndVertices.patch.1
+++ b/external/pdfium/AnnotationInkAndVertices.patch.1
@@ -1,155 +1,260 @@
+From 09ecef60e8292457d9e78a2242f5efec953c2c25 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Tue, 10 Nov 2020 21:50:38 +0000
+Subject: [PATCH] Add FPDFAnnot_GetVertices() API
+
+This follows the same pattern as FPDF_GetTrailerEnds(), so the client
+has to call this function twice, but allocation of the buffer happens
+outside pdfium.
+
+Change-Id: Ic733083eba0b110310d6bbdc48f874bac4c7f2d6
+Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/76050
+Commit-Queue: Miklos V <vmiklos at collabora.co.uk>
+Commit-Queue: Tom Sepez <tsepez at chromium.org>
+Reviewed-by: Tom Sepez <tsepez at chromium.org>
+---
+ constants/annotation_common.h       |  3 ++
+ fpdfsdk/fpdf_annot.cpp              | 28 ++++++++++++
+ fpdfsdk/fpdf_annot_embeddertest.cpp | 67 +++++++++++++++++++++++++++++
+ fpdfsdk/fpdf_view_c_api_test.c      |  1 +
+ public/fpdf_annot.h                 | 16 +++++++
+ testing/resources/polygon_annot.in  | 48 +++++++++++++++++++++
+ testing/resources/polygon_annot.pdf | 60 ++++++++++++++++++++++++++
+ 7 files changed, 223 insertions(+)
+ create mode 100644 testing/resources/polygon_annot.in
+ create mode 100644 testing/resources/polygon_annot.pdf
+
+diff --git a/constants/annotation_common.h b/constants/annotation_common.h
+index 471d24407..6f96e623a 100644
+--- a/constants/annotation_common.h
++++ b/constants/annotation_common.h
+@@ -26,6 +26,9 @@ constexpr char kC[] = "C";
+ constexpr char kStructParent[] = "StructParent";
+ constexpr char kOC[] = "OC";
+ 
++// Entries for polygon and polyline annotations.
++constexpr char kVertices[] = "Vertices";
++
+ }  // namespace annotation
+ }  // namespace pdfium
+ 
 diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
-index 98b3e4f0a..c1471220b 100644
+index 28dbe145d..13c73f6aa 100644
 --- a/fpdfsdk/fpdf_annot.cpp
 +++ b/fpdfsdk/fpdf_annot.cpp
-@@ -493,6 +493,65 @@ FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot) {
+@@ -809,6 +809,34 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
    return true;
  }
-
-+FPDF_EXPORT int FPDF_CALLCONV
-+FPDFAnnot_GetInkStrokeCount(FPDF_ANNOTATION annot)
-+{
-+  if (FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_INK)
-+    return -1;
+ 
++FPDF_EXPORT unsigned long FPDF_CALLCONV
++FPDFAnnot_GetVertices(FPDF_ANNOTATION annot,
++                      FS_POINTF* buffer,
++                      unsigned long length) {
++  FPDF_ANNOTATION_SUBTYPE subtype = FPDFAnnot_GetSubtype(annot);
++  if (subtype != FPDF_ANNOT_POLYGON && subtype != FPDF_ANNOT_POLYLINE)
++    return 0;
 +
-+  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
++  CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
++  if (!annot_dict)
++    return 0;
 +
-+  CPDF_Array* inklist = pAnnotDict->GetArrayFor("InkList");
-+  if (!inklist)
++  CPDF_Array* vertices = annot_dict->GetArrayFor(pdfium::annotation::kVertices);
++  if (!vertices)
 +    return 0;
 +
-+  return static_cast<int>(inklist->size());
++  // Truncate to an even number.
++  unsigned long points_len = vertices->size() / 2;
++  if (buffer && length >= points_len) {
++    for (unsigned long i = 0; i < points_len; ++i) {
++      buffer[i].x = vertices->GetNumberAt(i * 2);
++      buffer[i].y = vertices->GetNumberAt(i * 2 + 1);
++    }
++  }
++
++  return points_len;
 +}
 +
-+FPDF_EXPORT int FPDF_CALLCONV
-+FPDFAnnot_GetInkStrokePointCount(FPDF_ANNOTATION annot, int index)
-+{
-+  if (FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_INK)
-+    return -1;
+ 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 93064561b..7159602db 100644
+--- a/public/fpdf_annot.h
++++ b/public/fpdf_annot.h
+@@ -395,6 +395,22 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot,
+ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
+                                                       FS_RECTF* rect);
+ 
++// Experimental API.
++// Get the vertices of a polygon or polyline annotation. |buffer| is an array of
++// points of the annotation. If |length| is less than the returned length, or
++// |annot| or |buffer| is NULL, |buffer| will not be modified.
++//
++//   annot  - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
++//   buffer - buffer for holding the points.
++//   length - length of the buffer in points.
++//
++// Returns the number of points if the annotation is of type polygon or
++// polyline, 0 otherwise.
++FPDF_EXPORT unsigned long FPDF_CALLCONV
++FPDFAnnot_GetVertices(FPDF_ANNOTATION annot,
++                      FS_POINTF* buffer,
++                      unsigned long length);
 +
-+  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
+ // Experimental API.
+ // Check if |annot|'s dictionary has |key| as a key.
+ //
+-- 
+2.26.2
+
+From 8f7b1aed53e31eda9870146cb97602f03a8f23c4 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Tue, 17 Nov 2020 16:53:14 +0000
+Subject: [PATCH] Add FPDFAnnot_GetInkListPath() API
+
+This is somewhat similar to FPDFAnnot_GetVertices(), but this is for ink
+annotations and here the value is an array of paths.
+
+So first add an FPDFAnnot_GetInkListCount() to get the number of paths,
+then FPDFAnnot_GetInkListPath() can be used to get the individual paths.
+
+Change-Id: I204a5a53e949fdbb7b264711c27107fe62c9f2be
+Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/76350
+Commit-Queue: Tom Sepez <tsepez at chromium.org>
+Reviewed-by: Tom Sepez <tsepez at chromium.org>
+---
+ constants/annotation_common.h       |  3 +
+ fpdfsdk/fpdf_annot.cpp              | 50 ++++++++++++++++
+ fpdfsdk/fpdf_annot_embeddertest.cpp | 91 ++++++++++++++++++++++++++++-
+ fpdfsdk/fpdf_view_c_api_test.c      |  2 +
+ public/fpdf_annot.h                 | 28 +++++++++
+ testing/resources/ink_annot.in      | 48 +++++++++++++++
+ testing/resources/ink_annot.pdf     | 60 +++++++++++++++++++
+ 7 files changed, 281 insertions(+), 1 deletion(-)
+ create mode 100644 testing/resources/ink_annot.in
+ create mode 100644 testing/resources/ink_annot.pdf
+
+diff --git a/constants/annotation_common.h b/constants/annotation_common.h
+index 6f96e623a..be6420651 100644
+--- a/constants/annotation_common.h
++++ b/constants/annotation_common.h
+@@ -29,6 +29,9 @@ constexpr char kOC[] = "OC";
+ // Entries for polygon and polyline annotations.
+ constexpr char kVertices[] = "Vertices";
+ 
++// Entries for ink annotations
++constexpr char kInkList[] = "InkList";
 +
-+  CPDF_Array* pInkList = pAnnotDict->GetArrayFor("InkList");
-+  if (!pInkList)
+ }  // namespace annotation
+ }  // namespace pdfium
+ 
+diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
+index 13c73f6aa..51b4332c2 100644
+--- a/fpdfsdk/fpdf_annot.cpp
++++ b/fpdfsdk/fpdf_annot.cpp
+@@ -296,6 +296,18 @@ CPDFSDK_Widget* GetRadioButtonOrCheckBoxWidget(FPDF_FORMHANDLE hHandle,
+   return pFormControl ? pForm->GetWidget(pFormControl) : nullptr;
+ }
+ 
++CPDF_Array* GetInkList(FPDF_ANNOTATION annot) {
++  FPDF_ANNOTATION_SUBTYPE subtype = FPDFAnnot_GetSubtype(annot);
++  if (subtype != FPDF_ANNOT_INK)
 +    return 0;
 +
-+  CPDF_Array* pInkPoints = pInkList->GetArrayAt(index);
-+  if (!pInkPoints)
++  CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
++  if (!annot_dict)
 +    return 0;
 +
-+  return static_cast<int>(pInkPoints->size() / 2);
-+}
-+
-+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
-+FPDFAnnot_GetInkStrokePoints(FPDF_ANNOTATION annot, int index,
-+                             FS_POINTF* points)
-+{
-+  if (FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_INK)
-+    return false;
-+
-+  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
-+
-+  CPDF_Array* pInkList = pAnnotDict->GetArrayFor("InkList");
-+  if (!pInkList)
-+    return false;
-+  CPDF_Array* pInkPoints = pInkList->GetArrayAt(index);
-+  if (!pInkPoints)
-+    return false;
-+
-+  for (int i = 0; i < pInkPoints->size(); i += 2) {
-+      int pointIndex = i / 2;
-+      points[pointIndex].x = pInkPoints->GetNumberAt(i);
-+      points[pointIndex].y = pInkPoints->GetNumberAt(i + 1);
-+  }
-+
-+  return true;
++  return annot_dict->GetArrayFor(pdfium::annotation::kInkList);
 +}
 +
+ }  // namespace
+ 
  FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
- FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
-   CPDF_AnnotContext* pAnnot = CPDFAnnotContextFromFPDFAnnotation(annot);
-@@ -806,6 +865,48 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
-   return true;
+@@ -837,6 +849,44 @@ FPDFAnnot_GetVertices(FPDF_ANNOTATION annot,
+   return points_len;
  }
-
-+FPDF_EXPORT int FPDF_CALLCONV
-+FPDFAnnot_GetVerticesCount(FPDF_ANNOTATION annot)
-+{
-+  if (FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_POLYGON &&
-+      FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_POLYLINE) {
-+    return -1;
-+  }
-+
-+  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
-+
-+  CPDF_Array* pVertices = pAnnotDict->GetArrayFor("Vertices");
-+
-+  if (!pVertices)
+ 
++FPDF_EXPORT unsigned long FPDF_CALLCONV
++FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot) {
++  CPDF_Array* ink_list = GetInkList(annot);
++  if (!ink_list)
 +    return 0;
 +
-+  return static_cast<int>(pVertices->size() / 2);
++  return ink_list->size();
 +}
 +
-+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
-+FPDFAnnot_GetVertices(FPDF_ANNOTATION annot, FS_POINTF* points)
-+{
-+  if (FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_POLYGON &&
-+      FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_POLYLINE) {
-+    return false;
-+  }
-+
-+  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
++FPDF_EXPORT unsigned long FPDF_CALLCONV
++FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot,
++                         unsigned long path_index,
++                         FS_POINTF* buffer,
++                         unsigned long length) {
++  unsigned long path_count = FPDFAnnot_GetInkListCount(annot);
++  if (path_index >= path_count)
++    return 0;
 +
-+  CPDF_Array* pVertices = pAnnotDict->GetArrayFor("Vertices");
++  CPDF_Array* ink_list = GetInkList(annot);
++  if (!ink_list)
++    return 0;
 +
-+  if (!pVertices)
-+    return false;
++  CPDF_Array* path = ink_list->GetArrayAt(path_index);
++  if (!path)
++    return 0;
 +
-+  for (int i = 0; i < pVertices->size(); i += 2) {
-+      int pointIndex = i / 2;
-+      points[pointIndex].x = pVertices->GetNumberAt(i);
-+      points[pointIndex].y = pVertices->GetNumberAt(i + 1);
++  // Truncate to an even number.
++  unsigned long points_len = path->size() / 2;
++  if (buffer && length >= points_len) {
++    for (unsigned long i = 0; i < points_len; ++i) {
++      buffer[i].x = path->GetNumberAt(i * 2);
++      buffer[i].y = path->GetNumberAt(i * 2 + 1);
++    }
 +  }
 +
-+  return true;
++  return points_len;
 +}
 +
  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 9561d8416..2176450c8 100644
+index 7159602db..d121344f7 100644
 --- a/public/fpdf_annot.h
 +++ b/public/fpdf_annot.h
-@@ -222,6 +222,16 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_AddInkStroke(FPDF_ANNOTATION annot,
- FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
- FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot);
-
-+FPDF_EXPORT int FPDF_CALLCONV
-+FPDFAnnot_GetInkStrokeCount(FPDF_ANNOTATION annot);
-+
-+FPDF_EXPORT int FPDF_CALLCONV
-+FPDFAnnot_GetInkStrokePointCount(FPDF_ANNOTATION annot, int index);
+@@ -411,6 +411,34 @@ FPDFAnnot_GetVertices(FPDF_ANNOTATION annot,
+                       FS_POINTF* buffer,
+                       unsigned long length);
+ 
++// Experimental API.
++// Get the number of paths in the ink list of an ink annotation.
++//
++//   annot  - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
++//
++// Returns the number of paths in the ink list if the annotation is of type ink,
++// 0 otherwise.
++FPDF_EXPORT unsigned long FPDF_CALLCONV
++FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot);
 +
-+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
-+FPDFAnnot_GetInkStrokePoints(FPDF_ANNOTATION annot, int index,
-+                             FS_POINTF* points);
-+
- // Experimental API.
- // Add |obj| to |annot|. |obj| must have been created by
- // FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and
-@@ -394,6 +404,12 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot,
- FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
-                                                       FS_RECTF* rect);
-
-+FPDF_EXPORT int FPDF_CALLCONV
-+FPDFAnnot_GetVerticesCount(FPDF_ANNOTATION annot);
-+
-+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
-+FPDFAnnot_GetVertices(FPDF_ANNOTATION annot, FS_POINTF* points);
++// Experimental API.
++// Get a path in the ink list of an ink annotation. |buffer| is an array of
++// points of the path. If |length| is less than the returned length, or |annot|
++// or |buffer| is NULL, |buffer| will not be modified.
++//
++//   annot  - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
++//   path_index - index of the path
++//   buffer - buffer for holding the points.
++//   length - length of the buffer in points.
++//
++// Returns the number of points of the path if the annotation is of type ink, 0
++// otherwise.
++FPDF_EXPORT unsigned long FPDF_CALLCONV
++FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot,
++                         unsigned long path_index,
++                         FS_POINTF* buffer,
++                         unsigned long length);
 +
  // Experimental API.
  // Check if |annot|'s dictionary has |key| as a key.
  //
---
+-- 
 2.26.2
+
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 at 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 at chromium.org>
+Reviewed-by: Tom Sepez <tsepez at 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
 
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index 87012e73f931..cc7e0ff58d0c 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -14,9 +14,13 @@ pdfium_patches += build.patch.1
 # Avoids Windows 8 build dependency.
 pdfium_patches += windows7.patch.1
 pdfium_patches += c++20-comparison.patch
+# Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/76050> and
+# <https://pdfium-review.googlesource.com/c/pdfium/+/76350>.
 pdfium_patches += AnnotationInkAndVertices.patch.1
-pdfium_patches += AnnotationBorderProperties.patch.1
+# Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/76730>.
 pdfium_patches += AnnotationLineStartAndEnd.patch.1
+# Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/77010>.
+pdfium_patches += AnnotationBorderProperties.patch.1
 # Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/75910>.
 pdfium_patches += SignatureGetDocMDPPermission.patch.1
 # Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/76850>.
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 78abdc433fa6..6b535c52c5e2 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -885,15 +885,15 @@ OUString PDFiumAnnotation::getString(OString const& rKey)
 std::vector<std::vector<basegfx::B2DPoint>> PDFiumAnnotation::getInkStrokes()
 {
     std::vector<std::vector<basegfx::B2DPoint>> aB2DPointList;
-    int nInkStrokes = FPDFAnnot_GetInkStrokeCount(mpAnnotation);
+    int nInkStrokes = FPDFAnnot_GetInkListCount(mpAnnotation);
     for (int i = 0; i < nInkStrokes; i++)
     {
         std::vector<basegfx::B2DPoint> aB2DPoints;
-        int nPoints = FPDFAnnot_GetInkStrokePointCount(mpAnnotation, i);
+        int nPoints = FPDFAnnot_GetInkListPath(mpAnnotation, i, nullptr, 0);
         if (nPoints)
         {
             std::vector<FS_POINTF> aPoints(nPoints);
-            if (FPDFAnnot_GetInkStrokePoints(mpAnnotation, i, aPoints.data()))
+            if (FPDFAnnot_GetInkListPath(mpAnnotation, i, aPoints.data(), aPoints.size()))
             {
                 for (auto const& rPoint : aPoints)
                 {
@@ -909,11 +909,11 @@ std::vector<std::vector<basegfx::B2DPoint>> PDFiumAnnotation::getInkStrokes()
 std::vector<basegfx::B2DPoint> PDFiumAnnotation::getVertices()
 {
     std::vector<basegfx::B2DPoint> aB2DPoints;
-    int nPoints = FPDFAnnot_GetVerticesCount(mpAnnotation);
+    int nPoints = FPDFAnnot_GetVertices(mpAnnotation, nullptr, 0);
     if (nPoints)
     {
         std::vector<FS_POINTF> aPoints(nPoints);
-        if (FPDFAnnot_GetVertices(mpAnnotation, aPoints.data()))
+        if (FPDFAnnot_GetVertices(mpAnnotation, aPoints.data(), aPoints.size()))
         {
             for (auto const& rPoint : aPoints)
                 aB2DPoints.emplace_back(rPoint.x, rPoint.y);


More information about the Libreoffice-commits mailing list