summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-06-18 13:30:38 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-21 13:32:08 +0200
commit3870dd43e94c440a5094a57c47d3b7565658d73c (patch)
treea2021624905ce3f4a0e120e18a924bd63c1e6b49 /vcl
parentc72698b33779924877cd6fb103c270df297ee564 (diff)
sd: support adding PDF text / pop-up annotations as comments
Change-Id: I3e072f011089864f3349a470a32412cc33bcc022 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96758 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx31
1 files changed, 30 insertions, 1 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 9845c6c387c4..b5e63937bf00 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -278,7 +278,36 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG
Graphic aGraphic(aVectorGraphicDataPtr);
aGraphic.SetGfxLink(pGfxLink);
- rGraphics.emplace_back(std::move(aGraphic), Size(nPageWidth, nPageHeight));
+ auto pPage = pPdfDocument->openPage(nPageIndex);
+
+ std::vector<PDFGraphicAnnotation> aPDFGraphicAnnotations;
+ for (int nAnnotation = 0; nAnnotation < pPage->getAnnotationCount(); nAnnotation++)
+ {
+ auto pAnnotation = pPage->getAnnotation(nAnnotation);
+ if (pAnnotation && pAnnotation->getSubType() == 1 /*FPDF_ANNOT_TEXT*/
+ && pAnnotation->hasKey(vcl::pdf::constDictionaryKeyPopup))
+ {
+ OUString sAuthor = pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle);
+ OUString sText = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
+ auto pPopupAnnotation = pAnnotation->getLinked(vcl::pdf::constDictionaryKeyPopup);
+
+ basegfx::B2DRectangle rRectangle = pAnnotation->getRectangle();
+ basegfx::B2DRectangle rRectangleHMM(
+ convertPointToMm100(rRectangle.getMinX()),
+ convertPointToMm100(aPageSize.getY() - rRectangle.getMinY()),
+ convertPointToMm100(rRectangle.getMaxX()),
+ convertPointToMm100(aPageSize.getY() - rRectangle.getMaxY()));
+
+ PDFGraphicAnnotation aPDFGraphicAnnotation;
+ aPDFGraphicAnnotation.maRectangle = rRectangleHMM;
+ aPDFGraphicAnnotation.maAuthor = sAuthor;
+ aPDFGraphicAnnotation.maText = sText;
+ aPDFGraphicAnnotations.push_back(aPDFGraphicAnnotation);
+ }
+ }
+
+ rGraphics.emplace_back(std::move(aGraphic), Size(nPageWidth, nPageHeight),
+ aPDFGraphicAnnotations);
}
return rGraphics.size();