summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/pdf/PDFAnnotationMarker.hxx19
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx13
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx45
3 files changed, 76 insertions, 1 deletions
diff --git a/include/vcl/pdf/PDFAnnotationMarker.hxx b/include/vcl/pdf/PDFAnnotationMarker.hxx
index f2841b09db6c..2c525f85cbd5 100644
--- a/include/vcl/pdf/PDFAnnotationMarker.hxx
+++ b/include/vcl/pdf/PDFAnnotationMarker.hxx
@@ -45,6 +45,25 @@ struct VCL_DLLPUBLIC PDFAnnotationMarkerPolygon : public PDFAnnotationMarker
basegfx::B2DPolygon maPolygon;
};
+enum class PDFTextMarkerType
+{
+ Highlight,
+ Underline,
+ Squiggly,
+ StrikeOut
+};
+
+struct VCL_DLLPUBLIC PDFAnnotationMarkerHighlight : public PDFAnnotationMarker
+{
+ std::vector<basegfx::B2DPolygon> maQuads;
+ PDFTextMarkerType meTextMarkerType;
+
+ PDFAnnotationMarkerHighlight(PDFTextMarkerType eTextMarkerType)
+ : meTextMarkerType(eTextMarkerType)
+ {
+ }
+};
+
} // namespace vcl::pdf
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index b2866dd1701d..5e190f8a0117 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -154,6 +154,19 @@ bool SdPdfFilter::Import()
rCustomAnnotationMarker.mnLineWidth = pMarker->mnWidth;
rCustomAnnotationMarker.maFillColor = pMarker->maFillColor;
}
+ else if (rPDFAnnotation.meSubType == vcl::pdf::PDFAnnotationSubType::Highlight)
+ {
+ if (rCustomAnnotationMarker.maLineColor.GetTransparency() == 0)
+ rCustomAnnotationMarker.maLineColor.SetTransparency(0x90);
+ auto* pMarker = static_cast<vcl::pdf::PDFAnnotationMarkerHighlight*>(
+ rPDFAnnotation.mpMarker.get());
+ for (auto const& rPolygon : pMarker->maQuads)
+ rCustomAnnotationMarker.maPolygons.push_back(rPolygon);
+ rCustomAnnotationMarker.mnLineWidth = 1;
+ rCustomAnnotationMarker.maFillColor = rPDFAnnotation.maColor;
+ if (rCustomAnnotationMarker.maFillColor.GetTransparency() == 0)
+ rCustomAnnotationMarker.maFillColor.SetTransparency(0x90);
+ }
}
}
}
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);
+ }
+ }
+ }
+ }
}
}
}