From 53d610786ba8085fcce331174c74294c90c41a20 Mon Sep 17 00:00:00 2001 From: Jaume Pujantell Date: Mon, 5 Jun 2023 11:49:41 +0200 Subject: pdfium: better suport for annotations and some fixes Added suport to import FreeText annotations. Added some suport to export graphical annotations. Fixed some color issues to be more inline with the pdfium library. Change-Id: I7371595ebb95594ee765ae532ca7c7d4f0499592 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152606 Tested-by: Jenkins Reviewed-by: Andras Timar --- vcl/source/pdf/PDFiumLibrary.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'vcl/source/pdf') diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index e0562c4dbf9b..c445e5e5ad98 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -1126,24 +1126,36 @@ basegfx::B2DRectangle PDFiumAnnotationImpl::getRectangle() Color PDFiumAnnotationImpl::getColor() { - Color aColor = COL_TRANSPARENT; unsigned int nR, nG, nB, nA; if (FPDFAnnot_GetColor(mpAnnotation, FPDFANNOT_COLORTYPE_Color, &nR, &nG, &nB, &nA)) { - aColor = Color(ColorAlpha, nA, nR, nG, nB); + return Color(ColorAlpha, nA, nR, nG, nB); } - return aColor; + // FPDFAnnot_GetColor can return false if there is an appearance stream + // So we search for a color with getStrokeColor + for (int i = 0; i < getObjectCount(); ++i) + { + if (getObject(i)->getType() == PDFPageObjectType::Path) + return getObject(i)->getStrokeColor(); + } + return COL_TRANSPARENT; } Color PDFiumAnnotationImpl::getInteriorColor() { - Color aColor = COL_TRANSPARENT; unsigned int nR, nG, nB, nA; if (FPDFAnnot_GetColor(mpAnnotation, FPDFANNOT_COLORTYPE_InteriorColor, &nR, &nG, &nB, &nA)) { - aColor = Color(ColorAlpha, nA, nR, nG, nB); + return Color(ColorAlpha, nA, nR, nG, nB); } - return aColor; + // FPDFAnnot_GetColor can return false if there is an appearance stream + // So we search for a color with getFillColor + for (int i = 0; i < getObjectCount(); ++i) + { + if (getObject(i)->getType() == PDFPageObjectType::Path) + return getObject(i)->getFillColor(); + } + return COL_TRANSPARENT; } size_t PDFiumAnnotationImpl::getAttachmentPointsCount() -- cgit