summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-10-15 12:23:08 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-10-18 21:22:03 +0200
commit7ea49126e7a247ac60ad45ab420106fe4be574ea (patch)
tree3bcc90a13499bb4eb0fd0f584d40f70b2c44d97e /vcl
parent81a9e0eb98eacfb50ee1b30d1bbaea7a02594cc6 (diff)
sd: support text annotation PDF annot. as custom marker
This one is special as it annotates text. Normally the annotation would be present behind the text, but this is not possible in this case, so the best alternative is to use a transparent rectangle over the text. Change-Id: Ib115efa4a5994e17dcf9d7b02591ccae26800928 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104369 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx45
1 files changed, 44 insertions, 1 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index a0e9b51e28a8..9be28fcf0c9b 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -258,7 +258,8 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D
|| eSubtype == vcl::pdf::PDFAnnotationSubType::Polygon
|| eSubtype == vcl::pdf::PDFAnnotationSubType::Circle
|| eSubtype == vcl::pdf::PDFAnnotationSubType::Square
- || eSubtype == vcl::pdf::PDFAnnotationSubType::Ink)
+ || eSubtype == vcl::pdf::PDFAnnotationSubType::Ink
+ || eSubtype == vcl::pdf::PDFAnnotationSubType::Highlight)
{
OUString sAuthor = pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle);
OUString sText = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
@@ -351,6 +352,48 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D
pMarker->maFillColor = pAnnotation->getInteriorColor();
}
}
+ else if (eSubtype == vcl::pdf::PDFAnnotationSubType::Highlight)
+ {
+ size_t nCount = pAnnotation->getAttachmentPointsCount();
+ if (nCount > 0)
+ {
+ auto pMarker = std::make_shared<vcl::pdf::PDFAnnotationMarkerHighlight>(
+ vcl::pdf::PDFTextMarkerType::Highlight);
+ rPDFGraphicAnnotation.mpMarker = pMarker;
+ for (size_t i = 0; i < nCount; ++i)
+ {
+ auto aAttachmentPoints = pAnnotation->getAttachmentPoints(i);
+ if (!aAttachmentPoints.empty())
+ {
+ double x, y;
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.setClosed(true);
+
+ x = convertPointToMm100(aAttachmentPoints[0].getX());
+ y = convertPointToMm100(aPageSize.getY()
+ - aAttachmentPoints[0].getY());
+ aPolygon.append({ x, y });
+
+ x = convertPointToMm100(aAttachmentPoints[1].getX());
+ y = convertPointToMm100(aPageSize.getY()
+ - aAttachmentPoints[1].getY());
+ aPolygon.append({ x, y });
+
+ x = convertPointToMm100(aAttachmentPoints[3].getX());
+ y = convertPointToMm100(aPageSize.getY()
+ - aAttachmentPoints[3].getY());
+ aPolygon.append({ x, y });
+
+ x = convertPointToMm100(aAttachmentPoints[2].getX());
+ y = convertPointToMm100(aPageSize.getY()
+ - aAttachmentPoints[2].getY());
+ aPolygon.append({ x, y });
+
+ pMarker->maQuads.push_back(aPolygon);
+ }
+ }
+ }
+ }
}
}
}