From 342e427d33af0d4bfa694248e7a47fdf1f7f270d Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 14 Oct 2020 22:54:38 +0200 Subject: pdfium: add support for border property of PDF annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This extends PDFium with readon of "Border" property from the PDF annotations and adds the API to PDFium wrapper. Border is mostly used for border (line) width and the radius of rounding of the border (for drawing a rounded rectangle for example). Change-Id: I03f189eee03155ec699b2f56ceed23e6839a3f03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104361 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- external/pdfium/AnnotationBorderProperties.patch.1 | 60 ++++++++++++++++++++++ external/pdfium/UnpackedTarball_pdfium.mk | 1 + 2 files changed, 61 insertions(+) create mode 100644 external/pdfium/AnnotationBorderProperties.patch.1 (limited to 'external') diff --git a/external/pdfium/AnnotationBorderProperties.patch.1 b/external/pdfium/AnnotationBorderProperties.patch.1 new file mode 100644 index 000000000000..87f8f48beed9 --- /dev/null +++ b/external/pdfium/AnnotationBorderProperties.patch.1 @@ -0,0 +1,60 @@ +diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp +index c1471220b..229651d82 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, + 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) ++ return false; ++ ++ // If BA entry exists, then Border is ignored ++ if (pAnnotDict->KeyExist("BA")) ++ 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) ++ return false; ++ ++ *hor_radius = pBorderArray->GetNumberAt(0); ++ *vert_radius = pBorderArray->GetNumberAt(1); ++ *width = pBorderArray->GetNumberAt(2); ++ ++ return true; ++} ++ + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV + FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot) { + if (!annot) +diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h +index 2176450c8..ce033cde3 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); ++// 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 +-- +2.26.2 + diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index b5cbb6dc23df..5eccb92001eb 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -15,6 +15,7 @@ pdfium_patches += build.patch.1 pdfium_patches += windows7.patch.1 pdfium_patches += c++20-comparison.patch pdfium_patches += AnnotationInkAndVertices.patch.1 +pdfium_patches += AnnotationBorderProperties.patch.1 # Work around "c++20 rewritten operator== # recursive call mixing friend and external operators for template class" in GCC with -- cgit