summaryrefslogtreecommitdiff
path: root/vcl/source/pdf
diff options
context:
space:
mode:
authorJaume Pujantell <jaume.pujantell@collabora.com>2023-06-05 11:49:41 +0200
committerAndras Timar <andras.timar@collabora.com>2023-06-08 21:53:59 +0200
commit53d610786ba8085fcce331174c74294c90c41a20 (patch)
tree3f4af2f6ebc0a22b5070a0a951d79f6221309fa9 /vcl/source/pdf
parent260bc16e1923016d0628a8779e219b290d4c9011 (diff)
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 <andras.timar@collabora.com>
Diffstat (limited to 'vcl/source/pdf')
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx24
1 files changed, 18 insertions, 6 deletions
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()