summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-10-15 11:22:07 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-10-18 21:21:18 +0200
commit560d3b95840221fe9661d46682af7c4ce897193b (patch)
tree48b8e741d128d33d43148fb4668084140b5a2cc3 /vcl
parentfb3965470a79d5b45bd211e9f95775c75e793cc8 (diff)
sd: support ink PDF annot. as custom marker
Ink PDF annotation is similar to a set of polylines (or freehand drawing), so we can again just reuse the polygon code paths. The difference to the polygon is that the polygon is closed. Change-Id: I99641dccc0b2f9f2d3ebf2c71d3e20f8b1d0a485 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104367 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx27
1 files changed, 26 insertions, 1 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 001303194259..a0e9b51e28a8 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -257,7 +257,8 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D
if (eSubtype == vcl::pdf::PDFAnnotationSubType::Text
|| eSubtype == vcl::pdf::PDFAnnotationSubType::Polygon
|| eSubtype == vcl::pdf::PDFAnnotationSubType::Circle
- || eSubtype == vcl::pdf::PDFAnnotationSubType::Square)
+ || eSubtype == vcl::pdf::PDFAnnotationSubType::Square
+ || eSubtype == vcl::pdf::PDFAnnotationSubType::Ink)
{
OUString sAuthor = pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle);
OUString sText = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
@@ -326,6 +327,30 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D
if (pAnnotation->hasKey(vcl::pdf::constDictionaryKeyInteriorColor))
pMarker->maFillColor = pAnnotation->getInteriorColor();
}
+ else if (eSubtype == vcl::pdf::PDFAnnotationSubType::Ink)
+ {
+ auto const& rStrokesList = pAnnotation->getInkStrokes();
+ if (!rStrokesList.empty())
+ {
+ auto pMarker = std::make_shared<vcl::pdf::PDFAnnotationMarkerInk>();
+ rPDFGraphicAnnotation.mpMarker = pMarker;
+ for (auto const& rStrokes : rStrokesList)
+ {
+ basegfx::B2DPolygon aPolygon;
+ for (auto const& rVertex : rStrokes)
+ {
+ double x = convertPointToMm100(rVertex.getX());
+ double y = convertPointToMm100(aPageSize.getY() - rVertex.getY());
+ aPolygon.append({ x, y });
+ }
+ pMarker->maStrokes.push_back(aPolygon);
+ }
+ float fWidth = pAnnotation->getBorderWidth();
+ pMarker->mnWidth = convertPointToMm100(fWidth);
+ if (pAnnotation->hasKey(vcl::pdf::constDictionaryKeyInteriorColor))
+ pMarker->maFillColor = pAnnotation->getInteriorColor();
+ }
+ }
}
}
}