summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-10-15 14:35:26 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-10-18 21:23:10 +0200
commit354080769f34207e3c850c61e62e8af346964463 (patch)
treeb8718929b74ae0f6e217298918857e95faf4b9bf
parentaa301119c98bc5103d3738263b1df90b30013e32 (diff)
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 <quikee@gmail.com>
-rw-r--r--include/vcl/pdf/PDFAnnotationMarker.hxx6
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx13
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx24
3 files changed, 42 insertions, 1 deletions
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);
+ }
+ }
}
}
}