diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-06-18 13:30:38 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-21 13:32:08 +0200 |
commit | 3870dd43e94c440a5094a57c47d3b7565658d73c (patch) | |
tree | a2021624905ce3f4a0e120e18a924bd63c1e6b49 /sd | |
parent | c72698b33779924877cd6fb103c270df297ee564 (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 'sd')
-rw-r--r-- | sd/source/filter/pdf/sdpdffilter.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index 2b09bc9e828e..da989974bc87 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -29,6 +29,11 @@ #include <vcl/graph.hxx> #include <vcl/pdfread.hxx> +#include <com/sun/star/office/XAnnotation.hpp> +#include <com/sun/star/text/XText.hpp> + +using namespace css; + SdPdfFilter::SdPdfFilter(SfxMedium& rMedium, sd::DrawDocShell& rDocShell) : SdFilter(rMedium, rDocShell) { @@ -65,11 +70,28 @@ bool SdPdfFilter::Import() // Make the page size match the rendered image. pPage->SetSize(aSizeHMM); - Point aPosition(0, 0); SdrGrafObj* pSdrGrafObj = new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic, - tools::Rectangle(aPosition, aSizeHMM)); + tools::Rectangle(Point(), aSizeHMM)); pPage->InsertObject(pSdrGrafObj); + + for (auto const& rPDFAnnotation : rPDFGraphicResult.maAnnotations) + { + uno::Reference<office::XAnnotation> xAnnotation; + pPage->createAnnotation(xAnnotation); + + xAnnotation->setAuthor(rPDFAnnotation.maAuthor); + + uno::Reference<text::XText> xText(xAnnotation->getTextRange()); + xText->setString(rPDFAnnotation.maText); + // position is in mm not 100thmm + geometry::RealPoint2D aUnoPosition(rPDFAnnotation.maRectangle.getMinX() / 100.0, + rPDFAnnotation.maRectangle.getMinY() / 100.00); + geometry::RealSize2D aUnoSize(rPDFAnnotation.maRectangle.getWidth() / 100.0, + rPDFAnnotation.maRectangle.getHeight() / 100.00); + xAnnotation->setPosition(aUnoPosition); + xAnnotation->setSize(aUnoSize); + } } return true; |