From bfdd033bfb9015cb2a2d18ab506b9cf307004ea2 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 16 Sep 2020 23:41:20 +0200 Subject: [PATCH] poppler: Convert Ink annotations via C++ Instead of via the magic XML cycle of Poppler::AnnotationUtils::storeAnnotation + Okular::AnnotationUtils::createAnnotation --- generators/poppler/annots.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp index 6ad04d545..c11119a6f 100644 --- a/generators/poppler/annots.cpp +++ b/generators/poppler/annots.cpp @@ -521,6 +521,25 @@ static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler:: return oHighlightAnn; } +static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler::InkAnnotation *popplerAnnotation) +{ + Okular::InkAnnotation *oInkAnn = new Okular::InkAnnotation(); + + const QList> popplerInkPaths = popplerAnnotation->inkPaths(); + QList> okularInkPaths; + for (const QLinkedList &popplerInkPath : popplerInkPaths) { + QLinkedList okularInkPath; + for (const QPointF &popplerPoint : popplerInkPath) { + okularInkPath << Okular::NormalizedPoint(popplerPoint.x(), popplerPoint.y()); + } + okularInkPaths << okularInkPath; + } + + oInkAnn->setInkPaths(okularInkPaths); + + return oInkAnn; +} + Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete) { Okular::Annotation *okularAnnotation = nullptr; @@ -616,7 +635,13 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast(popplerAnnotation)); break; } - case Poppler::Annotation::AInk: + case Poppler::Annotation::AInk: { + externallyDrawn = true; + tieToOkularAnn = true; + *doDelete = false; + okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast(popplerAnnotation)); + break; + } case Poppler::Annotation::ACaret: externallyDrawn = true; /* fallthrough */