include/vcl/pdf/PDFAnnotationMarker.hxx | 6 ++++++ sd/source/filter/pdf/sdpdffilter.cxx | 13 +++++++++++++ vcl/source/filter/ipdf/pdfread.cxx | 24 +++++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-)
New commits: commit 354080769f34207e3c850c61e62e8af346964463 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Thu Oct 15 14:35:26 2020 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Sun Oct 18 21:23:10 2020 +0200 sd: support line PDF annot. as custom marker This renderes the line marker, but line start and end symbol is for now not supported. Change-Id: Ibf099f54b4bc047b22dae32c705982c8cb24388b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104377 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/vcl/pdf/PDFAnnotationMarker.hxx b/include/vcl/pdf/PDFAnnotationMarker.hxx index 2c525f85cbd5..d797115437e9 100644 --- a/include/vcl/pdf/PDFAnnotationMarker.hxx +++ b/include/vcl/pdf/PDFAnnotationMarker.hxx @@ -45,6 +45,12 @@ struct VCL_DLLPUBLIC PDFAnnotationMarkerPolygon : public PDFAnnotationMarker basegfx::B2DPolygon maPolygon; }; +struct VCL_DLLPUBLIC PDFAnnotationMarkerLine : public PDFAnnotationMarker +{ + basegfx::B2DPoint maLineStart; + basegfx::B2DPoint maLineEnd; +}; + enum class PDFTextMarkerType { Highlight, diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index e903c015d4be..4b52f9e4b574 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -170,6 +170,19 @@ bool SdPdfFilter::Import() if (rCustomAnnotationMarker.maFillColor.GetTransparency() == 0) rCustomAnnotationMarker.maFillColor.SetTransparency(0x90); } + else if (rPDFAnnotation.meSubType == vcl::pdf::PDFAnnotationSubType::Line) + { + auto* pMarker = static_cast<vcl::pdf::PDFAnnotationMarkerLine*>( + rPDFAnnotation.mpMarker.get()); + + basegfx::B2DPolygon aPoly; + aPoly.append(pMarker->maLineStart); + aPoly.append(pMarker->maLineEnd); + rCustomAnnotationMarker.maPolygons.push_back(aPoly); + + rCustomAnnotationMarker.mnLineWidth = pMarker->mnWidth; + rCustomAnnotationMarker.maFillColor = COL_TRANSPARENT; + } } } } diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index 9be28fcf0c9b..3ccad9b10ecc 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -259,7 +259,8 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D || eSubtype == vcl::pdf::PDFAnnotationSubType::Circle || eSubtype == vcl::pdf::PDFAnnotationSubType::Square || eSubtype == vcl::pdf::PDFAnnotationSubType::Ink - || eSubtype == vcl::pdf::PDFAnnotationSubType::Highlight) + || eSubtype == vcl::pdf::PDFAnnotationSubType::Highlight + || eSubtype == vcl::pdf::PDFAnnotationSubType::Line) { OUString sAuthor = pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle); OUString sText = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents); @@ -394,6 +395,27 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D } } } + else if (eSubtype == vcl::pdf::PDFAnnotationSubType::Line) + { + auto const& rLineGeometry = pAnnotation->getLineGeometry(); + if (!rLineGeometry.empty()) + { + double x, y; + auto pMarker = std::make_shared<vcl::pdf::PDFAnnotationMarkerLine>(); + rPDFGraphicAnnotation.mpMarker = pMarker; + + x = convertPointToMm100(rLineGeometry[0].getX()); + y = convertPointToMm100(aPageSize.getY() - rLineGeometry[0].getY()); + pMarker->maLineStart = basegfx::B2DPoint(x, y); + + x = convertPointToMm100(rLineGeometry[1].getX()); + y = convertPointToMm100(aPageSize.getY() - rLineGeometry[1].getY()); + pMarker->maLineEnd = basegfx::B2DPoint(x, y); + + float fWidth = pAnnotation->getBorderWidth(); + pMarker->mnWidth = convertPointToMm100(fWidth); + } + } } } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
